/* CUT — token layer and primitives. See proj/030-visual-design.md.
   ONLY this file defines custom properties. Every other stylesheet consumes
   them and declares nothing global. */

:root {
  /* Spectrum: Apple's iOS dark-mode system colours, in wavelength order.
	   The rainbow is the compilation, so these are data, not decoration. */
  --spec-1: #ff375f;
  --spec-2: #ff9f0a;
  --spec-3: #ffd60a;
  --spec-4: #30d158;
  --spec-5: #40c8e0;
  --spec-6: #0a84ff;
  --spec-7: #bf5af2;
  --spectrum: linear-gradient(
    90deg,
    var(--spec-1) 0%,
    var(--spec-2) 16.6%,
    var(--spec-3) 33.3%,
    var(--spec-4) 50%,
    var(--spec-5) 66.6%,
    var(--spec-6) 83.3%,
    var(--spec-7) 100%
  );

  /* Neutrals. True black so the video is the only lit object on an OLED. */
  --ink: #000000;
  --surface: #0a0a0b;
  --surface-2: #141416;
  --hairline: rgba(255, 255, 255, 0.1);
  --hairline-2: rgba(255, 255, 255, 0.06);
  --text: #f5f5f7;
  --text-dim: #86868b;
  /* 5.43:1 on --ink, 4.76:1 on --surface-2: passes AA body everywhere, so
	   there is no token in this palette that fails a contrast check. The
	   earlier #5A5A5F measured 3.06/2.89/2.68 and was used for the timeline
	   ruler, which is text a user reads to operate a control. */
  --text-faint: #818188;

  /* Contextual hue: the colour of the clip currently under the hand. */
  --hue: var(--spec-1);
  /* 070 A-9.4. A focus ring on a LIGHT surface — the white primary pill —
	   where the contextual hue would fail 2.4.11 (--spec-3 measures 1.30:1
	   against --text). Consumers must inset the ring: an outset ink ring sits on
	   the black page and is invisible. */
  --focus-on-light: var(--ink);

  --font-ui:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-num:
    ui-monospace, "SF Mono", SFMono-Regular, Menlo, "Cascadia Mono", "Roboto Mono", monospace;

  --r-pill: 980px;
  --r-panel: 14px;
  --r-row: 12px;
  --r-ctrl: 10px;
  --r-chip: 8px;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;

  --tap: 44px;
  --ease-move: cubic-bezier(0.32, 0.72, 0, 1);
  --dur-fast: 120ms;
  --dur-base: 180ms;
  --dur-slow: 220ms;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

html {
  background: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1,
h2,
h3,
p,
ol,
ul,
figure {
  margin: 0;
  padding: 0;
}

ol,
ul {
  list-style: none;
}

button,
input,
a {
  font: inherit;
  color: inherit;
}

button {
  margin: 0;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

a {
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

/* ---------------------------------------------------------------- focus */

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--hue);
  outline-offset: 2px;
  border-radius: var(--r-chip);
}

/* ------------------------------------------------------------ typography */

.label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

/* REQ-102. Every text container that renders data we do not control.
   `min-width: 0` is the half people forget: without it a flex child refuses to
   shrink below its content and the ellipsis never appears. */
.truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.truncate-2 {
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

/* ------------------------------------------------------------- wordmark */

.wordmark {
  font-size: clamp(30px, 8vw, 44px);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1;
  /* Fallback first: a solid mark for anything that cannot clip to text. */
  color: var(--text);
  background-image: var(--spectrum);
}

/* Only make the glyphs transparent where the clip is actually supported.
   Declaring -webkit-text-fill-color unconditionally is how a wordmark
   disappears entirely in a browser that ignores background-clip. */
@supports (background-clip: text) or (-webkit-background-clip: text) {
  .wordmark {
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
  }
}

/* Forced-colors strips background-image but keeps the transparent text fill,
   which would erase the wordmark entirely. Print does the same. Both put the
   glyphs back. */
@media (forced-colors: active), print {
  .wordmark {
    background-image: none;
    -webkit-text-fill-color: currentColor;
    color: CanvasText;
  }
}

/* -------------------------------------------------------------- controls */

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 0 var(--s5);
  border-radius: var(--r-pill);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition:
    transform var(--dur-fast) var(--ease-move),
    background-color var(--dur-fast) ease-out,
    opacity var(--dur-fast) ease-out;
}

.pill:active:not(:disabled) {
  transform: scale(0.97);
}

.pill--primary {
  background: var(--text);
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.pill--secondary {
  background: transparent;
  border: 1px solid var(--hairline);
  color: var(--text);
}

.pill--secondary:hover:not(:disabled) {
  background: var(--surface-2);
}

.pill--danger:hover:not(:disabled),
.pill--danger:focus-visible {
  color: var(--spec-1);
  border-color: var(--spec-1);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap);
  min-height: var(--tap);
  border-radius: var(--r-ctrl);
  color: var(--text-dim);
  transition:
    color var(--dur-fast) ease-out,
    background-color var(--dur-fast) ease-out;
}

.icon-button:hover:not(:disabled),
.icon-button:focus-visible {
  color: var(--text);
}

.icon-button--transport {
  font-size: 20px;
  color: var(--text);
  background: var(--surface-2);
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  min-width: 44px;
  padding: 0 var(--s3);
  border-radius: var(--r-chip);
  border: 1px solid var(--hairline);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
}

.chip:hover,
.chip:focus-visible {
  color: var(--text);
}

/* A chip that is a checkbox. The box is what says which state it is in: a
   chip that only changed colour reads as "selected", and this is a setting
   that stays on across clips, which is a different thing.
   The mark is `.check-box` and not a `.chip__box` child because the a11y suite
   reads every `[class*="chip"]` as a status chip that owes the reader words,
   and this one is decoration inside a control that already has them. */
.chip--check {
  gap: var(--s2);
  padding-left: var(--s2);
}

.check-box {
  position: relative;
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 3px;
  border: 1px solid currentColor;
}

.chip--check[aria-checked="true"] {
  color: var(--text);
  border-color: currentColor;
}

.chip--check[aria-checked="true"] .check-box {
  background: currentColor;
}

/* Two strokes in the surface colour, so the tick reads on the filled box. */
.chip--check[aria-checked="true"] .check-box::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid var(--ink);
  border-width: 0 2px 2px 0;
  rotate: 45deg;
}

.nudge {
  min-width: var(--tap);
  min-height: 34px;
  border-radius: var(--r-chip);
  background: var(--surface-2);
  color: var(--text-dim);
  font-family: var(--font-num);
  font-size: 12px;
  font-weight: 600;
}

.nudge:hover:not(:disabled),
.nudge:focus-visible {
  color: var(--text);
}

.input {
  min-height: var(--tap);
  padding: 0 var(--s3);
  border-radius: var(--r-ctrl);
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--text);
}

.input::placeholder {
  color: var(--text-faint);
}

/* REQ-107. A control that cannot act stays present, stays focusable, and says
   why somewhere next to itself. It is never hidden and never silently inert. */
:disabled,
[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
}

.empty {
  padding: var(--s5) var(--s4);
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  text-wrap: balance;
}

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

/* --------------------------------------------------------- reduced motion */

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