/*
 * site.css — design tokens + components + page styles for the Blackjack 101 site.
 *
 * The design implements the approved Milestone 0 v4 direction (light, natural
 * web feel; see design/milestone-0/): full-width white header band with the
 * classic centered title + suits + nav, one standard 960px content container,
 * and the article on a single white sheet.
 *
 * Layered top to bottom: tokens → font → reset/base → components → charts-page
 * components → print. A new page needs only the header pattern documented in
 * the README and a <link> to this file.
 *
 * The trainer app (public/trainer/) is a separate self-contained unit; it keeps
 * its own copy of the token block below so neither unit depends on the other's
 * files at runtime.
 */

/* =====================================================================
   1. SHARED DESIGN TOKENS — canonical block
   This exact block also lives in public/trainer/trainer.css. The two
   copies must stay identical (self-contained units, one design
   language); the token-parity check in verification diffs them.
   ===================================================================== */
:root {
    /* Light palette: warm paper ground, white surfaces, deep-green primary */
    --bg:            #f7f4ec;
    --surface:       #ffffff;
    --raised:        #f3efe4;               /* subtle wells: tips, table headers */
    --felt:          #1d6b43;               /* the one casino element: play surface */
    --felt-label:    rgba(255, 255, 255, 0.85);
    --text:          #22302a;
    --muted:         #5c6f60;
    --heading:       #14432c;
    --link:          #1d6b43;
    --primary:       #1d6b43;               /* the one primary action per context */
    --primary-ink:   #ffffff;
    --good-text:     #15803d;               /* positive copy on light surfaces */
    --danger-text:   #b3362b;               /* negative copy on light surfaces */
    --good-well:     #e4f2e6;               /* correct-state tint */
    --danger-well:   #f9e5e2;               /* incorrect-state tint */
    --hairline:      rgba(0, 0, 0, 0.08);
    --ctl-border:    rgba(0, 0, 0, 0.15);   /* interactive-control outlines */
    --shadow-1: 0 1px 3px rgba(31, 41, 26, 0.10);
    --shadow-2: 0 6px 18px rgba(31, 41, 26, 0.12);

    /* Chart action colors — all hold 4.5:1 against white text */
    --act-hit:       #dc2626;
    --act-stand:     #15803d;
    --act-split:     #9333ea;
    --act-double:    #2563eb;
    --act-surrender: #db2777;
    --act-ink:       #ffffff;               /* text on the action fills above */

    --suit-red:      #c0392b;               /* hearts/diamonds in the suits row */

    /* Spacing: 4px scale */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --sp-6: 32px;
    --sp-7: 48px;

    /* Radii: controls, cards, pills */
    --r-ctl:  8px;
    --r-card: 12px;
    --r-pill: 999px;

    /* Type scale */
    --fs-xs:  13px;
    --fs-sm:  14px;
    --fs-md:  16px;
    --fs-lg:  18px;
    --fs-xl:  22px;
    --fs-2xl: 30px;

    --font: 'Nunito Sans Variable', 'Nunito Sans', 'Segoe UI', system-ui, sans-serif;
}
/* ================== END SHARED DESIGN TOKENS ========================= */

/* =====================================================================
   2. FONT
   Vendored variable font (SIL OFL); weight axis 200-1000, latin subset.
   ===================================================================== */
@font-face {
    font-family: 'Nunito Sans Variable';
    font-style: normal;
    font-display: swap;
    font-weight: 200 1000;
    src: url('fonts/NunitoSans-Variable.woff2') format('woff2-variations');
}

/* =====================================================================
   3. RESET / BASE
   ===================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Author display rules outrank the UA's [hidden] { display: none } */
[hidden] {
    display: none !important;
}

body {
    font-family: var(--font);
    font-size: var(--fs-md);
    line-height: 1.65;
    color: var(--text);
    background-color: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    line-height: 1.25;
    font-weight: 800;
    color: var(--heading);
}

a {
    color: var(--link);
}

strong {
    font-weight: 800;
}

ul,
ol {
    margin: var(--sp-3) 0;
    padding-left: var(--sp-5);
}

li {
    margin: var(--sp-2) 0;
}

li::marker {
    color: var(--muted);
}

p {
    margin: var(--sp-3) 0;
}

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

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

.good {
    color: var(--good-text);
    font-weight: 800;
}

.bad {
    color: var(--danger-text);
    font-weight: 800;
}

/* =====================================================================
   4. COMPONENTS
   ===================================================================== */

/* ------------------------------------------------- site header band */
/* The classic centered header — title, suits, nav — as a white band */
.sitehero {
    background-color: var(--surface);
    border-bottom: 1px solid var(--hairline);
    text-align: center;
    padding: var(--sp-5) var(--sp-4) var(--sp-4);
}

.sitehero__title {
    font-size: var(--fs-2xl);
    margin-bottom: var(--sp-1);
}

.sitehero__suits {
    font-size: var(--fs-md);
    letter-spacing: 0.22em;
    margin-bottom: var(--sp-3);
}

.suit {
    color: var(--heading);
}

.suit--r {
    color: var(--suit-red);
}

.sitehero__nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    justify-content: center;
}

/* --------------------------------------------------------- container */
/* Standard widths only: 960px desktop, full width + gutters on mobile */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: var(--sp-4);
}

@media screen and (min-width: 768px) {
    .container {
        padding: var(--sp-5);
    }
}

/* ------------------------------------------------------------ sheet */
/* One white surface holds the whole article so the page reads finished */
.sheet {
    background-color: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-1);
    padding: var(--sp-4);
    margin-bottom: var(--sp-4);
}

@media screen and (min-width: 768px) {
    .sheet {
        padding: var(--sp-5) var(--sp-6);
    }
}

.sheet h2 {
    font-size: var(--fs-xl);
    margin: var(--sp-5) 0 var(--sp-2);
    padding-bottom: var(--sp-1);
    border-bottom: 1px solid var(--hairline);
}

.sheet h2:first-child {
    margin-top: 0;
}

.sheet > p:first-of-type {
    margin-top: 0;
}

/* ---------------------------------------------------------- buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;   /* minimum touch target */
    padding: var(--sp-2) var(--sp-4);
    border-radius: var(--r-ctl);
    border: 1px solid var(--ctl-border);
    background-color: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.btn:hover {
    border-color: var(--muted);
}

.btn--primary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--primary-ink);
    font-weight: 800;
}

.btn--primary:hover {
    background-color: #278355;   /* --primary lifted one step */
    border-color: #278355;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    margin: var(--sp-4) 0;
}

/* ---------------------------------------------------------- callout */
.callout {
    background-color: var(--raised);
    border-left: 4px solid var(--muted);
    border-radius: var(--r-ctl);
    padding: var(--sp-3) var(--sp-4);
    margin: var(--sp-4) 0;
}

.callout > :first-child {
    margin-top: 0;
}

.callout > :last-child {
    margin-bottom: 0;
}

.callout--tip {
    border-left-color: var(--good-text);
    background-color: var(--good-well);
}

.callout--warning {
    border-left-color: var(--danger-text);
    background-color: var(--danger-well);
}

.callout__heading {
    font-size: var(--fs-md);
    margin-bottom: var(--sp-2);
}

.callout--warning .callout__heading {
    color: var(--danger-text);
}

/* ----------------------------------------------------------- tables */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: var(--sp-4) 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
    background-color: var(--surface);
    border: 1px solid var(--hairline);
}

.data-table th,
.data-table td {
    text-align: left;
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--hairline);
}

.data-table thead th {
    color: var(--muted);
    font-size: var(--fs-xs);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background-color: var(--raised);
}

.data-table tbody tr:last-child th,
.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Numbers line up when comparing payouts */
.data-table td {
    font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------- footer */
.footer {
    border-top: 1px solid var(--hairline);
    text-align: center;
    padding: var(--sp-5) var(--sp-4) var(--sp-6);
    color: var(--muted);
    font-size: var(--fs-sm);
}

/* The rotating tagline is the site's signature */
.footer__tagline {
    color: var(--heading);
    font-size: var(--fs-lg);
    font-weight: 900;
    font-style: italic;
    margin-bottom: var(--sp-2);
}

/* =====================================================================
   5. CHARTS PAGE (blackjack-strategy.html)
   ===================================================================== */

/* ------------------------------------------- rules panel (collapsible) */
.rules {
    background-color: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-1);
    margin-bottom: var(--sp-4);
}

.rules__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    width: 100%;
    min-height: 44px;   /* minimum touch target */
    padding: var(--sp-3) var(--sp-4);
    background: none;
    border: none;
    border-radius: var(--r-card);
    color: var(--heading);
    font: inherit;
    cursor: pointer;
    text-align: left;
}

.rules__title {
    font-size: var(--fs-md);
    font-weight: 800;
    white-space: nowrap;
}

.rules__meta {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    min-width: 0;
}

/* Active config, readable while the panel is shut */
.rules__summary {
    display: none;
    color: var(--muted);
    font-size: var(--fs-xs);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rules--collapsed .rules__summary {
    display: block;
}

.rules__chevron {
    color: var(--muted);
    flex-shrink: 0;
    transition: transform 0.2s;
}

.rules--collapsed .rules__chevron {
    transform: rotate(-90deg);
}

.rules__body {
    max-height: 520px;   /* > tallest rules grid, incl. stacked mobile rows */
    overflow: hidden;
    transition: max-height 0.25s ease-in-out;
}

.rules__body--hidden {
    max-height: 0;
}

.rules__grid {
    padding: var(--sp-2) var(--sp-4) var(--sp-4);
    border-top: 1px solid var(--hairline);
    display: grid;
    gap: var(--sp-3);
}

.rule {
    display: grid;
    grid-template-columns: 150px 1fr;   /* 150px fits the longest rule label */
    align-items: center;
    gap: var(--sp-3);
}

.rule__label {
    color: var(--muted);
    font-weight: 800;
    font-size: var(--fs-sm);
}

@media screen and (max-width: 480px) {
    .rule {
        grid-template-columns: 1fr;
        gap: var(--sp-1);
    }
}

/* ------------------------------------------ segmented control (shared) */
.segs {
    display: flex;
    gap: var(--sp-2);
}

.seg {
    flex: 1;
    min-width: 44px;    /* minimum touch target */
    min-height: 44px;
    padding: var(--sp-2) var(--sp-2);
    background-color: var(--surface);
    border: 1px solid var(--ctl-border);
    border-radius: var(--r-ctl);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.seg:hover {
    border-color: var(--muted);
}

.seg--on {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--primary-ink);
    font-weight: 800;
}

/* ------------------------------------------------------------- legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2) var(--sp-4);
    justify-content: center;
    padding: var(--sp-3) var(--sp-4);
    background-color: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-1);
    margin-bottom: var(--sp-4);
    font-size: var(--fs-xs);
}

.legend__item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: 700;
    white-space: nowrap;
}

.legend__swatch {
    width: 22px;        /* legend swatch mirrors a chart cell */
    height: 22px;
    border-radius: 4px; /* cell radius, smaller than --r-ctl by design */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;   /* fits two letters inside the swatch */
    font-weight: 800;
    font-style: normal;
    color: var(--act-ink);
    flex-shrink: 0;
}

/* --------------------------------------------------------- chart grid */
.chart-section {
    margin-bottom: var(--sp-4);
}

.chart-section__title {
    font-size: var(--fs-lg);
    text-align: center;
    margin-bottom: var(--sp-2);
}

.chart-card {
    background-color: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-1);
    padding: var(--sp-2);
}

.chart-card__x-label {
    color: var(--muted);
    font-size: var(--fs-xs);
    font-weight: 800;
    text-align: center;
    padding: var(--sp-1) 0 var(--sp-1) 20px;   /* offset for the y-axis strip */
}

.chart-card__row {
    display: flex;
    align-items: stretch;
}

.chart-card__y-label {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    color: var(--muted);
    font-size: var(--fs-xs);
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--sp-1);
    flex-shrink: 0;
}

.chart-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}

.chart {
    width: 100%;
    border-collapse: separate;
    border-spacing: 2px;
    font-size: var(--fs-xs);
    table-layout: fixed;
}

.chart th,
.chart td {
    width: 9.09%;   /* 11 equal columns */
    padding: 0;
    text-align: center;
    font-weight: 800;
    vertical-align: middle;
    position: relative;
    border-radius: 4px;   /* cell radius, smaller than --r-ctl by design */
}

/* Square cells via the padding-top trick; dropped on tiny screens below */
.chart th::before,
.chart td::before {
    content: "";
    display: block;
    padding-top: 100%;
}

.chart th span,
.chart td span {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart thead th,
.chart .chart__row-header {
    background-color: var(--raised);
    color: var(--heading);
}

/* Row labels stay put if a chart ever scrolls sideways */
.chart .chart__row-header,
.chart thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 5;
}

.chart td {
    cursor: pointer;
}

/* A tapped cell shows its ring; the explainer below names the rule */
.chart td.chart__cell--picked span {
    outline: 3px solid var(--heading);
    outline-offset: -3px;
    border-radius: 4px;
}

/* Action colors */
.act-h {
    background-color: var(--act-hit);
    color: var(--act-ink);
}

.act-s {
    background-color: var(--act-stand);
    color: var(--act-ink);
}

.act-p {
    background-color: var(--act-split);
    color: var(--act-ink);
}

.act-d {
    background-color: var(--act-double);
    color: var(--act-ink);
}

.act-r {
    background-color: var(--act-surrender);
    color: var(--act-ink);
}

/* --------------------------------------------------- tap-a-cell explainer */
.explain {
    background-color: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-ctl);
    box-shadow: var(--shadow-1);
    padding: var(--sp-3) var(--sp-4);
    margin: 0 0 var(--sp-4);
    font-size: var(--fs-sm);
    font-weight: 600;
}

.explain__hand {
    color: var(--heading);
    font-weight: 800;
}

.explain--idle {
    color: var(--muted);
    font-weight: 600;
}

/* ---------------------------------------------------------- insurance */
.insurance {
    text-align: center;
    background-color: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-1);
    padding: var(--sp-4);
    color: var(--heading);
    font-size: var(--fs-md);
    font-weight: 800;
    margin-bottom: var(--sp-4);
}

/* -------------------------------------------------- charts breakpoints */
/* Standard widths only: charts share the 960px container and pair up on
   desktop instead of widening the page */
@media screen and (min-width: 900px) {
    .charts-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--sp-4);
        align-items: start;
    }
}

/* Tiny screens: drop square cells so all 11 columns always fit */
@media screen and (max-width: 380px) {
    .chart {
        font-size: 11px;   /* floor for 11 columns at 320px */
        border-spacing: 1px;
    }

    .chart th::before,
    .chart td::before {
        display: none;
    }

    .chart th span,
    .chart td span {
        position: static;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 26px;   /* keeps rows tappable once squares are dropped */
    }

    .chart-card__x-label {
        padding-left: 14px;   /* y-axis strip narrows with the smaller type */
    }
}

/* =====================================================================
   6. PRINT — ink-friendly chart pages
   ===================================================================== */
@media print {
    body {
        background: #fff;
        color: #000;
    }

    .sitehero,
    .rules__header,
    .footer,
    .btn-row,
    .explain {
        display: none;
    }

    .sheet,
    .rules,
    .legend,
    .chart-card,
    .insurance,
    .callout {
        background: #fff;
        border-color: #999;
        box-shadow: none;
        color: #000;
    }

    h1,
    h2,
    .chart-section__title,
    .rule__label,
    .legend__item,
    .chart-card__x-label,
    .chart-card__y-label,
    .insurance {
        color: #000;
    }

    .seg {
        background: #fff;
        color: #000;
        border-color: #999;
    }

    .seg--on {
        background: #ddd;
        color: #000;
        border-color: #000;
    }

    .chart thead th,
    .chart .chart__row-header {
        background-color: #eee;
        color: #000;
    }

    .chart td {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .rules__body {
        max-height: none !important;
    }
}
