/* ==========================================================================
   Forge — design tokens
   Locked in Phase 2 of the visual rebuild. Direction: "Coach+".

   This file is the single source of truth for spacing, type, colour, radii,
   shadows and motion. Nothing below is a raw value chosen on the spot; every
   number belongs to a scale, and every scale has a reason.

   THE RULE: styles.css must not contain a literal px size, hex colour, or
   duration. If a value is missing here, add it here first.

   Why the app looks the way it does:
   - Read at arm's length, in a bright gym, mid-set, in about half a second.
   - Tapped with sweaty hands. Nothing interactive is under 44px.
   - Dark only. Gyms are dim, and a white screen at 6am is hostile. Since
     v270 the dark is an even grey with one blue accent (see COLOUR).
   - No web fonts. The system stack loads instantly, works offline, and
     already ships the tabular figures the numbers need.

   Every colour pair below was measured with the WCAG formula, not estimated.
   Ratios are noted inline. Small text clears 4.5:1 against BOTH --bg and
   --surface, because most text sits on one or the other and it must not
   matter which.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* ======================================================== SPACING ====
     A 4px grid. Tokens are named for their own value, so --sp-16 is 16px
     and you never have to look up a table to read the CSS.

     4 and below are for optical nudges inside a component (icon to label).
     8-16 is intra-component. 24 is the page gutter and the gap between
     sections. 32+ separates whole blocks.

     Note: the approved prototype used a 26px gutter. Snapped to 24 to sit
     on the grid; the 2px is not perceptible and the consistency is. */

  --sp-2:   0.125rem;
  --sp-4:   0.25rem;
  --sp-6:   0.375rem;
  --sp-8:   0.5rem;
  --sp-12: 0.75rem;
  --sp-16: 1rem;
  --sp-20: 1.25rem;
  --sp-24: 1.5rem;
  --sp-32: 2rem;
  --sp-40: 2.5rem;
  --sp-48: 3rem;
  --sp-64: 4rem;

  /* Semantic spacing. Use these in layout code so intent survives a change
     of mind about the underlying number. */
  /* Left and right page padding, and with it the inset of the floating tab bar
     and of the recovery strip — everything on screen is measured off it. Kept
     narrow so the cards run close to the edge of the glass; the phone's own
     bezel is already the margin. */
  --gutter:      var(--sp-16);
  --stack-tight: var(--sp-8);    /* between siblings that belong together */
  --stack:       var(--sp-16);   /* between siblings in a group */
  --stack-loose: var(--sp-32);   /* between groups */
  --screen-top:  var(--sp-48);   /* first element under the status bar */

  /* Touch target floor. Anything tappable must reach this, even when the
     visible box is smaller — pad it out or use a pseudo-element. */
  --tap-min: 44px;

  /* =========================================================== TYPE ====
     Nine steps, each with a job. The previous stylesheet had thirty-one
     sizes, seven of them inside a 6% band — indistinguishable on screen but
     each one a separate decision to maintain.

     Sizes are in rem so the browser's own text-size setting still works.
     The px equivalent at the 16px default is in the comment. */

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace;

  --fs-micro:   0.625rem;   /* 10 — uppercase captions, figure legend, strip labels */
  --fs-tiny:    0.688rem;   /* 11 — kicker, evidence tag */
  --fs-small:   0.781rem;   /* 12.5 — chips, list index, form hints */
  --fs-meta:    0.844rem;   /* 13.5 — secondary lines under a title */
  --fs-body:    0.938rem;   /* 15 — body copy, cues, buttons */
  --fs-title:   1.063rem;   /* 17 — list item names, card titles, CTA */
  --fs-lead:    1.375rem;   /* 22 — stats strip numbers, sheet heading */
  --fs-figure:  1.750rem;   /* 28 — one big number alone (kcal, stat tiles) */
  /* 38 — the screen title, once per screen.
     Fluid only at the bottom end. 10.5vw reaches the 38px cap at 362px wide,
     so every phone from an iPhone 12 up gets exactly the size the design was
     approved at; below that it scales down rather than eating the screen. On
     a 320x568 SE the fixed 38px left a three-line title occupying 47% of the
     viewport with no exercise visible.
     The vw term does not follow the browser's text-size setting, but the floor
     and the cap are both in rem, so the extremes still do. */
  --fs-display: clamp(1.875rem, 10.5vw, 2.375rem);

  /* Line height. Large type needs less; small type needs more. Uppercase
     micro labels are single-line, so they get a tight box. */
  --lh-display: 1.02;
  --lh-tight:   1.15;   /* headings, big numbers */
  --lh-snug:    1.35;   /* list names, labels */
  --lh-body:    1.55;   /* paragraphs, cues */

  /* Tracking. Big type needs negative tracking to stop it looking loose;
     small uppercase needs positive tracking to stay readable. These pair
     with the sizes above — do not mix a display tracking onto body text. */
  --tr-display: -0.035em;
  --tr-lead:    -0.025em;
  --tr-title:   -0.015em;
  --tr-normal:   0;
  --tr-caps:     0.10em;   /* micro labels, legend, strip captions */
  --tr-kicker:   0.16em;   /* the one line above the title */

  /* Weight. Four steps. The system font is variable, so these are real
     weights and not synthesised. */
  --fw-regular: 400;
  --fw-medium:  600;
  --fw-bold:    700;
  --fw-display: 760;

  /* ========================================================= COLOUR ====
     Orange on black, since v278 (15/11/2026): the user asked for the
     original amber back on the black ground, with charcoal cards ("C3") and
     a three-colour glow ("G9") picked from a gallery. Blue on grey ran from
     v270 to v277.

     Contrast against --bg / --surface, measured:
       ink      18.69 / 17.05   AAA
       dim       7.27 /  6.63   AA
       faint     5.53 /  5.04   AA   (the quietest legal text)
       accent   10.29 /  9.39   AA */

  /* Black, and charcoal cards that lift off it by a hairline rather than by
     a lighter step (C3). The week strip under the greeting wears the same. */
  --bg:          #000000;   /* the page */
  --surface:     #0f0f10;   /* cards, raised rows, the week strip's days */
  --surface-2:   #1a1a1c;   /* inputs, wells, bar tracks */
  --sunken:      #000000;   /* behind everything; scrim base */
  --hairline:    rgba(255, 255, 255, 0.07);   /* the edge of every card */
  /* The glow behind every screen (G9): orange from the top left, violet from
     the right, sky from the bottom left. Each alpha is as much as
     tools/check-glow.py allows: the glow lightens the ground, and --faint is
     the ink that runs out of contrast first. */
  --glow:        rgba(245, 165, 36, 0.32);
  --glow-2:      rgba(171, 140, 246, 0.17);
  --glow-3:      rgba(79, 176, 232, 0.16);

  /* Four tones: the home screen's cards, and the three macros (see below).

     The accent stays the one voice for controls and active states. These
     say only which card or which macro is which, where several unrelated
     numbers sit side by side and have to stay apart at a glance.

     Measured against --surface: sky 7.94:1 · coral 7.23:1 · lime 11.60:1 ·
     violet 7.13:1. The soft pair of each is a 13% tint, used behind the icon
     and nowhere near text. */
  --tone-sky:         #4fb0e8;
  --tone-coral:       #f9786b;
  --tone-lime:        #a9d94b;
  --tone-violet:      #ab8cf6;
  --tone-sky-soft:    rgba(79, 176, 232, 0.13);
  --tone-coral-soft:  rgba(249, 120, 107, 0.13);
  --tone-lime-soft:   rgba(169, 217, 75, 0.13);
  --tone-violet-soft: rgba(171, 140, 246, 0.13);

  --line:        #2a2a2d;   /* dividers, card borders */
  --line-soft:   #1d1d20;   /* dividers inside a card */
  --line-strong: #38383c;   /* input borders, where the edge must be found */
  /* The edge of the day you picked in the home week strip. Asked for by name
     and set once for both themes, which is why it is here and not in either
     theme block.

     MEASURED, AND IT ONLY WORKS IN ONE OF THEM. Against the cell's own
     Surface-2 it is 12.55:1 on the light theme and 1.08:1 on the dark one —
     and 1.02:1 against the Line border every unpicked cell already carries, so
     in the dark the selected day is the same colour as the rest of the row.
     The 2px weight is the only thing left telling them apart there. If the
     selection ever needs to read on the dark theme too, this wants a per-theme
     value: #2B251E on light, --ink on dark, which is the same role either way. */
  --day-picked:  #2B251E;

  --ink:         #f6f1ea;   /* primary text */
  --dim:         #a2968a;   /* secondary text, still fully readable */
  --faint:       #8d8175;   /* captions and labels — the quietest legal text */

  /* The accent has two jobs that only look like one job in dark mode.
       --accent      is the accent as INK: text, icons, borders, active states.
       --accent-fill is the accent as a SURFACE: the CTA, the active pill.
     They are the same amber here. They are two tokens because a light theme
     once needed them apart, and the split still costs nothing. */
  --accent:      #f5a524;
  --accent-fill: #f5a524;
  --accent-soft: rgba(245, 165, 36, 0.13);
  --accent-line: rgba(245, 165, 36, 0.26);
  --accent-deep: #7a5a1e;   /* the accent in shadow — assisting muscles */
  --on-accent:   #1a1206;   /* text on --accent-fill — 9.08:1 */

  /* Semantic colours. "info" (focus rings, links, notes) is the sky tone: a
     greener blue than the accent, so the two stay apart without a focus ring
     turning a colour that belongs to nothing else in the app. */
  --success:      #5ec26a;
  --success-soft: rgba(94, 194, 106, 0.13);
  --info:         var(--tone-sky);
  --info-soft:    var(--tone-sky-soft);
  --warn:         #e8833a;
  --warn-soft:    rgba(232, 131, 58, 0.13);
  --danger:       #f0685f;
  --danger-soft:  rgba(240, 104, 95, 0.13);

  /* Weekly volume per muscle. A diverging scale, not a ramp: too little and
     too much are both wrong, so the ends are coloured and the middle is
     green. "high" is the note colour rather than red because exceeding the
     range is a note, not a fault. */
  --vol-none:     var(--line-strong);
  --vol-low:      var(--danger);
  --vol-building: var(--warn);
  --vol-good:     var(--success);
  --vol-high:     var(--info);

  /* Macros. Three fills that must be told apart at 7px tall: the card tones
     the user picked in the Nutrition preview of the rebrand. */
  --macro-protein: var(--tone-coral);
  --macro-carbs:   var(--tone-lime);
  --macro-fat:     var(--tone-violet);

  /* Body map. Monochrome on purpose: primary is the accent, assisting is the
     same blue in shadow. A second hue here would compete with the chips
     that already name the muscles. */
  --anat-outline:   #1f1f22;
  --anat-idle:      #2a2a2d;
  --anat-primary:   var(--accent);
  /* The muscle you tapped on the recovery screen. Deliberately NOT the accent:
     a muscle inside its window is already blue, so a blue pick would fade
     invisibly on exactly the muscles worth inspecting. Sky was used until
     v270, when the accent turned blue and sky stopped being different. */
  --anat-picked:    var(--tone-sky);
  --anat-secondary: var(--accent-deep);

  /* ========================================================== RADII ====
     Round, since the v270 rebrand: cards at 28, small things at 16, and
     every button a pill (.btn takes --r-full in styles.css). */

  --r-sm:   16px;   /* inputs, calendar cells */
  --r-md:   28px;   /* cards */
  --r-lg:   28px;   /* large surfaces */
  --r-xl:   28px;   /* the sheet's top corners */
  --r-full: 999px;  /* buttons, pills, chips, progress bars */

  /* ======================================================== SHADOWS ====
     On a dark UI, shadow barely reads — elevation comes from the surface
     getting lighter, plus a hairline. So --ring does most of the work and
     shadow is reserved for things that genuinely float above the page.

     --shadow-sheet points upward because the sheet arrives from below. */

  --ring:         inset 0 0 0 1px var(--hairline);
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.40);
  --shadow-float: 0 8px 24px -4px rgba(0, 0, 0, 0.55);   /* toast, rest timer */
  --shadow-sheet: 0 -8px 40px -8px rgba(0, 0, 0, 0.60);
  --scrim:        rgba(8, 9, 11, 0.62);

  /* Thin glass, for the tab bar: "A" from the page tried on the phone, picked
     on 13/11/2026 over "B" (Liquid Glass). Half a fill, so more of what is
     behind shows through, a hairline of light along the top and no sheen. The
     lens is the bubble under the active tab. */
  --glass-fill:     rgba(15, 15, 16, 0.50);
  --glass-fill-min: rgba(15, 15, 16, 0.32);   /* while it has stepped back */
  --glass-blur:     saturate(190%) blur(22px);
  --glass-rim:      inset 0 1px 0 rgba(255, 255, 255, 0.14),
                    inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  --glass-lens:     rgba(255, 255, 255, 0.06);

  /* ========================================================= MOTION ====
     Declared here in Phase 2 so the values exist in one place; they are
     applied in Phase 4. The Phase 0 audit found eight hardcoded durations
     that nearly matched each other, which is the problem these solve.

     The built-in CSS easings are too weak to read as intentional. Entrances
     use ease-out so movement starts immediately, at the moment the eye is
     watching most closely. ease-in is never correct for UI. */

  --ease-out:    cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);   /* iOS drawer curve */

  /* How far an entering overlay travels. One token so reduced motion can
     collapse the movement to zero while the fade still carries the change. */
  --rise: 12px;

  /* The sheet's closed position and opacity. Together these switch the
     technique rather than just the distance: normally the panel slides up
     from its own height at full opacity; under reduced motion it does not
     move at all and cross-fades instead, which is what iOS itself does. */
  --sheet-out:  100%;
  --sheet-fade: 1;

  --dur-press:  140ms;   /* button press feedback */
  --dur-fast:   180ms;   /* tooltips, small popovers */
  --dur-base:   220ms;   /* dropdowns, colour and fill changes */
  --dur-sheet:  320ms;   /* the sheet and other large surfaces */
  --dur-grow:   560ms;   /* a bar growing to its value as a screen opens */
  --dur-exit:   160ms;   /* exits are faster than entrances, always */

  /* ========================================================= LAYOUT ==== */
  /* The notch and the home indicator. `env()` is 0 everywhere that has
     neither, so these are safe to add to any offset unconditionally. */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* The band under the status bar that an iPhone blurs, in an app on the Home
     Screen, and so the space every screen leaves empty at its top. Zero here;
     set in the display-mode block at the end of this file.

     From iOS 26 the system blurs whatever sits just under the clock. Measured
     on a real iPhone on 23/09/2026: the blur runs from the bottom of the status
     bar to about 40pt below it, over the avatar and the gear on the home screen.
     Nothing a page can say turns it off -- v253 changed the status-bar meta tag
     and v254 gave the top bar the solid colour WebKit looks for, and the blur
     stayed through both. So nothing sits there at rest. The bloom behind it is
     a smooth gradient, and a blurred smooth gradient looks exactly like itself;
     content scrolls up into it the way it does in the phone's own apps. */
  --pocket:      0px;
  --tabbar-h:    3.625rem;   /* 58px at the reference width */
  /* The bar floats: it is inset from the sides and lifted off the bottom, so
     everything that has to clear it needs one number rather than three, and
     that number has to live in one place. --tabbar-clear is the distance from
     the bottom of the viewport to the top of the bar. */
  /* Two tenths of the bar's own height closer to the bottom edge than the twelve
     pixels it started at, in two steps of one tenth. Measured against the bar
     rather than against the gap, because a tenth of twelve pixels is not a
     change anyone can see. At 58px that leaves roughly nothing above the safe
     area, which is as low as this can usefully go. */
  --tabbar-lift: calc(var(--sp-12) - 0.2 * var(--tabbar-h));
  --tabbar-clear: calc(var(--tabbar-h) + var(--safe-bottom) + var(--tabbar-lift));
  /* The square behind an active tab's glyph. It stays centred in the bar; the
     amber rule is measured down from it in styles.css, so this is the one
     number the pair depends on. */
  --tab-chip: var(--sp-40);

  --content-max: 720px;

  /* Artwork sizes. Not spacing, but design decisions all the same: 106px is
     the figure width the approved header was composed around, and the pair of
     them has to stay the same size wherever it appears. */
  --fig-body: 6.625rem; /* 106px at the reference width; one anatomy figure in a front/back pair */
  --fig-move: 13.75rem; /* 220px at the reference width; the movement illustration at full size */
}

/* ==========================================================================
   There is no light theme

   The app is dark only, fixed by data-theme="dark" on <html>. The light
   palette that followed here was unreachable from the day that attribute
   was written, and was removed rather than carried.

   Comments above that mention light mode are kept on purpose: they record
   why a token was split -- --accent and --accent-fill are two tokens because
   one colour could not do both jobs on paper -- and the split still stands.
   ========================================================================== */

/* ==========================================================================
   Short screens

   The Coach+ header was composed at 812px tall. On a 568px iPhone SE the same
   header plus the two anatomy figures filled the whole viewport and pushed
   every exercise below the fold, so the list read as absent rather than as
   scrollable. The figures give up the most height for the least meaning at
   that size — they still say which region is worked at 84px.
   ========================================================================== */

/* Only an installed app has the blurred band under the clock; a browser tab
   draws its own bar and the page starts below it. */
@media (display-mode: standalone) {
  :root {
    --pocket: 30px;   /* 40 until v281; the user asked for every screen 10px higher */
  }
}

@media (max-height: 700px) {
  :root {
    /* Capped by HEIGHT, not width. The figure is roughly 1:2.65, so trimming
       the width barely touches the number that matters — 84px wide was still
       223px tall. Height is the constrained axis here. */
    --fig-body-max-h: 10rem;
    --screen-top: var(--sp-24);
  }
}

/* ==========================================================================
   Reduced motion

   Reduced motion means gentler, not absent. The previous stylesheet killed
   every transition with 0.01ms !important, which removes the colour and
   opacity changes that carry meaning — a set marking itself done, a fill
   changing state — and leaves the interface feeling broken rather than calm.

   So: movement durations collapse, but opacity and colour keep a short
   transition. Screens that translate should fade instead; that swap is made
   at the component level in Phase 4, using these values.
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  :root {
    /* Movement goes to zero, so nothing slides or rises. The fades stay, and
       stay long enough to read as a change rather than a flicker — that is
       what separates "gentler" from "off". */
    --rise: 0px;
    --sheet-out:  0%;   /* the sheet cross-fades instead of sliding */
    --sheet-fade: 0;

    --dur-press: 0ms;
    --dur-fast:  100ms;
    --dur-base:  120ms;
    --dur-sheet: 120ms;
    --dur-exit:  100ms;

    --ease-out:    ease;
    --ease-in-out: ease;
    --ease-drawer: ease;
  }
}
