/* ==========================================================================
   Chronicles of Michaelism — The Holographic Pantheon (Showcase v5 styles)
   Concepts: Reel of Eternity · Celestial Fan-Out · Depth Holo-Matrix ·
   Omni Convergence · Celestial Lightbox — Верховный Скриптор v3.5 (CHAD).
   v5 layout & interaction styles: Cuserob (Trinity+ COKI), 2026-10-04.
   ========================================================================== */

:root {
  --p-gap: 14px;
  --p-cw: 176px;
  --p-ch: 236px;
  --acc-anime: #22d3ee;
  --acc-reincarnation: #fbbf24;
  --acc-movie: #f87171;
  --acc-game: #a78bfa;
  --acc-music: #f472b6;
}

/* ---------------------------------------------------------------- stage */
.p-stage {
  position: relative;
  border-radius: 22px;
  border: 1px solid rgba(245, 158, 11, 0.22);
  background:
    radial-gradient(ellipse at 20% 0%, rgba(34, 211, 238, 0.10), transparent 55%),
    radial-gradient(ellipse at 80% 100%, rgba(168, 85, 247, 0.12), transparent 55%),
    radial-gradient(ellipse at 50% 50%, rgba(245, 158, 11, 0.07), transparent 65%),
    rgba(4, 6, 13, 0.92);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.75), 0 20px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  padding: 18px 0 22px;
}

.p-stage[hidden] {
  display: none;
}

.p-stage--hero {
  border-radius: 0;
  border-left: none;
  border-right: none;
  padding-top: 10px;
}

/* faint star dust */
.p-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 12% 22%, rgba(255, 255, 255, 0.5), transparent 60%),
    radial-gradient(1px 1px at 68% 14%, rgba(255, 255, 255, 0.4), transparent 60%),
    radial-gradient(1.5px 1.5px at 42% 76%, rgba(253, 230, 138, 0.5), transparent 60%),
    radial-gradient(1px 1px at 86% 62%, rgba(255, 255, 255, 0.35), transparent 60%),
    radial-gradient(1px 1px at 28% 90%, rgba(255, 255, 255, 0.3), transparent 60%);
  pointer-events: none;
}

.p-hud {
  position: relative;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 0 24px 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.p-hud-hint {
  letter-spacing: 0.5px;
}

.p-motion {
  background: rgba(4, 6, 13, 0.7);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--gold-primary);
  font: inherit;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 9999px;
  cursor: pointer;
  min-height: 36px;
}

.p-motion:hover,
.p-motion[aria-pressed="true"] {
  background: var(--gold-primary);
  color: #04060d;
}

/* ---------------------------------------------------------------- reel */
.p-reel {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: perspective(1600px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transition: transform 0.5s ease-out;
}

.p-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px 8px;
}

.p-row-title {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--acc, var(--gold-light));
}

.p-row-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9999px;
  padding: 1px 8px;
}

.p-row-more {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--acc, var(--gold-primary));
  text-decoration: none;
  white-space: nowrap;
}

.p-row-more:hover {
  text-decoration: underline;
}

.p-row--anime { --acc: var(--acc-anime); }
.p-row--reincarnation { --acc: var(--acc-reincarnation); }
.p-row--movie { --acc: var(--acc-movie); }
.p-row--game { --acc: var(--acc-game); }
.p-row--music { --acc: var(--acc-music); }

.p-viewport {
  overflow: hidden;
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  padding: 8px 0 12px;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 6%, #000 94%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 6%, #000 94%, transparent 100%);
}

.p-viewport.is-dragging {
  cursor: grabbing;
}

.p-track {
  display: flex;
  width: max-content;
  will-change: transform;
}

.p-loop {
  display: flex;
  gap: var(--p-gap);
  padding-right: var(--p-gap); /* trailing gap belongs to the loop: seamless wrap */
}

/* ---------------------------------------------------------------- cards */
.p-card {
  --acc: var(--gold-primary);
  position: relative;
  flex: none;
  width: var(--p-cw);
  height: var(--p-ch);
  padding: 0;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #050811;
  color: #fff;
  font: inherit;
  text-align: left;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.28s ease, border-color 0.28s ease;
}

.p-card--anime { --acc: var(--acc-anime); }
.p-card--reincarnation { --acc: var(--acc-reincarnation); }
.p-card--movie { --acc: var(--acc-movie); }
.p-card--game { --acc: var(--acc-game); }
.p-card--music { --acc: var(--acc-music); }

.p-card:hover,
.p-card:focus-visible {
  transform: translateY(-6px) scale(1.045);
  border-color: var(--acc);
  box-shadow: 0 0 0 1px var(--acc), 0 16px 34px rgba(0, 0, 0, 0.65), 0 0 26px color-mix(in srgb, var(--acc) 45%, transparent);
  outline: none;
  z-index: 3;
}

.p-card-media,
.p-card-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.p-card-media img {
  object-fit: cover;
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.6s ease;
}

.p-img-poster {
  opacity: 0;
  transform: scale(1.06);
}

.p-card:hover .p-img-poster,
.p-card:focus-visible .p-img-poster {
  opacity: 1;
  transform: scale(1);
}

.p-card:hover .p-img-hero,
.p-card:focus-visible .p-img-hero {
  transform: scale(1.06);
}

.p-card-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, transparent 28%, transparent 48%, rgba(2, 4, 10, 0.92) 100%);
  pointer-events: none;
}

.p-card-top {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.p-card-bottom {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.p-card-title {
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

.p-card-sub {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--acc);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 6px;
  color: #04060d;
  background: var(--gold-primary);
}

.p-badge--anime { background: var(--acc-anime); }
.p-badge--reincarnation { background: var(--acc-reincarnation); }
.p-badge--movie { background: var(--acc-movie); }
.p-badge--game { background: var(--acc-game); }
.p-badge--music { background: var(--acc-music); }

.p-tier {
  font-size: 0.6rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(4, 6, 13, 0.75);
  border: 1px solid currentColor;
}

.p-tier--1 { color: #fbbf24; }
.p-tier--2 { color: #38bdf8; }
.p-tier--3 { color: #c084fc; }

/* ---------------------------------------------------------------- hook (home) */
.p-hook {
  font-size: clamp(2rem, 5.2vw, 3.8rem);
  font-weight: 900;
  line-height: 1.1;
  margin: 6px 0 10px;
  color: #fff;
}

.p-hook-name {
  font: inherit;
  border: none;
  padding: 0 2px;
  background: linear-gradient(135deg, #fde68a 0%, #f59e0b 50%, #22d3ee 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--gold-primary);
  cursor: pointer;
  border-bottom: 3px solid rgba(245, 158, 11, 0.5);
  transition: opacity 0.26s ease, transform 0.26s ease;
  display: inline-block;
}

.p-hook-name:hover {
  border-bottom-color: var(--gold-primary);
}

.p-hook-name.is-swapping {
  opacity: 0;
  transform: translateY(-10px);
}

/* ---------------------------------------------------------------- toolbar (showcase) */
.p-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 18px;
  margin-bottom: 18px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(14, 16, 26, 0.6);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}

.p-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.p-pill {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 9999px;
  cursor: pointer;
  min-height: 36px;
  transition: all 0.2s ease;
}

.p-pill:hover {
  color: #fff;
  border-color: rgba(245, 158, 11, 0.5);
}

.p-pill[aria-pressed="true"] {
  background: var(--gold-gradient);
  color: #04060d;
  border-color: transparent;
}

/* ---------------------------------------------------------------- fan-out */
.p-fan-stage {
  min-height: 580px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.p-fan-controls {
  position: relative;
  z-index: 400; /* above a lifted card (z-index 200) */
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0 16px;
}

.p-fan-page {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.p-fan-deck {
  position: relative;
  width: 100%;
  height: 470px;
  margin-top: 30px;
  cursor: pointer;
}

.p-fan-card {
  --p-cw: 210px;
  --p-ch: 300px;
  position: absolute;
  left: 50%;
  top: 46%;
  margin-left: calc(var(--p-cw) / -2);
  margin-top: calc(var(--p-ch) / -2);
  transform-origin: 50% 140%;
  transform: translate(var(--fx, 0px), var(--fy, 0px)) rotate(var(--fa, 0deg));
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease, border-color 0.3s ease;
  pointer-events: none; /* the deck decides which card is "under" the pointer */
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.75);
}

.p-fan-card.is-lifted {
  transform: translate(var(--fx, 0px), calc(var(--fy, 0px) - 54px)) rotate(0deg) scale(1.12);
  border-color: var(--acc);
  box-shadow: 0 0 0 1px var(--acc), 0 26px 50px rgba(0, 0, 0, 0.85), 0 0 30px color-mix(in srgb, var(--acc) 45%, transparent);
}

.p-fan-card.is-lifted .p-img-poster {
  opacity: 1;
  transform: scale(1);
}

.p-fan-card:hover,
.p-fan-card:focus-visible {
  transform: translate(var(--fx, 0px), calc(var(--fy, 0px) - 54px)) rotate(0deg) scale(1.12);
}

/* ---------------------------------------------------------------- depth matrix */
.p-depth-mount {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 22px;
  padding: 4px 22px 10px;
}

.p-depth-card {
  --p-cw: 100%;
  --p-ch: 300px;
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.25s ease-out, box-shadow 0.28s ease, border-color 0.28s ease;
}

.p-depth-card:hover,
.p-depth-card:focus-visible {
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(1.03);
}

.p-sheen {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--sx, 50%) var(--sy, 50%), rgba(255, 255, 255, 0.22), transparent 55%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  mix-blend-mode: overlay;
}

.p-depth-card:hover .p-sheen {
  opacity: 1;
}

.p-omni-title {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--gold-light);
  padding: 6px 24px 12px;
}

/* ---------------------------------------------------------------- lightbox */
.p-modal {
  margin: auto; /* the global * { margin: 0 } reset would pin the dialog top-left */
  width: min(1060px, calc(100% - 24px));
  max-height: min(92vh, 900px);
  padding: 0;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 20px;
  background: rgba(10, 13, 22, 0.94);
  color: var(--text-main);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.8), 0 0 50px rgba(245, 158, 11, 0.12);
  overflow: hidden;
}

.p-modal::backdrop {
  background: rgba(2, 4, 10, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.p-modal[open] {
  animation: p-modal-in 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

@keyframes p-modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.p-modal-inner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  max-height: inherit;
}

.p-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(4, 6, 13, 0.75);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

.p-modal-close:hover {
  background: var(--gold-primary);
  color: #04060d;
}

.p-modal-media {
  position: relative;
  background: #02040a;
  min-height: 420px;
  max-height: min(92vh, 900px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.p-modal-img {
  width: 100%;
  height: 100%;
  max-height: min(92vh, 900px);
  object-fit: contain;
  cursor: zoom-in;
  transition: transform 0.35s ease;
}

.p-modal-img.is-zoomed {
  transform: scale(1.8);
  cursor: zoom-out;
}

.p-modal-switch {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 9999px;
  background: rgba(4, 6, 13, 0.8);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.p-modal-switch[hidden] {
  display: none;
}

.p-modal-switch button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 9999px;
  cursor: pointer;
}

.p-modal-switch button[aria-pressed="true"] {
  background: var(--gold-primary);
  color: #04060d;
}

.p-modal-body {
  padding: 26px 28px 20px;
  overflow-y: auto;
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.p-modal-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-right: 44px;
}

.p-modal-meta .badge-status[hidden] {
  display: none;
}

.p-modal-counter {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.p-modal-title {
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1.15;
}

.p-modal-sub {
  color: var(--cyan-accent);
  font-weight: 600;
}

.p-modal-lyric {
  margin: 0;
  padding: 12px 16px;
  border-left: 3px solid var(--acc-music);
  background: rgba(244, 114, 182, 0.08);
  border-radius: 0 10px 10px 0;
  font-style: italic;
  color: #fde7f3;
}

.p-modal-lyric[hidden],
.p-modal-play[hidden],
.p-modal-question[hidden],
.p-modal-actions [hidden] {
  display: none;
}

.p-modal-play {
  align-self: flex-start;
  border: none;
  background: var(--acc-music);
  color: #04060d;
  font: inherit;
  font-weight: 800;
  padding: 9px 18px;
  border-radius: 9999px;
  cursor: pointer;
  min-height: 40px;
}

.p-modal-text {
  background: rgba(0, 0, 0, 0.35);
  border-left: 3px solid var(--gold-primary);
  border-radius: 0 10px 10px 0;
  padding: 12px 16px;
  font-size: 0.95rem;
}

.p-modal-text strong {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold-primary);
  margin-bottom: 4px;
}

.p-modal-question {
  font-weight: 700;
  color: var(--gold-light);
}

.p-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.p-modal-actions .btn-cta,
.p-modal-actions .btn-outline-gold,
.p-modal-actions .btn-ghost {
  padding: 10px 16px;
  font-size: 0.88rem;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}

.p-modal-follow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.p-modal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
}

.p-modal-nav button {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  min-height: 40px;
}

.p-modal-nav button:hover {
  border-color: var(--gold-primary);
}

.p-modal-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
}

html.p-modal-active {
  overflow: hidden;
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 768px) {
  :root {
    --p-gap: 10px;
    --p-cw: 124px;
    --p-ch: 168px;
  }

  .p-row-head,
  .p-hud {
    padding-left: 16px;
    padding-right: 16px;
  }

  .p-card-title {
    font-size: 0.76rem;
  }

  .p-fan-card {
    --p-cw: 140px;
    --p-ch: 200px;
  }

  .p-fan-stage {
    min-height: 430px;
  }

  .p-fan-deck {
    height: 330px;
  }

  .p-depth-mount {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 4px 14px 10px;
  }

  .p-depth-card {
    --p-ch: 220px;
  }

  .p-modal {
    max-height: 94vh;
  }

  .p-modal-inner {
    grid-template-columns: 1fr;
    overflow-y: auto;
    max-height: 94vh;
  }

  .p-modal-media {
    min-height: 0;
    height: 40vh;
  }

  .p-modal-body {
    max-height: none;
    overflow: visible;
    padding: 18px 18px 16px;
  }

  .p-modal-title {
    font-size: 1.4rem;
  }

  .p-modal-hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .p-reel {
    transform: none !important;
  }

  .p-card:hover,
  .p-card:focus-visible {
    transform: none;
  }

  /* the fan position lives in transform: keep it, drop only the lift */
  .p-fan-card.is-lifted,
  .p-fan-card:focus-visible {
    transform: translate(var(--fx, 0px), var(--fy, 0px)) rotate(var(--fa, 0deg));
  }

  .p-modal[open] {
    animation: none;
  }
}

@media (max-width: 768px) {
  .p-hud-hint {
    display: none; /* the toggle stays; dragging is discoverable on touch */
  }

  .p-hud {
    justify-content: flex-end;
  }
}

/* ---- no layout shift: reserve the reel's height until the engine fills it
   (measured: each row = card height + ~51px; 16px between rows) */
.p-reel-mount:not(:has(.p-reel)) {
  min-height: calc(5 * (var(--p-ch) + 51px) + 64px);
}

[data-pantheon="full"] .p-depth-mount:not(:has(.p-card)) {
  min-height: 100vh;
}

@media (max-width: 768px) {
  .p-reel-mount:not(:has(.p-reel)) {
    min-height: calc(5 * (var(--p-ch) + 57px) + 64px);
  }
}

/* ---- Step 3: lightbox picture strip (entries with several pictures) */
.p-modal-gallery {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  z-index: 3;
}

.p-modal-gallery[hidden] {
  display: none;
}

.p-modal-gallery button {
  width: 54px;
  height: 54px;
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: #02040a;
  cursor: pointer;
}

.p-modal-gallery button[aria-pressed="true"] {
  border-color: var(--gold-primary);
  box-shadow: 0 0 12px var(--gold-glow);
}

.p-modal-gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---- Step 3: "Draw a hand" (home) — a 9-card Fan-Out */
.hand-section {
  margin-bottom: 50px;
}

.hand-lead {
  text-align: center;
  color: var(--text-muted);
  max-width: 720px;
  margin: -10px auto 18px;
}

.p-fan-stage--hand {
  min-height: 540px;
}

@media (max-width: 768px) {
  .p-fan-stage--hand {
    min-height: 420px;
  }
}
