/* Indigo-dyed cloth; crests are the undyed white. Guide lines in aobana (dayflower) blue,
   the washable ink crest painters sketch with. Kihada yellow marks data. */
:root {
  --ai: #13213f;        /* indigo cloth */
  --kachi: #0c1730;     /* deepest indigo */
  --nando: #1d3157;     /* raised indigo */
  --shiro: #eef0ea;     /* undyed white */
  --aobana: #86aef0;    /* dayflower guide ink */
  --kihada: #e2c25c;    /* amur-cork yellow */
  --mute: #9aa6bf;
  --cloth: var(--ai);
  --g0: #e2c25c; --g1: #86aef0; --g2: #e6a1b4; --g3: #8fc9a3; --g4: #e59a5b; --g5: #b6a4e3;
  --mincho: 'Shippori Mincho B1', 'Hiragino Mincho ProN', serif;
  --gothic: 'Zen Kaku Gothic New', 'Hiragino Sans', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; color: var(--shiro); font: 400 16px/1.65 var(--gothic);
  background: var(--ai);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .05 0 0 0 0 .09 0 0 0 0 .2 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
a { color: var(--shiro); text-decoration-color: var(--aobana); text-underline-offset: 3px; }
button { font: 500 14px/1 var(--gothic); color: var(--shiro); background: transparent; border: 1px solid #3a5283; border-radius: 999px; padding: 10px 16px; cursor: pointer; }
button:hover { border-color: var(--aobana); }
button[aria-pressed='true'] { background: var(--shiro); color: var(--kachi); border-color: var(--shiro); }
button.primary { background: var(--kihada); color: var(--kachi); border-color: var(--kihada); font-weight: 700; }
button:disabled { opacity: .35; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--kihada); outline-offset: 3px; }
h1, h2, h3 { font-family: var(--mincho); font-weight: 600; line-height: 1.15; margin: 0; }
h2 { font-size: clamp(32px, 4vw, 48px); }
h3 { font-size: 26px; }
.tategaki { writing-mode: vertical-rl; text-orientation: upright; font-family: var(--mincho); margin: 0; }

/* ---------- hero ---------- */
.hero { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: center; gap: 4vw; padding: 6vh 6vw; }
.hero-type { display: flex; gap: 32px; align-items: flex-start; }
.hero-kanji { font-size: clamp(90px, 13vw, 190px); font-weight: 800; line-height: 1; color: var(--shiro); letter-spacing: .06em; }
.hero h1 { font-size: clamp(40px, 5.2vw, 76px); max-width: 9ch; margin-top: 12px; }
.lede { font-size: 18px; max-width: 34ch; color: #cfd6e4; margin: 24px 0 32px; }
.hero-nav { display: flex; flex-wrap: wrap; gap: 20px; font-weight: 500; }
.hero-crest { margin: 0; justify-self: center; width: min(46vw, 78vh); }
.hero-crest svg { width: 100%; display: block; }
.hero-crest figcaption { margin-top: 12px; text-align: center; color: var(--mute); font-size: 14px; min-height: 1.6em; }
.hero-crest figcaption b { font-family: var(--mincho); color: var(--shiro); font-weight: 600; font-size: 18px; margin-right: 10px; }

/* ---------- shared svg ---------- */
.ink path, .ink circle { fill: var(--shiro); }
.ink .paper { fill: none; stroke: var(--cloth); stroke-linecap: round; }
.kage .ink path.part:not([data-role='enclosure']):not([data-role='overlay']) { fill: none; stroke: var(--shiro); }
.guides { fill: none; stroke: var(--aobana); stroke-width: 1.6; opacity: .75; }
.guides .dot { fill: var(--aobana); stroke: none; }

/* ---------- sections ---------- */
.section { padding: 12vh 6vw 6vh; }
.section-head { display: grid; grid-template-columns: auto minmax(0, 46ch) 1fr; gap: 16px 48px; align-items: end; margin-bottom: 40px; }
.section-head p { margin: 0; color: #cfd6e4; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.section-head .seg { justify-self: end; }

/* ---------- gallery board ---------- */
.board { position: relative; transition: height .7s cubic-bezier(.6, 0, .2, 1); }
.tile { position: absolute; top: 0; left: 0; width: var(--t); text-align: center; background: none; border: 0; border-radius: 12px; padding: 0; transition: transform .8s cubic-bezier(.6, 0, .2, 1), width .8s cubic-bezier(.6, 0, .2, 1); }
.tile svg { width: 100%; display: block; overflow: visible; }
.tile .crest { transition: transform .35s ease; transform-origin: 500px 500px; }
.tile:hover .crest, .tile:focus-visible .crest { transform: scale(1.05); }
.tile .lbl { display: block; margin-top: 6px; font-size: 13px; color: var(--mute); line-height: 1.3; }
.tile .lbl b { display: block; font: 600 17px/1.2 var(--mincho); color: var(--shiro); }
.tile .fp { opacity: 0; transition: opacity .6s; }
.board[data-mode='symmetry'] .tile .fp { opacity: 1; }
.tile.active .lbl b { color: var(--kihada); }
.row-label { position: absolute; left: 0; font-family: var(--mincho); transition: transform .8s cubic-bezier(.6, 0, .2, 1), opacity .5s; }
.row-label b { display: block; font-size: 22px; font-weight: 600; }
.row-label span { color: var(--mute); font-size: 13px; }

/* ---------- anatomy ---------- */
.anatomy { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 5vw; align-items: start; background: var(--kachi); --cloth: var(--kachi); }
.stage-wrap { position: relative; }
.stage-col { position: sticky; top: 4vh; }
#stage { width: 100%; max-height: 74vh; display: block; overflow: visible; }
.steps { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 20px 0 0; counter-reset: s; }
.steps li { counter-increment: s; }
.steps button::before { content: counter(s); font-family: var(--mincho); margin-right: 8px; color: var(--kihada); }
.steps button[aria-pressed='true']::before { color: var(--kachi); }
.step-cap { color: #cfd6e4; max-width: 60ch; min-height: 3.3em; margin: 14px 0 0; }
.info-col { display: grid; grid-template-columns: auto 1fr; gap: 28px; }
.info-col .tategaki { font-size: clamp(54px, 6vw, 84px); font-weight: 800; line-height: 1.05; letter-spacing: .05em; }
.info-col h3 { font-size: 34px; }
.info-col .romaji { font-family: var(--mincho); font-size: 20px; color: var(--kihada); margin: 4px 0 2px; }
.info-col .gloss { color: #cfd6e4; margin: 0 0 20px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 0 0 22px; font-size: 15px; }
.facts dt { color: var(--mute); }
.facts dd { margin: 0; }
.note { max-width: 52ch; font-size: 16.5px; line-height: 1.75; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 26px 0; }
.stat { border-top: 1px solid #2c4170; padding-top: 10px; }
.stat b { display: block; font: 600 28px/1.1 var(--mincho); color: var(--kihada); }
.stat span { font-size: 13px; color: var(--mute); }
.credit { font-size: 12.5px; color: var(--mute); max-width: 56ch; }
.strip { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 18px; grid-column: 1 / -1; }
.strip button { width: 42px; height: 42px; padding: 4px; border-radius: 8px; border-color: transparent; }
.strip button[aria-current='true'] { border-color: var(--kihada); background: none; }
.strip svg { width: 100%; height: 100%; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 0; font-size: 14px; color: #cfd6e4; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

/* ---------- workshop ---------- */
.ws-grid { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 5vw; align-items: start; }
.controls { display: grid; gap: 22px; }
.ctl > span { display: block; font-size: 14px; color: var(--mute); margin-bottom: 8px; }
.ctl output { color: var(--shiro); float: right; font-variant-numeric: tabular-nums; }
.picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.picker button { padding: 6px 4px 5px; border-radius: 10px; display: grid; justify-items: center; gap: 3px; font-size: 11.5px; }
.picker button svg { width: 34px; height: 34px; }
.picker button[aria-pressed='true'] svg .ink path { fill: var(--kachi); }
.picker button[aria-pressed='true'] svg .ink .paper { stroke: var(--shiro); }
input[type='range'] { width: 100%; accent-color: var(--kihada); }
select { width: 100%; font: 15px var(--gothic); color: var(--shiro); background: var(--nando); border: 1px solid #3a5283; border-radius: 8px; padding: 9px 10px; }
.ws-stage { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px 36px; }
.ws-stage .stage-wrap { max-width: 640px; }
#ws-svg { width: 100%; display: block; }
.ws-name { grid-row: span 2; display: flex; gap: 14px; }
.ws-name .tategaki { font-size: clamp(40px, 4.4vw, 64px); font-weight: 800; line-height: 1.08; letter-spacing: .04em; }
.ws-name .ro { writing-mode: vertical-rl; font-family: var(--mincho); color: var(--kihada); font-size: 17px; }
.ws-name .en { writing-mode: vertical-rl; color: var(--mute); font-size: 14px; }
.ws-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; padding: 0 6px; }
.check input { accent-color: var(--kihada); width: 16px; height: 16px; }
.field-head { display: grid; grid-template-columns: auto minmax(0, 46ch) 1fr; gap: 12px 40px; align-items: end; margin: 12vh 0 28px; }
.field-head p { margin: 0; color: #cfd6e4; }
.field-head button { justify-self: end; }
.field { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 22px 18px; }
.field button { border: 0; padding: 0; border-radius: 10px; text-align: center; }
.field svg { width: 100%; display: block; }
.field span { display: block; font: 600 15px/1.3 var(--mincho); margin-top: 6px; }
.field button:hover svg { transform: scale(1.04); }
.field svg { transition: transform .3s ease; }

.foot { padding: 6vh 6vw 8vh; color: var(--mute); font-size: 13px; max-width: 90ch; }

@media (max-width: 900px) {
  .hero, .anatomy, .ws-grid { grid-template-columns: 1fr; }
  .hero-crest { width: 86vw; }
  .section-head, .field-head { grid-template-columns: 1fr; }
  .section-head .seg, .field-head button { justify-self: start; }
  .stage-col { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tile, .row-label, .board { transition: none; }
}

/* ---------- language switch + Traditional Chinese type ---------- */
.lang-switch { position: fixed; top: 14px; right: 16px; z-index: 50; display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(12, 23, 48, .82); backdrop-filter: blur(6px); border: 1px solid #2c4170; }
.lang-switch button { border: 0; padding: 7px 12px; font-size: 13px; }
.lang-switch button[aria-pressed='true'] { background: var(--shiro); color: var(--kachi); }
:lang(zh-Hant) { --mincho: 'Noto Serif TC', 'Shippori Mincho B1', serif; --gothic: 'Noto Sans TC', 'Zen Kaku Gothic New', system-ui, sans-serif; }
:lang(ja) .hero h1, :lang(zh-Hant) .hero h1 { max-width: none; white-space: nowrap; }
