/* Stencil Audio design tokens: every colour, font, size, space, corner and timing the site uses.
 * Plain CSS custom properties, so they carry into any template system unchanged.
 * Source: the Stencil Audio brand guidelines; deviations from them are marked "Deviation".
 */

:root {
  /* ---- Primitives: the brand's four colours (proportion 40/20/20/20) ---- */
  --brand-black: #0f1314;
  --brand-white: #ffffff;
  --brand-grey: #eeeeee;
  --brand-offwhite: #edece2;

  /* UI greys, not in the brand book: hairlines, disabled states and muted text need more than four colours. */
  --brand-grey-100: #e2ddd8;
  --brand-grey-200: #d4d4c8;
  --brand-grey-300: #c8c4ba;
  --brand-grey-400: #b0b0a8;
  --brand-grey-500: #666666;
  /* Inverted sections only: the muted surface on black. */
  --brand-grey-800: #2a2e2f;

  /* ---- Semantic colour -------------------------------------------------- */
  --background: var(--brand-offwhite);
  --card: var(--brand-white);
  --muted: var(--brand-grey);
  --bg-inverse: var(--brand-black);

  --foreground: var(--text-ink); /* black, or the muted ink (data-ink="muted"); see the end of this file */
  --muted-foreground: var(--brand-grey-500);
  --primary-foreground: var(--brand-white);
  /* Deliberately faint: WCAG exempts inactive controls, and in a monochrome system faintness is the disabled signal. */
  --text-disabled: var(--brand-grey-400);

  --border: var(--brand-grey-200);
  /* A form control's boundary needs 3:1 (WCAG 1.4.11); --border is 1.49:1 on white, so it is for decorative
   * hairlines only. grey-500 is 5.74:1 on a white field. */
  --border-input: var(--brand-grey-500);
  --ring: var(--brand-black);

  --primary: var(--brand-black);
  --primary-hover: var(--brand-grey-500);
  --primary-disabled: var(--brand-grey-300);

  /* ---- Layout ----------------------------------------------------------- */
  --space-none: 0px;   /* zero is still a token: ghost buttons sit flush left */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  /* Fluid on the top three: the upper bound is reached at 1280px, phones get the lower bound, and each floor stays
   * above the step below, so the scale keeps its order at every width. */
  --space-2xl: clamp(48px, 5vw, 64px);
  --space-3xl: clamp(64px, 7.5vw, 96px);
  --space-4xl: clamp(96px, 12.5vw, 160px);

  --radius: 0px;            /* square by default; cards and buttons use --radius-sm / --radius-md below */

  /* ---- Grid --------------------------------------------------------------
   * Native CSS Grid, 12 columns (divides by 2, 3, 4 and 6). Breakpoints are not tokens: custom properties
   * can't be used in media queries. The breakpoints are 640px, 1024px and 1440px. */
  --grid-columns: 12;
  --grid-gutter: var(--space-md);
  --container-max: 1440px;
  --container-pad: max(clamp(16px, 5vw, 64px), env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px)); /* a phone held sideways: clear of the notch (viewport-fit=cover, layout.html) */
  /* Reading measure for body copy: --container-max governs the page, this the paragraph. */
  --measure: 36em; /* about 65-70 characters a line */
  --border-width: 1px;
  --border-width-strong: 2px;

  /* ---- Typography ------------------------------------------------------- */
  --font-display: "Archivo", system-ui, sans-serif;
  --font-body: "Archivo", system-ui, sans-serif;
  --font-accent: "Hack", ui-monospace, monospace; /* nav, labels and buttons, upper case only */

  /* The brand's scale: X, X×1.5, ×3, ×6, ×10, ×18 where X = 16px, with clamp() on the top sizes (the brand
   * book gives no responsive guidance; the upper bound is the brand value). */
  --text-label: 13px;
  --text-body: 16px;
  --text-lg: 24px;
  /* The brand ramp jumps 24 → 48; .t-h4 (ExtraBold at --text-lg) covers UI-scale headings without a new size. */
  --text-h3: clamp(32px, 4vw, 48px);
  --text-h2: clamp(48px, 8vw, 96px);
  --text-h1: clamp(64px, 13vw, 160px);
  --text-display: clamp(72px, 22vw, 288px);

  /* Deviation from the brand book's tracking (-45 on titles, -20 on the accent face): condensed capitals and a
   * monospace both want open spacing, so titles take 0 and every Hack capital takes 0.15em. */
  --tracking-tight: 0em;
  --tracking-accent: 0.15em;
  --leading-heading: 1;         /* brand book: 1× */
  --leading-body: 1.12;         /* brand book: 1.12× */
  /* Deviation: the brand's leading and tracking are display settings. At 16px they crowd the letters and lose
   * the eye between lines, so multi-line reading text uses these. Display and short UI text keep the values above. */
  --leading-prose: 1.5;
  --tracking-prose: -0.01em;

  /* ---- Motion ------------------------------------------------------------
   * One motion vocabulary: sharp deceleration, no spring or overshoot, so motion reads precise, not playful. */
  --duration-fast: 120ms;                       /* state: hover, focus */
  --duration-base: 320ms;                       /* entrance: reveal, expand */
  --duration-slow: 600ms;                       /* photos and drawings moving */
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);  /* no overshoot, on purpose */
}

/* ---- Type styles --------------------------------------------------------
 * Archivo is sentence case, the accent font is upper case only. Everything is left-aligned (the brand forbids
 * the alternatives).
 */

.t-display,
.t-h1,
.t-h2,
.t-h3,
.t-h4 {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-tight);
  text-align: left;
}

.t-display { font-size: var(--text-display); }
.t-h1 { font-size: var(--text-h1); }
.t-h2 { font-size: var(--text-h2); }
.t-h3 { font-size: var(--text-h3); }
.t-h3-italic { font-size: var(--text-h3); font-style: italic; }
/* Card headings, list items, table headers. Reuses --text-lg; the weight is
 * what separates it from .t-lead, which is Medium at the same size. */
.t-h4 { font-size: var(--text-lg); }

.t-lead,
.t-body {
  font-family: var(--font-body);
  font-weight: 500;
  line-height: var(--leading-body);
  letter-spacing: var(--tracking-tight);
  text-align: left;
}

.t-lead { font-size: var(--text-lg); }
.t-body { font-size: var(--text-body); }
.t-body-italic { font-size: var(--text-body); font-style: italic; }

/* Reading text: FAQ answers, case studies, page copy. Goes on the wrapper,
 * since a CMS rich-text field outputs plain <p>s; headings inside keep the
 * display settings. Pair with .measure for line length. */
.t-prose {
  line-height: var(--leading-prose);
  letter-spacing: var(--tracking-prose);
}
.t-prose :is(h2, h3, h4) {
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-tight);
}

.t-label {
  font-family: var(--font-accent);
  font-size: var(--text-label);
  line-height: var(--leading-body);
  letter-spacing: var(--tracking-accent);
  text-transform: uppercase;
  text-align: left;
}

/* ---- Focus --------------------------------------------------------------
 * One rule for every interactive element; --ring flips white in .section-inverse.
 */
:focus-visible {
  outline: var(--border-width-strong) solid var(--ring);
  outline-offset: 2px;
}

/* ---- Inverted sections --------------------------------------------------
 * Black bands: a scoped override (a layout choice, not a user preference, so not a media query).
 */
.section-inverse {
  background: var(--bg-inverse);
  --foreground: var(--brand-white);
  --muted-foreground: var(--brand-grey-300);
  --text-disabled: var(--brand-grey-500);
  --border: var(--brand-grey-500);
  --primary: var(--brand-white);
  --primary-foreground: var(--brand-black);
  /* Without this, a focus ring in a black band would be black on black. */
  --ring: var(--brand-white);
  --muted: var(--brand-grey-800);
  --card: var(--brand-black);
  --border-input: var(--brand-grey-400);
  --primary-hover: var(--brand-grey);
  --primary-disabled: var(--brand-grey-500);
  color: var(--foreground);
}

/* ---- Grid utility -------------------------------------------------------
 * The tokens above do nothing on their own; this is the minimum that uses them.
 */
.container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), minmax(0, 1fr));
  gap: var(--grid-gutter);
}

/* Body copy stays readable regardless of container width. */
.measure { max-width: var(--measure); }

/* ---- Reduced motion -----------------------------------------------------
 * Every animation and transition runs once, for 1ms. The hero has its own reduced variant (assets/hero/hero.css).
 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

/* The @font-face rules are in /assets/fonts/fonts.css. */
/* ---- Identity layer: corners, line weights and drawing timings ---------- */

:root {
  --display-stretch: 62%;            /* Archivo's narrowest width: "very condensed" titles */

  --ink-black: var(--brand-black);
  --ink-muted: var(--brand-grey-800);    /* #2a2e2f, an optional muted ink (data-ink="muted" on <html>) */
  --text-ink: var(--ink-black);

  --radius-sm: 6px;                  /* buttons, strips */
  --radius-md: 10px;                 /* cards, images */

  --line: currentColor;              /* drawings, borders, callouts and frame marks share one line colour */
  --line-outline: 1.6px;             /* matches handdraft.py STYLE outline */
  --line-detail: 0.7px;              /* matches handdraft.py STYLE detail */

  --dur-draw: 1600ms;                /* lines draw on */
  --dur-print: 900ms;                /* the print pass sweeps across */
  --dur-reveal: 600ms;               /* the photo shows through */
  --ease-draw: cubic-bezier(.45, 0, .2, 1);
  --ease-print: cubic-bezier(.7, 0, .3, 1);
}
:root[data-ink="muted"] { --text-ink: var(--ink-muted); }
@media (prefers-reduced-motion: reduce) { :root { --dur-draw: 0ms; --dur-print: 0ms; --dur-reveal: 0ms; } }
