/* Shared header, reset and typography live in styles.css, which loads first */

/* Scroll anchoring OFF for this page. Normally, when content grows above what
   you're looking at, the browser scrolls to keep your view still. Here that
   would hide the popup above the screen instead of sliding the ring down */
html {
  overflow-anchor: none;
}

/* =========================================================
   THE CAROUSEL AS A DRAWING SHEET (R2d). The page's one framed object
   (see THE SHEET; the entries lost theirs in D-b), a ruled title
   strip, and a ring of small sheets that projcript.js builds from
   data/projects.json. Every line uses --color-accent, so it follows
   the theme like the entries do
   ========================================================= */
#slideshow {
  position: relative;
  /* Room between the frame lines and what's inside. projcript.js fits the ring to the
     width INSIDE this padding, so it's real breathing room on phones too. Fixed, not vw:
     the wide layout below starts at a 62rem CONTENT width, and wider padding at 1440px
     pushed the sheet under it (the popup jumped above the ring) */
  padding: var(--space-6) var(--space-5);
  /* A column: title strip, then (on phones) the popup, then the ring */
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Makes #slideshow a container: the @container rules below ask how wide
     the SLIDESHOW is, not the whole window */
  container-type: inline-size;
  /* Beside the ring, the popup floats (position: absolute), so it can't push the frame taller.
     With the full picture in it, it can be taller than the ring: projcript.js (fitSheet) then
     sets a min-height so the frame grows to hold it, and this eases the frame open and shut */
  min-height: 0;
  transition: min-height var(--popup-speed, 350ms) var(--popup-ease, ease);
}

/* The hidden attribute must win over display: flex above (otherwise the empty frame shows) */
#slideshow[hidden] {
  display: none;
}

/* Title strip: "DWG 00 · Assembly view" on the left, the spin button on the right,
   ruled off underneath like the title of a drawing */
.ring-head {
  order: -2;                           /* always first, above the phone popup (order: -1) */
  align-self: stretch;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-accent);
}

/* Small square buttons in the drawing's mono lettering: Pause spin and Close */
.sheet-button {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-accent);
  border-radius: 0;
  background: var(--color-bg);
  color: var(--color-accent);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  cursor: pointer;
}

.sheet-button:hover {
  background: var(--color-surface);
}

/* The ring's box. The figures inside are absolutely positioned (so this box would be
   0px tall without a height). --ring-pad is the space above the ring for the back sheets,
   which the tilt lifts above the front ones. All sizes follow --figure-size, which
   projcript.js sets to fit the screen (at most 190px) */
.entire-content {
  --ring-pad: 0.12;   /* small since the ring is pushed back: the back sheets barely rise above the front */
  width: var(--figure-size, 190px);
  perspective: var(--ring-perspective);   /* design token in styles.css (the original 1000px) */
  /* Where the camera stands (task 1.15g): level with the ring's centre (the padding + half a
     sheet). The default is the middle of this box; a camera below the ring looked up at it
     and cancelled most of --ring-tilt */
  perspective-origin: 50% calc(var(--figure-size, 190px) * (var(--ring-pad) + 0.575));   /* 0.575 = half of a 1.15-tall sheet */
  position: relative;
  margin-top: var(--space-5);
  padding-top: calc(var(--figure-size, 190px) * var(--ring-pad));
  /* Measured: the pushed-back ring is about 1.35–1.5 sheets tall (more on phones, where the
     perspective is stronger), plus the padding above */
  height: calc(var(--figure-size, 190px) * 1.54);
  box-sizing: border-box;
}

.content-carrousel {
  width: 100%;
  position: absolute;
  transform-style: preserve-3d;
  /* Smooth spin: tells the browser this transform changes all the time, so it keeps the ring
     as ready-drawn layers on the graphics card instead of redrawing the sheets now and then
     as their size on screen changes (each redraw was a small hitch). The front sheet is
     drawn at 1× (pushed back, below), so the ready-drawn layers stay sharp */
  will-change: transform;
  /* The spinning-coin view (task 1.15f): projcript.js only sets --spin (the turn), CSS adds the tilt.
     Read right to left: rotateY spins the ring, then rotateX tips the whole ring toward you,
     so it shows as an ellipse and the back figures peek out above the front ones */
  /* --ring-tilt is a design token in styles.css (3D displays): change the tilt there.
     translateZ (applied last) pushes the whole ring back by its radius (projcript.js sets
     --ring-radius), so the front sheet sits at the screen's depth and shows at its true size.
     Closer than that, it was enlarged about 1.3×, and an enlarged 3D layer looks hazy */
  transform: translateZ(calc(-1 * var(--ring-radius, 0px))) rotateX(var(--ring-tilt)) rotateY(var(--spin, 0deg));
  /* Tilt around the ring's own middle (task 1.15g). This box holds only absolutely positioned
     figures, so it is 0px tall and "50%" would be its top edge: use half a figure instead */
  transform-origin: 50% calc(var(--figure-size, 190px) * 0.575);
}

/* The spin is JS (requestAnimationFrame), so the hover pause lives in projcript.js (task 1.15b) */
.content-carrousel:hover {
  cursor: pointer;
}

/* One small sheet. The figure is the PAPER: background and border, seen from both sides.
   preserve-3d lets the button inside keep its own front and back (below). No overflow: hidden
   here on purpose: it would flatten the figure and the back would show the picture mirrored.
   projcript.js sets each figure's place on the ring (rotateY + translateZ) */
.ring-figure {
  position: absolute;
  width: var(--figure-size, 190px);
  /* A little taller than wide: the label gets its own strip, so the picture area stays
     square. In a square sheet the label ate the picture's height, and object-fit: cover
     cropped the top and bottom off each render (it looked squashed on phones) */
  height: calc(var(--figure-size, 190px) * 1.15);
  margin: 0;                           /* browsers give <figure> a 40px side margin */
  transform-style: preserve-3d;
  background: var(--color-bg);
  border: 1px solid var(--color-accent);
  box-sizing: border-box;
}

/* The printed side: the render and its label. backface-visibility: hidden makes it vanish
   when the sheet faces away, so the back of the ring shows blank paper, not mirror writing.
   translateZ(1px) lifts it just off the paper, so the two never flicker into each other */
.figure-button {
  display: flex;
  flex-direction: column;
  gap: 4%;
  width: 100%;
  height: 100%;
  padding: 6%;
  border: 0;
  background: none;
  color: var(--color-accent);
  cursor: pointer;
  backface-visibility: hidden;
  transform: translateZ(1px);
}

/* The figure's border sits right at the edge, so the shared focus ring is drawn inside it */
.figure-button:focus-visible {
  outline-offset: -4px;
}

/* The viewport: a dashed frame with crop marks, like the entries (.cad-art; the crop
   marks are shared in CAD SECTIONS). The picture fills it, cropped evenly, never stretched */
.ring-art {
  position: relative;
  flex: 1;
  min-height: 0;                       /* lets the flex item shrink below the picture's own size */
  padding: 3px;                        /* a hairline gap, so the picture never covers the dashes */
  outline: 1px dashed var(--color-muted);
  outline-offset: -1px;
}

/* The window the picture shows through: inside the 3px gap, so inside the dashed line.
   overflow: hidden trims the hover zoom to it (the zoom used to spill past the line) */
.ring-window {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.ring-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--speed) ease;
}

/* A gentle zoom on hover or keyboard focus (was scale(1.2) with "transition: all") */
.figure-button:hover .ring-art img,
.figure-button:focus-visible .ring-art img {
  transform: scale(1.05);
}

/* "DWG 01 Bridge Guitar" under the picture, in the drawing's lettering */
.ring-label {
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: max(0.6rem, calc(var(--figure-size, 190px) * 0.06));
  letter-spacing: 0.06em;
  text-align: left;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.ring-num::before {
  content: "DWG ";
}

/* Small sheets (phones): only the number fits. projcript.js sets .is-compact */
.is-compact .ring-name {
  display: none;
}

/* =========================================================
   POPUP (task 1.16, restyled as a title block in R2e). projcript.js
   fills it from the picked project and adds .is-open to #slideshow.
   Two layouts, chosen by the slideshow's own width (container query):
   - narrow (phones, tablets): the popup opens ABOVE the ring
   - wide: it slides in beside the ring, and the ring glides left
   Closed = invisible AND unreachable (visibility: hidden), so Tab and
   screen readers skip it
   ========================================================= */
.sidebar-dwg-details {
  --popup-speed: 350ms;
  --popup-ease: cubic-bezier(0.22, 1, 0.36, 1);   /* ease-out: quick start, soft landing */
  order: -1;                           /* phones: above the ring, though it comes after it in the HTML */
  align-self: stretch;
  /* Phones: the popup pushes the ring down, so its HEIGHT has to change. Height can't
     animate to "auto", but a grid row can go from 0fr (nothing) to 1fr (its content's height).
     This is the one place a layout property animates: an overlay would cover the ring */
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  visibility: hidden;
  /* Closing: fade and shrink first, THEN hide (visibility waits for the animation) */
  transition: grid-template-rows var(--popup-speed) var(--popup-ease),
              opacity var(--popup-speed) var(--popup-ease),
              visibility 0s linear var(--popup-speed);
}

.information-popup {
  min-height: 0;                       /* lets the 0fr row really shrink to nothing */
  overflow: hidden;
  /* The content drops in a little while the row opens: transform only, so it's cheap */
  transform: translateY(-0.75rem);
  transition: transform var(--popup-speed) var(--popup-ease);
}

#slideshow.is-open .sidebar-dwg-details {
  grid-template-rows: 1fr;
  opacity: 1;
  visibility: visible;
  /* Opening: become visible right away (no delay), then grow and fade in */
  transition: grid-template-rows var(--popup-speed) var(--popup-ease),
              opacity var(--popup-speed) var(--popup-ease),
              visibility 0s;
}

#slideshow.is-open .information-popup {
  transform: none;
}

/* The title block's own frame, inside the popup. The header strip runs edge to edge;
   everything else keeps a margin. The id makes this rule outrank .cad-title's margin */
.information-popup {
  margin-top: var(--space-4);
  border: 1px solid var(--color-accent);
}

#selected-sidebar .information-popup > :not(.popup-head) {
  margin-inline: var(--space-3);
}

.popup-head {
  display: flex;
  gap: var(--space-2);
  justify-content: space-between;
  align-items: center;
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-accent);
}

#popup-title {
  margin-block: var(--space-3) var(--space-1);
  font-size: var(--step-1);
}

#popup-meta {
  margin-bottom: var(--space-3);
}

/* Script focus only (tabindex="-1"): no ring, it's a heading, not a control */
#popup-title:focus {
  outline: none;
}

#popup-desc {
  margin-block: 0 var(--space-3);
}

#popup-link {
  display: inline-block;
  margin-bottom: var(--space-3);
}

/* The full picture under the header strip (owner, 2026-11-15). The ring's sheets crop each render
   to a square (object-fit: cover); here it's shown WHOLE (contain) in a dashed viewport like the
   sheets, on the paper colour, so nothing is cut off */
.popup-art {
  display: block;
  margin-top: var(--space-3);
  aspect-ratio: 4 / 3;
  outline: 1px dashed var(--color-accent);
  outline-offset: -1px;
  padding: var(--space-2);             /* the picture stays inside the dashed line */
  background: var(--color-surface);
  overflow: hidden;                    /* the grow-in starts a little smaller, never bigger */
}

/* display: block above would beat the hidden attribute (a project with no picture) */
.popup-art[hidden] {
  display: none;
}

.popup-art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* Grows in as the popup opens: scale + opacity only, so the browser needn't redo the layout.
   The short delay lets the popup start moving first, so the picture seems to come out of it */
  scale: 0.85;
  opacity: 0;
  transition: scale var(--popup-speed) var(--popup-ease) 80ms,
              opacity var(--popup-speed) var(--popup-ease) 80ms;
}

#slideshow.is-open .popup-art img {
  scale: 1;
  opacity: 1;
}

.popup-art:focus-visible {
  outline: 2px solid var(--color-accent);   /* a link: it needs a visible ring, not the colour change */
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .popup-art img,
  #slideshow {
    transition: none;                  /* the picture and the frame change size at once, without easing */
  }
}

/* The ring glides when the layout around it changes */
.entire-content {
  transition: transform var(--popup-speed, 350ms) var(--popup-ease, ease);
}

/* Wide slideshow: popup beside the ring, as the owner designed it.
   62rem = the ring scaled to 0.8 + the 20rem popup + a gap */
@container (min-width: 62rem) {
  .sidebar-dwg-details {
    position: absolute;
    right: clamp(var(--space-3), 4vw, var(--space-5));
    top: calc(var(--space-5) * 2 + 2rem);   /* just under the title strip */
    width: 20rem;
    /* Beside the ring nothing needs to move, so the row stays open and only
       transform + opacity animate: the browser can do those without new layout */
    grid-template-rows: 1fr;
    transform: translateX(var(--space-5));
    transition: transform var(--popup-speed) var(--popup-ease),
                opacity var(--popup-speed) var(--popup-ease),
                visibility 0s linear var(--popup-speed);
  }

  #slideshow.is-open .sidebar-dwg-details {
    transform: none;
    transition: transform var(--popup-speed) var(--popup-ease),
                opacity var(--popup-speed) var(--popup-ease),
                visibility 0s;
  }

  .information-popup {
    margin-top: 0;
    transform: none;
    background: var(--color-bg);
  }

  /* Move the ring to the middle of the space left of the popup:
     half the popup width plus half the gap, and shrink it a little so it fits */
  #slideshow.is-open .entire-content {
    transform: translateX(calc(-1 * (20rem + var(--space-4)) / 2)) scale(0.8);
  }
}

/* Reduced motion: everything still opens and closes, just without the animation */
@media (prefers-reduced-motion: reduce) {
  .sidebar-dwg-details,
  #slideshow.is-open .sidebar-dwg-details,
  .information-popup,
  .entire-content,
  .ring-art img {
    transition: none;
  }
}

/* =========================================================
   CAD SECTIONS (task 2.5; restyled in the design pass as option A,
   "drawing sheet", owner's pick). js/sectcript.js builds the index and
   one .cad-entry per project; this file only dresses them.
   Each project looks like an engineering drawing: a ruled double frame
   with zone ticks, a dashed viewport with crop marks round the render,
   a DWG number, and the stats on one quiet line.
   All lines use --color-accent, so the sheet follows the theme: pine
   lines on white by day, pale blue lines at night, like a blueprint
   ========================================================= */
.cad-sections {
  margin-top: var(--space-7);
}

/* "All projects" sat flush on the first sheet's frame line; the same gap as Home's catalog label */
.cad-sections > .cad-label {
  margin-bottom: var(--space-4);
}

/* Small mono labels, the same look as the home catalog's "All projects" (2.7 unifies them) */
.cad-label,
.cad-kicker {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 400;
  color: var(--color-muted);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

/* "DWG" is added by CSS, so the JSON stays a plain number */
.cad-kicker::before {
  content: "DWG ";
}

/* =========================================================
   THE SHEET. Border = outer frame line, outline (pulled inside with a
   negative offset) = inner frame line. The zone ticks along the top and
   bottom are two thin repeating gradients: a 1px line every 12.5%
   (8 zones), only 0.6rem tall, painted in the margin between the lines
   ========================================================= */
/* The frame: the carousel's sheet only (.cad-sheet, R2d). Declutter (D-b, 2026-11-23): every entry
   had this double frame too, boxes stacked inside boxes. Now the carousel is the one drawing sheet
   and the entries are separated by space and a hairline, so the renders are what you see */
.cad-sheet {
  --sheet-inset: 0.6rem;               /* gap between the two frame lines */
  border: 2px solid var(--color-accent);
  outline: 1px solid var(--color-accent);
  outline-offset: calc(-1 * var(--sheet-inset));
  background:
    repeating-linear-gradient(90deg, var(--color-accent) 0 1px, transparent 1px 12.5%)
      top / 100% var(--sheet-inset) no-repeat,
    repeating-linear-gradient(90deg, var(--color-accent) 0 1px, transparent 1px 12.5%)
      bottom / 100% var(--sheet-inset) no-repeat;
}

/* One entry: a hairline on top, no side padding (it lines up with the page text) */
.cad-entry {
  display: grid;
  gap: var(--space-5);
  padding-block: var(--space-6);
  border-top: 1px solid var(--color-line);
  /* A jump to #bridge-guitar stops a little above the sheet, not flush with the screen edge */
  scroll-margin-top: var(--space-5);
}

@media (min-width: 40rem) {
  .cad-entry {
    grid-template-columns: 14rem 1fr;   /* fixed viewport column, text takes the rest */
    align-items: start;
  }
}

/* The viewport. It has a FIXED shape (square) before the image arrives. That matters here:
   scroll anchoring is off on this page (top of file), so if images above a #link target
   grew the page as they loaded, the target would slide off the screen. A reserved box
   can't grow, so the jump stays put. (5.4 adds width/height to every <img> for the same reason)
   The dashed outline is the viewport; the four corner marks are crop marks */
.cad-art {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  max-width: 20rem;                    /* phones: don't let one image fill the whole screen */
  outline: 1px dashed var(--color-muted);
  outline-offset: -0.5rem;
}

/* Crop marks on all four corners (owner, R1). Borders can only draw one L per box,
   so one layer paints eight short bars instead: linear-gradient(color 0 0) is a solid
   block of color, and each one is placed (top left…) and sized (--mark × --weight).
   Each corner is two bars: one lying flat, one standing up.
   The carousel's small sheets (.ring-art) share them, with shorter arms (below) */
.cad-art::before,
.ring-art::before {
  --mark: 1rem;                         /* arm length */
  --weight: 2px;                        /* line thickness */
  --ink: linear-gradient(var(--color-accent) 0 0);
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;                 /* clicks pass through to the image */
  background:
    var(--ink) top    left  / var(--mark) var(--weight),
    var(--ink) top    left  / var(--weight) var(--mark),
    var(--ink) top    right / var(--mark) var(--weight),
    var(--ink) top    right / var(--weight) var(--mark),
    var(--ink) bottom left  / var(--mark) var(--weight),
    var(--ink) bottom left  / var(--weight) var(--mark),
    var(--ink) bottom right / var(--mark) var(--weight),
    var(--ink) bottom right / var(--weight) var(--mark);
  background-repeat: no-repeat;
  z-index: 1;                           /* above the picture */
}

.ring-art::before {
  --mark: 0.5rem;
  --weight: 1px;
}

/* The picture fills everything inside the dashed line (owner, 2026-11-09). The line sits
   0.5rem in from the box's edge (outline-offset above), so 0.5rem of padding (plus 2px)
   keeps the picture just inside it; the crop marks stay outside.
   object-fit: cover scales evenly and trims the overflow: it can crop, never stretch */
.cad-art {
  padding: calc(0.5rem + 2px);         /* + 2px: a hairline gap, so the picture can never cover the line */
}

.cad-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* =========================================================
   GALLERY (R2a, D33): the big picture, its CAD / Photo tag, a caption,
   and thumbnails to switch pictures (only when a project has more than one)
   ========================================================= */
.cad-figure {
  margin: 0;                           /* browsers give <figure> a 40px side margin by default */
  max-width: 20rem;                    /* same cap as the picture box */
}

/* The tag sits inside the dashed frame, top left, like a label stamped on the sheet */
.cad-tag {
  position: absolute;
  top: 0.9rem;
  left: 0.9rem;
  z-index: 1;                          /* above the picture */
  padding: 0 var(--space-1);
  border: 1px solid var(--color-line);
  background: var(--color-bg);
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.cad-caption {
  margin-top: var(--space-2);
  color: var(--color-muted);
  font-size: var(--step--1);
}

.cad-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
}

/* 3rem = 48px: big enough to tap with a finger (44px is the usual minimum) */
.cad-thumb {
  display: block;
  width: 3rem;
  aspect-ratio: 1;
  padding: 2px;
  border: 1px solid var(--color-line);
  border-radius: 0;
  background: var(--color-surface);
  cursor: pointer;
}

.cad-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;                   /* a small square crop: fills the button, never stretched */
}

/* The thumbnail that's showing: an accent frame (aria-pressed is set by sectcript.js) */
.cad-thumb[aria-pressed="true"] {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent);
}

.cad-thumb:focus-visible {
  outline: 2px solid var(--color-active);
  outline-offset: 2px;
}

/* Cinzel by choice (Sleek pass): since D44 headings default to the body font */
.cad-title {
  margin: var(--space-1) 0 var(--space-3);
  font-family: var(--font-display);
}

.cad-body p {
  margin: 0 0 var(--space-3);
}

/* =========================================================
   THE STATS: one quiet line (sleek pass, owner's pick B, 2026-11-11):
   "8 iterations · 5 parts · 6 h print · ★★★★☆ difficulty".
   Was a ruled 4-cell table; one line reads faster and weighs less.
   ========================================================= */
.cad-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  margin: var(--space-3) 0;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--color-muted);
}

/* Each stat is a <div> holding <dt> (label) then <dd> (value): a <dl> must list the label
   first, and screen readers read it in that order ("Iterations, 8").
   row-reverse SHOWS the value first ("8 iterations"), without changing the HTML order */
.cad-stats div {
  display: flex;
  flex-direction: row-reverse;
  align-items: baseline;
  gap: 0.35em;
}

/* A middle dot AFTER each stat but the last, never before one: when the line wraps on a
   phone, a dot can end a line but never start the next (same rule as joinMeta, R1b).
   In a row-reverse row the lowest order sits furthest right, so order: -1 = the end */
.cad-stats div:not(:last-child)::after {
  content: "·";
  order: -1;
  margin-left: var(--space-1);
}

.cad-stats dt {
  text-transform: lowercase;
}

.cad-stats dd {
  margin: 0;
  color: var(--color-ink);             /* the number is the part you look for */
}

.cad-back {
  font-size: var(--step--1);
}

.cad-note {
  color: var(--color-muted);
}

/* =========================================================
   THE INDEX (owner, 2026-11-24): every project as a clean tile above the
   write-ups, like dazprojects: a picture on a pale square, the name, one meta
   line, nothing around them. It's the old Home catalog (sleek pass, 2026-11-11),
   moved here when Home became the mosaic, plus ‹ › arrows for projects with more
   than one picture. Built by js/sectcript.js
   ========================================================= */
.cad-index {
  --tile-min: 15rem;                   /* narrowest tile on a wide screen */
  --tile-min-phone: 45%;               /* phones: 2 tiles per row */
  margin-block: var(--space-6);
}

/* auto-FIT, not auto-fill: empty columns collapse, so 3 projects stretch across the row.
   list-style: none makes Safari drop the "list" meaning, so the HTML adds role="list" */
.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(var(--tile-min), var(--tile-min-phone)), 1fr));
  gap: var(--space-6) var(--space-4);
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
}

.index-tile {
  position: relative;                  /* the stretched link's ::after fills this box */
}

/* The picture on a pale square; overflow: hidden keeps the hover zoom inside it */
.index-art {
  position: relative;                  /* the arrows sit on the picture */
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--color-surface);
}

/* object-fit: cover fills the square evenly: it can crop, never stretch */
.index-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.index-name,
.index-meta {
  margin: 0;
}

.index-name {
  margin-top: var(--space-3);
  font-family: var(--font-body);
  font-size: var(--step-1);
  font-weight: 600;
}

.index-name a {
  color: var(--color-ink);
  text-decoration: none;
}

.index-tile:hover .index-name a {
  text-decoration: underline;
  text-decoration-color: var(--color-highlight);
}

/* The stretched link: an empty ::after over the whole tile, so a click anywhere follows the link */
.index-name a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.index-meta {
  margin-top: var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--color-muted);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

/* Keyboard focus lands on the small name link; the ring goes round the whole tile (:has) */
.index-tile:has(.index-name a:focus-visible) {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* ‹ › arrows, like dazprojects: small round buttons at the picture's sides.
   z-index 1 lifts them above the stretched link, so a click on an arrow turns the picture
   instead of following the link. They show on hover or keyboard focus; touch screens
   (no hover) always show them, since there's no way to hover first */
.index-arrow {
  position: absolute;
  top: 50%;
  z-index: 1;
  translate: 0 -50%;
  width: var(--space-6);
  height: var(--space-6);
  padding: 0;
  border: 1px solid var(--color-line);
  border-radius: 50%;
  background: var(--color-bg);
  color: var(--color-ink);
  font-size: var(--step-1);
  line-height: 1;
  cursor: pointer;
  opacity: 0;
}

.index-arrow.is-previous { left: var(--space-2); }
.index-arrow.is-next { right: var(--space-2); }

.index-tile:hover .index-arrow,
.index-arrow:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .index-arrow { opacity: 1; }
}

@media (prefers-reduced-motion: no-preference) {
  .index-arrow { transition: opacity var(--speed-fast) ease; }
}

/* The hover lift, shared with Home and Art (--lift and --shadow-lift in styles.css) */
.index-tile:hover .index-art,
.index-tile:has(.index-name a:focus-visible) .index-art {
  scale: var(--lift-scale);
  translate: 0 var(--lift);
  box-shadow: var(--shadow-lift);
}

@media (prefers-reduced-motion: no-preference) {
  .index-art { transition: scale var(--speed) var(--ease-smooth), translate var(--speed) var(--ease-smooth), box-shadow var(--speed) var(--ease-smooth); }
}
