/* =========================================================
   Ratio — 比率のきほん (Golden Ratio & Canon)
   Graphic Design Museum / Room 05
   スイス・スタイル共通クロームを踏襲。
   ========================================================= */

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

  --ink: #111111;
  --paper: #f4f2ec;
  --grey: #8a8780;
  --line: rgba(17, 17, 17, 0.14);
  --accent: #d5231a;
  --blue: #1c40a0;
  --gold: #c79a3a;
}

* { 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); }
.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(64px, 13vw, 176px); 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: var(--ink); 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: center; }
.gestalt-stage { aspect-ratio: 16 / 11; display: grid; place-items: center; background: var(--paper); border: 1px solid var(--line); padding: clamp(20px, 4vw, 48px); }
.gestalt-stage--dark { background: #1b1b1b; border-color: rgba(244,242,236,0.18); }

.ctrl { align-self: center; }
.ctrl__label { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--grey); margin: 0 0 14px; }
.section--invert .ctrl__label { color: #b8b5ad; }
.slider { width: 100%; accent-color: var(--accent); }
.ctrl__readout { margin: 18px 0 10px; font-size: 18px; font-weight: 700; line-height: 1.4; }
.ctrl__readout--light { color: var(--paper); }
.ctrl__readout.is-hit { color: var(--gold); }
.ctrl__hint { margin: 0; font-size: 14px; line-height: 1.7; color: var(--grey); }
.ctrl__btns { display: flex; flex-wrap: wrap; gap: 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; }
.section--invert .btn { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.section--invert .btn:hover, .section--invert .btn.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* =========================================================
   01 — RATIO BAR
   ========================================================= */
.ratio-bar { position: relative; width: 100%; height: 56%; display: flex; }
.ratio-seg { height: 100%; transition: width 0.08s linear; }
.ratio-seg--a { background: var(--ink); }
.ratio-seg--b { background: var(--accent); }
.ratio-target {
  position: absolute; top: -10px; bottom: -10px; left: 61.8%;
  width: 0; border-left: 2px dashed var(--gold);
}
.ratio-target::after {
  content: "φ"; position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
  font-size: 13px; font-weight: 700; color: var(--gold);
}

/* =========================================================
   02 — FIBONACCI
   ========================================================= */
.fib { width: min(100%, 460px); height: auto; }
.fib-square { fill: none; stroke: rgba(244,242,236,0.4); stroke-width: 0.8; }
.fib-square--fill { fill: rgba(199,154,58,0.10); }
.fib-label { fill: var(--paper); font-size: 11px; font-weight: 700; font-family: "Inter", sans-serif; text-anchor: middle; dominant-baseline: central; opacity: 0.85; }
.fib-spiral { fill: none; stroke: var(--gold); stroke-width: 2; opacity: 0; transition: opacity 0.4s ease; }
.fib.show-spiral .fib-spiral { opacity: 1; }

/* =========================================================
   03 — PAGE CANON
   ========================================================= */
.canon { width: min(100%, 460px); height: auto; }
.canon-page { fill: #fff; stroke: var(--ink); stroke-width: 1.5; }
.canon-diag line { stroke: var(--blue); stroke-width: 0.8; opacity: 0; transition: opacity 0.35s ease; }
.canon.show-diag .canon-diag line { opacity: 0.7; }
.canon-text rect { fill: rgba(213,35,26,0.12); stroke: var(--accent); stroke-width: 1.5; opacity: 0; transition: opacity 0.35s ease; }
.canon.show-text .canon-text rect { opacity: 1; }

/* =========================================================
   CLOSING
   ========================================================= */
.pull { margin-bottom: calc(var(--baseline) * 2); }
.pull p { margin: 0; font-size: clamp(26px, 3.6vw, 44px); line-height: 1.28; font-weight: 900; letter-spacing: -0.02em; max-width: 20ch; }
.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; 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; }

/* =========================================================
   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 { grid-column: 1 / -1; text-align: left; margin-bottom: var(--unit); }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
