/* ── Art (templates/art/) ─────────────────────────────────────
   A gallery's manners: the work is the page. Frames take each work's own
   shape before its picture arrives (the width and height are known), so
   nothing moves as pictures load; a work whose shape is not known sits on a
   mat. Colours are the site's tokens. Where a picture is shown for its own
   sake (the hero, a work's page, zoom, gallery mode) it sits on the neutral
   surround the viewing standards ask for (--surround, .art-surround, in
   style.css), the same in both themes, with no shadow: a drop shadow is a
   dark band immediately around the picture, where the surround must be
   uniform. */

/* ── Hero ─────────────────────────────────────────────────── */
.art-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: clamp(1.25rem, 4vw, 3.5rem);
  align-items: center;
  padding: clamp(1.5rem, 4vw, 3.5rem) var(--gutter);
}
.art-hero-picture {
  display: block;
  justify-self: center;
  max-width: 100%;
  width: min(100%, calc(min(70vh, 640px) * (var(--ar))));
  aspect-ratio: var(--ar);
  max-height: min(70vh, 640px);
  border-radius: 2px;
  overflow: hidden;
}
.art-hero-picture img { width: 100%; height: 100%; object-fit: cover; display: block; }
.art-hero-title { margin: 0 0 0.75rem; }
.art-lede { font-size: var(--step-1); line-height: 1.5; max-width: 38rem; margin: 0 0 1.25rem; }
.art-hero-caption { font-size: var(--step--1); margin: 1rem 0 0; }
.art-hero-caption a { text-decoration: underline; text-underline-offset: 0.2em; }
.art-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0; }
.art-empty { padding: 2rem var(--gutter); }

/* ── Cards and rails ──────────────────────────────────────── */
.art-rail { padding-top: 1.25rem; }
.art-rail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 0 var(--gutter); }
.art-rail-head .section-title a { color: inherit; text-decoration: none; }
.art-rail-head .section-title a:hover { text-decoration: underline; }
.art-more { color: var(--accent-text); font-size: var(--step--1); white-space: nowrap; }
.art-rail-track { --rail-h: clamp(170px, 22vw, 260px); align-items: flex-start; }

.art-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
  border-radius: 4px;
}
.art-rail-track .art-card {
  flex: 0 0 auto;
  width: clamp(120px, calc(var(--rail-h) * var(--ar)), calc(var(--rail-h) * 1.9));
}
.art-card-frame {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--placeholder);
  border-radius: 3px;
  box-shadow: 0 1px 2px oklch(0 0 0 / 0.18), 0 8px 22px oklch(0 0 0 / 0.16);
  transition: box-shadow var(--duration-normal) ease, transform var(--duration-normal) var(--spring-smooth);
}
.art-rail-track .art-card-frame { height: var(--rail-h); }
.art-card-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* A work of unknown shape: whole, on a mat. */
.art-card-frame--mat { background: var(--surface); }
.art-card-frame--mat img { object-fit: contain; padding: 6%; }
.art-card:hover .art-card-frame,
.art-card:focus-visible .art-card-frame { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.art-card:focus-visible { outline: none; }
/* The D-pad's ring goes round the picture alone, not the title too. */
:root .art-card.controller-focus,
:root[data-tv] .art-card.controller-focus { outline: none !important; box-shadow: none !important; }
.art-card:focus-visible .art-card-frame,
.art-card.controller-focus .art-card-frame { outline: 3px solid var(--focus-ring); outline-offset: 3px; }
.art-card-title {
  margin-top: 0.45rem;
  font-weight: 600;
  font-size: var(--step--1);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.art-card-meta { font-size: var(--step--2); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The browse grid: even tiles, each work whole inside its own. */
.art-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr));
  gap: 1.5rem 1.1rem;
  padding: 0.5rem var(--gutter) 2.5rem;
}
.art-grid .art-card-frame { aspect-ratio: 4 / 5; background: var(--surface); }
.art-grid .art-card-frame img { object-fit: contain; padding: 5%; }

/* ── Ways in ──────────────────────────────────────────────── */
.art-ways { padding: 1.5rem var(--gutter) 0; }
.art-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; list-style: none; margin: 0.6rem 0 0; padding: 0; }
.art-chip { display: inline-flex; align-items: center; gap: 0.4em; }
.art-chip .count { color: var(--text-dim); font-size: 0.85em; font-variant-numeric: tabular-nums; }
.art-swatch { width: 0.85em; height: 0.85em; border-radius: 50%; box-shadow: 0 0 0 1px var(--hairline); flex: none; }
.art-about { padding: 2.5rem var(--gutter) 3rem; max-width: 60rem; color: var(--text-muted); line-height: 1.6; }
.art-credits { margin: 0.5rem 0 1rem; padding-left: 1.2rem; }
.art-credits a, .art-about a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 0.15em; }
.art-policy summary { cursor: pointer; color: var(--text); font-weight: 600; }
.art-policy table { border-collapse: collapse; margin: 0.6rem 0; }
.art-policy th, .art-policy td { text-align: left; vertical-align: top; padding: 0.35rem 0.9rem 0.35rem 0; border-bottom: 1px solid var(--hairline); }

/* ── Browse ───────────────────────────────────────────────── */
.art-browse-head { padding: clamp(1.25rem, 3.5vw, 2.5rem) var(--gutter) 0.5rem; }
.art-crumbs { margin: 0 0 0.25rem; font-size: var(--step--1); }
.art-crumbs a { color: var(--accent-text); }
.art-gallery-link { color: var(--accent-text); text-decoration: underline; }
.art-filters { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: end; margin: 0 0 0.75rem; }
.art-filters label { display: grid; gap: 0.2rem; font-size: var(--step--2); color: var(--text-muted); }
.art-filters select {
  min-width: 8rem;
  max-width: 14rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--step--1);
}
.art-applied { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; padding: 0; margin: 0 0 0.5rem; align-items: center; }
.art-applied a:not(.filter-pill) { color: var(--accent-text); font-size: var(--step--1); text-decoration: underline; }
.art-pages { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; padding: 0 var(--gutter) 3rem; }
.art-pages a, .art-pages span { min-width: 2.5rem; text-align: center; }

/* ── A work's page ────────────────────────────────────────── */
.art-work {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 28rem);
  align-items: start;
}
.art-work-main {
  position: sticky;
  top: 0;
  display: grid;
  justify-items: center;
  gap: 1rem;
  padding: clamp(1rem, 3vw, 2.5rem);
  min-height: min(92vh, 1000px);
  align-content: center;
}
/* The stage spans its column, so the picture's width can be a share of it. */
.art-stage { margin: 0; width: 100%; display: grid; justify-items: center; }
.art-stage-img {
  display: block;
  width: min(100%, calc(min(78vh, 1100px) * (var(--ar))));
  height: auto;
  aspect-ratio: var(--ar);
  max-width: 100%;
}
.art-stage-img--unknown { object-fit: contain; }
.art-stage-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.art-label { padding: clamp(1.25rem, 3vw, 2.5rem) var(--gutter) 2rem; }
.art-title { font-family: var(--font-serif); font-size: var(--step-3); font-weight: 600; line-height: 1.15; margin: 0 0 0.6rem; overflow-wrap: anywhere; }
.art-also { color: var(--text-muted); margin: -0.3rem 0 0.6rem; overflow-wrap: anywhere; }
.art-maker { font-size: var(--step-0); margin: 0 0 0.2rem; }
.art-maker a { color: var(--text); text-decoration: underline; text-underline-offset: 0.2em; }
.art-role { color: var(--text-dim); font-size: var(--step--1); }
.art-life { color: var(--text-muted); font-size: 0.9em; }
.art-date { color: var(--text-muted); margin: 0 0 1rem; }
.art-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.45rem 1rem; font-size: var(--step--1); margin: 0 0 1.25rem; }
.art-facts dt { color: var(--text-dim); font-weight: 600; }
.art-facts dd { margin: 0; color: var(--text-muted); overflow-wrap: anywhere; }
.art-facts a { color: var(--accent-text); text-decoration: underline; }
.art-dept { color: var(--text-dim); }
.art-at-museum { margin: 0 0 1.5rem; }
.art-desc h2 { font-size: var(--step-1); margin: 0 0 0.5rem; }
.art-desc p { color: var(--text-muted); line-height: 1.65; max-width: 65ch; }
.art-desc-credit { font-size: var(--step--2); color: var(--text-dim); }
.art-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; padding: 0; margin: 1.25rem 0 0; }

/* ── Zoom ─────────────────────────────────────────────────── */
.art-zoom {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: none;
}
.art-zoom::backdrop { background: var(--surround); }
.art-zoom-view { position: absolute; inset: 0 0 4rem; overflow: hidden; touch-action: none; cursor: grab; outline: none; }
.art-zoom-view:active { cursor: grabbing; }
.art-zoom-layer { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; user-select: none; }
.art-zoom-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4rem; display: flex; gap: 0.5rem; align-items: center; justify-content: center; }
.art-zoom-note { min-width: 5rem; text-align: center; font-variant-numeric: tabular-nums; }

/* ── Gallery mode ─────────────────────────────────────────── */
/* Over the whole page, as a gallery's own room: the site's bars stay
   behind it, and Exit returns to them. */
.art-gallery {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}
.art-gallery-stage {
  position: relative;
  margin: 0;
  display: grid;
  place-items: center;
  padding: clamp(0.75rem, 3vh, 2.5rem) clamp(0.75rem, 3vw, 3rem) 0;
  min-height: 0;
  outline: none;
}
.art-gallery-img {
  grid-area: 1 / 1;
  max-width: 100%;
  max-height: calc(100dvh - 7.5rem);
  width: auto;
  height: auto;
  object-fit: contain;
}
.art-gallery-img--next { opacity: 0; transition: opacity 650ms ease; }
.art-gallery-img--in { opacity: 1; }
/* The stage is the view, not a control: the ring goes round the work. */
/* (The TV ring is :root[data-tv] .controller-focus, with !important.) */
:root .art-gallery-stage.controller-focus,
:root[data-tv] .art-gallery-stage.controller-focus,
:root .art-zoom-view.controller-focus,
:root[data-tv] .art-zoom-view.controller-focus { outline: none !important; box-shadow: none !important; }
.art-gallery-stage:is(:focus-visible, .controller-focus) .art-gallery-img { outline: 3px solid var(--focus-ring); outline-offset: 4px; }
.art-gallery-label {
  position: absolute;
  left: clamp(1rem, 3vw, 3rem);
  bottom: 5.5rem;
  max-width: min(32rem, 80vw);
  padding: 0.9rem 1.1rem;
  border-radius: 6px;
  /* The surround itself, opaque: where the label lies over the work it
     hides that part rather than tinting it, and beside the work it is the
     surround, so the picture's surround stays one grey. */
  background: var(--surround);
  transition: opacity var(--duration-slow) ease;
}
.art-gallery-title { font-family: var(--font-serif); font-size: var(--step-2); font-weight: 600; line-height: 1.2; margin: 0 0 0.3rem; }
.art-gallery-maker, .art-gallery-meta, .art-gallery-museum, .art-gallery-rights { margin: 0.1rem 0; font-size: var(--step--1); }
.art-gallery-rights { font-size: var(--step--2); }
.art-gallery-more { display: inline-block; margin-top: 0.4rem; text-decoration: underline; font-size: var(--step--1); }
.art-gallery-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  justify-content: center;
  padding: 0.75rem var(--gutter) max(0.75rem, env(safe-area-inset-bottom));
  transition: opacity var(--duration-slow) ease;
}
.art-gallery-btn {
  min-width: 2.75rem;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--on-surround);
  background: transparent;
  color: var(--on-surround);
  font: inherit;
  font-size: var(--step-0);
  text-decoration: none;
  cursor: pointer;
}
.art-gallery-btn:hover { background: var(--surround-hover); }
.art-gallery-btn:focus-visible, .art-gallery-btn.controller-focus { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.art-gallery-btn[aria-label] { font-size: var(--step-2); line-height: 1; }
.art-gallery-speed { font-size: var(--step--1); display: inline-flex; gap: 0.4rem; align-items: center; }
.art-gallery-speed select { background: transparent; color: var(--on-surround); border: 1px solid var(--on-surround); border-radius: 6px; padding: 0.3rem 0.4rem; font: inherit; }
.art-gallery-speed select option { color: initial; }
.art-gallery-count, .art-gallery-heading { font-size: var(--step--1); font-variant-numeric: tabular-nums; }
.art-gallery .art-gallery-link { font-size: var(--step--1); text-decoration: underline; }
.art-gallery-empty { padding: 3rem var(--gutter); }
.art-gallery-empty a { text-decoration: underline; }
/* The label hides on request (up or down, or a tap); while the slideshow
   plays undisturbed the controls and the cursor fade out. */
.art-gallery--bare .art-gallery-label { opacity: 0; pointer-events: none; }
.art-gallery--idle { cursor: none; }
.art-gallery--idle .art-gallery-controls { opacity: 0; }
.art-gallery--idle .art-gallery-label { opacity: 0.85; }
@media (prefers-reduced-motion: reduce) {
  .art-gallery-img--next, .art-gallery-label, .art-gallery-controls, .art-card-frame { transition: none; }
}

/* ── Phones ───────────────────────────────────────────────── */
@media (max-width: 760px) {
  .art-hero { grid-template-columns: minmax(0, 1fr); }
  .art-hero-picture { max-height: 52vh; width: min(100%, calc(52vh * (var(--ar)))); }
  .art-work { grid-template-columns: minmax(0, 1fr); }
  .art-work-main { position: static; min-height: 0; }
  .art-stage-img { width: min(100%, calc(70vh * (var(--ar)))); }
  .art-filters select { min-width: 0; max-width: none; width: 100%; }
  .art-filters label { flex: 1 1 calc(50% - 0.75rem); }
  .art-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem 0.75rem; }
  .art-facts { grid-template-columns: minmax(0, 1fr); gap: 0.1rem; }
  .art-facts dd { margin-bottom: 0.5rem; }
  .art-gallery-label { left: 0.75rem; right: 0.75rem; bottom: 7rem; max-width: none; }
  .art-gallery-heading { display: none; }
}

/* ── TV (10-foot) ─────────────────────────────────────────── */
:root[data-tv] .art-rail-track { --rail-h: clamp(220px, 16vw, 480px); }
:root[data-tv] .art-card:is(:focus-visible, .controller-focus) .art-card-frame {
  outline: 0.25rem solid var(--tv-focus);
  outline-offset: 0.2rem;
  box-shadow: 0 0 0 0.85rem var(--tv-focus-halo);
}
:root[data-tv] .art-card-title { font-size: var(--step-0); }
:root[data-tv] .art-card-meta { font-size: var(--step--1); }
:root[data-tv] .art-grid { grid-template-columns: repeat(auto-fill, minmax(clamp(240px, 15vw, 460px), 1fr)); }
:root[data-tv] .art-gallery-stage { padding: max(5vh, 1rem) max(5vw, 1rem) 0; }
:root[data-tv] .art-gallery-img { max-height: calc(100dvh - 9rem - 5vh); }
:root[data-tv] .art-gallery-label { left: max(5vw, 1rem); bottom: calc(6.5rem + 2vh); }
:root[data-tv] .art-gallery-controls { padding-bottom: max(1rem, 3.5vh); }
