:root {
  --bg: #08090b;
  --fg: #ece9e3;
  --dim: #8d8d8a;
  --line: rgba(236, 233, 227, .16);
  --ember: #ff5a1f;
  --gutter: clamp(16px, 2.6vw, 40px);
  --sans: 'Geist', 'Helvetica Neue', Arial, 'Noto Sans JP', sans-serif;
  --mono: 'Geist Mono', ui-monospace, Menlo, 'Noto Sans JP', monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: dark;
}

/* Light: warm paper and dark ink. Follows the device unless the visitor picked one. */
:root[data-theme="light"] {
  --bg: #efe9df;
  --fg: #16130f;
  --dim: #6f6a62;
  --line: rgba(22, 19, 15, .16);
  --ember: #d4430c;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #efe9df;
    --fg: #16130f;
    --dim: #6f6a62;
    --line: rgba(22, 19, 15, .16);
    --ember: #d4430c;
    color-scheme: light;
  }
}
html { transition: background-color .6s var(--ease); }
body, #gl { transition: background-color .6s var(--ease), color .6s var(--ease); }

* { margin: 0; padding: 0; box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; overflow-x: clip; scroll-behavior: smooth; }
body {
  font-family: var(--sans); font-size: 16px; line-height: 1.4; font-weight: 400;
  color: var(--fg); background: var(--bg); overflow-x: clip;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
b { font-weight: 400; }
:focus-visible { outline: 1px solid var(--fg); outline-offset: 4px; }
::selection { background: var(--ember); color: #000; }

#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100lvh; display: block; background: var(--bg); }
main { position: relative; z-index: 2; }

/* ---------- Cursor ---------- */
.cursor {
  position: fixed; left: 0; top: 0; z-index: 40; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border-radius: 50%; background: #fff; mix-blend-mode: difference; pointer-events: none;
  display: none; will-change: transform;
}
.cursor::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: #fff; transition: transform .45s var(--ease); }
.cursor.on::after { transform: scale(5); }
.has-cursor .cursor { display: block; }

/* ---------- Top bar ---------- */
.top {
  position: fixed; z-index: 30; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; gap: 16px;
  padding: calc(18px + env(safe-area-inset-top)) var(--gutter) 0;
  font-size: 14px; mix-blend-mode: difference; color: #fff;
}
.top nav { display: flex; gap: clamp(14px, 2vw, 30px); }
.top-r { display: flex; align-items: center; gap: clamp(14px, 2vw, 30px); }

/* Theme switch: a sun in dark mode (go light), a moon in light mode (go dark). */
.theme {
  display: grid; place-items: center; width: 22px; height: 22px; margin: -3px -3px -3px 0;
  border: 0; background: none; color: inherit; cursor: pointer; border-radius: 50%;
}
.theme svg { width: 16px; height: 16px; transition: transform .6s var(--ease); }
.theme:hover svg { transform: rotate(40deg); }
.theme .moon { display: none; }
:root[data-theme="light"] .theme .sun { display: none; }
:root[data-theme="light"] .theme .moon { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme .sun { display: none; }
  :root:not([data-theme="dark"]) .theme .moon { display: block; }
}
html:not(.js) .theme { display: none; }
.name { font-weight: 500; }

.index {
  position: fixed; z-index: 30; right: var(--gutter); bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.index i { display: block; width: 28px; height: 1px; background: var(--line); }
#index-now { color: var(--fg); }

/* Text that rolls upward to a duplicate on hover. */
.roll { display: inline-block; position: relative; overflow: hidden; vertical-align: top; }
.roll > span { display: block; transition: transform .6s var(--ease); }
.roll > span + span { position: absolute; left: 0; top: 100%; }
a:hover .roll > span, .roll:hover > span, a:focus-visible .roll > span { transform: translateY(-100%); }

/* ---------- Line reveal ---------- */
.reveal { overflow: hidden; }
.reveal > span { display: block; transition: transform 1.3s var(--ease), opacity .8s; }
.js .reveal:not(.in) > span { transform: translateY(105%); opacity: 0; }
.reveal.d1 > span { transition-delay: .08s; }
.reveal.d2 > span { transition-delay: .16s; }

/* ---------- Sections ---------- */
.s { position: relative; height: 210vh; }
.s-long { height: 320vh; }
.pin {
  position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden;
  padding: 0 var(--gutter) calc(52px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; justify-content: flex-end;
}
.copy { max-width: min(680px, 100%); }
.label { font-family: var(--mono); font-size: 12px; color: var(--dim); margin-bottom: 12px; }
.label b { margin-left: 10px; font-family: 'Noto Sans JP', var(--mono); }
h2 { font-size: clamp(52px, 8.2vw, 136px); font-weight: 400; line-height: 1; letter-spacing: -.045em; padding-bottom: .1em; }
.lede { font-size: clamp(16px, 1.35vw, 20px); line-height: 1.35; color: var(--fg); margin-top: 12px; max-width: 26em; letter-spacing: -.01em; text-wrap: balance; }

/* ---------- Hero ---------- */
.hero { height: 170vh; }
.hero .pin { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.hero-text { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: clamp(8px, 1.2vw, 18px); }
.hero-sub { font-size: clamp(16px, 1.6vw, 24px); letter-spacing: -.015em; }
.ja { font-family: 'Noto Sans JP', var(--sans); font-size: 12px; color: var(--dim); }
.hero-name {
  font-size: 16.6vw; line-height: .86; font-weight: 400; letter-spacing: -.055em;
  white-space: nowrap; margin-left: -.05em; padding-bottom: .06em;
  display: flex; gap: .22em;
}
.hero-name > span { display: block; transition: transform 1.5s var(--ease), opacity .8s; }
.hero-name > span + span { transition-delay: .09s; }
.js .hero-name:not(.in) > span { transform: translateY(105%); opacity: 0; }

/* ---------- Hello ---------- */
.s-hello { position: relative; min-height: 100vh; min-height: 100svh; display: flex; }
.hello-inner {
  flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
  padding: 90px var(--gutter) calc(52px + env(safe-area-inset-bottom));
}
.mail {
  display: block; font-size: clamp(30px, 8.5vw, 150px); line-height: 1.04; letter-spacing: -.05em;
  overflow-wrap: anywhere; transition: color .3s;
}
.mail:hover { color: var(--ember); }
.hello-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.links { display: flex; flex-wrap: wrap; gap: 6px clamp(16px, 2.4vw, 36px); font-size: 15px; }
.foot { font-family: var(--mono); font-size: 12px; color: var(--dim); padding-right: 92px; }

/* ---------- Fallbacks ---------- */
.no-gl #gl, .no-gl .cursor { display: none; }
.no-gl .s, html:not(.js) .s { height: auto; }
.no-gl .pin, html:not(.js) .pin { position: static; height: auto; min-height: 70vh; padding-top: 90px; }
html:not(.js) #gl, html:not(.js) .index { display: none; }

/* ---------- Narrow ---------- */
@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  .top nav { display: none; }
  .hero-text { display: block; }
  .ja { margin-top: 6px; }
  .hero-name { display: block; font-size: 33vw; line-height: .84; }
  .hero-name > span + span { margin-top: -.02em; }
  h2 { font-size: clamp(52px, 17vw, 110px); }
  .foot { padding-right: 0; width: 100%; margin-bottom: 24px; }
  .mail { font-size: 8.5vw; overflow-wrap: normal; }
  .hero .pin { padding-bottom: calc(44px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal > span, .hero-name > span, .roll > span { transition: none; }
}
