*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-feature-settings: 'tnum' 0; /* default to proportional; tabular numerals applied where needed */
  background: #000;
  color: #fff;
}

/* Visually hidden but available to screen readers (e.g. the aria-live
 * announcer). Standard clip pattern. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── Designed entry sequence ── */
/*
 * On page load, the entry overlay covers the viewport. The wordmark
 * fades in (400ms), holds for at least 1s, then the overlay fades
 * out as the gallery and top-chrome fade in. If artworks.json fails,
 * the wordmark dims and the error message fades in centered below.
 *
 * This sequence doubles as the loading state — no separate spinner.
 */
.entry-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #000;
  pointer-events: none;
  opacity: 1;
  transition: opacity 600ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.entry-wordmark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Fraunces', Georgia, serif;
  font-variation-settings: 'opsz' 144;
  /* Scales with the viewport so the line spans roughly the full width. */
  font-size: clamp(1.6rem, 7.5vw, 8rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  white-space: nowrap;
  max-width: 92vw;
  opacity: 0;
  transition: opacity 400ms ease-out;
}

/* On narrow/portrait viewports the wordmark may need to wrap to keep
 * the type readable at a reasonable line length. */
@media (max-width: 480px) {
  .entry-wordmark {
    white-space: normal;
    line-height: 1.15;
    letter-spacing: 0.05em;
  }
}

.entry-error {
  position: absolute;
  top: 60%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Fraunces', Georgia, serif;
  font-variation-settings: 'opsz' 36;
  font-size: 1.5rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
  text-align: center;
  opacity: 0;
  transition: opacity 300ms ease-out;
}

/* Wordmark fade-in triggered one frame after page paint. */
body.entry-fading-in .entry-wordmark {
  opacity: 1;
}

/* During entry, hide gallery and chrome. */
body.entry-active #gallery,
body.entry-active #label-stack {
  opacity: 0;
}

/* When entry completes (entry-active removed), the overlay fades out. */
body:not(.entry-active) .entry-overlay {
  opacity: 0;
  visibility: hidden;
  transition: opacity 600ms cubic-bezier(0.25, 0.1, 0.25, 1),
              visibility 0s linear 600ms;
}

/* Gallery and chrome have their own fade-in transitions. The chrome
 * one is overridden during entry; this is the resting transition. */
#gallery,
#label-stack {
  transition: opacity 600ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* Failure path: dim wordmark, show error. body.entry-active remains. */
body.entry-failed .entry-wordmark {
  opacity: 0.4;
}

body.entry-failed .entry-error {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .entry-overlay,
  .entry-wordmark,
  .entry-error,
  #gallery,
  #label-stack,
  body:not(.entry-active) .entry-overlay {
    transition: none;
  }
}

/* ── Gallery layout ── */
#gallery {
  display: flex;
  width: max-content;
  height: 100vh;
  overflow: hidden;
}

.series-column {
  width: 100vw;
  height: 100vh;
  /*
   * NOT overflow:hidden. Vertical painting navigation moves this column
   * with translateY, and an element's overflow clip travels with its
   * transform — so clipping here would push every painting except the
   * first (translateY 0) outside its own clip box, rendering them black.
   * The gallery (height:100vh; overflow:hidden) does the vertical
   * clipping instead, against a box that does not move.
   */
  overflow: visible;
  flex-shrink: 0;
  position: relative;
}

.painting-slide {
  width: 100vw;
  height: 100vh;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  overflow: hidden;
  background: #000;
}

/*
 * Image sizing is computed in JS from the image's natural dimensions
 * and the current viewport, then applied as inline `width`/`height`.
 * The image is absolutely centered so it can be larger than the slide
 * (cover case, cropping ≤ 10%) or smaller (constrained case, with
 * black letterbox/pillarbox bars on the under-filled axis). See
 * sizeImage() in js/app.js.
 */
.painting-slide img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0;
  transition: opacity 150ms ease-out;
}

.painting-slide img.loaded {
  opacity: 1;
}

.slide-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  border-top-color: rgba(255, 255, 255, 0.65);
  border-radius: 50%;
  animation: slide-spinner-rotate 1s linear infinite;
  pointer-events: none;
}

.painting-slide.loaded .slide-spinner {
  display: none;
}

@keyframes slide-spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .painting-slide img {
    transition: none;
  }
  .slide-spinner {
    animation: none;
    border-top-color: rgba(255, 255, 255, 0.35);
  }
}

/* (The bottom-left hover painting-label and its gradient overlay are
 * removed — the painting title is now always visible as the bottom line
 * of #label-stack at the top-left. See PRD: Top-Left Label Stack.) */

/* ── Series navigation dots ── */
#series-nav {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.75rem;
  z-index: 100;
}

.series-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  border: none;
  cursor: pointer;
  transition: background 0.3s, transform 0.3s;
  padding: 0;
  /* Scrim so the dot stays visible over light paintings, not just black. */
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.55);
}

/* Expand the touch/click target beyond the 8px visual dot so the whole
 * dot strip is tappable with no dead zones. (Dots sit 20px center-to-
 * center, so a full 44px target isn't possible without respacing — this
 * tiles the available room: ~20px wide, ~32px tall.) */
.series-dot::before {
  content: '';
  position: absolute;
  inset: -12px -6px;
}

.series-dot:hover {
  background: rgba(255, 255, 255, 0.7);
}

.series-dot.active {
  background: #fff;
  transform: scale(1.3);
}

/* Painting dots (vertical) */
.painting-dots {
  position: fixed;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 100;
}

.painting-dot {
  position: relative;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  border: none;
  cursor: pointer;
  transition: background 0.3s, transform 0.3s;
  padding: 0;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.55);
}

/* Expanded hit area — see .series-dot::before. */
.painting-dot::before {
  content: '';
  position: absolute;
  inset: -7px -12px;
}

.painting-dot:hover {
  background: rgba(255, 255, 255, 0.7);
}

.painting-dot.active {
  background: #fff;
  transform: scale(1.4);
}

/* ── Modal ── */
.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 2.5rem;
  max-width: 500px;
  width: 90%;
  animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.modal-close:hover {
  color: #fff;
}

.modal-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 500;
  font-variation-settings: 'opsz' 36;
  margin-bottom: 0.25rem;
  letter-spacing: 0.02em;
}

.modal-series {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1.25rem;
}

.modal-details {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.65);
}

.modal-description {
  font-size: 0.95rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.8);
}

/* Sold/available status sits alongside year/medium/dimensions in
 * .modal-details. Available pieces get a slightly heavier weight and
 * higher-opacity color to read as a soft CTA without shouting. */
.modal-status {
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.02em;
}

.modal-status[data-state="sold"] {
  font-weight: 400;
  color: rgba(255, 255, 255, 0.45);
}

/* Inquiry mailto link — only present for unsold paintings. Subtle
 * text link, not a heavy button. */
.modal-inquiry {
  display: inline-block;
  margin-top: 1.25rem;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 0.2s;
}

.modal-inquiry:hover {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ── Top-left label stack ── */
/*
 * Site name, series name, and painting name stacked at the top-left,
 * floating above the painting on every viewport. Hierarchy runs from
 * quiet site-name wordmark at the top to the prominent current-work
 * title at the bottom. Each line truncates with ellipsis rather than
 * wrapping or overflowing. See PRD: Top-Left Label Stack.
 */
#label-stack {
  position: fixed;
  top: 1rem;
  left: 1.25rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  pointer-events: none;
  transition: opacity 200ms ease-out;
  max-width: min(70vw, 22rem);
}

.label-site,
.label-series,
.label-painting,
.label-price {
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 200ms ease-out;
}

/* Site, series, and painting share size (1.05rem); hierarchy comes from
 * font (serif site, sans series/painting), case, and opacity. */
.label-site {
  font-family: 'Fraunces', Georgia, serif;
  font-variation-settings: 'opsz' 14;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

.label-series {
  font-family: 'Manrope', sans-serif;
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.label-painting {
  font-family: 'Manrope', sans-serif;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.9);
}

/* Price / availability line — secondary detail, sits below the painting
 * name. Hidden entirely when the painting is sold. */
.label-price {
  font-family: 'Manrope', sans-serif;
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.7);
}

.label-price:empty {
  display: none;
}

/* Cross-fade-out helper: JS adds this to the line about to change. */
.label-series.swapping,
.label-painting.swapping,
.label-price.swapping {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .label-series,
  .label-painting,
  .label-price {
    transition: none;
  }
}

/* Modal open: hide all top chrome. */
body.modal-open #label-stack {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  #label-stack,
  .chrome-series-title {
    transition: none;
  }
}

/* ── First-visit navigation hint ── */
/*
 * A dimmed overlay shown once (per browser) after the entry sequence
 * completes, teaching the gesture model. pointer-events:none so a first
 * tap/click passes through to the slide (and opens the modal) while the
 * window-level dismiss listeners fade the hint out. Suppressed on
 * return visits via localStorage. Mobile-first copy; the arrow-keys
 * line shows only on hover-capable devices.
 */
.nav-hint {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

.nav-hint.visible {
  opacity: 1;
}

.nav-hint-inner {
  text-align: center;
  font-weight: 400;
  font-size: 0.95rem;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  padding: 0 2rem;
}

.nav-hint-inner p {
  margin: 0;
}

.nav-hint-keys {
  display: none;
}

@media (hover: hover) {
  .nav-hint-keys {
    display: block;
  }
}

/* ── One-time "Tap for details" hint (touch devices only) ── */
.tap-hint {
  position: fixed;
  bottom: 4rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

.tap-hint.visible {
  animation: tap-hint-pulse 1.6s ease-in-out infinite;
}

@keyframes tap-hint-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .nav-hint {
    transition: none;
  }
  .tap-hint {
    transition: none;
  }
  .tap-hint.visible {
    animation: none;
    opacity: 0.85;
  }
}

/* ── Keyboard focus indicators (:focus-visible only) ── */
/*
 * Differentiated by control shape so the indicator fits the element:
 * a bright stroke + soft halo on buttons, an inset ring on the
 * full-bleed slide (an outset ring would sit off-screen), and a heavier
 * underline on inline text links. Bright 0.95 stroke carries WCAG 3:1
 * contrast; the translucent halo is decorative.
 */
.series-dot:focus-visible,
.painting-dot:focus-visible,
.modal-close:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.95);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.12);
}

/* Slide: ring drawn on a top pseudo-element so it sits above the image
 * (an inset box-shadow on the slide itself would be hidden under the
 * absolutely-positioned <img>). */
.painting-slide::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.95),
              inset 0 0 0 6px rgba(255, 255, 255, 0.12);
}

.painting-slide:focus-visible {
  outline: none;
}

.painting-slide:focus-visible::before {
  opacity: 1;
}

.modal-inquiry:focus-visible {
  outline: none;
  text-decoration: underline solid currentColor 2px;
  text-underline-offset: 4px;
}

/* ── Reduced-motion: remaining gaps ── */
/*
 * Slide transforms are set via inline JS transitions, so !important is
 * needed to override them. The modal entry animation is also disabled.
 * (Entry sequence, hints, spinner, and title cross-fade already handle
 * reduced motion in their own blocks.)
 */
@media (prefers-reduced-motion: reduce) {
  #gallery,
  .series-column {
    transition: none !important;
  }
  .modal-content {
    animation: none;
  }
}
