@font-face {
    font-family: "Newsreader";
    src: url(/static/fonts/newsreader.ttf) format("truetype-variations");
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Newsreader";
    src: url(/static/fonts/newsreader-italic.ttf) format("truetype-variations");
    font-weight: 300 700;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: "Public Sans";
    src: url(/static/fonts/publicsans.ttf) format("truetype-variations");
    font-weight: 300 800;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "IBM Plex Mono";
    src: url(/static/fonts/plexmono-regular.ttf) format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "IBM Plex Mono";
    src: url(/static/fonts/plexmono-medium.ttf) format("truetype");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #ECEEEA;
    --surface: #F7F8F4;
    --surface-raised: #FFFFFF;
    --ink: #14171B;
    --muted: #5B5D54;
    --rule: #D6D4C8;
    --brass: #8A5E1D;
    --brass-strong: #6E4B17;
    --brass-ink: #FFFFFF;
    --signal-up: #2F6B4E;
    --signal-down: #A23B2E;
    --shadow: rgba(20, 23, 27, 0.08);
    --focus: #2F6B4E;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #14171B;
        --surface: #191D21;
        --surface-raised: #1F2327;
        --ink: #ECEAE1;
        --muted: #9C9D92;
        --rule: #2B2F2C;
        --brass: #D6A34C;
        --brass-strong: #E8B968;
        --brass-ink: #14171B;
        --signal-up: #5FAE86;
        --signal-down: #E07A63;
        --shadow: rgba(0, 0, 0, 0.4);
        --focus: #5FAE86;
    }
}

:root[data-theme="dark"] {
    --bg: #14171B;
    --surface: #191D21;
    --surface-raised: #1F2327;
    --ink: #ECEAE1;
    --muted: #9C9D92;
    --rule: #2B2F2C;
    --brass: #D6A34C;
    --brass-strong: #E8B968;
    --brass-ink: #14171B;
    --signal-up: #5FAE86;
    --signal-down: #E07A63;
    --shadow: rgba(0, 0, 0, 0.4);
    --focus: #5FAE86;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Public Sans", -apple-system, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
::selection { background: var(--brass); color: var(--brass-ink); }

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

h1, h2, h3 {
    font-family: "Newsreader", Georgia, serif;
    font-weight: 500;
    text-wrap: balance;
    margin: 0;
}

em { font-style: italic; color: var(--brass); }

.mono {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
}

.eyebrow {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

.wrap {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* ---------- Masthead ---------- */

header.masthead {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    border-bottom: 1px solid var(--rule);
}

/* backdrop-filter (like transform/filter) makes its element a containing block for
   position:fixed descendants -- harmless on desktop where #auth-panel is
   position:absolute, but on mobile it's position:fixed and needs the real viewport as
   its containing block, so the blur is desktop-only. */
@media (min-width: 641px) {
    header.masthead { backdrop-filter: blur(10px); }
}

.masthead-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 1.1rem 0;
    gap: 1.5rem;
}

.wordmark {
    display: flex;
    align-items: baseline;
    gap: 0.65rem;
    text-decoration: none;
    color: var(--ink);
}

.wordmark .g {
    font-family: "Newsreader", serif;
    font-style: italic;
    font-weight: 600;
    font-size: 1.65rem;
    letter-spacing: 0.01em;
}

.wordmark .tag {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.66rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    display: none;
}

@media (min-width: 640px) {
    .wordmark .tag { display: inline; }
}

.masthead-actions {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn {
    font-family: "Public Sans", sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: 3px;
    padding: 0.55rem 1.05rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-ghost {
    background: transparent;
    border-color: var(--rule);
    color: var(--ink);
}
.btn-ghost:hover { border-color: var(--brass); color: var(--brass); }
.btn-ghost[aria-expanded="true"] {
    background: var(--surface-raised);
    border-color: var(--brass);
    color: var(--brass);
}

.btn-solid {
    background: var(--brass);
    color: var(--brass-ink);
}
.btn-solid:hover { background: var(--brass-strong); }

.btn-text {
    background: none;
    border: none;
    padding: 0;
    font-family: "Public Sans", sans-serif;
    font-size: 0.82rem;
    color: var(--muted);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.btn-text:hover { color: var(--brass); }

/* ---------- Auth panel (compact dropdown under the Log in / Sign up buttons) ---------- */

#auth-panel {
    position: absolute;
    top: calc(100% + 0.65rem);
    right: 0;
    width: min(320px, calc(100vw - 2rem));
    background: var(--surface-raised);
    border: 1px solid var(--rule);
    border-radius: 8px;
    box-shadow: 0 16px 32px -12px var(--shadow);
    opacity: 0;
    transform: translateY(-4px);
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}
#auth-panel.open {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
}
@media (prefers-reduced-motion: reduce) {
    #auth-panel { transition: none; }
}

.auth-close {
    display: none;
    position: absolute;
    top: 0.6rem;
    right: 0.7rem;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.6rem;
    line-height: 1;
    padding: 0.5rem;
    cursor: pointer;
    z-index: 1;
}
.auth-close:hover { color: var(--brass); }

.auth-panel-inner {
    padding: 1.25rem 1.15rem;
}

/* Below the breakpoint where the dropdown card would otherwise get squeezed against the
   right edge, the panel takes the full screen instead -- anchored positioning stops
   making sense once there's no room beside it. This must come after the base
   #auth-panel/.auth-panel-inner rules above -- same specificity, so cascade order (not
   just the media query) is what makes these overrides actually win on mobile. */
@media (max-width: 640px) {
    #auth-panel {
        position: fixed;
        inset: 0;
        top: 0;
        width: 100%;
        height: 100%;
        border: none;
        border-radius: 0;
        box-shadow: none;
        background: var(--bg);
        transform: none;
        overflow-y: auto;
        z-index: 30;
    }
    #auth-panel.open { opacity: 1; }
    .auth-close { display: block; }
    .auth-panel-inner {
        max-width: 420px;
        margin: 0 auto;
        padding: 4.5rem 1.5rem 3rem;
        min-height: 100%;
    }
}

.auth-panel-inner h3 {
    font-size: 1.05rem;
    margin-bottom: 0.25rem;
}
.auth-panel-sub {
    color: var(--muted);
    font-size: 0.78rem;
    margin-bottom: 1rem;
}

.reset-message {
    background: color-mix(in srgb, var(--signal-up) 12%, transparent);
    border: 1px solid var(--signal-up);
    color: var(--signal-up);
    border-radius: 4px;
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
    margin-bottom: 1.2rem;
}

.error-message {
    background: color-mix(in srgb, var(--signal-down) 12%, transparent);
    border: 1px solid var(--signal-down);
    color: var(--signal-down);
    border-radius: 4px;
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
    margin-bottom: 1.2rem;
}

.field {
    margin-bottom: 0.6rem;
}
.field label {
    display: block;
    font-size: 0.72rem;
    color: var(--muted);
    margin-bottom: 0.2rem;
}
.field input {
    width: 100%;
    background: var(--surface-raised);
    border: 1px solid var(--rule);
    border-radius: 3px;
    color: var(--ink);
    font-family: "Public Sans", sans-serif;
    font-size: 0.88rem;
    padding: 0.45rem 0.6rem;
}
.field input:focus { border-color: var(--brass); }

/* Matches the classes password-toggle.js injects at runtime around any
   input[type=password] -- keeps the reveal control consistent with the rest of GAIN. */
.password-wrap { position: relative; }
.password-wrap input { padding-right: 2.9rem; }
.password-toggle {
    position: absolute;
    right: 0.25rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.68rem;
    padding: 0.25rem 0.4rem;
    cursor: pointer;
}
.password-toggle:hover { color: var(--brass); }

.field-row { display: flex; gap: 0.6rem; }
.field-row .field { flex: 1; min-width: 0; }

.auth-row-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: -0.1rem 0 0.8rem;
}

.auth-submit {
    width: 100%;
    margin-top: 0.1rem;
    padding: 0.5rem 1.05rem;
}

.auth-switch {
    margin-top: 0.9rem;
    font-size: 0.78rem;
    color: var(--muted);
    text-align: center;
}
.auth-switch button {
    background: none;
    border: none;
    color: var(--brass);
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    font-size: inherit;
    font-family: inherit;
}

.auth-state { display: none; }
.auth-state.active { display: block; }

.confirm-icon {
    width: 2.6rem;
    height: 2.6rem;
    border: 1px solid var(--signal-up);
    color: var(--signal-up);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

/* ---------- Hero ---------- */

.hero {
    padding: 4.5rem 0 5rem;
    border-bottom: 1px solid var(--rule);
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 3.5rem;
    align-items: center;
}

@media (max-width: 860px) {
    .hero-grid { grid-template-columns: 1fr; gap: 2.5rem; }
}

.hero h1 {
    font-size: clamp(2.3rem, 4.4vw, 3.4rem);
    line-height: 1.08;
    letter-spacing: -0.01em;
}

.hero-sub {
    margin-top: 1.4rem;
    font-size: 1.08rem;
    color: var(--muted);
    max-width: 46ch;
}

.hero-cta {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.link-arrow {
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--ink);
    border-bottom: 1px solid var(--rule);
    padding-bottom: 0.15rem;
}
.link-arrow:hover { color: var(--brass); border-color: var(--brass); }

/* Alert ticket */

.ticket {
    background: var(--surface-raised);
    border: 1px solid var(--rule);
    border-radius: 4px;
    box-shadow: 0 18px 40px -18px var(--shadow);
    position: relative;
    overflow: hidden;
}

.ticket::before {
    content: "";
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 16px;
    background-image: radial-gradient(circle at 12px 8px, var(--bg) 6px, transparent 6.5px);
    background-size: 24px 16px;
    background-repeat: repeat-x;
}

.ticket-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.3rem 1.4rem 0.9rem;
    border-bottom: 1px dashed var(--rule);
}

.ticket-head .eyebrow { letter-spacing: 0.14em; }

.ticket-live {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.68rem;
    color: var(--signal-up);
}
.ticket-live .dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--signal-up);
}
@media (prefers-reduced-motion: no-preference) {
    .ticket-live .dot { animation: pulse 2.2s ease-in-out infinite; }
}
@keyframes pulse {
    0%, 100% { opacity: 1; } 50% { opacity: 0.35; }
}

.ticket-body { padding: 1.3rem 1.4rem 1.5rem; }

.ticket-ticker {
    display: flex;
    align-items: baseline;
    gap: 0.7rem;
    margin-bottom: 0.2rem;
}
.ticket-ticker .sym {
    font-family: "Newsreader", serif;
    font-size: 1.9rem;
    font-weight: 600;
}
.ticket-ticker .delta {
    font-family: "IBM Plex Mono", monospace;
    font-size: 1.15rem;
    color: var(--signal-down);
    font-variant-numeric: tabular-nums;
}

.ticket-meta {
    color: var(--muted);
    font-size: 0.88rem;
    margin-bottom: 1rem;
}

.ticket-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--rule);
}
.ticket-row:first-of-type { border-top: 1px solid var(--rule); margin-top: 0.2rem; }
.ticket-row .k { color: var(--muted); }
.ticket-row .v { font-family: "IBM Plex Mono", monospace; }

/* ---------- Sections ---------- */

section { padding: 4.5rem 0; }
section.alt { background: var(--surface); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }

.section-head {
    max-width: 56ch;
    margin-bottom: 2.6rem;
}
.section-head h2 {
    font-size: clamp(1.7rem, 2.6vw, 2.2rem);
    margin-top: 0.5rem;
}
.section-head p {
    color: var(--muted);
    margin-top: 0.9rem;
    font-size: 1.02rem;
}

/* Feature tiles */

.tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--rule);
    border: 1px solid var(--rule);
}
@media (max-width: 860px) {
    .tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
    .tiles { grid-template-columns: 1fr; }
}

.tile {
    background: var(--surface-raised);
    padding: 1.9rem 1.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.tile .eyebrow-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tile-status {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.64rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--brass);
    border: 1px solid var(--brass);
    border-radius: 2px;
    padding: 0.12rem 0.4rem;
}

.tile h3 {
    font-size: 1.2rem;
    font-weight: 500;
}

.tile p {
    color: var(--muted);
    font-size: 0.92rem;
    margin: 0;
}

/* Process strip */

.process {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2.5rem;
}
@media (max-width: 760px) {
    .process { grid-template-columns: 1fr; gap: 2rem; }
}
.process-step .num {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.85rem;
    color: var(--brass);
    margin-bottom: 0.6rem;
}
.process-step h3 {
    font-size: 1.15rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}
.process-step p {
    color: var(--muted);
    font-size: 0.92rem;
    margin: 0;
}

/* Testimonials */

.stories {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
}
@media (max-width: 860px) {
    .stories { grid-template-columns: 1fr; }
}
.story {
    padding: 0 2rem 0 0;
    border-left: 1px solid var(--rule);
    padding-left: 2rem;
}
.story:first-child { border-left: none; padding-left: 0; }
@media (max-width: 860px) {
    .story { border-left: none; padding-left: 0; border-top: 1px solid var(--rule); padding-top: 2rem; margin-top: 2rem; }
    .story:first-child { border-top: none; padding-top: 0; margin-top: 0; }
}
.story blockquote {
    margin: 0 0 1.1rem;
    font-family: "Newsreader", serif;
    font-style: italic;
    font-size: 1.14rem;
    line-height: 1.5;
}
.story cite {
    font-style: normal;
    font-size: 0.82rem;
    color: var(--muted);
}
.story cite strong { color: var(--ink); font-weight: 600; }

/* CTA band */

.cta-band {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    flex-wrap: wrap;
}
.cta-band h2 { font-size: clamp(1.6rem, 2.6vw, 2.1rem); max-width: 34ch; }

/* Footer */

footer {
    border-top: 1px solid var(--rule);
    padding: 2.5rem 0;
}
.footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.footer-links {
    display: flex;
    gap: 1.4rem;
    font-size: 0.85rem;
    color: var(--muted);
}
.footer-links a { text-decoration: none; }
.footer-links a:hover { color: var(--brass); }
.footer-copy {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    color: var(--muted);
}

/* ---------- Standalone reset-password page ---------- */

.reset-main { padding: 4.5rem 0; }
.reset-card {
    max-width: 380px;
    margin: 0 auto;
    background: var(--surface-raised);
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 2rem 1.75rem;
}
.reset-card h1 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}
.reset-card .lede {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}
.reset-card .btn { display: inline-block; text-decoration: none; text-align: center; }
