/* ==========================================================================
   Design tokens — pulled from Figma variables (file "Nuno website V6")
   Collections: primitives, responsive, themes. "utility" intentionally
   excluded. Regenerate by hand if the Figma source changes — no live sync.
   ========================================================================== */

/* --- Fonts ----------------------------------------------------------------
   Local files (assets/fonts/) - licensed, not loaded from a CDN. Inter and
   Plex Mono are also preloaded (snippets/font-preload.php) - change them
   there too.

   Inter is the variable version (weight 100-900, plus optical size, which
   the browser sets from the size the text is drawn at), cut down to Latin
   characters - English, Portuguese and the other Western European
   languages, with every punctuation mark and OpenType feature kept. The
   full file is InterVariable.ttf, used by nothing; cut it again from that
   if a character is ever missing. ------------------------- */
@font-face {
  font-family: "Inter";
  src: url("../fonts/InterVariable-Latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/IBMPlexMono-Regular.woff2") format("woff2"),
       url("../fonts/IBMPlexMono-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Not wired to --font-family-base or any type style yet - available under
   --font-family-neue-haas-unica for whatever uses it next. No Bold weight
   was supplied, only these three. */
@font-face {
  font-family: "Neue Haas Unica";
  src: url("../fonts/NeueHaasUnica-Light.woff2") format("woff2"),
       url("../fonts/NeueHaasUnica-Light.woff") format("woff");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Neue Haas Unica";
  src: url("../fonts/NeueHaasUnica-Regular.woff2") format("woff2"),
       url("../fonts/NeueHaasUnica-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Neue Haas Unica";
  src: url("../fonts/NeueHaasUnica-Medium.woff2") format("woff2"),
       url("../fonts/NeueHaasUnica-Medium.woff") format("woff");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* --- Primitives ---------------------------------------------------------- */
:root {
  --radius: 3px;
  /* How long body's background/text fade when data-theme changes - a page
     load, or a Theme Switch block's threshold crossing mid-scroll. */
  --theme-transition-duration: 1s;

  /* Grey scale (white -> black) */
  --grey-00: #ffffff;
  --grey-25: #f8f8f8;
  --grey-50: #f1f1f1;
  --grey-75: #eaeaea;
  --grey-100: #e3e3e3;
  --grey-125: #dddddd;
  --grey-150: #d5d5d5;
  --grey-175: #cfcfcf;
  --grey-200: #c8c8c8;
  --grey-225: #c1c1c1;
  --grey-250: #bbbbbb;
  --grey-275: #b4b4b4;
  --grey-300: #adadad;
  --grey-325: #a7a7a7;
  --grey-350: #a0a0a0;
  --grey-375: #999999;
  --grey-400: #939393;
  --grey-425: #8d8d8d;
  --grey-450: #868686;
  --grey-475: #808080;
  --grey-500: #7a7a7a;
  --grey-525: #737373;
  --grey-550: #6d6d6d;
  --grey-575: #666666;
  --grey-600: #606060;
  --grey-625: #5a5a5a;
  --grey-650: #545454;
  --grey-675: #4e4e4e;
  --grey-700: #484848;
  --grey-725: #414141;
  --grey-750: #3b3b3b;
  --grey-775: #353535;
  --grey-800: #2f2f2f;
  --grey-825: #292929;
  --grey-850: #232323;
  --grey-875: #1d1d1d;
  --grey-900: #171717;
  --grey-925: #121212;
  --grey-950: #0c0c0c;
  --grey-975: #060606;
  --grey-1000: #000000;

  /* Typography primitives */
  --font-family-base: "Inter", system-ui, -apple-system, sans-serif;
  --font-family-mono: "IBM Plex Mono", ui-monospace, monospace;
  --font-family-base-2: "Neue Haas Unica", system-ui, -apple-system, sans-serif;
  /* Weight names as stored in Figma map to these CSS values - not given
     numerically in the variables themselves, confirm against the actual
     font files if this assumption is wrong. */
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-bold: 700;
}

/* --- Responsive ------------------------------------------------------------
   Fluid, not tiered: margin/gutter/spacing/type scale continuously with the
   viewport via clamp(min, slope·vw + offset, max) instead of jumping at
   fixed breakpoints - this is what actually fixes the "container width
   locks to a stale reference size mid-range" bug the old 4-tier system had.

   Every clamp() below interpolates between the same two reference points:
   375px viewport (the "min" value) and 1440px viewport (the "max" value) -
   both are real values validated in Figma. To change either end in future,
   give both the new (viewport, value) pair and the formula gets recomputed -
   editing just the min or max number alone will NOT give the right curve,
   since the middle term's slope is derived from both endpoints together.

   Grid column count is NOT part of this - it's a flat, constant 12 at every
   size (see the Column count note below). --------------------------------- */
:root {
  /* Slides atom. Durations rather than a speed: there's nothing to measure
     here - every item occupies the same box, so the same numbers give the
     same pace whatever the contents. One full cycle per item is hold + duration.

     The hold is the DEFAULT only - each Slides atom carries its own,
     from a slider in the panel, published as a --slides-hold on its own
     frame. This value is what an atom saved before that slider existed
     falls back to, and what the JS falls back to if the property is ever
     unreadable. The duration is global: it's the character of the dissolve
     rather than the pace of the sequence.

     The CSS transition and the JS that advances the layers both read these,
     so the two stay in step. */
  --slides-duration: 0.3s;
  --slides-hold: 4s;

  /* How far the incoming layer travels, and what it starts scaled to, for
     the Swipe and Scale transitions. Only ever the INCOMING layer moves -
     see the note in style.css.

     The shift is a FRACTION of the layer's own size, not a length: it's
     multiplied out to a percentage translate, so it reads the same in a
     200px column as in a full-width block, where a pixel value would be
     overbearing on one and invisible on the other. Unitless because the
     same number also has to produce the compensation zoom that stops the
     outgoing layer showing at the trailing edge (see style.css) - and
     calc() can add a number to 1, but not a percentage.

     Both are deliberately small: the movement is happening underneath a
     dissolve, and anything bigger fights it rather than adding to it. */
  --slides-shift: 0.05;
  --slides-zoom: 1.1;

  /* Column count stays 12 at every size (mobile included) so that a
     block's own grid-column placement (Text's left/right alignment,
     Omni's swap, etc.) never needs remapping between a
     mobile-specific grid and a desktop one - it's one grid, always. */
  --grid-columns: 12;

  /* A Text block's width in grid columns, unless the block has its own
     (its Width in the Panel, left on Default). Change it here and every
     Text block on Default follows. Desktop widens as the screen narrows:
     8 here (768px up), then 7, 6 and 5 at the breakpoints just after
     this :root block. Phones (below 768px) take -phone. The Width fields'
     help text in blueprints/blocks/text.yml names the numbers too. */
  --text-block-columns: 8;
  --text-block-columns-phone: 12;

  /* Overall content-width ceiling - the only non-fluid size in this section.
     Prevents the container from stretching indefinitely on very wide
     screens; margin is added on top of this in .container's max-width. */
  --container-max: 1800px;

  /* Spacing scale - xxs is fluid 375px -> 1440px; xs/sm are fixed at every
     breakpoint. Kept together so --spacing-* reads as one group rather
     than being split across the fluid/constant sections. */
  --spacing-xs: 2px;
  --spacing-sm: 16px;
  --spacing-md: 40px;

  /* Spacing/grid - fluid 375px -> 1440px */
  --grid-margin: clamp(12px, 2.63vw + 2.14px, 40px);       /* 12px -> 40px */
  --grid-gutter: clamp(12px, 1.13vw + 7.77px, 24px);       /* 12px -> 24px */

   
  --padding-project-block-grid-gutter: var(--grid-gutter);
  /* A block's inner padding, 30px at 375 up to its own size at 1880 - where
     the page stops widening (--container-max plus two 40px margins), so it
     grows for as long as the page does. Not a straight line between the
     two: a straight line takes up a share of the block that jumps on small
     screens and then stalls. Each is instead a curve along which that share
     changes evenly from 375 to 1880 - a few straight pieces, max() where the
     curve bends up, min() where it bends down. sm can't: an even share would
     take it past 50px midway, so it rises to ~46px by ~700 and eases into
     50px at 1880. Share = padding / (width - 2 x grid-margin). Change
     --container-max and change the 1880 here. */
  --padding-project-block-sm: clamp(30px, min(4.93vw + 11.51px, 0.36vw + 43.23px), 50px);                          /* 30px -> 50px */
  --padding-project-block-md: clamp(30px, min(6.46vw + 5.79px, 4.57vw + 22.36px, 2.93vw + 44.86px), 100px);        /* 30px -> 100px */
  --padding-project-block-lg: clamp(30px, max(9.51vw - 5.64px, 11.12vw - 19.84px, 13.26vw - 49.23px), 200px);     /* 30px -> 200px */
  --padding-project-block-xl: clamp(30px, max(12.56vw - 17.08px, 17.68vw - 62.04px, 23.58vw - 143.33px), 300px);  /* 30px -> 300px */
  /* A Media atom's padding inside a Marquee item, which is far smaller than
     a column: a share of the item's shorter side (cqmin), so it scales with
     the item. Roughly the share the sizes above take of a half-page atom. */
  --padding-marquee-atom-sm: 7cqmin;
  --padding-marquee-atom-md: 14cqmin;
  --padding-marquee-atom-lg: 24cqmin;
  --padding-marquee-atom-xl: 32cqmin;
   
  --gap-project-sm: clamp(40px, 5.63vw + 18.87px, 100px);   /* 40px -> 100px */
  --gap-project-md: clamp(80px, 6.57vw + 55.35px, 150px);   /* 80px -> 150px */
  --gap-project-lg: clamp(150px, 18.78vw + 79.58px, 350px); /* 150px -> 350px */
  
  /* Masonry adds a column each time its own width can afford another this
     wide. Not fluid: it's a threshold, and the column count it produces is
     a whole number anyway. Raise it to add columns more reluctantly. */
  --masonry-column-min: 200px;
  /* The same threshold for the Media Grid atom, which adds a column on the
     same terms. Its own token rather than a shared one: an atom sits inside
     a layout column and Masonry spans the page, so the width at which each
     should break into another column can move independently. */
  --media-grid-column-min: 200px;
  
  --gap-header-top: clamp(200px, 9.39vw + 164.79px, 300px);            /* 200px -> 300px */
  --gap-header-bottom-home: clamp(100px, 9.39vw + 64.79px, 200px);     /* 100px -> 200px */
  --gap-header-bottom-project: clamp(50px, 14.08vw - 2.82px, 200px);   /* 50px -> 200px */
  --gap-next-project: clamp(250px, 32.86vw + 126.76px, 600px);         /* 250px -> 600px */
  --gap-header-stack: clamp(60px, 13.15vw + 10.7px, 200px);            /* 60px -> 200px */
  --gap-intro-kpi: 70px;
  --gap-kpi: 24px;
  /* Between an eyebrow and the text under it: a case study's KPI label and
     its value, and an About list's eyebrow and its items. Separate so each
     can be tuned on its own. */
  --eyebrow-gap-kpi: 2px;
  --eyebrow-gap-about: 16px;
  /* The line height of About's lists, apart from other body text. Starts at
     the body style's own (--type-lh-body). */
  --about-list-line-height: 1.6;

  /* Links in body text (text blocks and atoms, intros, About's lists): an
     underline under the text's own colour. The hover colour is with the
     theme colours below. */
  --link-underline-thickness: 0.5px;
  --link-underline-offset: 0.25em;
  --link-hover-duration: 100ms;

  /* Nav labels - the swap to their hover titles from the Site. */
  --nav-swap-duration: 300ms;
  --nav-swap-ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* Scroll reveal (reveal.js) - how far things rise, how long they take, and
     the wait between items entering together. */
  --reveal-distance: 8vh;
  --reveal-distance-about: min(8vh, 40px); /* About's text, a line or a name at a time - the full rise is too much for pieces that small. */
  --reveal-duration: 1500ms;
  --reveal-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --reveal-stagger: 200ms;
  --reveal-load-delay: 300ms; /* The blank moment before the first screen starts. */
  --reveal-load-duration: 2000ms; /* The first screen's own --reveal-duration. */
  --reveal-line-stagger: 50ms; /* About's intro, one line after another. */
  --reveal-waterfall-stagger: 50ms; /* About's lists, one name after another. */
  --reveal-letter-stagger: 15ms; /* The home title, one letter after another. */

  /* The Work menu (work-menu.js) - its fade and stagger, the gap between rows,
     and its columns. */
  --work-menu-fade: 200ms;
  --work-menu-stagger: 60ms; /* From one card to the next, in list order. */
  --work-menu-hover-duration: 0.3s; /* A card's overlay fading in. */
  --gap-work-menu-row: 40px;
  /* As many columns as fit at the card width below, never fewer than the
     min or more than the max - so a column comes or goes as soon as there's
     room, at whatever width, rather than at fixed breakpoints. */
  --work-menu-card-min: 240px; /* The narrowest a card gets before a column drops. */
  --work-menu-columns-min: 2;
  --work-menu-columns-max: 6;

  /* The crossfade from one page to the next. */
  --page-fade-duration: 400ms;

  /* How far the rest of a case study fades back once the Next project
     module swaps the theme. */
  --next-project-dim: 0.1;
  
  --gap-home-project-gap: clamp(100px, 28.17vw - 5.63px, 400px); /* 100px -> 400px */
  /* Desktop only - the staggered home project grid's downward push on every
     other card. Mobile drops the stagger entirely, so there's no smaller
     viewport value to fade this towards. */
  --gap-home-project-offset: 600px;

  /* Typography - fluid between two screen widths. Edit the plain numbers
     (px, no unit): each size grows from its min at --type-fluid-from to
     its max at --type-fluid-to, and stays put outside that range. */
  --type-fluid-from: 375;
  --type-fluid-to: 1440;

  /* Each style's settings, as set in the Type panel (dev only) - its
     "Apply to CSS" writes Inter's and Tag's straight into these, so edit
     them here or there. Sizes are plain px numbers. */
  --in-heading-size-min: 22;
  --in-heading-size-max: 26;
  --in-heading-weight: 450;
  --in-heading-line-height: 1.25;
  --in-heading-letter-spacing: -0.015em;

  --in-body-size-min: 15;
  --in-body-size-max: 16;
  --in-body-weight: 350;
  --in-body-line-height: 1.5;
  --in-body-letter-spacing: 0em;

  --in-caption-size-min: 13;
  --in-caption-size-max: 13;
  --in-caption-weight: 300;
  --in-caption-line-height: 1.55;
  --in-caption-letter-spacing: 0em;

  /* Tags, labels and eyebrows (body-sm, IBM Plex Mono, one weight). */
  --mono-size-min: 13;
  --mono-size-max: 13;
  --mono-line-height: 1.55;
  --mono-letter-spacing: 0em;

  --type-heading-min: var(--in-heading-size-min);  --type-heading-max: var(--in-heading-size-max);
  --type-body-min: var(--in-body-size-min);        --type-body-max: var(--in-body-size-max);
  --type-body-sm-min: var(--mono-size-min);        --type-body-sm-max: var(--mono-size-max);
  --type-caption-min: var(--in-caption-size-min);  --type-caption-max: var(--in-caption-size-max);

  --type-weight-heading: var(--in-heading-weight);
  --type-weight-body: var(--in-body-weight);
  --type-weight-caption: var(--in-caption-weight);

  /* Worked out from the numbers above - no need to touch. rem + vw, so it
     still respects the user's browser font-size/zoom setting (vw alone
     would ignore it): px / 16 = rem. */
  --type-fs-heading: clamp(
    calc(var(--type-heading-min) / 16 * 1rem),
    calc((var(--type-heading-min) - var(--type-fluid-from) * (var(--type-heading-max) - var(--type-heading-min)) / (var(--type-fluid-to) - var(--type-fluid-from))) / 16 * 1rem
      + (var(--type-heading-max) - var(--type-heading-min)) / (var(--type-fluid-to) - var(--type-fluid-from)) * 100vw),
    calc(var(--type-heading-max) / 16 * 1rem)
  );
  --type-fs-body: clamp(
    calc(var(--type-body-min) / 16 * 1rem),
    calc((var(--type-body-min) - var(--type-fluid-from) * (var(--type-body-max) - var(--type-body-min)) / (var(--type-fluid-to) - var(--type-fluid-from))) / 16 * 1rem
      + (var(--type-body-max) - var(--type-body-min)) / (var(--type-fluid-to) - var(--type-fluid-from)) * 100vw),
    calc(var(--type-body-max) / 16 * 1rem)
  );
  --type-fs-body-sm: clamp(
    calc(var(--type-body-sm-min) / 16 * 1rem),
    calc((var(--type-body-sm-min) - var(--type-fluid-from) * (var(--type-body-sm-max) - var(--type-body-sm-min)) / (var(--type-fluid-to) - var(--type-fluid-from))) / 16 * 1rem
      + (var(--type-body-sm-max) - var(--type-body-sm-min)) / (var(--type-fluid-to) - var(--type-fluid-from)) * 100vw),
    calc(var(--type-body-sm-max) / 16 * 1rem)
  );
  /* Captions under atoms and blocks - their own size, apart from tags
     (body-sm), though they start the same. */
  --type-fs-caption: clamp(
    calc(var(--type-caption-min) / 16 * 1rem),
    calc((var(--type-caption-min) - var(--type-fluid-from) * (var(--type-caption-max) - var(--type-caption-min)) / (var(--type-fluid-to) - var(--type-fluid-from))) / 16 * 1rem
      + (var(--type-caption-max) - var(--type-caption-min)) / (var(--type-fluid-to) - var(--type-fluid-from)) * 100vw),
    calc(var(--type-caption-max) / 16 * 1rem)
  );
}

/* The Text block's default width at each breakpoint (see
   --text-block-columns above). */
@media (min-width: 1024px) {
  :root { --text-block-columns: 7; }
}

@media (min-width: 1200px) {
  :root { --text-block-columns: 6; }
}

@media (min-width: 1440px) {
  :root { --text-block-columns: 5; }
}

/* --- Type styles (line-height / letter-spacing / paragraph spacing) ------
   From Figma's Text Styles (heading/body/body-sm), not
   Variables — only font-size is variable-bound there, so these are fixed
   across every breakpoint. heading/body use percentage line-height
   and letter-spacing in Figma, reproduced here as unitless line-height and
   em-based letter-spacing so both keep scaling with font-size automatically.
   body-sm uses fixed-pixel line-height in Figma, kept as-is.

   Paragraph spacing (ps) is em for the same reason: em resolves against the
   element's own font-size, so one value per style stays proportional at
   every viewport without needing a clamp of its own, and a 48px heading and
   22px body each get spacing suited to their size. rem would give both the
   same gap regardless of how big the type is, and px would sit still while
   the type around it scaled. Each is roughly half that style's line-height,
   which is the usual starting point - tune per style from here. ---------- */
:root {
  --type-lh-heading: var(--in-heading-line-height);
  --type-ps-heading: 0.6em;
  --type-ls-heading: var(--in-heading-letter-spacing);

  --type-lh-body: var(--in-body-line-height);
  --type-ps-body: 0.7em;
  --type-ls-body: var(--in-body-letter-spacing);

  --type-lh-body-sm: var(--mono-line-height);
  --type-ps-body-sm: 0.75em;
  --type-ls-body-sm: var(--mono-letter-spacing);

  --type-lh-caption: var(--in-caption-line-height);
  --type-ls-caption: var(--in-caption-letter-spacing);
}

/* --- Themes ----------------------------------------------------------------
   Not tied to OS/browser preference - light and dark are deliberate,
   authored styles applied wherever the design calls for them (a whole
   page, a section, a scroll-triggered wrapper). Light is the default on
   :root; add data-theme="dark" to any element to switch its subtree, and
   data-theme="light" to switch back within a dark ancestor. ------------- */
:root,
[data-theme="light"] {
  --text-primary: var(--grey-1000);
  --text-primary-inverse: var(--grey-00);
  --text-secondary: color-mix(in srgb, var(--grey-1000) 50%, transparent);
  /* A body-text link on hover (style.css). Set per theme so a block with its
     own theme gets its own. */
  --link-hover-color: var(--text-secondary);
  --text-secondary-inverse: color-mix(in srgb, var(--grey-00) 50%, transparent);
  --text-tertiary: color-mix(in srgb, var(--grey-1000) 35%, transparent);
  --text-tertiary-inverse: color-mix(in srgb, var(--grey-00) 35%, transparent);
  --text-all-white: var(--grey-00);
  --text-all-black: var(--grey-1000);

  --button-primary: var(--grey-1000);
  --button-primary-hover: color-mix(in srgb, var(--grey-1000) 75%, transparent);
  --button-secondary: color-mix(in srgb, var(--grey-1000) 50%, transparent);
  --button-secondary-hover: color-mix(in srgb, var(--grey-1000) 75%, transparent);

  --ui-bg: var(--grey-00);
  --ui-bg-inverse: var(--grey-1000);
  --ui-bg-layer-1: var(--grey-50);
  --ui-bg-layer-2: var(--grey-100);
  --ui-border: color-mix(in srgb, var(--grey-1000) 15%, transparent);
  /* Frosted buttons laid over media (the Carousel's arrows, a refused
     video's play button): a dark tint here, a light one in dark sections,
     so the disc stands out from what's around it either way. */
  --ui-glass: rgb(20 20 22 / 0.2);
  --ui-glass-hover: rgb(20 20 22 / 0.35);
}

[data-theme="dark"] {
  --text-primary: var(--grey-00);
  --text-primary-inverse: var(--grey-1000);
  --text-secondary: color-mix(in srgb, var(--grey-00) 50%, transparent);
  --link-hover-color: var(--text-secondary);
  --text-secondary-inverse: color-mix(in srgb, var(--grey-1000) 50%, transparent);
  --text-tertiary: color-mix(in srgb, var(--grey-00) 30%, transparent);
  --text-tertiary-inverse: color-mix(in srgb, var(--grey-1000) 30%, transparent);
  /* text-all-white / text-all-black intentionally unchanged - fixed in Figma too */

  --button-primary: var(--grey-00);
  --button-primary-hover: color-mix(in srgb, var(--grey-00) 75%, transparent);
  --button-secondary: color-mix(in srgb, var(--grey-00) 50%, transparent);
  --button-secondary-hover: color-mix(in srgb, var(--grey-00) 75%, transparent);

  --ui-bg: var(--grey-1000);
  --ui-bg-inverse: var(--grey-00);
  --ui-bg-layer-1: var(--grey-950);
  --ui-bg-layer-2: var(--grey-850);
  --ui-border: color-mix(in srgb, var(--grey-00) 15%, transparent);
  --ui-glass: rgb(255 255 255 / 0.05);
  --ui-glass-hover: rgb(255 255 255 / 0.1);
}
