/* ════════════════════════════════════════════════════════════════
   sspm-player — stylesheet
   Palette & rules from the sspm-player design charter.
   ════════════════════════════════════════════════════════════════ */

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

:root {
  /* backgrounds */
  --bg-base:     #0A0A10;
  --bg-panel:    #0C0C14;
  --bg-card:     #10101A;
  --bg-selected: #1C2644;

  /* accents */
  --blue:        #5082DC;
  --purple:      #534AB7;
  --purple-lt:   #7F77DD;
  --teal:        #1D9E75;
  --star-blue:   #5A9BFF;
  --star-purple: #AF87FF;

  /* text */
  --text-primary: #F5F5F5;
  --text-default: #D2D2E4;
  --text-muted:   #8287AA;
  --text-faint:   #5A5A73;
  --text-hint:    #444664;

  /* lines */
  --border:       #2C2C46;
  --border-hover: #373C5F;
  --border-focus: #5082DC;
  --ok:           #64DC78;

  /* difficulty scale (charter) */
  --d-1: #50DC64;  --d-2: #DCBE32;  --d-3: #F08228;  --d-4: #E63C3C;  --d-5: #BE3CDC;

  /* spacing scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;

  /* radii */
  --r-sm: 4px; --r-md: 6px; --r-lg: 8px;

  /* type */
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  --ease: 140ms cubic-bezier(0.4, 0, 0.2, 1);
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg-base);
  color: var(--text-default);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

::selection { background: rgba(80, 130, 220, 0.3); color: var(--text-primary); }

/* ── Particle field ──────────────────────────────────────────── */
#particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ── Shell ───────────────────────────────────────────────────── */
.app {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--s5) var(--s7);
}

/* ── Header ──────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s5);
  padding: var(--s5) 0 var(--s4);
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-shrink: 0;
}

.logo-mark { display: block; }

.logo-text {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.logo-accent {
  color: var(--text-faint);
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--s5);
}

/* ── Search ──────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: var(--s3);
  pointer-events: none;
}

.search-input {
  width: 240px;
  padding: var(--s2) var(--s3) var(--s2) 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-default);
  font-family: var(--sans);
  font-size: 13px;
  outline: none;
  transition: border-color var(--ease), background var(--ease);
}

.search-input::placeholder { color: var(--text-hint); }
.search-input:hover { border-color: var(--border-hover); }
.search-input:focus {
  border-color: var(--border-focus);
  background: var(--bg-panel);
}

/* ── Stats ───────────────────────────────────────────────────── */
.stats {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  letter-spacing: -0.02em;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: var(--s2);
  padding: var(--s5) 0;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color var(--ease), border-color var(--ease), background var(--ease);
}

.tab-btn:hover { color: var(--text-default); border-color: var(--border-hover); }

.tab-btn.active {
  background: var(--bg-selected);
  border-color: var(--blue);
  color: var(--text-primary);
}

.tab-count {
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0;
}

.tab-btn.active .tab-count { color: var(--star-blue); }

/* ── Status panel ────────────────────────────────────────────── */
.status-panel {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

/* ── Folder card ─────────────────────────────────────────────── */
.folder-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: border-color var(--ease);
}

.folder-card:hover,
.folder-card.expanded { border-color: var(--border-hover); }

/* left accent bar */
.folder-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent, var(--blue));
  opacity: 0.85;
}

.folder-header {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s4) var(--s4) var(--s4) var(--s5);
  cursor: pointer;
  user-select: none;
}

/* star badge — the hero of the card */
.star-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  flex-shrink: 0;
  min-width: 52px;
}

.star-badge .num {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
  color: var(--accent, var(--star-blue));
  letter-spacing: -0.03em;
}

.star-badge .glyph {
  font-size: 12px;
  line-height: 1;
  color: var(--accent, var(--star-blue));
  opacity: 0.7;
}

.folder-meta {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  flex: 1;
  min-width: 0;
}

.folder-meta .count {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-default);
}

.folder-meta .dot-sep { color: var(--text-hint); font-size: 11px; }

.folder-meta .size {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: -0.02em;
}

.folder-actions {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-shrink: 0;
}

/* ── ZIP button ──────────────────────────────────────────────── */
.btn-zip {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--ease), border-color var(--ease), background var(--ease);
}

.btn-zip:hover {
  color: var(--star-blue);
  border-color: var(--border-focus);
  background: rgba(80, 130, 220, 0.08);
}

/* fixed-size slot: icon and spinner share one 12px box, so swapping them
   never changes the button's width (no jump on click) */
.zip-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.zip-glyph .btn-spinner {
  display: none;
  width: 11px; height: 11px;
  border: 1.5px solid var(--border);
  border-top-color: var(--star-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn-zip.busy { pointer-events: none; opacity: 0.75; }
.btn-zip.busy .zip-glyph .zip-icon  { display: none; }
.btn-zip.busy .zip-glyph .btn-spinner { display: block; }

.chevron {
  flex-shrink: 0;
  color: var(--text-hint);
  transition: transform 180ms ease, color var(--ease);
}

.folder-header:hover .chevron { color: var(--text-muted); }
.folder-card.expanded .chevron { transform: rotate(180deg); }

/* ── Map list ────────────────────────────────────────────────── */
.map-list {
  display: none;
  max-height: 420px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

.folder-card.expanded .map-list { display: block; }

.map-list::-webkit-scrollbar { width: 6px; }
.map-list::-webkit-scrollbar-track { background: transparent; }
.map-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.map-list::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

.map-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s4) var(--s2) var(--s5);
  border-bottom: 1px solid rgba(44, 44, 70, 0.4);
  transition: background var(--ease);
}

.map-item:last-child { border-bottom: none; }
.map-item:hover { background: rgba(255, 255, 255, 0.018); }
.map-item.hidden { display: none; }

.map-score {
  flex-shrink: 0;
  width: 44px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent, var(--star-blue));
  opacity: 0.85;
  letter-spacing: -0.02em;
}

.map-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-default);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-size {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-hint);
  letter-spacing: -0.02em;
}

.btn-dl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px; height: 28px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--text-faint);
  text-decoration: none;
  transition: color var(--ease), border-color var(--ease), background var(--ease);
}

.btn-dl:hover {
  color: var(--star-blue);
  border-color: var(--border-focus);
  background: rgba(80, 130, 220, 0.08);
}

/* ── States ──────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  padding: var(--s7) 0;
  color: var(--text-muted);
  font-size: 13px;
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
  padding: var(--s7) var(--s5);
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

.empty code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px 7px;
}

/* ── Download toasts ─────────────────────────────────────────── */
.toasts {
  position: fixed;
  right: var(--s5);
  bottom: var(--s5);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  width: 330px;
  max-width: calc(100vw - 2 * var(--s4));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s3) var(--s4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: toast-in 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.toast.leaving {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 250ms ease, transform 250ms ease;
}

.toast-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.toast-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  flex-shrink: 0;
  color: var(--star-blue);
}

.toast-spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--star-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.toast-main { flex: 1; min-width: 0; }

.toast-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}

.toast-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast-bar {
  position: relative;
  height: 4px;
  margin-top: var(--s3);
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.toast-fill {
  height: 100%;
  width: 0;
  background: var(--blue);
  border-radius: 2px;
  transition: width 200ms ease;
}

.toast.indeterminate .toast-fill {
  width: 35%;
  transition: none;
  animation: toast-sweep 1.1s ease-in-out infinite;
}

@keyframes toast-sweep {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(310%); }
}

.toast-stats {
  margin-top: var(--s2);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: -0.02em;
}

.toast.done  .toast-ico  { color: var(--ok); }
.toast.done  .toast-fill { background: var(--ok); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 680px) {
  .app { padding: 0 var(--s4) var(--s6); }
  header { flex-wrap: wrap; gap: var(--s3); }
  .header-right { width: 100%; justify-content: space-between; }
  .search-input { width: 100%; }
  .search-wrap { flex: 1; }
  .tabs { flex-wrap: wrap; }
}


/* ════════════════════════════════════════════════════════════════
   LANDING PAGE
   ════════════════════════════════════════════════════════════════ */

/* logo doubles as the home link on every page */
.logo { text-decoration: none; }
.logo:hover .logo-text { color: #fff; }

/* ── Top bar (over the hero) ─────────────────────────────────── */
.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 3;
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--s4) var(--s5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
}

.topbar-links { display: flex; align-items: center; gap: var(--s5); }

.topbar-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  transition: color var(--ease);
}
.topbar-link:hover { color: var(--text-primary); }

.topbar-cta {
  padding: var(--s2) var(--s4);
  border: 1px solid var(--blue);
  border-radius: var(--r-md);
  color: var(--star-blue);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--ease), color var(--ease);
}
.topbar-cta:hover { background: rgba(80, 130, 220, 0.12); color: #fff; }

/* landing fills the screen: hero grows, footer pinned just below it */
body.landing {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

/* ── Hero ────────────────────────────────────────────────────── */
.hero {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;               /* fill the viewport above the footer */
  min-height: 540px;
  display: flex;
  align-items: flex-end;        /* text sits in a band at the bottom */
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.hero-media { position: absolute; inset: 0; z-index: 0; }

.hero-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;                    /* revealed by home.js on first frame */
  transition: opacity 0.8s ease;
}
.hero.has-video .hero-video { opacity: 1; }

/* placeholder shown until (and if) a clip is present */
.hero-placeholder {
  position: absolute;
  left: 0; right: 0; top: 30%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
  color: var(--text-hint);
  pointer-events: none;
  transition: opacity 0.5s ease;
}
.hero-placeholder span {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.hero.has-video .hero-placeholder { opacity: 0; }

/* legibility gradient: dark at the bottom (text) and top (bar), clearer middle */
.hero-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    var(--bg-base) 0%,
    rgba(10, 10, 16, 0.86) 14%,
    rgba(10, 10, 16, 0.32) 46%,
    rgba(10, 10, 16, 0.22) 72%,
    rgba(10, 10, 16, 0.55) 100%
  );
}

.hero-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--s5) 92px;
}

.hero-title {
  font-size: clamp(40px, 8vw, 84px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.02;
  color: var(--text-primary);
}
.hero-title .acc { color: var(--star-blue); }

.hero-lead {
  font-size: clamp(15px, 2vw, 18px);
  color: var(--text-default);
  max-width: 560px;
  margin-top: var(--s4);
  line-height: 1.6;
}
.hero-lead strong { color: var(--text-primary); font-weight: 600; }

/* ── Footer ──────────────────────────────────────────────────── */
.home-footer { position: relative; z-index: 1; }
.foot-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--s6) var(--s5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s4);
}
.foot-mark { font-weight: 600; color: var(--text-default); }
.foot-note { font-size: 12px; color: var(--text-faint); }
.foot-links { display: flex; gap: var(--s5); }
.foot-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  transition: color var(--ease);
}
.foot-links a:hover { color: var(--star-blue); }

/* ── Landing responsive ──────────────────────────────────────── */
@media (max-width: 560px) {
  .topbar { padding: var(--s3) var(--s4); }
  .topbar-link { display: none; }
  .hero-content { padding-bottom: var(--s7); }
  .foot-inner { justify-content: center; text-align: center; }
}
