/* Rosetta design system — one home for the tokens and components every page
 * used to re-implement in its own <style> block. Load BEFORE the page styles:
 *   <link rel="stylesheet" href="shared.css">
 *
 * Tokens first (colors, surfaces, type scale, radii), then the shared
 * components: app bar + nav, page head, chips, pills, search box, banners,
 * buttons/inputs, modal, skeletons. Domain colors stay in shared.js
 * (DOMAIN_COLORS) because the canvas needs them as JS values; everything
 * else lives here.
 */

:root {
    /* surfaces */
    --bg: #0b0c10;
    --surface-1: rgba(255, 255, 255, 0.03);   /* cards, rows */
    --surface-2: rgba(255, 255, 255, 0.06);   /* hover, raised */
    --surface-3: #16181f;                     /* opaque: modals, popovers, overlays */
    --border: rgba(255, 255, 255, 0.10);
    --border-soft: rgba(255, 255, 255, 0.06);
    --border-strong: rgba(255, 255, 255, 0.22);

    /* text */
    --text: #d6d9e0;
    --text-dim: #9aa0ad;
    --text-faint: #6b7280;
    --text-strong: #ffffff;
    --text-mid: #dddddd;
    --text-soft: #cccccc;

    /* accent (one hue — the old blue) */
    --accent: #6495ff;
    --accent-text: #9bb8ff;
    --accent-bright: #c5d6ff;
    --accent-soft: rgba(100, 150, 255, 0.12);
    --accent-border: rgba(100, 150, 255, 0.40);

    /* semantic */
    --rating: #e8b341;          /* star ratings — deliberately NOT a domain color */
    --ok: #7dd87f;
    --err: #ff8a8a;

    /* overlays / canvas chrome */
    --overlay-bg: rgba(17, 19, 26, 0.92);
    --appbar-bg: rgba(11, 12, 16, 0.88);
    --modal-backdrop: rgba(5, 6, 10, 0.72);
    --graph-inset: rgba(0, 0, 0, 0.3);
    --row-hover: rgba(100, 150, 255, 0.05);
    --inset-bg: rgba(0, 0, 0, 0.15);
    --shadow: rgba(0, 0, 0, 0.55);

    /* canvas rendering */
    --canvas-label: rgba(255, 255, 255, 0.96);
    --canvas-halo: rgba(0, 0, 0, 0.88);
    --canvas-edge: rgba(255, 255, 255, 0.06);
    --canvas-edge-dim: rgba(255, 255, 255, 0.025);
    --canvas-edge-cross: rgba(255, 255, 255, 0.025);
    --canvas-node-stroke: rgba(0, 0, 0, 0.6);
    --canvas-selection-stroke: #ffffff;

    /* radii */
    --radius-s: 6px;
    --radius-m: 10px;
    --radius-l: 14px;
    --radius-pill: 999px;

    /* type scale (rem-based; base 16px) */
    --fs-0: 0.75rem;     /* 12 — micro labels, counts */
    --fs-1: 0.8125rem;   /* 13 — chips, meta, nav */
    --fs-2: 0.875rem;    /* 14 — body, rows */
    --fs-3: 1rem;        /* 16 — emphasized body, panel titles */
    --fs-4: 1.25rem;     /* 20 — section headings */
    --fs-5: 1.625rem;    /* 26 — page titles */

    --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
}

/* ── light theme ────────────────────────────────────────────────────────── */
[data-theme="light"] {
    --bg: #f4f5f9;
    --surface-1: rgba(0, 0, 0, 0.035);
    --surface-2: rgba(0, 0, 0, 0.06);
    --surface-3: #ffffff;
    --border: rgba(0, 0, 0, 0.12);
    --border-soft: rgba(0, 0, 0, 0.07);
    --border-strong: rgba(0, 0, 0, 0.22);

    --text: #2c3040;
    --text-dim: #5a6070;
    --text-faint: #848a98;
    --text-strong: #111318;
    --text-mid: #333640;
    --text-soft: #555860;

    --accent: #3b6fd8;
    --accent-text: #2a5bb8;
    --accent-bright: #1a3f8e;
    --accent-soft: rgba(59, 111, 216, 0.10);
    --accent-border: rgba(59, 111, 216, 0.35);

    --rating: #c89920;
    --ok: #2d8a2f;
    --err: #d43d3d;

    --overlay-bg: rgba(255, 255, 255, 0.95);
    --appbar-bg: rgba(244, 245, 249, 0.92);
    --modal-backdrop: rgba(80, 85, 100, 0.45);
    --graph-inset: rgba(0, 0, 0, 0.04);
    --row-hover: rgba(59, 111, 216, 0.06);
    --inset-bg: rgba(0, 0, 0, 0.03);
    --shadow: rgba(0, 0, 0, 0.12);

    --canvas-label: rgba(17, 19, 24, 0.92);
    --canvas-halo: rgba(255, 255, 255, 0.85);
    --canvas-edge: rgba(0, 0, 0, 0.08);
    --canvas-edge-dim: rgba(0, 0, 0, 0.03);
    --canvas-edge-cross: rgba(0, 0, 0, 0.03);
    --canvas-node-stroke: rgba(255, 255, 255, 0.6);
    --canvas-selection-stroke: #111318;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg);
    font-family: var(--font-ui);
    font-size: 16px;
    color: var(--text);
    min-height: 100vh;
}
::selection { background: rgba(100, 150, 255, 0.35); }
a { color: var(--accent-text); text-decoration: none; }
a:hover { color: var(--accent-bright); }

:focus-visible { outline: 2px solid var(--accent-border); outline-offset: 2px; }

.page { max-width: 1360px; margin: 0 auto; padding: 20px 20px 60px; }

/* ── app bar ───────────────────────────────────────────────────────────── */
.appbar {
    position: sticky; top: 0; z-index: 100;
    background: var(--appbar-bg);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-soft);
}
.appbar-inner {
    max-width: 1360px; margin: 0 auto; min-height: 52px;
    display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
    padding: 8px 20px;
}
.brand {
    display: inline-flex; align-items: center; gap: 9px;
    font-family: var(--font-display); font-weight: 600; font-size: 1.1rem;
    color: var(--text-strong); letter-spacing: 0.01em; white-space: nowrap;
}
.brand:hover { color: var(--text-strong); }
.brand svg { display: block; }
.nav {
    display: flex; align-items: center; gap: 4px; flex: 1; flex-wrap: wrap;
    font-size: var(--fs-1);
}
.nav a {
    color: var(--text-dim); padding: 5px 12px;
    border-radius: var(--radius-pill); border: 1px solid transparent;
    white-space: nowrap;
}
.nav a:hover { color: var(--text); border-color: var(--border); }
.nav a.current { color: var(--text-strong); background: var(--surface-2); }

/* ── People sub-nav (second row under the app bar; injected by shared.js) ── */
.subnav {
    background: var(--appbar-bg);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-soft);
}
.subnav-inner {
    max-width: 1360px; margin: 0 auto;
    display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
    padding: 5px 20px; font-size: var(--fs-0);
}
.subnav a {
    color: var(--text-dim); padding: 3px 10px;
    border-radius: var(--radius-pill); border: 1px solid transparent;
    white-space: nowrap;
}
.subnav a:hover { color: var(--text); border-color: var(--border); }
.subnav a.current { color: var(--text-strong); background: var(--surface-2); }

/* ── page head (compact, left-aligned — replaces the old hero masthead) ── */
.page-head { margin: 6px 0 18px; }
.page-head h1 {
    font-family: var(--font-display); font-weight: 600;
    font-size: var(--fs-5); color: var(--text-strong); letter-spacing: 0.005em;
}
.page-head .tagline { color: var(--text-faint); font-size: var(--fs-2); margin-top: 3px; }

/* ── chips (filters, tabs, people, tags — one component) ─────────────────── */
.chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 13px; border-radius: var(--radius-pill);
    background: var(--surface-1); border: 1px solid var(--border);
    color: var(--text-dim); font-size: var(--fs-1); font-family: var(--font-ui);
    cursor: pointer; user-select: none;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active, .chip.on {
    background: var(--accent-soft); border-color: var(--accent-border); color: var(--text-strong);
}
.chip.static { cursor: default; }

/* ── stat pills (the My Library ribbon, promoted to the shared component) ── */
.ribbon { display: flex; gap: 6px; flex-wrap: wrap; }
.ribbon.center { justify-content: center; }
.pill {
    padding: 6px 16px; background: var(--surface-1);
    border: 1px solid var(--border-soft); border-radius: var(--radius-pill);
    font-size: var(--fs-1); color: var(--text-dim); white-space: nowrap;
}
.pill b { color: var(--accent-bright); font-weight: 600; font-variant-numeric: tabular-nums; }
.pill.accent { border-color: var(--accent-border); background: rgba(100, 150, 255, 0.08); }
.pill.accent b { color: #8db4ff; }

/* ── search box ──────────────────────────────────────────────────────────── */
.search-box {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface-1); border: 1px solid var(--border);
    border-radius: var(--radius-s); padding: 8px 12px; min-width: 240px;
    color: var(--text-faint);
}
.search-box:focus-within { border-color: var(--accent-border); }
.search-box svg { flex-shrink: 0; }
.search-box input {
    background: none; border: none; color: var(--text);
    font-size: var(--fs-2); font-family: var(--font-ui); outline: none; width: 100%;
}
.search-box input::placeholder { color: var(--text-faint); }

/* ── info banners (reader scope, meta drill, notes) ──────────────────────── */
.banner {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; flex-wrap: wrap; margin-bottom: 14px; padding: 10px 16px;
    background: rgba(100, 150, 255, 0.10); border: 1px solid var(--accent-border);
    border-radius: var(--radius-m); font-size: var(--fs-2); color: #dbe6ff;
}
.banner.violet {
    background: rgba(180, 140, 255, 0.10);
    border-color: rgba(180, 140, 255, 0.35); color: #e6dbff;
}
.banner a { white-space: nowrap; font-weight: 600; }

/* ── buttons + inputs ────────────────────────────────────────────────────── */
button, .btn {
    padding: 8px 16px; border-radius: var(--radius-s); cursor: pointer;
    font-size: var(--fs-2); font-family: var(--font-ui);
    background: var(--accent-soft); border: 1px solid var(--accent-border);
    color: var(--text-strong); transition: background 0.15s, border-color 0.15s;
}
button:hover, .btn:hover { background: rgba(100, 150, 255, 0.25); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.quiet {
    background: var(--surface-1); border-color: var(--border); color: var(--text);
}
button.quiet:hover { background: var(--surface-2); border-color: var(--border-strong); }

input[type=text], textarea, select {
    padding: 8px 12px; background: var(--surface-1);
    border: 1px solid var(--border); border-radius: var(--radius-s);
    color: var(--text); font-size: var(--fs-2); font-family: var(--font-ui);
}
input[type=text]:focus, textarea:focus { border-color: var(--accent-border); outline: none; }
select { cursor: pointer; }
select option { color: #111; }   /* readable on the white native dropdown */
label { color: var(--text-dim); font-size: var(--fs-1); }

/* ── modal ───────────────────────────────────────────────────────────────── */
.modal {
    position: fixed; inset: 0; z-index: 1000;
    background: var(--modal-backdrop);
    display: flex; justify-content: center; align-items: center; padding: 20px;
    opacity: 0; visibility: hidden;
    transition: opacity 0.18s ease, visibility 0.18s;
}
.modal.show { opacity: 1; visibility: visible; }
.modal-card {
    background: var(--surface-3); border: 1px solid var(--border);
    border-radius: var(--radius-l); padding: 26px;
    max-width: 560px; width: 100%; max-height: 80vh; overflow-y: auto;
    position: relative; box-shadow: 0 18px 50px var(--shadow);
    transform: translateY(10px) scale(0.985);
    transition: transform 0.18s ease;
}
.modal.show .modal-card { transform: none; }
.modal-card h2 { color: var(--text-strong); font-size: var(--fs-4); font-family: var(--font-display); font-weight: 600; }
.modal-close {
    position: absolute; top: 12px; right: 14px; font-size: 1.1em;
    color: var(--text-faint); cursor: pointer; transition: color 0.15s;
    background: none; border: none; padding: 4px 6px;
}
.modal-close:hover { color: var(--text-strong); background: none; }

/* ── concept chips (links into the graph) ────────────────────────────────── */
.concept-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.concept-chip {
    background: var(--accent-soft); border: 1px solid rgba(100, 150, 255, 0.3);
    color: #cdd9ff; padding: 4px 11px; border-radius: var(--radius-pill);
    font-size: var(--fs-1); text-decoration: none; transition: background 0.15s, color 0.15s;
}
a.concept-chip:hover { background: rgba(100, 150, 255, 0.25); color: var(--text-strong); }

/* ── rating stars ────────────────────────────────────────────────────────── */
.rating, .stars .star.on, .brating { color: var(--rating); }

/* ── loading / empty / skeleton ──────────────────────────────────────────── */
.loading, .empty-state { text-align: center; padding: 50px; color: var(--text-faint); }
.skeleton {
    border-radius: var(--radius-s);
    background: linear-gradient(90deg, var(--surface-1) 25%, var(--surface-2) 45%, var(--surface-1) 65%);
    background-size: 200% 100%;
    animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
    .skeleton { animation: none; }
    .modal, .modal-card { transition: none; }
}

/* numeric alignment for stats and counts everywhere */
.num, .tabular { font-variant-numeric: tabular-nums; }

/* ── omnisearch (search.js) ── */
.os-btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 5px 12px; border-radius: var(--radius-pill);
    background: var(--surface-1); border: 1px solid var(--border);
    color: var(--text-dim); font-size: var(--fs-1); font-family: var(--font-ui);
    cursor: pointer; white-space: nowrap;
    transition: border-color 0.15s, color 0.15s;
}
.os-btn:hover { background: var(--surface-1); border-color: var(--border-strong); color: var(--text); }
.os-btn svg { flex-shrink: 0; }
.os-kbd {
    font-family: var(--font-ui); font-size: var(--fs-0); color: var(--text-faint);
    border: 1px solid var(--border-soft); border-radius: 4px; padding: 0 5px;
    background: var(--surface-1);
}

.os-modal { align-items: flex-start; padding: 12vh 20px 20px; }
.os-card {
    max-width: 620px; padding: 0; overflow: hidden;
    display: flex; flex-direction: column; max-height: 65vh;
}
input[type=text].os-input {
    width: 100%; background: none; border: none; border-radius: 0;
    border-bottom: 1px solid var(--border);
    padding: 15px 18px; font-size: var(--fs-3);
}
input[type=text].os-input:focus { border-color: var(--border); outline: none; }

.os-results { overflow-y: auto; padding: 6px 0 10px; }
.os-hint { padding: 16px 18px; color: var(--text-faint); font-size: var(--fs-2); }
.os-group-label {
    padding: 11px 18px 4px; font-size: var(--fs-0);
    text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint);
}
.os-row {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 18px; font-size: var(--fs-2); color: var(--text);
    cursor: pointer;
}
.os-row.hi { background: var(--accent-soft); color: var(--text-strong); }
.os-row .os-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.os-row .os-sub {
    margin-left: auto; padding-left: 14px; flex-shrink: 0;
    color: var(--text-faint); font-size: var(--fs-1);
    max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.os-row.hi .os-sub { color: var(--text-dim); }
.os-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.os-err { padding: 7px 18px; color: var(--err); font-size: var(--fs-1); }

@media (max-width: 768px) {
    .os-btn { padding: 5px 9px; }
    .os-btn .os-btn-label, .os-btn .os-kbd { display: none; }
    .os-modal { padding: 10px; }
    .os-card { max-height: 80vh; }
}

/* ── theme toggle ───────────────────────────────────────────────────────── */
.theme-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: var(--radius-pill);
    background: none; border: 1px solid transparent; color: var(--text-dim);
    cursor: pointer; padding: 0; margin-left: auto; flex-shrink: 0;
    transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border); }
.theme-toggle svg { display: block; }
[data-theme="light"] .theme-toggle .icon-moon,
:root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-sun,
:root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }

/* ── hovercard (book/film detail on hover) ─────────────────────────────── */
.hovercard {
    position: fixed; z-index: 200; pointer-events: none;
    background: var(--surface-3); border: 1px solid var(--border-strong);
    border-radius: var(--radius-m); padding: 14px 16px;
    box-shadow: 0 12px 36px var(--shadow);
    max-width: 380px; min-width: 220px;
    opacity: 0; visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s;
    font-size: var(--fs-1); line-height: 1.45;
}
.hovercard.show { opacity: 1; visibility: visible; pointer-events: auto; }
.hovercard-inner { display: flex; gap: 12px; }
.hovercard-cover {
    width: 48px; height: 72px; border-radius: 3px; object-fit: cover;
    flex-shrink: 0; background: var(--surface-2);
}
.hovercard-body { flex: 1; min-width: 0; }
.hovercard-title {
    font-weight: 600; color: var(--text-strong); font-size: var(--fs-2);
    margin-bottom: 3px; line-height: 1.3;
}
.hovercard-author { color: var(--text-dim); margin-bottom: 4px; }
.hovercard-meta {
    display: flex; flex-wrap: wrap; gap: 4px 10px;
    color: var(--text-faint); font-size: var(--fs-0);
    margin-bottom: 6px;
}
.hovercard-meta .hc-rating { color: var(--rating); }
.hovercard-meta .hc-year { font-variant-numeric: tabular-nums; }
.hovercard-domain {
    display: inline-block; padding: 2px 8px; border-radius: var(--radius-pill);
    font-size: var(--fs-0); border: 1px solid; margin-bottom: 4px;
}
.hovercard-concepts {
    display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px;
}
.hovercard-concepts .hc-concept {
    padding: 2px 7px; border-radius: var(--radius-pill);
    background: var(--accent-soft); border: 1px solid rgba(100, 150, 255, 0.25);
    font-size: 0.7rem; color: var(--accent-text);
}
.hovercard-series { color: var(--text-faint); font-size: var(--fs-0); font-style: italic; }
.hovercard-review {
    color: var(--text-dim); font-size: var(--fs-0); font-style: italic;
    margin-top: 4px; line-height: 1.4;
    max-height: 7.2em; overflow-y: auto;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.hovercard-review::-webkit-scrollbar { width: 4px; }
.hovercard-review::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
@media (max-width: 768px) { .hovercard { display: none !important; } }
