/* =========================================================
   TANGΣNTS — shared design system
   Tokens, base, type, buttons, nav, footer, reveals.
   Used by every page. Page specific styles live in home.css
   and case-study.css.
   ========================================================= */

/* ---------- Fonts (self hosted, variable, subset) ---------- */
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/manrope-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: "Manrope";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/manrope-greek.woff2") format("woff2");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("../fonts/geist-mono-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;
}

/* ---------- Tokens ---------- */
:root {
  /* Brand palette */
  --ink: #1c1b1d;
  --charcoal: #313032;
  --paper: #f6f5f2;
  --teal: #7db2c0;        /* Σ Teal: CTAs, the mark, key numbers, hovers */
  --deep-teal: #3a6e7a;   /* accent text on light surfaces */
  --mist: #e4eff2;        /* tinted panels on light surfaces */

  /* Theme roles (dark first) */
  --bg: var(--ink);
  --surface: var(--charcoal);
  --surface-2: #262527;
  --text: var(--paper);
  --text-muted: rgba(246, 245, 242, 0.66);
  --text-faint: rgba(246, 245, 242, 0.52);
  --line: rgba(246, 245, 242, 0.1);
  --line-strong: rgba(246, 245, 242, 0.18);
  --accent: var(--teal);
  --accent-text: var(--teal);
  --on-accent: var(--ink);
  --glow: rgba(125, 178, 192, 0.14);
  --nav-bg: rgba(28, 27, 29, 0.72);
  --overlay-bg: rgba(28, 27, 29, 0.86);
  color-scheme: dark;

  /* Spacing scale (only these values) */
  --s-25: 2px;
  --s-50: 4px;
  --s-75: 8px;
  --s-100: 12px;
  --s-200: 16px;
  --s-300: 24px;
  --s-400: 32px;
  --s-500: 40px;
  --s-600: 48px;
  --s-700: 64px;
  --s-800: 80px;
  --s-900: 96px;

  /* Radius: brand range 6 to 8px */
  --r-sm: 6px;
  --r: 8px;

  /* Type */
  --font: "Manrope", ui-sans-serif, system-ui, sans-serif;
  --mono: "Geist Mono", "Manrope", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Motion */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-reveal: cubic-bezier(0.16, 1, 0.3, 1);

  --container: 1200px;
  --gutter: var(--s-200);
}

/* Light theme: Paper ground, Deep Teal accent text, Mist panels */
:root[data-theme="light"] {
  --bg: var(--paper);
  --surface: #ffffff;
  --surface-2: var(--mist);
  --text: var(--ink);
  --text-muted: rgba(28, 27, 29, 0.74);
  --text-faint: rgba(28, 27, 29, 0.62);
  --line: rgba(28, 27, 29, 0.1);
  --line-strong: rgba(28, 27, 29, 0.18);
  --accent: var(--deep-teal);
  --accent-text: var(--deep-teal);
  --on-accent: var(--paper);
  --glow: rgba(58, 110, 122, 0.1);
  --nav-bg: rgba(246, 245, 242, 0.78);
  --overlay-bg: rgba(246, 245, 242, 0.9);
  color-scheme: light;
}

@media (min-width: 768px) {
  :root { --gutter: var(--s-400); }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: var(--s-900);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 24px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
h1, h2, h3, h4, p, ul, ol, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1, h2, h3, h4 { text-wrap: balance; font-weight: 600; letter-spacing: -0.02em; }
p, li, blockquote { text-wrap: pretty; }
::selection { background: var(--teal); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

.skip-link {
  position: fixed;
  top: var(--s-200);
  left: var(--s-200);
  z-index: 100;
  padding: var(--s-100) var(--s-200);
  background: var(--teal);
  color: var(--ink);
  border-radius: var(--r);
  font-weight: 600;
  transform: translateY(-200%);
  transition: transform 200ms var(--ease-out);
}
.skip-link:focus { transform: translateY(0); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.icon { width: 20px; height: 20px; flex: none; fill: currentColor; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  position: relative;
  padding-block: var(--s-800);
  background: var(--bg);
  color: var(--text);
}
@media (min-width: 1024px) {
  .section { padding-block: var(--s-900); }
}

.section-head {
  display: grid;
  gap: var(--s-200);
  max-width: 680px;
  margin-bottom: var(--s-600);
}
.section-head p:not(.label) { color: var(--text-muted); font-size: 18px; line-height: 28px; }

/* Small label: quiet context above a headline, never a headline itself */
.label {
  display: inline-flex;
  align-items: center;
  gap: var(--s-75);
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--text-faint);
}
.label .sigma { color: var(--accent); }

/* ---------- Type scale (Tailwind steps) ---------- */
.t-display { font-size: 48px; line-height: 1.04; letter-spacing: -0.035em; font-weight: 600; }
.t-h2 { font-size: 36px; line-height: 40px; letter-spacing: -0.03em; }
.t-h3 { font-size: 20px; line-height: 28px; letter-spacing: -0.01em; }
.t-lead { font-size: 18px; line-height: 28px; color: var(--text-muted); }
.t-small { font-size: 14px; line-height: 20px; }
.t-muted { color: var(--text-muted); }

@media (min-width: 768px) {
  .t-display { font-size: 60px; }
  .t-h2 { font-size: 48px; line-height: 1.04; }
  .t-h3 { font-size: 24px; line-height: 32px; }
}
@media (min-width: 1200px) {
  .t-display { font-size: 72px; }
}


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

/* Placeholder marker: anything in brackets the team still has to fill */
.ph {
  color: var(--text-faint);
  text-decoration: underline dotted var(--accent);
  text-underline-offset: 4px;
}

/* ---------- Wordmark ---------- */
.wordmark {
  display: inline-flex;
  align-items: baseline;
  font-weight: 700;
  font-size: 18px;
  line-height: 28px;
  letter-spacing: 0.14em;
  color: var(--text);
}
.wordmark .sigma { color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--text);
  --btn-border: var(--line-strong);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-75);
  min-height: 44px;
  padding: var(--s-75) var(--s-200);
  border-radius: var(--r);
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 160ms var(--ease-out),
    background-color 200ms ease,
    border-color 200ms ease,
    color 200ms ease;
}
.btn:active { transform: scale(0.97); }
.btn .icon { transition: transform 240ms var(--ease-out); }

.btn-primary {
  --btn-bg: var(--accent);
  --btn-fg: var(--on-accent);
  --btn-border: var(--accent);
}
.btn-ghost { --btn-bg: transparent; }
.btn-sm { min-height: 36px; padding: var(--s-50) var(--s-100); font-size: 14px; line-height: 20px; }

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { --btn-bg: color-mix(in srgb, var(--accent) 86%, var(--text)); }
  .btn-ghost:hover { --btn-border: var(--accent); --btn-fg: var(--accent-text); }
  .btn:hover .icon-shift { transform: translateX(3px); }
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: var(--s-75);
  font-weight: 600;
  color: var(--accent-text);
}
.link-arrow .icon { transition: transform 240ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .link-arrow:hover .icon { transform: translateX(3px); }
}

/* ---------- Nav: floating island ---------- */
.nav {
  position: fixed;
  inset: var(--s-200) 0 auto;
  z-index: 50;
  pointer-events: none;
}
.nav-inner {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-300);
  max-width: calc(var(--container) + var(--s-300) * 2);
  margin-inline: var(--s-200);
  padding: var(--s-75) var(--s-75) var(--s-75) var(--s-200);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  transition: border-color 300ms ease, transform 500ms var(--ease-drawer);
}
@media (min-width: 1248px) {
  .nav-inner { margin-inline: auto; }
}
.nav.is-scrolled .nav-inner { border-color: var(--line-strong); }

.nav-links {
  display: none;
  align-items: center;
  gap: var(--s-50);
}
.nav-links a {
  position: relative;
  padding: var(--s-75) var(--s-100);
  border-radius: var(--r-sm);
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 200ms ease, background-color 200ms ease;
}
.nav-links a[aria-current="true"],
.nav-links a[aria-current="page"] { color: var(--text); }
.nav-links a[aria-current="true"]::after,
.nav-links a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 4px; height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--accent);
}
@media (hover: hover) and (pointer: fine) {
  .nav-links a:hover { color: var(--text); background: var(--line); }
}

.nav-actions { display: flex; align-items: center; gap: var(--s-75); }
.nav-actions .btn-primary { display: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  transition: color 200ms ease, background-color 200ms ease, transform 160ms var(--ease-out);
}
.icon-btn:active { transform: scale(0.94); }
@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover { color: var(--text); background: var(--line); }
}

.theme-toggle .i-sun { display: none; }
:root[data-theme="light"] .theme-toggle .i-sun { display: block; }
:root[data-theme="light"] .theme-toggle .i-moon { display: none; }

/* Hamburger morphs into an X */
.menu-toggle { position: relative; }
.menu-toggle span {
  position: absolute;
  left: 11px;
  width: 18px; height: 1.5px;
  border-radius: 2px;
  background: var(--text);
  transition: transform 400ms var(--ease-drawer), opacity 200ms ease;
}
.menu-toggle span:nth-child(1) { top: 15px; }
.menu-toggle span:nth-child(2) { top: 23px; }
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(4px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { transform: translateY(-4px) rotate(-45deg); }

@media (min-width: 960px) {
  .nav-links { display: flex; }
  .nav-actions .btn-primary { display: inline-flex; }
  .menu-toggle { display: none; }
}

/* Mobile overlay menu */
.menu {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 112px var(--gutter) var(--s-500);
  background: var(--overlay-bg);
  -webkit-backdrop-filter: blur(40px);
  backdrop-filter: blur(40px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 400ms var(--ease-drawer), visibility 0s linear 400ms;
}
.menu.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 400ms var(--ease-drawer), visibility 0s;
}
.menu ul { display: grid; gap: var(--s-75); }
.menu li {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity 500ms var(--ease-drawer), transform 600ms var(--ease-drawer);
  transition-delay: calc(var(--i, 0) * 50ms + 80ms);
}
.menu.is-open li { opacity: 1; transform: none; }
.menu ul a {
  display: block;
  padding-block: var(--s-75);
  font-size: 36px;
  line-height: 40px;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.menu-foot { display: grid; gap: var(--s-100); }
.menu-foot .btn { width: 100%; }
@media (min-width: 960px) { .menu { display: none; } }

body.menu-open { overflow: hidden; }

/* ---------- Cards with cursor glow ---------- */
.card {
  position: relative;
  isolation: isolate;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  overflow: hidden;
  transition: border-color 300ms ease, transform 500ms var(--ease-out);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%), var(--glow), transparent 70%);
  opacity: 0;
  transition: opacity 400ms ease;
  pointer-events: none;
}
@media (hover: hover) and (pointer: fine) {
  .card:hover { border-color: var(--line-strong); }
  .card:hover::before { opacity: 1; }
}

/* ---------- Forms ---------- */
.field { display: grid; gap: var(--s-75); }
.field label { font-size: 14px; line-height: 20px; font-weight: 600; }
.field .hint { font-size: 12px; line-height: 16px; color: var(--text-faint); font-weight: 400; }
.input {
  width: 100%;
  min-height: 48px;
  padding: var(--s-100) var(--s-200);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 24px;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.input::placeholder { color: var(--text-faint); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
textarea.input { min-height: 120px; resize: vertical; }
.field.has-error .input { border-color: #d98a7a; }
.field .error { display: none; font-size: 14px; line-height: 20px; color: #e3a091; }
:root[data-theme="light"] .field .error { color: #a5432f; }
.field.has-error .error { display: block; }

/* ---------- Reveal on scroll ---------- */
.js [data-reveal] {
  opacity: 0;
  transform: translate3d(0, 24px, 0);
  filter: blur(6px);
  transition:
    opacity 800ms var(--ease-drawer),
    transform 900ms var(--ease-drawer),
    filter 800ms var(--ease-drawer);
  transition-delay: calc(var(--d, 0) * 70ms);
}
.js [data-reveal].is-in { opacity: 1; transform: none; filter: none; }

/* Staggered word reveal (hero) */
.word-reveal .word {
  display: inline-block;
  white-space: pre;
}
/* CSS keyframes, not JS triggered, so the hero paints on the first frame (LCP) */
.js .word-reveal .word {
  animation: wordIn 800ms var(--ease-reveal) both;
  animation-delay: calc(var(--wi, 0) * 70ms + 80ms);
}
@keyframes wordIn {
  from { opacity: 0; transform: translate3d(0, 0.4em, 0); }
}

/* Intro elements above the fold: same feel as [data-reveal], no observer needed */
.js [data-intro] {
  animation: introIn 900ms var(--ease-drawer) both;
  animation-delay: calc(var(--d, 0) * 70ms + 120ms);
}
@keyframes introIn {
  from { opacity: 0; transform: translate3d(0, 24px, 0); filter: blur(6px); }
}

/* ---------- Footer ---------- */
.footer {
  padding-block: var(--s-800) var(--s-500);
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.footer-grid {
  display: grid;
  gap: var(--s-600);
}
.footer-brand { display: grid; gap: var(--s-200); max-width: 320px; align-content: start; }
.footer-brand p { color: var(--text-muted); }
.footer-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-400); }
.footer h3 {
  margin-bottom: var(--s-200);
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--text-faint);
}
.footer li + li { margin-top: var(--s-75); }
.footer-cols a, .footer-cols span { font-size: 14px; line-height: 20px; color: var(--text-muted); transition: color 200ms ease; }
.footer-cols a { display: inline-flex; align-items: center; gap: var(--s-75); }
@media (hover: hover) and (pointer: fine) {
  .footer-cols a:hover { color: var(--accent-text); }
}
.footer-base {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s-200);
  margin-top: var(--s-700);
  padding-top: var(--s-300);
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 16px;
  color: var(--text-faint);
}
.footer-base nav { display: flex; gap: var(--s-300); }
.footer-base a { transition: color 200ms ease; }
.footer-base a:hover { color: var(--text); }

@media (min-width: 768px) {
  .footer-grid { grid-template-columns: 1fr 2fr; }
  .footer-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    transition-delay: 0ms !important;
    animation-delay: 0ms !important;
  }
  .js [data-reveal],
  .js .word-reveal .word { opacity: 1; transform: none; filter: none; }
}

/* Line breaks that only apply on wide screens */
.br-lg { display: none; }
@media (min-width: 1024px) { .br-lg { display: inline; } }
