/* ============================================================
   PATRIOTAI — DESIGN SYSTEM
   Tokens · Atmosphere · Components · Motion
   ============================================================ */

:root {
    /* -- Color tokens -- */
    --navy-900: #0A1428;
    --navy-800: #0D1B3D;
    --navy-700: #16264F;
    --blue-600: #1E3A8A;
    --crimson: #B91C1C;
    --crimson-deep: #991B1B;
    --gold: #C9A227;
    --silver: #E7ECF2;
    --slate: #64748B;
    --slate-light: #94A3B8;
    --paper: #F7F9FC;
    --white: #FFFFFF;

    /* -- Semantic -- */
    --bg: var(--paper);
    --panel: var(--white);
    --border: rgba(13, 27, 61, .08);
    --border-strong: rgba(13, 27, 61, .14);
    --text: var(--navy-800);
    --text-dim: var(--slate);

    /* -- Type -- */
    --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;

    /* -- Space (8pt) -- */
    --s1: 4px;  --s2: 8px;  --s3: 16px; --s4: 24px;
    --s5: 32px; --s6: 48px; --s7: 64px; --s8: 96px;

    /* -- Radius -- */
    --r-sm: 10px; --r-md: 16px; --r-lg: 22px; --r-pill: 999px;

    /* -- Elevation -- */
    --shadow-1: 0 1px 2px rgba(13, 27, 61, .05), 0 1px 3px rgba(13, 27, 61, .06);
    --shadow-2: 0 4px 12px rgba(13, 27, 61, .07), 0 2px 4px rgba(13, 27, 61, .05);
    --shadow-3: 0 12px 32px rgba(13, 27, 61, .12), 0 4px 10px rgba(13, 27, 61, .06);
    --shadow-glow: 0 0 0 4px rgba(30, 58, 138, .07);

    /* -- Motion -- */
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --ease-soft: cubic-bezier(.4, 0, .2, 1);

    --maxw: 800px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection { background: rgba(30, 58, 138, .15); }

/* ============================================================
   ATMOSPHERE — layered background artwork, felt not noticed
   ============================================================ */
.atmosphere {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}
/* soft vertical light */
.atmosphere::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(1200px 600px at 50% -8%, rgba(30, 58, 138, .07), transparent 65%),
        radial-gradient(900px 500px at 50% 108%, rgba(13, 27, 61, .06), transparent 70%),
        linear-gradient(180deg, #FBFCFE 0%, var(--paper) 32%, #EEF2F8 100%);
}
/* star field — 3% presence */
.atmosphere::after {
    content: "";
    position: absolute;
    inset: 0 0 40% 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'%3E%3Cg fill='%231E3A8A'%3E%3Cpath d='M30 40l1.8 3.6 4 .6-2.9 2.8.7 4-3.6-1.9-3.6 1.9.7-4-2.9-2.8 4-.6z'/%3E%3Cpath d='M150 20l1.4 2.8 3.1.5-2.2 2.2.5 3.1-2.8-1.5-2.8 1.5.5-3.1-2.2-2.2 3.1-.5z'/%3E%3Cpath d='M210 90l1.4 2.8 3.1.5-2.2 2.2.5 3.1-2.8-1.5-2.8 1.5.5-3.1-2.2-2.2 3.1-.5z'/%3E%3Cpath d='M90 130l1.4 2.8 3.1.5-2.2 2.2.5 3.1-2.8-1.5-2.8 1.5.5-3.1-2.2-2.2 3.1-.5z'/%3E%3Ccircle cx='60' cy='90' r='1.3'/%3E%3Ccircle cx='190' cy='160' r='1.3'/%3E%3Ccircle cx='120' cy='70' r='1'/%3E%3Ccircle cx='220' cy='30' r='1'/%3E%3Ccircle cx='20' cy='170' r='1'/%3E%3Ccircle cx='170' cy='210' r='1.3'/%3E%3C/g%3E%3C/svg%3E");
    opacity: .05;
    mask-image: linear-gradient(180deg, #000 0%, transparent 92%);
    -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 92%);
}
/* capitol watermark anchored at the horizon */
.atmo-capitol {
    position: absolute;
    left: 50%;
    bottom: -2%;
    transform: translateX(-50%);
    width: min(880px, 96vw);
    opacity: .06;
    filter: saturate(.4);
}

/* ============================================================
   APP FRAME
   ============================================================ */
.app {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

/* ---------- Top bar : frosted glass ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px clamp(20px, 4vw, 44px);
    background: rgba(255, 255, 255, .78);
    backdrop-filter: blur(14px) saturate(1.4);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    flex-shrink: 0;
}

.topline {
    height: 3px;
    background: linear-gradient(90deg, var(--navy-800), var(--blue-600) 50%, var(--navy-800));
    flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
    width: 46px;
    height: auto;
    flex-shrink: 0;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(13, 27, 61, .18));
}

.brand-name {
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -.45px;
    color: var(--navy-800);
    line-height: 1.1;
}
.wm-accent { color: var(--crimson); }
.wm-suffix { font-size: .6em; font-weight: 700; color: var(--slate-light); letter-spacing: 0; }

.brand-tag {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 2.2px;
    color: var(--slate);
    margin-top: 2px;
}

.btn-ghost {
    background: rgba(255, 255, 255, .6);
    border: 1px solid var(--border-strong);
    color: var(--navy-800);
    border-radius: var(--r-sm);
    padding: 9px 18px;
    font-family: var(--font-ui);
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: .1px;
    cursor: pointer;
    box-shadow: var(--shadow-1);
    transition: all .25s var(--ease-soft);
}
.btn-ghost:hover {
    border-color: var(--blue-600);
    color: var(--blue-600);
    box-shadow: var(--shadow-2);
    transform: translateY(-1px);
}

/* ============================================================
   HERO — the movie poster
   ============================================================ */
.chat-scroll {
    flex: 1;
    overflow-y: auto;
    padding: var(--s5) var(--s3);
}

.hero {
    max-width: 680px;
    margin: clamp(4px, 1.5vh, 24px) auto 0;
    text-align: center;
}

.hero-stage {
    position: relative;
    margin: 0 auto var(--s2);
    width: min(350px, 85%);
}
.hero-stage::before {
    content: "";
    position: absolute;
    inset: -12% -18%;
    background: radial-gradient(ellipse 60% 55% at 50% 55%, rgba(255, 255, 255, .9), transparent 70%);
    z-index: 0;
}
.hero-art {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: auto;
    mask-image: radial-gradient(ellipse 78% 82% at 50% 45%, #000 55%, transparent 88%);
    -webkit-mask-image: radial-gradient(ellipse 78% 82% at 50% 45%, #000 55%, transparent 88%);
    animation: rise .9s var(--ease-out) both;
}

.hero h1 {
    margin: 0 0 var(--s2);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(32px, 4.4vw, 42px);
    letter-spacing: -.5px;
    line-height: 1.08;
    color: var(--navy-800);
    animation: rise .9s var(--ease-out) .08s both;
}

.hero-sub {
    margin: 0 auto var(--s3);
    max-width: 500px;
    color: var(--text-dim);
    font-size: 16px;
    line-height: 1.65;
    animation: rise .9s var(--ease-out) .16s both;
}

/* -- Suggested prompts -- */
.chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 9px;
    margin-bottom: var(--s3);
    animation: rise .9s var(--ease-out) .24s both;
}
.chip {
    background: rgba(255, 255, 255, .85);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    padding: 10px 20px;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 500;
    color: var(--navy-700);
    cursor: pointer;
    box-shadow: var(--shadow-1);
    transition: all .25s var(--ease-soft);
}
.chip:hover {
    border-color: rgba(30, 58, 138, .35);
    color: var(--blue-600);
    transform: translateY(-2px);
    box-shadow: var(--shadow-2);
}
.chip:active { transform: translateY(0); }

/* -- Value badges : quiet, institutional -- */
.badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--s4);
    animation: rise .9s var(--ease-out) .32s both;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--slate);
}
.badge svg { width: 14px; height: 14px; color: var(--gold); }
.badge-red svg { color: var(--crimson); }

/* ============================================================
   MESSAGES
   ============================================================ */
.messages {
    max-width: var(--maxw);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--s4);
}

.msg {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    animation: msg-in .5s var(--ease-out) both;
}
.msg.user { flex-direction: row-reverse; }

.avatar {
    width: 34px; height: 34px;
    border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 11.5px;
    letter-spacing: .3px;
    flex-shrink: 0;
    margin-top: 2px;
}
.assistant-avatar { background: transparent; }
.assistant-avatar img { width: 32px; height: auto; display: block; filter: drop-shadow(0 1px 3px rgba(13,27,61,.2)); }
.user .avatar {
    background: linear-gradient(150deg, var(--navy-700), var(--navy-900));
    color: rgba(255, 255, 255, .92);
    box-shadow: var(--shadow-1);
}

.bubble {
    padding: 15px 20px;
    border-radius: var(--r-md);
    line-height: 1.65;
    font-size: 15.5px;
    max-width: 82%;
    overflow-wrap: break-word;
    white-space: normal;
}
.assistant .bubble {
    background: var(--panel);
    border: 1px solid var(--border);
    border-top-left-radius: var(--s1);
    box-shadow: var(--shadow-2);
}
.user .bubble {
    background: linear-gradient(150deg, var(--navy-700), var(--navy-900));
    color: rgba(255, 255, 255, .95);
    border-top-right-radius: var(--s1);
    box-shadow: var(--shadow-2);
}

.bubble p { margin: 0 0 .75em; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: .45em 0 .75em; padding-left: 1.35em; }
.bubble li { margin: .3em 0; }
.bubble h1, .bubble h2, .bubble h3 {
    margin: .9em 0 .45em;
    font-size: 1.06em;
    font-weight: 700;
    letter-spacing: -.2px;
    color: var(--navy-800);
}
.bubble a { color: var(--blue-600); text-decoration-color: rgba(30,58,138,.3); text-underline-offset: 3px; }
.bubble code {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.5px 7px;
    font-size: .87em;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.bubble pre {
    background: var(--navy-900);
    color: var(--silver);
    border-radius: var(--r-sm);
    padding: 14px 18px;
    overflow-x: auto;
    margin: .7em 0;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.bubble pre code { background: none; border: none; padding: 0; color: inherit; }
.bubble blockquote {
    margin: .7em 0;
    padding: .25em 1.1em;
    border-left: 2px solid var(--gold);
    color: var(--text-dim);
    font-style: italic;
}

/* Typing indicator */
.typing { display: inline-flex; gap: 6px; padding: 7px 2px; }
.typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--slate-light);
    animation: pulse 1.3s var(--ease-soft) infinite;
}
.typing span:nth-child(2) { animation-delay: .18s; }
.typing span:nth-child(3) { animation-delay: .36s; }
@keyframes pulse {
    0%, 70%, 100% { opacity: .25; transform: scale(.85); }
    35% { opacity: 1; transform: scale(1); }
}

/* ============================================================
   COMPOSER — the hero object
   ============================================================ */
.composer-wrap {
    flex-shrink: 0;
    padding: var(--s2) var(--s3) var(--s3);
}

.composer {
    max-width: var(--maxw);
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    padding: 14px 14px 14px 24px;
    box-shadow: var(--shadow-3);
    transition: box-shadow .35s var(--ease-soft), border-color .35s var(--ease-soft), transform .35s var(--ease-soft);
}
.composer:focus-within {
    border-color: rgba(30, 58, 138, .45);
    box-shadow: var(--shadow-3), var(--shadow-glow);
    transform: translateY(-2px);
}

#prompt {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 16.5px;
    line-height: 1.55;
    max-height: 200px;
    padding: 6px 0;
}
#prompt::placeholder { color: var(--slate-light); }

#mic {
    width: 44px; height: 44px;
    border-radius: 14px;
    border: 1px solid var(--border-strong);
    background: var(--paper);
    color: var(--slate);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .25s var(--ease-soft);
    flex-shrink: 0;
}
#mic:hover { color: var(--blue-600); border-color: rgba(30, 58, 138, .4); }
#mic.recording {
    background: linear-gradient(160deg, var(--crimson), var(--crimson-deep));
    border-color: transparent;
    color: #fff;
    animation: mic-pulse 1.6s var(--ease-soft) infinite;
}
@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(185, 28, 28, .35); }
    50%      { box-shadow: 0 0 0 9px rgba(185, 28, 28, 0); }
}

#send {
    width: 44px; height: 44px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(160deg, var(--crimson), var(--crimson-deep));
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 10px rgba(185, 28, 28, .3);
    transition: all .25s var(--ease-soft);
    flex-shrink: 0;
}
#send:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(185, 28, 28, .38); }
#send:active { transform: translateY(0); }
#send:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }

.fineprint {
    max-width: var(--maxw);
    margin: 14px auto 0;
    text-align: center;
    font-size: 11.5px;
    color: var(--slate-light);
    line-height: 1.8;
}
.fine-taglines {
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--slate);
}
.fine-link { color: var(--slate); text-decoration: underline; text-underline-offset: 2px; }
.fine-link:hover { color: var(--blue-600); }

.error-note { color: var(--crimson); }

/* ============================================================
   AUTH — sign in / create account
   ============================================================ */
.top-actions { display: flex; gap: 10px; align-items: center; }

.hidden { display: none !important; }

.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(13, 27, 61, .45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--s3);
}
.auth-card {
    position: relative;
    background: var(--panel);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-3);
    padding: var(--s5) var(--s5) var(--s4);
    width: 100%;
    max-width: 400px;
    text-align: center;
    animation: rise .45s var(--ease-out) both;
}
.auth-close {
    position: absolute;
    top: 14px; right: 16px;
    background: none;
    border: none;
    font-size: 18px;
    color: var(--slate-light);
    cursor: pointer;
}
.auth-close:hover { color: var(--navy-800); }
.auth-logo { width: 52px; height: auto; margin: 0 auto var(--s3); display: block; }
.auth-card h2 {
    margin: 0 0 6px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 24px;
    letter-spacing: -.3px;
    color: var(--navy-800);
}
.auth-sub { margin: 0 0 var(--s4); color: var(--text-dim); font-size: 14px; }
.auth-input {
    width: 100%;
    background: var(--paper);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    color: var(--text);
    padding: 12px 14px;
    font-family: var(--font-ui);
    font-size: 15px;
    outline: none;
    margin-bottom: 10px;
    transition: border-color .2s var(--ease-soft), box-shadow .2s var(--ease-soft);
}
.auth-input:focus { border-color: rgba(30, 58, 138, .5); box-shadow: var(--shadow-glow); }
.auth-error {
    color: var(--crimson);
    font-size: 13px;
    margin: 2px 0 10px;
}
.auth-primary {
    width: 100%;
    border: none;
    border-radius: var(--r-sm);
    background: linear-gradient(160deg, var(--crimson), var(--crimson-deep));
    color: #fff;
    font-family: var(--font-ui);
    font-size: 15px;
    font-weight: 600;
    padding: 13px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(185, 28, 28, .28);
    transition: all .25s var(--ease-soft);
}
.auth-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(185, 28, 28, .36); }
.auth-primary:disabled { opacity: .5; transform: none; }
.auth-switch { margin-top: var(--s3); font-size: 13.5px; color: var(--text-dim); }
.auth-switch a { color: var(--blue-600); font-weight: 600; text-decoration: none; margin-left: 4px; }
.auth-switch a:hover { text-decoration: underline; }

/* ============================================================
   EMPTY STATE — composer rides beneath the hero
   ============================================================ */
.bottom-art { display: none; }

.app.empty .chat-scroll {
    /* Shrinks to fit; scrolls itself on short viewports so the
       composer never leaves the screen. */
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-top: var(--s3);
    padding-bottom: var(--s1);
}
.app.empty .composer-wrap { padding-top: var(--s2); }
.app.empty .composer { max-width: 660px; }
.app.empty::after { content: ""; flex: 1; }

/* ============================================================
   MOTION
   ============================================================ */
@keyframes rise {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes msg-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
    .bubble { max-width: 90%; font-size: 15px; }
    .brand-tag { display: none; }
    .brand-name { font-size: 19px; }
    .brand-mark { width: 38px; }
    .hero { margin-top: 1vh; }
    .hero-sub { margin-bottom: var(--s4); }
    .chips { margin-bottom: var(--s4); }
    .badges { gap: var(--s3); }
    .composer { padding: 11px 11px 11px 18px; }
    #send, #mic { width: 40px; height: 40px; }
}
