/* ============================================================
   Portfolio — global styles
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--tx-md);
  line-height: 1.55;
  font-feature-settings: "ss01", "cv11", "kern";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  position: relative;
}

/* subtle film-grain noise — fixed-position, blends as overlay so the texture
   tracks the viewport rather than scrolling away. SVG turbulence keeps the
   bundle small. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 240px 240px;
}
[data-palette="light"] body::before { opacity: 0.04; mix-blend-mode: multiply; }

/* ── ascii wave background ─────────────────────────────── */
.ascii-bg {
  position: fixed;
  inset: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 0;
  /* no blend mode — opacity handles the subtlety, like openhands.dev */
}
/* ensure body content sits above the canvas */
.nav, main, footer, .hero, .section, .marquee { position: relative; z-index: 2; }

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

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
img { display: block; max-width: 100%; }

/* ── reusable type roles ────────────────────────────────── */
.t-display {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 0.95;
}
.t-meta {
  font-family: var(--font-mono);
  font-size: var(--tx-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.t-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--tx-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.t-section {
  font-family: var(--font-display);
  font-size: var(--tx-3xl);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

/* tabular numerics for technical readouts */
.tabular { font-variant-numeric: tabular-nums; }

/* ── container ──────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.hairline { height: 1px; background: var(--line-2); width: 100%; }
.hairline-strong { height: 1px; background: var(--line); width: 100%; }

/* ── nav ────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  background: color-mix(in oklab, var(--bg) 70%, transparent);
  border-bottom: 1px solid var(--line-2);
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; gap: var(--sp-5);
}
.nav-mono {
  display: flex; align-items: center; gap: var(--sp-3);
  font-family: var(--font-mono); font-size: var(--tx-xs);
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-2);
}
.nav-mono b { color: var(--fg); font-weight: 500; }
.nav-progress {
  position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; pointer-events: none; overflow: hidden;
}
.nav-progress-fill {
  height: 100%; width: 100%;
  background: var(--accent);
  transform-origin: 0 50%;
  transform: scaleX(0);
  transition: transform 80ms linear;
  box-shadow: 0 0 8px color-mix(in oklab, var(--accent) 50%, transparent);
}
.nav-mark {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px;
  border: 1px solid var(--line); border-radius: 4px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  color: var(--fg); letter-spacing: 0;
  position: relative;
}
.nav-mark::after {
  content: ""; position: absolute; right: -3px; top: -3px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px color-mix(in oklab, var(--accent) 60%, transparent);
}
.nav-links {
  display: flex; align-items: center; gap: var(--sp-5);
  font-family: var(--font-mono); font-size: var(--tx-xs);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.nav-links a {
  color: var(--fg-2);
  transition: color var(--t-fast) var(--ease);
  position: relative; padding: 4px 0;
}
.nav-links a:hover, .nav-links a.is-active { color: var(--fg); }
.nav-links a.is-active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px;
  height: 1px; background: var(--accent);
}

/* ── buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: var(--sp-3);
  height: 44px; padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--font-mono); font-size: var(--tx-xs);
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--fg);
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
  cursor: pointer;
}
.btn:hover { background: var(--bg-2); border-color: var(--fg-3); }
.btn .arrow { transition: transform var(--t-fast) var(--ease); display:inline-block; }
.btn:hover .arrow { transform: translateX(3px); }
.btn-primary {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--accent-ink); }

/* ── tags / chips ───────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--fg-2);
}
.tag-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px color-mix(in oklab, var(--accent) 40%, transparent); }

/* ── theme toggle ──────────────────────────────────────── */
.theme-toggle {
  display: inline-flex; align-items: center;
  width: 52px; height: 26px;
  border-radius: 999px;
  border: 1px solid var(--line);
  position: relative;
  background: color-mix(in oklab, var(--fg) 6%, transparent);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.theme-toggle .knob {
  position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--fg);
  transition: transform var(--t-med) var(--ease-out), background var(--t-fast) var(--ease);
  box-shadow: 0 0 8px color-mix(in oklab, var(--accent) 35%, transparent);
}
[data-palette="light"] .theme-toggle .knob { transform: translateX(26px); background: var(--accent); }
.theme-toggle .icon {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 9px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--fg-3);
  pointer-events: none;
}
.theme-toggle .icon.dk { left: 8px; }
.theme-toggle .icon.lt { right: 8px; }

/* ── focus rings ────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ── custom cursor ──────────────────────────────────────── */
.has-custom-cursor,
.has-custom-cursor * { cursor: none !important; }

.cursor-dot,
.cursor-ring {
  position: fixed; top: 0; left: 0;
  pointer-events: none;
  z-index: 9999;
  transition: opacity 200ms var(--ease), width 220ms var(--ease-out),
              height 220ms var(--ease-out), border-color 220ms var(--ease),
              background 220ms var(--ease);
  will-change: transform;
}
.cursor-dot {
  width: 6px; height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px color-mix(in oklab, var(--accent) 60%, transparent);
}
.cursor-ring {
  width: 32px; height: 32px;
  border: 1px solid color-mix(in oklab, var(--fg) 40%, transparent);
  border-radius: 50%;
  position: fixed;
}

.cur-hover .cursor-ring {
  width: 46px; height: 46px;
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 10%, transparent);
}
.cur-hover .cursor-dot {
  width: 4px; height: 4px;
  margin: -2px 0 0 -2px;
}

.cur-tap .cursor-ring {
  width: 38px; height: 38px;
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 15%, transparent);
}

.cur-view .cursor-ring {
  width: 72px; height: 72px;
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 12%, transparent);
}
.cur-view .cursor-dot { opacity: 0; }
.cur-view .cursor-ring::after {
  content: "VIEW";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--accent);
}

.cur-down .cursor-ring { width: 22px; height: 22px; }
.cur-down .cursor-dot { width: 4px; height: 4px; margin: -2px 0 0 -2px; }

/* mini bloom — apply to anything tagged with .bloom or to elements that
   already paint with var(--accent). We layer drop-shadows so it reads as
   gentle halation, not a hard glow. */
.bloom,
.tag-dot,
.marquee-track .dot,
.nav-mark::after,
.intro-progress-fill,
.hero-eyebrow .pulse,
.intro-name .accent,
.intro-caret,
.nav-links a.is-active::after,
.hero-title .accent,
.stat .num,
.proj-card .head b,
.timeline-row .when,
.t-eyebrow,
.btn-primary {
  filter: drop-shadow(0 0 3px color-mix(in oklab, var(--accent) 22%, transparent));
}

.hero-title .accent,
.intro-name .accent,
.stat .num {
  filter: drop-shadow(0 0 4px color-mix(in oklab, var(--accent) 14%, transparent));
}

/* ── utility ────────────────────────────────────────────── */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); } .gap-5 { gap: var(--sp-5); }
.between { justify-content: space-between; }

/* ── image placeholder treatment ─────────────────────────── */
.img-frame {
  position: relative;
  background: var(--bg-2);
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: 2px;
}
.img-frame img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transform: translate3d(var(--p-x, 0px), var(--p-y, 0px), 0) scale(var(--p-s, 1));
  transition: transform 350ms var(--ease-out), filter var(--t-med) var(--ease);
  will-change: transform;
}
.img-frame .img-meta {
  position: absolute; left: 12px; bottom: 12px;
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--fg);
  background: color-mix(in oklab, var(--bg) 70%, transparent);
  backdrop-filter: blur(8px);
  padding: 4px 8px; border-radius: 2px;
  border: 1px solid var(--line-2);
}

.placeholder {
  width: 100%; height: 100%;
  background:
    repeating-linear-gradient(
      135deg,
      transparent 0 14px,
      color-mix(in oklab, var(--fg) 4%, transparent) 14px 15px
    ),
    var(--bg-2);
  display: grid; place-items: center;
  position: relative;
  overflow: hidden;
}
.placeholder::before {
  content: "";
  position: absolute; inset: 12px;
  border: 1px dashed color-mix(in oklab, var(--fg) 18%, transparent);
}
.placeholder-label {
  position: relative;
  font-family: var(--font-mono); font-size: var(--tx-xs);
  letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--fg-3);
  background: var(--bg);
  padding: 4px 10px;
  border: 1px solid var(--line-2);
  border-radius: 2px;
  text-align: center;
  max-width: 70%;
}

/* ── marquee ────────────────────────────────────────────── */
@keyframes marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.marquee {
  display: flex; overflow: hidden;
  border-block: 1px solid var(--line-2);
  padding-block: 14px;
  user-select: none;
}
.marquee-track {
  display: flex; gap: 56px; flex-shrink: 0;
  animation: marquee 40s linear infinite;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: var(--tx-2xl);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.marquee-track > span { display: inline-flex; align-items: center; gap: 56px; }
.marquee-track .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
  display: inline-block;
  box-shadow: 0 0 12px color-mix(in oklab, var(--accent) 50%, transparent);
}

/* ── reveal-on-mount fade ────────────────────────────────── */
.reveal {
  opacity: 0; transform: translateY(10px);
  animation: reveal var(--t-slow) var(--ease-out) forwards;
}
@keyframes reveal {
  to { opacity: 1; transform: translateY(0); }
}
.reveal[data-d="1"] { animation-delay: 80ms; }
.reveal[data-d="2"] { animation-delay: 160ms; }
.reveal[data-d="3"] { animation-delay: 240ms; }
.reveal[data-d="4"] { animation-delay: 320ms; }
.reveal[data-d="5"] { animation-delay: 400ms; }
.reveal[data-d="6"] { animation-delay: 480ms; }
.reveal[data-d="7"] { animation-delay: 560ms; }

/* ── route mask transition ───────────────────────────────── */
.route-mask {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  pointer-events: none;
  transform: translateY(100%);
}
.route-mask.is-in { animation: maskIn 480ms var(--ease-out) forwards; }
.route-mask.is-out { animation: maskOut 480ms var(--ease-out) forwards; }
@keyframes maskIn { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes maskOut { from { transform: translateY(0); } to { transform: translateY(-100%); } }
