/* tybenito.com design tokens. DESIGN_SYSTEM.md explains every value and where it's used.
   Pages load this file, then use the tokens and the .ds-* text styles instead of
   hardcoded sizes, colours or spacing. A value that isn't here doesn't belong on the site. */

:root {
  /* ── Families: serif for Title, H1 and H2; sans for everything else ── */
  --font-serif: 'Source Serif 4', Georgia, serif;
  --font-sans: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; /* data only: hex codes */
  --font-pixel: 'Press Start 2P', var(--font-sans);                          /* cat microcopy only */
  --font-tag: 'Pixelify Sans', var(--font-pixel);                                /* Perch name tags only */

  /* ── Weights ── */
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;

  /* ── Type scale (desktop; phone values below) ── */
  --title-size: 44px;  --title-line: 52px;
  --h2-size: 30px;     --h2-line: 38px;
  --h3-size: 22px;     --h3-line: 30px;
  --h4-size: 18px;     --h4-line: 26px;
  --body-size: 18px;   --body-leading: 1.6;   /* phones 1.65 */
  --body-line: calc(var(--body-size) * var(--body-leading));
  --small-size: 15px;  --small-line: 22px;
  --label-size: 13px;  --label-line: 16px;
  --serif-tracking: 0;         /* Title and H2 */
  --heading-tracking: 0;       /* H3 and H4 */
  --body-tracking: 0.01em;     /* body paragraphs; never negative at body or small sizes */
  --body-word: 0.04em;         /* body paragraphs */
  --label-tracking: 0.02em;
  --pixel-size: 8px;   --pixel-line: 12px;
  /* the runner game: score, messages and countdown, the play area and its close button */
  --game-size: 14px;   --game-small: 12px;  --game-line: 20px;  --game-big: 32px;
  --game-w: 720px;     --game-h: 196px;     --game-close: 40px;
  --hand-top: 46px;    --hand-bottom: 38px;  /* handwritten words in What I bring (Vara font size) */
  --measure: 68ch;     /* longest line for body text */

  /* ── Colour ── */
  --ink: #121212;            /* headings and body, 17.7:1 on --page */
  --ink-secondary: #6B655C;  /* Small, Label and inactive tabs, 5.4:1 on --page, 5.1:1 on --sunken */
  --ink-inverse: #FAF8F3;    /* text on --ink fills, 17.7:1 */
  --ink-inverse-secondary: #A3A19C; /* quieter text on dark fills, 7.4:1 on #16171A */
  --page: #FAF8F3;
  --raised: #FDFCF8;         /* cards on the page */
  --sunken: #F3F0E9;         /* wells, table stripes */
  --rule: rgba(18, 18, 18, 0.12);
  --accent: #C2552F;         /* site accent for fills and marks, never small text */
  --accent-text: #A8461F;    /* site accent as text or a link, 5.6:1 on --page */
  --fill-muted: #C9C3B8;     /* chart bars and keys that aren't the highlight, never text */
  /* The cat tree and the ledge (js/ledge.js): pale carpet and sisal, so the cats stay the focus */
  --carpet-top: #EFE6D8;     /* top faces */
  --carpet-front: #E4D8C4;   /* front faces, one step darker */
  --carpet-side: #DACBB3;    /* side faces and fabric flecks */
  --carpet-line: #CDBB9F;    /* the soft outline and the ledge's bottom edge */
  --carpet-hole: #B9A688;    /* inside the cubby, one tone past the outline */
  --rope-a: #D9C29A;         /* sisal stripes */
  --rope-b: #C9AE82;
  --rope-line: #A98F65;      /* the outline around a post */
  --cat-shadow: rgba(70, 50, 30, 0.16);  /* on the tree and every ledge */

  /* Each case study sets its own theme with [data-theme] on <body>. --theme-text is for
     links, data highlights and one accent per section; --theme-fill for shapes and fills. */
  --theme-text: var(--accent-text);
  --theme-fill: var(--accent);

  /* ── Spacing scale ── */
  --space-4: 4px;
  --space-8: 8px;
  --space-12: 12px;
  --space-16: 16px;
  --space-24: 24px;
  --space-32: 32px;
  --space-48: 48px;
  --space-64: 64px;
  --space-96: 96px;

  /* ── Case study cards ── home and /work */
  --cards-row-gap: 56px;   /* between rows of cards, off the scale */
  --cards-after: 40px;     /* the grid to See all work, off the scale */

  /* ── Case study layout ── repeated units, label pairs, tables, charts and media */
  --unit-gap: var(--space-48);      /* between repeated groups */
  --media-before: var(--space-32);  /* text to the figure, chart, table or card below it */
  --media-after: var(--space-48);   /* media to the next text block */
  --row-gap: var(--space-64);       /* between image-and-text rows */
  --media-caption: var(--space-12); /* media to its caption */
  --pair-label: var(--space-8);     /* a label to its text */
  --pair-gap: var(--space-24);      /* between label-and-text pairs */
  --cell-x: var(--space-16);        /* table cell padding */
  --cell-y: var(--space-16);
  --chart-label: var(--space-8);    /* a label to its bar */
  --chart-bar-gap: 20px;            /* between bars */
  --chart-caption: var(--space-16); /* above a chart's caption */

  /* ── Radius scale ── no pill shapes except icon-only buttons (DESIGN_SYSTEM.md, Shape) */
  --radius-control: 8px;   /* buttons, segmented controls, inputs */
  --radius-card: 16px;     /* cards and dialogs */
  --radius-round: 999px;   /* icon-only buttons only */
  --radius-nested-min: 4px;
  --icon-stroke: 1.4px;     /* every line icon, drawn at this weight on screen whatever its size (DESIGN_SYSTEM.md, Icons) */ /* the smallest a nested radius goes (DESIGN_SYSTEM.md, Shape) */
  --stroke-button: 1.5px;  /* the outline on Let's chat */
  --swatch-size: 40px;     /* a colour swatch for fur, markings and eyes */
  --tap-min: 44px;         /* the smallest tap area */
  --head-gap: calc(var(--u) * 2);  /* between counter heads: 6px, in whole units */
  --u: 3px;                /* /cat-tree's pixel unit, one sprite pixel; js/pixel-unit.js fits it to the screen */
  --swatch-tap: var(--tap-min);

  /* What the scale is used for. The space above a heading is always at least twice the
     space below it, so the heading belongs to what follows (Word's space before and after). */
  --section-gap: var(--space-96);   /* between sections; also the space above an H2 */
  --h2-after: var(--space-24);
  --h3-before: var(--space-48);
  --h3-after: var(--space-12);
  --h4-before: var(--space-32);
  --h4-after: var(--space-8);
  --title-after: var(--space-24);
  --paragraph-gap: var(--space-24);   /* phones 20px */

  /* ── Motion ── */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-quick: 160ms;
  --duration-base: 260ms;
  --duration-slow: 420ms;
  --duration-zoom: 400ms;  /* a case study card's image on hover */
  --duration-note: 250ms;  /* the "tap me" note coming in */
  --duration-preview: 250ms;  /* a case study card's video crossfading in over its thumbnail */
  --ease-preview: linear;
  --duration-enter: 500ms;   /* a case study card coming in on scroll */
  --ease-enter: cubic-bezier(0.2, 0.7, 0.2, 1);
  --enter-shift: 16px;
  --enter-stagger: 70ms;     /* between cards in the same row (js/card-enter.js) */     /* a straight crossfade, so the poster and video never both dim */
  --roll-ease: cubic-bezier(0.22, 1, 0.36, 1);  /* the rolling label only */
  --roll-duration: 400ms;
  --roll-stagger: 25ms;   /* per character */
  --roll-fade: 150ms;     /* the crossfade with reduced motion */
  --roll-nudge: 2px;      /* the arrow */
}

/* the pixel frame (DESIGN_SYSTEM.md, Shape): a one-unit ink outline with corners stepped in two
   pixels of the page's unit, and the same weight on all four edges. It's
   built from two clipped layers rather than a border, so the anchor itself stays unclipped
   and its focus ring can sit outside the box. Only on /cat-tree: its Let's chat and the Perch
   submit button (the name tags have their own). --px-corners uses --s, so it's declared
   where --s is set. */
.px-frame, [data-theme="pixel"] footer#contact [data-cta-body] { --s: var(--u); --px-corners: polygon(calc(var(--s) * 2) 0, calc(100% - var(--s) * 2) 0, calc(100% - var(--s) * 2) var(--s), calc(100% - var(--s)) var(--s), calc(100% - var(--s)) calc(var(--s) * 2), 100% calc(var(--s) * 2), 100% calc(100% - var(--s) * 2), calc(100% - var(--s)) calc(100% - var(--s) * 2), calc(100% - var(--s)) calc(100% - var(--s)), calc(100% - var(--s) * 2) calc(100% - var(--s)), calc(100% - var(--s) * 2) 100%, calc(var(--s) * 2) 100%, calc(var(--s) * 2) calc(100% - var(--s)), var(--s) calc(100% - var(--s)), var(--s) calc(100% - var(--s) * 2), 0 calc(100% - var(--s) * 2), 0 calc(var(--s) * 2), var(--s) calc(var(--s) * 2), var(--s) var(--s), calc(var(--s) * 2) var(--s)); }
.px-frame { position: relative; isolation: isolate; display: inline-flex; padding: var(--s); border: 0; background: none; color: var(--ink); font-family: var(--font-sans); font-size: var(--small-size); line-height: var(--small-line); font-weight: var(--weight-medium); white-space: nowrap; cursor: pointer; transition: transform var(--duration-quick) var(--ease); }
.px-frame::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--ink); clip-path: var(--px-corners); }
/* the box is slim, but the tap area reaches past 44px above and below it */
.px-frame::after { content: ''; position: absolute; inset: calc(var(--space-8) * -1) 0; }
.px-frame-fill { flex: 1; display: flex; align-items: center; justify-content: center; gap: var(--space-12); padding: var(--space-4) var(--space-12); background: var(--page); clip-path: var(--px-corners); }
.px-frame:hover .px-frame-fill, .px-frame:focus-visible .px-frame-fill { background: var(--ink); color: var(--ink-inverse); }
.px-frame:active { transform: translate3d(0, 1px, 0); }
.px-frame:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .px-frame { transition: none; } }

/* phones */
@media (max-width: 767px) {
  :root {
    --u: 2px;
    --game-h: 160px;
    --head-gap: calc(var(--u) * 3);
    --title-size: 34px;  --title-line: 40px;
    --h2-size: 26px;     --h2-line: 32px;
    --body-size: 17px;   --body-leading: 1.65;
    --paragraph-gap: 20px;
    --hand-top: 34px;    --hand-bottom: 28px;
  }
}

/* Case study themes */
[data-theme="zentra"]   { --theme-text: #6D28D9; --theme-fill: #7C2FF0; } /* 6.7:1 */
[data-theme="valorant"] { --theme-text: #C4213A; --theme-fill: #FF4655; } /* 5.5:1; the brand red fails as text */
[data-theme="chatime"]  { --theme-text: #612B87; --theme-fill: #612B87; } /* 9.0:1 */
[data-theme="biotomy"]  { --theme-text: #2F6B4D; --theme-fill: #3A7D5C; } /* 5.9:1; #3A7D5C fails on --sunken */

/* the line icons: one weight and one cap and join on screen, whatever each icon's size or viewBox.
   The Cat tree's pixel icons, the flowers and the hand-drawn hint arrow are drawn, not line icons. */
:is(.link-arrow, .roll-arrow, .nv-i-open, .nv-i-close, [data-chevron], .cs-pr-arrow svg, .mag-btn svg, [aria-label="Back to top"] svg, button:is([aria-label="Previous"], [aria-label="Next"], [aria-label="Previous page"], [aria-label="Next page"]) svg) :is(path, line, polyline) {
  stroke-width: var(--icon-stroke);
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* headings balance their lines by element as well as by class, so a heading without a ds- class still does */
h1, h2, h3, .ds-card-title { text-wrap: balance; }

/* ── Text styles ── one class per style, so a page never sets font values itself */
.ds-title, .ds-h2, .ds-card-title {
  font-family: var(--font-serif);
  font-weight: var(--weight-regular);
  color: var(--ink);
  letter-spacing: var(--serif-tracking);
  text-wrap: balance;
}
.ds-title { font-size: var(--title-size); line-height: var(--title-line); }
.ds-h2    { font-size: var(--h2-size);    line-height: var(--h2-line); }
.ds-card-title { font-size: var(--h3-size); line-height: var(--h3-line); } /* serif at H3 size, case study cards only */
.ds-h3, .ds-h4 {
  font-family: var(--font-sans);
  font-weight: var(--weight-semibold);
  color: var(--ink);
  letter-spacing: var(--heading-tracking);
  text-wrap: balance;
}
.ds-h3 { font-size: var(--h3-size); line-height: var(--h3-line); }
.ds-h4 { font-size: var(--h4-size); line-height: var(--h4-line); }
.ds-body {
  font-family: var(--font-sans);
  font-weight: var(--weight-regular);
  font-size: var(--body-size);
  line-height: var(--body-line);
  letter-spacing: var(--body-tracking);
  word-spacing: var(--body-word);
  color: var(--ink);
  max-width: var(--measure);
  text-wrap: pretty;
}
.ds-body + .ds-body { margin-top: var(--paragraph-gap); }
.ds-small {
  font-family: var(--font-sans);
  font-weight: var(--weight-regular);
  font-size: var(--small-size);
  line-height: var(--small-line);
  color: var(--ink-secondary);
}
/* Label: the hero meta row, figure captions and data sources. Never above a heading. */
.ds-label {
  font-family: var(--font-sans);
  font-weight: var(--weight-medium);
  font-size: var(--label-size);
  line-height: var(--label-line);
  letter-spacing: var(--label-tracking);
  color: var(--ink-secondary);
}
/* Figure: a number shown as data, like "3/4" or "24". Title size in the theme colour. */
.ds-figure {
  font-family: var(--font-serif);
  font-weight: var(--weight-regular);
  font-size: var(--title-size);
  line-height: var(--title-line);
  letter-spacing: var(--serif-tracking);
  color: var(--theme-text);
  font-variant-numeric: tabular-nums;
}
/* numbers that line up or change in place: years, case study dates and the runner's score and countdown.
   Metrics get it from .ds-figure. The Cat tree's counters keep the pixel theme as it is. */
.pg-card-meta, [data-exp-year], .cs-meta dd, .pg-game-hud, .pg-game-big { font-variant-numeric: tabular-nums; }
.ds-data { font-family: var(--font-mono); font-size: var(--small-size); line-height: var(--small-line); }
.ds-link { color: var(--theme-text); }
/* Text links: the only hover is a colour, a heavier underline and the arrow moving 2px. The
   !important stops a page's own button hover (.h7 and the like) ever reaching one of these. */
.ds-link, .pg-button-ghost, .cs-text-link { text-decoration-line: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.ds-link:is(:hover, :focus-visible), .pg-button-ghost:is(:hover, :focus-visible), .cs-text-link:is(:hover, :focus-visible) { background: none !important; box-shadow: none !important; color: var(--theme-text) !important; text-decoration-thickness: 2px; transform: none !important; }
.link-arrow { display: inline-block; flex: none; transition: transform var(--duration-quick) var(--ease); }
a:is(:hover, :focus-visible) > .link-arrow { transform: translate3d(2px, 0, 0); }
@media (prefers-reduced-motion: reduce) { .link-arrow { transition: none; } a:is(:hover, :focus-visible) > .link-arrow { transform: none; } }

/* ── Flow: a text column with Word-style spacing and one shared left edge ── */
.ds-flow { max-width: var(--measure); text-align: left; }
.ds-flow > * { margin-top: 0; margin-bottom: 0; }
.ds-flow > * + * { margin-top: var(--paragraph-gap); }
.ds-flow > .ds-h2, .ds-flow > h2 { margin-top: var(--section-gap); }
.ds-flow > .ds-h3, .ds-flow > h3 { margin-top: var(--h3-before); }
.ds-flow > .ds-h4, .ds-flow > h4 { margin-top: var(--h4-before); }
.ds-flow > :first-child { margin-top: 0; }
.ds-flow > .ds-title + * { margin-top: var(--title-after); }
.ds-flow > .ds-h2 + *, .ds-flow > h2 + * { margin-top: var(--h2-after); }
.ds-flow > .ds-h3 + *, .ds-flow > h3 + * { margin-top: var(--h3-after); }
.ds-flow > .ds-h4 + *, .ds-flow > h4 + * { margin-top: var(--h4-after); }
/* a heading right under another heading gets twice its own space after, so both keep the 2:1 rule */
.ds-flow > :is(.ds-h3, h3) + :is(.ds-h4, h4) { margin-top: var(--space-16); }
.ds-flow > :is(.ds-h2, h2) + :is(.ds-h3, h3) { margin-top: var(--space-32); }

/* Anchor targets clear the sticky nav when jumped to from the table of contents */
:where(h2[id], .ds-h2[id]) { scroll-margin-top: var(--toc-offset, var(--space-96)); }

/* Scroll reveal (js/reveal.js). Only .js can hide anything, and never in print or with reduced motion. */
@keyframes reveal-in { from { opacity: 0; transform: translate3d(0, var(--space-12), 0); } to { opacity: 1; transform: none; } }
@media screen and (prefers-reduced-motion: no-preference) {
  .js [data-reveal="pending"] { opacity: 0; transform: translate3d(0, var(--space-12), 0); }
  .js [data-reveal="in"] { animation: reveal-in var(--duration-slow) var(--ease) both; }
}

/* The rolling label (js/rolling-label.js, DESIGN_SYSTEM.md, Shape): Let's chat in the nav and the
   contact form's submit only. Two matching rows in a one-line window, each character moving up
   one line in turn. Nothing here changes the button's box, in any state. */
.roll-view { position: relative; display: block; height: var(--small-line); overflow: hidden; }
.roll-row { display: block; white-space: nowrap; }
.roll-row + .roll-row { position: absolute; top: 100%; left: 0; }
.roll-ch { display: inline-block; transition: transform var(--roll-duration) var(--roll-ease) calc(var(--i) * var(--roll-stagger)); }
.roll-arrow { flex: none; margin-left: var(--space-4); transition: transform var(--roll-duration) var(--roll-ease); }
.roll:focus-visible .roll-ch, .roll.is-rolling .roll-ch { transform: translate3d(0, calc(var(--small-line) * -1), 0); }
.roll:focus-visible .roll-arrow, .roll.is-rolling .roll-arrow { transform: translate3d(var(--roll-nudge), 0, 0); }
@media (hover: hover) {
  .roll:hover .roll-ch { transform: translate3d(0, calc(var(--small-line) * -1), 0); }
  .roll:hover .roll-arrow { transform: translate3d(var(--roll-nudge), 0, 0); }
}
.roll.is-settling .roll-ch, .roll.is-settling .roll-arrow, .roll.is-settling .roll-row { transition: none; }
@media (max-width: 767px) { .roll-arrow { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .roll .roll-ch, .roll .roll-arrow, .roll:hover .roll-ch, .roll:hover .roll-arrow, .roll:focus-visible .roll-ch, .roll:focus-visible .roll-arrow, .roll.is-rolling .roll-ch, .roll.is-rolling .roll-arrow { transform: none; transition: none; }
  .roll-row { transition: opacity var(--roll-fade) linear; }
  .roll-row + .roll-row { top: 0; opacity: 0; }
  .roll:hover .roll-row, .roll:focus-visible .roll-row, .roll.is-rolling .roll-row { opacity: 0; }
  .roll:hover .roll-row + .roll-row, .roll:focus-visible .roll-row + .roll-row, .roll.is-rolling .roll-row + .roll-row { opacity: 1; }
}

/* The magnetic link (js/magnetic.js, DESIGN_SYSTEM.md, Shape): case study calls to action only.
   .mag holds the button's place and never moves; ::before is its hit area, 16px past the button
   on every side, taking no layout. Only .mag-btn moves, and its label and arrow a little more. */
.mag[data-study="zentra"] { --mag-theme: #7C2FF0; }
.mag[data-study="valorant"] { --mag-theme: #FF4655; }
.mag[data-study="chatime"] { --mag-theme: #612B87; }
.mag[data-study="biotomy"] { --mag-theme: #3A7D5C; }
.mag { position: relative; display: inline-flex; color: var(--ink); }
.mag::before { content: ''; position: absolute; inset: calc(var(--space-16) * -1); }
.mag-btn { position: relative; display: inline-flex; align-items: center; gap: var(--space-12); min-height: var(--space-48); padding: 0 var(--space-24); border-radius: var(--radius-control); background: var(--ink); box-shadow: inset 0 0 0 var(--stroke-button) var(--ink); color: var(--ink-inverse); font-family: var(--font-sans); font-size: var(--small-size); line-height: var(--small-line); font-weight: var(--weight-medium); white-space: nowrap; }
.mag-label, .mag-arrow { display: block; flex: none; }
.mag-btn, .mag-label, .mag-arrow { transition: transform var(--duration-base) var(--ease); }
.mag.is-live .mag-btn, .mag.is-live .mag-label, .mag.is-live .mag-arrow { transition: none; }
/* the outline only: the arrow stays cream, because Chatime's purple is 1.97:1 on ink */
@media (hover: hover) {
  .mag:hover .mag-btn { box-shadow: inset 0 0 0 var(--stroke-button) var(--mag-theme); }
}
/* keyboard: on Next case study the button is the link. On a card the whole card is, with its own ring (pages.css). */
a.mag:focus-visible { outline: none; }
a.mag:focus-visible .mag-btn { outline: 2px solid var(--ink); outline-offset: 2px; box-shadow: inset 0 0 0 var(--stroke-button) var(--mag-theme); transform: translate3d(0, -2px, 0) !important; }
a.mag:focus-visible .mag-label, a.mag:focus-visible .mag-arrow { transform: none !important; }
.mag.is-leaning .mag-btn { transform: translate3d(0, -2px, 0); }
.mag.is-leaning .mag-arrow { transform: translate3d(2px, -2px, 0); }
@media (prefers-reduced-motion: reduce) {
  .mag-btn, .mag-label, .mag-arrow { transform: none !important; transition: none; }
}
