/* =========================================================
   Gestalt — 知覚のきほん
   Graphic Design Museum / Room 03
   スイス・スタイルの共通クロームを踏襲。
   ========================================================= */

: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;
}

* { 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  (bauhaus/grid と共通)
   ========================================================= */
.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(40px, 6vw, 72px); line-height: 0.92; 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  (stage + control)
   ========================================================= */
.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); }

/* control panel */
.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; }
.ctrl__slider-row { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--grey); }
.ctrl__slider-row .slider { flex: 1; }
.slider { 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__hint { margin: 0; font-size: 14px; line-height: 1.7; color: var(--grey); }
.ctrl__btns { display: flex; flex-wrap: wrap; gap: 10px; }

/* buttons */
.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; }

/* =========================================================
   DOT FIELDS  (proximity / similarity / common fate)
   ========================================================= */
.dotfield { display: grid; grid-template-columns: repeat(6, auto); justify-content: center; align-content: center; }
.dot { width: 18px; height: 18px; border-radius: 50%; background: var(--ink); transition: background 0.2s, border-radius 0.2s, transform 0.2s; }
.gestalt-stage--dark .dot { background: var(--paper); }
.dot.is-color { background: var(--accent); }
.dot.is-shape { border-radius: 2px; }

/* common fate field */
.dotfield--cf { grid-template-columns: repeat(9, auto); gap: 16px; }
.dotfield--cf .dot { width: 16px; height: 16px; }
.dot--cf.is-running { animation: cf-bob 1.1s ease-in-out infinite; }
@keyframes cf-bob {
  0%, 100% { transform: translateY(-13px); }
  50%      { transform: translateY(13px); }
}

/* =========================================================
   03 CLOSURE — Kanizsa
   ========================================================= */
.kanizsa { width: min(100%, 380px); height: auto; }
.kanizsa .pac { fill: var(--ink); transition: transform 0.5s cubic-bezier(.6,0,.2,1); transform-box: fill-box; transform-origin: center; }
.kanizsa.is-open .pac { transform: rotate(180deg); }
.kanizsa .ghost { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 5; opacity: 0; transition: opacity 0.4s; }
.kanizsa.is-open .ghost { opacity: 0; }

/* =========================================================
   04 CONTINUITY
   ========================================================= */
.cross { width: min(100%, 420px); height: auto; }
.cross path { fill: none; stroke: var(--ink); stroke-width: 8; stroke-linecap: round; transition: stroke 0.35s; }
.cross.is-split #curveA { stroke: var(--accent); }
.cross.is-split #curveB { stroke: var(--blue); }

/* =========================================================
   05 FIGURE / GROUND — Rubin
   ========================================================= */
.rubin { width: min(100%, 320px); height: auto; }
#rubinBg { fill: #1b1b1b; transition: fill 0.35s; }
#rubinVase { fill: var(--paper); transition: fill 0.35s; }
.rubin.show-vase #rubinBg { fill: #1b1b1b; }
.rubin.show-vase #rubinVase { fill: var(--accent); }
.rubin.show-faces #rubinBg { fill: var(--accent); }
.rubin.show-faces #rubinVase { fill: #1b1b1b; }

/* =========================================================
   CLOSING
   ========================================================= */
.pull { margin-bottom: calc(var(--baseline) * 2); }
.pull p { margin: 0; font-size: clamp(28px, 4vw, 48px); line-height: 1.25; 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 { }
.takeaway__t { font-size: 18px; line-height: 1.85; max-width: 62ch; color: var(--ink); }

/* =========================================================
   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; }
  .dot--cf.is-running { animation: none; transform: translateY(-13px); }
}
