/*
 * 制作の流れ（見本の家）の見た目。ビフォーアフターの見た目は before-after.css（パーツ/ビフォーアフター の写し）。
 *
 * 図面の作法を借りている:
 *   番号の丸 … 図面の通り芯の記号（X1〜X5）と同じ形
 *   一点鎖線 … 通り芯の線。頭の5枚と、01〜05 の番号をつなぐ
 *
 * 画像はどれもクリックできない（押しても何も起きない）。01〜05 の fig-frame は <span>。
 * 末尾の「参考」（.refs）は 01〜05 の番号の流れの外にある（.step クラスを持たない）ので、
 * 縦の一点鎖線や重なりの検査（検算.py）には入らない。
 */

:root {
  color-scheme: light;
  --paper: #f4f2ed;
  --sheet: #ffffff;
  --ink: #1d1e20;
  --sub: #575b61;
  --faint: #85888d;
  --rule: #b7b1a5;      /* 一点鎖線 */
  --hair: #dcd7cd;      /* 細い区切り線 */
  --red: #d6312f;       /* 照合の絵の赤い線と同じ色。凡例だけに使う */

  --max: 1160px;
  --gutter: 40px;
  --rail: 88px;
  --bubble: 44px;
  --pad-top: 120px;

  --mincho: "Zen Old Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --gothic: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;

  /* 一点鎖線（長い線 14px・すき間 4px・点 2px・すき間 4px） */
  --dashdot-v: linear-gradient(to bottom, var(--rule) 0 14px, transparent 14px 18px, var(--rule) 18px 20px, transparent 20px 24px);
  --dashdot-h: linear-gradient(to right, var(--rule) 0 14px, transparent 14px 18px, var(--rule) 18px 20px, transparent 20px 24px);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--gothic);
  font-size: 16px;
  line-height: 1.9;
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
  /* 折り返すのは、組む.py が入れた言葉の切れ目（<wbr>）と句読点のあとだけ */
  word-break: keep-all;
  overflow-wrap: anywhere;
}

img { display: block; max-width: 100%; height: auto; }
picture { display: block; }
a { color: inherit; }
h1, h2, h3, p, ol, ul, figure { margin: 0; padding: 0; }

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

/* ---- いちばん上の帯（図面の紙の頭） ---- */

.sheet-head { border-bottom: 1px solid var(--hair); }
.sheet-head .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  font-size: 12.5px;
  line-height: 1.6;
  letter-spacing: 0.16em;
  color: var(--sub);
}

/* ---- 頭 ---- */

.hero { padding: 96px 0 24px; }

.hero h1 {
  font-family: var(--mincho);
  font-weight: 600;
  font-size: clamp(32px, 5vw, 60px);
  line-height: 1.35;
  letter-spacing: 0.06em;
  font-feature-settings: "palt";
}

/* 題は「図面から、」のあとでだけ折り返す */
.ph { display: inline-block; }

.lead {
  margin-top: 28px;
  max-width: 34em;
  font-size: 17px;
  line-height: 2;
}

/* 番号の丸（通り芯の記号の形） */
.bubble {
  --b: var(--bubble);
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  flex: none;
  width: var(--b);
  height: var(--b);
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--gothic);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* 頭の5枚。番号の丸を一点鎖線でつなぐ */
.overview {
  --gap: 24px;
  --ob: 36px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--gap);
  margin-top: 72px;
  list-style: none;
}

.overview::before {
  content: "";
  position: absolute;
  top: calc(var(--ob) / 2);
  left: calc((100% - 4 * var(--gap)) / 10);
  right: calc((100% - 4 * var(--gap)) / 10);
  height: 1px;
  background: var(--dashdot-h);
  background-size: 24px 1px;
  background-repeat: repeat-x;
}

.overview li { min-width: 0; }

.overview a {
  display: grid;
  justify-items: center;
  gap: 16px;
  text-decoration: none;
  border-radius: 2px;
}

.overview .bubble { --b: var(--ob); font-size: 12px; }

.ov-img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: 2px;
  background: var(--sheet);
  box-shadow: 0 0 0 1px var(--hair);
}

.ov-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.ov-name {
  font-size: 13.5px;
  line-height: 1.5;
  letter-spacing: 0.08em;
  text-align: center;
}

@media (hover: hover) {
  .overview a:hover .ov-img img { transform: scale(1.04); }
  .overview a:hover .bubble { background: var(--ink); color: var(--paper); }
}

.overview a:focus-visible { outline: 2px solid var(--ink); outline-offset: 8px; }

/* 開いたとき、一点鎖線が 01 から 05 へ引かれ、5枚が順に出てくる。
   終わったあとに動きの名残を残さない（backwards） */
@media (prefers-reduced-motion: no-preference) {
  .overview::before {
    transform-origin: left center;
    animation: ov-line 1.1s cubic-bezier(0.45, 0, 0.2, 1) 0.15s backwards;
  }
  .overview li { animation: ov-rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) backwards; }
  .overview li:nth-child(1) { animation-delay: 0.1s; }
  .overview li:nth-child(2) { animation-delay: 0.3s; }
  .overview li:nth-child(3) { animation-delay: 0.5s; }
  .overview li:nth-child(4) { animation-delay: 0.7s; }
  .overview li:nth-child(5) { animation-delay: 0.9s; }
}

/* 横の線（PC）にも縦の線（スマホ）にも同じ動きを使う。幅で動きの名前を変えると、窓の幅が変わったときに引き直しになる */
@keyframes ov-line { from { transform: scale(0); } to { transform: none; } }
@keyframes ov-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---- 01〜05 ---- */

.step {
  position: relative;
  padding-top: var(--pad-top);
}

/* 番号の丸をつなぐ縦の一点鎖線。01 の丸から始まり、05 の丸で終わる */
.step::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(max(var(--gutter), (100% - var(--max)) / 2) + var(--rail) / 2 - 0.5px);
  width: 1px;
  background: var(--dashdot-v);
  background-size: 1px 24px;
  background-repeat: repeat-y;
}

.step:first-of-type::before { top: calc(var(--pad-top) + var(--bubble) / 2); }
.step:last-of-type::before { bottom: auto; height: calc(var(--pad-top) + var(--bubble) / 2); }

.step-grid {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
}

.rail .bubble { margin: 0 auto; }

.step-main { min-width: 0; }

.step-head {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  column-gap: 56px;
  row-gap: 18px;
  align-items: start;
  margin-bottom: 48px;
}

.kind {
  font-size: 13px;
  line-height: var(--bubble);
  letter-spacing: 0.2em;
  color: var(--sub);
}

.step h2 {
  margin-top: 4px;
  font-family: var(--mincho);
  font-weight: 600;
  font-size: clamp(25px, 3vw, 36px);
  line-height: 1.45;
  letter-spacing: 0.06em;
  font-feature-settings: "palt";
}

/* 本文の1行目を、見出しの1行目にそろえる */
.step-text { padding-top: calc(var(--bubble) + 12px); }

.spec {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--hair);
  list-style: none;
  font-size: 13.5px;
  line-height: 1.8;
}

.spec span {
  margin-right: 0.7em;
  color: var(--faint);
  font-size: 12.5px;
  letter-spacing: 0.08em;
}

.note {
  margin-top: 14px;
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--sub);
}

/* ---- 絵 ---- */

.fig-frame {
  position: relative;
  display: block;
  overflow: hidden;
}

.fig-frame img { width: 100%; }

/* 図面は白い紙を机に置いた見え方 */
.fig--sheet .fig-frame {
  background: var(--sheet);
  box-shadow:
    0 0 0 1px rgba(40, 32, 20, 0.05),
    0 1px 2px rgba(40, 32, 20, 0.06),
    0 18px 40px -18px rgba(40, 32, 20, 0.28);
}

.fig--pic .fig-frame {
  border-radius: 2px;
  background: #e7e3db;
}

.fig figcaption {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 20px;
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--sub);
}

/* 03 の照合 */
.pair {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 32px 56px;
  align-items: center;
  margin-top: 72px;
}

.pair h3 {
  font-family: var(--mincho);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.5;
  letter-spacing: 0.06em;
  font-feature-settings: "palt";
}

.pair-text p { margin-top: 14px; }

.legend {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--sub);
}

.legend i {
  display: block;
  flex: none;
  width: 32px;
  height: 2px;
  background: var(--red);
}

/* 04 の見比べ */
.fig--slider .ba-slider {
  --ba-radius: 2px;
  --ba-label-bg: rgba(24, 24, 22, 0.52);
}

/* 05 の寄り。正方形と 1.6:1 を、高さをそろえて並べる */
.details {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 20px;
  margin-top: 24px;
}

/* ---- 参考 ---- */

.refs {
  padding-top: var(--pad-top);
  padding-bottom: 120px;
  border-top: 1px solid var(--hair);
}

.refs-head { margin-bottom: 40px; }

.refs-head h2 {
  margin-top: 4px;
  font-family: var(--mincho);
  font-weight: 600;
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.5;
  letter-spacing: 0.06em;
  font-feature-settings: "palt";
}

.refs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px 24px;
}

/* ---- 幅ごと ---- */

@media (max-width: 1024px) {
  :root { --rail: 72px; --pad-top: 104px; }
  .step-head { column-gap: 40px; }
}

@media (max-width: 880px) {
  .step-head { grid-template-columns: minmax(0, 1fr); }
  .step-text { padding-top: 0; max-width: 40em; }
  .pair { grid-template-columns: minmax(0, 1fr); margin-top: 56px; }
}

/* スマホ: 縦の一点鎖線をやめ、番号の丸は見出しの左に */
@media (max-width: 760px) {
  :root { --gutter: 20px; --pad-top: 88px; --bubble: 40px; }
  body { font-size: 15.5px; }
  .hero { padding: 64px 0 8px; }
  .lead { font-size: 16px; }
  .step::before { display: none; }
  .step-grid { position: relative; grid-template-columns: minmax(0, 1fr); }
  .rail { position: absolute; top: 0; left: 0; }
  .kind { padding-left: calc(var(--bubble) + 14px); }
  .refs-head .kind { padding-left: 0; }
  .step-head { margin-bottom: 32px; }
  .refs { padding-bottom: 72px; }
}

/* 頭の5枚は、縦に並べて左の一点鎖線でつなぐ */
@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .overview {
    --row: 80px;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    margin-top: 48px;
  }
  .overview::before {
    top: calc(var(--row) / 2);
    bottom: calc(var(--row) / 2);
    left: calc(var(--ob) / 2 - 0.5px);
    right: auto;
    width: 1px;
    height: auto;
    background: var(--dashdot-v);
    background-size: 1px 24px;
    background-repeat: repeat-y;
  }
  .overview a {
    grid-template-columns: var(--ob) 120px minmax(0, 1fr);
    justify-items: start;
    align-items: center;
    gap: 16px;
  }
  .ov-img { width: 120px; }
  .ov-name { text-align: left; font-size: 14px; letter-spacing: 0.04em; }
  .sheet-head .wrap { font-size: 11.5px; letter-spacing: 0.1em; }
}

@media (max-width: 640px) and (prefers-reduced-motion: no-preference) {
  .overview::before { transform-origin: center top; }
}

@media (max-width: 520px) {
  .details { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .refs-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; }
}

/* いちばん狭い幅（320px など）でも、頭の5枚の名前が1行に収まるように */
@media (max-width: 360px) {
  .overview { --row: 67px; }
  .overview a { grid-template-columns: var(--ob) 100px minmax(0, 1fr); gap: 12px; }
  .ov-img { width: 100px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ov-img img, .bubble { transition: none; }
}
