/* One stylesheet for every page, including the login form served by the Worker. */

:root {
  /* Chroma-zero white with a single cobalt accent: the N700 Shinkansen stripe, not flag red. */
  --bg: oklch(99% 0 0);
  --surface: oklch(96.5% 0.003 262);
  --ink: oklch(21% 0.012 262);
  --muted: oklch(45% 0.014 262);
  --rule: oklch(89% 0.006 262);
  --accent: oklch(46% 0.19 262);
  --accent-ink: oklch(99% 0 0);
  --focus: oklch(62% 0.19 262);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro JP", "SF Pro Display", "Hiragino Sans", "Helvetica Neue", system-ui, "Segoe UI", Arial, sans-serif;

  /* 1.25 modular scale from 16px */
  --t-1: 0.8125rem;
  --t0: 1rem;
  --t1: 1.25rem;
  --t2: 1.5625rem;
  --t3: 1.953rem;
  --t4: 2.441rem;

  --radius: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* z scale */
  --z-sticky: 10;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: oklch(17% 0.01 262);
    --surface: oklch(22% 0.012 262);
    --ink: oklch(94% 0.005 262);
    --muted: oklch(73% 0.012 262);
    --rule: oklch(31% 0.012 262);
    --accent: oklch(79% 0.11 262);
    --accent-ink: oklch(17% 0.01 262);
    --focus: oklch(79% 0.11 262);
  }
}
:root[data-theme="dark"] {
  --bg: oklch(17% 0.01 262);
  --surface: oklch(22% 0.012 262);
  --ink: oklch(94% 0.005 262);
  --muted: oklch(73% 0.012 262);
  --rule: oklch(31% 0.012 262);
  --accent: oklch(79% 0.11 262);
  --accent-ink: oklch(17% 0.01 262);
  --focus: oklch(79% 0.11 262);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: var(--t0)/1.6 var(--font);
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
}

/* Layout */
.wrap {
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 24px) clamp(56px, 10vw, 96px);
}
main.wrap { padding-top: clamp(28px, 6vw, 48px); }

/* Back link injected by the Worker on every inner page */
.back { padding-top: clamp(16px, 3vw, 24px); padding-bottom: 0; }
.back + main.wrap { padding-top: clamp(16px, 4vw, 32px); }
.back a {
  color: var(--muted);
  font-size: var(--t-1);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 2px;
}
.back a:hover, .back a:focus-visible { color: var(--ink); border-color: currentColor; }

/* Type */
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(var(--t3), 4vw + 1rem, var(--t4)); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: clamp(var(--t2), 2.5vw + 0.75rem, var(--t3)); font-weight: 700; letter-spacing: -0.015em; margin-top: clamp(40px, 8vw, 64px); }
h3 { font-size: var(--t1); font-weight: 700; margin-top: 28px; }
h4 { font-size: 1.0625rem; font-weight: 700; }
p { margin: 0.6em 0 0; text-wrap: pretty; }
p, li { max-width: 65ch; }
.muted { color: var(--muted); }
.sub { color: var(--muted); font-size: var(--t0); margin-top: 6px; }
.lede { max-width: 60ch; margin-top: 16px; }
small, .small { font-size: var(--t-1); }
b, strong { font-weight: 700; }

a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
a, button, summary { transition: color 0.15s var(--ease), background-color 0.15s var(--ease), border-color 0.15s var(--ease); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }

/* The one big mark on each page */
.kanji {
  font-weight: 800;
  font-size: clamp(5rem, 20vw, 9rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--accent);
  margin: 0 0 20px -0.04em;
}

/* Lists */
ul.plain { margin: 12px 0 0; padding-left: 1.2em; }
ul.plain li { margin: 8px 0; }
ul.plain li::marker { color: var(--muted); }

/* Two-column facts: name on the left, detail on the right */
.facts { list-style: none; margin: 16px 0 0; padding: 0; border-top: 1px solid var(--rule); }
.facts li { display: grid; grid-template-columns: minmax(7rem, 11rem) 1fr; gap: 4px 20px; padding: 10px 0; border-bottom: 1px solid var(--rule); max-width: none; }
.facts li b { font-weight: 700; }
.facts li span { color: var(--muted); }
@media (max-width: 480px) { .facts li { grid-template-columns: 1fr; } .facts li span { margin-top: -2px; } }

/* Tables */
.tablewrap { overflow-x: auto; margin-top: 16px; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 0.9375rem; }
th, td { text-align: left; vertical-align: top; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--rule); }
th { font-weight: 500; color: var(--muted); }
thead th, tr:first-child th { font-weight: 700; color: var(--ink); }
tr.total td { font-weight: 700; }

/* Callouts: a tinted block, never a side stripe */
.note {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.9375rem;
  margin-top: 16px;
}
.note b { font-weight: 700; }

/* Maps */
.map {
  height: min(60vh, 340px);
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: var(--surface);
  overflow: hidden;
  margin: 20px 0 8px;
}
.map.big { height: min(70vh, 440px); }
.map iframe { display: block; width: 100%; height: 100%; border: 0; }

/* Numbered timeline of stops */
.stops { list-style: none; margin: 20px 0 0; padding: 0; position: relative; }
.stops::before { content: ""; position: absolute; left: 13px; top: 14px; bottom: 14px; width: 2px; background: var(--rule); }
.stop { position: relative; padding: 0 0 24px 44px; }
.stop:last-child { padding-bottom: 8px; }
.stop .num {
  position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 0.8125rem;
}
.stop .num.none { border-style: dashed; border-color: var(--muted); }
.stop .t { font-size: var(--t-1); color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.stop h3, .stop h4 { margin: 0; }
.stop p { margin-top: 4px; }
.stop .go { color: var(--muted); font-size: 0.9375rem; margin-top: 6px; }
.tags { color: var(--muted); font-size: var(--t-1); margin-top: 8px; }
.tags span + span::before { content: " · "; }
.links { display: flex; gap: 18px; margin-top: 8px; font-size: 0.9375rem; font-weight: 600; }

/* Segmented control */
.toggle { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; padding: 3px; background: var(--bg); margin-top: 18px; }
.toggle button {
  font: 600 0.9375rem var(--font); border: 0; background: transparent; color: var(--ink);
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
}
.toggle button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* Collapsible sections */
details > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 12px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: ""; flex: none; width: 9px; height: 9px; align-self: center;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform 0.2s var(--ease);
}
details[open] > summary::before { transform: rotate(45deg); }
details > summary:hover::before { border-color: var(--ink); }

/* Form controls (login, phrases) */
input[type="password"], input[type="text"] {
  width: 100%; padding: 12px 14px; font: inherit; color: inherit;
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--bg);
}
input:focus-visible { outline-offset: 0; border-color: transparent; }
button.primary {
  width: 100%; padding: 12px; font: 600 var(--t0) var(--font); border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
button.primary:hover { filter: brightness(1.08); }

footer { padding-top: clamp(40px, 8vw, 64px); font-size: var(--t-1); color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
