/* ── Reset & base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --stone:       #0e0c0a;
  --stone-1:     #141210;
  --stone-2:     #1c1916;
  --stone-3:     #252118;
  --stone-4:     #2e2922;
  --stone-5:     #3d3630;
  --stone-6:     #4d4640;
  --torch:       #c87a18;
  --torch-dim:   #7a4a0e;
  --torch-glow:  rgba(200, 122, 24, 0.18);
  --torch-glow2: rgba(200, 122, 24, 0.07);
  --parchment:   #c8b48a;
  --parchment-2: #9a8a6a;
  --parchment-3: #5a5040;
  --twitch:      #9147ff;
  --sidebar-w:   240px;
  --mobile-h:    56px;
  --radius:      2px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--stone);
  color: var(--parchment);
  font-family: 'Crimson Text', Georgia, serif;
  overflow-x: hidden;
  min-height: 100vh;
}

/* noise overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ── App shell ───────────────────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  background: var(--stone-2);
  border-right: 1px solid var(--stone-3);
  display: flex;
  flex-direction: column;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px 0 0;
  position: relative;
  overflow: hidden;
}

.sidebar-logo-link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--stone-3);
  margin-bottom: 20px;
}

.sidebar-logo {
  width: 140px;
  height: auto;
}

.sidebar-section-label {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.48rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--stone-6);
  padding: 0 16px 10px;
}

/* ── Sidebar stream buttons ──────────────────────────────────── */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
}

.stream-btn {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--parchment-3);
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  position: relative;
}

.stream-btn:hover {
  color: var(--parchment);
  background: var(--stone-3);
  border-color: var(--stone-4);
}

.stream-btn.active {
  color: var(--parchment);
  background: var(--stone-3);
  border-color: var(--stone-4);
}

.stream-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--torch);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px var(--torch-glow);
}

.stream-btn-platform {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  opacity: 0.4;
  transition: opacity 0.15s;
}

.stream-btn-platform svg { width: 16px; height: 16px; }
.stream-btn.active .stream-btn-platform,
.stream-btn:hover  .stream-btn-platform { opacity: 0.8; }

.twitch-icon { color: var(--twitch); }
.yt-icon     { color: #ff0000; }

.stream-btn-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.stream-btn-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.62rem;
  letter-spacing: 1px;
}

.stream-btn-platform-name {
  font-size: 0.48rem;
  letter-spacing: 2px;
  color: var(--stone-6);
  font-weight: 400;
  text-transform: uppercase;
}

.stream-btn.active .stream-btn-platform-name { color: var(--parchment-3); }

.stream-btn-indicators {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Live badge + dot ────────────────────────────────────────── */
.live-badge {
  font-size: 0.45rem;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 2px 4px;
  background: #e91916;
  color: #fff;
  border-radius: 2px;
  display: none;
  line-height: 1.4;
  font-family: 'Cinzel', Georgia, serif;
}

.live-badge.visible { display: inline-block; }

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: transparent;
}

.dot.live {
  background: #00e676;
  box-shadow: 0 0 6px #00e676;
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Sidebar spacer + bepper counter ─────────────────────────── */
.sidebar-spacer { flex: 1; }

.sidebar-beppers {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 20px;
  border-top: 1px solid var(--stone-3);
  margin-top: auto;
}

.bepper-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}

.bepper-count {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--parchment);
}

.bepper-label {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.48rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--stone-6);
}

/* ── Sidebar crenellations (right edge) ──────────────────────── */
.sidebar-battlements {
  position: absolute;
  top: 0;
  right: -8px;
  bottom: 0;
  width: 8px;
  background: repeating-linear-gradient(
    to bottom,
    var(--stone-2) 0px 18px,
    transparent   18px 28px
  );
  pointer-events: none;
  z-index: 2;
}

/* ── Main content area ───────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Mobile header (hidden on desktop) ──────────────────────── */
.mobile-header { display: none; }

/* ── Stage ───────────────────────────────────────────────────── */
.stage {
  position: relative;
  width: 100%;
  height: 100vh;
  background: #000;
  overflow: hidden;
  flex-shrink: 0;
}

.stream-pane {
  position: absolute;
  inset: 0;
  display: none;
}

.stream-pane.active {
  display: block;
  animation: fade-in 0.25s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#twitch-embed,
#twitch-embed iframe,
#youtube-player,
#youtube-player iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ── Offline overlay ─────────────────────────────────────────── */
.offline-overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--stone-1);
  z-index: 5;
}

.offline-overlay.visible { display: flex; }

.offline-icon {
  width: 52px;
  height: 52px;
  color: var(--stone-5);
  margin-bottom: 4px;
}

.offline-icon svg { width: 100%; height: 100%; }

.offline-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--parchment-3);
}

.offline-sub {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--stone-5);
}

/* ── Vignette + scanlines ────────────────────────────────────── */
.stage-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%);
  pointer-events: none;
  z-index: 8;
}

.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent      0px 3px,
    rgba(0,0,0,0.06) 3px 4px
  );
  pointer-events: none;
  z-index: 9;
}

/* ── Gallery ─────────────────────────────────────────────────── */
.gallery {
  padding: 56px 32px 64px;
  display: none;
}

.gallery.visible { display: block; }

.gallery-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
}

.gallery-rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--stone-4), transparent);
}

.gallery-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 5px;
  text-transform: uppercase;
  color: var(--parchment-3);
  white-space: nowrap;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.gallery-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  background: var(--stone-1);
  border: 1px solid var(--stone-3);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  position: relative;
}

.gallery-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.5) 0%, transparent 60%);
  z-index: 1;
  opacity: 0;
  transition: opacity 0.2s;
}

.gallery-card:hover {
  transform: translateY(-3px);
  border-color: var(--torch-dim);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 0 0 1px var(--torch-glow);
}

.gallery-card:hover::before { opacity: 1; }

.gallery-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: var(--stone-2);
}

.gallery-card-title {
  padding: 10px 12px 12px;
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 0.85rem;
  color: var(--parchment-2);
  line-height: 1.45;
}

/* skeleton */
.gallery-skeleton {
  background: var(--stone-1);
  border: 1px solid var(--stone-3);
  border-radius: var(--radius);
  overflow: hidden;
}

.gallery-skeleton-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(90deg, var(--stone-2) 25%, var(--stone-3) 50%, var(--stone-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.gallery-skeleton-line {
  height: 10px;
  margin: 10px 12px 4px;
  background: var(--stone-3);
  border-radius: 2px;
}

.gallery-skeleton-line.short { width: 60%; margin-bottom: 12px; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Inner Keep ──────────────────────────────────────────────── */
.keep {
  position: relative;
  z-index: 1;
  padding-bottom: 80px;
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.keep.visible { opacity: 1; transform: translateY(0); }

.portcullis {
  display: flex;
  align-items: flex-end;
  height: 48px;
  overflow: hidden;
  margin-bottom: 56px;
}

.portcullis-bars {
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(90deg, var(--stone-3) 0px 5px, transparent 5px 20px),
    linear-gradient(to bottom, var(--stone-4), transparent);
}

.keep-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.keep-eyebrow {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.5rem;
  letter-spacing: 5px;
  text-transform: uppercase;
  color: var(--torch-dim);
}

.keep-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: 5px;
  text-transform: uppercase;
  color: var(--parchment);
  text-shadow: 0 0 40px var(--torch-glow);
  margin-bottom: 32px;
}

.keep-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
  margin-bottom: 40px;
}

.keep-card {
  border: 1px solid var(--stone-3);
  background: var(--stone-1);
  padding: 32px 20px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}

.keep-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(200,122,24,0.03) 0%, transparent 60%);
  pointer-events: none;
}

.keep-card-lock {
  width: 32px;
  height: 32px;
  color: var(--stone-5);
  margin-bottom: 4px;
}

.keep-card-lock svg { width: 100%; height: 100%; }

.keep-card-label {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.5rem;
  letter-spacing: 3px;
  color: var(--stone-5);
  border: 1px solid var(--stone-3);
  padding: 3px 8px;
  border-radius: 1px;
}

.keep-card-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.75rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--parchment-3);
}

.keep-card-desc {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--stone-5);
  line-height: 1.5;
}

/* ── Pledge area ─────────────────────────────────────────────── */
.pledge-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.pledge-btn {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--pledge-border, var(--stone-4));
  color: var(--pledge-color, var(--parchment-3));
  padding: 14px 40px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: color 0.6s ease, border-color 0.6s ease, box-shadow 0.6s ease;
  position: relative;
  overflow: hidden;
  box-shadow: var(--pledge-shadow, none);
}

/* Inner glow layer — grows with clicks */
.pledge-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 130%, var(--torch-glow) 0%, transparent 65%);
  opacity: var(--pledge-inner-glow, 0);
  transition: opacity 0.6s ease;
  pointer-events: none;
}

/* Hover always shows full glow regardless of progress */
.pledge-btn:hover {
  color: var(--parchment);
  border-color: var(--torch);
  box-shadow: 0 0 24px rgba(200,122,24,0.3), inset 0 0 16px rgba(200,122,24,0.12);
}

.pledge-btn:hover::before { opacity: 1; }
.pledge-btn:active { transform: scale(0.98); }
.pledge-btn:disabled { opacity: 0.2; cursor: default; pointer-events: none; transition: none; }

.pledge-counter {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.55rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--torch);
  opacity: 0.7;
  transition: opacity 0.4s;
}

.pledge-msg {
  font-family: 'Crimson Text', Georgia, serif;
  font-style: italic;
  font-size: 1rem;
  color: var(--parchment-2);
  min-height: 1.5em;
  text-align: center;
}

.pledge-msg.flash { animation: msg-flash 0.4s ease forwards; }

@keyframes msg-flash {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.keep-enter-btn {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-block;
  background: transparent;
  border: 1px solid var(--parchment-3);
  color: var(--parchment);
  padding: 14px 40px;
  border-radius: var(--radius);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s ease, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.keep-enter-btn.revealed { opacity: 1; pointer-events: auto; }

.keep-enter-btn:hover {
  border-color: var(--torch);
  color: var(--torch);
  box-shadow: 0 0 20px var(--torch-glow2);
}

/* ── Mobile layout ───────────────────────────────────────────── */
@media (max-width: 768px) {

  .sidebar { display: none; }

  .main { margin-left: 0; }

  .mobile-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    height: var(--mobile-h);
    background: var(--stone-2);
    border-bottom: 1px solid var(--stone-3);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
    position: relative;
  }

  .logo-link { display: flex; align-items: center; flex-shrink: 0; }
  .logo { height: 28px; width: auto; }

  .mobile-nav {
    display: flex;
    gap: 6px;
    flex: 1;
    justify-content: center;
  }

  .mobile-stream-btn {
    font-family: 'Cinzel', Georgia, serif;
    font-size: 0.52rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: transparent;
    border: 1px solid var(--stone-4);
    border-radius: var(--radius);
    color: var(--parchment-3);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
  }

  .mobile-stream-btn svg { width: 12px; height: 12px; }

  .mobile-stream-btn.active {
    color: var(--parchment);
    border-color: var(--torch-dim);
    background: var(--stone-3);
  }

  .mobile-beppers {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: 'Cinzel', Georgia, serif;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--parchment-2);
    flex-shrink: 0;
  }

  .bepper-icon-sm {
    width: 14px;
    height: 14px;
  }

  .mobile-battlements {
    position: absolute;
    bottom: -8px;
    left: 0;
    right: 0;
    height: 8px;
    background: repeating-linear-gradient(
      90deg,
      var(--stone-2) 0px 16px,
      transparent   16px 24px
    );
    z-index: 2;
  }

  .stage {
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .gallery { padding: 40px 16px 48px; }

  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  .keep-grid { grid-template-columns: 1fr; max-width: 360px; }

  .keep-inner { padding: 0 16px; }
}

@media (max-width: 400px) {
  .gallery-grid { grid-template-columns: 1fr; }
}

/* ── VOD play button overlay on gallery cards ────────────────── */
.gallery-card-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 2;
}

.gallery-card-play svg {
  width: 40px;
  height: 40px;
  color: #fff;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.8));
}

.gallery-card:hover .gallery-card-play { opacity: 1; }

.gallery-card.playing {
  border-color: var(--torch);
  box-shadow: 0 0 0 1px var(--torch-glow), 0 8px 24px rgba(0,0,0,0.4);
}

.gallery-card.playing::after {
  content: 'NOW PLAYING';
  position: absolute;
  top: 8px;
  left: 8px;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.45rem;
  letter-spacing: 2px;
  background: var(--torch);
  color: #000;
  padding: 3px 6px;
  border-radius: 1px;
  z-index: 3;
}

/* ── VOD back button ─────────────────────────────────────────── */
.vod-back-btn {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 20;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: rgba(14, 12, 10, 0.85);
  border: 1px solid var(--stone-4);
  color: var(--parchment-2);
  padding: 8px 14px;
  cursor: pointer;
  border-radius: var(--radius);
  backdrop-filter: blur(4px);
  transition: color 0.15s, border-color 0.15s;
}

.vod-back-btn:hover {
  color: var(--parchment);
  border-color: var(--torch-dim);
}
