:root {
  --bg: #000;
  --fg: #f4f4f4;
  --muted: #8a8a8a;
  --dim: #3a3a3a;
  --line: rgba(255, 255, 255, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: clamp(20px, 5vw, 64px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
main { overflow-x: clip; }
html.intro-running, html.intro-running body { overflow: hidden; }
a { color: inherit; }
button { font: inherit; color: inherit; }
::selection { background: #fff; color: #000; }

/* subtle film grain */
body::after {
  content: "";
  position: fixed;
  inset: -50%;
  pointer-events: none;
  z-index: 50;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); }
  75% { transform: translate(-2%, -1%); }
  100% { transform: translate(0, 0); }
}

/* ---------------- Intro ---------------- */
#intro {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: none;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
html.intro-running #intro { display: flex; }
.intro-stage { position: relative; text-align: center; will-change: transform, filter, opacity; }
.intro-word {
  position: relative;
  display: flex;
  justify-content: center;
  font-weight: 700;
  font-size: clamp(64px, 17vw, 240px);
  letter-spacing: -0.055em;
  line-height: 1;
}
.intro-letter { position: relative; display: inline-block; }
.intro-letter .core { position: relative; display: inline-block; will-change: transform, filter; }
.intro-letter .ghost {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  will-change: transform, opacity;
}
.intro-sub {
  margin-top: clamp(10px, 2vw, 22px);
  font-size: clamp(12px, 1.4vw, 16px);
  font-weight: 500;
  letter-spacing: 0.6em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0;
  padding-left: 0.6em;
  will-change: letter-spacing, opacity, filter;
}
.intro-streak {
  position: absolute;
  left: 0;
  top: 50%;
  width: 40vw;
  height: 2px;
  margin-top: -1px;
  background: linear-gradient(90deg, transparent, #fff, transparent);
  filter: blur(1px);
  transform: translateX(-60vw);
  opacity: 0;
}
.intro-skip {
  position: absolute;
  right: var(--gutter);
  bottom: calc(24px + env(safe-area-inset-bottom));
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 8px;
}
.intro-skip:hover { color: var(--fg); }

/* ---------------- Steps ---------------- */
.step {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: 96px var(--gutter) 120px;
}
.wrap { width: 100%; max-width: 1100px; margin: 0 auto; }

.kicker {
  margin: 0 0 28px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-name {
  margin: 0;
  font-size: clamp(72px, 19vw, 280px);
  font-weight: 700;
  letter-spacing: -0.06em;
  line-height: 0.9;
}
.hero-sub {
  margin: 28px 0 40px;
  font-size: clamp(18px, 2.2vw, 26px);
  color: var(--muted);
}

.statement {
  margin: 0;
  font-size: clamp(36px, 6.6vw, 96px);
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.04;
  max-width: 14em;
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--fg);
  background: var(--fg);
  color: #000;
  border-radius: 999px;
  padding: 14px 24px;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.4s var(--ease), background 0.3s, color 0.3s;
}
.cta svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.cta:hover { background: transparent; color: var(--fg); transform: translateY(-2px); }

.hero-orbit {
  position: absolute;
  right: -20vw;
  top: 50%;
  width: 70vw;
  height: 70vw;
  max-width: 900px;
  max-height: 900px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.10), rgba(255,255,255,0) 60%);
  border: 1px solid var(--line);
  pointer-events: none;
  animation: drift 14s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translateY(-50%) rotate(0deg) scale(1); }
  to { transform: translateY(-46%) rotate(20deg) scale(1.06); }
}

/* Projects */
.projects { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.projects li { border-bottom: 1px solid var(--line); }
.projects a, .projects li > div {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(22px, 3.4vw, 40px) 0;
  text-decoration: none;
}
.p-name {
  font-size: clamp(34px, 6vw, 84px);
  font-weight: 650;
  letter-spacing: -0.04em;
  line-height: 1;
  transition: transform 0.6s var(--ease), letter-spacing 0.6s var(--ease);
}
.p-note { color: var(--muted); font-size: clamp(14px, 1.5vw, 18px); white-space: nowrap; margin-left: auto; }
.p-arrow {
  width: clamp(22px, 2.6vw, 34px);
  height: clamp(22px, 2.6vw, 34px);
  flex: none;
  align-self: center;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  transition: transform 0.6s var(--ease);
}
.projects a:hover .p-name { transform: translateX(14px); letter-spacing: -0.02em; }
.projects a:hover .p-arrow { transform: translate(4px, -4px); }

/* Stack */
.stack {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.1em 0.45em;
  font-size: clamp(36px, 7vw, 104px);
  font-weight: 650;
  letter-spacing: -0.04em;
  line-height: 1.05;
}
.stack .w:nth-child(even) { color: var(--muted); }
.stack-note { margin: 32px 0 0; font-size: clamp(18px, 2vw, 24px); color: var(--muted); }

/* Contact */
.step-contact { flex-direction: column; justify-content: center; }
.ask {
  margin: 0 0 clamp(36px, 6vw, 64px);
  font-size: clamp(48px, 9.5vw, 150px);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 0.95;
  max-width: 10em;
}
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.option {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.02);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.3s, background 0.3s, transform 0.5s var(--ease);
}
.option:hover, .option[aria-expanded="true"] { border-color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.06); transform: translateY(-2px); }
.o-label { font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.o-value { font-size: clamp(17px, 1.8vw, 22px); font-weight: 600; overflow-wrap: anywhere; }
.o-warn {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.4;
  color: #ff453a;
}

.chat {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
  animation: chatIn 0.7s var(--ease);
}
@keyframes chatIn { from { opacity: 0; transform: translateY(16px); filter: blur(8px); } }
.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}
.chat-dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(255,255,255,0.12); }
.chat-new { margin-left: auto; white-space: nowrap; background: none; border: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 13px; }
.chat-new:hover { color: var(--fg); }
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  max-height: 46vh;
  overflow-y: auto;
}
.chat-log:empty { display: none; }
.msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: msgIn 0.5s var(--ease);
}
@keyframes msgIn { from { opacity: 0; transform: translateY(8px) scale(0.98); filter: blur(4px); } }
.msg.me { align-self: flex-end; background: #fff; color: #000; border-bottom-right-radius: 6px; }
.msg.them { align-self: flex-start; background: #1c1c1c; border-bottom-left-radius: 6px; }
.msg-meta { font-size: 11px; color: var(--muted); margin: -2px 4px 4px; }
.msg-meta.me { align-self: flex-end; }
.chat-form { padding: 16px 20px 18px; display: flex; flex-direction: column; gap: 10px; }
.chat-name, .chat-row textarea {
  width: 100%;
  background: #0d0d0d;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--fg);
  font: 16px/1.4 var(--font);
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s;
}
.chat-name:focus, .chat-row textarea:focus { border-color: rgba(255,255,255,0.5); }
.chat-row { display: flex; gap: 10px; align-items: flex-end; }
.chat-row textarea { resize: none; min-height: 48px; max-height: 180px; }
.chat-send {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: #fff;
  color: #000;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.3s var(--ease), opacity 0.2s;
}
.chat-send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.chat-send:hover { transform: scale(1.06); }
.chat-send:disabled { opacity: 0.4; cursor: default; transform: none; }
.chat-status { margin: 0; min-height: 1.2em; font-size: 13px; color: var(--muted); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.foot {
  width: 100%;
  max-width: 1100px;
  margin: 72px auto 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---------------- Guide ---------------- */
.rail {
  position: fixed;
  left: calc(var(--gutter) / 2 - 4px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
}
.rail ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.rail button {
  display: block;
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--dim);
  cursor: pointer;
  transition: background 0.3s, transform 0.4s var(--ease), height 0.4s var(--ease);
}
.rail button.active { background: #fff; height: 28px; border-radius: 4px; }

.guide {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 0);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 8px 8px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.72);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  font-size: 14px;
  transition: opacity 0.5s var(--ease), transform 0.6s var(--ease);
}
.guide.hidden { opacity: 0; transform: translate(-50%, 24px); pointer-events: none; }
.guide-step { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.guide-label { font-weight: 600; min-width: 5.5em; white-space: nowrap; }
.guide-next {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #000;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.3s var(--ease);
}
.guide-next svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.guide-next:hover { transform: translateY(2px); }
.guide.last .guide-next svg { transform: rotate(180deg); }

/* ---------------- Reveal (motion blur) ---------------- */
html.js .reveal {
  opacity: 0;
  transform: translateY(40px);
  filter: blur(14px);
  transition: opacity 1s var(--ease), transform 1.2s var(--ease), filter 1s var(--ease);
  transition-delay: var(--d, 0s);
}
html.js .reveal.in { opacity: 1; transform: none; filter: none; }

.reveal-words .w { display: inline-block; white-space: pre; }
html.js .reveal-words .w {
  opacity: 0;
  transform: translateY(0.55em) scaleY(1.35);
  transform-origin: 50% 100%;
  filter: blur(16px);
  transition: opacity 0.9s var(--ease), transform 1.1s var(--ease), filter 0.9s var(--ease);
  transition-delay: calc(var(--i) * 70ms + var(--d, 0s));
}
html.js .reveal-words.in .w { opacity: 1; transform: none; filter: none; }

@media (max-width: 720px) {
  .options { grid-template-columns: 1fr; }
  .rail { display: none; }
  .guide { font-size: 13px; gap: 10px; padding-left: 16px; }
  .guide-label { min-width: 0; }
  .hero-orbit { width: 120vw; height: 120vw; right: -60vw; }
  .p-note { font-size: 14px; }
  .projects a, .projects li > div { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body::after, .hero-orbit { animation: none; }
  html.js .reveal, html.js .reveal-words .w { opacity: 1; transform: none; filter: none; transition: none; }
}
