/* View: artworks — a wall of square details, and the gallery behind it.
   Copy and images both come from dist/artworks/manifest.json. */

.aw-page {
  font-family: 'Roboto Mono', monospace;
  padding-bottom: var(--space-2xl);
  /* main.css centres everything inside #mainDiv (text-align: -webkit-center),
     which centres block boxes too, not just text. */
  text-align: left;
}

/* ── Header ── deliberately short: the wall is the page. ── */
.aw-header {
  text-align: center;
  padding: var(--space-xl) var(--space-md) var(--space-lg);
}

.aw-title {
  font-size: var(--font-size-3xl);
  color: var(--color-cyberpunk-pink);
  letter-spacing: 6px;
  margin-bottom: var(--space-md);
}

.aw-lead {
  max-width: 700px;
  margin: 0 auto;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
}

.aw-hint {
  margin-top: var(--space-sm);
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ── Empty state ── */
.aw-empty {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
  padding: var(--space-3xl) var(--space-md);
  color: var(--color-terminal-green);
  border: 1px dashed rgba(51, 255, 51, 0.3);
  border-radius: var(--border-radius-sm);
}
.aw-empty-sub {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin-top: var(--space-sm);
}
.aw-empty code { color: var(--color-text-secondary); }

/* ── The wall ──
   Edge to edge, square tiles, no gaps: one field of detail rather than a set of
   cards. auto-fill keeps the tiles near 220px however wide the window is. */
.aw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 2px;
  padding: 0 2px 2px;
  background: var(--color-bg-black);
  /* The wall is meant to meet the window. Every page on the site sits inside a
     20px body gutter (main.css `body { padding: 20px }`); this steps back out of
     it with margins rather than 100vw, which would overshoot by a scrollbar. */
  --aw-body-gutter: 20px;
  width: auto;
  margin-inline: calc(-1 * var(--aw-body-gutter));
}

@media (min-width: 768px) {
  .aw-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

.aw-tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  margin: 0;
  overflow: hidden;
  background: var(--color-bg-dark);
  cursor: pointer;
  /* The tile is a button; nothing about it should look like one. */
  -webkit-appearance: none;
  appearance: none;
}

.aw-tile-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* --aw-zoom is set per tile from the manifest's detail.zoom. */
  transform: scale(var(--aw-zoom, 1));
  transition: transform var(--transition-slow), filter var(--transition-normal);
  filter: saturate(0.92);
}

.aw-tile:hover .aw-tile-img,
.aw-tile:focus-visible .aw-tile-img {
  transform: scale(calc(var(--aw-zoom, 1) * 1.08));
  filter: saturate(1.05);
}

/* A hairline that only shows on hover — keeps the grid seamless at rest. */
.aw-tile-frame {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 0 var(--color-terminal-green);
  transition: box-shadow var(--transition-fast);
}
.aw-tile:hover .aw-tile-frame,
.aw-tile:focus-visible .aw-tile-frame {
  box-shadow: inset 0 0 0 2px var(--color-terminal-green), inset 0 0 24px rgba(51, 255, 51, 0.18);
}
.aw-tile:focus { outline: none; }
.aw-tile:focus-visible { outline: none; }

.aw-tile-missing {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  letter-spacing: 2px;
  border: 1px dashed rgba(108, 106, 108, 0.6);
}

/* ── Hover tooltip ── fixed, follows the cursor, clamped by JS. ── */
.aw-tip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-sticky);
  display: none;
  flex-direction: column;
  gap: 2px;
  max-width: 260px;
  padding: var(--space-sm) var(--space-md);
  background: rgba(0, 0, 0, 0.92);
  border: 1px solid var(--color-terminal-green);
  box-shadow: var(--shadow-brutal-sm);
  pointer-events: none;
  will-change: transform;
}
.aw-tip.is-on { display: flex; }

.aw-tip-title {
  color: var(--color-terminal-green);
  font-size: var(--font-size-sm);
  letter-spacing: 1px;
}
.aw-tip-meta {
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
  line-height: 1.4;
}
.aw-tip-meta:empty { display: none; }

/* ══ GALLERY ══════════════════════════════════════════════════════════════ */

/* Shut, the gallery is invisible and untabbable but still laid out, so opening
   it is one class and no reflow — no requestAnimationFrame needed to give the
   fade a start state. The `hidden` attribute stays in the markup for the no-JS
   case and is removed once at init. */
.aw-gallery {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility 0s var(--transition-normal);
}
.aw-gallery.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--transition-normal), visibility 0s 0s;
}
.aw-gallery[hidden] { display: none; }

.aw-gallery-backdrop {
  position: absolute;
  inset: 0;
  background: var(--color-bg-black);
}

.aw-gallery-inner {
  position: relative;
  text-align: left;   /* see .aw-page — #mainDiv centres its descendants */
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  gap: var(--space-md);
}

.aw-close {
  position: absolute;
  top: 10px;
  right: 14px;
  z-index: 2;
  background: none;
  border: none;
  color: var(--color-terminal-green);
  font-size: 2rem;
  line-height: 1;
  padding: 4px 10px;
  cursor: pointer;
  transition: color var(--transition-fast), text-shadow var(--transition-fast);
}
.aw-close:hover { color: var(--color-cyberpunk-pink); text-shadow: var(--glow-pink); }

/* ── Top half: the work, and what it's made of, side by side ── */
.aw-main {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: var(--space-xl);
  align-items: stretch;
}

.aw-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.aw-stage-figure {
  margin: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.aw-stage-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid rgba(51, 255, 51, 0.25);
  background: var(--color-bg-dark);
  opacity: 1;
  transition: opacity var(--transition-fast);
}
.aw-stage-img.is-swapping { opacity: 0; }

/* ── Arrows ── over the image at the edges of the stage ── */
.aw-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 44px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(51, 255, 51, 0.4);
  color: var(--color-terminal-green);
  font-size: 1.4rem;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.aw-arrow:hover {
  background: rgba(51, 255, 51, 0.15);
  color: var(--color-cyberpunk-pink);
  border-color: var(--color-cyberpunk-pink);
}
.aw-arrow--prev { left: 0; }
.aw-arrow--next { right: 0; }

/* One piece on the wall: nothing to navigate to. */
.aw-gallery.is-single .aw-arrow,
.aw-gallery.is-single .aw-strip-wrap { display: none; }

/* ── Info panel ── */
.aw-info {
  min-width: 0;
  overflow-y: auto;
  padding-right: var(--space-sm);
  border-left: 1px solid rgba(51, 255, 51, 0.25);
  padding-left: var(--space-lg);
}

.aw-info-count {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  letter-spacing: 3px;
  margin-bottom: var(--space-sm);
}

.aw-info-title {
  color: var(--color-cyberpunk-pink);
  font-size: var(--font-size-xl);
  letter-spacing: 2px;
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-md);
}

.aw-info-specs {
  padding-bottom: var(--space-md);
  margin-bottom: var(--space-md);
  border-bottom: 1px dashed rgba(51, 255, 51, 0.3);
}
.aw-info-specs p {
  margin: 0 0 4px;
  font-size: var(--font-size-sm);
  line-height: 1.5;
}
.aw-info-specs p:empty { display: none; }
.aw-info-specs[hidden] { display: none; }   /* JS hides it when a piece has no specs at all */

.aw-info-medium { color: var(--color-terminal-green); }
.aw-info-dims   { color: var(--color-text-secondary); }
.aw-info-year   { color: var(--color-text-muted); }
.aw-info-credit { color: var(--color-text-muted); font-size: var(--font-size-xs) !important; }

.aw-info-desc {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
  white-space: pre-line;
}
.aw-info-desc:empty { display: none; }

/* ── Filmstrip ── every piece, one row, always ── */
.aw-strip-wrap {
  flex: 0 0 auto;
  border-top: 1px solid rgba(51, 255, 51, 0.25);
  padding-top: var(--space-md);
}

.aw-strip {
  display: flex;
  flex-wrap: nowrap;
  /* Centred while the row fits, left-aligned once it overflows — plain
     `center` would push the first thumbs out of reach of the scroller. */
  justify-content: safe center;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: var(--space-sm);
  scrollbar-width: thin;
  scrollbar-color: rgba(51, 255, 51, 0.5) transparent;
}
.aw-strip::-webkit-scrollbar { height: 6px; }
.aw-strip::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); }
.aw-strip::-webkit-scrollbar-thumb { background: rgba(51, 255, 51, 0.45); }

.aw-strip-item {
  flex: 0 0 auto;
  width: 76px;
  height: 76px;
  padding: 0;
  border: 1px solid rgba(108, 106, 108, 0.5);
  background: var(--color-bg-dark);
  overflow: hidden;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}
.aw-strip-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.aw-strip-item:hover { opacity: 0.9; border-color: var(--color-terminal-green); }
.aw-strip-item.is-active {
  opacity: 1;
  border-color: var(--color-cyberpunk-pink);
  box-shadow: 0 0 0 1px var(--color-cyberpunk-pink), var(--glow-pink);
  transform: translateY(-2px);
}

.aw-strip-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

/* ── Narrow screens ── the info goes under the image, the strip stays a row ── */
@media (max-width: 900px) {
  .aw-gallery-inner { padding: var(--space-md) var(--space-sm) var(--space-sm); }

  .aw-main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 3fr) minmax(0, 2fr);
    gap: var(--space-md);
    overflow-y: auto;
  }

  .aw-info {
    border-left: none;
    border-top: 1px solid rgba(51, 255, 51, 0.25);
    padding-left: 0;
    padding-top: var(--space-md);
    overflow-y: visible;
  }

  .aw-arrow { width: 36px; height: 52px; }
  .aw-strip-item { width: 60px; height: 60px; }

  /* No cursor to follow. */
  .aw-tip { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .aw-tile-img,
  .aw-stage-img,
  .aw-strip-item { transition: none; }
  .aw-gallery,
  .aw-gallery.is-open { transition: none; }
  .aw-tile:hover .aw-tile-img,
  .aw-tile:focus-visible .aw-tile-img { transform: scale(var(--aw-zoom, 1)); }
}
