/*
 * Critical Velocity Calculator site styles.
 * No DESIGN.md exists for this app. Tokens are derived from
 * projects/critical-velocity-toolkit/composeApp/src/commonMain/kotlin/org/sonicon/cvt/theme/Theme.kt
 * (CvColors, shape radii, type ramp), composeApp res colors.xml and the Play store art,
 * as recorded in projects/critical-velocity-toolkit/site-docs/SEO-BRIEF.md section 0.9.
 * The app is dark-only: the dark theme below is the app's palette verbatim; the light
 * theme is the derived palette from the brief (same hues, accents darkened for AA).
 * Identity: near-black ground with a deep-red glow, coral primary, amber result values,
 * green "converged", uppercase section labels as in the app's cards. System sans only
 * (the app uses FontFamily.SansSerif), equations in a monospace stack.
 */

:root {
    color-scheme: light dark;

    --ground: #F6F8FA;
    --surface: #FFFFFF;
    --surface-variant: #EEF1F4;
    --outline: #D0D7DE;
    --outline-strong: #8C959F;
    --ink: #1F2328;
    --ink-muted: #57606A;
    --primary: #B3261E;
    --on-primary: #FFFFFF;
    --primary-container: #FFDAD6;
    --on-primary-container: #410002;
    --amber: #8A5A00;
    --orange: #C2410C;
    --success: #176F32;
    --glow: rgba(179, 38, 30, 0.12);

    --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, "Roboto Mono", Menlo, Consolas, monospace;

    --r-xs: 6px;
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 18px;
    --r-xl: 24px;

    --wrap: 72rem;
    --gutter: 1.25rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --ground: #0D1117;
        --surface: #161B22;
        --surface-variant: #21262D;
        --outline: #30363D;
        --outline-strong: #484F58;
        --ink: #E6EDF3;
        --ink-muted: #8B949E;
        --primary: #FF6B6B;
        --on-primary: #1A0A0A;
        --primary-container: #5C2121;
        --on-primary-container: #FFDAD6;
        --amber: #FBBF24;
        --orange: #FF6B35;
        --success: #3FB950;
        --glow: rgba(139, 44, 44, 0.35);
    }
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: 1rem;
}

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 1rem;
    line-height: 1.5;
    overflow-wrap: break-word;
}

::selection {
    background: var(--primary-container);
    color: var(--on-primary-container);
}

img {
    display: block;
    max-width: 100%;
    height: auto;
}

svg {
    flex: none;
}

a {
    color: var(--primary);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
}

a:hover {
    text-decoration-thickness: 2px;
}

:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 3px;
    border-radius: 4px;
}

h1,
h2,
h3 {
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
    text-wrap: balance;
}

h1 {
    font-size: clamp(min(2rem, 9vw), 1.4rem + 2.6vw, 3.25rem);
    line-height: 1.1;
    letter-spacing: -0.015em;
}

h2 {
    font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.125rem);
    line-height: 1.2;
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
}

h3 {
    font-size: 1.25rem;
    line-height: 1.3;
}

p {
    margin: 0 0 1rem;
}

p:last-child {
    margin-bottom: 0;
}

code {
    font-family: var(--mono);
    font-size: 0.92em;
    overflow-wrap: anywhere;
}

ul,
ol {
    margin: 0 0 1rem;
    padding-left: 1.25rem;
}

.wrap {
    width: 100%;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -10rem;
    z-index: 10;
    padding: 0.75rem 1.25rem;
    background: var(--surface);
    color: var(--ink);
    border: 2px solid var(--primary);
    border-radius: var(--r-sm);
    font-weight: 600;
}

.skip-link:focus {
    top: 1rem;
}

/* Section label: the app's uppercase card titles ("RESULTS — SEDH METHOD") */
.label {
    display: block;
    margin: 0 0 0.5rem;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--amber);
}

.label-coral {
    color: var(--primary);
}

.answer {
    font-size: 1.0625rem;
    max-width: 68ch;
}

.detail {
    color: var(--ink-muted);
    max-width: 68ch;
}

/* ---------- Top bar ---------- */

.topbar {
    border-bottom: 1px solid var(--outline);
    background: var(--ground);
}

.topbar .wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem 1.5rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    min-height: 48px;
    min-width: 0;
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.0625rem;
}

.brand img {
    border-radius: var(--r-sm);
}

.site-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.25rem;
}

.site-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
    color: var(--primary);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.35em;
}

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

.hero {
    position: relative;
    overflow: hidden;
    padding: 2.5rem 0 3rem;
    background:
        radial-gradient(ellipse 60% 70% at 85% 30%, var(--glow), transparent 70%),
        radial-gradient(ellipse 40% 45% at 0% 100%, var(--glow), transparent 70%),
        var(--ground);
    border-bottom: 1px solid var(--outline);
}

.hero-grid {
    display: grid;
    gap: 2.5rem;
    align-items: center;
}

.hero-copy {
    min-width: 0;
}

.hero .sub {
    font-size: 1.125rem;
    color: var(--ink-muted);
    max-width: 40ch;
    margin: 1rem 0 1.5rem;
}

.get {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
}

.get p {
    margin: 0;
    color: var(--ink-muted);
    font-size: 0.9375rem;
    max-width: 30ch;
}

/* Official Google Play badge: unmodified art */
.play-badge {
    display: inline-block;
    border-radius: 8px;
    line-height: 0;
}

.play-badge img {
    width: 188px;
    height: 56px;
}

.hero-shot {
    justify-self: center;
    width: min(100%, 20rem);
}

.hero-shot img,
.shot img {
    border: 1px solid var(--outline-strong);
    border-radius: var(--r-lg);
    background: #0D1117;
}

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

.section {
    padding: 3rem 0;
    border-bottom: 1px solid var(--outline);
}

.section:last-of-type {
    border-bottom: 0;
}

.section-head {
    max-width: 68ch;
    margin-bottom: 1.75rem;
}

.split {
    display: grid;
    gap: 2rem;
    align-items: start;
}

.split > * {
    min-width: 0;
}

/* Cards, as the app's SectionCard */
.card {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--outline);
    border-radius: var(--r-md);
    padding: 1.25rem;
    min-width: 0;
}

.methods {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1rem;
}

.methods h3 {
    margin-bottom: 0.5rem;
}

.methods p {
    color: var(--ink);
}

.methods .tag {
    margin-top: 0.75rem;
}

/* A word, never a colour alone */
.tag {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border: 1px solid var(--outline-strong);
    border-radius: var(--r-xs);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ink-muted);
}

.tag-ok {
    color: var(--success);
    border-color: currentColor;
}

.features {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--outline);
}

.features li {
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--outline);
}

.features strong {
    font-weight: 700;
}

/* ---------- Readout: the app's results card, redrawn ---------- */

.readout {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--outline);
    border-radius: var(--r-md);
    padding: 1.25rem;
    margin: 0;
    min-width: 0;
}

.readout-title {
    margin-bottom: 1rem;
}

.metrics {
    margin: 0;
    display: grid;
    gap: 0.625rem;
}

.metrics div {
    background: var(--surface-variant);
    border-radius: var(--r-sm);
    padding: 0.625rem 0.875rem;
}

.metrics dt {
    font-size: 0.875rem;
    color: var(--ink-muted);
}

.metrics dd {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--amber);
    font-variant-numeric: tabular-nums;
}

.metrics dd span {
    font-size: 0.9375rem;
    font-weight: 600;
}

.iters {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
    font-family: var(--mono);
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

.iters li {
    padding: 0.125rem 0;
    overflow-wrap: anywhere;
}

.iters .done {
    color: var(--success);
    font-weight: 700;
}

.readout figcaption {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--ink-muted);
}

/* Facts list */
.facts {
    margin: 0;
    border-top: 1px solid var(--outline);
}

.facts div {
    display: grid;
    gap: 0.125rem 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--outline);
}

.facts dt {
    color: var(--ink-muted);
}

.facts dd {
    margin: 0;
    font-weight: 700;
}

/* Reliance notice */
.notice {
    border: 1px solid var(--primary);
    background: var(--surface);
    color: var(--ink);
    border-radius: var(--r-md);
    padding: 1.25rem 1.5rem;
    max-width: 72ch;
}

/* Gallery */
.gallery {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.shot {
    margin: 0;
    min-width: 0;
}

.shot figcaption {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--ink-muted);
}

/* Question links */
.qlinks {
    list-style: none;
    margin: 0;
    padding: 0;
}

.qlinks a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 48px;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--outline);
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
}

.qlinks a:hover span {
    text-decoration: underline;
}

.qlinks svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: var(--primary);
    stroke-width: 2;
}

/* Closing band */
.cta {
    padding: 3rem 0;
    background:
        radial-gradient(ellipse 50% 90% at 50% 100%, var(--glow), transparent 70%),
        var(--ground);
    border-top: 1px solid var(--outline);
    text-align: center;
}

.cta h2 {
    margin-bottom: 1.25rem;
}

.cta .get {
    justify-content: center;
}

/* ---------- Inner pages ---------- */

.page-head {
    padding: 1.5rem 0 2rem;
    border-bottom: 1px solid var(--outline);
    background:
        radial-gradient(ellipse 50% 80% at 100% 0%, var(--glow), transparent 70%),
        var(--ground);
}

.crumbs ol {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    font-size: 0.9375rem;
    color: var(--ink-muted);
}

.crumbs li {
    display: inline-flex;
    align-items: center;
}

.crumbs li + li::before {
    content: "›";
    padding: 0 0.5rem;
}

.crumbs a {
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    color: var(--ink-muted);
}

.page-head .answer {
    margin-top: 1rem;
}

.ledger > section {
    padding: 2.25rem 0;
    border-bottom: 1px solid var(--outline);
    scroll-margin-top: 1rem;
}

.ledger > section:last-child {
    border-bottom: 0;
}

.ledger h2 {
    max-width: 34ch;
}

.ledger h3 {
    margin: 1.5rem 0 0.5rem;
}

/* Equations: text, wrapping, never a sideways scroll */
.eqs {
    list-style: none;
    margin: 1rem 0;
    padding: 0;
    display: grid;
    gap: 0.5rem;
    max-width: 72ch;
}

.eqs li {
    background: var(--surface-variant);
    color: var(--ink);
    border: 1px solid var(--outline);
    border-radius: var(--r-sm);
    padding: 0.625rem 0.875rem;
    min-width: 0;
}

.eqs code {
    color: var(--ink);
}

.eqs .note {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.9375rem;
    color: var(--ink-muted);
}

.limits {
    list-style: none;
    margin: 1.25rem 0 0;
    padding: 0;
    max-width: 75ch;
    border-top: 1px solid var(--outline);
    counter-reset: lim;
}

.limits li {
    padding: 0.875rem 0 0.875rem 2.75rem;
    border-bottom: 1px solid var(--outline);
    position: relative;
    counter-increment: lim;
}

.limits li::before {
    content: counter(lim);
    position: absolute;
    left: 0;
    top: 0.875rem;
    min-width: 2rem;
    font-family: var(--mono);
    font-weight: 700;
    color: var(--amber);
}

.limits strong {
    font-weight: 700;
}

/* Tables (stack into cards under 600px) */
.table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.25rem 0 0;
    font-size: 0.9875rem;
}

.table caption {
    text-align: left;
    color: var(--ink-muted);
    padding-bottom: 0.75rem;
}

.table th,
.table td {
    text-align: left;
    vertical-align: top;
    padding: 0.75rem 1rem 0.75rem 0;
    border-bottom: 1px solid var(--outline);
}

.table thead th {
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--amber);
    border-bottom-color: var(--outline-strong);
}

.table tbody th {
    font-weight: 700;
}

.table .num {
    font-variant-numeric: tabular-nums;
}

/* ---------- Footer ---------- */

.footer {
    background: var(--surface);
    color: var(--ink);
    padding: 2.5rem 0 3rem;
    border-top: 1px solid var(--outline);
}

.footer-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 2rem;
    margin-bottom: 1.25rem;
}

.footer-top p {
    margin: 0;
}

.footer-top strong {
    font-size: 1.25rem;
}

.footer-links {
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.25rem;
}

.footer-links a {
    overflow-wrap: anywhere;
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    color: var(--ink);
}

.fine {
    font-size: 0.875rem;
    color: var(--ink-muted);
}

.fine p {
    margin-bottom: 0.375rem;
}

/* ---------- Breakpoints ---------- */

@media (max-width: 37.5rem) {
    .table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .table,
    .table tbody,
    .table tr,
    .table th,
    .table td,
    .table caption {
        display: block;
        width: 100%;
    }

    .table tr {
        background: var(--surface);
        color: var(--ink);
        border: 1px solid var(--outline);
        border-radius: var(--r-md);
        padding: 0.75rem 1rem;
        margin-bottom: 0.75rem;
    }

    .table th,
    .table td {
        border: 0;
        padding: 0.25rem 0;
    }

    .table [data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 0.8125rem;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--amber);
    }
}

@media (min-width: 40rem) {
    :root {
        --gutter: 2rem;
    }

    .methods {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .facts div {
        grid-template-columns: minmax(0, 14rem) minmax(0, 1fr);
    }

    .gallery {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 60rem) {
    .hero {
        padding: 3.5rem 0 4rem;
    }

    .hero-grid {
        grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
        gap: 3rem;
    }

    .hero-shot {
        justify-self: end;
        width: 21rem;
    }

    .split {
        grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
        gap: 3rem;
    }

    .methods {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .gallery {
        max-width: 48rem;
    }
}
