/* ============================================================
   USMAN GHANI — PORTFOLIO
   Tokens → Base → Layout → Sections → Components → Responsive
   ============================================================ */

/* ---------- TOKENS ---------- */
:root {
  --font-sans: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Space Grotesk", ui-sans-serif, system-ui, sans-serif; /* the site uses one typeface throughout */
  --font-grid: "Space Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; /* only where columns must line up */

  --bg: #0a0e14;
  --bg-2: #0f141c;
  --bg-3: #151b25;
  --panel: rgba(21, 27, 37, .72);
  --line: rgba(148, 163, 184, .12);
  --line-2: rgba(148, 163, 184, .22);
  --text: #e6edf3;
  --text-2: #9aa7b8;
  --text-3: #7c8a9f;                      /* 4.6:1+ on every dark surface it sits on */

  --accent: #00e5a0;
  --accent-2: #7c9cff;
  --accent-3: #ff6b9d;
  --accent-glow: rgba(0, 229, 160, .35);
  --warn: #f5c542;

  --code-k: #7c9cff;
  --code-s: #00e5a0;
  --code-n: #f5c542;
  --code-b: #ff6b9d;
  --code-c: #5c6b7f;

  --r-sm: 8px;
  --r: 14px;
  --r-lg: 22px;

  --shadow: 0 20px 60px -20px rgba(0, 0, 0, .7);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --nav-h: 68px;
  --gutter: clamp(20px, 6vw, 96px);
}

/* light = coffee paper: beige stock, cream cards, espresso ink */
[data-theme="light"] {
  --bg: #efe4cf;
  --bg-2: #f8f0e0;
  --bg-3: #e6d8bd;
  --panel: rgba(248, 240, 224, .8);
  --line: rgba(92, 62, 32, .14);
  --line-2: rgba(92, 62, 32, .26);
  --text: #2b1d12;
  --text-2: #5b4633;
  --text-3: #705a44;                      /* 4.6:1+ on every light surface it sits on */

  --accent: #5c3a1e;                      /* dark coffee: stands in for dark mode's green */
  --accent-2: #4552c4;
  --accent-3: #b9512c;
  --accent-glow: rgba(92, 58, 30, .25);

  --code-k: #4552c4;
  --code-s: #7a4a22;
  --code-n: #a0621a;
  --code-b: #b3432a;
  --code-c: #917a61;

  --shadow: 0 20px 60px -24px rgba(74, 46, 20, .3);
}

/* ---------- BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background .4s, color .4s;
}
body.no-scroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--bg); }
kbd {
  font-family: var(--font-mono);
  font-size: .72em;
  padding: 2px 6px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg-3);
  color: var(--text-2);
}
code { font-family: var(--font-mono); }
.grow { flex: 1; }

/* ---------- BACKGROUND ---------- */
.bg {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.noise {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}
[data-theme="light"] .noise { opacity: .11; mix-blend-mode: multiply; } /* paper grain */

/* ---------- BOOT SCREEN ---------- */
.boot {
  position: fixed; inset: 0; z-index: 1000;
  background: #05080c;
  display: grid; place-items: center;
  transition: opacity .6s var(--ease), visibility .6s;
}
.boot.done { opacity: 0; visibility: hidden; }
.boot-inner { width: min(560px, 90vw); }
.boot-log {
  margin: 0 0 18px;
  font-family: var(--font-mono);
  font-size: clamp(11px, 2.6vw, 13.5px);
  line-height: 1.7;
  color: #9aa7b8;
  min-height: 12em;
  white-space: pre-wrap;
}
.boot-log .ok { color: #00e5a0; }
.boot-log .warn { color: #f5c542; }
.boot-log .dim { color: #5c6b7f; }
.boot-bar { height: 3px; background: rgba(255,255,255,.08); border-radius: 3px; overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #00e5a0, #7c9cff); transition: width .25s; }
.boot-skip {
  margin-top: 16px; font-family: var(--font-mono); font-size: 12px; color: #5c6b7f;
  border: 1px solid rgba(255,255,255,.1); padding: 6px 12px; border-radius: 6px;
}
.boot-skip:hover { color: #e6edf3; border-color: rgba(255,255,255,.3); }

/* ---------- CURSOR ---------- */
.cursor, .cursor-ring { display: none; }
@media (hover: hover) and (pointer: fine) {
  body, body * { cursor: none !important; }
  input, textarea, [contenteditable] { cursor: text !important; } /* you still see where you type */
  .cursor {
    display: block; position: fixed; z-index: 999; pointer-events: none;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent);
    left: 0; top: 0; transform: translate(-50%, -50%);
    mix-blend-mode: difference;
  }
  .cursor-ring {
    display: block; position: fixed; z-index: 999; pointer-events: none;
    width: 36px; height: 36px; border-radius: 50%;
    border: 1.5px solid var(--accent);
    left: 0; top: 0; transform: translate(-50%, -50%);
    opacity: .6;
    transition: width .25s, height .25s, opacity .25s, background .25s;
  }
  body.cursor-hover .cursor-ring { width: 56px; height: 56px; opacity: .9; background: var(--accent-glow); }
  body.cursor-hidden .cursor, body.cursor-hidden .cursor-ring { opacity: 0; }
}

/* ---------- PROGRESS ---------- */
.progress {
  position: fixed; top: 0; left: 0; z-index: 200;
  height: 2px; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ---------- NAV ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 var(--gutter);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  border-bottom: 1px solid transparent;
  transition: transform .35s var(--ease), border-color .3s, background .3s;
}
.nav.scrolled { border-bottom-color: var(--line); }
.nav.hide { transform: translateY(-100%); }
.logo {
  font-family: var(--font-mono); font-weight: 700; font-size: 17px;
  display: inline-flex; align-items: center; letter-spacing: -.01em;
}
.logo-prompt { color: var(--accent); }
.logo-cursor { color: var(--accent); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.nav-links { display: flex; gap: 6px; }
.nav-links a {
  font-family: var(--font-mono); font-size: 13.5px; color: var(--text-2);
  padding: 8px 12px; border-radius: var(--r-sm);
  transition: color .2s, background .2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--bg-3); }
.nav-idx { color: var(--accent); margin-right: 4px; font-size: 11px; }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.kbd-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2);
  padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--bg-3); transition: border-color .2s, color .2s;
}
.kbd-btn:hover { border-color: var(--line-2); color: var(--text); }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg-3);
  color: var(--text-2); transition: color .2s, border-color .2s, transform .2s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }
.icon-btn:active { transform: scale(.94); }
.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }
.burger { display: none; flex-direction: column; justify-content: center; align-items: center; gap: 4.5px; }
.burger span { width: 18px; height: 2px; background: currentColor; border-radius: 2px; transition: transform .3s var(--ease), opacity .2s; }
.burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* ---------- LAYOUT ---------- */
main { position: relative; z-index: 2; }
.section {
  max-width: 1120px; margin: 0 auto;
  padding: clamp(72px, 10vw, 128px) var(--gutter);
}
.section-title {
  display: flex; align-items: center; gap: 14px;
  font-family: var(--font-mono); font-size: clamp(22px, 3.2vw, 30px); font-weight: 700;
  margin: 0 0 clamp(28px, 4vw, 48px); letter-spacing: -.02em;
}
.section-idx { color: var(--accent); font-size: .75em; font-weight: 500; }
.section-line { flex: 1; height: 1px; background: var(--line-2); max-width: 320px; margin-left: 8px; }
.section-lead { color: var(--text-2); margin: -20px 0 32px; max-width: 60ch; }

/* grid children must be allowed to shrink below their pre-formatted content */
.hero-grid > *, .about-grid > *, .contact-grid > *, .projects > *, .skills-grid > *, .case-grid > * { min-width: 0; }

/* reveal on scroll */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity .8s var(--ease), transform .8s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- BUTTONS ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-weight: 600; font-size: 14px;
  padding: 13px 22px; border-radius: var(--r-sm); overflow: hidden;
  transition: transform .2s var(--ease), box-shadow .3s, color .2s, border-color .2s;
  isolation: isolate;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #04110c; box-shadow: 0 8px 30px -10px var(--accent-glow); }
.btn-primary::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.35) 50%, transparent 70%);
  transform: translateX(-120%); transition: transform .6s var(--ease);
}
.btn-primary:hover::before { transform: translateX(120%); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 40px -12px var(--accent-glow); }
.btn-primary svg { transition: transform .25s var(--ease); }
.btn-primary:hover svg { transform: translateX(4px); }
.btn-ghost { border: 1px solid var(--line-2); color: var(--text); background: transparent; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }

/* ---------- HERO ---------- */
.hero {
  position: relative; min-height: 100svh;
  display: flex; align-items: center;
  padding: calc(var(--nav-h) + 40px) var(--gutter) 80px;
  max-width: 1120px; margin: 0 auto;
  overflow-x: clip; /* the showcase spotlight is wider than a phone screen; it must not widen the page */
}
.hero-grid {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: clamp(32px, 6vw, 72px);
  align-items: center; width: 100%; min-width: 0; /* flex item: allow shrinking below fr max-content */
}
.hero-title { margin: 0 0 14px; line-height: 1.02; letter-spacing: -.035em; font-weight: 800; }
.hero-hi { display: block; font-size: clamp(20px, 2.6vw, 26px); font-weight: 500; color: var(--text-2); letter-spacing: 0; margin-bottom: 6px; font-family: var(--font-mono); }
.hero-name {
  display: inline-block; position: relative;
  font-size: clamp(44px, 8.4vw, 88px);
  background: linear-gradient(100deg, var(--text) 0%, var(--text) 45%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-name.glitch::before, .hero-name.glitch::after {
  content: attr(data-text); position: absolute; left: 0; top: 0; width: 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  clip-path: inset(0 0 0 0);
}
.hero-name.glitch::before { background: var(--accent-3); animation: glitch1 .5s steps(2) both; transform: translate(-3px, 0); }
.hero-name.glitch::after { background: var(--accent-2); animation: glitch2 .5s steps(2) both; transform: translate(3px, 0); }
@keyframes glitch1 { 0% { clip-path: inset(10% 0 80% 0); } 25% { clip-path: inset(60% 0 10% 0); } 50% { clip-path: inset(30% 0 50% 0); } 75% { clip-path: inset(80% 0 5% 0); } 100% { clip-path: inset(0 0 100% 0); } }
@keyframes glitch2 { 0% { clip-path: inset(70% 0 10% 0); } 25% { clip-path: inset(10% 0 70% 0); } 50% { clip-path: inset(50% 0 30% 0); } 75% { clip-path: inset(20% 0 60% 0); } 100% { clip-path: inset(100% 0 0 0); } }
.hero-sub {
  font-family: var(--font-mono); font-size: clamp(16px, 2.4vw, 22px); margin: 0 0 20px;
  color: var(--text); min-height: 1.6em;
}
.hero-prompt { color: var(--accent); margin-right: 8px; }
.typed { color: var(--accent-2); }
.typed-caret { color: var(--accent); animation: blink 1s steps(1) infinite; font-weight: 300; }
.hero-desc { color: var(--text-2); font-size: clamp(15px, 1.7vw, 17px); max-width: 52ch; margin: 0 0 32px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 32px; }
.hero-socials { display: flex; gap: 6px; }
.hero-socials a {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: var(--r-sm);
  color: var(--text-2); border: 1px solid transparent;
  transition: color .2s, transform .25s var(--ease), border-color .2s, background .2s;
}
.hero-socials a:hover { color: var(--accent); transform: translateY(-3px); border-color: var(--line); background: var(--panel); }

.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot.r { background: #ff5f57; } .dot.y { background: #febc2e; } .dot.g { background: #28c840; }
.k { color: var(--code-k); } .s { color: var(--code-s); } .n { color: var(--code-n); } .b { color: var(--code-b); } .c { color: var(--code-c); font-style: italic; }
.f { color: #f5c542; } .t { color: #7cdbff; } .p { color: var(--text-2); }
[data-theme="light"] .f { color: #a0621a; } [data-theme="light"] .t { color: #1f6f8b; }
.scroll-hint { position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%); opacity: .6; transition: opacity .2s; }
.scroll-hint:hover { opacity: 1; }
.mouse { display: block; width: 22px; height: 36px; border: 2px solid var(--text-2); border-radius: 12px; position: relative; }
.mouse span { position: absolute; left: 50%; top: 6px; width: 3px; height: 7px; margin-left: -1.5px; border-radius: 3px; background: var(--accent); animation: wheel 1.6s var(--ease) infinite; }
@keyframes wheel { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(14px); opacity: 0; } }

/* ---------- ABOUT ---------- */
.about-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: clamp(28px, 5vw, 64px); align-items: start; }
.about-text p { color: var(--text-2); font-size: clamp(15px, 1.7vw, 17px); margin: 0 0 18px; }
.about-text em { color: var(--text); font-style: normal; font-family: var(--font-mono); font-size: .92em; background: var(--bg-3); padding: 1px 6px; border-radius: 5px; }
.about-facts { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; }
.about-facts li { display: grid; grid-template-columns: 96px 1fr; gap: 12px; font-size: 14px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.fact-k { font-family: var(--font-mono); color: var(--accent); }
.fact-v { color: var(--text-2); }
.json-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.json-head { display: flex; align-items: center; gap: 8px; padding: 11px 14px; background: var(--bg-3); border-bottom: 1px solid var(--line); font-family: var(--font-mono); font-size: 12px; color: var(--text-2); }
.json-head span:last-child { margin-left: 6px; }
.json-body { margin: 0; padding: 18px; font-size: clamp(12px, 1.3vw, 13.5px); line-height: 1.75; overflow-x: auto; }

/* ---------- SKILLS ---------- */
.skills-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 40px; }
.skill-group {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 22px;
  backdrop-filter: blur(10px); transition: border-color .3s, transform .3s var(--ease);
}
.skill-group:hover { border-color: var(--line-2); transform: translateY(-3px); }
/* light theme: a tan a step darker than the page, so the cards sit apart and the cream tags stand out */
[data-theme="light"] .skill-group { background: rgba(196, 164, 118, .28); border-color: rgba(92, 62, 32, .18); }
[data-theme="light"] .skill-group:hover { border-color: var(--line-2); }
.skill-group h3 { margin: 0 0 14px; font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 10px; text-transform: uppercase; letter-spacing: .08em; }
.sg-icon { color: var(--accent); font-size: 16px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  position: relative; font-family: var(--font-mono); font-size: 13px; padding: 7px 12px;
  border: 1px solid var(--line-2); border-radius: 999px; color: var(--text);
  background: var(--bg-2); cursor: default;
  transition: color .2s, border-color .2s, background .2s, transform .2s var(--ease);
}
.tag:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
/* skill logos: each in its brand colour, or the text colour in a theme where that colour wouldn't read */
.skill-group .tag { display: inline-flex; align-items: center; gap: 7px; padding-left: 10px; }
.ti { width: 15px; height: 15px; flex: none; color: var(--brand, var(--text)); }
.ti-line { color: var(--text-2); }
:where(:root:not([data-theme="light"])) .ti[data-lo~="dark"], :where([data-theme="light"]) .ti[data-lo~="light"] { color: var(--text); }
.tag:hover :is(.ti-line, .ti-mono) { color: inherit; }
.tag[data-lvl]::after {
  content: attr(data-lvl); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translate(-50%, 4px);
  font-size: 11px; padding: 4px 8px; border-radius: 6px; background: var(--text); color: var(--bg);
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s var(--ease);
}
.tag[data-lvl]:hover::after { opacity: 1; transform: translate(-50%, 0); }

/* ---------- TERMINAL ---------- */
.terminal {
  background: #0b0f16; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
  font-family: var(--font-mono); box-shadow: var(--shadow); color: #cfd8e3;
}
[data-theme="light"] .terminal { background: #2a1f16; } /* espresso */
[data-theme="light"] .case-backdrop, [data-theme="light"] .palette-backdrop { background: rgba(43, 29, 18, .55); }
.term-bar { display: flex; align-items: center; gap: 8px; padding: 11px 14px; background: rgba(255,255,255,.04); border-bottom: 1px solid rgba(255,255,255,.06); font-size: 12px; }
.term-title { margin-left: 8px; color: #9aa7b8; }
.term-hint { margin-left: auto; color: #5c6b7f; }
.term-hint code { color: #00e5a0; }
.term-body { padding: 14px 16px 6px; font-size: 13px; line-height: 1.65; max-height: 320px; overflow-y: auto; }
.term-line { white-space: pre-wrap; word-break: break-word; }
.term-cmd { color: #e6edf3; }
.term-cmd .term-ps1 { color: #00e5a0; }
.term-cmd .term-path { color: #7c9cff; }
.term-out { color: #9aa7b8; }
.term-out b { color: #e6edf3; }
.term-out a { color: #7c9cff; text-decoration: underline; text-underline-offset: 3px; }
.term-err { color: #ff6b9d; }
.term-ok { color: #00e5a0; }
.term-input { display: flex; align-items: center; gap: 8px; padding: 6px 16px 14px; font-size: 13px; }
.term-input label { white-space: nowrap; }
.term-ps1 { color: #00e5a0; } .term-path { color: #7c9cff; }
.term-input input { flex: 1; background: none; border: 0; outline: none; color: #e6edf3; caret-color: #00e5a0; min-width: 0; }
.term-input input::placeholder { color: #818c9a; } /* 4.7:1+ on both terminal backgrounds */

/* ---------- PROJECTS ---------- */
.project-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 28px; }
.chip {
  font-family: var(--font-mono); font-size: 13px; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--text-2); transition: all .2s;
}
.chip::before { content: "#"; color: var(--accent); margin-right: 2px; }
.chip:hover { color: var(--text); border-color: var(--text-3); }
.chip.active { background: var(--accent); color: #04110c; border-color: var(--accent); }
.chip.active::before { color: #04110c; }
.projects { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.project {
  position: relative; display: flex; gap: 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 22px;
  backdrop-filter: blur(10px); overflow: hidden;
  transition: transform .35s var(--ease), border-color .3s, box-shadow .35s, opacity .3s;
}
.project::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(500px circle at var(--mx, 50%) var(--my, 50%), rgba(124,156,255,.12), transparent 45%);
}
.project:hover { transform: translateY(-6px); border-color: var(--line-2); box-shadow: var(--shadow); }
.project:hover::before { opacity: 1; }
.project:has(.project-open:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.project.featured { grid-column: 1 / -1; background: linear-gradient(135deg, var(--panel), color-mix(in srgb, var(--accent) 6%, var(--panel))); }
.project.hidden { display: none; }
.project-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.project-head { display: flex; align-items: center; gap: 10px; }
.project-badge { font-family: var(--font-mono); font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--accent); color: #04110c; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.project-src {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: var(--r-sm); color: var(--text-2); transition: color .2s, background .2s;
}
.project-src:hover { color: var(--accent); background: var(--bg-3); }
.project-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; font-family: var(--font-mono); }
.project-open { font: inherit; letter-spacing: inherit; text-align: left; padding: 0; }
.project-open::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.project-open:focus-visible { outline: none; }
.project-desc { margin: 0; color: var(--text-2); font-size: 14.5px; }
.project-arch { margin: 0; font-family: var(--font-mono); font-size: 12px; color: var(--text-3); }
.project-arch::before { content: "▸ "; color: var(--accent); }
.project-stack { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.project-stack li { font-family: var(--font-mono); font-size: 11.5px; color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 10%, transparent); padding: 3px 9px; border-radius: 6px; }
.project-meta { display: flex; align-items: center; gap: 14px; margin-top: auto; font-family: var(--font-mono); font-size: 12px; color: var(--text-3); padding-top: 10px; border-top: 1px dashed var(--line); }
.project-meta .lang { display: inline-flex; align-items: center; gap: 6px; }
.project-meta .lang i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.project-cta { margin-left: auto; color: var(--accent); transition: transform .25s var(--ease); }
.project:hover .project-cta { transform: translateX(4px); }
/* featured: a phone (or code) peeking in from the right edge */
.project-shot { flex: 0 0 38%; max-width: 360px; align-self: stretch; display: flex; justify-content: center; align-items: flex-start; margin: -22px -22px -22px 0; padding: 22px 22px 0; overflow: hidden; }

/* ---------- PHONE FRAME + CAROUSEL ---------- */
.phone {
  position: relative; width: min(300px, 100%); aspect-ratio: 9 / 20; margin: 0 auto; padding: 9px;
  border-radius: 40px; background: #07090d; border: 1px solid var(--line-2);
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(255,255,255,.05);
}
.phone-sm { width: 172px; flex: none; padding: 6px; border-radius: 28px; }
.phone > img, .phone > video { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 31px; background: #000; overflow: hidden; }
.phone-sm > img { border-radius: 22px; object-position: top; }

/* ---------- CASE STUDY ---------- */
.case { position: fixed; inset: 0; z-index: 450; display: grid; place-items: center; padding: 24px; }
.case[hidden] { display: none; }
.case-backdrop { position: absolute; inset: 0; background: rgba(3,6,10,.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: fade .25s; }
.case-box {
  position: relative; width: min(1040px, 100%); max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-lg); outline: none;
  box-shadow: 0 40px 100px -30px rgba(0,0,0,.8); animation: pop .3s var(--ease);
}
.case-bar {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px;
  background: color-mix(in srgb, var(--bg-3) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.case-bar .icon-btn { width: 34px; height: 34px; font-family: var(--font-mono); }
.player-fs { position: absolute; right: 10px; bottom: 10px; z-index: 2; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: rgba(10, 14, 20, .55); border: 1px solid rgba(255, 255, 255, .22); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.case-path { margin-left: 8px; font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case-grid { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: clamp(24px, 4vw, 52px); padding: clamp(20px, 4vw, 40px); align-items: start; }
.case-grid.no-stage { grid-template-columns: 1fr; }
.case-stage { position: sticky; top: 76px; }
/* keep the whole phone on screen: its height tracks the viewport */
.case-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.case-chip { font-family: var(--font-mono); font-size: 11.5px; padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.case-chip.dim { background: var(--bg-3); color: var(--text-3); }
.case-title { margin: 0 0 14px; font-size: clamp(28px, 4vw, 40px); line-height: 1.1; letter-spacing: -.03em; }
.case-desc { margin: 0 0 26px; color: var(--text-2); font-size: 16px; }
.case-h { margin: 0 0 10px; font-family: var(--font-mono); font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); }
.case-h::before { content: "// "; color: var(--accent); }
.case-arch { display: flex; flex-direction: column; gap: 8px; margin: 0 0 26px; }
.case-arch span { font-family: var(--font-mono); font-size: 13.5px; padding: 10px 14px; background: var(--bg-3); border-left: 2px solid var(--accent); border-radius: 0 8px 8px 0; }
.case-info .project-stack { margin-bottom: 28px; }
.case-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.qr { display: flex; align-items: center; gap: 14px; margin: 20px 0 0; font-family: var(--font-mono); font-size: 12px; color: var(--text-3); }
.qr img { width: 120px; height: 120px; padding: 8px; background: #fff; border-radius: 10px; }
@media (hover: none), (pointer: coarse) { .qr { display: none; } }
/* ---------- ASCII PORTRAIT ---------- */
.ascii-card { margin: 0; }
.ascii {
  margin: 0; padding: 14px; font-family: var(--font-mono); font-size: 7px; line-height: 1; letter-spacing: 0;
  white-space: pre; overflow: hidden; color: var(--accent); cursor: pointer; user-select: none;
}
[data-theme="light"] .ascii { color: #3b2616; } /* dark coffee ink on the paper theme */
.term-ascii { line-height: 1; font-size: 10px; color: #00e5a0; margin: 4px 0 8px; }


/* ---------- CONTACT ---------- */
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(28px, 5vw, 64px); align-items: start; }
.contact-big { font-size: clamp(34px, 4.6vw, 52px); line-height: 1.05; letter-spacing: -.035em; font-weight: 800; margin: 0 0 18px; text-wrap: balance; }
.grad { background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3)); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shift 6s linear infinite; }
@keyframes shift { to { background-position: 200% 0; } }
.contact-copy p { color: var(--text-2); max-width: 44ch; margin: 0 0 28px; }
.contact-links { display: grid; gap: 10px; }
.contact-row {
  display: grid; grid-template-columns: 80px 1fr auto; gap: 12px; align-items: center;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel);
  font-family: var(--font-mono); font-size: 13.5px; transition: border-color .2s, transform .25s var(--ease);
}
.contact-row:hover { border-color: var(--accent); transform: translateX(4px); }
.cr-k { color: var(--accent); }
.cr-v { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-a { color: var(--text-3); font-size: 12px; }
.contact-row:hover .cr-a { color: var(--accent); }
.contact-form { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.form-head { display: flex; align-items: center; gap: 8px; padding: 11px 14px; background: var(--bg-3); border-bottom: 1px solid var(--line); font-family: var(--font-mono); font-size: 12px; color: var(--text-2); }
.form-head span:last-child { margin-left: 6px; }
.contact-form label { display: flex; gap: 14px; padding: 6px 16px; border-bottom: 1px solid var(--line); font-family: var(--font-mono); }
.contact-form label:focus-within { background: color-mix(in srgb, var(--accent) 5%, transparent); outline: 2px solid var(--accent); outline-offset: -2px; }
.ln { color: var(--text-3); font-size: 12px; width: 14px; padding-top: 10px; text-align: right; }
.contact-form input, .contact-form textarea { flex: 1; min-width: 0; background: none; border: 0; outline: none; padding: 8px 0; font-size: 14px; resize: vertical; }
.contact-form ::placeholder { color: var(--text-3); }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; }
.form-hint { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); }
.send-arrow { transition: transform .25s var(--ease); }
.btn:hover .send-arrow { transform: translateX(4px); }

/* ---------- FOOTER ---------- */
.footer { position: relative; z-index: 2; text-align: center; padding: 32px var(--gutter) 40px; border-top: 1px solid var(--line); font-family: var(--font-mono); font-size: 12.5px; color: var(--text-3); }
.footer p { margin: 4px 0; }
.footer b { color: var(--text-2); }
.footer-hint { font-size: 11.5px; }

/* ---------- COMMAND PALETTE ---------- */
.palette { position: fixed; inset: 0; z-index: 500; display: grid; place-items: start center; padding: 12vh 16px 16px; }
.palette[hidden] { display: none; }
.palette-backdrop { position: absolute; inset: 0; background: rgba(3,6,10,.6); backdrop-filter: blur(6px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.palette-box {
  position: relative; width: min(600px, 100%); background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: var(--r); box-shadow: 0 30px 80px -20px rgba(0,0,0,.8); overflow: hidden;
  animation: pop .25s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-10px) scale(.98); } }
.palette-search { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--text-2); }
.palette-search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; font-size: 16px; color: var(--text); }
.palette-list { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow-y: auto; }
.palette-list li {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--r-sm);
  font-size: 14px; cursor: pointer; color: var(--text-2);
}
.palette-list li .pi { width: 26px; text-align: center; font-size: 16px; }
.palette-list li .pl { flex: 1; color: var(--text); }
.palette-list li .pl small { display: block; font-size: 12px; color: var(--text-3); }
.palette-list li .pk { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }
.palette-list li.sel { background: var(--bg-3); }
.palette-list li.sel .pk { color: var(--accent); }
.palette-list .empty { color: var(--text-3); justify-content: center; cursor: default; font-family: var(--font-mono); font-size: 13px; }
.palette-list .group { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); padding: 10px 12px 4px; cursor: default; }
.palette-foot { display: flex; gap: 18px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-3); font-family: var(--font-mono); }
.palette-foot kbd { margin-right: 2px; }

/* ---------- TOAST / TOTOP ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 600; transform: translate(-50%, 20px);
  padding: 11px 18px; border-radius: 999px; background: var(--text); color: var(--bg);
  font-family: var(--font-mono); font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .3s var(--ease); max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.totop {
  position: fixed; right: 22px; bottom: 22px; z-index: 90; width: 44px; height: 44px; border-radius: 50%;
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--text); font-family: var(--font-mono);
  opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .3s, transform .3s var(--ease), color .2s;
}
.totop.show { opacity: 1; transform: none; pointer-events: auto; }
.totop:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- PARTY MODE (konami) ---------- */
body.party { animation: hue 3s linear infinite; }
@keyframes hue { to { filter: hue-rotate(360deg); } }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1024px) {
  .projects { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; gap: 40px; }
  .hero { padding-top: calc(var(--nav-h) + 28px); }
  .hero-visual { max-width: 560px; }
  .about-grid, .contact-grid { grid-template-columns: 1fr; }
  .section-line { max-width: 120px; }
  .kbd-btn-text { display: none; }
  .case-grid { grid-template-columns: 1fr; }
  .case-stage { position: static; }
}
@media (max-width: 760px) {
  :root { --nav-h: 60px; }
  .burger { display: flex; }
  .kbd-btn { display: none; }
  /* nav has backdrop-filter, so it is the containing block for this fixed panel */
  .nav-links {
    position: fixed; top: 100%; left: 0; right: 0;
    height: calc(100vh - var(--nav-h)); height: calc(100dvh - var(--nav-h));
    flex-direction: column; gap: 4px; padding: 20px var(--gutter);
    background: var(--bg); border-top: 1px solid var(--line);
    transform: translateX(100%); transition: transform .35s var(--ease); z-index: 99;
    overflow-y: auto;
  }
  input, textarea { font-size: 16px; }
  .nav-links.open { transform: none; }
  .nav-links a { font-size: 18px; padding: 14px 12px; border-bottom: 1px solid var(--line); border-radius: 0; }
  .nav-idx { font-size: 13px; margin-right: 10px; }
  .skills-grid { grid-template-columns: 1fr; }
  .projects { grid-template-columns: 1fr; }
  .project { flex-direction: column; }
  .project-shot { order: -1; flex: none; max-width: none; height: 210px; margin: -22px -22px 0; padding: 20px 22px 0; background: color-mix(in srgb, var(--accent) 5%, transparent); border-bottom: 1px solid var(--line); }
  .case { padding: 0; }
  .case-box { width: 100%; height: 100%; max-height: none; border-radius: 0; border: 0; }
  .contact-row { grid-template-columns: 1fr auto; gap: 4px 12px; }
  .cr-k { grid-column: 1 / -1; } /* key on top; value and its action (copy / open / download) share the second line */
  .about-facts li { grid-template-columns: 1fr; gap: 2px; }
  .scroll-hint { display: none; }
  .hero-cta .btn { flex: 1; justify-content: center; }
  .hero-cta .btn-primary { flex-basis: 100%; } /* the main action gets its own row; contact and resume share the next */
  .totop { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); }
  .footer-hint { display: none; }
  .term-hint { display: none; }
  .term-body { max-height: 260px; }
}
@media (max-width: 420px) {
  .hero-name { font-size: clamp(38px, 12vw, 48px); }
  .hero-cta .btn { padding: 13px 14px; font-size: 13px; white-space: nowrap; }
}
/* Big screens */
@media (min-width: 1500px) {
  .section, .hero { max-width: 1240px; }
}

/* ---------- COFFEE ACCENTS (light theme) ----------
   Dark mode's green becomes dark coffee via --accent. These cover the spots
   where green is hardcoded or where text sits on the accent. */
[data-theme="light"] .btn-primary,
[data-theme="light"] .chip.active,
[data-theme="light"] .chip.active::before,
[data-theme="light"] .project-badge { color: #f8f0e0; }
[data-theme="light"] .cursor { mix-blend-mode: normal; }
/* the terminal stays dark, so its green turns caramel instead of dark brown */
[data-theme="light"] .term-ps1,
[data-theme="light"] .term-ok,
[data-theme="light"] .term-hint code,
[data-theme="light"] .term-ascii { color: #d9a066; }
[data-theme="light"] .term-input input { caret-color: #d9a066; }
/* the boot screen follows the light theme: cream paper, coffee ink */
[data-theme="light"] .boot { background: var(--bg); }
[data-theme="light"] .boot-log { color: var(--text-2); }
[data-theme="light"] .boot-log .ok { color: var(--accent); font-weight: 700; }
[data-theme="light"] .boot-log .warn { color: var(--accent-3); }
[data-theme="light"] .boot-log .dim { color: var(--text-3); }
[data-theme="light"] .boot-bar { background: var(--line); }
[data-theme="light"] .boot-bar span { background: linear-gradient(90deg, var(--accent), #a8743f); }
[data-theme="light"] .boot-skip { color: var(--text-3); border-color: var(--line-2); }
[data-theme="light"] .boot-skip:hover { color: var(--text); border-color: var(--text-3); }
/* powering off: the screen collapses into a coffee-coloured line instead of a white flash */
[data-theme="light"] .boot.done { animation-name: crtOffLight; }
@keyframes crtOffLight {
  0%   { transform: scale(1, 1); }
  45%  { transform: scale(1, .004); }
  60%  { transform: scale(1, .004); background-color: var(--accent); box-shadow: 0 0 40px 8px var(--accent-glow); }
  85%  { transform: scale(.18, .004); background-color: var(--accent); opacity: 1; }
  100% { transform: scale(0, .004); opacity: 0; }
}

/* ---------- PROJECT CARDS: title row ---------- */
.project-head .project-title { min-width: 0; }
.project-links { margin-left: auto; display: flex; gap: 2px; position: relative; z-index: 2; }
/* card screens: two stacked layers crossfade while the pointer rests on the card */
.phone-sm > .card-scr { position: absolute; top: 6px; left: 6px; width: calc(100% - 12px); height: calc(100% - 12px); opacity: 0; transition: opacity .6s var(--ease); }
.phone-sm > .card-scr.on { opacity: 1; }

/* ---------- DEMO PLAYER ---------- */
.case { --phone-w: min(300px, 100%, calc((100vh - 230px) * 9 / 20)); }
/* wide explainer: full width, but short enough that the details peek out below */
.case { --screen-w: min(100%, calc((100vh - 290px) * 16 / 9)); }
@supports (height: 100dvh) { .case { --phone-w: min(300px, 100%, calc((100dvh - 230px) * 9 / 20)); --screen-w: min(100%, calc((100dvh - 290px) * 16 / 9)); } }
.case .phone { width: var(--phone-w); }
.player .phone, .player .screen { position: relative; }
.screen { width: var(--screen-w); margin: 0 auto; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: #000; border: 1px solid var(--line-2); box-shadow: var(--shadow); }
.screen > video { display: block; width: 100%; height: 100%; object-fit: cover; }
.player video { cursor: pointer; transition: filter .35s var(--ease); }
.player.paused video { filter: brightness(.78); }
.player-toggle {
  position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; background: rgba(10, 14, 20, .5); border: 1px solid rgba(255, 255, 255, .22);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; transform: scale(.85); pointer-events: none; transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.player-toggle svg { margin-left: 3px; }
.player.paused .player-toggle { opacity: 1; transform: none; pointer-events: auto; }
.player.loading .player-toggle { opacity: 0; pointer-events: none; }
/* spinner until the first frame actually plays */
.player:not(.ready):not(.paused) .phone::after,
.player:not(.ready):not(.paused) .screen::after,
.player.loading .phone::after, .player.loading .screen::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .25); border-top-color: #fff; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.player-bar { height: 3px; margin: 16px auto 0; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.player-phone .player-bar { width: var(--phone-w); }
.player-wide .player-bar { width: var(--screen-w); }
.player-bar i { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); }

/* ---------- CASE STUDY LAYOUTS ---------- */
.case-box:has(.no-stage) { width: min(820px, 100%); }
.case-grid.wide-stage { grid-template-columns: 1fr; }
.wide-stage .case-stage { position: static; }
.case-grid.no-stage .case-info, .case-grid.wide-stage .case-info { max-width: 760px; }
.no-stage .case-desc { font-size: 17.5px; }
.no-stage .case-arch, .wide-stage .case-arch { flex-direction: row; flex-wrap: wrap; }
.no-stage .case-arch span, .wide-stage .case-arch span { flex: 1 1 200px; }

/* ---------- CASE STUDY MOTION: open, close, switch ---------- */
@keyframes caseIn { from { opacity: 0; transform: translateY(18px) scale(.985); } }
@keyframes caseOut { to { opacity: 0; transform: translateY(12px) scale(.985); } }
@keyframes sheetIn { from { transform: translateY(100%); } }
@keyframes sheetOut { to { transform: translateY(100%); } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes caseSwap { from { opacity: 0; transform: translateX(calc(var(--dir, 1) * 28px)); } }
.case-box { animation: caseIn .4s var(--ease); }
.case.closing .case-box { animation: caseOut .24s ease forwards; }
.case.closing .case-backdrop { animation: fadeOut .24s ease forwards; }
.case-grid.swap { animation: caseSwap .42s var(--ease); }
@media (max-width: 900px) {
  .case { --phone-w: min(280px, 100%, calc(62vh * 9 / 20)); }
}
@media (max-width: 760px) {
  .case-box { animation: sheetIn .45s var(--ease); }             /* slides up like a native sheet */
  .case.closing .case-box { animation: sheetOut .26s ease-in forwards; }
  .screen { border-radius: 12px; }
  .no-stage .case-desc { font-size: 16px; }
}

/* ---------- FIXED-WIDTH SPOTS: text art and aligned columns need a monospace grid ---------- */
.ascii, .terminal, .boot-log { font-family: var(--font-grid); }

/* ---------- RESUME LINK (nav) ---------- */
.nav-links a.nav-cv { color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); margin-left: 6px; }
.nav-links a.nav-cv:hover { background: var(--accent); color: var(--bg); }
@media (max-width: 760px) { .nav-links a.nav-cv { margin: 12px 0 0; border-radius: var(--r-sm); text-align: center; } }

/* ============================================================
   MOTION
   ============================================================ */

/* boot screen powers off like a CRT: collapses to a glowing line, then blinks out */
.boot.done { opacity: 1; visibility: visible; animation: crtOff .62s cubic-bezier(.7, 0, .3, 1) forwards; }
.boot.done .boot-inner { opacity: 0; transition: opacity .12s; }
@keyframes crtOff {
  0%   { transform: scale(1, 1); }
  45%  { transform: scale(1, .004); }
  60%  { transform: scale(1, .004); background-color: #effff9; box-shadow: 0 0 60px 14px var(--accent-glow); }
  85%  { transform: scale(.18, .004); background-color: #fff; opacity: 1; }
  100% { transform: scale(0, .004); opacity: 0; }
}

/* reveals come into focus as they rise */
.reveal { filter: blur(8px); transition: opacity .9s var(--ease), transform .9s var(--ease), filter .9s var(--ease); }
.reveal.in { filter: none; }

/* list items cascade in after their card appears */
@keyframes riseIn { from { opacity: 0; transform: translateY(10px) scale(.96); } }
.reveal.in :is(.tags, .project-stack, .about-facts, .contact-links) > * {
  animation: riseIn .55s var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 35ms + 200ms);
}

/* section rule lines draw in behind the decoding title */
.section-line { transform: scaleX(0); transform-origin: left; transition: transform 1.1s var(--ease) .25s; }
.section-title.in .section-line { transform: none; }

/* nav: one pill glides between links (desktop; the phone menu keeps its rows) */
@media (min-width: 761px) {
  .nav-links { position: relative; isolation: isolate; }
  .nav-links a:hover, .nav-links a.active { background: transparent; }
  .nav-ink {
    position: absolute; top: 0; left: 0; height: 100%; z-index: -1; pointer-events: none; opacity: 0;
    border-radius: var(--r-sm); background: var(--bg-3); border: 1px solid var(--line);
    transition: transform .45s var(--ease), width .45s var(--ease), opacity .3s;
  }
}
@media (max-width: 760px) { .nav-ink { display: none; } }

/* magnetic elements ease back into place when the cursor leaves */
:is(.btn, .icon-btn, .hero-socials a, .nav-links a).magnetic {
  transition: transform .35s var(--ease), box-shadow .3s, color .2s, border-color .2s, background .2s;
}

/* hero depth is driven from JS; hint the compositor */
.hero-copy, .hero-visual { will-change: transform, opacity; }

/* shared-element morph: featured card phone ⇄ case-study phone */
.case .player-phone .phone { view-transition-name: demo-phone; }
::view-transition-group(demo-phone) { animation-duration: .6s; animation-timing-function: cubic-bezier(.22, 1, .36, 1); }
::view-transition-old(demo-phone), ::view-transition-new(demo-phone) { animation-duration: .6s; height: 100%; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .3s; }

/* ============================================================
   TOUCH & SMALL SCREENS
   ============================================================ */

/* a tap leaves :hover stuck on touch screens, so the lifts stay with mouse and trackpad */
@media (hover: none) {
  .project:hover, .skill-group:hover, .tag:hover, .contact-row:hover, .hero-socials a:hover,
  .btn-primary:hover, .btn-ghost:hover, .project:hover .project-cta { transform: none; }
  .project:hover { box-shadow: none; }
  .project:hover::before { opacity: 0; }
}

/* fingers need ~44px targets; negative margins keep the visual layout where it was */
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
  .case-bar .icon-btn { width: 40px; height: 40px; }
  .project-src { width: 44px; height: 44px; margin: -5px; }
  .chip { padding: 10px 16px; }
  .logo { padding: 8px 0; }
}
/* the Ctrl K shortcut means nothing on a phone held sideways */
@media (hover: none) and (pointer: coarse) { .kbd-btn { display: none; } }

/* short landscape phones: the height-based sizes above shrink the demo to a sliver,
   so give it a floor and let the sheet scroll */
@media (orientation: landscape) and (max-height: 520px) {
  .case { --phone-w: min(220px, 100%); --screen-w: min(100%, calc((100vh - 64px) * 16 / 9)); padding: 0; }
  .case-box { width: 100%; height: 100%; max-height: none; border-radius: 0; border: 0; }
  @supports (height: 100dvh) { .case { --screen-w: min(100%, calc((100dvh - 64px) * 16 / 9)); } }
}

/* ============================================================
   POLISH: browser surfaces, focus, and small affordances
   ============================================================ */

/* one focus ring, drawn in the accent, for every keyboard stop */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input, textarea { caret-color: var(--accent); }
html { scrollbar-color: color-mix(in srgb, var(--text-3) 55%, transparent) var(--bg); }
.case-box, .palette-list, .term-body { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }


/* drawn icons in place of glyphs */
.skill-group h3 .sg-icon { flex: none; }
.totop { display: grid; place-items: center; }
.palette-list li .pi { display: grid; place-items: center; }
.palette-list li .pi .ti { width: 16px; height: 16px; color: var(--text-2); }
.palette-list li.sel .pi .ti { color: var(--accent); }

/* a card says out loud when there's something to try, not just to read */
.project-links { align-items: center; }
.project-try {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; margin-right: 6px;
  border: 1px solid var(--line-2); border-radius: 999px; font-family: var(--font-mono); font-size: 12px; color: var(--text-2);
  transition: color .2s, border-color .2s, background .2s;
}
.project-try:hover { color: var(--accent); border-color: var(--accent); }

/* the way on from a case study: resume and contact, quieter than its main actions */
.case-more { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 18px 0 0; font-family: var(--font-mono); font-size: 13px; }
.case-more a { color: var(--text-2); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 4px; transition: color .2s, text-decoration-color .2s; }
.case-more a:hover { color: var(--accent); text-decoration-color: currentColor; }

@media (pointer: coarse) {
  .term-input input { min-height: 40px; }
  .project-try { height: 36px; }
  .case-more a { padding: 10px 0; }
}

/* ============================================================
   HERO SHOWCASE: a 3D phone cycling through the apps
   ============================================================ */
.showcase { position: relative; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.showcase-stage {
  --dw: min(clamp(220px, 21vw, 280px), calc((100svh - 330px) * 9 / 19.6));
  position: relative; isolation: isolate; width: 100%; display: grid; place-items: center;
  perspective: 1500px; padding: 22px 0 30px;
}
/* a soft spotlight behind the phone, and its shadow on the floor */
.showcase-stage::before {
  content: ""; position: absolute; z-index: -1; left: 50%; top: 45%; width: calc(var(--dw) * 2.1); aspect-ratio: 1;
  transform: translate(-50%, -50%); pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%);
}
.showcase-stage::after {
  content: ""; position: absolute; z-index: -1; bottom: 8px; left: 50%; width: calc(var(--dw) * .9); height: 22px;
  transform: translateX(-50%); border-radius: 50%; background: rgba(0, 0, 0, .5); filter: blur(12px); pointer-events: none;
}
[data-theme="light"] .showcase-stage::after { background: rgba(60, 36, 16, .3); }

.device-wrap { transform-style: preserve-3d; animation: deviceFloat 7s ease-in-out infinite; }
@keyframes deviceFloat { 50% { transform: translateY(-9px); } }
.device {
  position: relative; display: block; width: var(--dw); aspect-ratio: 9 / 19.6; padding: 0; border: 0; background: none;
  border-radius: calc(var(--dw) * .15); cursor: pointer; touch-action: pan-y; transform-style: preserve-3d;
  transform: rotateY(calc(-17deg + var(--tx, 0deg) + var(--spin, 0deg))) rotateX(calc(5deg + var(--ty, 0deg))) rotateZ(1.2deg);
  transition: transform 1s cubic-bezier(.22, 1, .36, 1);
}
.device.turn { --spin: 12deg; transition-duration: .32s; }
.device:focus-visible { outline: none; }
.device:focus-visible .device-body { box-shadow: 0 0 0 3px var(--accent), inset 0 0 0 1px rgba(255, 255, 255, .08); }
/* thickness: rounded layers stacked behind the face show as the side of the phone as it turns */
.device-edge { position: absolute; inset: 0; border-radius: inherit; transform-style: preserve-3d; }
.device-edge i {
  position: absolute; inset: 0; border-radius: inherit; transform: translateZ(calc(var(--i) * -1.1px));
  background: linear-gradient(100deg, #3b414c, #13171d 35%, #0b0e12 65%, #2d333d);
}
.device-body {
  position: absolute; inset: 0; border-radius: inherit; padding: calc(var(--dw) * .034);
  background: linear-gradient(150deg, #3a404b, #12161c 28%, #0a0d11 72%, #2a303a);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), inset 0 0 0 3px #05070a;
}
.device-screen { position: relative; display: block; width: 100%; height: 100%; border-radius: calc(var(--dw) * .118); overflow: hidden; background: #000; }
.device-cam {
  position: absolute; z-index: 3; top: calc(var(--dw) * .07); left: 50%; width: calc(var(--dw) * .042); aspect-ratio: 1;
  transform: translateX(-50%); border-radius: 50%; background: #05070a; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .07);
}
/* glass: a sheen that slides as the phone turns toward the pointer */
.device-glare {
  position: absolute; inset: 0; z-index: 2; pointer-events: none; mix-blend-mode: screen;
  background: linear-gradient(115deg, transparent 32%, rgba(255, 255, 255, .13) 46%, transparent 60%) var(--gx, 64%) 0 / 260% 100% no-repeat;
  transition: background-position 1s cubic-bezier(.22, 1, .36, 1);
}
/* between apps the screen dims, like switching apps on a real phone */
.device-screen::after { content: ""; position: absolute; inset: 0; z-index: 1; background: #000; opacity: 0; transition: opacity .28s ease; pointer-events: none; }
.device-screen.switching::after { opacity: 1; }

.scr, .scr-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.scr { opacity: 0; transform: translateX(7%) scale(1.03); transition: opacity .55s ease, transform .8s cubic-bezier(.22, 1, .36, 1); }
.scr.on { opacity: 1; transform: none; }
.scr.off { opacity: 0; transform: translateX(-5%) scale(.98); }
.scr.reset { transition: none; }
.scr-video { opacity: 0; transition: opacity .6s ease; background: transparent; }
.scr-video.on { opacity: 1; }

/* notes float at their own depth and drift against the phone as it turns */
.showcase-note {
  position: absolute; z-index: 4; display: flex; align-items: center; gap: 10px; max-width: 176px; padding: 10px 13px;
  border-radius: 12px; border: 1px solid var(--line-2); background: color-mix(in srgb, var(--bg-2) 84%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .6); font-size: 12.5px; line-height: 1.35; color: var(--text);
  transition: opacity .35s ease, transform .9s cubic-bezier(.22, 1, .36, 1); pointer-events: none;
}
.showcase-note svg { flex: none; width: 28px; height: 28px; padding: 6px; border-radius: 8px; background: color-mix(in srgb, var(--text-3) 14%, transparent); }
.showcase-note svg:not(.ti-brand) { color: var(--accent); } /* brand logos keep their own colour */
.showcase-note.n1 { left: -8%; top: 11%; transform: translate3d(calc(var(--px, 0) * -12px), calc(var(--py, 0) * -8px), 0); }
.showcase-note.n2 { right: -8%; top: 31%; transform: translate3d(calc(var(--px, 0) * 14px), calc(var(--py, 0) * 10px), 0); }
.showcase-note.n3 { left: -5%; top: 55%; transform: translate3d(calc(var(--px, 0) * -16px), calc(var(--py, 0) * -11px), 0); }
.showcase-note.n4 { right: -5%; top: 74%; transform: translate3d(calc(var(--px, 0) * 11px), calc(var(--py, 0) * 8px), 0); }
.showcase-note.swap { opacity: 0; }

.showcase-bar {
  display: inline-flex; align-items: center; gap: 14px; padding: 5px 5px 5px 18px; border-radius: 999px;
  border: 1px solid var(--line-2); background: color-mix(in srgb, var(--bg-2) 82%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 12px 30px -16px rgba(0, 0, 0, .55);
  font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2); white-space: nowrap;
}
[data-theme="light"] .showcase-bar { box-shadow: 0 12px 28px -18px rgba(60, 36, 16, .4); }
.showcase-now { margin: 0; }
/* a fixed width keeps the pill still as the names change; each new name eases in */
.showcase-now b { display: inline-block; min-width: 7.2ch; color: var(--text); font-weight: 600; }
.showcase-now b.in { animation: nameIn .45s cubic-bezier(.22, 1, .36, 1); }
@keyframes nameIn { from { opacity: 0; transform: translateY(5px); filter: blur(3px); } }

/* one segment per app, like story progress: finished apps full, the current one filling, the rest empty */
.showcase-dots { display: flex; }
.showcase-dots button { position: relative; width: 34px; height: 30px; }
.showcase-dots button::before, .showcase-dots button::after {
  content: ""; position: absolute; left: 4px; right: 4px; top: 50%; height: 4px; margin-top: -2px; border-radius: 99px;
}
.showcase-dots button::before { background: color-mix(in srgb, var(--text-3) 32%, transparent); transition: background .25s; }
.showcase-dots button:hover::before { background: color-mix(in srgb, var(--text-3) 60%, transparent); }
.showcase-dots button[aria-current="true"]::before { background: color-mix(in srgb, var(--accent) 24%, transparent); }
/* the fill is clipped, not scaled, so its rounded ends keep their shape all the way through */
.showcase-dots button::after { background: var(--accent); clip-path: inset(0 100% 0 0 round 99px); }
.showcase-dots button.done::after { clip-path: inset(0 0 0 0 round 99px); }
.showcase-dots button[aria-current="true"]::after { animation: segFill var(--dwell, 15s) linear forwards; }
@keyframes segFill { from { clip-path: inset(0 100% 0 0 round 99px); } to { clip-path: inset(0 0 0 0 round 99px); } }
.showcase.is-paused .showcase-dots button::after { animation-play-state: paused; }
.showcase.static .showcase-dots button[aria-current="true"]::after { animation: none; clip-path: inset(0 0 0 0 round 99px); }
.showcase-pause, .showcase-step {
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: var(--text-2);
  background: color-mix(in srgb, var(--text-3) 14%, transparent); transition: color .2s, background .2s;
}
.showcase-step { background: none; margin: 0 -6px; } /* the arrows hug the segments they step through */
.showcase-pause:hover, .showcase-step:hover { color: var(--text); background: color-mix(in srgb, var(--text-3) 26%, transparent); }
.showcase-pause .i-play { display: none; }
.showcase.user-paused .showcase-pause .i-play { display: block; }
.showcase.user-paused .showcase-pause .i-pause { display: none; }
.showcase.static .showcase-pause { display: none; }

@media (pointer: coarse) {
  .showcase-dots button { width: 40px; height: 44px; }
  .showcase-pause, .showcase-step { width: 44px; height: 44px; }
}
@media (max-width: 900px) {
  .showcase-stage { --dw: min(62vw, 250px); }
  .showcase-note.n1, .showcase-note.n3 { left: 1%; }
  .showcase-note.n2, .showcase-note.n4 { right: 1%; }
}
@media (max-width: 420px) {
  .showcase-note { max-width: 150px; gap: 7px; padding: 6px 10px 6px 7px; font-size: 11.5px; }
  .showcase-note svg { width: 24px; height: 24px; padding: 5px; }
  .showcase-bar { gap: 6px; padding-left: 14px; }
  .showcase-dots button { width: 30px; }
}
/* phones drop the words before the name, then the name itself (screen readers still hear both) */
@media (max-width: 420px) {
  .showcase-now .sn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
@media (max-width: 380px) {
  .showcase-dots button { width: 24px; }
  .showcase-pause, .showcase-step { width: 40px; height: 40px; }
}
@media (max-width: 340px) {
  .showcase-now { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .showcase-bar { padding-left: 5px; }
}
