/* =========================================================
   Letterpress — 活版印刷と活字のはじまり
   Museum / Room M2（回廊「デザインと人類の5万年」・技術の通史）
   スイス・スタイル共通クロームを踏襲。アクセントは活版インクの朱。
   ========================================================= */

:root {
  --unit: 8px;
  --baseline: 28px;
  --content: 1180px;
  --margin: 40px;

  --ink: #111111;
  --paper: #f4f2ec;
  --grey: #8a8780;
  --line: rgba(17, 17, 17, 0.14);
  --accent: #b23a1f;   /* 活版インクの朱 */
  --metal: #6f7176;    /* 活字ボディ（鉛合金） */
  --metal-d: #4c4e52;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Inter", "Noto Sans JP", "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
  line-height: var(--baseline);
  font-feature-settings: "palt" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

p { margin: 0 0 var(--baseline); }
em { font-style: normal; color: var(--accent); }
strong { font-weight: 700; }

.wrap {
  max-width: calc(var(--content) + var(--margin) * 2);
  margin-inline: auto;
  padding-inline: var(--margin);
}

/* ============ MASTHEAD ============ */
.masthead { padding-block: calc(var(--baseline) * 3) calc(var(--baseline) * 2); border-bottom: 2px solid var(--ink); }
.masthead .wrap { display: grid; grid-template-columns: repeat(12, 1fr); column-gap: 24px; }
.masthead__meta { grid-column: 1 / -1; display: flex; gap: var(--unit); margin-bottom: calc(var(--baseline) * 2); flex-wrap: wrap; }
.tag { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--paper); background: var(--accent); padding: 4px 10px; border-radius: 2px; }
.tag--muted { background: transparent; color: var(--grey); border: 1px solid var(--line); }
.masthead__title { grid-column: 1 / 9; margin: 0; font-size: clamp(58px, 11.5vw, 150px); line-height: 0.86; font-weight: 900; letter-spacing: -0.03em; }
.masthead__sub { grid-column: 9 / -1; align-self: end; justify-self: end; margin: 0; font-size: 20px; font-weight: 700; color: var(--accent); writing-mode: vertical-rl; }
.masthead__lede { grid-column: 1 / 8; margin-top: calc(var(--baseline) * 2); font-size: 20px; line-height: var(--baseline); }
.masthead__index { grid-column: 9 / -1; margin: calc(var(--baseline) * 2) 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.masthead__index li { display: flex; gap: 14px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; font-weight: 500; }
.masthead__index span { color: var(--accent); font-weight: 700; }

/* ============ SECTION ============ */
.section { padding-block: calc(var(--baseline) * 3); border-bottom: 1px solid var(--line); }
.section__head { display: grid; grid-template-columns: repeat(12, 1fr); column-gap: 24px; }
.section__num { grid-column: 1 / 2; margin: 0; font-size: 16px; font-weight: 700; color: var(--accent); }
.section__title { grid-column: 2 / 6; margin: 0; font-size: clamp(36px, 5.4vw, 64px); line-height: 0.96; font-weight: 900; letter-spacing: -0.02em; }
.section__body { grid-column: 7 / -1; }
.lead { font-size: 22px; line-height: calc(var(--baseline) + 4px); font-weight: 500; }
.section--invert { background: #14100c; color: var(--paper); border-bottom: none; }
.section--invert .section__title { color: var(--paper); }

/* ============ DEMO LAYOUT ============ */
.demo { margin-top: calc(var(--baseline) * 2); display: grid; grid-template-columns: 1fr 340px; gap: 48px; align-items: start; }
.stage { background: var(--paper); border: 1px solid var(--line); padding: clamp(18px, 3vw, 32px); }
.ctrl { align-self: start; }
.ctrl__label { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--grey); margin: 0 0 14px; }
.ctrl__readout { margin: 18px 0 10px; font-size: 18px; font-weight: 700; line-height: 1.5; }
.ctrl__hint { margin: 0; font-size: 14px; line-height: 1.7; color: var(--grey); }
.ctrl__btns { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }

.btn { font-family: inherit; font-size: 15px; font-weight: 500; letter-spacing: 0.02em; background: var(--ink); color: var(--paper); border: 1px solid var(--ink); padding: 11px 18px; border-radius: 2px; cursor: pointer; transition: background 0.18s, color 0.18s; }
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--sm { font-size: 14px; padding: 9px 14px; }
.btn.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ============ 01 — 活字ケース & 植字 ============ */
.mode-toggle { display: inline-flex; border: 1px solid var(--ink); border-radius: 2px; overflow: hidden; margin-bottom: 18px; }
.mode-toggle button { font-family: inherit; font-size: 14px; font-weight: 700; padding: 8px 16px; border: none; background: var(--paper); color: var(--ink); cursor: pointer; }
.mode-toggle button.is-on { background: var(--ink); color: var(--paper); }

.case-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--grey); margin: 0 0 10px; }
.case-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 7px; }
.case-grid.kana { grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); }
/* 活字（拾う対象）＝鏡文字の金属ボディ */
.type-sort {
  aspect-ratio: 3 / 4; border: none; cursor: pointer; padding: 0;
  background: linear-gradient(160deg, #8f9195, var(--metal) 55%, var(--metal-d));
  border-radius: 2px; box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 1px 2px rgba(0,0,0,.3);
  display: grid; place-items: center; transition: transform .1s;
}
.type-sort:hover { transform: translateY(-2px); }
.type-sort:active { transform: translateY(0); }
.type-sort .face {
  font-family: "Noto Serif JP", Georgia, "Times New Roman", serif; font-weight: 700;
  font-size: 22px; color: #f2f0ea; transform: scaleX(-1); /* 鏡文字 */
  text-shadow: 0 1px 0 rgba(0,0,0,.4);
}
.type-sort.spacer { background: linear-gradient(160deg, #d8d5cc, #bdb9ae); }
.type-sort.spacer .face { color: #6f6c64; font-size: 11px; transform: none; font-family: inherit; font-weight: 700; }

/* 組みステッキ（組んだ版） */
.stick-wrap { margin-top: 6px; }
/* 版は刷り上がりの鏡像＝文字も並び順も左右反転。だから右から組む（row-reverse） */
.stick {
  min-height: 96px; display: flex; flex-direction: row-reverse; flex-wrap: wrap; align-content: flex-start; gap: 3px;
  background: repeating-linear-gradient(90deg, #2b2d31, #2b2d31 2px, #303237 2px, #303237 4px);
  border: 3px solid #17181b; border-right-width: 10px; border-radius: 3px; padding: 10px;
}
.stick:empty::before { content: "活字を拾って、ここに組む（版は右から）"; color: #8b8d92; font-size: 14px; font-weight: 700; align-self: center; margin-inline: auto; }
.set-sort {
  min-width: 34px; height: 62px; border-radius: 2px;
  background: linear-gradient(160deg, #9a9ca0, var(--metal) 55%, var(--metal-d));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 1px 2px rgba(0,0,0,.4);
  display: grid; place-items: center;
}
.set-sort .face { font-family: "Noto Serif JP", Georgia, serif; font-weight: 700; font-size: 26px; color: #f2f0ea; transform: scaleX(-1); text-shadow: 0 1px 0 rgba(0,0,0,.4); }
.set-sort.sp { background: linear-gradient(160deg, #cfccc3, #b0ada3); height: 46px; align-self: flex-end; }
.set-sort.sp.quad { min-width: 52px; }
.stick-actions { display: flex; gap: 10px; margin-top: 12px; }

/* ============ 02 — 刷る ============ */
.press-flow { display: grid; gap: 18px; }
.press-row { display: grid; grid-template-columns: 1fr; gap: 8px; }
.press-cap { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--grey); }
.plate {
  background: repeating-linear-gradient(90deg, #2b2d31, #2b2d31 2px, #303237 2px, #303237 4px);
  border: 3px solid #17181b; border-radius: 3px; padding: 10px; display: flex; flex-direction: row-reverse; flex-wrap: wrap; gap: 3px; min-height: 84px; align-content: center;
}
.press-arrow { text-align: center; font-size: 22px; color: var(--accent); font-weight: 900; }
.print-paper {
  background: #fbfaf6; border: 1px solid var(--line); box-shadow: inset 0 0 40px rgba(180,170,150,.18); border-radius: 2px;
  padding: 22px 18px; min-height: 84px; display: flex; flex-wrap: wrap; align-items: center; gap: 0;
}
.print-paper:empty::before { content: "「刷る」を押すと、組んだ版が紙に転写されます"; color: var(--grey); font-size: 14px; }
.print-ch { font-family: "Noto Serif JP", Georgia, serif; font-weight: 700; font-size: 34px; color: #14110c; line-height: 1; text-shadow: 0 0 1px rgba(20,17,12,.5); }
.print-ch.sp { display: inline-block; }

/* ============ 03 — QUIZ ============ */
.quiz-picto { width: 60%; max-width: 260px; color: var(--ink); }
.quiz-picto svg { width: 100%; height: auto; display: block; }
.quiz-q { font-size: 16px; font-weight: 700; margin: 0 0 14px; min-height: 56px; }
.quiz-opts { display: flex; flex-direction: column; gap: 10px; }
.quiz-opt { font-family: inherit; font-size: 15px; text-align: left; cursor: pointer; background: transparent; color: var(--ink); border: 1px solid var(--line); padding: 11px 16px; border-radius: 2px; transition: background .15s, border-color .15s, color .15s; }
.quiz-opt:hover { border-color: var(--ink); }
.quiz-opt:disabled { cursor: default; }
.quiz-opt.is-correct { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.quiz-opt.is-wrong { border-color: var(--accent); color: var(--accent); }

/* ============ CLOSING ============ */
.pull { margin-bottom: calc(var(--baseline) * 2); }
.pull p { margin: 0; font-size: clamp(30px, 4.4vw, 56px); line-height: 1.18; font-weight: 900; letter-spacing: -0.02em; max-width: 18ch; }
.pull cite { display: block; margin-top: var(--baseline); font-style: normal; font-size: 15px; color: var(--accent); font-weight: 700; }
.takeaway__t { font-size: 18px; line-height: 1.85; max-width: 62ch; }

/* ============ COLOPHON ============ */
.colophon { background: var(--ink); color: var(--paper); padding-block: calc(var(--baseline) * 2); }
.colophon .wrap { display: grid; grid-template-columns: repeat(12, 1fr); column-gap: 24px; }
.colophon__brand { grid-column: 1 / 4; margin: 0; font-size: 22px; font-weight: 900; }
.colophon__txt { grid-column: 5 / 9; margin: 0 0 var(--unit); font-size: 14px; line-height: 1.6; color: #c9c6bf; }
.colophon__spec { grid-column: 9 / -1; margin: 0; font-size: 12px; color: var(--grey); text-align: right; font-weight: 500; }
.colophon__refs { grid-column: 1 / -1; font-size: 12px; line-height: 1.8; color: #9b9890; }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  :root { --margin: 24px; }
  body { font-size: 16px; }
  .masthead__title { grid-column: 1 / -1; }
  .masthead__sub { grid-column: 1 / -1; writing-mode: horizontal-tb; justify-self: start; margin-top: var(--unit); }
  .masthead__lede, .masthead__index { grid-column: 1 / -1; }
  .section__num { grid-column: 1 / -1; }
  .section__title { grid-column: 1 / -1; margin-bottom: var(--baseline); }
  .section__body { grid-column: 1 / -1; }
  .demo { grid-template-columns: 1fr; gap: 28px; }
  .colophon__brand, .colophon__txt, .colophon__spec, .colophon__refs { grid-column: 1 / -1; text-align: left; margin-bottom: var(--unit); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
