/* ============================================
   SNAPTARA — Analog Darkroom
   Background: Deep warm black
   Type: Cormorant Garamond (display) + IBM Plex Mono (UI)
   Accent: Amber safelight / copper
   ============================================ */

/* ─── Accessibility / SEO ─── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip to main content link — off-screen until focused */
.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    z-index: 10000;
    text-decoration: none;
}

.skip-link:focus {
    position: fixed;
    top: 10px;
    left: 10px;
    width: auto;
    height: auto;
    overflow: visible;
    background: #EDE0CA;
    color: #080604;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    outline: 2px solid var(--amber);
    outline-offset: 2px;
}

/* ─── Custom Properties ─── */
:root {
    /* Backgrounds */
    --bg:          #080604;
    --bg-card:     rgba(16, 11, 7, 0.98);
    --bg-elevated: rgba(24, 17, 11, 0.92);

    /* Borders */
    --border:        rgba(237, 224, 202, 0.06);
    --border-warm:   rgba(237, 224, 202, 0.11);
    --border-amber:  rgba(192, 57, 43, 0.32);

    /* Typography — warm cream */
    --text:        #EDE0CA;
    --text-dim:    rgba(237, 224, 202, 0.52);
    --text-faint:  rgba(237, 224, 202, 0.22);

    /* Accent — safelight red / darkroom crimson */
    --amber:        #C0392B;
    --amber-bright: #D44235;
    --amber-glow:   rgba(192, 57, 43, 0.22);
    --amber-deep:   rgba(192, 57, 43, 0.08);

    /* Fonts */
    --font-display: 'Plus Jakarta Sans', 'Helvetica Neue', sans-serif;
    --font-ui:      'Plus Jakarta Sans', 'Helvetica Neue', sans-serif;
    --font-mono:    'SF Mono', ui-monospace, 'Courier New', monospace;

    /* Geometry — flat, analog, no big rounding */
    --radius-xs: 2px;
    --radius-sm: 3px;

    /* Easing */
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html { height: 100%; }

body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ─── Film Grain Overlay ─── */
.grain-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.055;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-size: 220px 220px;
    animation: grain 0.35s steps(1) infinite;
}

@keyframes grain {
    0%   { transform: translate(0,    0); }
    14%  { transform: translate(5px, -3px); }
    28%  { transform: translate(-4px,  6px); }
    42%  { transform: translate(7px,   2px); }
    57%  { transform: translate(-3px, -7px); }
    71%  { transform: translate(-6px,  4px); }
    85%  { transform: translate(4px,  -5px); }
    100% { transform: translate(-5px,  8px); }
}

/* ─────────────────────────────────────────
   APP WRAPPER
───────────────────────────────────────── */
.app-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    /* Warm safelight glow at center, cool dark vignette at edges */
    background:
        radial-gradient(ellipse 80% 60% at 50% 38%,
            rgba(192, 57, 43, 0.07) 0%,
            transparent 65%
        ),
        radial-gradient(ellipse 120% 80% at 50% 110%,
            rgba(4, 2, 1, 0.6) 0%,
            transparent 55%
        );
}

/* ─────────────────────────────────────────
   HEADER
───────────────────────────────────────── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(5, 3, 2, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    font-family: var(--font-display);
    font-size: 20px;
    font-style: normal;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.logo-badge {
    display: none;
    font-family: var(--font-ui);
    font-size: 9px;
    font-weight: 400;
    color: var(--text);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 2px 7px;
}

.roll-counter {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 400;
    color: var(--text);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

#rollNumber {
    color: var(--amber-bright);
    font-weight: 500;
}

/* ─────────────────────────────────────────
   MAIN
───────────────────────────────────────── */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 20px;
}

/* ─────────────────────────────────────────
   PROMPT DISPLAY — Analog Film Card
───────────────────────────────────────── */
.idea-display {
    width: 100%;
    max-width: 560px;
    min-height: 178px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top-color: var(--border-amber);
    border-radius: var(--radius-xs);
    box-shadow:
        0 0 60px var(--amber-glow),
        0 1px 0  rgba(200, 123, 48, 0.10),
        0 20px 60px rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    /* left/right padding accounts for 16px film edge + breathing room */
    padding: 38px 34px;
    position: relative;
    overflow: hidden;
}

/* Amber light leak — thin gradient line along the top edge */
.idea-display::before {
    content: '';
    position: absolute;
    top: 0;
    left: 16px;
    right: 16px;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(192, 57, 43, 0.55) 25%,
        rgba(210, 68, 46, 0.85) 50%,
        rgba(192, 57, 43, 0.55) 75%,
        transparent 100%
    );
}

/* Film perforation strips */
.film-edge {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 16px;
    /* Alternating hole / strip pattern */
    background: repeating-linear-gradient(
        to bottom,
        #050302 0px,
        #050302 5px,
        #1A1108 5px,
        #1A1108 16px,
        #050302 16px,
        #050302 21px
    );
}

.film-edge--left {
    left: 0;
    border-right: 1px solid rgba(237, 224, 202, 0.05);
}

.film-edge--right {
    right: 0;
    border-left: 1px solid rgba(237, 224, 202, 0.05);
}

.idea-text {
    font-family: var(--font-display);
    font-size: clamp(20px, 5vw, 32px);
    font-style: normal;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: -0.02em;
    color: var(--text);
    text-align: center;
    position: relative;
    z-index: 1;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.idea-text.fade-out {
    opacity: 0;
    transform: translateY(7px);
}

.idea-text.fade-in {
    opacity: 1;
    transform: translateY(0);
}

/* ─────────────────────────────────────────
   ACTION BUTTONS — mobile-first, side by side
───────────────────────────────────────── */
.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 560px;
}

/* Generate — amber / copper */
.btn-generate {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--amber);
    color: #F5E8E5;
    border: none;
    border-radius: var(--radius-sm);
    padding: 13px 22px;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.01em;
    text-transform: none;
    cursor: pointer;
    box-shadow:
        0 0 24px var(--amber-glow),
        inset 0 1px 0 rgba(255, 180, 160, 0.22);
    transition: background 0.14s ease, box-shadow 0.14s ease, transform 0.14s var(--ease-spring);
}

.btn-generate:hover {
    background: var(--amber-bright);
    box-shadow:
        0 0 40px rgba(192, 57, 43, 0.45),
        inset 0 1px 0 rgba(255, 180, 160, 0.26);
    transform: translateY(-1px);
}

.btn-generate:active {
    transform: scale(0.97);
    box-shadow:
        0 0 12px var(--amber-glow),
        inset 0 1px 0 rgba(255, 180, 160, 0.10);
}

.btn-generate:focus-visible {
    outline: 2px solid rgba(192, 57, 43, 0.65);
    outline-offset: 3px;
}

.btn-generate.firing .shutter-icon {
    animation: shutter-click 0.38s var(--ease-spring);
}

@keyframes shutter-click {
    0%   { transform: scale(1)    rotate(0deg); }
    28%  { transform: scale(0.72) rotate(-14deg); }
    62%  { transform: scale(1.12) rotate(7deg); }
    100% { transform: scale(1)    rotate(0deg); }
}

.shutter-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.85;
}

/* Copy — dark ghost */
.btn-copy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border-warm);
    border-radius: var(--radius-sm);
    padding: 12px 22px;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 400;
    letter-spacing: -0.01em;
    text-transform: none;
    cursor: pointer;
    transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease, transform 0.14s var(--ease-spring);
}

.btn-copy svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    opacity: 0.50;
    transition: opacity 0.14s;
}

.btn-copy:hover {
    background: rgba(237, 224, 202, 0.05);
    color: var(--text);
    border-color: rgba(237, 224, 202, 0.20);
}

.btn-copy:hover svg {
    opacity: 0.80;
}

.btn-copy:active {
    transform: scale(0.97);
}

.btn-copy:focus-visible {
    outline: 2px solid rgba(237, 224, 202, 0.25);
    outline-offset: 2px;
}

/* ─────────────────────────────────────────
   HISTORY STRIP
───────────────────────────────────────── */
.history-strip {
    border-top: 1px solid var(--border);
    padding: 16px 20px 24px;
    flex-shrink: 0;
    background: rgba(4, 3, 1, 0.85);
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.history-label {
    font-family: var(--font-ui);
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.btn-clear {
    background: none;
    border: none;
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-dim);
    cursor: pointer;
    /* 44×44px minimum touch target — WCAG 2.5.5 */
    min-height: 44px;
    min-width: 44px;
    padding: 0 8px;
    transition: color 0.12s;
}

.btn-clear:hover {
    color: var(--amber);
}

.btn-clear:focus-visible {
    outline: 2px solid rgba(237, 224, 202, 0.50);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

.history-list {
    list-style: none;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
}

.history-list::-webkit-scrollbar {
    display: none;
}

.history-item {
    flex-shrink: 0;
    width: 185px;
    background: rgba(14, 10, 6, 0.97);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 12px 13px;
    animation: slideIn 0.24s var(--ease-smooth);
    transition: background 0.12s, border-color 0.12s;
    cursor: default;
    position: relative;
    overflow: hidden;
}

/* Amber accent on top of each history tile */
.history-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--amber);
    opacity: 0.20;
}

.history-item:hover {
    background: rgba(22, 15, 9, 0.98);
    border-color: var(--border-warm);
}

.history-frame-num {
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.12em;
    color: var(--amber-bright);
    opacity: 0.70;
    margin-bottom: 7px;
}

.history-item-text {
    font-family: var(--font-ui);
    font-size: 13px;
    font-style: normal;
    font-weight: 400;
    color: var(--text);
    line-height: 1.55;
}

.history-empty {
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-dim);
    padding: 4px 0;
    letter-spacing: 0.04em;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(10px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ─────────────────────────────────────────
   TOAST
───────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 54px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: rgba(20, 14, 8, 0.97);
    border: 1px solid var(--border-amber);
    border-radius: var(--radius-sm);
    padding: 8px 15px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 400;
    letter-spacing: -0.01em;
    text-transform: none;
    color: var(--text);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease, transform 0.18s var(--ease-smooth), visibility 0.18s ease;
    z-index: 99;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.65), 0 0 16px var(--amber-glow);
}

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

.toast svg {
    width: 12px;
    height: 12px;
    color: var(--amber);
    flex-shrink: 0;
}

/* ─────────────────────────────────────────
   FOOTER
───────────────────────────────────────── */
.footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 16px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: rgba(4, 2, 1, 0.70);
}

.footer-hints {
    display: flex;
    gap: 20px;
    align-items: center;
}

.footer-credit {
    font-family: var(--font-ui);
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: -0.01em;
}

.footer-credit-link {
    color: var(--amber-bright);
    text-decoration: none;
    transition: opacity 0.14s ease;
}

.footer-credit-link:hover {
    opacity: 0.75;
}

.footer-credit-link:focus-visible {
    outline: 2px solid rgba(192, 57, 43, 0.55);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

.hint {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-dim);
    letter-spacing: -0.01em;
    text-transform: none;
}

kbd {
    display: inline-block;
    padding: 2px 6px;
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-dim);
    background: rgba(237, 224, 202, 0.05);
    border: 1px solid var(--border-warm);
    border-radius: var(--radius-xs);
}

/* ─────────────────────────────────────────
   FAQ — Matches history strip aesthetic
───────────────────────────────────────── */
.faq {
    border-top: 1px solid var(--border);
    padding: 16px 20px 24px;
    flex-shrink: 0;
    background: rgba(4, 3, 1, 0.85);
}

.faq-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

/* Matches .history-label exactly */
.faq-eyebrow {
    font-family: var(--font-ui);
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.faq-title {
    display: none; /* label is enough; h2 still in DOM for a11y */
}

/* ── FAQ List — vertical stack of cards ── */
.faq-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── FAQ Item — mirrors .history-item ── */
.faq-item {
    background: rgba(14, 10, 6, 0.97);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    animation: slideIn 0.24s var(--ease-smooth);
    transition: background 0.12s, border-color 0.12s;
    position: relative;
    overflow: hidden;
}

/* Amber top-edge accent — matches history-item::before */
.faq-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--amber);
    opacity: 0.20;
    transition: opacity 0.22s ease;
}

.faq-item.open::before {
    opacity: 0.80;
}

.faq-item:hover {
    background: rgba(22, 15, 9, 0.98);
    border-color: var(--border-warm);
}

.faq-q {
    margin: 0;
}

/* ── FAQ Button ── */
.faq-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 11px 12px 11px 12px;
    text-align: left;
    color: var(--text);
}

.faq-btn:focus-visible {
    outline: 2px solid rgba(192, 57, 43, 0.55);
    outline-offset: -2px;
    border-radius: var(--radius-sm);
}

/* Frame number — matches .history-frame-num */
.faq-frame {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.12em;
    color: var(--amber-bright);
    opacity: 0.70;
    flex-shrink: 0;
    transition: opacity 0.2s ease;
    margin-bottom: 0;
}

.faq-item.open .faq-frame {
    opacity: 1;
}

/* Question text — matches .history-item-text weight/size */
.faq-q-text {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
    line-height: 1.55;
    flex: 1;
}

/* Chevron */
.faq-chevron {
    width: 13px;
    height: 13px;
    color: var(--text-dim);
    flex-shrink: 0;
    opacity: 0.50;
    transition: transform 0.28s var(--ease-smooth), opacity 0.2s ease, color 0.2s ease;
}

.faq-item.open .faq-chevron {
    transform: rotate(180deg);
    opacity: 1;
    color: var(--amber);
}

/* ── FAQ Answer — CSS grid height animation ── */
.faq-answer {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.30s var(--ease-smooth);
}

.faq-item.open .faq-answer {
    grid-template-rows: 1fr;
}

.faq-answer-inner {
    overflow: hidden;
}

.faq-answer p {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.65;
    color: var(--text);
    padding: 2px 12px 13px 34px;
}

/* ─────────────────────────────────────────
   RESPONSIVE — Desktop
───────────────────────────────────────── */
@media (min-width: 600px) {
    .header {
        padding: 16px 28px;
    }

    .logo-badge {
        display: inline-block;
    }

    .main {
        padding: 64px 32px;
        gap: 26px;
    }

    .idea-display {
        padding: 52px 48px;
        min-height: 200px;
    }

    .actions {
        width: auto;
    }

    .btn-generate,
    .btn-copy {
        flex: none;
    }

    .history-strip {
        padding: 18px 28px 28px;
    }

    .history-item {
        width: 200px;
    }

    .faq {
        padding: 18px 28px 28px;
    }
}

/* ─────────────────────────────────────────
   ACCESSIBILITY
───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .grain-overlay {
        animation: none !important;
    }
}

@media (prefers-contrast: high) {
    :root {
        --border:       rgba(237, 224, 202, 0.22);
        --border-warm:  rgba(237, 224, 202, 0.36);
        --text-dim:     rgba(237, 224, 202, 0.78);
        --text-faint:   rgba(237, 224, 202, 0.52);
    }
}
