/* ==========================================================================
   COMPONENTS: built only from tokens.css (sizes) and themes.css (colour).
   Load order: tokens.css, themes.css, components.css
   ========================================================================== */

/* Slides the gradient by exactly one tile, so the loop has no seam */
@keyframes ring-flow {
  from { background-position-x: 200%; }
  to   { background-position-x: 0%; }
}

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

body {
  margin: 0;
  padding: var(--page-margin);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Type styles ---------- */
.headline      { font-size: var(--text-headline);      font-weight: var(--weight-regular); line-height: var(--leading-display); letter-spacing: var(--tracking-display); }
.page-heading  { font-size: var(--text-page-heading);  font-weight: var(--weight-light);   line-height: var(--leading-title); }
.heading       { font-size: var(--text-heading);       font-weight: var(--weight-regular); line-height: var(--leading-heading); }
.small-heading { font-size: var(--text-small-heading); font-weight: var(--weight-bold);    line-height: var(--leading-subheading); }
.overline      { font-size: var(--text-overline);      font-weight: var(--weight-medium);  line-height: var(--leading-body); text-transform: uppercase; color: var(--color-text-muted); }
.body-large    { font-size: var(--text-body-large);    font-weight: var(--weight-light);   line-height: var(--leading-body); }
.body-small    { font-size: var(--text-body-small);    font-weight: var(--weight-light);   line-height: var(--leading-body); }
.body-xsmall   { font-size: var(--text-body-xsmall);   font-weight: var(--weight-light);   line-height: var(--leading-body); }

/* paragraph styles are a step softer than headings */
.body-large, .body-small, .body-xsmall { color: var(--color-text-body); }

/* ---------- Icons (Feather) ----------
   <svg class="icon" aria-hidden="true"><use href="icons/feather-sprite.svg#NAME"/></svg>
   Icons take the colour of the surrounding text. */
.icon {
  flex: none;
  width: var(--icon-24);
  height: var(--icon-24);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke-24);
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}
/* Company logos (icons/brands-sprite.svg, from Font Awesome) are solid shapes.
   <svg class="icon icon-brand" …>. Feather stays the set for everything else. */
.icon.icon-brand { fill: currentColor; stroke: none; }
.icon-16 { width: var(--icon-16); height: var(--icon-16); stroke-width: var(--icon-stroke-16); }
.icon-12 { width: var(--icon-12); height: var(--icon-12); stroke-width: var(--icon-stroke-12); }

/* ---------- Buttons ---------- */
.btn {
  /* size settings: L is the default; .btn-m and .btn-s change these */
  --button-text: var(--font-size-24);
  --button-line: var(--button-line-l);
  --button-pad-x: var(--space-40);
  --button-gap: var(--space-8);
  --button-icon: var(--icon-24);
  --button-icon-stroke: var(--icon-stroke-24);

  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--button-gap);
  max-width: 100%;
  padding: var(--space-8) var(--button-pad-x);   /* height = padding + line height */
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-action-text);
  font: var(--weight-medium) var(--button-text) / var(--button-line) var(--font);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--hover-fade), box-shadow var(--hover-fade);
}

/* An icon before the label, after it, or both: order in the HTML decides */
.btn .icon { width: var(--button-icon); height: var(--button-icon); stroke-width: var(--button-icon-stroke); }

/* Gradient ring, drawn just outside buttons so nothing shifts.
   .focus-ring draws the same ring just inside a larger block such as a card. */
.btn::before,
.focus-ring::after {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--ring-width));
  padding: var(--ring-width);
  border-radius: inherit;
  /* mirrored, eased stops: no sharp edges, and both ends of the tile match.
     The in-between shades are mixed from the theme's two ring colours. */
  background-image: linear-gradient(90deg,
    var(--color-ring-start) 0%,
    color-mix(in srgb, var(--color-ring-start), var(--color-ring-end) 15%) 12.5%,
    color-mix(in srgb, var(--color-ring-start), var(--color-ring-end) 50%) 25%,
    color-mix(in srgb, var(--color-ring-start), var(--color-ring-end) 85%) 37.5%,
    var(--color-ring-end) 50%,
    color-mix(in srgb, var(--color-ring-start), var(--color-ring-end) 85%) 62.5%,
    color-mix(in srgb, var(--color-ring-start), var(--color-ring-end) 50%) 75%,
    color-mix(in srgb, var(--color-ring-start), var(--color-ring-end) 15%) 87.5%,
    var(--color-ring-start) 100%);
  background-size: 200% 100%;
  animation: ring-flow var(--ring-duration) linear infinite;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0;
  transition: opacity var(--hover-fade);
  pointer-events: none;
}

.focus-ring { position: relative; }
.focus-ring::after { inset: 0; z-index: 2; }

.btn:hover::before,
.btn:focus-visible::before,
.focus-ring:has(:focus-visible)::after { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .btn::before, .focus-ring::after { animation: none; transition: none; }
}

/* Keeps focus visible in Windows high contrast mode */
.btn:focus-visible { outline: var(--line-2) solid transparent; outline-offset: var(--focus-offset); }

.btn-primary {
  background: var(--color-action-primary-bg);
  color: var(--color-action-primary-text);
  box-shadow: inset 0 0 0 var(--line-1) transparent;
}
.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--color-action-primary-bg-hover);
  box-shadow: inset 0 0 0 var(--line-1) var(--color-action-primary-border-hover);
}

/* Drawn as an inset shadow so the outline adds nothing to the size */
.btn-secondary { box-shadow: inset 0 0 0 var(--line-1) var(--color-action-secondary-border); }
.btn-secondary:hover,
.btn-secondary:focus-visible {
  background: var(--color-action-secondary-bg-hover);
  box-shadow: inset 0 0 0 var(--line-1) var(--color-action-secondary-border-hover);
}

/* .btn-tertiary is the plain button: no fill or outline of its own */

@media (forced-colors: active) {
  .btn-primary, .btn-secondary { outline: var(--line-1) solid ButtonText; outline-offset: calc(-1 * var(--line-1)); }
}

.btn-link .label {
  text-decoration: underline transparent var(--line-1);
  text-underline-offset: var(--underline-offset);
  transition: text-decoration-color var(--hover-fade);
}
.btn-link:hover .label,
.btn-link:focus-visible .label { text-decoration-color: currentColor; }

@media (max-width: 560px) {
  .btn { --button-text: var(--font-size-16); --button-pad-x: var(--space-16); }
}

/* ---------- Button sizes (keep after the mobile rule) ---------- */
.btn-m {
  --button-text: var(--font-size-16);
  --button-line: var(--button-line-m);
  --button-pad-x: var(--space-24);
  --button-icon: var(--icon-16);
  --button-icon-stroke: var(--icon-stroke-16);
}

.btn-s {
  --button-text: var(--font-size-12);
  --button-line: var(--button-line-s);
  --button-pad-x: var(--space-16);
  --button-gap: var(--space-4);
  --button-icon: var(--icon-12);
  --button-icon-stroke: var(--icon-stroke-12);
}

/* ---------- Custom cursor (scripts/cursor-tag.js) ----------
   data-cursor="View case study" on a block turns the pointer into a tag. */
.cursor-tag {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  filter: var(--shadow-float);
  transition: opacity var(--cursor-fade);
}
.cursor-tag.is-visible { opacity: 1; }

@media (hover: hover) and (pointer: fine) {
  .has-cursor-tag [data-cursor],
  .has-cursor-tag [data-cursor] * { cursor: none; }
}

/* The same tag fixed in a corner, for touch screens and keyboard focus */
.cursor-hint {
  display: none;
  position: absolute;
  right: var(--space-40);
  bottom: var(--space-40);
  z-index: 2;
  pointer-events: none;
  filter: var(--shadow-float);
}
@media (hover: none) { .cursor-hint { display: block; } }
.focus-ring:has(:focus-visible) .cursor-hint { display: block; }

/* Makes a whole block clickable from the link in its heading */
.stretched-link { color: inherit; text-decoration: none; outline: none; }
.stretched-link::after { content: ""; position: absolute; inset: 0; z-index: 1; }

/* ---------- Fading gridline ---------- */
.gridline {
  justify-self: stretch;
  width: 100%;
  height: var(--line-1);
  margin: 0;
  border: 0;
  background: linear-gradient(90deg, var(--color-gridline), transparent);
}
.gridline-vertical {
  justify-self: start;
  align-self: stretch;
  flex: none;
  width: var(--line-1);
  height: auto;
  background: linear-gradient(180deg, var(--color-gridline), transparent);
}

/* A page-level horizontal line, add to .gridline:
   - fades in from outside the left side line, is strongest where it passes
     that line, and fades to nothing at the right side line
   - .gridline-reverse mirrors it
   - on narrow screens the outer fade ends exactly at the window edge
   - where it crosses another line only the stronger one shows, so there is
     no bright dot. For that it is drawn in solid colour and blended: it must
     share a stacking context with the lines it crosses, and that context
     needs a solid background of its own.
   Its parent spans the page width and is centred in the window.
   Set its "top" where it is used. */
.gridline-overshoot {
  --gridline-out: min(var(--gridline-overshoot), var(--page-margin) + max(0px, 50vw - var(--page-width) / 2));
  --gridline-angle: 90deg;
  position: absolute;
  left: calc(var(--page-margin) - var(--gridline-out));
  right: var(--page-margin);
  z-index: -1;
  width: auto;
  background: linear-gradient(var(--gridline-angle),
    var(--color-bg),
    var(--color-gridline-solid) var(--gridline-out),
    var(--color-bg));
  mix-blend-mode: var(--gridline-blend);
  pointer-events: none;
}
.gridline-reverse {
  --gridline-angle: 270deg;
  left: var(--page-margin);
  right: calc(var(--page-margin) - var(--gridline-out));
}

/* ---------- Blinds reveal (scripts/blinds.js) ----------
   .reveal-line is one line of text inside a [data-blinds] block. The script
   covers it with temporary .blind-slat copies and animates those. */
.reveal-line { position: relative; display: inline-block; }
.blinds-wait [data-blinds] .reveal-line,
.reveal-line.is-slatted { visibility: hidden; }
.blind-slat {
  position: absolute;
  inset: 0;
  visibility: visible;
  white-space: nowrap;
  pointer-events: none;
}

/* ---------- Badge ----------
   A short label such as a role: <span class="badge">UX Designer</span>.
   Filled, small and with one square corner, so it is not mistaken for a button. */
.badge {
  display: inline-block;
  padding: var(--space-4) var(--space-8);         /* 4 + 16 + 4 = 24 high */
  border-radius: var(--radius-8) var(--radius-8) var(--radius-8) 0;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--font-size-12);
  font-weight: var(--weight-medium);
  line-height: var(--button-line-s);
  text-transform: uppercase;
}
@media (forced-colors: active) { .badge { outline: var(--line-1) solid CanvasText; } }

/* ---------- Table ----------
   Rows are grids, so columns can follow a page grid: set --table-columns on the
   table and add .col-2 or .col-3 to wider cells. Changing how a table displays
   can hide it from screen readers, so keep the role attributes (table,
   rowgroup, row, columnheader, cell).
   .cell-strong names the row, .cell-muted is secondary, .cell-aside moves to
   the top right when rows stack on narrow screens, .cell-links holds links. */
.table { --table-columns: var(--grid-columns); display: block; width: 100%; border-collapse: collapse; }
.table thead, .table tbody { display: block; }
.table tr {
  display: grid;
  grid-template-columns: repeat(var(--table-columns), minmax(0, 1fr));
  column-gap: var(--grid-gutter);
  align-items: baseline;
  padding-block: var(--space-16);
  border-bottom: var(--line-1) solid var(--color-divider);    /* solid, no fade */
}
.table th, .table td { display: block; min-width: 0; padding: 0; text-align: left; overflow-wrap: break-word; }
.table th { color: var(--color-text-muted); font-size: var(--text-overline); font-weight: var(--weight-medium); line-height: var(--leading-body); text-transform: uppercase; }
.table td { font-size: var(--text-body-small); font-weight: var(--weight-light); line-height: var(--leading-body); }
.table .cell-strong { font-weight: var(--weight-medium); }
.table .cell-muted { color: var(--color-text-muted); }
.table .cell-links { display: flex; flex-wrap: wrap; gap: var(--space-8) var(--space-24); }
/* .btn-link.btn-m in a cell: as tall as a line of text, and pulled back by its
   side padding so the words line up with the column */
.table .cell-links .btn-link { --button-pad-x: var(--space-8); padding-block: 0; margin-inline: calc(-1 * var(--button-pad-x)); align-items: baseline; }
.table .cell-links .btn-link .icon { align-self: center; }   /* the words set the baseline, not a leading icon */

@media (max-width: 760px) {
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .table tr { grid-template-columns: minmax(0, 1fr) auto; row-gap: var(--space-4); }
  .table td { grid-column: 1 / -1; }
  .table td:first-child { grid-column: 1; }
  .table .cell-aside { grid-column: 2; grid-row: 1; }
  .table .cell-links { margin-top: var(--space-8); }
}

/* ---------- Fade in on scroll (scripts/fade-in.js) ---------- */
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }
.fade-ready :is([data-appear], [data-sequence]) { opacity: 0; }
.fade-ready :is([data-appear], [data-sequence]).appear-in {
  animation: appear var(--appear-duration) ease-in-out calc(var(--appear-delay) + var(--step, 0) * var(--sequence-gap)) both;
}
/* data-from="right": also travels in a short way from the right as it fades */
@keyframes slide-from-right { from { translate: var(--slide-distance) 0; } to { translate: 0 0; } }
.fade-ready [data-appear][data-from="right"] { translate: var(--slide-distance) 0; }
.fade-ready [data-appear][data-from="right"].appear-in {
  --delay: calc(var(--appear-delay) + var(--step, 0) * var(--sequence-gap));
  animation: appear var(--appear-duration) ease-in-out var(--delay) both,
             slide-from-right var(--appear-duration) var(--reveal-ease) var(--delay) both;
}
@media print { .fade-ready :is([data-appear], [data-sequence]) { opacity: 1; translate: none; } }

/* ---------- Debug menu (scripts/debug-menu.js) ---------- */
.debug-menu {
  position: fixed; right: var(--space-16); bottom: var(--space-16); z-index: 90;
  display: grid; gap: var(--space-16);
  width: min(320px, calc(100vw - 2 * var(--space-16))); max-height: calc(100vh - 2 * var(--space-16)); overflow: auto;
  padding: var(--space-16);
  background: var(--color-surface); color: var(--color-text);
  font-size: var(--font-size-12); line-height: var(--leading-body);
  filter: var(--shadow-float);
}
.debug-menu[hidden] { display: none; }
.debug-menu .overline { font-size: var(--font-size-12); }
.debug-menu fieldset { display: grid; gap: var(--space-8); margin: 0; padding: 0; border: 0; }
.debug-menu legend { padding: 0; margin-bottom: var(--space-8); font-weight: var(--weight-bold); }
.debug-menu label { display: grid; grid-template-columns: 1fr auto; column-gap: var(--space-8); }
.debug-menu input[type="range"] { grid-column: 1 / -1; width: 100%; margin: 0; accent-color: var(--color-text); }
.debug-menu .debug-check { grid-template-columns: auto 1fr; align-items: center; }
.debug-menu input[type="checkbox"] { margin: 0; accent-color: var(--color-text); }
.debug-actions { display: flex; gap: var(--space-8); }

/* ---------- Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), minmax(0, 1fr));
  gap: var(--grid-gutter);
}
.col-1 { grid-column: span 1; }
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }

@media (max-width: 560px) {               /* wider spans stack */
  .col-2, .col-3, .col-4, .col-5 { grid-column: 1 / -1; }
}

/* ---------- Corners: pick a size, then which corners take it ---------- */
.radius-8  { --r: var(--radius-8); }
.radius-16 { --r: var(--radius-16); }
.radius-32 { --r: var(--radius-32); }
.radius-96 { --r: var(--radius-96); }
.radius-8, .radius-16, .radius-32, .radius-96 { border-radius: var(--r); }
.corners-diagonal { border-radius: var(--r) 0; }   /* top left + bottom right */
/* or keep chosen corners square */
.square-tl { border-top-left-radius: 0; }
.square-tr { border-top-right-radius: 0; }
.square-br { border-bottom-right-radius: 0; }
.square-bl { border-bottom-left-radius: 0; }
