/* ═══════════════════════════════════════════════════════
   PARROT TALES — Design System
   
   Philosophy: Stories are the design.
   Newspaper aesthetic. Warm. Breathable. No tricks.
   Dark mode that feels like reading by lamplight.
   ═══════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────── */
:root {
    /* Anthropic Folio Palette (Light Mode - Default) */
    --bg:           #F9F1E8; /* Soft Parchment */
    --bg-surface:   #f4ede5; 
    --bg-hover:     #ebe2d7; 
    --text:         #343330; /* Warm Deep Charcoal */
    --text-muted:   #61605e; 
    --text-faint:   #94928e; 
    --accent:       #AF5C40; /* Muted Terracotta */
    --accent-hover: #8f4b34;
    --rule:         #e7ded4;
    --rule-accent:  #d9d1c7;

    /* Typography - Academic & Human */
    --font-serif:   'Newsreader', 'Lora', serif;
    --font-sans:    'Inter', -apple-system, sans-serif;

    /* Spacing */
    --space-xs:     0.25rem;
    --space-sm:     0.5rem;
    --space-md:     1.25rem;
    --space-lg:     2rem;
    --space-xl:     3.5rem;
    --space-2xl:    6rem;

    /* Layout */
    --max-width:    700px; /* Reading focused column */
    --header-height: auto;
}

/* ── Dark Mode (Warm Coal) ─────────────────── */
.dark {
    --bg:           #1e1e1a; /* Warm coal */
    --bg-surface:   #262621;
    --bg-hover:     #2e2e28;
    --text:         #f2ebd9;
    --text-muted:   #b8b2a5;
    --text-faint:   #8a857b;
    --accent:       #d97757;
    --accent-hover: #ff8b6b;
    --rule:         #33332d;
    --rule-accent:  #403f38;
}

/* ── Base ───────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 18px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-serif);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.4s ease, color 0.4s ease;
}

::selection {
    background: var(--accent);
    color: var(--bg);
}

/* ── Header ─────────────────────────────────── */
#site-header {
    padding: var(--space-2xl) var(--space-lg) var(--space-xl);
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
    text-align: center;
}

.masthead {
    margin-bottom: var(--space-lg);
}

#site-title {
    font-family: var(--font-serif);
    font-size: 3.5rem;
    font-weight: 400; /* Academic elegance */
    letter-spacing: -0.01em;
    line-height: 1;
    color: var(--text);
    margin-bottom: var(--space-sm);
}

.tagline {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 400;
    font-style: italic;
    opacity: 0.8;
}

/* Nav is moved to the bottom footer for total minimalism, 
   but we'll keep the buttons for now tucked away */
#site-nav {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-faint);
    padding: var(--space-sm);
    cursor: pointer;
    font-size: 0.9rem;
    transition: color 0.2s ease;
    font-family: var(--font-sans);
}

.nav-btn:hover {
    color: var(--accent);
}

/* ── Filter Bar ─────────────────────────────── */
.filter-bar {
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--rule);
    margin-bottom: var(--space-xl);
}

.filter-pill {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-faint);
    padding: 4px 12px;
    border-radius: 4px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-pill:hover {
    color: var(--text);
}

.filter-pill.active {
    color: var(--accent);
    font-weight: 600;
    border-bottom: 2px solid var(--accent);
    border-radius: 0;
}

/* ── Focus Rings (A11y) ─────────────────────── */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
    border-radius: 4px;
}

.tale-row:focus-visible {
    background: var(--bg-hover);
    outline: none; /* Custom outline */
    border-left: 2px solid var(--accent);
    padding-left: var(--space-md);
}

.hero-banner:focus-visible {
    outline-offset: 6px;
}

/* ── About Panel ────────────────────────────── */
.about-panel {
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
    padding: 0 var(--space-lg);
    overflow: hidden;
    max-height: 600px;
    opacity: 1;
    transition: max-height 0.5s ease, opacity 0.3s ease, padding 0.5s ease;
}

.about-panel.hidden {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.about-content {
    background: var(--bg-surface);
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: var(--space-lg);
    margin-top: var(--space-lg);
    position: relative;
}

.about-content h2 {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    margin-bottom: var(--space-md);
    color: var(--accent);
}

.about-content h3 {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
    color: var(--text);
}

.about-content p {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: var(--space-sm);
}

.about-content ol {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.8;
    padding-left: var(--space-lg);
}

.about-content ol li {
    margin-bottom: var(--space-xs);
}

.about-footnote {
    font-style: italic;
    color: var(--text-faint);
    margin-top: var(--space-md);
    border-top: 1px solid var(--rule);
    padding-top: var(--space-md);
}

.ai-warning {
    color: var(--accent);
    font-weight: 500;
}

.close-btn {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    background: none;
    border: none;
    color: var(--text-faint);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--text);
}

/* ── Main Content ───────────────────────────── */
#tales-container {
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
    padding: var(--space-lg);
    flex: 1;
}

/* ── State Messages ─────────────────────────── */
.state-message {
    text-align: center;
    padding: var(--space-2xl) 0;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.95rem;
}

.state-message.hidden {
    display: none !important;
}

.state-message code {
    background: var(--bg-surface);
    padding: 0.15em 0.5em;
    border-radius: 4px;
    font-size: 0.85em;
    border: 1px solid var(--rule);
}

/* ── Hero Banner ────────────────────────────── */
.hero-banner {
    position: relative;
    width: 100%;
    margin-bottom: var(--space-2xl);
    text-align: center;
}

.hero-banner img {
    width: 140px; /* Small centered emblem/illustration */
    height: auto;
    margin: 0 auto var(--space-lg);
    filter: sepia(0.5) opacity(0.7);
}

.hero-banner .tale-title {
    font-size: 2.5rem;
    font-weight: 400;
    margin-bottom: var(--space-md);
    line-height: 1.1;
}

/* ── Tale Row ───────────────────────────── */
.tale-row {
    display: block;
    padding: var(--space-lg) 0;
    background: transparent;
    cursor: pointer;
    border-bottom: none;
    animation: fadeInUp 0.7s ease both;
    text-align: center;
    width: 100%;
}

.tale-row:hover {
    background: transparent;
}

.tale-row:hover .tale-title {
    color: var(--accent);
}

.tale-title {
    font-family: var(--font-serif);
    font-size: 1.85rem;
    font-weight: 400;
    line-height: 1.25;
    color: var(--text);
    margin-bottom: var(--space-xs);
    transition: color 0.3s ease;
    letter-spacing: -0.01em;
}

.tale-meta-top {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--accent);
    opacity: 0.8;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-weight: 500;
}

.dot {
    color: var(--rule-accent);
}

.reading-time {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 500;
}

.ai-badge {
    font-family: var(--font-serif);
    font-size: 0.7rem;
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 1px 6px;
    border-radius: 2px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
    font-weight: 600;
}

/* ── Tale Footer ────────────────────────────── */
.tale-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

.tale-source {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    color: var(--text-faint);
}

.source-label {
    margin-right: var(--space-xs);
}

.source-link {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.source-link:hover {
    border-bottom-color: var(--accent);
}

.tale-reasoning-toggle {
    background: none;
    border: 1px solid var(--rule);
    color: var(--text-faint);
    font-family: var(--font-sans);
    font-size: 0.72rem;
    padding: var(--space-xs) var(--space-sm);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.02em;
}

.tale-reasoning-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.tale-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.vouch-btn {
    background: none;
    border: 1px solid var(--rule);
    color: var(--text-faint);
    font-family: var(--font-sans);
    font-size: 0.72rem;
    padding: var(--space-xs) var(--space-sm);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.vouch-btn:hover:not(:disabled) {
    border-color: var(--text-muted);
    color: var(--text);
}

.vouch-btn.vouched {
    color: var(--bg);
    background: var(--accent);
    border-color: var(--accent);
    cursor: default;
}

.vouch-count {
    background: var(--bg-surface);
    border: 1px solid var(--rule);
    padding: 0 6px;
    border-radius: 10px;
    font-size: 0.65rem;
}

.vouch-btn.vouched .vouch-count {
    background: rgba(255, 255, 255, 0.2);
    border-color: transparent;
    color: var(--bg);
}

/* ── Reasoning Panel ────────────────────────── */
.tale-reasoning {
    background: transparent;
    border-top: 1px solid var(--rule);
    border-radius: 0;
    padding: var(--space-md) 0 0;
    margin-top: var(--space-md);
    overflow: hidden;
    max-height: 200px;
    opacity: 1;
    transition: max-height 0.4s ease, opacity 0.3s ease, margin 0.4s ease, padding 0.4s ease;
}

.tale-reasoning.hidden {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    padding: 0;
    border-top: 1px solid transparent;
}

.tale-reasoning p {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.6;
    font-style: italic;
}

.reasoning-score {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    color: var(--text-faint);
    display: block;
    margin-top: var(--space-sm);
}

/* ── Footer ─────────────────────────────────── */
#site-footer {
    padding: var(--space-2xl) 0;
    margin-top: var(--space-2xl);
    text-align: center;
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
}

.footer-stats {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--text-faint);
    margin-bottom: var(--space-lg);
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.footer-credit {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--text-faint);
    font-style: italic;
    margin-top: var(--space-lg);
}

.nav-btn {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    margin: 0 10px;
    border: none;
    background: none;
    cursor: pointer;
}

.nav-btn:hover {
    color: var(--accent);
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 768px) {
    html {
        font-size: 16px;
    }

    #site-title {
        font-size: 2.2rem;
    }

    .tale-row {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }
}

/* ── Reading Modal ──────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(249, 241, 232, 0.95); /* Parchment overlay */
    backdrop-filter: blur(4px);
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.dark .modal-overlay {
    background: rgba(30, 30, 26, 0.95);
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: transparent;
    width: 100%;
    max-width: 650px;
    margin: var(--space-2xl) auto;
    position: relative;
    transform: translateY(40px);
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.open .modal {
    transform: translateY(0);
    opacity: 1;
}

.modal-header {
    padding-bottom: var(--space-xl);
    text-align: center;
}

.breadcrumbs {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--text-faint);
    text-align: left;
    margin-bottom: var(--space-xl);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.breadcrumbs span.interactive {
    cursor: pointer;
    transition: color 0.2s ease;
}

.breadcrumbs span.interactive:hover {
    color: var(--accent);
}

.breadcrumbs span.separator {
    margin: 0 8px;
    opacity: 0.5;
}

.modal-header .tale-title {
    font-size: 3rem;
    color: var(--text);
}

.modal-header .tale-meta-top {
    color: var(--accent);
}

/* ── Abstracts ───────────────────── */
.tale-abstract {
    opacity: 1;
    margin-top: var(--space-md);
    padding-bottom: var(--space-md);
    text-align: center;
}

.tale-abstract p {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.6;
    max-width: 500px;
    margin: 0 auto;
}

.modal-body {
    font-size: 1.25rem;
    line-height: 1.9;
    color: var(--text);
    padding-bottom: var(--space-2xl);
}

.modal-footer {
    padding-top: var(--space-xl);
    border-top: 1px solid var(--rule);
    text-align: center;
}

@media (max-width: 768px) {
    .modal {
        margin: 0;
        min-height: 100vh;
        border-radius: 0;
        border: none;
    }
    .modal-header {
        padding: var(--space-xl) var(--space-lg) var(--space-md);
    }
    .modal-body {
        padding: var(--space-lg);
    }
}
