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

html, body {
  height: 100%;
  overflow: hidden;
  color-scheme: dark;
}

body {
  background: #0d0a14;
  color: #c4b8d8;
  font-family: 'Raleway', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 300;
  font-size: 16px;
  line-height: 1.5;
}

/* ── Sort buttons (shared) ─────────────────────────── */

.sort-btn {
  background: transparent;
  border: 1px solid #2e1f4a;
  color: #7055a0;
  padding: 0.28rem 0.75rem;
  border-radius: 3px;
  cursor: pointer;
  font-family: 'Raleway', sans-serif;
  font-weight: 300;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  transition: border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.sort-btn:hover {
  border-color: #6644aa;
  color: #b090e0;
}

.sort-btn.active {
  border-color: #a855f7;
  color: #c084fc;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.25);
}

/* ── Catalog page ──────────────────────────────────── */

.catalog-page {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #0d0a14;
}

.catalog-page--dim {
  pointer-events: none;
}

.catalog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid #1e1530;
  flex-shrink: 0;
  position: relative;
  z-index: 101;
}

/* In play view: float the header transparently over the overlay */
.catalog-page--dim .catalog-header {
  pointer-events: auto;
  background: transparent;
  border-bottom-color: transparent;
}

.catalog-header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.catalog-site-title {
  font-family: 'Raleway', sans-serif;
  font-size: 0.85rem;
  font-weight: 300;
  color: #c4b8d8;
  letter-spacing: 0.2em;
}

.sort-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* More breathing room between sort buttons in the catalog header */
.catalog-header .sort-controls {
  gap: 1.5rem;
}

.col-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 2px;
  background: #2e1f4a;
  outline: none;
  border-radius: 1px;
  cursor: pointer;
}

.col-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #a855f7;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.5);
  transition: box-shadow 0.2s;
}

.col-slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.8);
}

.col-slider::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: none;
  border-radius: 50%;
  background: #a855f7;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.5);
}

.catalog-grid {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  gap: 1.75rem;
  padding: 2rem;
  align-content: start;
  align-items: start;
  outline: none;
  scroll-behavior: smooth;
}

.catalog-grid::-webkit-scrollbar {
  width: 5px;
}

.catalog-grid::-webkit-scrollbar-thumb {
  background: #2a1a40;
  border-radius: 3px;
}

.catalog-item {
  cursor: pointer;
  min-width: 0;
  transition: transform 0.2s, opacity 0.2s;
}

.catalog-item:hover {
  transform: scale(1.03);
  opacity: 0.85;
}

.catalog-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 3px;
}

.catalog-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.catalog-title {
  font-size: 0.8rem;
  font-weight: 300;
  color: #9880be;
  margin-top: 0.6rem;
  letter-spacing: 0.03em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Loading ───────────────────────────────────────── */

.prism-loading {
  color: #3d2860;
  font-size: 0.85rem;
  padding: 1.5rem 1rem;
  letter-spacing: 0.06em;
}

/* ── Hero overlay ──────────────────────────────────── */

/* On desktop the cover-row wrapper is transparent to the parent flex —
   its children behave as direct flex children of hero-overlay. */
.hero-cover-row {
  display: contents;
}

/* Flex row: [balance] [cover-row: ← cover →] [sidebar]
   balance and sidebar both have flex:1 — they share the remaining space
   equally, which keeps the cover perfectly centered regardless of
   viewport size. */
.hero-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 7, 18, 0.88);
  display: flex;
  flex-direction: row;
  align-items: stretch;
  /* When balance + sidebar are both capped, center the whole group */
  justify-content: center;
}

/* Left counterweight — matches sidebar's flex + max-width so the cover
   stays perfectly centered. */
.hero-balance {
  flex: 1;
  min-width: 0;
  max-width: 380px;
  pointer-events: none;
}

/* ── Navigation arrows ────────────────────────────── */

.hero-nav {
  width: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
  z-index: 2;
}

.hero-nav:hover {
  background: rgba(168, 85, 247, 0.06);
}

.hero-nav--disabled {
  opacity: 0.15;
  cursor: default;
  pointer-events: none;
}

.hero-nav-arrow {
  font-size: 2.8rem;
  color: #4a3070;
  line-height: 1;
  font-weight: 200;
  transition: color 0.2s;
}

.hero-nav:hover .hero-nav-arrow {
  color: #a855f7;
}

/* ── Cover — full viewport height, square, centered ── */

/* aspect-ratio: 1 with height: 100vh makes it a square filling the screen
   top-to-bottom. The balance + sidebar flex:1 shares keep it centered. */
.hero-cover-area {
  height: 100vh;
  aspect-ratio: 1;
  flex-shrink: 0;
  position: relative;
  /* Safety cap: never wider than the space available between navs + sidebar */
  max-width: calc(100vw - 128px - 280px);
}

/* FLIP target. Clicking retreats the cover back to the grid. */
.hero-main-cover {
  position: absolute;
  inset: 0;
  cursor: pointer;
  will-change: transform, opacity;
}

.hero-main-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Sidebar ──────────────────────────────────────── */

.hero-sidebar {
  flex: 1;
  min-width: 0;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem 1.75rem;
  overflow: hidden;
}


/* Info: title above, description centered, audio at bottom */
.hero-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem 0;
  min-height: 0;
}

.hero-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 2.25rem;
  font-weight: 300;
  color: #f0e8ff;
  line-height: 1.2;
  letter-spacing: 0.04em;
  overflow-wrap: break-word;
  text-shadow: 0 0 40px rgba(200, 150, 255, 0.4),
               0 0 80px rgba(168, 85, 247, 0.2);
}

.hero-date {
  font-size: 0.72rem;
  font-weight: 300;
  color: #5a3d88;
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}

.hero-description {
  font-size: 0.88rem;
  font-weight: 300;
  color: #8878b0;
  line-height: 1.8;
  letter-spacing: 0.02em;
  overflow-y: auto;
  max-height: 30vh;
  flex-shrink: 1;
}

.hero-description::-webkit-scrollbar {
  width: 3px;
}

.hero-description::-webkit-scrollbar-thumb {
  background: #2a1a40;
  border-radius: 3px;
}

/* Audio at the bottom of the sidebar */
.hero-audio {
  flex-shrink: 0;
  padding-top: 0.5rem;
}

.hero-audio audio {
  width: 100%;
  height: 32px;
  accent-color: #a855f7;
}

.hero-audio audio::-webkit-media-controls-panel {
  background: #100c1c;
}

/* ── Medium screens — sidebar below cover ─────────── */

@media (max-width: 1100px) and (min-width: 641px) {

  .hero-overlay {
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .hero-balance {
    display: none;
  }

  .hero-cover-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    flex-shrink: 0;
  }

  .hero-cover-area {
    flex: 1;
    min-width: 0;
    height: auto;
    max-width: calc(100vh - 3rem);
  }

  .hero-sidebar {
    max-width: 640px;
    width: 100%;
    justify-content: flex-start;
    padding: 1rem 2rem 1.5rem;
  }

  .hero-info {
    padding: 0;
  }

  .hero-description {
    max-height: 20vh;
  }
}

/* ── Mobile portrait ───────────────────────────────── */

@media (max-width: 640px) {

  /* Stack the overlay as a column: [sidebar-top] [cover-row] [info] [audio] */
  .hero-overlay {
    flex-direction: column;
    align-items: stretch;
    background: #0d0a14;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Spacer not needed in column layout */
  .hero-balance {
    display: none;
  }

  /* Restore the wrapper as a real flex row so nav arrows flank the cover */
  .hero-cover-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    flex-shrink: 0;
  }

  /* Cover fills the row between the two nav arrows */
  .hero-cover-area {
    flex: 1;
    min-width: 0;
    height: auto;
    max-width: 100%;
  }

  /* Narrow the arrows so the cover gets most of the width */
  .hero-nav {
    width: 40px;
    flex-shrink: 0;
  }

  .hero-nav-arrow {
    font-size: 2rem;
  }

  /* Sidebar flows naturally below the cover */
  .hero-sidebar {
    max-width: 100%;
    justify-content: flex-start;
    padding: 1rem 1.25rem 1.5rem;
    gap: 0.75rem;
    overflow: visible;
  }

.hero-title {
    font-size: 1.75rem;
  }

  .hero-info {
    padding: 0;
    gap: 0.5rem;
  }

  /* Let description grow naturally rather than being capped at 30vh */
  .hero-description {
    max-height: none;
    overflow-y: visible;
  }

  .hero-audio {
    padding-top: 0.5rem;
  }
}
