/* ============================================================
   base.css — app shell, deck stage, chrome
   ============================================================ */
:root {
  --stage-w: 1280px;
  --stage-h: 720px;
  --ui-font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --ui-bg: #0b0c14;
  --ui-panel: rgba(20, 22, 34, 0.72);
  --ui-line: rgba(255, 255, 255, 0.1);
  --ui-text: #e9ebf5;
  --ui-muted: #a7abc4;
  --ease-spring: cubic-bezier(0.22, 1.2, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--ui-font);
  background:
    radial-gradient(1200px 700px at 12% -10%, #1a1140 0%, transparent 55%),
    radial-gradient(1000px 700px at 100% 0%, #10233f 0%, transparent 55%),
    radial-gradient(900px 900px at 50% 120%, #2a0f36 0%, transparent 55%),
    var(--ui-bg);
  color: var(--ui-text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; }

/* ---------- Boot veil ---------- */
.boot {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-content: center; justify-items: center; gap: 22px;
  background: var(--ui-bg);
  transition: opacity 0.6s ease, visibility 0.6s;
}
.boot.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.boot__mark { animation: bootFloat 3s var(--ease-in-out) infinite; }
.boot__ring { stroke-dasharray: 208; stroke-dashoffset: 208; animation: bootDraw 1.6s var(--ease-out) forwards, spin 8s linear infinite 1.6s; transform-origin: center; }
.boot__label { color: var(--ui-muted); font-size: 14px; letter-spacing: 0.3px; }
@keyframes bootDraw { to { stroke-dashoffset: 0; } }
@keyframes bootFloat { 50% { transform: translateY(-8px); } }

/* ---------- Stage & scaling ---------- */
.stage {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  overflow: hidden;
}
.scaler {
  position: relative;
  width: var(--stage-w); height: var(--stage-h);
  transform-origin: center center;
  will-change: transform;
}
.slide {
  position: absolute; inset: 0;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 40px 120px -40px rgba(0,0,0,0.8), 0 0 0 1px rgba(255,255,255,0.04);
  backface-visibility: hidden;
}
/* the inactive slide must not paint over the active one (it has no theme,
   so it would fall back to the default dark palette and cover the slide). */
.slide[aria-hidden="true"] { pointer-events: none; visibility: hidden; }

/* ---------- Progress ---------- */
.progress {
  position: absolute; left: 0; right: 0; top: 0; height: 3px; z-index: 30;
  background: rgba(255,255,255,0.06);
}
.progress__bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #7c5cff, #ff5cc8, #43e0c0);
  box-shadow: 0 0 14px rgba(124,92,255,0.6);
  transition: width 0.5s var(--ease-out);
}

/* ---------- Top / bottom bars ---------- */
.topbar, .bottombar {
  position: absolute; z-index: 30; display: flex; align-items: center; gap: 10px;
}
.topbar { top: 16px; left: 18px; right: 18px; }
.topbar__spacer { flex: 1; }
.bottombar { bottom: 18px; left: 50%; transform: translateX(-50%); gap: 14px; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px; border-radius: 999px; cursor: pointer;
  background: var(--ui-panel); color: var(--ui-text);
  border: 1px solid var(--ui-line); backdrop-filter: blur(14px);
  font: 600 12.5px/1 var(--ui-font); letter-spacing: 0.2px;
  transition: transform 0.25s var(--ease-spring), background 0.25s, border-color 0.25s;
}
.chip:hover { transform: translateY(-2px); background: rgba(40,44,66,0.85); border-color: rgba(255,255,255,0.22); }
.chip.is-on { background: linear-gradient(120deg, rgba(124,92,255,0.85), rgba(255,92,200,0.7)); border-color: transparent; color: #fff; }
.chip svg { opacity: 0.9; }

.crumb {
  display: flex; align-items: center; gap: 9px;
  color: var(--ui-muted); font-size: 12.5px; font-weight: 600;
  padding: 7px 14px; border-radius: 999px;
  background: var(--ui-panel); border: 1px solid var(--ui-line); backdrop-filter: blur(14px);
  max-width: 52vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.crumb .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 10px currentColor; }
.crumb b { color: var(--ui-text); font-weight: 700; }

.navbtn {
  width: 46px; height: 46px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; color: var(--ui-text);
  background: var(--ui-panel); border: 1px solid var(--ui-line); backdrop-filter: blur(14px);
  transition: transform 0.25s var(--ease-spring), background 0.25s, box-shadow 0.25s;
}
.navbtn:hover { transform: scale(1.08); background: rgba(40,44,66,0.9); box-shadow: 0 10px 30px -12px rgba(124,92,255,0.7); }
.navbtn:active { transform: scale(0.95); }
.counter {
  min-width: 84px; text-align: center; font-variant-numeric: tabular-nums;
  color: var(--ui-text); font-weight: 700; font-size: 14px;
  padding: 9px 16px; border-radius: 999px;
  background: var(--ui-panel); border: 1px solid var(--ui-line); backdrop-filter: blur(14px);
}
.counter i { color: var(--ui-muted); margin: 0 5px; font-style: normal; }

/* ---------- Branch rail ---------- */
.rail {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  z-index: 30; display: flex; flex-direction: column; gap: 8px;
  padding: 10px 8px; border-radius: 18px;
  background: var(--ui-panel); border: 1px solid var(--ui-line); backdrop-filter: blur(14px);
}
.rail__item {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 7px 9px; border-radius: 12px; color: var(--ui-muted);
  font: 700 11px/1 var(--ui-font); letter-spacing: 0.3px;
  transition: background 0.25s, color 0.25s, transform 0.25s var(--ease-spring);
  max-width: 40px; overflow: hidden;
}
.rail__item .txt { opacity: 0; transform: translateX(-6px); transition: opacity 0.2s, transform 0.2s; white-space: nowrap; }
.rail:hover .rail__item { max-width: 190px; }
.rail:hover .rail__item .txt { opacity: 1; transform: none; }
.rail__item .swatch { width: 16px; height: 16px; border-radius: 6px; flex: 0 0 auto; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2); }
.rail__item:hover { background: rgba(255,255,255,0.07); color: var(--ui-text); }
.rail__item.is-active { background: rgba(255,255,255,0.1); color: var(--ui-text); }
.rail__item.is-active .swatch { box-shadow: 0 0 12px currentColor, inset 0 0 0 1px rgba(255,255,255,0.4); }

/* ---------- Hint ---------- */
.hint {
  position: absolute; left: 18px; bottom: 20px; z-index: 25;
  color: var(--ui-muted); font-size: 12px; opacity: 0.85;
  transition: opacity 0.5s ease;
}
.hint b { color: var(--ui-text); }
.hint.is-hidden { opacity: 0; }

/* ---------- Gallery ---------- */
.gallery {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(8,9,16,0.86); backdrop-filter: blur(18px) saturate(1.1);
  opacity: 0; visibility: hidden; transition: opacity 0.4s ease, visibility 0.4s;
  display: flex; flex-direction: column;
}
.gallery.is-open { opacity: 1; visibility: visible; }
.gallery__head {
  position: relative; padding: 26px 34px 14px; flex: 0 0 auto;
}
.gallery__head h2 { margin: 0; font-size: 24px; letter-spacing: -0.02em; }
.gallery__head h2::before {
  content: ""; display: inline-block; width: 12px; height: 22px; margin-right: 12px; vertical-align: -3px;
  border-radius: 4px; background: linear-gradient(180deg, #7c5cff, #ff5cc8);
}
.gallery__head p { margin: 8px 0 16px; color: var(--ui-muted); font-size: 13.5px; }
.gallery__head p strong { color: var(--ui-text); }
.gallery__close {
  position: absolute; top: 24px; right: 30px; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.08); border: 1px solid var(--ui-line); color: var(--ui-text);
  cursor: pointer; font-size: 16px; transition: transform 0.25s var(--ease-spring), background 0.25s;
}
.gallery__close:hover { transform: rotate(90deg); background: rgba(255,90,120,0.3); }
.gallery__filters { display: flex; flex-wrap: wrap; gap: 8px; }
.gfilter {
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font: 600 12px/1 var(--ui-font);
  background: rgba(255,255,255,0.05); border: 1px solid var(--ui-line); color: var(--ui-muted);
  transition: all 0.25s;
}
.gfilter:hover { color: var(--ui-text); border-color: rgba(255,255,255,0.25); }
.gfilter.is-on { color: #fff; border-color: transparent; }

.gallery__grid {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  display: grid; grid-template-columns: repeat(auto-fill, 216px); justify-content: center;
  gap: 16px; padding: 12px 34px 40px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.gcard {
  position: relative; border-radius: 14px; overflow: hidden; cursor: pointer;
  aspect-ratio: 16/9; border: 1px solid var(--ui-line);
  transform: translateY(12px); opacity: 0;
  animation: gcardIn 0.5s var(--ease-out) forwards;
  transition: transform 0.3s var(--ease-spring), box-shadow 0.3s, border-color 0.3s;
}
.gcard:hover { transform: translateY(-6px) scale(1.02); box-shadow: 0 24px 60px -24px rgba(0,0,0,0.9); border-color: rgba(255,255,255,0.28); z-index: 2; }
.gcard__thumb { position: absolute; inset: 0; }
.gcard__mini { position: absolute; inset: 0; transform: scale(0.169); transform-origin: top left; width: 1280px; height: 720px; pointer-events: none; }
.gcard__meta {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 12px 9px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.82));
  display: flex; align-items: center; gap: 8px;
}
.gcard__num { font: 800 11px/1 var(--ui-font); color: #fff; opacity: 0.7; }
.gcard__lay { font: 600 11px/1.2 var(--ui-font); color: #fff; opacity: 0.95; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gcard__tag { margin-left: auto; font: 700 9px/1 var(--ui-font); text-transform: uppercase; letter-spacing: 0.5px; padding: 4px 7px; border-radius: 6px; color: #fff; }
@keyframes gcardIn { to { transform: none; opacity: 1; } }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* Small screens */
@media (max-width: 760px) {
  .crumb { max-width: 40vw; }
  .chip span { display: none; }
  .rail { display: none; }
  .hint { display: none; }
}
