/* ============================================================
   Danny Seabra — Portfolio
   Shared design system
   ============================================================ */

/* ---------- Fonts ----------
   Instrument Sans, self-hosted (variable 400–700, normal + italic, latin + latin-ext).
   Vendored from Google Fonts v4 so the site makes no runtime CDN calls. */
@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../assets/fonts/instrument-sans/instrument-sans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../assets/fonts/instrument-sans/instrument-sans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Instrument Sans';
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url('../assets/fonts/instrument-sans/instrument-sans-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Instrument Sans';
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url('../assets/fonts/instrument-sans/instrument-sans-italic-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { min-height: 100%; }
img, video, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* ============================================================
   TOKENS
   ============================================================ */
:root {
  /* type families — Instrument Sans everywhere; --font-mono is a legacy alias
     (the [data-type] switching system is retired) */
  --font-display: 'Instrument Sans', -apple-system, sans-serif;
  --font-body: 'Instrument Sans', -apple-system, sans-serif;
  --font-mono: 'Instrument Sans', -apple-system, sans-serif;

  /* accent / primary — actions & functional states only (customisation retired).
     Primary colour is ink/near-black (was indigo #586597) — see DESIGN.md Decisions Log. */
  --accent: #11151A;
  --accent-ink: #F9FAFB;

  /* committed-dark surfaces (theme-independent): physical device bezels and the
     immersive §06 image field read as real hardware, so they stay dark in both
     themes. See DESIGN.md Color + Decisions Log 2026-07-13. */
  --ink-deep: #0A0D12;      /* deepest surface: device bezels, field ground */
  --on-ink-deep: #E9EDF1;   /* light text / hairlines on --ink-deep */

  /* case-brand surfaces (theme-independent): brand-coloured cover panels on case
     studies. MAG teal pair = Manchester Airport app cover gradient. See DESIGN.md. */
  --mag-teal: #0F6E7A;
  --mag-navy: #114C63;

  /* spacing scale */
  --gap: clamp(1rem, 2.4vw, 1.6rem);
  --pad-x: clamp(1.25rem, 5vw, 6rem);
  --section-y: clamp(4.5rem, 10vw, 9rem);
  --maxw: 1320px;
  --radius: 14px;
  --radius-lg: 22px;

  /* fluid type */
  --fs-eyebrow: 0.72rem;
  --fs-body: clamp(1rem, 0.96rem + 0.3vw, 1.18rem);
  --fs-lead: clamp(1.25rem, 1.1rem + 0.9vw, 1.7rem);
  --fs-h3: clamp(1.4rem, 1.2rem + 1vw, 2.1rem);
  --fs-h2: clamp(2rem, 1.4rem + 3vw, 3.8rem);
  --fs-h1: clamp(2.6rem, 1rem + 6vw, 6.4rem);
}

/* light (default) — Cool Swiss, see DESIGN.md */
:root, [data-theme="light"] {
  --paper: #F9FAFB;
  --paper-2: #EDF0F3;
  --surface: #F3F5F7;
  --ink: #11151A;
  --ink-2: #4D5760;
  --ink-3: #7C8893;
  --stone: #95A3AF;
  --line: rgba(17,21,26,0.14);
  --line-soft: rgba(17,21,26,0.07);
  --ok: #0E8A5C; --warn: #B98900; --err: #C81E45; --info: #0B7285;
  --shadow: 0 1px 2px rgba(17,21,26,.04), 0 18px 40px -24px rgba(17,21,26,.28);
  --grain-opacity: .05;
  /* tile behind full-colour brand logos (experience list) */
  --logo-tile: var(--paper-2);
}
[data-theme="dark"] {
  --paper: #14171A;
  --paper-2: #1B1F24;
  --surface: #171B1F;
  --ink: #E9EDF1;
  --ink-2: #9AA6B1;
  --ink-3: #6B7782;
  --stone: #57636E;
  --line: rgba(233,237,241,0.16);
  --line-soft: rgba(233,237,241,0.07);
  --accent: #E9EDF1;
  --accent-ink: #14171A;
  --ok: #2EC58D; --warn: #E0B12F; --err: #F0597F; --info: #3FBBD8;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 24px 50px -28px rgba(0,0,0,.8);
  --grain-opacity: .22;
  /* keep a soft light tile in dark mode so full-colour brand logos (incl. black marks) still read */
  --logo-tile: #EDEFF2;
}


/* ============================================================
   BASE
   ============================================================ */
body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01","cv01";
  transition: background-color .5s ease, color .5s ease;
  overflow-x: hidden;
  position: relative;   /* containing block for the grain overlay */
}

/* film grain overlay — absolute (scrolls with the page), NOT fixed: a fixed
   full-viewport blend layer forces the compositor to re-blend the whole screen
   on every scroll frame, which visibly janks scrolling on macOS. Anchored to
   the content, the blended result is cacheable and scrolling stays cheap. */
body::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}
[data-theme="dark"] body::before { mix-blend-mode: screen; }

::selection { background: var(--accent); color: var(--accent-ink); }

h1,h2,h3,h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.02; letter-spacing: -0.02em; }

/* ---------- Layout helpers ---------- */
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding-inline: var(--pad-x); }
.section { padding-block: var(--section-y); }
.divider { border: none; border-top: 1px solid var(--line); margin: 0; }

/* ---------- Eyebrow / inverted label chip ---------- */
.eyebrow {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 0.45em 0.95em;
  border-radius: 2px;
  box-shadow: 2px 2px 0 var(--stone);
  display: inline-flex;
  align-items: center;
  gap: .6em;
  line-height: 1.4;
}
/* solid (inverted) variant — black chip, white text; e.g. the metric tag on work cards */
.eyebrow.is-solid { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.eyebrow.is-solid b { font-weight: 700; }

/* outlined in paper on dark bands (impact, footer) */
.impact .eyebrow, .footer .eyebrow { background: transparent; color: var(--paper); border-color: var(--paper); }
[data-theme="dark"] .impact .eyebrow, [data-theme="dark"] .footer .eyebrow { background: var(--paper); color: var(--ink); border-color: var(--ink); }

/* ---------- Section heading ---------- */
.section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.5rem; margin-bottom: clamp(2rem,5vw,3.5rem); }
.section-head h2 { font-size: var(--fs-h2); max-width: 16ch; }
.section-head .meta { color: var(--ink-2); max-width: 32ch; }

/* ============================================================
   NAV
   ============================================================ */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  padding-block: 1.1rem;
  transition: padding .35s ease, background-color .35s ease, border-color .35s ease;
  border-bottom: 1px solid transparent;
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--pad-x);
}
.nav.scrolled {
  padding-block: .7rem;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  /* 8px (was 14px): backdrop blur re-samples on every scrolled frame; smaller
     radius ≈ half the cost on macOS with no visible loss at this opacity */
  backdrop-filter: blur(8px) saturate(1.3);
  -webkit-backdrop-filter: blur(8px) saturate(1.3);
  border-bottom-color: var(--line);
}
.brand { display: flex; align-items: center; color: var(--ink); }
.brand-logo { height: 30px; width: auto; display: block; }
.nav-links { display: flex; align-items: center; gap: clamp(1rem, 2.5vw, 2.4rem); }
.nav-links a { font-size: .92rem; font-weight: 600; color: var(--ink-2); position: relative; transition: color .2s; }
/* animated underline — plain links only. Never the CTA button: its own ::after rendered a
   "moving line" underneath the button on hover (the underline pseudo out-specified the CTA). */
.nav-links a:not(.nav-cta)::after { content:""; position:absolute; left:0; bottom:-4px; height:1px; width:0; background: var(--ink); transition: width .25s ease; }
.nav-links a:not(.nav-cta):hover { color: var(--ink); }
.nav-links a:not(.nav-cta):hover::after { width: 100%; }
/* CTA is literally the hero primary button — markup `class="btn btn-primary"` + the same arrow — so it
   looks and animates identically. The ONLY nav-specific fix: `.nav-links a` declares `transition: color .2s`
   at higher specificity than `.btn`, which was silently overriding the button's transform/box-shadow easing
   (that killed transition = the "rushed" snap on hover). Restore the full transition + trim to nav size at
   `.nav-links a.nav-cta` specificity so it wins. The `.nav-cta` class also keeps the nav underline
   (`a:not(.nav-cta)`) off it and pins the on-accent text colour. */
.nav-links a.nav-cta {
  font-size: .9rem; padding: .55rem 1.1rem;
  transition: transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s cubic-bezier(.2,.8,.2,1), background-color .25s, color .25s;
}
.nav-links a.nav-cta, .nav-links a.nav-cta:hover { color: var(--accent-ink); }
.nav-links a.menu-only { display: none; }
@media (max-width: 720px) {
  .nav-links a:not(.menu-only):not(.nav-cta) { display: none; }
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: .6em;
  font-family: var(--font-body); font-weight: 600; font-size: .98rem;
  padding: .85rem 1.5rem; border-radius: 2px;
  background: var(--paper); color: var(--ink); border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s cubic-bezier(.2,.8,.2,1), background-color .25s, color .25s, border-color .25s;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn .arr { transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.btn:hover .arr { transform: translateY(4px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); box-shadow: 2px 2px 0 1px var(--stone); }
.btn-primary:hover { box-shadow: 4px 4px 0 1px var(--stone); }
.btn-primary:active { box-shadow: 1px 1px 0 var(--stone); }
.btn-ghost { background: var(--paper); color: var(--ink); }

/* ============================================================
   REVEAL ANIMATIONS
   Visible by default. Hidden state only applies when JS adds
   `.js-reveal` to <html>, so a JS failure can never hide content.
   `.reveal--shown` force-shows statically (failsafe / frozen envs).
   ============================================================ */
.reveal { transition: opacity .9s cubic-bezier(.16,1,.3,1), transform .9s cubic-bezier(.16,1,.3,1); }
html.js-reveal .reveal:not(.in):not(.reveal--shown) { opacity: 0; transform: translateY(26px); }
.reveal.in { opacity: 1; transform: none; }
.reveal.reveal--shown { opacity: 1 !important; transform: none !important; transition: none !important; }
.reveal[data-d="1"] { transition-delay: .08s; }
.reveal[data-d="2"] { transition-delay: .16s; }
.reveal[data-d="3"] { transition-delay: .24s; }
.reveal[data-d="4"] { transition-delay: .32s; }
.reveal[data-d="5"] { transition-delay: .40s; }
@media (prefers-reduced-motion: reduce) {
  html.js-reveal .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
}

/* line-by-line clip reveal for big headings */
.lines span { display: block; }
.line-mask { overflow: hidden; }
.line-mask > span { display: block; transition: transform 1s cubic-bezier(.16,1,.3,1); }
html.js-reveal .line-mask:not(.in):not(.reveal--shown) > span { transform: translateY(108%); }
.line-mask.in > span { transform: none; }
.line-mask.reveal--shown > span { transform: none !important; transition: none !important; }
.line-mask[data-d="1"] > span { transition-delay: .09s; }
.line-mask[data-d="2"] > span { transition-delay: .18s; }
.line-mask[data-d="3"] > span { transition-delay: .27s; }
@media (prefers-reduced-motion: reduce) { html.js-reveal .line-mask > span { transform: none !important; } }

/* ============================================================
   FOOTER
   ============================================================ */
/* Footer is an inverted (ink) panel; --f-ink is "footer foreground" so dark mode can
   flip it back to readable text on the dark surface (was dark-on-dark, WCAG fail). */
.footer { --f-ink: var(--paper); background: var(--ink); color: var(--f-ink); position: relative; }
[data-theme="dark"] .footer { background: var(--surface); --f-ink: var(--ink); }
.footer .wrap { padding-block: clamp(4rem, 9vw, 7rem) clamp(2rem,4vw,3rem); }
.footer-cta { font-family: var(--font-display); font-weight: 600; font-size: clamp(2.4rem, 1rem + 7vw, 7rem); letter-spacing: -.03em; line-height: .98; }
.footer-cta a { display: inline-flex; align-items: baseline; gap: .15em; transition: color .25s; }
.footer-cta a:hover { color: var(--stone); }
.footer-grid { display: flex; flex-wrap: wrap; gap: 2rem 4rem; justify-content: space-between; margin-top: clamp(3rem,7vw,5rem); }
.footer-col h2 { font-family: var(--font-mono); font-weight: 500; font-size: .72rem; letter-spacing: .22em; text-transform: uppercase; color: color-mix(in srgb, var(--f-ink) 62%, transparent); margin-bottom: 1.1rem; }
.footer-col ul { display: flex; flex-direction: column; gap: .6rem; }
.footer-col a { color: color-mix(in srgb, var(--f-ink) 80%, transparent); transition: color .2s; display: inline-flex; align-items: center; gap: .5em; }
.footer-col a:hover { color: var(--stone); }
.footer-bottom { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: center; margin-top: clamp(3rem,6vw,4.5rem); padding-top: 1.6rem; border-top: 1px solid color-mix(in srgb, var(--f-ink) 16%, transparent); font-size: .82rem; color: color-mix(in srgb, var(--f-ink) 62%, transparent); }

/* ============================================================
   THEME TOGGLE (light/dark button appended by js/site.js)
   ============================================================ */
.theme-toggle {
  position: fixed; z-index: 9000; right: 20px; bottom: 20px;
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 10px 26px -10px rgba(0,0,0,.5);
}
@media (prefers-reduced-motion: no-preference) {
  .theme-toggle { transition: transform .15s ease, box-shadow .15s ease; }
}
.theme-toggle:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -10px rgba(0,0,0,.55); }
.theme-toggle:active { transform: translateY(0); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
/* icon shows the theme you'd switch TO: moon on light, sun on dark */
.theme-toggle .tt-sun { display: none; }
[data-theme="dark"] .theme-toggle .tt-moon { display: none; }
[data-theme="dark"] .theme-toggle .tt-sun { display: block; }
/* narrow viewports: smaller and slightly translucent so it doesn't swallow right-edge copy */
@media (max-width: 640px) {
  .theme-toggle { width: 38px; height: 38px; right: 12px; bottom: 12px; opacity: .82; }
  .theme-toggle:hover, .theme-toggle:focus-visible { opacity: 1; }
}

/* ============================================================
   UTIL
   ============================================================ */
.accent-text { color: var(--accent); }
.mono { font-family: var(--font-mono); }
.measure { max-width: 64ch; }
.center { text-align: center; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); border:0; }
