/*
 * Jet Fan Calculator site styles.
 * Tokens from projects/jet-fan-calculator/DESIGN.md (Colour table, light and
 * dark exactly as the app's theme): ground, surface, surfaceHigh, outline,
 * outlineStrong, text, textDim, primary (coral fill), onPrimary,
 * primaryText, accent (amber rules only), accentText, warningContainer.
 * Reservation rules kept: coral and amber are fills, rules and large type;
 * small text uses primaryText / accentText; coral never signals an error.
 * Type: Rajdhani (500, 600, 700) for labels, titles and body; JetBrains Mono
 * (400, 500) for every number, unit and formula. Rajdhani has no superscript
 * two/three or Greek, so JetBrains Mono follows it in the stack and formulas
 * and units sit in .m spans. One loud element per screen: the coral
 * "Required Number of Jet Fans" tile. No gradients, no elevation.
 * Fonts: SIL Open Font License, licenses/Rajdhani-OFL.txt and
 * licenses/JetBrainsMono-OFL.txt.
 */

@font-face {
    font-family: "Rajdhani";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("/jet-fan-calculator/fonts/rajdhani-500.woff2") format("woff2");
}

@font-face {
    font-family: "Rajdhani";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("/jet-fan-calculator/fonts/rajdhani-600.woff2") format("woff2");
}

@font-face {
    font-family: "Rajdhani";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("/jet-fan-calculator/fonts/rajdhani-700.woff2") format("woff2");
}

@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/jet-fan-calculator/fonts/jetbrainsmono-400.woff2") format("woff2");
}

@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("/jet-fan-calculator/fonts/jetbrainsmono-500.woff2") format("woff2");
}

:root {
    color-scheme: light dark;

    --ground: #F5F7FA;
    --surface: #FFFFFF;
    --surface-high: #ECEFF3;
    --outline: #D1D5DB;
    --outline-strong: #7A8594;
    --text: #1F2937;
    --text-dim: #4B5563;
    --primary: #FF6B6B;
    --on-primary: #111827;
    --primary-text: #B42318;
    --accent: #FBBF24;
    --accent-text: #8A4A0B;
    --warn-bg: #FEF3C7;
    --warn-ink: #78350F;

    --body: "Rajdhani", "JetBrains Mono", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

    --r-small: 6px;
    --r-card: 12px;

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

@media (prefers-color-scheme: dark) {
    :root {
        --ground: #0D1117;
        --surface: #161B22;
        --surface-high: #21262D;
        --outline: #30363D;
        --outline-strong: #6E7681;
        --text: #E6EDF3;
        --text-dim: #9DA7B3;
        --on-primary: #0D1117;
        --primary-text: #FF8A8A;
        --accent-text: #FBBF24;
        --warn-bg: #3A2F0A;
        --warn-ink: #FDE68A;
    }
}

/* ---------- 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(--text);
    font-family: var(--body);
    font-weight: 500;
    font-size: 1.1875rem;
    line-height: 1.5;
    overflow-wrap: break-word;
}

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

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

svg {
    flex: none;
}

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

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

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

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

h1 {
    font-size: clamp(min(2.25rem, 9vw), 1.2rem + 3vw, 3.5rem);
    line-height: 1.02;
}

h2 {
    font-size: clamp(1.75rem, 1.4rem + 1.2vw, 2.375rem);
    margin-bottom: 1rem;
}

h3 {
    font-size: 1.375rem;
    font-weight: 700;
    line-height: 1.2;
}

p {
    margin: 0 0 1rem;
}

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

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

sub,
sup {
    line-height: 0;
}

/* Mono: numbers, units and formulas, always left to right */
.m {
    font-family: var(--mono);
    font-weight: 400;
    font-size: 0.86em;
    font-variant-numeric: tabular-nums;
    unicode-bidi: isolate;
    direction: ltr;
}

.num {
    white-space: nowrap;
}

.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(--text);
    border: 2px solid var(--primary-text);
    border-radius: var(--r-small);
    font-weight: 700;
}

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

/* Group title: accentText caps beside an amber rule, as in the app */
.label {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin: 0 0 0.75rem;
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-text);
}

.label::before {
    content: "";
    flex: none;
    width: 1.5rem;
    height: 3px;
    background: var(--accent);
}

.answer {
    font-size: 1.25rem;
    max-width: 64ch;
}

.detail {
    color: var(--text-dim);
    max-width: 66ch;
}

/* ---------- 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(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.3125rem;
}

.brand img {
    border-radius: 8px;
}

.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(--text);
    text-decoration: none;
    font-weight: 700;
}

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

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

.hero {
    padding: 2.5rem 0 3rem;
    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.3125rem;
    max-width: 44ch;
    margin: 1.25rem 0 1rem;
}

.hero .aid {
    color: var(--text-dim);
    max-width: 52ch;
    margin: 0 0 1.5rem;
}

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

.get p {
    margin: 0;
    color: var(--text-dim);
    font-size: 1.0625rem;
    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);
}

/* Framed shots sit on the dark #0D1117 frame: a 1 px outline on the light page */
.hero-shot img,
.shot img {
    border: 1px solid var(--outline-strong);
    border-radius: var(--r-card);
    background: #0D1117;
}

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

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

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

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

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

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

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

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

.groups p {
    margin: 0;
    color: var(--text-dim);
}

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

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

/* Results readout, redrawn from engine output */
.readout {
    margin: 0;
}

.tile {
    background: var(--primary);
    color: var(--on-primary);
    border-radius: var(--r-small);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.tile p {
    margin: 0;
    font-weight: 700;
    color: var(--on-primary);
}

.tile .figure {
    font-family: var(--mono);
    font-weight: 500;
    font-size: 3.5rem;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

.facts {
    margin: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

.facts div {
    background: var(--surface-high);
    color: var(--text);
    border-radius: var(--r-small);
    padding: 0.625rem 0.75rem;
    min-width: 0;
}

.facts dt {
    color: var(--text-dim);
    font-size: 1rem;
    line-height: 1.25;
}

.facts dd {
    margin: 0.25rem 0 0;
    font-family: var(--mono);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.readout figcaption {
    margin-top: 1rem;
    font-size: 1.0625rem;
    color: var(--text-dim);
}

/* Reliance notice (warningContainer pair) */
.notice {
    border: 1px solid var(--warn-ink);
    background: var(--warn-bg);
    color: var(--warn-ink);
    border-radius: var(--r-card);
    padding: 1.25rem 1.5rem;
    max-width: 72ch;
}

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

.notice a {
    color: var(--warn-ink);
    outline-color: var(--warn-ink);
}

/* 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: 1.0625rem;
    color: var(--text-dim);
}

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

.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(--text);
    text-decoration: none;
    font-weight: 700;
}

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

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

/* Closing band */
.cta {
    padding: 3rem 0;
    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);
}

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

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

.crumbs li + li::before {
    content: "›";
    padding: 0 0.5rem;
    font-family: var(--mono);
}

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

.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;
}

/* Formulas: mono, 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);
    color: var(--text);
    border: 1px solid var(--outline);
    border-radius: var(--r-small);
    padding: 0.625rem 0.875rem;
    min-width: 0;
}

.eq {
    display: block;
    font-family: var(--mono);
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text);
    overflow-wrap: anywhere;
    direction: ltr;
    text-align: left;
}

.eqs .note {
    display: block;
    margin-top: 0.25rem;
    font-size: 1.0625rem;
    color: var(--text-dim);
}

.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.9rem;
    min-width: 2rem;
    font-family: var(--mono);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--primary-text);
}

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

.table caption {
    display: block;
    text-align: left;
    color: var(--text-dim);
    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.9375rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-text);
    border-bottom-color: var(--outline-strong);
}

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

.table td.m,
.table td .m {
    overflow-wrap: anywhere;
}

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

.footer {
    background: var(--surface);
    color: var(--text);
    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.375rem;
}

.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(--text);
}

.fine {
    font-size: 1rem;
    color: var(--text-dim);
}

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

.fine a {
    color: var(--text-dim);
}

/* ---------- 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(--text);
        border: 1px solid var(--outline);
        border-radius: var(--r-card);
        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-family: var(--body);
        font-size: 0.9375rem;
        font-weight: 700;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: var(--accent-text);
    }
}

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

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

    .gallery {
        grid-template-columns: repeat(4, 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;
    }

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