/* Browse Art page (R4e, D48, owner's pick A after research and previews A/B/C).
   An index grid like brittanybravo.com: bare photos, never cropped, in three columns with even
   gaps; each caption fades in over its photo on hover or focus (O4). No frames, mats, shadows
   or tilt: the work is the colour.
   (It was a "salon hang" of tilted gilded frames, 2.4 / D42; the class names .salon and .frame
   are kept from then, so the HTML and script didn't have to change.)
   Shared header, tokens and footer live in styles.css */

.art-head {
  margin-block: 0 var(--space-5);   /* the top comes from --page-top (styles.css) */
}

.art-head h1 {
  margin: 0 0 var(--space-2);
}

.art-head p {
  margin: 0;
}

.art-room {
  margin-bottom: var(--space-8);
}

/* Small mono label, the same look as the other pages' section labels */
.art-label {
  margin: var(--space-6) 0 var(--space-4);
  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;
}

/* =========================================================
   AREAS (R4e-2, owner's pick B): Photography splits into areas
   (Nature, Architecture…), each a quiet sub-heading with its count
   and its own grid; a jump list under the intro links to each one
   ========================================================= */
.area-title {
  margin: var(--space-6) 0 var(--space-4);
  font-family: var(--font-body);
  font-size: var(--step-0);
  font-weight: 500;
  color: var(--color-ink);
}

/* The first area sits right under "PHOTOGRAPHY", so it doesn't need the full gap */
.art-label + #photo-areas > .area-title:first-child {
  margin-top: 0;
}

.area-count {
  margin-left: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--step--2);
  font-weight: 400;
  color: var(--color-muted);
}

.area-jump ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

.area-jump a {
  display: inline-block;
  padding-block: var(--space-1);       /* small text, but a tap target of 24px+ (WCAG 2.5.8) */
  color: var(--color-ink);
  text-decoration-color: var(--color-line);
}

.area-jump .area-count {
  margin-left: 0;
}

/* display: block or flex in a rule would beat the hidden attribute; nav has none, but say it anyway */
.area-jump[hidden] {
  display: none;
}

/* =========================================================
   THE GRID. Three columns, 2 on tablets, 1 on phones. Every photo keeps
   its own height (align-items: start), so nothing is cropped.

   MASONRY (owner, 2026-11-22: "cleanly laid out chaotically", like
   brittanybravo.com). Photos stack tightly in their column instead of
   waiting for the tallest one in a row. CSS can't do that on its own
   in every browser yet, so js/artcript.js adds .is-masonry and gives
   each photo grid-row-end: span N, where N = its height / --masonry-row.
   The grid's auto-placement then drops each photo into the first free
   spot from the top: the shortest column, keeping the page order.
   Without the script there's no .is-masonry: plain rows, still fine
   ========================================================= */
.salon {
  --masonry-row: 4px;                      /* the tiny row height the spans count in (read by the script) */
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);                     /* one even gap both ways: the "crisp white border" between photos (O4) */
  align-items: start;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Masonry on: no row gap (the 4px rows would multiply it); each photo carries its own space below */
.salon.is-masonry {
  grid-auto-rows: var(--masonry-row);
  row-gap: 0;
}

.salon.is-masonry > li {
  padding-bottom: var(--space-4);          /* the same as the column gap, so every gap matches */
}

/* The Art page's <main> is wider than the site's 72rem, like Home's, so photos get room
   (only <main>: the header keeps the site width, so the nav doesn't shift between pages) */
.theartpage .site-main {
  --content-max: 86rem;
}

@media (width < 56rem) {
  .salon { grid-template-columns: repeat(2, 1fr); }
}

@media (width < 37.5rem) {
  .salon { grid-template-columns: 1fr; }
}

.piece {
  position: relative;                      /* the caption is laid over the photo (THE CAPTION below) */
  margin: 0;
}

/* The link around the photo. The pale surface shows while the photo loads,
   in the photo's exact shape (its width/height attributes reserve the space) */
.frame {
  display: block;
  background: var(--color-surface);
  transition: scale var(--speed) ease;
}

/* Whole photo, its own shape: width fills the column, height follows (never cropped) */
.frame img {
  display: block;
  width: 100%;
  height: auto;
}

/* The hover lift (owner, 2026-11-24), the same as Home and the CAD index (tokens in styles.css).
   The whole figure lifts (photo + its caption overlay move together).
   Not while a photo is being dragged: that one has its own bigger lift (.is-dragging below) */
.salon > li:not(.is-dragging) .piece:hover,
.piece:has(.frame:focus-visible) {
  scale: var(--lift-scale);
  translate: 0 var(--lift);
  box-shadow: var(--shadow-lift);
}

/* The hovered photo's <li> comes to the front, so its shadow lies over its neighbours */
.salon > li:hover,
.salon > li:focus-within {
  position: relative;
  z-index: 1;
}

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

/* styles.css colours focused links instead of drawing a ring; a photo needs a real ring */
.frame:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
  text-shadow: none;
}

/* =========================================================
   THE CAPTION: title, then the detail and year in small mono capitals, laid over
   the photo on a dark veil. Hidden until the photo is hovered or focused, like the
   reference and Home's mosaic (owner, 2026-11-23, O4). It was always visible below
   the photo before. Who still gets the words:
   - keyboard visitors: Tab onto a photo and it shows (:focus-visible)
   - touch visitors (no hover): a tap opens the viewer, which shows the caption
   - screen readers: opacity hides it from sight only, never from them
   ========================================================= */
.piece figcaption {
  position: absolute;
  inset: 0;                                /* the figure is exactly the photo's size (the caption is out of the flow) */
  display: grid;
  place-content: center;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--color-veil);
  color: var(--color-on-veil);
  font-size: var(--step-1);
  font-weight: 600;                        /* 19px+ bold counts as large text: 3:1 is enough on the veil */
  line-height: 1.3;
  text-align: center;
  opacity: 0;
  pointer-events: none;                    /* it lies over the link: clicks and drags must reach the photo */
}

.piece:hover figcaption,
.frame:focus-visible + figcaption {
  opacity: 1;
}

/* Small mono capitals. Also used by the viewer's caption, which copies the same spans */
.label-meta {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--step--2);
  font-weight: 400;
  color: var(--color-muted);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

/* On the veil, the capitals are white like the title */
.piece .label-meta {
  color: inherit;
}

/* The fade, only for visitors who haven't asked for less motion (the same as Home's tiles) */
@media (prefers-reduced-motion: no-preference) {
  .piece figcaption {
    transition: opacity var(--speed) ease;
  }
}

/* =========================================================
   REORDERING (R4, D42): drag a photo, or Alt + arrow keys, like sliding
   tasks up and down a list. js/artcript.js moves the <li>; CSS only styles it
   ========================================================= */
.art-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--color-muted);
}

/* Touch screens can't hover, so (hover: none) tells phones apart from mouse-and-keyboard
   computers: each gets the hint for how IT rearranges */
.hint-touch { display: none; }

@media (hover: none) {
  .hint-pointer { display: none; }
  .hint-touch { display: inline; }
}

/* display: flex above would beat the hidden attribute's display: none, so hidden needs its own rule */
.art-tools[hidden] {
  display: none;
}

/* Same outline pill as Home's "Next card" button (X8 will make one shared button class).
   The viewer's buttons share it, so the page has one button look, not two */
.art-tools button,
.viewer button {
  padding: var(--space-1) var(--space-4);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-pill);
  background: none;
  color: var(--color-accent);
  font: inherit;
  cursor: pointer;
}

.art-tools button:hover,
.art-tools button:focus-visible,
.viewer button:hover,
.viewer button:focus-visible {
  border-color: var(--color-highlight);
  outline: none;
  text-shadow: var(--faux-bold);
}

.salon > li {
  cursor: grab;
  -webkit-touch-callout: none;         /* iOS: no "save image" menu on a long press (that's how you pick a photo up) */
}

/* The photo being dragged: lifted above the rest with a soft shadow, and invisible to the pointer,
   so the script can see which photo is UNDER it (document.elementFromPoint) */
.salon > li.is-dragging {
  position: relative;
  z-index: 10;
  cursor: grabbing;
  pointer-events: none;
}

.salon > li.is-dragging .frame {
  scale: 1.03;
  box-shadow: 0 1.5rem 2rem -0.75rem rgb(0 0 0 / 0.35);
}

@media (prefers-reduced-motion: reduce) {
  .frame {
    transition: none;
  }
}

/* =========================================================
   THE VIEWER (R4e-3): a click opens the photo large in a <dialog>,
   on the page colour (no black box: the photo stays the only colour).
   Three rows: count + Close, the photo, then Previous · caption · Next
   ========================================================= */
.viewer {
  /* A dialog is a small centred box by default; this one fills the window */
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: var(--space-4);
  border: 0;
  background: var(--color-bg);
  color: var(--color-ink);
}

/* Only when open: display: grid on the closed dialog would beat the browser's display: none */
.viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;   /* minmax(0, …): the photo row may shrink, so a tall photo can't push the buttons off screen */
  gap: var(--space-3);
}

/* ::backdrop covers the page behind the dialog; the page colour hides it completely */
.viewer::backdrop {
  background: var(--color-bg);
}

/* No scrolling the page underneath while the viewer is open */
html:has(.viewer[open]) {
  overflow: hidden;
}

.viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--color-muted);
}

.viewer-bar p {
  margin: 0;
}

/* Whole photo, never cropped, as big as the stage allows. The <img> box is pinned to the stage
   (absolute, inset 0) and object-fit: contain fits the picture inside it at its own shape.
   (max-height: 100% looks simpler but doesn't hold: a percentage height inside a grid row
   can't always be resolved, and a tall photo spilled over the buttons. Found in testing) */
.viewer-stage {
  position: relative;
  min-height: 0;
}

.viewer-stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* The caption in the middle reads like the grid's: title in ink, detail · year in small capitals */
.viewer-caption {
  flex: 1;
  text-align: center;
  font-family: var(--font-body);
  color: var(--color-ink);
}

/* Phones: the caption gets its own line above the two buttons */
@media (width < 37.5rem) {
  .viewer-foot { flex-wrap: wrap; }
  .viewer-caption { order: -1; flex-basis: 100%; }
}

/* A soft fade in, only for visitors who haven't asked for less motion */
@media (prefers-reduced-motion: no-preference) {
  .viewer[open] {
    animation: viewer-in var(--speed) ease-out;
  }
}

@keyframes viewer-in {
  from { opacity: 0; }
}
