/* =========================
   1) Font face
   ========================= */
@font-face {
    font-family: "Lucida";
    /* relative to this CSS file, which lives in assets/ */
    src: url("Lucida-Grande/lucidagrande.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Lucida";
    src: url("Lucida-Grande/lucidagrande_bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* =========================
   2) Tokens (match index.html's purple-black palette)
   Purple + green = Agatha + Rio. Green is tuned to the same brightness as
   the lavender so they read as a pair; it's used sparingly (title,
   scene breaks, accent bars) so purple stays the main highlight.
   ========================= */
:root {
    --bg: #141122;            /* purple-tinted near-black, a step lighter than the index */
    --bg-card: #1c1733;       /* raised panels: preface, summaries, notes */
    --border-subtle: #2c2450;
    --accent: #c4a8ff;        /* same lavender as index titles/chips */
    --green: #7fc98f;         /* Rio green — same contrast as --accent */
    --text: #bdb4d6;          /* soft lavender, halfway to --muted; ~9:1 on --bg */
    --muted: #9d93bd;         /* ~6:1 on --bg-card */

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-xl: 18px;

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;

    --shadow-soft: 0 6px 18px rgba(0, 0, 0, 0.45);

    --measure: 68ch;          /* comfortable line length on wide screens */
}

/* =========================
   3) Base
   ========================= */
html {
    box-sizing: border-box;
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

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

body {
    margin: 0 auto;
    max-width: calc(var(--measure) + 2 * var(--space-4));
    padding: var(--space-5) var(--space-4) var(--space-8);
    background-color: var(--bg);
    color: var(--text);
    font-family: "Lucida", "Lucida Grande", system-ui, -apple-system,
        "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans",
        "Liberation Sans", sans-serif;
    line-height: 1.65;
    font-size: 1rem;
    text-rendering: optimizeLegibility;
}

/* keep the background full-bleed even though body is centred */
html {
    background-color: var(--bg);
}

/* =========================
   4) Headings
   ========================= */
h1, h2, h3 {
    color: var(--accent);
    line-height: 1.3;
    margin-block: var(--space-4) var(--space-2);
    font-weight: 600;
    letter-spacing: 0.02em;
    text-align: center;
}

h1 {
    font-size: 1.6rem;
    color: var(--green);
    margin-top: 0;
}

h2 {
    font-size: 1.25rem;
}

h3 {
    font-size: 1.05rem;
    color: var(--muted);
}

/* =========================
   5) Text & spacing
   ========================= */
p,
ul,
ol,
blockquote,
pre,
table {
    margin-block: var(--space-3);
}

p,
li {
    overflow-wrap: break-word;
    font-size: 0.94rem; /* ~13px story text */
}

/* Gentle scene-break style for common fanfic separators */
hr {
    border: none;
    margin: var(--space-6) auto;
    height: 1px;
    max-width: 40%;
    background: linear-gradient(
        to right,
        transparent,
        var(--accent),
        var(--green),
        transparent
    );
    opacity: 0.6;
}

/* =========================
   6) Links
   ========================= */
a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.18s ease-out, color 0.18s ease-out;
}

a:hover {
    border-color: var(--accent);
}

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

/* =========================
   7) Preface list & blockquotes
   ========================= */
dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 10px 20px;
    font-size: 0.85rem;
}

dt {
    font-weight: bold;
    grid-column: 1;
}

dd {
    margin: 0;
    grid-column: 2;
}

dl,
blockquote {
    margin-inline: 0;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    color: var(--muted);
    position: relative;
}

blockquote {
    padding-left: var(--space-6);  /* clear the accent bar */
}

blockquote::before {
    content: "";
    position: absolute;
    left: 0.7rem;
    top: 0.8rem;
    bottom: 0.8rem;
    width: 2px;
    border-radius: 999px;
    background: linear-gradient(
        to bottom,
        var(--accent),
        var(--green) 70%,
        transparent
    );
}

/* =========================
   8) Media & tables
   ========================= */
img,
video,
svg {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
}

table {
    width: 100%;
    border-collapse: collapse;
    display: block;
    overflow-x: auto;
    margin-block: var(--space-3);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
}

th,
td {
    padding: 0.5rem 0.6rem;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
}

th {
    text-align: left;
    color: var(--accent);
    font-weight: 500;
}

/* =========================
   9) Code blocks
   ========================= */
code,
pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

pre {
    background: var(--bg-card);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    overflow-x: auto;
    white-space: pre;
    border: 1px solid var(--border-subtle);
    font-size: 0.8rem;
    box-shadow: var(--shadow-soft);
}

code {
    background: var(--bg-card);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85rem;
    border: 1px solid var(--border-subtle);
}

/* =========================
   10) Misc utility bits
   ========================= */

/* chapter headers, notes, preface */
.meta,
.notes,
.header {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: var(--space-2);
}

.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: var(--space-3);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
}

/* =========================
   11) Selection color
   ========================= */
::selection {
    background: rgba(196, 168, 255, 0.35);
    color: #ffffff;
}

.byline {
    font-size: 1rem;
    color: var(--muted);
    margin-bottom: var(--space-2);
    text-align: center;
}

/* =========================
   Kudos reminder button (added by assets/kudos.js)
   ========================= */
.kudos-reminder {
    max-width: var(--measure);
    margin: var(--space-8) auto var(--space-8);
    padding: 0 var(--space-4);
    text-align: center;
}
.kudos-btn {
    font: inherit;
    font-size: 0.95rem;
    color: var(--accent);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-5);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.kudos-btn:hover, .kudos-btn:focus-visible {
    border-color: var(--accent);
    outline: none;
}
.kudos-btn.saved {
    color: var(--green);
    border-color: var(--green);
}
