/* Aitherios
   Inner pages: calm night-blue ink on cool grey, steel blue for data,
   and the landing page's star gold as the accent. */

:root {
    --bg: #eceef1;
    --panel: #ffffff;
    --ink: #17202a;
    --muted: #586472;
    --line: #cfd4da;
    --steel: #2d5b84;
    --accent: #c98f1d;
    --accent-ink: #17202a;
    --error-bg: #fdf1e7;
    --error-ink: #8a3b12;

    --sans: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
    --serif: "Source Serif 4", Georgia, serif;

    --radius: 6px;
    --gutter: 16px;
    --max: 1180px;
    --narrow: 720px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #11161c;
        --panel: #192028;
        --ink: #e6eaee;
        --muted: #9aa6b3;
        --line: #2b3540;
        --steel: #8ab6de;
        --accent: #f4c96b;
        --accent-ink: #11161c;
        --error-bg: #2e1d12;
        --error-ink: #f4b88f;
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 1.0625rem;
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--steel); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

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

img { max-width: 100%; height: auto; display: block; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

.skip-link {
    position: absolute; left: var(--gutter); top: -40px; z-index: 10;
    background: var(--accent); color: var(--accent-ink); padding: 6px 12px; font-weight: 700;
}
.skip-link:focus { top: 8px; }

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.wrap--narrow { max-width: var(--narrow); }
.wrap--form { max-width: 440px; }

/* Header */

.site-header { background: var(--ink); color: var(--bg); border-bottom: 3px solid var(--accent); }
@media (prefers-color-scheme: dark) { .site-header { background: #0b0f13; color: var(--ink); } }

.site-header__inner {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; min-height: 64px; padding-block: 10px;
}

.brand {
    color: inherit; text-decoration: none;
    font-weight: 800; font-stretch: 112%; font-size: 1.35rem; letter-spacing: -0.01em;
}

.site-nav { display: flex; align-items: center; gap: 4px 20px; flex-wrap: wrap; }
.site-nav a, .link-button {
    color: inherit; text-decoration: none; font-weight: 500; font-size: 0.98rem;
    padding: 6px 0; border-bottom: 2px solid transparent;
}
.site-nav a:hover, .link-button:hover { border-bottom-color: currentColor; }
.site-nav a[aria-current="page"] { border-bottom-color: var(--accent); }
.site-nav__form { margin: 0; display: inline; }
.link-button { background: none; border-top: 0; border-left: 0; border-right: 0; font-family: inherit; cursor: pointer; }


.site-main { flex: 1; padding-bottom: 64px; }

.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; }
.site-footer p { margin: 0; padding: 20px 0; }

/* Home hero */

.hero { padding: 56px 0 40px; }
.hero__title {
    margin: 0;
    font-weight: 800; font-stretch: 125%;
    font-size: clamp(2.6rem, 9vw, 5.6rem);
    line-height: 0.95; letter-spacing: -0.035em;
}
.hero__intro { max-width: 34em; margin-top: 20px; font-size: 1.2rem; color: var(--muted); }
.hero__intro p { margin: 0; }

.home-grid { display: grid; gap: 40px; grid-template-columns: 1fr; padding-top: 8px; }
@media (min-width: 860px) { .home-grid { grid-template-columns: 3fr 2fr; gap: 56px; } }

.section-title {
    font-size: 1.05rem; font-weight: 700; margin: 0 0 12px;
    padding-bottom: 10px; border-bottom: 3px solid var(--ink);
}

/* Lists */

.post-list, .dash-list, .dash-cards { list-style: none; margin: 0; padding: 0; }

.post-list__item { padding: 16px 0; border-bottom: 1px solid var(--line); display: grid; gap: 2px; }
.post-list__link { font-weight: 700; font-size: 1.2rem; text-decoration: none; color: var(--ink); line-height: 1.25; }
.post-list__link:hover { text-decoration: underline; }
.post-list time, .page-head time { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.post-list p { margin: 4px 0 0; color: var(--muted); }
.post-list--large .post-list__link { font-size: 1.45rem; }

.dash-list li { border-bottom: 1px solid var(--line); }
.dash-list a { display: block; padding: 14px 0; font-weight: 700; text-decoration: none; }
.dash-list a:hover { text-decoration: underline; }

.dash-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.dash-card {
    display: grid; gap: 6px; height: 100%; padding: 20px;
    background: var(--panel); border: 1px solid var(--line); border-left: 6px solid var(--accent);
    border-radius: var(--radius); color: var(--ink); text-decoration: none;
}
.dash-card:hover { border-color: var(--steel); border-left-color: var(--accent); }
.dash-card__title { font-weight: 700; font-size: 1.2rem; }
.dash-card__desc { color: var(--muted); font-size: 0.95rem; }

.empty { color: var(--muted); }

/* Page headers */

.page-head { padding: 40px 0 24px; }
.page-head h1 {
    margin: 4px 0 8px;
    font-weight: 800; font-stretch: 110%;
    font-size: clamp(2rem, 6vw, 3.2rem); line-height: 1.05; letter-spacing: -0.025em;
}
.page-head__intro { color: var(--muted); max-width: 40em; font-size: 1.1rem; }
.page-head__intro p { margin: 0; }
.page-head__meta { color: var(--muted); font-size: 0.88rem; margin: 10px 0 0; }
.back-link { font-size: 0.95rem; font-weight: 600; text-decoration: none; }
.back-link::before { content: "‹ "; }

/* Dashboard grid */

.dash-grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 900px) {
    .dash-grid { grid-template-columns: 1fr 1fr; }
    .slot--full { grid-column: 1 / -1; }
}
.slot { min-width: 0; }
.slot > .block-heading { margin-top: 12px; }

.panel {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 20px; height: 100%;
}
.panel__title { font-size: 1.05rem; font-weight: 700; margin: 0 0 14px; }

.stats { display: flex; flex-wrap: wrap; gap: 12px 36px; margin: 0 0 18px; }
.stat { display: flex; flex-direction: column-reverse; }
.stat dt { color: var(--muted); font-size: 0.88rem; }
.stat dd {
    margin: 0; font-weight: 800; font-stretch: 85%;
    font-size: 2.3rem; line-height: 1.05; font-variant-numeric: tabular-nums;
}

.table-scroll { overflow-x: auto; margin: 0 -4px; }
.data-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.97rem; }
.data-table th {
    text-align: left; font-weight: 700; font-size: 0.86rem; color: var(--muted);
    padding: 8px 10px; border-bottom: 2px solid var(--ink); white-space: nowrap;
}
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.data-table tbody tr:hover td { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.data-table .num { text-align: right; }
.data-table th.num { text-align: right; }

.plotly-chart { width: 100%; }

.api-error {
    margin: 0; padding: 12px 14px; border-radius: 4px;
    background: var(--error-bg); color: var(--error-ink); font-size: 0.95rem;
}

/* Long-form text */

.prose { font-family: var(--serif); font-size: 1.15rem; line-height: 1.7; }
.prose .block-heading, .prose h3 { font-family: var(--sans); line-height: 1.2; }
.prose .panel, .prose .callout, .prose figcaption { font-family: var(--sans); font-size: 1rem; line-height: 1.55; }
.streamfield > * + * { margin-top: 24px; }
.block-heading { font-size: 1.55rem; font-weight: 800; margin: 40px 0 0; letter-spacing: -0.015em; }
.block-text p { margin: 0 0 1em; }
.block-image img { border-radius: var(--radius); }

.callout { border-left: 6px solid var(--steel); background: var(--panel); padding: 14px 18px; border-radius: 0 var(--radius) var(--radius) 0; }
.callout--warning { border-left-color: var(--accent); }
.callout p { margin: 0; }

.block-code { margin-left: 0; margin-right: 0; }
.block-code figcaption { font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
.block-code pre {
    margin: 0; padding: 16px; overflow-x: auto; border-radius: var(--radius);
    background: #17202a; color: #e6eaee; font-size: 0.9rem; line-height: 1.5;
}
.block-code code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* Forms */

.form { display: grid; gap: 6px; }
.form label { font-weight: 600; font-size: 0.95rem; margin-top: 10px; }
.form input, .search-form input {
    font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px;
    background: var(--bg); color: var(--ink); width: 100%;
}
.button {
    font: inherit; font-weight: 700; cursor: pointer; margin-top: 16px;
    background: var(--ink); color: var(--bg); border: 0; border-radius: 4px; padding: 11px 18px;
}
.button:hover { background: var(--steel); color: #fff; }
.login { margin-top: 56px; }
.login h1 { margin: 0 0 4px; font-stretch: 110%; font-weight: 800; }
.login__lead { color: var(--muted); margin: 0 0 12px; }
.login .api-error { margin-bottom: 8px; }

.search-form { display: flex; gap: 8px; }
.search-form .button { margin-top: 0; }

.pager { display: flex; gap: 20px; align-items: center; padding-top: 24px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* Traditional Chinese: add Noto fonts behind the Latin faces */
:lang(zh-Hant) {
    --sans: "Archivo", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
    --serif: "Source Serif 4", "Noto Serif TC", "PingFang TC", serif;
}
:lang(zh-Hant) .prose { line-height: 1.85; }

.site-nav .lang-switch {
    border: 1px solid currentColor;
    border-radius: 999px; padding: 3px 12px; font-size: 0.9rem;
}
.site-nav .lang-switch:hover { background: rgba(255, 255, 255, 0.1); border-bottom-color: currentColor; }

/* ---------- Landing page: the night sky ---------- */

.page-home {
    --space: #050816;
    --star: #f4f1ff;
    --star-dim: #aeb6d6;
    --gold: #f4c96b;
    background:
        radial-gradient(ellipse 55% 40% at 80% 14%, rgba(96, 70, 180, 0.34), transparent 70%),
        radial-gradient(ellipse 45% 38% at 8% 62%, rgba(20, 112, 134, 0.26), transparent 70%),
        radial-gradient(ellipse 38% 28% at 62% 92%, rgba(168, 68, 118, 0.18), transparent 70%),
        var(--space);
    background-attachment: fixed;
    color: var(--star);
    color-scheme: dark;
}

.starfield {
    position: fixed; inset: 0; width: 100%; height: 100%;
    z-index: 0; pointer-events: none;
}

.page-home .site-header,
.page-home .site-main,
.page-home .site-footer { position: relative; z-index: 1; }

.page-home .site-header { background: transparent; color: var(--star); border-bottom: 0; }
.page-home .site-footer { border-top-color: rgba(174, 182, 214, 0.2); color: var(--star-dim); }
.page-home a { color: var(--gold); }
.page-home .site-nav a, .page-home .brand, .page-home .link-button { color: var(--star); }
.page-home :focus-visible { outline-color: var(--gold); }
.page-home .site-main { padding-bottom: 0; }

.cosmos-hero {
    min-height: calc(100svh - 84px);
    display: flex; align-items: center;
    padding: 48px 0 72px;
}

.cosmos-title {
    margin: 0;
    font-weight: 300; font-stretch: 125%;
    font-size: clamp(3.2rem, 13vw, 9.5rem);
    line-height: 0.9; letter-spacing: 0.02em;
    color: var(--star);
    text-shadow: 0 0 40px rgba(160, 150, 255, 0.35);
}

.cosmos-word {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px;
    margin: 22px 0 0;
}
.cosmos-word__greek {
    font-family: var(--serif); font-style: italic; font-weight: 400;
    font-size: clamp(1.8rem, 5vw, 2.8rem); color: var(--gold);
}
.cosmos-word__say { color: var(--star-dim); font-size: 1rem; }

.cosmos-intro { max-width: 32em; margin-top: 20px; font-size: clamp(1.1rem, 2.4vw, 1.3rem); color: var(--star-dim); }
.cosmos-intro p { margin: 0; }

.page-home .cosmos-next {
    display: inline-block; margin-top: 40px;
    color: var(--star); text-decoration: none; font-weight: 600;
    padding-bottom: 6px; border-bottom: 1px solid var(--gold);
}
.cosmos-next::after { content: " ↓"; color: var(--gold); }
.cosmos-next:hover { border-bottom-width: 2px; }

.cosmos-meaning { padding: 72px 0 88px; }
.meaning-grid { display: grid; gap: 48px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 900px) { .meaning-grid { grid-template-columns: 7fr 5fr; gap: 80px; } }

.meaning-text h2 {
    margin: 0 0 20px;
    font-weight: 700; font-stretch: 110%;
    font-size: clamp(1.8rem, 4.5vw, 2.6rem); line-height: 1.1; letter-spacing: -0.01em;
}
.meaning-text p {
    font-family: var(--serif); font-size: 1.2rem; line-height: 1.75;
    color: #d9ddef; margin: 0 0 1.1em; max-width: 36em;
}
:lang(zh-Hant) .meaning-text p { line-height: 1.85; }

.roots { margin: 0; display: grid; gap: 0; border-left: 1px solid rgba(244, 201, 107, 0.5); }
.root { padding: 18px 0 18px 24px; position: relative; }
.root::before {
    content: ""; position: absolute; left: -4px; top: 30px;
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--gold); box-shadow: 0 0 10px var(--gold);
}
.root dt { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.root__term { font-family: var(--serif); font-size: 1.7rem; color: var(--star); }
.root__translit { font-family: var(--serif); font-style: italic; color: var(--star-dim); }
.root dd { margin: 4px 0 0; color: #d9ddef; }

.cosmos-latest {
    padding: 56px 0 72px;
    background: linear-gradient(to bottom, rgba(5, 8, 22, 0), rgba(5, 8, 22, 0.75) 120px);
}
.page-home .section-title { border-bottom-color: rgba(244, 241, 255, 0.7); }
.page-home .post-list__item,
.page-home .dash-list li { border-bottom-color: rgba(174, 182, 214, 0.2); }
.page-home .post-list__link { color: var(--star); }
.page-home .post-list time,
.page-home .post-list p,
.page-home .empty { color: var(--star-dim); }
.page-home .dash-list a { color: var(--gold); }
.page-home .panel { background: rgba(14, 19, 40, 0.8); border-color: rgba(174, 182, 214, 0.2); }
