/* base reset ───────────────────────────────────────────────── */

/* Border-box everywhere: an element's declared width includes its padding and
   border, so width:100% + inline padding (e.g. .shell) never overflows its
   container. Under the content-box default, .shell overflows by its padding
   whenever a vertical scrollbar is present, producing a subtle site-wide
   horizontal scroll. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* No document-level horizontal scroll. Full-bleed rails (e.g. work's
   .shelf__rail at 100vw, which counts the scrollbar) and sub-pixel rounding can
   nudge content a few px past the viewport edge. clip (not hidden) suppresses
   the horizontal scroll without establishing a scroll container — the sticky
   nav and vertical scrolling are unaffected. Inner carousels scroll via their
   own overflow. */
html,
body {
  margin: 0;
  overflow-x: clip;
}

/* Links inherit their type color and drop the UA underline by default; styled
   links (nav, footer) set their own. Prevents stray UA-blue anchors such as
   .nav__brand on pages whose stylesheet doesn't reset anchors. */
a {
  color: inherit;
  text-decoration: none;
}

/* layout shell ─────────────────────────────────────────────── */

.page {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100svh;
  position: relative;
  isolation: isolate;
}

.shell {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem);
}

/* grain overlay ────────────────────────────────────────────── */

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  mix-blend-mode: overlay;
  opacity: 0.007;
  transition: opacity var(--sc-motion-mode-duration) var(--sc-p-motion-easing-out);
}

/* nav ──────────────────────────────────────────────────────── */

.nav {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: transparent;
  /* Transparent overlay anchored to the page top — it scrolls away with the
     content rather than sticking. Adaptive foreground: light on dark grounds
     (default), primary on light; nav.js resolves the tone from the section
     under the nav line as it exits. */
  color: var(--sc-p-color-warm-gray-300);
  transition: color var(--sc-motion-mode-duration) var(--sc-p-motion-easing-out);
}
.nav.is-on-light { color: var(--sc-color-text-primary); }

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: var(--sc-p-space-24);
}

.nav__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sc-p-space-12);
  font-family: var(--sc-p-font-family-sans);
  font-weight: var(--sc-p-font-weight-medium);
  font-size: var(--sc-p-font-size-18);
  letter-spacing: -0.005em;
  color: inherit;
}
.nav__wm-accent { color: var(--sc-color-brand-accent); }

.nav__mark {
  width: 22px;
  height: auto;
  flex: 0 0 auto;
  display: block;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: var(--sc-p-space-24);
  font-family: var(--sc-p-font-family-sans);
  font-size: var(--sc-p-font-size-14);
  font-weight: var(--sc-p-font-weight-medium);
  letter-spacing: 0.01em;
  color: inherit;
}

.nav__link {
  position: relative;
  padding: var(--sc-p-space-4) 0;
  color: inherit;
  transition:
    color var(--sc-motion-press-duration) var(--sc-motion-hover-easing),
    transform var(--sc-motion-press-duration) var(--sc-motion-hover-easing);
  will-change: transform;
}

/* Slot-machine character roll — split markup built by nav.js initNavRoll() at
   boot; no-JS keeps the plain link text (no .nav__label) and stays usable.
   Base glyph inherits the nav's adaptive tone (currentColor); the accent glyph
   is parked one line below and rises into place on hover/focus. */
.nav__label {
  display: inline-flex;
  align-items: baseline;
}

.nav__label-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.nav__char {
  display: inline-block;
  position: relative;
  overflow: hidden;
  height: 1.2em; /* fallback for engines without lh units */
  height: 1lh;
  vertical-align: bottom;
}

.nav__char-layer {
  display: block;
  transition: transform var(--sc-motion-mode-duration) var(--sc-motion-hover-easing);
  transition-delay: var(--nav-char-delay, 0ms);
}

.nav__char-layer--hover {
  position: absolute;
  left: 0;
  top: 100%;
  color: var(--sc-color-interactive-hover);
}

.nav__link:hover .nav__char-layer,
.nav__link:focus-visible .nav__char-layer {
  transform: translateY(-100%);
}

.nav__link:active {
  transform: scale(var(--sc-motion-press-scale));
}

.nav__link:focus-visible {
  outline: var(--sc-border-width-focus) solid var(--sc-color-border-focus);
  outline-offset: var(--sc-border-focus-offset);
  border-radius: var(--sc-radius-control);
}

/* Active / current item: brand accent, no roll (enhancer leaves it un-split). */
.nav__link[aria-current="page"] {
  color: var(--sc-color-brand-accent);
}

@media (prefers-reduced-motion: reduce) {
  .nav__char-layer {
    transition: none;
  }
  .nav__link,
  .nav__link:active {
    transition: none;
    transform: none;
  }
}

.theme-toggle {
  position: relative;
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  color: inherit;
  border-radius: var(--sc-radius-control);
  transition: color var(--sc-motion-press-duration) var(--sc-p-motion-easing-out),
    background-color var(--sc-motion-press-duration) var(--sc-p-motion-easing-out);
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  color: var(--sc-color-brand-accent);
  background: color-mix(in srgb, currentColor 10%, transparent);
}

/* Tri-state toggle (system / light / dark). All three icons share one grid
   cell; the icon for the active preference is shown and the others crossfade
   out with a slight scale + rotate so the swap reads as motion. */
.theme-toggle svg {
  grid-area: 1 / 1;
  width: 16px;
  height: 16px;
  opacity: 0;
  transform: scale(0.5) rotate(-90deg);
  transition: opacity var(--sc-motion-mode-duration) var(--sc-motion-mode-easing),
    transform var(--sc-motion-mode-duration) var(--sc-motion-mode-easing);
}

.theme-toggle[data-pref="auto"] .icon-auto,
.theme-toggle[data-pref="light"] .icon-sun,
.theme-toggle[data-pref="dark"] .icon-moon,
.theme-toggle:not([data-pref]) .icon-auto {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle svg { transition: none; }
}

/* Full-page theme crossfade via the View Transitions API (Chromium, Safari 18+).
   Firefox and reduced-motion fall back to an instant cut — the JS skips the
   transition there. Duration/easing tied to the mode-change motion tokens. */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--sc-motion-mode-duration);
  animation-timing-function: var(--sc-motion-mode-easing);
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none; }
}

/* hero / board ─────────────────────────────────────────────── */

.hero {
  position: relative;
  padding-block: var(--sc-p-space-64) var(--sc-p-space-48);
  display: flex;
  flex-direction: column;
  gap: var(--sc-p-space-48);
}

.hero__intro {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sc-p-space-24);
  flex-wrap: wrap;
}

.hero__eyebrow {
  font-family: var(--sc-p-font-family-mono);
  font-size: var(--sc-p-font-size-13);
  color: var(--sc-color-text-secondary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.hero__shokunin {
  font-family: var(--sc-p-font-family-mono);
  font-size: var(--sc-p-font-size-13);
  color: var(--sc-color-text-secondary);
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 0.5ch;
  transition: color var(--sc-motion-press-duration) var(--sc-p-motion-easing-out);
}

.hero__shokunin:hover,
.hero__shokunin:focus-visible {
  color: var(--sc-color-text-primary);
}

.hero__shokunin::after {
  content: "→";
  transition: transform var(--sc-motion-mode-duration) var(--sc-p-motion-easing-cinematic);
}

.hero__shokunin:hover::after,
.hero__shokunin:focus-visible::after {
  transform: translateX(4px);
}

.board {
  display: flex;
  flex-direction: column;
  gap: var(--sc-p-space-32);
  position: relative;
}

.rail {
  position: relative;
  display: block;
  width: 100%;
  height: calc(var(--tile-size) * 1.53 + 12px);
}

.rail__bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  height: 1px;
  background: var(--sc-color-border-strong);
  transition: background-color var(--sc-motion-mode-duration) var(--sc-p-motion-easing-out);
}

.rail__track {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.tile {
  position: absolute;
  bottom: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sc-p-font-family-mono);
  font-weight: 500;
  text-transform: uppercase;
  color: var(--sc-color-text-primary);
  background: var(--sc-color-surface-sunk);
  border: 1px solid color-mix(in srgb, var(--sc-color-border-strong) 18%, transparent);
  border-radius: 1px;
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--sc-p-color-utility-white) 8%, transparent),
    0 1px 0 color-mix(in srgb, var(--sc-p-color-utility-black) 24%, transparent),
    0 6px 10px -6px color-mix(in srgb, var(--sc-p-color-utility-black) 50%, transparent);
  overflow: hidden;
  will-change: transform, opacity;
  user-select: none;
}

.tile canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.55;
  mix-blend-mode: overlay;
}

.tile__char {
  position: relative;
  z-index: 1;
  letter-spacing: 0.02em;
}

.tile--space {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.tile--space canvas { display: none; }

/* reduced-motion path: fade tiles in place */
@media (prefers-reduced-motion: reduce) {
  .tile {
    transition: opacity var(--sc-motion-mode-duration) var(--sc-p-motion-easing-out);
  }
}

/* shokunin overlay ─────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--sc-color-surface-page) 92%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 200;
  display: none;
  opacity: 0;
  transition: opacity var(--sc-motion-mode-duration) var(--sc-p-motion-easing-out);
}

.overlay[aria-hidden="false"] {
  display: block;
  opacity: 1;
}

.overlay__inner {
  position: relative;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--sc-p-space-64) clamp(1rem, 4vw, 2.5rem);
  gap: var(--sc-p-space-24);
}

.overlay__kanji {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--sc-p-font-family-sans);
  font-size: clamp(14rem, 38vw, 28rem);
  font-weight: 300;
  color: var(--sc-color-text-primary);
  opacity: 0.04;
  pointer-events: none;
  user-select: none;
  line-height: 1;
  z-index: 0;
}

.overlay__label {
  font-family: var(--sc-p-font-family-mono);
  font-size: var(--sc-p-font-size-13);
  color: var(--sc-color-brand-accent);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}

.overlay__lede {
  font-size: var(--sc-p-font-size-32);
  font-weight: 300;
  line-height: 1.2;
  letter-spacing: -0.02em;
  max-width: 22ch;
  position: relative;
  z-index: 1;
}

.overlay__body {
  font-size: var(--sc-p-font-size-16);
  color: var(--sc-color-text-secondary);
  line-height: 1.55;
  max-width: 56ch;
  position: relative;
  z-index: 1;
}

.overlay__tagline {
  font-family: var(--sc-p-font-family-mono);
  font-size: var(--sc-p-font-size-13);
  color: var(--sc-color-text-primary);
  letter-spacing: 0.01em;
  margin-top: var(--sc-p-space-16);
  position: relative;
  z-index: 1;
}

.overlay__close {
  position: absolute;
  top: var(--sc-p-space-24);
  right: clamp(1rem, 4vw, 2.5rem);
  font-family: var(--sc-p-font-family-mono);
  font-size: var(--sc-p-font-size-13);
  color: var(--sc-color-text-secondary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: var(--sc-p-space-8) var(--sc-p-space-12);
  border: 1px solid var(--sc-color-border-default);
  border-radius: var(--sc-radius-control);
  transition: color var(--sc-motion-press-duration) var(--sc-p-motion-easing-out),
    border-color var(--sc-motion-press-duration) var(--sc-p-motion-easing-out);
  z-index: 2;
}

.overlay__close:hover,
.overlay__close:focus-visible {
  color: var(--sc-color-text-primary);
  border-color: var(--sc-color-text-primary);
}

/* footer ───────────────────────────────────────────────────── */

.footer {
  border-top: 1px solid var(--sc-color-border-default);
  background: var(--sc-color-surface-page);
  transition: background-color var(--sc-motion-mode-duration) var(--sc-p-motion-easing-out),
    border-color var(--sc-motion-mode-duration) var(--sc-p-motion-easing-out);
}

.footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sc-p-space-24);
  min-height: 48px;
  font-family: var(--sc-p-font-family-mono);
  font-size: var(--sc-p-font-size-13);
  color: var(--sc-color-text-secondary);
  padding-block: var(--sc-p-space-16);
}

.footer__email {
  color: var(--sc-color-text-secondary);
  transition: color var(--sc-motion-press-duration) var(--sc-p-motion-easing-out);
}

.footer__email:hover,
.footer__email:focus-visible {
  color: var(--sc-color-text-primary);
}

@media (max-width: 480px) {
  .nav__links {
    gap: var(--sc-p-space-16);
  }
  .nav__link[data-secondary] { display: none; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
