/* accordion-gallery.css — extracted from accordion-gallery.md, 2026-08-13.
 *
 * This component was written as a markdown spec with its code in fenced
 * blocks — readable, but not linkable: a build cannot <link> a .md. The
 * prose, the reasoning and the don'ts stay in accordion-gallery.md; this is the
 * shippable part, extracted verbatim.
 */

/* ── 1 · The mechanism is three declarations ───────────────────────────────────────── */
.gallery { display: flex; }

/* ⚠ THE FALLBACK IN var(--ease, …) IS LOAD-BEARING, AND ITS ABSENCE IS WHY
   THIS FELT "TOO SNAPPY". `--ease` is not defined anywhere in the library —
   it came over from the source's own stylesheet during extraction. An
   unresolved var() makes the whole declaration INVALID AT COMPUTED-VALUE TIME,
   so `transition` fell back to its initial value and the panels snapped open
   with no animation at all. It reads as "the timing is wrong"; it is actually
   "there is no transition". Any var() in a transition or animation shorthand
   needs a fallback for exactly this reason — the failure is silent and total,
   never partial. */
.panel {
  flex: 1;
  filter: grayscale(1);
  transition:
    flex   var(--gallery-speed, .75s) var(--ease, cubic-bezier(.22, 1, .36, 1)),
    filter var(--gallery-speed, .75s) var(--ease, cubic-bezier(.22, 1, .36, 1));
}
.panel.is-open { flex: 2.5; filter: none; }

/* ── 2 · The label turns from vertical to horizontal ────────────────────────
 * The source's collapsed panels carry the name running UP the panel, and it
 * swings to horizontal as the panel opens.
 *
 * ⭐ IT IS A ROTATION, NOT A writing-mode SWAP. `writing-mode` is not an
 * animatable property — switching it would jump — so the label is normal
 * horizontal text rotated -90° about its bottom-left corner, and opening
 * takes it back to 0°. Same two keyframes the flex-grow is already using, so
 * the turn and the widening are one motion instead of two. */
.panel__label {
  position: absolute;
  left: var(--gallery-pad, 1.1rem);
  bottom: var(--gallery-pad, 1.1rem);
  margin: 0;
  /* ⚠ width: max-content IS REQUIRED, not tidying. An <h3> is a block, so it
     is as wide as the panel; rotating that about its bottom-left corner swings
     a panel-wide box out past the panel's left edge, where `overflow: hidden`
     clips it — the closed labels simply vanish (measured at x = -18px inside a
     panel starting at 0). Shrink-wrapped, the rotated box occupies its LINE
     HEIGHT horizontally and its TEXT LENGTH vertically, which is exactly the
     column of type the effect wants. */
  width: max-content;

  /* ⚠ ROTATION ALONE PUTS THE LABEL OUTSIDE THE PANEL. About the bottom-left
     corner, rotate(-90deg) maps a corner at offset (dx,dy) to (dy,-dx), so a
     box w×h ends up spanning x ∈ [-h, 0] — entirely LEFT of its own origin,
     off the panel and clipped away by `overflow: hidden`. The companion
     translateY(100%) is applied in the element's OWN rotated frame, which
     lands it at x ∈ [0, h] instead: up and to the right, reading bottom-to-top
     from the corner. Both states keep the same function list
     (rotate + translateY) so the two transforms interpolate componentwise —
     mismatched lists fall back to a discrete swap and the turn would jump. */
  transform-origin: 0 100%;
  transform: rotate(-90deg) translateY(100%);
  white-space: nowrap;
  transition: transform var(--gallery-speed, .75s) var(--ease, cubic-bezier(.22, 1, .36, 1));
}
.panel.is-open .panel__label { transform: rotate(0deg) translateY(0%); }

/* the panel has to be a positioning context for the label, and clip its photo */
.panel { position: relative; overflow: hidden; }

/* ── 2b · open on HOVER instead of click ────────────────────────────────────
 * Pure CSS, no JS, and it composes with the panel being a real link: hovering
 * opens, clicking follows the href. In click mode the JS below owns `.is-open`
 * and a click on an ALREADY-OPEN panel is what navigates — so the first click
 * is never stolen from the person who only wanted to look.
 *
 * ⚠ Do not ship hover as the ONLY way in. A touch device has no hover, and
 * `.gallery--hover` alone leaves every panel shut on a phone; the JS keeps
 * click working underneath. */
.gallery--hover .panel:hover,
.gallery--hover .panel:focus-visible { flex: 2.5; filter: none; }
.gallery--hover .panel:hover .panel__label,
.gallery--hover .panel:focus-visible .panel__label { transform: rotate(0deg) translateY(0%); }

/* when a panel is a link, it must not look like one until it is */
.panel[href] { text-decoration: none; color: inherit; display: block; }
.panel[href]:focus-visible { outline: 2px solid currentColor; outline-offset: -4px; }

/* ── 3 · Full-bleed and panel count (Ivan's requirements) ───────────────────────────────────────── */
/* ⚠ 100vw IS WIDER THAN THE PAGE WHENEVER THERE IS A SCROLLBAR. The viewport
   unit includes the scrollbar gutter; the page's content box does not. So
   `width: 100vw` overhangs by ~15px and creates a horizontal scrollbar of its
   own — Ivan: "E-02 got some horizontal width? it mustn't be." The bleed is
   still available, but it is measured against the ELEMENT'S OWN containing
   block, which never counts the gutter, so it can reach the edges and no
   further. */
.gallery-wrap { width: 100%; }
.gallery-wrap--bleed {
  width: calc(100% + 2 * var(--bleed, 0px));
  margin-inline: calc(-1 * var(--bleed, 0px));
}
.gallery      { height: clamp(420px, 78vh, 900px); }

/* ── Required guards ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) { .panel, .panel__label { transition: none; } }
@media (max-width: 900px) { .gallery { flex-direction: column; } .panel.is-open { flex: 2; } }
