/* ==========================================================================
   Mayank Pratap Singh — portfolio
   Design tokens → base → layout → components → sections → case study
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --surface-2: #f2f2ef;
  --surface-3: #e9e9e5;
  --text: #0f0f0d;
  --muted: #57574f;
  --faint: #8b8b84;
  --border: #e4e4df;
  --border-strong: #cfcfc8;
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-ink: #ffffff;
  --accent-soft: rgba(194, 65, 12, 0.08);
  --accent-line: rgba(194, 65, 12, 0.35);
  --success: #15803d;
  --error: #b91c1c;
  --bezel: #17171a;
  --shadow-sm: 0 1px 2px rgba(16, 16, 12, 0.05);
  --shadow-md: 0 1px 2px rgba(16, 16, 12, 0.04), 0 12px 32px -12px rgba(16, 16, 12, 0.14);
  --shadow-lg: 0 2px 4px rgba(16, 16, 12, 0.04), 0 32px 64px -24px rgba(16, 16, 12, 0.22);
  --grid-line: rgba(15, 15, 13, 0.045);

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --container: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
  --nav-h: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0a0a0b;
  --surface: #121214;
  --surface-2: #18181b;
  --surface-3: #202024;
  --text: #f1f1ee;
  --muted: #a3a39c;
  --faint: #6f6f69;
  --border: #232327;
  --border-strong: #34343a;
  --accent: #ff7a3d;
  --accent-hover: #ff9a6a;
  --accent-ink: #170a03;
  --accent-soft: rgba(255, 122, 61, 0.1);
  --accent-line: rgba(255, 122, 61, 0.4);
  --success: #4ade80;
  --error: #f87171;
  --bezel: #2a2a2f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 32px 64px -24px rgba(0, 0, 0, 0.75);
  --grid-line: rgba(255, 255, 255, 0.035);
  color-scheme: dark;
}

/* No-JS fallback: follow the OS */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0a0a0b; --surface: #121214; --surface-2: #18181b; --surface-3: #202024;
    --text: #f1f1ee; --muted: #a3a39c; --faint: #6f6f69; --border: #232327; --border-strong: #34343a;
    --accent: #ff7a3d; --accent-hover: #ff9a6a; --accent-ink: #170a03;
    --accent-soft: rgba(255, 122, 61, 0.1); --accent-line: rgba(255, 122, 61, 0.4);
    --success: #4ade80; --error: #f87171; --bezel: #2a2a2f;
    --grid-line: rgba(255, 255, 255, 0.035);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.025em; line-height: 1.1; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
::selection { background: var(--accent); color: var(--accent-ink); }

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

.skip-link {
  position: absolute; left: 16px; top: -100px; z-index: 100;
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 500;
}
.skip-link:focus { top: 12px; }

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

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.section { padding-block: clamp(72px, 9vw, 120px); }
.section + .section { border-top: 1px solid var(--border); }

.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.eyebrow::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}

.section-head { display: grid; gap: 16px; margin-bottom: clamp(40px, 6vw, 72px); max-width: 720px; }
.section-head h2 { font-size: clamp(32px, 5vw, 52px); }
.section-head p { color: var(--muted); font-size: clamp(16px, 1.6vw, 18px); max-width: 560px; }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px;
  border-radius: 999px; border: 1px solid var(--btn-bd);
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: 15px; font-weight: 500; letter-spacing: -0.01em; white-space: nowrap;
  cursor: pointer;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
}
.btn:hover { border-color: var(--text); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn svg { width: 16px; height: 16px; flex: none; transition: transform .25s var(--ease); }
.btn:hover svg.arrow { transform: translateX(3px); }
.btn:hover svg.arrow-down { transform: translateY(2px); }
.btn-primary { --btn-bg: var(--text); --btn-fg: var(--bg); --btn-bd: var(--text); }
.btn-primary:hover { --btn-bg: var(--accent); --btn-bd: var(--accent); --btn-fg: var(--accent-ink); }
.btn-accent { --btn-bg: var(--accent); --btn-fg: var(--accent-ink); --btn-bd: var(--accent); }
.btn-accent:hover { --btn-bg: var(--accent-hover); --btn-bd: var(--accent-hover); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; padding-inline: 12px; color: var(--muted); }
.btn-ghost:hover { --btn-bd: transparent; color: var(--text); }
.btn-sm { min-height: 38px; padding: 0 16px; font-size: 14px; }

.link-arrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 500; color: var(--text);
  border-bottom: 1px solid var(--border-strong); padding-bottom: 2px;
  transition: border-color .2s var(--ease), color .2s var(--ease);
}
.link-arrow svg { width: 15px; height: 15px; transition: transform .25s var(--ease); }
.link-arrow:hover { color: var(--accent); border-color: var(--accent); }
.link-arrow:hover svg { transform: translateX(3px); }

/* ---------- Tags ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-family: var(--mono); font-size: 12px; line-height: 1;
  padding: 7px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
}

/* ---------- Navigation ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50; height: var(--nav-h);
  transition: background-color .3s var(--ease), border-color .3s var(--ease), backdrop-filter .3s;
  border-bottom: 1px solid transparent;
}
.nav.is-scrolled, .nav.is-open {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom-color: var(--border);
}
.nav-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 600; letter-spacing: 0.02em; font-size: 15px;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 700; letter-spacing: -0.02em;
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; right: -2px; bottom: -2px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--bg);
}
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a:not(.btn) {
  position: relative; padding: 8px 12px; font-size: 14px; color: var(--muted); border-radius: 8px;
  transition: color .2s var(--ease);
}
.nav-links a:not(.btn):hover, .nav-links a[aria-current="true"] { color: var(--text); }
.nav-links a[aria-current="true"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 2px; height: 1.5px;
  background: var(--accent); border-radius: 2px;
}
.nav-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; flex: none;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; transition: border-color .2s var(--ease), transform .2s var(--ease);
}
.icon-btn:hover { border-color: var(--border-strong); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }

.menu-toggle { display: none; }
.menu-toggle .bars { position: relative; width: 16px; height: 10px; }
.menu-toggle .bars span {
  position: absolute; left: 0; width: 100%; height: 1.5px; background: currentColor; border-radius: 2px;
  transition: transform .3s var(--ease), top .3s var(--ease);
}
.menu-toggle .bars span:first-child { top: 0; }
.menu-toggle .bars span:last-child { top: 8.5px; }
.nav.is-open .menu-toggle .bars span:first-child { top: 4.25px; transform: rotate(45deg); }
.nav.is-open .menu-toggle .bars span:last-child { top: 4.25px; transform: rotate(-45deg); }

@media (max-width: 860px) {
  .menu-toggle { display: grid; }
  .nav-cta { display: none; }
  .nav-links {
    position: fixed; top: var(--nav-h); left: 0; right: 0; bottom: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    padding: 12px var(--gutter) 32px;
    background: var(--bg);
    opacity: 0; visibility: hidden; transform: translateY(-8px);
    transition: opacity .3s var(--ease), transform .3s var(--ease), visibility 0s linear .3s;
    overflow-y: auto;
  }
  .nav.is-open .nav-links {
    opacity: 1; visibility: visible; transform: none;
    transition: opacity .3s var(--ease), transform .3s var(--ease), visibility 0s;
  }
  .nav-links a:not(.btn) {
    font-size: 28px; font-weight: 500; letter-spacing: -0.02em; color: var(--text);
    padding: 14px 0; border-bottom: 1px solid var(--border); border-radius: 0;
  }
  .nav-links a[aria-current="true"]::after { display: none; }
  .nav-links .btn { margin-top: 28px; min-height: 52px; font-size: 16px; }
  body.menu-open { overflow: hidden; }
}
@media (min-width: 861px) { .nav-links .nav-mobile-only { display: none; } }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding-top: calc(var(--nav-h) + clamp(48px, 8vw, 96px));
  padding-bottom: clamp(56px, 8vw, 96px);
  overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 70% 30%, #000 30%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 70% at 70% 30%, #000 30%, transparent 75%);
}
.hero-grid {
  display: grid; grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr);
  gap: clamp(40px, 5vw, 72px); align-items: center;
}
.hero-status {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 14px 6px 8px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13px; color: var(--muted); margin-bottom: 28px;
}
.hero-status .pulse {
  position: relative; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent-soft); display: grid; place-items: center;
}
.hero-status .pulse::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
}
.hero-status .pulse::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid var(--accent); opacity: 0;
  animation: ping 2.4s var(--ease) infinite;
}
@keyframes ping { 0% { transform: scale(0.5); opacity: .8; } 100% { transform: scale(1.4); opacity: 0; } }
.hero-status strong { color: var(--text); font-weight: 500; }

.hero h1 {
  font-size: clamp(38px, 5.6vw, 68px);
  line-height: 1.02; letter-spacing: -0.04em; font-weight: 600;
  text-wrap: balance;
}
.hero h1 .soft { color: var(--faint); }
.hero-lede {
  margin-top: 24px; max-width: 540px;
  font-size: clamp(16px, 1.55vw, 18.5px); color: var(--muted); line-height: 1.6;
}
.hero-lede strong { color: var(--text); font-weight: 500; }
.hero-ctas { margin-top: 36px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.hero-meta {
  margin-top: 40px; display: flex; flex-wrap: wrap; gap: 10px 28px;
  font-size: 13.5px; color: var(--muted);
}
.hero-meta span { display: inline-flex; align-items: center; gap: 8px; }
.hero-meta svg { width: 15px; height: 15px; color: var(--faint); }

/* Hero collage — built from real product assets */
.collage { position: relative; aspect-ratio: 1 / 0.92; width: 100%; }
.collage > * { position: absolute; }
.collage .browser { left: 0; top: 0; width: 86%; }
.collage .phone { right: 0; bottom: 0; width: 31%; z-index: 3; }
.collage .phone.back { left: 8%; right: auto; bottom: 0; width: 25%; z-index: 2; }
.collage .label {
  z-index: 4; display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-md);
  font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap;
}
.collage .label i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.collage .label.l1 { left: 38%; bottom: 7%; }
.collage .label.l2 { right: 17%; top: 5%; }
.collage .label.l3 { left: 2%; top: 30%; }
.collage svg.flow { inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; overflow: visible; }
.flow path { fill: none; stroke: var(--accent-line); stroke-width: 1.5; stroke-dasharray: 3 6; }
.flow path.live { stroke: var(--accent); stroke-dasharray: 16 220; stroke-linecap: round; animation: flow 3.2s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -236; } }

/* Device frames */
.browser {
  border-radius: 12px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.browser-bar {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.browser-bar .dots { display: flex; gap: 5px; }
.browser-bar .dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.browser-bar .url {
  flex: 1; max-width: 260px; margin-inline: auto;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 3px 10px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.browser-bar .spacer { width: 31px; }
.browser img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; }

.phone {
  aspect-ratio: 1 / 2.06;
  border-radius: clamp(18px, 3.2vw, 34px);
  padding: clamp(4px, 0.55vw, 7px);
  background: var(--bezel);
  box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(255,255,255,0.06);
}
.phone img {
  width: 100%; height: 100%; object-fit: cover; object-position: top;
  border-radius: calc(clamp(18px, 3.2vw, 34px) - clamp(4px, 0.55vw, 7px));
  background: #fff;
}

.device-chip {
  aspect-ratio: 1; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-md);
  display: grid; place-items: center; padding: 8%;
}
.device-chip img { width: 100%; height: 100%; object-fit: contain; }

@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; }
  .collage { max-width: 640px; margin-inline: auto; }
}
@media (max-width: 520px) {
  .collage { aspect-ratio: 1 / 1.02; }
  .collage .browser { width: 100%; }
  .collage .phone { width: 37%; }
  .collage .phone.back { width: 30%; left: 2%; }
  .collage .label { font-size: 10.5px; padding: 6px 9px; }
  .collage .label.l1 { left: 34%; bottom: 4%; }
  .collage .label.l2 { display: none; }
  .collage .label.l3 { left: 2%; top: 30%; }
}

/* ---------- Stack strip ---------- */
.stack-strip { border-block: 1px solid var(--border); background: var(--surface); }
.stack-strip .container {
  display: flex; align-items: center; gap: clamp(20px, 4vw, 48px);
  padding-block: 22px;
}
.stack-strip .lead {
  flex: none; font-size: 13px; color: var(--muted); max-width: 190px; line-height: 1.4;
}
.stack-strip ul {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px clamp(18px, 2.6vw, 34px);
}
.stack-strip li {
  font-family: var(--mono); font-size: 13.5px; color: var(--text); font-weight: 500;
  display: inline-flex; align-items: center; gap: 10px;
}
@media (max-width: 760px) {
  .stack-strip .container { flex-direction: column; align-items: flex-start; gap: 14px; }
  .stack-strip .lead { max-width: none; }
}

/* ---------- Work ---------- */
.work-list { display: grid; gap: clamp(28px, 4vw, 48px); }

.project {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); overflow: hidden;
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease);
}
.project:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.project.flip { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
.project.flip .project-visual { order: 2; }

.project-visual {
  position: relative; overflow: hidden; min-height: 380px;
  background: var(--surface-2);
  display: grid; place-items: center;
}
.project-visual::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(var(--grid-line) 1.2px, transparent 1.2px);
  background-size: 18px 18px;
  -webkit-mask-image: linear-gradient(180deg, #000, transparent 90%);
  mask-image: linear-gradient(180deg, #000, transparent 90%);
}
.project-visual > * { position: relative; }
.project-visual .media { transition: transform .8s var(--ease); }
.project:hover .project-visual .media { transform: scale(1.03); }

.project-body {
  padding: clamp(28px, 4vw, 48px);
  display: flex; flex-direction: column; gap: 18px;
}
.project-index {
  font-family: var(--mono); font-size: 12px; color: var(--faint); letter-spacing: 0.06em;
  display: flex; justify-content: space-between; gap: 12px;
}
.project-index .kind { color: var(--accent); }
.project h3 { font-size: clamp(28px, 3.4vw, 40px); letter-spacing: -0.035em; }
.project h3 a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.project { position: relative; }
.project .subtitle { font-size: 17px; color: var(--text); font-weight: 500; margin-top: -8px; }
.project .desc { color: var(--muted); font-size: 15.5px; }
.project .contrib { display: grid; gap: 8px; font-size: 14.5px; color: var(--muted); }
.project .contrib li { display: grid; grid-template-columns: 14px 1fr; gap: 10px; }
.project .contrib li::before {
  content: ""; width: 6px; height: 6px; margin-top: 9px; border-radius: 2px;
  background: var(--accent);
}
.project .project-foot { margin-top: auto; padding-top: 8px; display: grid; gap: 22px; }
.project .link-arrow { position: relative; z-index: 2; width: fit-content; }

/* Featured (Dozemate) */
.project.featured { grid-template-columns: 1fr; }
.project.featured .project-visual { min-height: 0; padding: clamp(32px, 5vw, 64px) clamp(16px, 4vw, 48px) 0; }
.featured-media {
  display: flex; align-items: flex-end; justify-content: center; gap: clamp(10px, 2.2vw, 28px);
  width: 100%;
}
.featured-media .phone { width: clamp(104px, 16vw, 200px); flex: none; }
.featured-media .phone.mid { width: clamp(120px, 19vw, 232px); }
.featured-media .phone.side { margin-bottom: -10%; }
.featured-media .phone.mid { margin-bottom: -4%; }
.featured-media .device-chip { width: clamp(110px, 17vw, 200px); margin-bottom: 8%; flex: none; }
.project.featured .project-body {
  display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.6fr); gap: clamp(28px, 4vw, 56px);
  border-top: 1px solid var(--border); position: relative; z-index: 1; background: var(--surface);
}
.featured-intro { display: flex; flex-direction: column; gap: 16px; }
.breakdown { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 32px; }
.breakdown h4 {
  font-family: var(--mono); font-size: 11.5px; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--faint); margin-bottom: 8px;
}
.breakdown p { font-size: 14.5px; color: var(--muted); }

/* Simple per-project compositions */
.media-device { width: min(52%, 260px); filter: drop-shadow(0 30px 40px rgba(0,0,0,.18)); }
.media-device.wide { width: min(86%, 520px); }
.media-pair { display: flex; align-items: center; gap: clamp(12px, 3vw, 32px); padding: 32px; }
.media-pair .phone { width: clamp(110px, 14vw, 170px); }

/* Mini architecture inside cards */
.mini-flow {
  position: absolute !important; left: 16px; right: 16px; bottom: 16px; z-index: 2;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}
.mini-flow span {
  padding: 5px 9px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
}
.mini-flow em { font-style: normal; color: var(--accent); }

/* Websites row */
.sites { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(20px, 3vw, 32px); }
.site-card {
  position: relative; display: flex; flex-direction: column; gap: 20px;
  padding: clamp(16px, 2vw, 20px); padding-bottom: clamp(22px, 2.6vw, 28px);
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease);
}
.site-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.site-card .browser { box-shadow: none; }
.site-card .browser img { transition: transform .8s var(--ease); }
.site-card:hover .browser img { transform: scale(1.025); }
.site-card .meta { padding-inline: 6px; display: grid; gap: 8px; }
.site-card h3 { font-size: 22px; letter-spacing: -0.02em; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.site-card h3 svg { width: 18px; height: 18px; color: var(--faint); transition: transform .25s var(--ease), color .25s; }
.site-card:hover h3 svg { color: var(--accent); transform: translate(2px, -2px); }
.site-card p { color: var(--muted); font-size: 14.5px; }
.site-card a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }

.subhead {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  margin: clamp(64px, 8vw, 96px) 0 28px;
  padding-top: 24px; border-top: 1px solid var(--border);
}
.subhead h3 { font-size: 22px; letter-spacing: -0.02em; }
.subhead p { color: var(--muted); font-size: 14.5px; }

@media (max-width: 900px) {
  .project, .project.flip { grid-template-columns: 1fr; }
  .project.flip .project-visual { order: 0; }
  .project-visual { min-height: 320px; }
  .project.featured .project-body { grid-template-columns: 1fr; }
  .sites { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .breakdown { grid-template-columns: 1fr; gap: 20px; }
  .featured-media .device-chip { display: none; }
  .featured-media .phone.side:last-child { display: none; }
  .featured-media .phone { width: 40%; }
  .featured-media .phone.mid { width: 46%; }
  .project-visual { min-height: 280px; }
  .subhead { flex-direction: column; gap: 6px; }
}

/* ---------- Layers (full-stack differentiator) ---------- */
.layers-wrap {
  display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: clamp(40px, 6vw, 88px); align-items: start;
}
.layers-wrap .section-head { margin-bottom: 0; position: sticky; top: calc(var(--nav-h) + 40px); }
.layers { position: relative; display: grid; gap: 10px; }
.layers::before {
  content: ""; position: absolute; left: 27px; top: 28px; bottom: 28px; width: 1px;
  background: linear-gradient(var(--accent-line), var(--border-strong));
}
.layer {
  position: relative; display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 18px;
  padding: 14px 20px 14px 0;
  border-radius: var(--radius); border: 1px solid transparent;
  transition: background-color .3s var(--ease), border-color .3s var(--ease);
}
.layer:hover { background: var(--surface); border-color: var(--border); }
.layer-icon {
  position: relative; z-index: 1; width: 56px; height: 56px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--text);
}
.layer-icon svg { width: 22px; height: 22px; }
.layer h3 { font-size: 17px; letter-spacing: -0.015em; }
.layer p { font-size: 14px; color: var(--muted); margin-top: 3px; }
.layer .tags { justify-content: flex-end; max-width: 260px; }
@media (max-width: 960px) {
  .layers-wrap { grid-template-columns: 1fr; }
  .layers-wrap .section-head { position: static; }
}
@media (max-width: 640px) {
  .layer { grid-template-columns: 56px 1fr; padding-right: 8px; }
  .layer .tags { grid-column: 2; justify-content: flex-start; }
}

/* ---------- Services ---------- */
.services { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.service { background: var(--surface); padding: clamp(24px, 2.6vw, 32px); display: flex; flex-direction: column; gap: 14px; min-height: 260px; transition: background-color .3s var(--ease); }
.service:hover { background: var(--surface-2); }
.service .num { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.service h3 { font-size: 20px; letter-spacing: -0.02em; margin-top: 28px; }
.service p { font-size: 14.5px; color: var(--muted); }
.service .tags { margin-top: auto; padding-top: 4px; }
@media (max-width: 1024px) { .services { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .services { grid-template-columns: 1fr; } .service { min-height: 0; } .service h3 { margin-top: 12px; } }

/* ---------- Experience ---------- */
.timeline { display: grid; gap: 0; border-top: 1px solid var(--border); }
.tl-item {
  display: grid; grid-template-columns: minmax(160px, 0.32fr) minmax(0, 1fr); gap: clamp(20px, 4vw, 64px);
  padding-block: clamp(28px, 4vw, 44px); border-bottom: 1px solid var(--border);
}
.tl-when { font-family: var(--mono); font-size: 13px; color: var(--muted); display: grid; gap: 10px; align-content: start; }
.tl-when .now {
  width: fit-content; display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  font-size: 11.5px;
}
.tl-when .now::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tl-what h3 { font-size: clamp(22px, 2.6vw, 28px); letter-spacing: -0.025em; }
.tl-what .org { margin-top: 6px; color: var(--muted); font-size: 15.5px; }
.tl-what .org a { border-bottom: 1px solid var(--border-strong); transition: color .2s, border-color .2s; }
.tl-what .org a:hover { color: var(--accent); border-color: var(--accent); }
.tl-what ul { margin-top: 22px; display: grid; gap: 12px; max-width: 720px; }
.tl-what li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; color: var(--muted); font-size: 15.5px; }
.tl-what li::before { content: "→"; color: var(--accent); font-family: var(--mono); font-size: 13px; line-height: 1.85; }
.tl-what .tags { margin-top: 22px; }
.tl-item.small .tl-what h3 { font-size: 19px; }
.tl-item.small .tl-what .org { font-size: 14.5px; }
@media (max-width: 680px) { .tl-item { grid-template-columns: 1fr; gap: 14px; } }

/* ---------- About ---------- */
.about-grid { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: clamp(40px, 6vw, 96px); align-items: start; }
.portrait {
  position: relative; border-radius: var(--radius-lg); overflow: hidden;
  background: linear-gradient(180deg, var(--surface-2), var(--surface-3));
  border: 1px solid var(--border); aspect-ratio: 4 / 4.6;
}
.portrait img { position: absolute; inset: auto 0 0 0; width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.portrait figcaption {
  position: absolute; left: 14px; bottom: 14px; z-index: 1;
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; color: var(--muted);
}
.portrait figcaption svg { width: 14px; height: 14px; }
.about-text h2 { font-size: clamp(30px, 4.2vw, 46px); text-wrap: balance; }
.about-text .prose { margin-top: 28px; display: grid; gap: 18px; color: var(--muted); font-size: clamp(16px, 1.5vw, 17.5px); max-width: 620px; }
.about-text .prose strong { color: var(--text); font-weight: 500; }
.facts {
  margin-top: 40px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; gap: 1px; background: var(--border);
}
.fact { background: var(--surface); padding: 18px 20px; display: grid; gap: 4px; }
.fact dt { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.fact dd { margin: 0; font-size: 15px; }
.fact dd span { color: var(--muted); }
.fact.full { grid-column: 1 / -1; }
@media (max-width: 860px) {
  .about-grid { grid-template-columns: 1fr; }
  .portrait { max-width: 420px; }
}
@media (max-width: 480px) { .facts { grid-template-columns: 1fr; } }

/* ---------- Process ---------- */
.process { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(16px, 2vw, 24px); counter-reset: step; }
.step { position: relative; padding-top: 28px; border-top: 1px solid var(--border-strong); }
.step::before {
  content: ""; position: absolute; top: -1px; left: 0; width: 40px; height: 1px; background: var(--accent);
  transition: width .6s var(--ease);
}
.step:hover::before { width: 100%; }
.step .n { font-family: var(--mono); font-size: 12.5px; color: var(--accent); }
.step h3 { font-size: 22px; margin-top: 14px; letter-spacing: -0.02em; }
.step p { margin-top: 10px; font-size: 14.5px; color: var(--muted); }
@media (max-width: 900px) { .process { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 36px; } }
@media (max-width: 480px) { .process { grid-template-columns: 1fr; } }

/* ---------- Contact ---------- */
.contact {
  position: relative; overflow: hidden;
  background: var(--text); color: var(--bg);
  border-radius: clamp(20px, 3vw, 32px);
  padding: clamp(36px, 6vw, 80px);
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(36px, 5vw, 72px);
}
.contact::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(color-mix(in srgb, var(--bg) 6%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--bg) 6%, transparent) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse 60% 80% at 0% 0%, #000, transparent 70%);
  mask-image: radial-gradient(ellipse 60% 80% at 0% 0%, #000, transparent 70%);
}
.contact > * { position: relative; }
.contact .eyebrow { color: color-mix(in srgb, var(--bg) 65%, var(--text)); }
.contact h2 { font-size: clamp(32px, 4.4vw, 54px); letter-spacing: -0.04em; margin-top: 20px; text-wrap: balance; }
.contact h2 span { color: color-mix(in srgb, var(--bg) 55%, var(--text)); }
.contact .lede { margin-top: 20px; font-size: 17px; color: color-mix(in srgb, var(--bg) 72%, var(--text)); max-width: 460px; }
.contact-actions { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 10px; }
.contact .btn { --btn-bg: transparent; --btn-fg: var(--bg); --btn-bd: color-mix(in srgb, var(--bg) 28%, var(--text)); }
.contact .btn:hover { --btn-bd: var(--bg); }
.contact .btn-accent { --btn-bg: var(--accent); --btn-fg: var(--accent-ink); --btn-bd: var(--accent); }
.contact .btn-accent:hover { --btn-bg: var(--accent-hover); --btn-bd: var(--accent-hover); }
.contact-lines { margin-top: 36px; display: grid; gap: 6px; font-size: 14.5px; color: color-mix(in srgb, var(--bg) 62%, var(--text)); }
.contact-lines a { color: var(--bg); border-bottom: 1px solid color-mix(in srgb, var(--bg) 30%, var(--text)); }
.contact-lines a:hover { border-color: var(--bg); }

.form {
  display: grid; gap: 14px; align-content: start; align-self: start;
  padding: clamp(20px, 3vw, 32px); border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--bg) 6%, var(--text));
  border: 1px solid color-mix(in srgb, var(--bg) 14%, var(--text));
}
.form h3 { font-size: 18px; letter-spacing: -0.015em; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; color: color-mix(in srgb, var(--bg) 70%, var(--text)); }
.field input, .field textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--bg);
  background: color-mix(in srgb, var(--bg) 4%, var(--text));
  border: 1px solid color-mix(in srgb, var(--bg) 20%, var(--text));
  border-radius: 10px; padding: 12px 14px; transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input::placeholder, .field textarea::placeholder { color: color-mix(in srgb, var(--bg) 40%, var(--text)); }
.form .btn { width: 100%; margin-top: 4px; }
.form-status { font-size: 14px; min-height: 1.4em; }
.form-status.ok { color: var(--success); }
.form-status.err { color: var(--error); }
.hp { display: none !important; }
:root:not([data-theme="dark"]) .contact .form-status.ok { color: #4ade80; }
:root:not([data-theme="dark"]) .contact .form-status.err { color: #fca5a5; }
@media (max-width: 900px) { .contact { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .form .row { grid-template-columns: 1fr; } .contact-actions .btn { flex: 1 1 auto; } }

/* ---------- Footer ---------- */
.footer { padding-block: 40px 48px; }
.footer .container { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; }
.footer p { font-size: 13.5px; color: var(--muted); }
.footer nav { display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: 13.5px; }
.footer nav a { color: var(--muted); transition: color .2s; }
.footer nav a:hover { color: var(--text); }

/* ---------- Reveal ---------- */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .9s var(--ease), transform .9s var(--ease); transition-delay: var(--d, 0ms); }
.js .reveal.in { opacity: 1; transform: none; }
.js .hero .reveal { transition-duration: 1.1s; }

/* ==========================================================================
   Case study pages
   ========================================================================== */
.cs-hero { padding-top: calc(var(--nav-h) + clamp(40px, 6vw, 80px)); padding-bottom: clamp(40px, 5vw, 64px); }
.crumb {
  display: flex; width: fit-content; align-items: center; gap: 8px; font-size: 14px; color: var(--muted);
  margin-bottom: 36px; transition: color .2s;
}
.crumb svg { width: 15px; height: 15px; transition: transform .25s var(--ease); }
.crumb:hover { color: var(--text); }
.crumb:hover svg { transform: translateX(-3px); }
.cs-hero h1 { font-size: clamp(44px, 8vw, 96px); letter-spacing: -0.05em; line-height: 0.98; }
.cs-hero .kicker { margin-top: 18px; font-size: clamp(19px, 2.4vw, 26px); color: var(--muted); letter-spacing: -0.02em; max-width: 760px; text-wrap: balance; }
.cs-meta {
  margin-top: clamp(36px, 5vw, 56px);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--border);
}
.cs-meta div { padding: 18px 18px 0 0; display: grid; gap: 6px; align-content: start; }
.cs-meta dt { font-family: var(--mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); }
.cs-meta dd { margin: 0; font-size: 15px; }
@media (max-width: 760px) { .cs-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 8px; } }

.cs-visual {
  position: relative; overflow: hidden;
  border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface-2);
  padding: clamp(32px, 6vw, 72px) clamp(16px, 4vw, 48px);
  display: flex; align-items: center; justify-content: center; gap: clamp(12px, 3vw, 36px);
  min-height: clamp(320px, 46vw, 560px);
}
.cs-visual::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(var(--grid-line) 1.2px, transparent 1.2px);
  background-size: 18px 18px;
}
.cs-visual > * { position: relative; }
.cs-visual .phone { width: clamp(120px, 20vw, 250px); }
.cs-visual .device-photo { width: min(70%, 520px); filter: drop-shadow(0 40px 50px rgba(0,0,0,.18)); }
.cs-visual .device-photo.tall { width: min(46%, 300px); }
.cs-visual .device-photo.dz { width: clamp(64px, 8vw, 104px); }
@media (max-width: 560px) {
  .cs-visual .optional { display: none; }
  .cs-visual .phone { width: 42%; }
}

.cs-body { padding-block: clamp(56px, 8vw, 104px); }
.cs-section {
  display: grid; grid-template-columns: minmax(150px, 0.3fr) minmax(0, 1fr); gap: clamp(20px, 4vw, 64px);
  padding-block: clamp(32px, 4.5vw, 52px); border-top: 1px solid var(--border);
}
.cs-section > h2 {
  font-family: var(--mono); font-size: 12.5px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding-top: 6px;
  display: flex; gap: 10px;
}
.cs-section > h2 span { color: var(--accent); }
.cs-content { display: grid; gap: 18px; max-width: 760px; }
.cs-content > p { font-size: clamp(16px, 1.6vw, 18px); color: var(--muted); }
.cs-content > p.big { font-size: clamp(20px, 2.4vw, 26px); color: var(--text); letter-spacing: -0.02em; line-height: 1.4; }
.cs-content strong { color: var(--text); font-weight: 500; }
.cs-list { display: grid; gap: 12px; }
.cs-list li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; color: var(--muted); font-size: 16px; }
.cs-list li::before { content: "→"; color: var(--accent); font-family: var(--mono); font-size: 13px; line-height: 1.9; }
.features { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.feature { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.feature h3 { font-size: 16px; letter-spacing: -0.01em; }
.feature p { margin-top: 6px; font-size: 14.5px; color: var(--muted); }
@media (max-width: 760px) {
  .cs-section { grid-template-columns: 1fr; gap: 16px; }
  .features { grid-template-columns: 1fr; }
}

/* Architecture diagram */
.arch {
  display: flex; align-items: stretch; padding: clamp(16px, 2.4vw, 24px); border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface);
}
.arch-node {
  flex: 1 1 0; min-width: 0;
  position: relative; display: grid; gap: 10px; align-content: start;
  padding: 18px 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border);
}
.arch-node .k { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.arch-node .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); }
.arch-node .ico svg { width: 18px; height: 18px; }
.arch-node h3 { font-size: 15px; letter-spacing: -0.01em; }
.arch-node p { font-size: 13px; color: var(--muted); line-height: 1.5; }
.arch-link {
  flex: 0 0 64px;
  position: relative; display: grid; place-items: center;
  font-family: var(--mono); font-size: 10.5px; color: var(--accent); text-align: center;
}
.arch-link::before {
  content: ""; position: absolute; left: 6px; right: 6px; top: 50%; height: 1px;
  background-image: linear-gradient(90deg, var(--accent-line) 50%, transparent 50%);
  background-size: 7px 1px;
}
.arch-link::after {
  content: ""; position: absolute; right: 5px; top: calc(50% - 3px);
  border-left: 6px solid var(--accent); border-block: 3.5px solid transparent;
}
.arch-link span { position: relative; background: var(--surface); padding: 2px 4px; margin-top: -28px; }
.arch-link i {
  position: absolute; top: calc(50% - 3px); left: 6px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
  animation: packet 2.6s var(--ease) infinite;
}
@keyframes packet { 0% { left: 6px; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { left: calc(100% - 14px); opacity: 0; } }
@media (max-width: 900px) {
  .arch { flex-direction: column; }
  .arch-node { flex: none; }
  .arch-link { flex: 0 0 52px; }
  .arch-link::before { left: 50%; right: auto; top: 6px; bottom: 6px; width: 1px; height: auto;
    background-image: linear-gradient(180deg, var(--accent-line) 50%, transparent 50%); background-size: 1px 7px; }
  .arch-link::after { right: auto; left: calc(50% - 3.5px); top: auto; bottom: 5px; border-left: 3.5px solid transparent; border-right: 3.5px solid transparent; border-top: 6px solid var(--accent); border-bottom: 0; }
  .arch-link span { margin: 0 0 0 110px; background: none; }
  .arch-link i { left: calc(50% - 3px); top: 6px; animation-name: packet-v; }
  @keyframes packet-v { 0% { top: 6px; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { top: calc(100% - 14px); opacity: 0; } }
}

/* Screens gallery */
.screens {
  display: grid; grid-auto-flow: column; grid-auto-columns: clamp(150px, 20vw, 220px); gap: 18px;
  overflow-x: auto; padding: 4px 4px 20px; scroll-snap-type: x mandatory;
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
.screens { align-items: start; }
.screens figure { align-content: start; margin: 0; scroll-snap-align: start; display: grid; gap: 12px; }
.screens .phone { width: 100%; box-shadow: var(--shadow-md); }
.screens figcaption { font-size: 13px; color: var(--muted); }
.screens-wide { margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); }

.cs-next {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: clamp(28px, 4vw, 44px); border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); transition: border-color .3s var(--ease), box-shadow .3s var(--ease);
  margin-top: clamp(32px, 5vw, 56px);
}
.cs-next:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.cs-next small { font-family: var(--mono); font-size: 12px; color: var(--faint); letter-spacing: .06em; text-transform: uppercase; }
.cs-next strong { display: block; margin-top: 6px; font-size: clamp(24px, 3.4vw, 36px); letter-spacing: -0.03em; font-weight: 600; }
.cs-next .go { width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--border-strong); display: grid; place-items: center; flex: none; transition: background-color .25s, color .25s, border-color .25s; }
.cs-next .go svg { width: 20px; height: 20px; }
.cs-next:hover .go { background: var(--text); color: var(--bg); border-color: var(--text); }

.note, .cs-content > p.note { font-size: 13px; color: var(--faint); }

/* 404 */
.lost { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: var(--gutter); }
.lost h1 { font-size: clamp(64px, 14vw, 140px); letter-spacing: -0.06em; }
.lost p { color: var(--muted); margin: 12px 0 28px; }

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .js .reveal { opacity: 1; transform: none; }
  .flow path.live, .arch-link i, .hero-status .pulse::after { display: none; }
}

/* Phone frame that follows the screenshot's own aspect ratio */
.phone.auto { aspect-ratio: auto; }
.phone.auto img { height: auto; }
.project:not(.featured) .project-visual { padding: 32px 24px 72px; }
.media-pair .phone:last-child { margin-top: 48px; }
@media (max-width: 560px) { .media-pair { padding: 24px 8px; gap: 14px; } .media-pair .phone { width: 40%; } }
.media-pair.trio { gap: clamp(10px, 1.6vw, 20px); }
.media-pair.trio .phone { width: clamp(92px, 10.5vw, 150px); }
.media-pair.trio .phone:nth-child(2) { margin-top: 48px; }
.media-pair.trio .phone:last-child { margin-top: 0; }
@media (max-width: 560px) { .media-pair.trio .phone { width: 30%; } }

/* ==========================================================================
   v2 additions
   ========================================================================== */

/* Proof strip */
.proof-wrap { padding-block: clamp(48px, 6vw, 72px); }
.proof {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px; background: var(--border); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.proof-item { background: var(--surface); padding: clamp(20px, 2.4vw, 28px); display: grid; gap: 6px; align-content: start; }
.proof-item strong { font-size: clamp(26px, 3vw, 34px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.05; }
.proof-item span { font-weight: 500; font-size: 15px; }
.proof-item small { color: var(--muted); font-size: 13.5px; line-height: 1.5; }
@media (max-width: 900px) { .proof { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .proof-item strong { font-size: 22px; } .proof-item small { font-size: 12.5px; } }

/* Data-flow chain */
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; }
.chain span { padding: 6px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); white-space: nowrap; }
.chain i { font-style: normal; color: var(--accent); }
.breakdown .wide { grid-column: 1 / -1; }

/* Technology groups */
.tech-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px; background: var(--border); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.tech-group { background: var(--surface); padding: clamp(22px, 2.6vw, 30px); display: grid; gap: 14px; align-content: start; }
.tech-group h3 {
  font-family: var(--mono); font-size: 11.5px; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--faint);
}
.tech-group ul { display: flex; flex-wrap: wrap; gap: 6px; }
.tech-group li { font-size: 14.5px; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
@media (max-width: 900px) { .tech-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .tech-grid { grid-template-columns: 1fr; } }

/* Education */
.edu-head { margin: clamp(48px, 6vw, 72px) 0 20px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.edu-head h3 { font-size: 20px; letter-spacing: -0.02em; }
.edu { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.edu-item { padding: 20px 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); display: grid; gap: 4px; }
.edu-item time { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.edu-item h4 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.edu-item p { font-size: 14px; color: var(--muted); }
@media (max-width: 640px) { .edu { grid-template-columns: 1fr; } }

/* Contact use cases */
.contact-cases { margin-top: 28px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 560px; }
.contact-case {
  padding: 16px 18px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--bg) 16%, var(--text));
  background: color-mix(in srgb, var(--bg) 4%, var(--text));
}
.contact-case h3 { font-size: 15px; letter-spacing: -0.01em; }
.contact-case p { margin-top: 4px; font-size: 14px; color: color-mix(in srgb, var(--bg) 68%, var(--text)); }
.contact-lines.secondary { font-size: 13.5px; }
@media (max-width: 480px) { .contact-cases { grid-template-columns: 1fr; } }

/* Case studies: sticky section labels + page transitions */
@media (min-width: 761px) {
  .cs-section > h2 { position: sticky; top: calc(var(--nav-h) + 28px); align-self: start; }
}
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .22s var(--ease) both; }
::view-transition-new(root) { animation: vt-in .38s var(--ease) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}
.breakdown .chain { font-size: 12px; color: var(--text); margin-top: 4px; }
.proof-wrap + .section { padding-top: clamp(32px, 4vw, 56px); }
.project-index { flex-wrap: wrap; row-gap: 4px; }
@media (max-width: 520px) {
  .hero-ctas .btn { flex: 1 1 100%; }
  .hero-ctas .btn-ghost { margin-top: -4px; }
}

/* Hero: open-source contributions */
.oss { margin-top: 28px; max-width: 600px; }
.oss-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 10px; }
.oss-title {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.oss-title svg { width: 15px; height: 15px; color: var(--text); }
.oss-all { font-size: 13px; color: var(--muted); transition: color .2s var(--ease); }
.oss-all:hover { color: var(--accent); }
.oss-cards, .oss-review { list-style: none; margin: 0; padding: 0; }
.oss-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.oss-card {
  height: 100%; display: flex; flex-direction: column; gap: 6px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.oss-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.oss-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.oss-card-top strong { font-size: 14px; font-weight: 500; letter-spacing: -0.01em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oss-card-desc { font-size: 13px; line-height: 1.45; color: var(--muted); }
.oss-card-meta { margin-top: auto; display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--faint); }
.oss-pr { font-family: var(--mono); white-space: nowrap; }
.oss-card:hover .oss-pr { color: var(--accent); }
.oss-badge {
  flex: none; font-family: var(--mono); font-size: 10.5px; line-height: 1; font-weight: 500;
  padding: 4px 7px; border-radius: 999px;
  color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
}
.oss-badge.is-review { color: var(--faint); background: transparent; border-color: var(--border-strong); }
.oss-review { margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 12.5px; color: var(--faint); }
.oss-review a { color: inherit; transition: color .2s var(--ease); }
.oss-review a:hover { color: var(--text); }
@media (max-width: 520px) {
  /* Swipeable row on phones; the page itself never scrolls sideways */
  .oss-cards {
    grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 84%;
    overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; contain: inline-size;
    margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter);
    scroll-padding-inline: var(--gutter);
  }
  .oss-cards::-webkit-scrollbar { display: none; }
  .oss-cards li { scroll-snap-align: start; }
}
/* Laptop-height screens: fit the whole hero (incl. open-source row) in the first view */
@media (min-width: 961px) and (max-height: 1100px) {
  .hero { padding-top: calc(var(--nav-h) + clamp(20px, 3vh, 32px)); padding-bottom: clamp(40px, 5vh, 56px); }
  .hero-status { margin-bottom: 18px; }
  .hero h1 { font-size: clamp(38px, min(4.4vw, 7.4vh), 60px); }
  .hero-lede { margin-top: 16px; font-size: clamp(16px, 1.3vw, 17px); line-height: 1.55; }
  .oss { margin-top: 20px; }
  .oss-card { padding: 10px 12px; gap: 4px; }
  .hero-ctas { margin-top: 20px; }
}
/* Desktop: hero owns the first screen; the next section starts below the fold */
@media (min-width: 961px) {
  .hero { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; justify-content: center; }
}
/* Tech strip: accent ribbon, centred under the hero (accent swaps to the lighter orange in dark mode) */
.stack-strip { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.stack-strip .container { justify-content: center; }
.stack-strip .lead { color: color-mix(in srgb, var(--accent-ink) 78%, transparent); }
.stack-strip ul { justify-content: center; gap: 8px clamp(4px, 1vw, 12px); }
.stack-strip li {
  color: var(--accent-ink); padding: 7px 14px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent-ink) 22%, transparent);
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.stack-strip li:hover { background: var(--accent-ink); color: var(--accent); border-color: var(--accent-ink); transform: translateY(-2px); }
@media (max-width: 760px) {
  .stack-strip .container { align-items: center; text-align: center; }
}
@media (prefers-reduced-motion: reduce) { .stack-strip li:hover { transform: none; } }
