:root {
  --bg: #F4F1EA;
  --bg-rgb: 244, 241, 234;
  --ink: #1A1917;
  --muted: #6B655C;
  --accent: #26415E;
  --seal: #C1432E;
  --hair: rgba(26, 25, 23, 0.14);
}

:root[data-theme="dark"] {
  --bg: #45413A;
  --bg-rgb: 69, 65, 58;
  --ink: #F4F1EA;
  --muted: #A39C8E;
  --accent: #7C9CC4;
  --seal: #E2604A;
  --hair: rgba(244, 241, 234, 0.16);
}

:root {
  --section-scrim: linear-gradient(
    180deg,
    rgba(var(--bg-rgb), 0.96) 0%,
    rgba(var(--bg-rgb), 0.78) 18%,
    rgba(var(--bg-rgb), 0.78) 82%,
    rgba(var(--bg-rgb), 0.96) 100%
  );
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans', sans-serif;
  min-height: 100vh;
  transition: background 500ms ease, color 500ms ease;
  overflow-x: hidden;
}

a { text-decoration: none; }
::selection { background: #26415E; color: #F4F1EA; }

@keyframes blinkPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes letterboxIn { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes petalFall {
  0% { transform: translate3d(0, -8vh, 0) rotate(0deg); }
  100% { transform: translate3d(0, 108vh, 0) rotate(360deg); }
}
@keyframes petalSway {
  0%, 100% { margin-left: 0; }
  50% { margin-left: 34px; }
}

/* karesansui: raked gravel + pond ripple, ambient and motionless */
.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.ambient-svg { position: absolute; inset: 0; }
.rake-lines { stroke: var(--ink); stroke-width: 1; fill: none; opacity: 0.05; }
.ripple-lines { stroke: var(--accent); stroke-width: 1; fill: none; }
.ripple-a { opacity: 0.06; }
.ripple-b { opacity: 0.045; }

/* falling petals, ambient and sparse */
.petals {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.petal {
  position: absolute;
  top: 0;
  will-change: transform;
  animation-name: petalFall, petalSway;
  animation-timing-function: linear, ease-in-out;
  animation-iteration-count: infinite, infinite;
}
@media (prefers-reduced-motion: reduce) {
  .ambient-bg, .petals { display: none; }
}

/* top bar */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: clamp(18px, 3vw, 32px) clamp(20px, 6vw, 64px) clamp(14px, 2vw, 20px);
  pointer-events: none;
  background: rgba(var(--bg-rgb), 0);
  border-bottom: 1px solid transparent;
  transition: background 400ms ease, border-color 400ms ease;
}
.topbar.scrolled {
  background: rgba(var(--bg-rgb), 0.96);
  border-bottom-color: var(--hair);
}
.topbar-left { display: flex; flex-direction: column; gap: 6px; }
.brand-mark {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.22em;
  color: var(--ink);
  pointer-events: auto;
}
.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
  opacity: 0.75;
}
.status-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: blinkPulse 2.6s ease-in-out infinite;
}
.telemetry-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  opacity: 0.55;
  font-variant-numeric: tabular-nums;
}
.telemetry-sep { opacity: 0.5; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  pointer-events: auto;
}
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
}
.lang-sep { color: var(--muted); opacity: 0.5; }
.lang-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  transition: color 200ms ease;
}
.lang-btn:hover { color: var(--accent); }
.lang-btn[aria-pressed="true"] {
  color: var(--ink);
  border-bottom: 1px solid var(--ink);
}
.theme-toggle {
  pointer-events: auto;
  background: none;
  border: 1px solid var(--hair);
  border-radius: 999px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--ink);
  font-size: 14px;
  font-family: 'IBM Plex Mono', monospace;
  transition: border-color 200ms ease, color 200ms ease;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* hero */
.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(90px, 14vw, 140px) clamp(20px, 6vw, 64px) clamp(60px, 8vw, 90px);
  position: relative;
  overflow: hidden;
}
/* image sits on its own negative-z layer, brightness/saturation baked into
   the files themselves (not a CSS filter). Uses real position:fixed rather
   than background-attachment:fixed — the latter is unreliable/ignored on
   iOS Safari and several other engines when scrolling. JS toggles the
   .past-hero class to fade this out once the hero scrolls out of view, so
   the fixed layer doesn't bleed into the rest of the page. */
.hero::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: linear-gradient(180deg, rgba(var(--bg-rgb), 0.62) 0%, rgba(var(--bg-rgb), 0.5) 50%, rgba(var(--bg-rgb), 0.42) 100%), url('images/hero-forest-light.webp');
  background-size: cover;
  background-position: center bottom;
  background-repeat: no-repeat;
  /* Set continuously from scroll position (script.js), not a threshold
     class toggle — a proper scroll-linked dissolve rather than a pop. */
  opacity: var(--hero-fade, 1);
}
:root[data-theme="dark"] .hero::before {
  background-image: linear-gradient(180deg, rgba(var(--bg-rgb), 0.55) 0%, rgba(var(--bg-rgb), 0.42) 50%, rgba(var(--bg-rgb), 0.35) 100%), url('images/hero-forest-dark.webp');
}
.letterbox {
  position: absolute; left: 0; right: 0;
  height: 3px;
  background: var(--ink);
  opacity: 0.9;
  animation: letterboxIn 1400ms cubic-bezier(0.16, 0.7, 0.2, 1) both;
}
/* The letterbox bars are a one-time cinematic flourish on load, but the
   bottom one sits almost exactly at the hero/section seam — without
   this it stays printed as a stark line right where the transition is
   supposed to be graceful. Dissolves together with the hero photo. */
.hero .letterbox {
  opacity: calc(var(--hero-fade, 1) * 0.9);
}
.letterbox-top { top: 0; transform-origin: left; }
.letterbox-bottom { bottom: 0; transform-origin: right; }

.hero-kicker {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin-bottom: 10px;
  text-shadow: 0 1px 16px rgba(var(--bg-rgb), 0.9), 0 1px 4px rgba(var(--bg-rgb), 0.9);
}
.hero-gloss {
  font-family: 'Shippori Mincho', serif;
  font-style: italic;
  font-size: clamp(13px, 1.2vw, 15px);
  line-height: 1.5;
  color: var(--muted);
  max-width: 34ch;
  margin-bottom: clamp(28px, 5vw, 48px);
  text-shadow: 0 1px 16px rgba(var(--bg-rgb), 0.9), 0 1px 4px rgba(var(--bg-rgb), 0.9);
}
.hero-gloss-reading {
  font-family: 'IBM Plex Mono', monospace;
  font-style: normal;
  font-size: 0.85em;
  letter-spacing: 0.02em;
}
.hero-title {
  font-family: 'Shippori Mincho', serif;
  font-weight: 600;
  font-size: clamp(36px, 7vw, 92px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0;
  max-width: 14ch;
  text-shadow: 0 2px 24px rgba(var(--bg-rgb), 0.9), 0 1px 6px rgba(var(--bg-rgb), 0.85);
}
.hero-copy {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: clamp(16px, 1.6vw, 19px);
  line-height: 1.7;
  color: var(--muted);
  max-width: 38ch;
  margin: clamp(28px, 5vw, 44px) 0 0;
  text-shadow: 0 1px 16px rgba(var(--bg-rgb), 0.9), 0 1px 4px rgba(var(--bg-rgb), 0.9);
}
.hero-cta {
  margin-top: clamp(32px, 6vw, 56px);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--ink);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--ink);
  transition: color 200ms ease, border-color 200ms ease;
  text-shadow: 0 1px 16px rgba(var(--bg-rgb), 0.9), 0 1px 4px rgba(var(--bg-rgb), 0.9);
}
.hero-cta-arrow { color: var(--accent); }
.hero-cta:hover { color: var(--seal); border-color: var(--seal); }
.hero-cta:hover .hero-cta-arrow { color: var(--seal); }
.kanji-side {
  position: absolute;
  right: clamp(20px, 4vw, 56px);
  bottom: clamp(40px, 6vw, 72px);
  writing-mode: vertical-rl;
  font-family: 'Shippori Mincho', serif;
  font-size: 15px;
  letter-spacing: 0.3em;
  color: var(--muted);
  opacity: 0.45;
  text-shadow: 0 1px 10px rgba(var(--bg-rgb), 0.9);
}

/* generic blocks */
.block {
  /* top floor (100px) clears the fixed topbar's real height (~67px on
     narrow viewports) plus breathing room — 12vw alone shrinks below that
     on phones since it scales with width, not the topbar's fixed content. */
  padding: clamp(100px, 12vw, 140px) clamp(20px, 6vw, 64px);
  border-top: 1px solid var(--hair);
  position: relative;
}
/* one photo per section, echoing its kanji motif — kept far more muted
   than the hero (image barely surfacing) since these sections carry dense
   text and a single neutral image has to read in both themes, not just its
   own tuned one like the hero's pair does. Scrolls normally with the
   section (not fixed — that's a hero-only effect). The gradient fades
   almost fully to the flat background colour at the top/bottom edges so
   one section's photo doesn't cut hard into the next across the border —
   it blooms in the middle and dissolves at the seams instead. */
.block::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.block[data-reveal-key="philosophy"]::before {
  background-image: var(--section-scrim), url('images/section-philosophy.webp');
}
.block[data-reveal-key="discipline"]::before {
  background-image: var(--section-scrim), url('images/section-discipline.webp');
}
.block[data-reveal-key="work"]::before {
  background-image: var(--section-scrim), url('images/section-work.webp');
}
.block[data-reveal-key="how"]::before {
  background-image: var(--section-scrim), url('images/section-how.webp');
}
.block[data-reveal-key="about"]::before {
  background-image: var(--section-scrim), url('images/section-about.webp');
}
.block[data-reveal-key="contact"]::before {
  background-image: var(--section-scrim), url('images/section-contact.webp');
}
.block-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: clamp(24px, 4vw, 40px);
}
.block-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.block-counter {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--accent);
  opacity: 0.8;
}
.kanji-mid {
  position: absolute;
  right: clamp(16px, 3vw, 40px);
  top: 50%;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  font-family: 'Shippori Mincho', serif;
  font-size: 14px;
  letter-spacing: 0.3em;
  color: var(--muted);
  opacity: 0.22;
}

/* reveal-on-scroll */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 900ms cubic-bezier(0.22, 0.61, 0.36, 1), transform 900ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* 01 philosophy */
.philosophy-copy {
  font-family: 'Shippori Mincho', serif;
  font-weight: 500;
  font-size: clamp(24px, 3.4vw, 42px);
  line-height: 1.5;
  max-width: 22ch;
  margin: 0 0 0 clamp(0px, 4vw, 60px);
}

/* 02 what I do */
.discipline-list { display: flex; flex-direction: column; }
.discipline-row {
  display: grid;
  grid-template-columns: minmax(120px, 220px) 1fr;
  gap: clamp(16px, 3vw, 32px);
  padding: clamp(20px, 3vw, 30px) 0;
  border-top: 1px solid var(--hair);
}
.discipline-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--accent);
  padding-top: 2px;
}
.discipline-line {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: clamp(16px, 1.8vw, 20px);
  line-height: 1.6;
  max-width: 48ch;
  color: var(--ink);
}
.discipline-rule { border-top: 1px solid var(--hair); }

/* 03 selected work */
.work-eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--seal);
  margin-bottom: 14px;
}
.work-title {
  font-family: 'Shippori Mincho', serif;
  font-weight: 600;
  font-size: clamp(28px, 4vw, 52px);
  line-height: 1.2;
  max-width: 16ch;
  margin: 0 0 clamp(28px, 4vw, 44px);
}
.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 54ch) minmax(220px, 320px);
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
}
.work-copy {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: clamp(16px, 1.7vw, 19px);
  line-height: 1.75;
  color: var(--ink);
}
.work-copy p { margin: 0 0 1.4em; }
.work-copy p:last-child { margin-bottom: 0; }
.work-facts {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 2.5vw, 26px);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.03em;
  padding-top: 6px;
}
.work-facts dt { color: var(--muted); margin-bottom: 6px; }
.work-facts dd { margin: 0; color: var(--ink); line-height: 1.6; }

/* 04 how I work */
.principle-list {
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 3vw, 30px);
  max-width: 56ch;
}
.principle-row { display: flex; gap: clamp(16px, 3vw, 28px); }
.principle-n {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--accent);
  padding-top: 3px;
  flex: 0 0 28px;
}
.principle-text {
  font-family: 'Shippori Mincho', serif;
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.55;
  color: var(--ink);
}

/* 05 about */
.about-copy {
  font-family: 'Shippori Mincho', serif;
  font-weight: 500;
  font-size: clamp(22px, 2.8vw, 34px);
  line-height: 1.55;
  max-width: 26ch;
  margin: 0 0 0 clamp(0px, 4vw, 60px);
}

/* 06 contact */
.block-contact {
  padding: clamp(100px, 14vw, 160px) clamp(20px, 6vw, 64px) clamp(90px, 14vw, 160px);
}
.contact-title {
  font-family: 'Shippori Mincho', serif;
  font-weight: 600;
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1.2;
  margin: 0 0 clamp(24px, 4vw, 36px);
}
.contact-email {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(16px, 2vw, 22px);
  letter-spacing: 0.02em;
  color: var(--ink);
  border-bottom: 1px solid var(--hair);
  padding-bottom: 8px;
  transition: color 200ms ease, border-color 200ms ease;
}
.contact-email:hover { color: var(--accent); border-color: var(--accent); }
.seal {
  display: inline-block;
  width: 9px; height: 9px;
  background: var(--seal);
  border-radius: 1px;
  transform: rotate(45deg);
  flex: 0 0 auto;
}
.footer-row {
  margin-top: clamp(70px, 10vw, 120px);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  .letterbox, .status-dot { animation: none !important; }
  .reveal { transition: none; }
}

@media (max-width: 480px) {
  .seijaku-hero-title { font-size: 34px !important; }
}

/* Below this, the two-column grids (label|line, copy|facts) squeeze into
   unreadably narrow columns rather than wrapping normally — stack instead. */
@media (max-width: 700px) {
  .discipline-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .work-grid {
    grid-template-columns: 1fr;
    gap: clamp(32px, 6vw, 80px) 0;
  }
  .work-facts {
    padding-top: 0;
  }
}
