:root {
  --argos-red: #e30613;
  --argos-dark: #1a1a1a;
  --argos-cream: #f7f3ea;
  --argos-gold: #c9a227;
  --neon-purple: #bf5af2;
  --neon-purple-bright: #e040fb;
  --retro-purple-deep: #0a0412;
  --retro-purple-mid: #1a0a2e;
  --retro-purple-glow: #4a1a6b;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  --card-width: 180px;
  --cover-height: 240px;
  --book-depth: 14px;
  --bg-video-opacity: 1;
  --bg-video-overlay-strength: 0.06;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  background: radial-gradient(circle at top, #2b2b2b 0%, #111 55%, #000 100%);
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body {
  position: relative;
  isolation: isolate;
}

.hidden {
  display: none !important;
}

/* ---- Background video ---- */

.bg-video-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: var(--bg-video-opacity);
  transform: scale(1.03);
  pointer-events: none;
}

.bg-video-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(
      circle at 50% 15%,
      rgba(74, 26, 107, 0.12) 0%,
      transparent 45%
    ),
    radial-gradient(
      circle at top,
      rgba(0, 0, 0, calc(var(--bg-video-overlay-strength) * 0.35)) 0%,
      rgba(0, 0, 0, var(--bg-video-overlay-strength)) 55%,
      rgba(0, 0, 0, calc(var(--bg-video-overlay-strength) * 1.4)) 100%
    );
}

body.has-bg-video {
  background: transparent;
}

html:has(body.has-bg-video) {
  background: #000;
}

body.has-bg-video .home-header .logo-title,
body.has-bg-video .home-header p,
body.has-bg-video .home-header .logo-badge {
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.85);
}

/* ---- Sound toggle ---- */

.sound-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 2px solid rgba(191, 90, 242, 0.55);
  background: rgba(10, 4, 18, 0.78);
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.sound-toggle:hover,
.sound-toggle:focus-visible {
  border-color: var(--neon-purple-bright);
  box-shadow: 0 0 14px rgba(191, 90, 242, 0.45);
  outline: none;
}

.sound-toggle:active {
  transform: scale(0.97);
}

.sound-toggle[hidden] {
  display: none !important;
}

.sound-toggle-icon {
  font-size: 1rem;
  line-height: 1;
}

/* ---- Home / picker ---- */

.home {
  position: relative;
  z-index: 1;
  isolation: isolate;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 2rem 2.5rem;
}

.home-header {
  text-align: center;
  margin-bottom: 1.5rem;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.grid-loading,
.empty-state {
  width: 100%;
  text-align: center;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1.1rem;
  opacity: 0.85;
  padding: 2rem 1rem;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.85);
}

.home-header .badge,
.home-header .logo-badge {
  /* badge styles live in fonts.css as .logo-badge */
}

.home-header h1:not(.logo-title) {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 400;
  letter-spacing: 0.02em;
  margin-bottom: 0.5rem;
}

.home-header p {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1.1rem;
  opacity: 0.75;
}

.catalogue-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-wrap: wrap;
  gap: 2rem 1.75rem;
  padding: 0.75rem 1rem 1.5rem;
  align-content: flex-start;
  justify-content: center;
  scroll-behavior: smooth;
}

.catalogue-grid::-webkit-scrollbar {
  width: 10px;
}

.catalogue-grid::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
}

.catalogue-grid::-webkit-scrollbar-thumb {
  background: rgba(191, 90, 242, 0.45);
  border-radius: 999px;
}

.catalogue-card {
  position: relative;
  z-index: 1;
  color: #fff;
  border-radius: 0 0 10px 10px;
  padding: 0.35rem 1.75rem 0 0.35rem;
  cursor: pointer;
  text-align: left;
  transition: transform 0.25s ease, opacity 0.2s ease;
  overflow: visible;
  display: block;
  width: calc(var(--card-width) + 2.5rem);
  flex: 0 0 calc(var(--card-width) + 2.5rem);
  text-decoration: none;
  outline: none;
  border: 2px solid transparent;
  background: transparent;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
}

.catalogue-card:active {
  transform: scale(0.97);
  opacity: 0.88;
}

.catalogue-card:hover,
.catalogue-card:focus-visible {
  transform: translateY(-6px);
  border-color: transparent;
}

.catalogue-card:hover .cover-book,
.catalogue-card:focus-visible .cover-book {
  transform: rotateY(-10deg) rotateX(2deg) translateY(-2px);
}

.catalogue-card:hover .cover-shadow,
.catalogue-card:focus-visible .cover-shadow {
  opacity: 0.85;
  transform: scale(1.05);
}

.catalogue-card:hover .card-meta,
.catalogue-card:focus-visible .card-meta {
  border-color: var(--neon-purple-bright);
  box-shadow:
    0 0 10px rgba(191, 90, 242, 0.55),
    0 8px 24px rgba(0, 0, 0, 0.35);
}

@keyframes neonPulse {
  0%,
  100% {
    box-shadow:
      0 0 6px rgba(191, 90, 242, 0.6),
      0 0 16px rgba(191, 90, 242, 0.45),
      0 0 32px rgba(224, 64, 251, 0.25),
      0 12px 40px rgba(0, 0, 0, 0.4);
  }
  50% {
    box-shadow:
      0 0 10px rgba(191, 90, 242, 1),
      0 0 28px rgba(191, 90, 242, 0.75),
      0 0 48px rgba(224, 64, 251, 0.55),
      0 0 64px rgba(168, 85, 247, 0.35),
      0 16px 48px rgba(0, 0, 0, 0.45);
  }
}

/* ---- 3D catalogue cover ---- */

.cover-scene {
  position: relative;
  width: var(--card-width);
  height: var(--cover-height);
  margin: 0 auto 0.5rem;
  perspective: 900px;
  pointer-events: none;
  z-index: 1;
}

.cover-shadow {
  position: absolute;
  left: 8%;
  right: 4%;
  bottom: -10px;
  height: 18px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.55) 0%, transparent 72%);
  transform: scale(0.95);
  opacity: 0.65;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 0;
}

.cover-book {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateY(-24deg) rotateX(1deg);
  transition: transform 0.35s ease;
  z-index: 1;
}

.cover-wrap {
  position: absolute;
  inset: 0;
  transform: translateZ(calc(var(--book-depth) / 2));
  backface-visibility: hidden;
  overflow: hidden;
  line-height: 0;
  background: #222;
  box-shadow:
    inset -4px 0 12px rgba(0, 0, 0, 0.25),
    inset 0 -2px 8px rgba(0, 0, 0, 0.15);
}

.cover-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.18) 0%,
    transparent 35%,
    transparent 60%,
    rgba(0, 0, 0, 0.12) 100%
  );
  pointer-events: none;
}

.cover-spine {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--book-depth);
  height: 100%;
  transform: rotateY(-90deg) translateX(calc(var(--book-depth) / -2));
  transform-origin: left center;
  background: linear-gradient(
    to right,
    #1a0808 0%,
    #5c2222 35%,
    #3d1515 70%,
    #220808 100%
  );
  box-shadow: inset -2px 0 6px rgba(0, 0, 0, 0.45);
}

.cover-pages {
  position: absolute;
  right: 0;
  top: 3px;
  width: calc(var(--book-depth) - 2px);
  height: calc(100% - 6px);
  transform: rotateY(90deg) translateX(calc(var(--book-depth) / 2));
  transform-origin: right center;
  background:
    repeating-linear-gradient(
      to bottom,
      #faf6ee 0 2px,
      #e9e0d2 2px 4px
    ),
    linear-gradient(to right, #ddd5c8, #fff8ef 45%, #cfc5b5);
  box-shadow: inset 2px 0 4px rgba(255, 255, 255, 0.35);
}

.cover-wrap img,
.cover-wrap .cover-placeholder {
  display: block;
  width: var(--card-width);
  height: var(--cover-height);
  min-width: var(--card-width);
  min-height: var(--cover-height);
  max-width: var(--card-width);
  max-height: var(--cover-height);
  object-fit: cover;
  object-position: top center;
}

.cover-wrap .cover-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--argos-red), #8b0000);
  font-size: 2.5rem;
  font-weight: 700;
  color: #fff;
  line-height: normal;
}

.catalogue-card .card-meta {
  position: relative;
  z-index: 5;
  padding: 0.75rem 0.85rem 0.9rem;
  background: var(--argos-cream);
  color: var(--argos-dark);
  flex-shrink: 0;
  border-radius: 8px;
  border: 2px solid transparent;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.catalogue-card .year {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--argos-red);
}

.catalogue-card .season {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.82rem;
  margin-top: 0.2rem;
  opacity: 0.85;
}

.catalogue-card .pages {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.75rem;
  margin-top: 0.35rem;
  opacity: 0.55;
}

.empty-state {
  width: 100%;
  text-align: center;
  padding: 3rem;
  font-family: Arial, Helvetica, sans-serif;
  opacity: 0.8;
  line-height: 1.6;
}

.empty-state code {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

/* ---- Flipbook viewer ---- */

body.viewer-mode {
  background: var(--retro-purple-deep);
}

#kiosk-viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.viewer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(74, 26, 107, 0.45) 0%, transparent 70%),
    radial-gradient(ellipse 100% 80% at 50% 100%, rgba(26, 10, 46, 0.9) 0%, transparent 55%),
    linear-gradient(165deg, #0a0412 0%, #1a0a2e 45%, #0d0618 100%);
}

.viewer-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.75rem 1.25rem 0.85rem;
  background: rgba(10, 4, 18, 0.82);
  border-bottom: 1px solid rgba(191, 90, 242, 0.15);
  backdrop-filter: blur(10px);
  z-index: 10;
  flex-shrink: 0;
}

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.page-scrubber {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.page-scrubber label {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.8rem;
  opacity: 0.7;
  white-space: nowrap;
  flex-shrink: 0;
}

.page-scrubber input[type="range"] {
  flex: 1;
  height: 2.5rem;
  margin: 0;
  cursor: pointer;
  accent-color: var(--neon-purple-bright);
  touch-action: none;
}

.page-scrubber input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(191, 90, 242, 0.35),
    rgba(224, 64, 251, 0.85)
  );
}

.page-scrubber input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--neon-purple-bright);
  border: 3px solid #fff;
  box-shadow:
    0 0 10px rgba(191, 90, 242, 0.9),
    0 0 20px rgba(224, 64, 251, 0.5);
}

.page-scrubber input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(191, 90, 242, 0.35),
    rgba(224, 64, 251, 0.85)
  );
}

.page-scrubber input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--neon-purple-bright);
  border: 3px solid #fff;
  box-shadow:
    0 0 10px rgba(191, 90, 242, 0.9),
    0 0 20px rgba(224, 64, 251, 0.5);
}

.viewer-toolbar h2 {
  font-size: 1rem;
  font-weight: 400;
  font-family: Arial, Helvetica, sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.btn {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  padding: 0.65rem 1.1rem;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn:active {
  opacity: 0.75;
}

.btn-back {
  background: #fff;
  color: var(--argos-dark);
}

.btn-nav {
  background: var(--argos-red);
  color: #fff;
  min-width: 3rem;
}

.page-indicator {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.95rem;
  min-width: 7rem;
  text-align: center;
  opacity: 0.85;
}

.flipbook-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  min-height: 0;
  padding: 0.5rem;
  background:
    radial-gradient(circle at 50% 45%, rgba(191, 90, 242, 0.12) 0%, transparent 45%),
    radial-gradient(ellipse 90% 70% at 50% 50%, rgba(45, 20, 80, 0.6) 0%, transparent 75%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(255, 255, 255, 0.012) 2px,
      rgba(255, 255, 255, 0.012) 4px
    ),
    linear-gradient(180deg, #12081f 0%, #1a0a2e 50%, #0a0412 100%);
}

.flipbook-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse 85% 75% at 50% 50%,
    transparent 35%,
    rgba(0, 0, 0, 0.55) 100%
  );
  z-index: 1;
}

.flipbook-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 30%, rgba(224, 64, 251, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(124, 58, 237, 0.1) 0%, transparent 40%);
  z-index: 1;
  animation: atmosphereShift 12s ease-in-out infinite alternate;
}

@keyframes atmosphereShift {
  from {
    opacity: 0.7;
  }
  to {
    opacity: 1;
  }
}

#book {
  position: relative;
  z-index: 2;
  box-shadow:
    0 0 40px rgba(191, 90, 242, 0.15),
    0 0 80px rgba(0, 0, 0, 0.6),
    0 24px 64px rgba(0, 0, 0, 0.5);
  max-width: 100%;
  max-height: 100%;
}

#book .stf__parent {
  max-width: 100%;
  max-height: 100%;
}

#book canvas {
  background: transparent;
}

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: rgba(10, 4, 18, 0.75);
  z-index: 20;
  font-family: Arial, Helvetica, sans-serif;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(191, 90, 242, 0.2);
  border-top-color: var(--neon-purple-bright);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hint-bar {
  text-align: center;
  padding: 0.5rem;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.85rem;
  opacity: 0.45;
  flex-shrink: 0;
  background: rgba(10, 4, 18, 0.6);
  border-top: 1px solid rgba(191, 90, 242, 0.1);
}

/* ---- Idle overlay ---- */

.idle-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: pointer;
  animation: fadeIn 0.4s ease;
}

.idle-overlay h2:not(.logo-title) {
  font-size: clamp(1.8rem, 4vw, 3rem);
  margin-bottom: 0.75rem;
}

.idle-overlay p {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1.2rem;
  opacity: 0.7;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
