/* The one place either site names a colour, a radius or a duration.
 *
 * Every colour here is copied from `lib/core/theme.dart` — Coach Sultan's
 * own palette, near-black carrying one bright yellow, the same values the
 * app ships. `sites/test/tokens_test.js` reads both files and fails if a
 * shared colour drifts, so this file is not a sketch of the app's theme;
 * it is the same theme.
 *
 * Dark is the default because the coach's programme file is black and both
 * sites are built from it. Light exists only for the dashboard, which is a
 * tool someone sits in front of all day; the public site never offers it.
 */

:root {
  /* ---- brand ---- */
  --yellow: #f5e13c; /* AppColors.primary — a FILL, never small text */
  --yellow-ink: #f5e13c; /* AppColors.primaryInk — ink: text, icons, hairlines */
  --on-yellow: #141210; /* AppColors.onPrimary — 14:1 on the fill */

  /* ---- surfaces ---- */
  --bg: #0a0a0a; /* AppColors.background */
  --card: #161616; /* AppColors.card */
  --raised: #1f1f1f; /* AppColors.surfaceRaised */
  --chip: #2e2e2e; /* the grey title chip from the coach's file */

  /* ---- text ---- */
  --text: #f4f4f2; /* AppColors.textPrimary */
  --text-2: #9c9c98; /* AppColors.textSecondary — 4.5:1 on --bg and --card */
  --divider: #2c2c2a; /* AppColors.divider */
  --border: rgb(255 255 255 / 10%); /* AppColors.border */

  /* ---- states ---- */
  --alert: #ff6b6b; /* AppColors.alert — deliberately NOT the yellow */
  --ok: #f5e13c; /* AppColors.success collapses into the accent */

  /* ---- shape, taken from AppSpacing ---- */
  --r-card: 16px;
  --r-lg: 20px;
  --r-pill: 999px;
  --gap: 12px;
  --pad: 16px;

  /* ---- motion ---- */
  --fast: 140ms;
  --base: 220ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);

  color-scheme: dark;
}

/* The dashboard's light mode. `--yellow` stays the brand in both — light
 * mode does not deepen the fill, it splits the ink off, exactly as
 * DESIGN.md describes: #F5E13C on white is ~1.3:1 and useless as a caption
 * or a hairline, so ink becomes #7A6A00 (4.5:1 on all three surfaces). */
:root[data-theme='light'] {
  --yellow: #f5e13c;
  --yellow-ink: #7a6a00;
  --on-yellow: #141210;

  --bg: #fafaf6;
  --card: #ffffff;
  --raised: #f1f1ea;
  --chip: #e6e6de;

  --text: #141210;
  --text-2: #6a6a63;
  --divider: #e6e6de;
  --border: rgb(0 0 0 / 10%);

  --alert: #b3261e;
  --ok: #278744;

  color-scheme: light;
}

/* ------------------------------------------------------------------ */
/* Cairo, served from this repo rather than Google Fonts: one less
 * third party, and the app already bundles these exact files.        */
@font-face {
  font-family: 'Cairo';
  src: url('fonts/Cairo-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Cairo';
  src: url('fonts/Cairo-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Cairo';
  src: url('fonts/Cairo-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

/* ------------------------------------------------------------------ */
/* Base, shared by both sites.                                        */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

/* Any rule that sets `display` outranks the UA's `[hidden] { display:
 * none }`, which is how a panel marked hidden ends up on screen anyway.
 * Both sites toggle views with the attribute, so hidden has to win. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
p,
figure {
  margin: 0;
}

h1,
h2 {
  text-wrap: balance;
  line-height: 1.3;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
}

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

::selection {
  background: color-mix(in srgb, var(--yellow) 30%, transparent);
  color: var(--text);
}

/* Latin numerals inside Arabic text need an isolate or the bidi algorithm
 * reorders a run like "4 × 12" on its own. Same rule as the app, which
 * uses Latin digits throughout. */
.num {
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}

/* The single most recognisable mark in the coach's file: a yellow band
 * down the edge of every page. Decorative, so it is hidden from
 * assistive tech and dropped on narrow screens where it would eat the
 * gutter. */
.edge-stripe {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: 14px;
  background: var(--yellow);
  z-index: 50;
  pointer-events: none;
}

@media (max-width: 760px) {
  .edge-stripe {
    width: 6px;
  }
}

/* The section title as his file sets it: a grey chip with a short yellow
 * bar sitting above its leading corner. */
.chip-title {
  display: inline-block;
  position: relative;
  margin-block-start: 18px;
  padding: 10px 26px;
  background: var(--chip);
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
}

.chip-title::before {
  content: '';
  position: absolute;
  inset-block-start: -12px;
  inset-inline-start: 24px;
  width: 86px;
  height: 6px;
  background: var(--yellow);
}

/* A number in a hairline box with its label above it — the way sets and
 * reps are printed on every exercise in his file. */
.figure-box {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.figure-box > .label {
  font-size: 12px;
  color: var(--text-2);
}

.figure-box > .value {
  min-width: 56px;
  padding: 2px 12px;
  border: 1px solid var(--border);
  text-align: center;
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--yellow);
  color: var(--on-yellow);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--fast) var(--ease), filter var(--fast) var(--ease);
}

.btn:hover {
  filter: brightness(1.06);
}

/* The app presses to 0.96; the sites match so the two feel like one
 * product. */
.btn:active {
  transform: scale(0.96);
}

.btn[disabled],
.btn[aria-disabled='true'] {
  background: var(--raised);
  color: var(--text-2);
  cursor: not-allowed;
  filter: none;
  transform: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--yellow-ink);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: var(--pad);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
