/* ── Design Tokens ───────────────────────────────────────── */
:root {
    --bg:       #f0ebe1;
    --surface:  #e6e0d4;
    --card:     #faf8f4;
    --border:   #6c5d49;
    --gold:     #5a4530;
    --gold-dim: #8c7a62;
    --cream:    #1a1510;
    --muted:    #1e1c19;
    --accent:   #b56e56;
    --text:     #3c3228;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Libre Baskerville', Georgia, serif;
    overflow-x: hidden;
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
}

/* ── Grain overlay ────────────────────────────────────────── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 9999;
    opacity: 0.35;
}

/* ── Radial glow ──────────────────────────────────────────── */
body::after {
    content: '';
    position: fixed;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 800px;
    height: 600px;
    background: radial-gradient(ellipse at center, rgba(90, 69, 48, 0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ── Page wrapper ─────────────────────────────────────────── */
.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    position: relative;
    z-index: 1;
}

/* ── Hero ─────────────────────────────────────────────────── */
.hero {
    text-align: center;
    margin-bottom: 52px;
}

.logo-rule {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: center;
    margin-bottom: 12px;
}

.logo-rule span {
    height: 1px;
    width: 60px;
    background: linear-gradient(to right, transparent, var(--gold-dim));
}

.logo-rule span:last-child {
    background: linear-gradient(to left, transparent, var(--gold-dim));
}

.ornament {
    color: var(--gold-dim);
    font-size: 14px;
    letter-spacing: 0.4em;
}

.site-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(2.4rem, 6vw, 4rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--cream);
    line-height: 1;
    margin-bottom: 10px;
}

.site-title-link {
    text-decoration: none;
    display: inline-block;
}

.site-title-link:hover .site-title {
    color: var(--gold);
}

.site-title-link:hover .site-title em {
    color: var(--cream);
}

.site-title em {
    font-style: italic;
    color: var(--gold);
}

.hero-motto {
    margin-top: 14px;
}

.hero-motto-text {
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    font-size: clamp(0.95rem, 2vw, 1.1rem);
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 6px;
}


/* ── Category pills ───────────────────────────────────────── */
.categories {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 36px;
}

.cat-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 7px 16px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cat-btn:hover {
    border-color: var(--gold-dim);
    color: var(--gold);
}

.cat-btn.active {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--bg);
    font-weight: 500;
}

.cat-btn--italic {
    font-style: italic;
}

/* ── Quote card ───────────────────────────────────────────── */
.card-wrap {
    width: 100%;
    max-width: 720px;
    perspective: 1000px;
}

#quote-content {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.quote-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-top: 2px solid var(--gold-dim);
    padding: 52px 56px;
    position: relative;
    transition: opacity 0.35s ease, transform 0.35s ease;
    box-shadow: 0 2px 24px rgba(30, 20, 10, 0.07);
}

.quote-card.fade-out {
    opacity: 0;
    transform: translateY(8px);
}

.quote-card.fade-in {
    animation: fadeSlideIn 0.4s ease forwards;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.big-quote {
    font-family: 'Playfair Display', serif;
    font-size: 5rem;
    line-height: 0.5;
    color: var(--gold);
    opacity: 0.35;
    position: absolute;
    top: 36px;
    left: 44px;
    user-select: none;
}

.quote-text {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(1.15rem, 2.5vw, 1.45rem);
    line-height: 1.75;
    color: var(--cream);
    font-style: italic;
    margin-bottom: 32px;
    position: relative;
    z-index: 1;
}

/* ── Attribution ──────────────────────────────────────────── */
.attribution {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.attr-line {
    flex-shrink: 0;
    width: 32px;
    height: 1px;
    background: var(--gold-dim);
    margin-top: 10px;
}

.attr-author {
    font-family: 'DM Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 4px;
}

.attr-source {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.attr-book {
    font-size: 0.82rem;
    color: var(--muted);
    font-style: italic;
}

.attr-page {
    font-family: 'DM Mono', monospace;
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    color: var(--accent);
    background: rgba(212, 120, 90, 0.1);
    border: 1px solid rgba(212, 120, 90, 0.25);
    padding: 2px 8px;
    border-radius: 2px;
}

.category-tag {
    position: absolute;
    top: 20px;
    right: 24px;
    font-family: 'DM Mono', monospace;
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    opacity: 0.6;
}

/* ── Loading dots ─────────────────────────────────────────── */
.loading-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
    align-items: center;
    height: 60px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold-dim);
    animation: pulse 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
    40%            { opacity: 1;   transform: scale(1.1); }
}

/* ── Action buttons ───────────────────────────────────────── */
.actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-primary {
    background: var(--gold);
    color: var(--bg);
    border: none;
    font-family: 'DM Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    padding: 14px 32px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    border-radius: 0;
}

.btn-primary:hover:not(:disabled) { background: var(--cream); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    font-family: 'DM Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    padding: 14px 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 0;
}

.btn-ghost:hover         { border-color: var(--muted); color: var(--text); }
.btn-ghost.copied        { border-color: var(--gold-dim); color: var(--gold); }

/* ── Session counter ──────────────────────────────────────── */
.counter {
    margin-top: 28px;
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--muted);
    opacity: 0.5;
    text-align: center;
    min-height: 1em;
}

/* ── Error state (inside card) ────────────────────────────── */
.error-msg {
    text-align: center;
    padding: 40px;
    color: var(--muted);
}

.error-msg strong {
    display: block;
    color: var(--accent);
    font-family: 'DM Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

/* ── Error page ───────────────────────────────────────────── */
.site-error {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.site-error h1 { color: var(--gold); font-family: 'Playfair Display', serif; }
.site-error h2 { color: var(--cream); font-family: 'Playfair Display', serif; margin-bottom: 1rem; }
.site-error p  { color: var(--muted); }

.site-error .btn-outline-primary {
    color: var(--gold);
    border-color: var(--gold-dim);
    font-family: 'DM Mono', monospace;
    letter-spacing: 0.1em;
    border-radius: 0;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.site-error .btn-outline-primary:hover {
    background: var(--gold);
    color: var(--bg);
    border-color: var(--gold);
}

/* ── Burger Menu ─────────────────────────────────────────── */
.burger-btn {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 1002;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    transition: transform 0.3s ease;
}

.burger-btn span {
    display: block;
    width: 24px;
    height: 1px;
    background-color: var(--gold);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.burger-btn:hover span {
    background-color: var(--accent);
}

/* Burger to X animation */
.burger-btn.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.burger-btn.active span:nth-child(2) {
    opacity: 0;
}

.burger-btn.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 200px;
    height: 100%;
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 100px 24px 40px;
    display: flex;
    flex-direction: column;
}

.sidebar.active {
    transform: translateX(0);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30, 28, 25, 0.4);
    backdrop-filter: blur(2px);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-link {
    color: var(--text);
    text-decoration: none;
    font-family: 'DM Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    transition: all 0.2s ease;
    opacity: 0.8;
}

.sidebar-link:hover {
    color: var(--gold);
    opacity: 1;
    transform: translateX(4px);
}

/* ── About Page ───────────────────────────────────────────── */
.about-content {
    position: relative;
    z-index: 1;
}

.about-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    color: var(--gold);
    margin-bottom: 24px;
}

.about-text {
    font-family: 'Libre Baskerville', serif;
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--text);
    margin-bottom: 20px;
}

.inline-link {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s ease;
}

.inline-link:hover {
    color: var(--gold);
}

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
    text-align: center;
    padding: 48px 20px 36px;
    position: relative;
    z-index: 1;
}

.site-footer__rule {
    display: flex;
    align-items: center;
    gap: 14px;
    justify-content: center;
    margin-bottom: 20px;
}

.site-footer__rule span {
    height: 1px;
    width: 48px;
    background: linear-gradient(to right, transparent, var(--border));
}

.site-footer__rule span:last-child {
    background: linear-gradient(to left, transparent, var(--border));
}

.site-footer__ornament {
    font-size: 11px;
    letter-spacing: 0.4em;
    color: var(--border);
}

.site-footer__name {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--gold-dim);
    margin-bottom: 16px;
}

.site-footer__copy {
    font-family: 'DM Mono', monospace;
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold-dim);
    opacity: 0.6;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
    .page        { padding: 32px 16px; }

    .hero        { margin-bottom: 36px; }
    .logo-rule span { width: 40px; }

    .site-title  { font-size: 2.6rem; margin-bottom: 8px; }

    .hero-motto-text { font-size: 1.05rem; }

    .categories  { gap: 6px; margin-bottom: 28px; }
    .cat-btn     { padding: 10px 14px; font-size: 0.72rem; }

    .quote-card  { padding: 36px 24px; }
    .big-quote   { font-size: 3.5rem; top: 28px; left: 20px; }

    .quote-text  { font-size: 1.22rem; line-height: 1.8; }

    .attr-author { font-size: 0.84rem; }
    .attr-book   { font-size: 0.84rem; }

    .actions     { flex-direction: column; gap: 8px; }
    .btn-primary,
    .btn-ghost   { width: 100%; text-align: center; }
}
