/* Scroll-story layer on top of styles.css. Without .scrub (reduced motion or no JS)
   everything below falls back to a normal stacked page. */

.stage {
  position: relative;
}

/* ---------- Hero ---------- */

.hero .stage {
  max-width: var(--wrap);
  margin-inline: auto;
  padding: clamp(48px, 10vw, 120px) var(--gutter) clamp(48px, 8vw, 96px);
}

.hero-name {
  font-size: clamp(4.5rem, 0.5rem + 17vw, 13rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 0.86;
  margin-left: -0.05em;
}

.hero-copy {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-top: clamp(28px, 4vw, 48px);
  max-width: 44rem;
}

.hero .lede {
  font-size: clamp(1.375rem, 1rem + 1.4vw, 2rem);
  line-height: 1.32;
  letter-spacing: -0.01em;
}

.hint {
  display: none;
}

.scrub .hero {
  height: 210vh;
}
.scrub .hero .stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: 0;
}
.scrub .hero-name {
  transform-origin: 0 100%;
  transform: scale(calc(1 - var(--p, 0) * 0.42));
}
.scrub .hero .w {
  color: color-mix(in srgb, var(--ink) 22%, var(--bg));
  transition: color 0.25s ease;
}
.scrub .hero .w.on {
  color: var(--ink);
}
.scrub .hero a .w.on {
  color: var(--link);
}
.scrub .hero-contact {
  opacity: clamp(0, (var(--p, 0) - 0.7) * 5, 1);
}
.scrub .hint {
  display: block;
  position: absolute;
  bottom: 28px;
  left: var(--gutter);
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
  opacity: clamp(0, 1 - var(--p, 0) * 8, 1);
}

/* ---------- Journey ---------- */

.career {
  background: var(--ink);
  color: var(--bg);
}
.career .stage {
  max-width: var(--wrap);
  margin-inline: auto;
  padding: 72px var(--gutter);
}
.career .step {
  margin-bottom: 48px;
}
.career .place {
  font-size: clamp(3rem, 1rem + 9vw, 9rem);
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 0.9;
  margin: 0;
}
.career .years {
  margin: 0 0 12px;
  font-variant-numeric: tabular-nums;
  opacity: 0.6;
}
.career .what {
  margin: 18px 0 0;
  max-width: 34rem;
  font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  opacity: 0.85;
}
.career a {
  color: inherit;
}

.scrub .career {
  height: calc(var(--n) * 90vh + 100vh);
}
.scrub .career .stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  padding-block: 0;
  overflow: hidden;
}
.scrub .career .step {
  position: absolute;
  inset: 0 var(--gutter);
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: 0;
  transform: translateY(8vh);
  transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
  pointer-events: none;
}
.scrub .career .step.past {
  transform: translateY(-8vh);
}
.scrub .career .step.on {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.career .bar {
  display: none;
}
.scrub .career .bar {
  display: block;
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: 32px;
  height: 2px;
  background: color-mix(in srgb, var(--bg) 20%, transparent);
}
.scrub .career .bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg);
  transform-origin: 0 50%;
  transform: scaleX(var(--p, 0));
}

/* ---------- Projects ---------- */

.made-title {
  padding-top: clamp(64px, 9vw, 112px);
  padding-bottom: 8px;
}
.made-title p {
  margin: 0;
  color: var(--muted);
  max-width: var(--text);
}

.proj {
  --pink: var(--accent);
  background: var(--bg-p);
  color: var(--ink-p);
}
.proj a {
  color: var(--accent);
}
.proj .stage {
  max-width: var(--wrap);
  margin-inline: auto;
  padding: 64px var(--gutter);
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  grid-template-rows: auto 1fr;
  column-gap: clamp(24px, 5vw, 72px);
}

.proj-head {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid color-mix(in srgb, var(--ink-p) 18%, transparent);
}
.proj-head h2 {
  margin: 0;
  font-size: clamp(2rem, 1.2rem + 3vw, 3.5rem);
  letter-spacing: -0.035em;
}
.proj-head h2 small {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted-p);
}

.rail {
  display: flex;
  gap: 4px 22px;
  flex-wrap: wrap;
  font-size: 0.9375rem;
}
.rail a {
  color: var(--muted-p);
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.rail a.on {
  color: var(--ink-p);
  border-color: var(--accent);
}

.steps {
  grid-column: 1;
  padding-top: 32px;
}
.step h3 {
  font-size: clamp(1.375rem, 1.1rem + 1vw, 1.875rem);
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.step p {
  margin: 0 0 12px;
  max-width: 32rem;
}
.proj .step p.say {
  font-size: clamp(1.625rem, 1.1rem + 2.2vw, 2.75rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.025em;
}
.step .note {
  color: var(--muted-p);
}

.stats {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 28px;
}
.stats b {
  display: block;
  font-size: clamp(2.25rem, 1.4rem + 3vw, 3.75rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stats span {
  color: var(--muted-p);
  font-size: 1rem;
}

.visuals {
  grid-column: 2;
  grid-row: 2;
  padding-top: 32px;
  position: relative;
}
.vis {
  display: none;
}
.vis:first-child {
  display: block;
}

/* Scroll mode: pinned stage, steps and visuals crossfade in place. */
.scrub .proj {
  height: calc(var(--n) * 75vh + 100vh);
}
.scrub .proj .stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  padding-block: clamp(20px, 5vh, 56px);
  overflow: hidden;
}
.scrub .steps,
.scrub .visuals {
  position: relative;
}
.scrub .step,
.scrub .vis {
  position: absolute;
  inset: 32px 0 0;
  display: block;
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.45s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
  pointer-events: none;
}
.scrub .step.past {
  transform: translateY(-28px);
}
.scrub .step.on,
.scrub .vis.on {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.scrub .vis {
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(40px) scale(0.98);
}

/* ---------- Visual building blocks ---------- */

.device {
  max-height: 100%;
  width: auto;
  border-radius: 28px;
  box-shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.45);
}
.vis img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.scrub .vis {
  overflow: hidden;
}
.scrub .vis img {
  max-height: 100%;
}

.chat {
  width: min(100%, 440px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bubble {
  align-self: flex-start;
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 18px 18px 18px 6px;
  background: var(--card-p);
  color: var(--card-ink, var(--ink-p));
  font-size: 1rem;
  line-height: 1.4;
  box-shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.5);
}
.bubble.mine {
  align-self: flex-end;
  border-radius: 18px 18px 6px 18px;
  background: var(--accent);
  color: var(--on-accent, #fff);
}
.bubble small {
  display: block;
  opacity: 0.65;
  font-size: 0.8125rem;
  margin-bottom: 2px;
}
.bubble ul {
  margin: 4px 0 0;
  padding-left: 1.1em;
}

.term {
  width: min(100%, 520px);
  background: #0e150f;
  color: #cfe3b4;
  border-radius: 14px;
  padding: 18px 20px;
  font: 500 0.875rem/1.65 ui-monospace, 'SF Mono', Menlo, monospace;
  box-shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.6);
  white-space: pre;
  overflow: hidden;
}
.term .dim {
  color: #6f8a5c;
}
.term .hi {
  color: #e8f59a;
}

.bigword {
  font-size: clamp(3.5rem, 2rem + 6vw, 7.5rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 0.9;
  margin: 0;
}

/* ---------- Small screens ---------- */

@media (max-width: 760px) {
  .proj .stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    padding-block: 40px;
  }
  .steps,
  .visuals {
    grid-column: 1;
  }
  .visuals {
    grid-row: auto;
  }
  .proj-head {
    padding-bottom: 12px;
  }
  .rail {
    font-size: 0.875rem;
    gap: 2px 16px;
  }
  .stats {
    gap: 14px 20px;
  }

  .scrub .proj .stage {
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding-block: 16px 20px;
  }
  .scrub .visuals {
    grid-row: 2;
    padding-top: 14px;
  }
  .scrub .steps {
    grid-row: 3;
    padding-top: 0;
    min-height: 15.5rem;
  }
  .scrub .step {
    inset: 8px 0 0;
  }
  .scrub .vis {
    inset: 14px 0 0;
  }
  .proj .step p.say {
    font-size: 1.625rem;
  }
  .proj .step p {
    font-size: 1rem;
  }
  .chat {
    font-size: 0.875rem;
  }
  .term {
    font-size: 0.6875rem;
    padding: 14px;
  }
}

/* ---------- Per-project visuals ---------- */

.app-icon {
  width: min(52%, 240px);
  border-radius: 22%;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.45);
}
.mark {
  width: min(60%, 260px);
}
.mascot {
  width: min(70%, 340px);
  filter: drop-shadow(0 24px 40px rgba(0, 0, 0, 0.25));
}
.poster {
  width: 100%;
  border-radius: 18px;
  box-shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.7);
}
.device.wide {
  border-radius: 12px;
  width: 100%;
  height: auto;
}

.watch {
  width: 260px;
  aspect-ratio: 0.82;
  border-radius: 58px;
  background: #1b1b1d;
  padding: 16px;
  box-shadow: inset 0 0 0 2px #3a3a3e, 0 30px 60px -22px rgba(0, 0, 0, 0.55);
  position: relative;
}
.watch::after {
  content: '';
  position: absolute;
  right: -9px;
  top: 30%;
  width: 9px;
  height: 46px;
  border-radius: 0 6px 6px 0;
  background: #3a3a3e;
}
.watch-face {
  height: 100%;
  border-radius: 44px;
  background: #000;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.watch-face img {
  width: 76px;
  border-radius: 50%;
}
.watch-face .rec {
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #ff5a4f;
}
.watch-face .cap {
  font-size: 0.875rem;
  opacity: 0.7;
}
.scrub .vis.on .rec {
  animation: blink 1.4s steps(2, start) infinite;
}
@keyframes blink {
  to {
    opacity: 0.35;
  }
}

.kenji {
  margin: 0;
  position: relative;
  height: 100%;
  display: flex;
  justify-content: center;
}
.kenji img {
  border-radius: 18px;
  box-shadow: 0 0 0 1px rgba(95, 227, 255, 0.35), 0 0 60px -10px rgba(95, 227, 255, 0.45);
}
.kenji figcaption {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 800;
  font-size: 0.875rem;
}

.dare {
  width: min(100%, 320px);
  padding: 28px;
  border-radius: 24px;
  background: var(--card-p);
  text-align: center;
  box-shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.7);
}
.dare img {
  width: 96px;
  margin: 0 auto 16px;
  border-radius: 22%;
}
.dare-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.dare-meta {
  margin: 6px 0 0;
  color: var(--accent);
  font-weight: 600;
}

.doc {
  width: min(100%, 460px);
  padding: 26px;
  border-radius: 16px;
  background: #f6f4ff;
  color: #1c1a2b;
  font-size: 1.0625rem;
  line-height: 1.6;
  box-shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.7);
}
.doc p {
  margin: 0;
}
.doc del {
  color: #b3261e;
  background: #fde7e4;
}
.doc ins {
  color: #1d6b3a;
  background: #dff3e4;
  text-decoration: none;
}
.doc-actions {
  display: flex;
  gap: 8px;
  margin: 14px 0;
  font-size: 0.875rem;
  font-weight: 600;
}
.doc-actions span {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid #cfc9ef;
}
.doc-actions .ok {
  background: #1c1a2b;
  color: #fff;
  border-color: #1c1a2b;
}
.doc .bubble {
  background: #e9e5ff;
  color: #1c1a2b;
  box-shadow: none;
}
.margin-term {
  background: #12101e;
  color: #d9d4ff;
}
.margin-term .hi {
  color: #b8a6ff;
}

@media (max-width: 760px) {
  .watch {
    width: 150px;
    border-radius: 42px;
    padding: 11px;
  }
  .watch-face {
    border-radius: 32px;
  }
  .watch-face img {
    width: 52px;
  }
  .dare {
    padding: 20px;
  }
  .doc {
    font-size: 0.9375rem;
    padding: 18px;
  }
}

@media (min-width: 761px) {
  .proj .step p {
    font-size: 1.1875rem;
  }
  .proj .step p.note {
    font-size: 1.125rem;
  }
}

/* ---------- Career ---------- */

.career {
  background: #0f1724;
  color: #eef2f7;
  --muted-c: #9aa6b8;
}
.career-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--muted-c);
  margin: 0 0 32px;
}
.scrub .career-title {
  position: absolute;
  top: clamp(20px, 5vh, 48px);
  left: var(--gutter);
  margin: 0;
}
.career .logo {
  display: block;
  align-self: flex-start;
  height: clamp(36px, 2.5vw + 22px, 64px);
  width: auto;
  max-width: 80%;
  object-fit: contain;
  object-position: left center;
  filter: brightness(0) invert(1);
  margin-bottom: clamp(18px, 3vh, 32px);
}
.career .role {
  margin: 0 0 clamp(20px, 4vh, 40px);
  font-size: clamp(1.25rem, 1rem + 1vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.015em;
}
.career .role span {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted-c);
}
.wins {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 24px 40px;
  max-width: 64rem;
}
.wins b {
  display: block;
  font-size: clamp(2.75rem, 1.6rem + 4vw, 5.5rem);
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 0.95;
}
.wins span {
  display: block;
  margin-top: 8px;
  color: var(--muted-c);
  max-width: 20rem;
}
.career .more {
  margin: 28px 0 0;
}
.career .more a {
  color: #fff;
}
.before {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 28px 48px;
  max-width: 56rem;
}
.before img {
  display: block;
  width: auto;
  height: 30px;
  width: auto;
  filter: brightness(0) invert(1);
  margin-bottom: 10px;
}
.before strong {
  display: block;
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  margin-bottom: 8px;
}
.before span {
  color: var(--muted-c);
}

/* ---------- Hero logos ---------- */

.logo-strip {
  list-style: none;
  padding: 0;
  margin: clamp(28px, 4vw, 44px) 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px clamp(24px, 3vw, 44px);
}
.logo-strip img {
  height: 26px;
  width: auto;
  filter: brightness(0);
  opacity: 0.72;
}
.logo-strip li:first-child img,
.logo-strip li:nth-child(3) img {
  height: 22px;
}
.logo-strip li:last-child img {
  height: 34px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .logo-strip img {
    filter: brightness(0) invert(1);
  }
}
.scrub .logo-strip {
  opacity: clamp(0, (var(--p, 0) - 0.55) * 5, 1);
}
.hero-contact {
  margin-left: 0;
}

@media (max-width: 760px) {
  .wins {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 20px;
  }
  .wins b {
    font-size: 2.5rem;
  }
  .wins span {
    font-size: 0.9375rem;
  }
  .before {
    gap: 20px;
  }
  .before strong {
    font-size: 1.125rem;
  }
  .before span {
    font-size: 0.9375rem;
  }
}

/* ---------- Side rail ---------- */

.rail-nav {
  position: fixed;
  z-index: 50;
  right: 10px;
  --fg: #fff;
  --tip-bg: #fff;
  --tip-ink: #0f1724;
  top: calc(50% - min(32vh, 280px));
  height: min(64vh, 560px);
  width: 36px;
  touch-action: none;
  cursor: ns-resize;
  user-select: none;
  -webkit-user-select: none;
}
.rail-track {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--fg) 30%, transparent);
  overflow: hidden;
}
.rail-fill {
  position: absolute;
  inset: 0;
  background: var(--fg);
  transform-origin: 50% 0;
  transform: scaleY(0);
}
.rail-thumb {
  position: absolute;
  left: 50%;
  width: 10px;
  height: 26px;
  margin: -13px 0 0 -5px;
  border-radius: 999px;
  background: var(--fg);
  transition: width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
    height 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), margin 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}
.rail-nav.dragging .rail-thumb {
  width: 16px;
  height: 40px;
  margin: -20px 0 0 -8px;
}
.rail-mark {
  --s: 1;
  position: absolute;
  left: 0;
  width: 36px;
  height: 22px;
  margin-top: -11px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
}
.rail-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--fg);
  transform: scale(var(--s));
  transition: transform 0.45s cubic-bezier(0.34, 1.8, 0.64, 1);
}
.rail-mark.on .rail-dot {
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
}
.rail-tip {
  position: absolute;
  right: calc(100% + 6px);
  top: 50%;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--tip-bg);
  color: var(--tip-ink);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translate(10px, -50%) scale(0.5);
  transform-origin: 100% 50%;
  transition: opacity 0.2s ease, transform 0.45s cubic-bezier(0.34, 1.8, 0.64, 1);
  pointer-events: none;
}
.rail-tip em {
  font-style: normal;
  font-weight: 500;
  opacity: 0.6;
  margin-left: 8px;
}
.rail-mark.near .rail-tip,
.rail-mark:focus-visible .rail-tip,
.rail-nav.dragging .rail-mark.on .rail-tip {
  opacity: 1;
  transform: translate(0, -50%) scale(1);
}
.rail-nav.dragging .rail-mark.near:not(.on) .rail-tip {
  opacity: 0;
}
.rail-mark:focus-visible {
  outline: none;
}
.rail-mark:focus-visible .rail-dot {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fg) 50%, transparent);
}

@media (max-width: 760px) {
  .rail-nav {
    right: 2px;
    width: 26px;
    top: 22vh;
    height: 56vh;
  }
  .rail-mark {
    width: 26px;
  }
  .rail-dot {
    width: 5px;
    height: 5px;
    margin: -2.5px 0 0 -2.5px;
  }
  .rail-mark .rail-tip {
    font-size: 0.8125rem;
  }
  /* Touch has no hover: only show the current section while dragging. */
  .rail-mark.near .rail-tip {
    opacity: 0;
  }
  .rail-nav.dragging .rail-mark.on .rail-tip {
    opacity: 1;
    transform: translate(0, -50%) scale(1);
  }
}
@media (prefers-reduced-motion: reduce) {
  .rail-dot,
  .rail-tip,
  .rail-thumb {
    transition: none;
  }
}

.rail-nav.on-light {
  --fg: #0f1724;
  --tip-bg: #0f1724;
  --tip-ink: #fff;
}

.files {
  list-style: none;
  margin: 0;
  padding: 8px;
  width: min(100%, 420px);
  border-radius: 18px;
  background: var(--card-p);
  color: var(--card-ink, var(--ink-p));
  box-shadow: 0 20px 50px -24px rgba(0, 0, 0, 0.45);
}
.files li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-radius: 12px;
}
.files li + li {
  border-top: 1px solid color-mix(in srgb, var(--ink-p) 10%, transparent);
}
.files em {
  font-style: normal;
  color: var(--muted-p);
  font-variant-numeric: tabular-nums;
}
.bubble li b {
  font-weight: 700;
}
