/* emotions CMS: brand from www.emotions.ch (orange #e65425, black, Libre Caslon Text + Inter).
   Fonts are self-hosted because the dashboard CSP only allows same-origin resources. */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("fonts/inter-latin.woff2") format("woff2"); }
@font-face { font-family: "Libre Caslon Text"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/libre-caslon-text-400.woff2") format("woff2"); }
@font-face { font-family: "Libre Caslon Text"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/libre-caslon-text-700.woff2") format("woff2"); }
@font-face { font-family: "Libre Caslon Text"; font-style: italic; font-weight: 400; font-display: swap; src: url("fonts/libre-caslon-text-400-italic.woff2") format("woff2"); }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --brand: #e65425;
    --bg: #000;
    --panel: #121212;
    --panel-2: #1c1c1c;
    --field: #0a0a0a;
    --line: #262626;
    --line-strong: #3a3a3a;
    --text: #f5f5f5;
    --muted: #a3a3a3;
    --dim: #737373;
    /* Brand orange darkened just enough for white button text to reach WCAG AA */
    --accent: #cc4417;
    --accent-hover: #b23a12;
    --accent-text: #f07a55;
    --ok: #5ccf7a;
    --err: #ff6b6b;
    --warn: #f0b429;
    --focus: #f07a55;
    --radius: 2px;
    --serif: "Libre Caslon Text", Georgia, serif;
    --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color-scheme: dark;
}

html { -webkit-text-size-adjust: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 var(--sans);
    min-height: 100vh;
}

a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 0.82rem; }
.empty { color: var(--muted); padding: 0.5rem 0; }
.error { color: var(--err); font-size: 0.9rem; margin: 0 0 1rem; }

main { max-width: 1120px; margin: 0 auto; padding: 2rem 1.5rem 4rem; outline: none; }
/* main receives focus after route changes (for screen readers); no focus ring around the whole page */
main:focus, main:focus-visible { outline: none; }
main.narrow { max-width: 400px; padding-top: 12vh; }

/* Top bar (orange navbar with the white flag logo, as on emotions.ch) */
.topbar { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 0 1.5rem; height: 64px; display: flex; align-items: center; gap: 2rem; }
.topbar :focus-visible { outline-color: #fff; }
.brand { display: flex; align-items: center; gap: 0.9rem; text-decoration: none; white-space: nowrap; color: #fff; }
.brand img { display: block; width: 132px; height: auto; }
.brand-product { font-size: 0.95rem; font-weight: 500; letter-spacing: 0.02em; }
.tabs { display: flex; gap: 1.75rem; flex: 1; justify-content: flex-end; }
.tabs a { text-decoration: none; color: #fff; padding: 0.4rem 0; font-size: 0.95rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 2px solid transparent; }
.tabs a:hover { border-bottom-color: rgba(255, 255, 255, 0.6); }
.tabs a[aria-current="page"] { border-bottom-color: #fff; }

.menu { position: relative; padding-left: 1.25rem; border-left: 1px solid rgba(255, 255, 255, 0.7); }
.menu-trigger { display: flex; align-items: center; gap: 0.6rem; background: none; border: 1px solid transparent; color: #fff; font: inherit; font-size: 0.9rem; padding: 0.3rem 0.5rem; cursor: pointer; }
.menu-trigger:hover, .menu-trigger[aria-expanded="true"] { background: rgba(0, 0, 0, 0.12); }
.menu-panel { color: var(--text); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 0.8rem; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); width: 260px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0.5rem; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5); }
.menu-head { padding: 0.5rem 0.6rem 0.75rem; border-bottom: 1px solid var(--line); margin-bottom: 0.5rem; display: flex; flex-direction: column; }
.menu-head span { color: var(--muted); font-size: 0.8rem; }
.menu-label { padding: 0 0.6rem; font-size: 0.75rem; }
.menu-panel select { margin: 0.25rem 0.6rem 0.5rem; width: calc(100% - 1.2rem); }
.menu-item { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); font: inherit; font-size: 0.9rem; padding: 0.5rem 0.6rem; border-radius: var(--radius); cursor: pointer; text-decoration: none; }
.menu-item:hover { background: var(--panel-2); }

/* Page head */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { font-family: var(--serif); font-size: 2.1rem; font-weight: 700; line-height: 1.15; }
.page-head .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.crumb { display: inline-block; color: var(--muted); text-decoration: none; font-size: 0.85rem; margin-bottom: 0.35rem; }
.crumb:hover { color: var(--accent-text); }
.link-quiet { text-decoration: none; font-size: 0.85rem; }
.link-quiet:hover { color: var(--accent-text); text-decoration: underline; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    font: inherit; font-size: 0.875rem; line-height: 1.2;
    padding: 0.55rem 0.95rem; min-height: 38px;
    border-radius: var(--radius); border: 1px solid var(--line-strong);
    background: var(--panel-2); color: var(--text);
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: #24242a; border-color: #4a4a52; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger-solid { background: #a11212; border-color: #a11212; }
.btn-ghost-danger { background: none; border-color: transparent; color: var(--err); }
.btn-ghost-danger:hover { background: #2a1313; border-color: #4a1d1d; }
.btn-sm { min-height: 32px; padding: 0.35rem 0.7rem; font-size: 0.82rem; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.5rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-head h2 { font-family: var(--serif); font-size: 1.2rem; font-weight: 700; }
.empty-card { text-align: center; padding: 3rem 1.5rem; color: var(--muted); }

.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.site-card { text-decoration: none; display: flex; flex-direction: column; gap: 0.35rem; transition: border-color 0.15s, background 0.15s; }
.site-card:hover { border-color: var(--brand); background: var(--panel-2); }
.site-card h2 { font-family: var(--serif); font-size: 1.35rem; font-weight: 700; }
.chips { display: flex; gap: 0.35rem; margin-top: 0.5rem; }
.chip { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0.1rem 0.4rem; }

/* Site view */
.site-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.segmented button { background: none; border: 0; color: var(--muted); font: inherit; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em; padding: 0.3rem 0.75rem; cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--line-strong); }
.segmented button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); }
.search { margin-bottom: 0.75rem; }

.page-list { list-style: none; }
.page-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 1rem; padding: 0.7rem 0; border-top: 1px solid var(--line); }
.page-row:first-child { border-top: 0; }
.page-main { display: flex; flex-direction: column; min-width: 0; }
.page-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-path { color: var(--dim); font-size: 0.8rem; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-meta { color: var(--muted); font-size: 0.8rem; text-align: right; white-space: nowrap; }

.activity { list-style: none; }
.activity li { padding: 0.6rem 0; border-top: 1px solid var(--line); font-size: 0.875rem; }
.activity li:first-child { border-top: 0; padding-top: 0; }
.activity-page { color: var(--text); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.82rem; }
.page-row:hover .btn-edit, .btn-edit:focus-visible { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Tables */
.table-card { padding: 0.25rem 1.5rem; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
th, td { padding: 0.8rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.cell-actions { text-align: right; white-space: nowrap; }
.cell-actions .btn + .btn { margin-left: 0.35rem; }
.tag { display: inline-block; font-size: 0.75rem; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0.1rem 0.45rem; color: var(--muted); }
.tag-admin { color: #fff; border-color: var(--accent); background: rgba(230, 84, 37, 0.18); }

/* Forms */
.field { margin-bottom: 1rem; border: 0; }
label, legend { display: block; color: var(--muted); font-size: 0.82rem; margin-bottom: 0.35rem; }
input, select, textarea {
    width: 100%;
    padding: 0.6rem 0.7rem;
    background: var(--field);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(230, 84, 37, 0.25); }
input[readonly] { color: var(--muted); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.input-group { display: flex; gap: 0.4rem; }
.input-group input { flex: 1; min-width: 0; }
.hint { color: var(--dim); font-size: 0.78rem; margin-top: 0.3rem; }
.check { display: flex; align-items: center; gap: 0.6rem; color: var(--text); font-size: 0.9rem; padding: 0.3rem 0; cursor: pointer; }
.site-access { padding: 0.75rem 0.9rem; border: 1px solid var(--line); border-radius: var(--radius); }
.site-access legend { padding: 0 0.3rem; }

.status { font-size: 0.82rem; margin-top: 0.4rem; min-height: 1.2em; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.status.loading { color: var(--muted); }

.notice { border: 1px solid #5a4a1a; background: #1d180a; color: #f3d98b; border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1.5rem; }

/* Login & setup */
.form-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem; }
.form-card h1 { font-family: var(--serif); font-size: 1.6rem; font-weight: 700; line-height: 1.2; margin-bottom: 0.35rem; }
.auth-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 0.7rem; margin-bottom: 1.75rem; }
.auth-brand img { display: block; width: 180px; height: auto; }
.auth-brand span { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.form-card .subtitle { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.5rem; }
.form-card input { margin-bottom: 1rem; }
.form-card .hint { margin: -0.7rem 0 1rem; }
.form-card .btn { width: 100%; margin-top: 0.25rem; min-height: 44px; }
.form-card code { font-size: 0.8rem; word-break: break-all; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(0, 0, 0, 0.72);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 8vh 1rem 1rem;
    overflow-y: auto;
}
.modal { background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 1.75rem; width: 100%; max-width: 460px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6); }
.modal-wide { max-width: 560px; }
.modal h2 { font-family: var(--serif); font-size: 1.35rem; font-weight: 700; margin-bottom: 1.25rem; }
.modal-text { color: var(--muted); margin: -0.5rem 0 1.25rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.5rem; }
.modal-actions .btn-ghost-danger { margin-right: auto; }
.maint-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; align-items: start; padding: 1rem 0; border-top: 1px solid var(--line); }
.maint-row h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.2rem; }
.maint-row .small { color: var(--muted); }

/* Toasts */
.toasts { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 0.5rem; align-items: center; pointer-events: none; }
.toast { background: #1f3b27; border: 1px solid #2f5a3a; color: #e5f7ea; padding: 0.6rem 1rem; border-radius: var(--radius); font-size: 0.9rem; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); transition: opacity 0.3s; max-width: min(90vw, 480px); }
.toast-err { background: #3d1717; border-color: #6b2525; color: #ffe1e1; }
.toast-out { opacity: 0; }

@media (max-width: 860px) {
    .site-layout { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    main { padding: 1.25rem 1rem 3rem; }
    .topbar-inner { padding: 0 1rem; gap: 1rem; }
    .brand img { width: 104px; }
    .brand-product { display: none; }
    .tabs { gap: 1rem; }
    .tabs a { font-size: 0.85rem; }
    .menu { padding-left: 0.5rem; }
    .menu-name { display: none; }
    .page-row { grid-template-columns: minmax(0, 1fr) auto; }
    .page-meta { grid-column: 1; grid-row: 2; text-align: left; margin-top: -0.6rem; }
    .page-row .btn { grid-column: 2; grid-row: 1 / span 2; }
    .card { padding: 1rem; }
    .modal { padding: 1.25rem; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
