/* =============================================================================
   Base: reset, document, type scale, layout primitives.
   Requires tokens.css. Rules: 03-typography.md, 04-layout-and-spacing.md.

   Graphik is not available as a web font yet, so everything here runs on the
   fallback stack in --font-sans. See the commented @font-face block in
   css/tokens.css for how to enable it once the files and licence arrive.
   ============================================================================= */

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

/* ---- Layout tokens in rem ------------------------------------------------
   The container, the grid and the bar height are stated in rem so that a reader
   who raises their own default font size scales the whole layout with it, not
   just the text. At the default 16px root these are the pixel values in the
   comments. The page does NOT scale with the viewport; see the note below. */
:root {
  --container-max: 76rem;       /* 1216px, 19 x --grid-size (see tokens.css) */
  --container-narrow: 47.5rem;  /* 760px  */
  --container-form: 55rem;      /* 880px, the submit wizard */
  --grid-size: 4rem;            /* 64px   */
  --nav-h: 5.5rem;              /* 88px, the sticky top bar (Method One is 87px) */
  --task-space: 2.5rem;         /* 40px, section rhythm inside task views */
}

/* The root size is FIXED at the reader's own default (16px unless they changed
   it). It used to grow with the viewport above 1440px, which is why the page
   looked oversized next to the Method One console: at 2000x940 the root reached
   18.8px, so body text rendered at 21px against the console's 18px, the headline
   at 66px against 56px, and the top bar at 104px against 87px.

   The console does not scale with the viewport either. A fixed column on a very
   wide monitor leaves more empty space at the sides, and that is the accepted
   trade: matching the console's density matters more than filling a 2560px
   screen. Everything stays in rem so a reader who raises their own default font
   size still scales the whole page. */

/* The hero headline is bounded by height as well as width: on a laptop whose
   window is wide for its height (browser chrome eats 130-250px) the width term
   alone asks for more type than the screen can carry. */
@media (min-width: 1024px) {
  :root { --text-display: clamp(2.25rem, min(1.2rem + 2.6vw, 7vh), 3.5rem); }
}
/* From the width where the rails appear, the gutter is exactly one grid cell, so
   the text column's edges land on grid lines as well: container edge, gutter and
   content all share the 4rem rhythm instead of cutting across it. */
@media (min-width: 1296px) {
  :root { --gutter: 4rem; }
}

html {
  -webkit-text-size-adjust: 100%;
  /* The page colour lives here so the fixed background grid shows through
     ordinary sections (see the note at the end of background-grid.css). */
  background: var(--color-bg);
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  color: var(--color-text);
  background: transparent;
  font-size: var(--text-body);
  line-height: var(--leading-body);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Headings carry no colour of their own: one weight, one colour ---- */
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: var(--weight-semibold); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }

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

img, svg { max-width: 100%; }

/* ---- Type scale ---- */
.display {
  font-size: var(--text-display); font-weight: var(--weight-semibold);
  line-height: var(--leading-display); letter-spacing: var(--tracking-display);
  text-wrap: balance;
}
.h1 {
  font-size: var(--text-h1); font-weight: var(--weight-semibold);
  line-height: var(--leading-heading); letter-spacing: var(--tracking-h1);
  text-wrap: balance;
}
.h2 {
  font-size: var(--text-h2); font-weight: var(--weight-semibold);
  line-height: var(--leading-heading); letter-spacing: var(--tracking-h2);
  text-wrap: balance;
}
.h3 { font-size: var(--text-h3); font-weight: var(--weight-semibold); line-height: 1.2; letter-spacing: var(--tracking-h3); }
.h4 { font-size: var(--text-h4); font-weight: var(--weight-semibold); line-height: 1.3; }

.body-lg { font-size: var(--text-body-lg); max-width: 65ch; text-wrap: pretty; }
.body { font-size: var(--text-body); max-width: 70ch; text-wrap: pretty; }
.small { font-size: var(--text-small); }
.caption { font-size: var(--text-caption); line-height: 1.4; }
.muted { color: var(--color-text-muted); }
.tabular { font-variant-numeric: tabular-nums; }

/* ---- Layout ---- */
.container {
  width: 100%; max-width: var(--container-max);
  margin-inline: auto; padding-inline: var(--gutter);
}
.narrow { max-width: var(--container-narrow); margin-inline: auto; }

.section { padding-block: var(--section-space); }
.section-tight { padding-block: var(--space-8); }
/* The tile row sits directly under the hero, which already carries bottom
   padding, so it only needs space beneath it. */
.quick-links { padding-block: 0 var(--space-6); }

/* ---- Task views versus marketing sections -------------------------------
   The Discover hero is a marketing moment and keeps display type and generous
   space. Submit, Leaderboard and Detail are work surfaces: on a laptop at 125
   to 150 percent scaling the visible area is about 1280x600 CSS pixels, so a
   display headline and --section-space rhythm cost most of the first screen.
   These keep the title to one line and the rhythm to 32-48px. */
.section-task { padding-block: var(--space-5) var(--task-space); }

.title-task {
  font-size: clamp(1.625rem, 1.2rem + 1.1vw, 2.125rem);  /* ~26-34px */
  font-weight: var(--weight-semibold);
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

/* One short intro line under a task title. */
.intro-task { font-size: var(--text-small); color: var(--color-text-muted); margin-top: var(--space-2); }

.task-head {
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-6);
  border-bottom: var(--border-width) solid var(--color-border);
}

/* A quiet band. Opaque, so it covers the grid on purpose. */
.band { background: var(--color-bg-subtle); border-block: var(--border-width) solid var(--color-border); }

.stack > * + * { margin-top: var(--space-4); }
.stack-lg > * + * { margin-top: var(--space-6); }

.section-head {
  display: flex; flex-wrap: wrap; gap: var(--space-4);
  align-items: baseline; justify-content: space-between;
  margin-bottom: var(--space-6);
}

/* ---- Accessibility helpers ---- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: var(--space-4); top: var(--space-4);
  z-index: var(--z-overlay); transform: translateY(-200%);
  background: var(--color-bg); color: var(--color-text);
  border: 2px solid var(--color-border-strong); border-radius: var(--radius-control);
  padding: var(--space-3) var(--space-4);
  text-decoration: none; font-weight: var(--weight-semibold);
}
.skip:focus { transform: translateY(0); }

main { flex: 1 0 auto; }

/* ---- View switching. Only one view is in the document flow at a time. ---- */
.view { display: none; }
.view.active { display: block; }
