/* =====================================================================
   ch-hexapod.css: chapter 1, Hexapod (chapters/10-hexapod.html), two pages:
   the opener with the hero video and the labelled photo ("What's on it"),
   then the build log (a timeline of four stages) and how it walks (the
   gait drawing and a link to the web sim). Linked after css/book.css.
   Colours are book.css tokens; motion is transform / opacity / stroke.
   ===================================================================== */

/* ------------------------------------------------------------------ opener + hero */
.hex-open-note { max-width: 30em; margin: 0 0 var(--s4); font-size: var(--t-lede); line-height: 1.5; color: var(--ink); }
.hex-open-note a { text-underline-offset: 4px; }
.hex-hero .fig-frame { box-shadow: none; }
/* the opener is a tall page: the first screen is the title and the hero, the second the labelled photo */
.hex-open .opener-body.has-media { grid-template-columns: auto minmax(0, .62fr) minmax(0, 1.38fr); }
.hex-open .opener-body.has-media .ch-title { font-size: clamp(56px, 6.4vw, 112px); }
.hex-open .opener-media { align-self: center; margin: 0; }

/* ------------------------------------------------------------------ what's on it */
.hex-ga { position: relative; z-index: 2; display: grid; grid-template-columns: minmax(0, 471px) minmax(0, 1fr); grid-template-areas: "h h" "fig side"; gap: var(--s5) clamp(32px, 5vw, 80px); align-items: start; margin-top: var(--s7); padding-top: var(--s6); border-top: 1.5px solid var(--line); }
.hex-ga-h { grid-area: h; margin: 0; font: 700 clamp(30px, 3vw, 44px)/1 var(--f-disp); text-transform: uppercase; letter-spacing: .02em; }
.hex-ga-fig { grid-area: fig; width: 100%; }
.hex-ga-side { grid-area: side; display: grid; gap: var(--s5); align-content: start; }
.hex-ga .datasheet td:last-child { color: var(--ink-2); font-size: var(--t-small); }
.hex-tb { width: min(100%, 320px); justify-self: end; }

/* the parts: each a disclosure with an arrow; open, its note slides down under it and its balloon
   elsewhere it opens at once and the note still fades in. */
.hex-parts { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--line); }
.hex-parts > li { border-bottom: 1px solid rgba(142,179,230,.45); }
.part { interpolate-size: allow-keywords; }
.part summary { display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 6px 4px; cursor: pointer; list-style: none; }
.part summary::-webkit-details-marker { display: none; }
.part summary:hover { background: rgba(216,232,255,.06); }
.part summary b { font: 700 clamp(21px, 1.9vw, 26px)/1.05 var(--f-disp); text-transform: uppercase; letter-spacing: .04em; }
.part-arr { position: relative; width: 30px; height: 30px; margin-left: auto; border: 1.5px solid var(--line-2); border-radius: 50%; transition: transform .45s var(--ease), border-color .2s; }
.part-arr::before { content: ""; position: absolute; left: 50%; top: 45%; width: 8px; height: 8px; border-right: 1.8px solid var(--ink); border-bottom: 1.8px solid var(--ink); transform: translate(-50%, -50%) rotate(45deg); }
.part summary:hover .part-arr { border-color: var(--ink); }
.part[open] .part-arr { transform: rotate(180deg); border-color: var(--ink); }
.part p { margin: 0; padding: 0 4px 14px 46px; max-width: 34em; font-size: var(--t-small); line-height: 1.5; color: var(--ink); }
.mo .part p { transition: opacity .35s ease .1s, transform .45s var(--ease) .05s; }
.mo .part:not([open]) p { opacity: 0; transform: translateY(-8px); }
/* the open part's balloon on the photo fills in */
.callouts .co .pl.bal, .callouts .co text { transition: fill .3s; }
.hex-ga:has(.part[data-co="1"][open]) .co-1 .pl.bal,
.hex-ga:has(.part[data-co="2"][open]) .co-2 .pl.bal,
.hex-ga:has(.part[data-co="3"][open]) .co-3 .pl.bal,
.hex-ga:has(.part[data-co="4"][open]) .co-4 .pl.bal { fill: var(--ink); }
.hex-ga:has(.part[data-co="1"][open]) .co-1 text,
.hex-ga:has(.part[data-co="2"][open]) .co-2 text,
.hex-ga:has(.part[data-co="3"][open]) .co-3 text,
.hex-ga:has(.part[data-co="4"][open]) .co-4 text { fill: var(--paper); }
.hex-parts .key-n { flex: none; }

/* ------------------------------------------------------------------ build log: the timeline */
.tl { position: relative; list-style: none; margin: var(--s5) 0 0; padding: 34px 0 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s5) clamp(18px, 2.2vw, 34px); }
/* the rail: a dimension line across the top, with a node over each stage */
.tl::before { content: ""; position: absolute; left: 0; right: 0; top: 11px; height: 1.5px; background: var(--line); transform-origin: 0 50%; }
.mo .tl:not(.in)::before { transform: scaleX(0); }
.mo .tl.in::before { transition: transform 1.2s var(--ease); }
.tl-st { position: relative; display: flex; flex-direction: column; gap: 10px; }
.tl-no { position: absolute; top: -34px; left: 0; margin: 0; display: grid; place-items: center; width: 24px; height: 24px; border: 1.5px solid var(--ink); border-radius: 50%; background: var(--paper); font: 600 10.5px/1 var(--f-mono); letter-spacing: .02em; }
.tl-next .tl-no { border-style: dashed; }
.tl-t { margin: 6px 0 0; font: 700 clamp(21px, 1.8vw, 26px)/1.05 var(--f-disp); text-transform: uppercase; letter-spacing: .03em; }
.tl-d { margin: 0; font-size: var(--t-small); line-height: 1.5; }
.tl .fig-ctl { gap: 8px; grid-template-columns: auto minmax(0, 1fr) 6ch; }
.tl .fig-ctl .play { padding: 0 9px; }
.tl .fig-ctl .play span { display: none; }   /* icon only in a narrow column; the button keeps its name */
.tl .fig-reserved .reserved { padding: 10px 12px; font-size: 13px; }
.tl figcaption { margin-top: 8px; }
.tl .fig-frame { aspect-ratio: 16 / 9; }   /* one frame size along the rail; the clips are cropped to it */

/* ------------------------------------------------------------------ how it walks */
.hex-walk { margin-top: var(--s7); padding-top: var(--s6); border-top: 1.5px solid var(--line); align-items: start; }
.hex-walk-h { margin: 0 0 var(--s4); font: 700 clamp(30px, 3vw, 44px)/1 var(--f-disp); text-transform: uppercase; letter-spacing: .02em; }
.hex-gait-fig { container-type: inline-size; }
.hex-gait-fig .anim { aspect-ratio: 16 / 10; }
/* reserve the controls bar gait.js adds under the drawing (44 px buttons + 1.5 px rule) */
.js .hex-gait-fig:not(:has(.vp-tools)) .anim { margin-bottom: calc(45.5px + var(--s3)); }
.hex-gaitlist { list-style: none; margin: var(--s3) 0 0; padding: 0; border-top: 1.5px solid var(--line); }
.hex-gaitlist li { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; padding: 8px 0 7px; border-bottom: 1px solid rgba(142,179,230,.45); }
.hex-gaitlist .n { min-width: 2.2em; font: 600 12px/1 var(--f-mono); letter-spacing: .08em; color: var(--ink-2); }
.hex-gaitlist b { font: 700 21px/1.05 var(--f-disp); text-transform: uppercase; letter-spacing: .04em; }
.hex-gaitlist small { font: italic 400 15px/1.3 var(--f-body); color: var(--ink-2); }
/* the still that stands in for the gait drawing without JS (gait.js removes it when it mounts) */
.hex-still { display: grid; grid-template-columns: minmax(0, 45fr) minmax(0, 55fr); gap: 0 18px; align-items: center; padding: 14px 16px 12px; }
.hex-still svg { display: block; width: 100%; height: auto; overflow: visible; }
.hex-still .pl.ft { fill: var(--ink); stroke: var(--ink); }
.hex-still .pl.bd, .hex-still .pl.sv, .hex-still .pl.ft.up, .hex-still .msk { fill: var(--paper); }
.hex-still .pl.bar { stroke: var(--ink); }
.hex-still .pl.sup { fill: rgba(216,232,255,.08); stroke: var(--ink); }
.hex-still .hd, .hex-still .rw { fill: var(--ink); font-weight: 600; }
.hex-still .mk { stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; paint-order: stroke; }
html:not(.js) .hex-gait-fig .anim { aspect-ratio: auto; }
.js .hex-still { position: absolute; inset: 0; overflow: hidden; }

/* the web sim: a card that opens hexapod-sim.html */
.sim-card { display: grid; grid-template-columns: 150px minmax(0, 1fr); grid-template-areas: "art t" "art s"; gap: 4px 18px; align-items: center; margin-top: var(--s5); padding: 12px 16px 12px 12px; border: 1.5px solid var(--line); text-decoration: none; transition: background-color .2s; }
.sim-card:hover, .sim-card:focus-visible { background: rgba(216,232,255,.07); }
.sim-card-art { grid-area: art; display: block; border: 1px solid var(--line-2); padding: 4px; }
.sim-card-art svg { display: block; width: 100%; height: auto; overflow: visible; }
.sim-card-t { grid-area: t; align-self: end; font: 700 22px/1.05 var(--f-disp); text-transform: uppercase; letter-spacing: .04em; }
.sim-card-t span { display: inline-block; transition: transform .3s var(--ease); }
.sim-card:hover .sim-card-t span { transform: translateX(5px); }
.sim-card-s { grid-area: s; align-self: start; font: 400 13px/1.45 var(--f-mono); color: var(--ink-2); }

/* ------------------------------------------------------------------ narrower windows */
@media (max-width: 1180px) {
  .tl { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--s6); }
  .tl::before { display: none; }
  .tl-st { padding-top: 34px; }
  .tl-no { top: 0; }
  .tl-st::before { content: ""; position: absolute; left: 30px; right: 0; top: 11px; height: 1px; background: var(--line-2); }
  .tl { padding-top: 0; }
}
@media (min-width: 761px) and (max-width: 1000px) {
  .hex-open .opener-body.has-media { grid-template-columns: auto minmax(0, 1fr); }
  .hex-open .opener-media { grid-column: 1 / -1; margin-top: var(--s5); }
}

/* ------------------------------------------------------------------ phone */
/* "What's on it" stacks (photo, then parts and spec) up to 900 px: beside a 471 px photo the side column
   was under 200 px on a landscape phone, the part names broke and the spec notes were cut */
@media (max-width: 900px) {
  .hex-ga { grid-template-columns: minmax(0, 1fr); grid-template-areas: "h" "fig" "side"; }
  .hex-ga-fig { justify-self: center; max-width: 471px; }
}
@media (max-width: 760px) {
  .hex-tb { justify-self: stretch; width: auto; }
  .hex-gaitlist b { font-size: 20px; }
  .hex-walk-text { order: -1; }
  .sim-card { grid-template-columns: 96px minmax(0, 1fr); }
  .hex-open .opener-body.has-media { grid-template-columns: minmax(0, 1fr); }
  .hex-open .opener-body.has-media .ch-title { font-size: min(15vw, 64px); }
  .hex-open .opener-media { margin-top: var(--s5); }
}
/* the spec table: item over value and note, so nothing is squeezed into a 70 px column. On a phone, and
   from 901 to 1000 px, where the table sits in a side column under 300 px wide */
@media (max-width: 760px), (min-width: 901px) and (max-width: 1000px) {
  .hex-spec tr { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 14px; padding: 8px 0; }
  .hex-spec th { grid-column: 1 / -1; padding: 0 0 2px; }
  .hex-spec td { padding: 0; }
}
@media (max-width: 560px) {
  .tl { grid-template-columns: minmax(0, 1fr); }
  .tl .fig-ctl .play span { display: inline; }
}
/* js/anim/gait.js draws its compact layout (robot above, chart below) when the drawing is under
   560 px wide; that layout is 640 px tall: reserve it, so mounting does not shift the page */
@media (max-width: 620px) {
  .js .hex-gait-fig .anim { aspect-ratio: auto; height: 643px; }
  .hex-still { grid-template-columns: minmax(0, 1fr); gap: 18px 0; }
  .hex-still svg:first-child { justify-self: center; max-width: 280px; }
}
@container (max-width: 562.4px) {
  .js .hex-gait-fig .anim { aspect-ratio: auto; height: 643px; }
}

/* a button over each balloon on the photo (js/anim/parts.js): opens that part in the list */
.co-hit { position: absolute; z-index: 6; width: 48px; height: 48px; margin: -24px 0 0 -24px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.co-hit:hover { background: rgba(216,232,255,.18); }
.co-hit:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
