/* VerseOracle — candlelit editorial: ivory & gold, Garamond, light/dark */

/* ---------- Fonts (self-hosted variable woff2, latin subset) ---------- */

@font-face {
    font-family: 'Cormorant Garamond';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('/fonts/cormorant-garamond.woff2') format('woff2');
}

@font-face {
    font-family: 'Cormorant Garamond';
    font-style: italic;
    font-weight: 300 700;
    font-display: swap;
    src: url('/fonts/cormorant-garamond-italic.woff2') format('woff2');
}

@font-face {
    font-family: 'EB Garamond';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('/fonts/eb-garamond.woff2') format('woff2');
}

@font-face {
    font-family: 'EB Garamond';
    font-style: italic;
    font-weight: 400 800;
    font-display: swap;
    src: url('/fonts/eb-garamond-italic.woff2') format('woff2');
}

/* ---------- Tokens ---------- */

:root {
    --bg: #f8f4ea;
    --surface: #fffdf6;
    --ink: #241f15;
    --ink-soft: #52493a;
    --muted: #86795f;
    --gold: #a5802e;
    --gold-deep: #7d5f1d;
    --border: #e5dbc3;
    --hairline: #d9cca9;
    --halo: rgba(196, 156, 68, 0.14);
    --shadow-soft: 0 1px 2px rgba(64, 50, 22, 0.05), 0 14px 36px -18px rgba(64, 50, 22, 0.25);
    --grain-opacity: 0.04;

    --display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    --text: 'EB Garamond', Georgia, 'Times New Roman', serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12100a;
        --surface: #1b1710;
        --ink: #ede3ca;
        --ink-soft: #cbbd9d;
        --muted: #94876a;
        --gold: #d3ab55;
        --gold-deep: #e2c172;
        --border: #2e2717;
        --hairline: #3d341f;
        --halo: rgba(211, 171, 85, 0.09);
        --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.5), 0 16px 40px -18px rgba(0, 0, 0, 0.6);
        --grain-opacity: 0.05;
    }
}

/* ---------- Base ---------- */

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

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

body {
    background:
        radial-gradient(70rem 42rem at 50% -12rem, var(--halo), transparent 62%),
        var(--bg);
    color: var(--ink);
    font-family: var(--text);
    font-size: 1.125rem;
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Paper grain — fixed overlay, never intercepts input */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    opacity: var(--grain-opacity);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: var(--gold-deep); }

::selection { background: color-mix(in srgb, var(--gold) 30%, transparent); }

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

/* Small-caps utility look, used across labels */
.smallcaps,
.kicker,
.verse-ref,
.btn,
.home-section h2,
.topic-card .count,
.site-header nav a,
.pagination .page-count {
    font-family: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.22em;
}

/* ---------- Header ---------- */

.site-header {
    text-align: center;
    padding: clamp(1.6rem, 4vh, 2.4rem) 1.25rem 0;
}

.wordmark {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    text-decoration: none;
    color: var(--ink);
}

.wordmark .flame {
    width: 22px;
    height: 22px;
    color: var(--gold);
}

.wordmark-text {
    font-family: var(--display);
    font-size: 1.55rem;
    font-weight: 500;
    letter-spacing: 0.3em;
    margin-right: -0.3em; /* optically recenter tracked text */
    text-transform: uppercase;
    white-space: nowrap;
}

.wordmark-text em {
    font-style: normal;
    color: var(--gold);
}

.site-header nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem 2.2rem;
    margin-top: 1.1rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--hairline);
    max-width: 44rem;
    margin-left: auto;
    margin-right: auto;
}

.site-header nav a {
    font-size: 0.72rem;
    color: var(--muted);
    text-decoration: none;
    padding: 0.15rem 0;
    border-bottom: 1px solid transparent;
    transition: color 0.15s;
}

.site-header nav a:hover { color: var(--gold-deep); }

.site-header nav a.active {
    color: var(--gold-deep);
    border-bottom-color: var(--gold);
}

/* ---------- Main ---------- */

main {
    flex: 1;
    width: 100%;
    max-width: 46rem;
    margin: 0 auto;
    padding: clamp(2.5rem, 7vh, 4.5rem) 1.4rem 4rem;
}

.kicker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.1rem;
    font-size: 0.74rem;
    color: var(--gold);
    margin-bottom: 2.2rem;
}

.kicker::before,
.kicker::after {
    content: '';
    width: 3rem;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--hairline));
}

.kicker::after {
    background: linear-gradient(to left, transparent, var(--hairline));
}

/* ---------- Verse hero ---------- */

.verse-hero { text-align: center; }

.verse-text {
    font-family: var(--display);
    font-size: clamp(1.7rem, 4.4vw, 2.5rem);
    font-weight: 500;
    font-style: italic;
    line-height: 1.42;
    text-wrap: balance;
    max-width: 30em;
    margin: 0 auto;
}

.verse-text::before {
    content: '\201C';
    display: block;
    height: 3.1rem;
    font-size: 5.5rem;
    line-height: 1;
    font-style: normal;
    color: var(--gold);
    opacity: 0.45;
}

.verse-ref {
    margin-top: 1.9rem;
    font-size: 0.82rem;
    color: var(--gold-deep);
}

.verse-ref .translation { color: var(--muted); }

.verse-actions {
    margin-top: 2.4rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
}

/* Staggered entrance */
@keyframes rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

.verse-hero > * { animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.3, 1) backwards; }
.verse-hero > :nth-child(2) { animation-delay: 0.08s; }
.verse-hero > :nth-child(3) { animation-delay: 0.16s; }
.verse-hero > :nth-child(4) { animation-delay: 0.24s; }

/* ---------- Buttons & toggles ---------- */

.btn {
    font-size: 0.72rem;
    color: var(--gold-deep);
    background: none;
    border: 1px solid color-mix(in srgb, var(--gold) 55%, transparent);
    border-radius: 999px;
    padding: 0.6rem 1.5rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s;
}

.btn:hover {
    border-color: var(--gold);
    background: color-mix(in srgb, var(--gold) 10%, transparent);
}

.btn-primary {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--bg);
}

.btn-primary:hover {
    background: var(--gold-deep);
    border-color: var(--gold-deep);
    color: var(--bg);
    box-shadow: 0 6px 20px -8px color-mix(in srgb, var(--gold) 70%, transparent);
}

.translation-toggle {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.translation-toggle a,
.translation-toggle .current {
    padding: 0.55rem 1rem;
    text-decoration: none;
    color: var(--muted);
    transition: color 0.15s, background 0.15s;
}

.translation-toggle a:hover { color: var(--gold-deep); }

.translation-toggle .current {
    color: var(--gold-deep);
    background: color-mix(in srgb, var(--gold) 14%, transparent);
}

/* ---------- Ornament divider ---------- */

.divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    margin: clamp(3rem, 9vh, 5rem) auto;
    color: var(--gold);
    font-size: 0.95rem;
}

.divider::before,
.divider::after {
    content: '';
    width: 5.5rem;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--hairline));
}

.divider::after {
    background: linear-gradient(to left, transparent, var(--hairline));
}

/* ---------- Home sections ---------- */

.home-section { text-align: center; }

.home-section h2 {
    font-size: 0.74rem;
    font-weight: normal;
    color: var(--muted);
    margin-bottom: 1.6rem;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.65rem;
    max-width: 36rem;
    margin: 0 auto;
}

.chips a {
    font-size: 0.98rem;
    color: var(--ink-soft);
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    padding: 0.42rem 1.15rem;
    transition: border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.chips a:hover {
    border-color: var(--gold);
    color: var(--gold-deep);
    box-shadow: var(--shadow-soft);
}

/* ---------- Page head (topics, topic, about) ---------- */

.page-head { text-align: center; }

.page-head .kicker { margin-bottom: 1.4rem; }

.page-title {
    font-family: var(--display);
    font-size: clamp(2.1rem, 5vw, 2.9rem);
    font-weight: 500;
    line-height: 1.15;
    text-wrap: balance;
}

.page-intro {
    color: var(--muted);
    font-size: 1.05rem;
    max-width: 32rem;
    margin: 1rem auto 0;
}

.page-tools {
    display: flex;
    justify-content: center;
    margin-top: 1.8rem;
}

/* ---------- Topic index ---------- */

.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14.5rem, 1fr));
    gap: 1.1rem;
    margin-top: 3rem;
}

.topic-card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.35rem 1.4rem 1.2rem;
    transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
}

.topic-card::after {
    content: attr(data-initial);
    position: absolute;
    right: 0.4rem;
    bottom: -1.6rem;
    font-family: var(--display);
    font-size: 6.5rem;
    font-weight: 600;
    line-height: 1;
    color: var(--gold);
    opacity: 0.09;
    pointer-events: none;
}

.topic-card:hover {
    border-color: color-mix(in srgb, var(--gold) 60%, var(--border));
    transform: translateY(-3px);
    box-shadow: var(--shadow-soft);
}

.topic-card h3 {
    font-family: var(--display);
    font-weight: 600;
    font-size: 1.45rem;
    color: var(--gold-deep);
}

.topic-card p {
    font-size: 0.98rem;
    line-height: 1.55;
    color: var(--muted);
    margin-top: 0.4rem;
}

.topic-card .count {
    margin-top: auto;
    padding-top: 0.9rem;
    font-size: 0.66rem;
    color: color-mix(in srgb, var(--muted) 80%, var(--gold));
}

/* ---------- Verse list (topic pages) ---------- */

.verse-list {
    list-style: none;
    margin-top: 3rem;
}

.verse-item {
    position: relative;
    padding: 0 0 0 2.4rem;
}

.verse-item + .verse-item {
    margin-top: 2.4rem;
    padding-top: 2.4rem;
    border-top: 1px solid var(--hairline);
}

.verse-item::before {
    content: '\201C';
    position: absolute;
    left: 0;
    top: -0.35rem;
    font-family: var(--display);
    font-size: 3rem;
    line-height: 1;
    color: var(--gold);
    opacity: 0.5;
}

.verse-item + .verse-item::before { top: 2.05rem; }

.verse-item p {
    font-family: var(--display);
    font-size: 1.35rem;
    font-style: italic;
    line-height: 1.5;
    color: var(--ink);
}

.verse-item .ref {
    display: block;
    margin-top: 0.7rem;
    font-size: 0.78rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold-deep);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.3rem;
    margin-top: 3.5rem;
}

.pagination .page-count {
    font-size: 0.72rem;
    color: var(--muted);
}

/* ---------- Prose (about) ---------- */

.prose {
    max-width: 34rem;
    margin: 2.6rem auto 0;
    font-size: 1.14rem;
}

.prose p { margin-bottom: 1.2rem; }

.prose > p:first-of-type::first-letter {
    font-family: var(--display);
    font-size: 3.4em;
    font-weight: 500;
    float: left;
    line-height: 0.82;
    padding: 0.08em 0.12em 0 0;
    color: var(--gold-deep);
}

.prose .verse-quote {
    font-family: var(--display);
    font-size: 1.35rem;
    font-style: italic;
    color: var(--gold-deep);
    text-align: center;
    margin: 2.2rem 0;
    padding: 0 1rem;
    line-height: 1.5;
}

/* ---------- Footer ---------- */

.site-footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.92rem;
    padding: 0 1.25rem 2.6rem;
}

.footer-rule {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    color: var(--gold);
    font-size: 1.1rem;
    margin-bottom: 1.4rem;
}

.footer-rule::before,
.footer-rule::after {
    content: '';
    width: min(9rem, 24vw);
    height: 1px;
    background: linear-gradient(to right, transparent, var(--hairline));
}

.footer-rule::after {
    background: linear-gradient(to left, transparent, var(--hairline));
}

.site-footer .scripture-note {
    font-family: var(--display);
    font-style: italic;
    font-size: 1.15rem;
    color: var(--ink-soft);
}

.site-footer .fine {
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.site-footer a { color: var(--muted); }

.site-footer a:hover { color: var(--gold-deep); }

/* ---------- Toast ---------- */

#toast {
    position: fixed;
    left: 50%;
    bottom: 1.8rem;
    z-index: 10;
    transform: translateX(-50%) translateY(1rem);
    background: var(--ink);
    color: var(--bg);
    font-size: 0.95rem;
    letter-spacing: 0.03em;
    padding: 0.6rem 1.4rem;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0ms !important;
        transition-duration: 0.01ms !important;
    }
}
