/* ============================================================
   Marvel Multiverse Timeline — design tokens
   Palette: deep-space void + six transit-line accent colors
   Type: Bebas Neue (display/signage), Inter (body/UI), IBM Plex Mono (data)
   ============================================================ */

:root {
  --bg: #0a0b12;
  --bg-panel: #14151f;
  --bg-panel-2: #191b28;
  --border: #262838;
  --border-soft: #1c1e2c;
  --text: #f2f1ec;
  --text-dim: #9b9cae;
  --text-faint: #666980;

  --line-mcu: #e0313b;
  --line-xmen: #d9a63e;
  --line-spiderSony: #2e86de;
  --line-spiderVerse: #ff3ea5;
  --line-sonyVillains: #3fa34d;
  --line-classic: #a97142;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --font-display: "Bebas Neue", "Arial Narrow", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(224,49,59,0.10), transparent 60%),
    radial-gradient(ellipse 700px 500px at 90% 10%, rgba(46,134,222,0.08), transparent 60%);
  background-attachment: fixed;
}

a { color: inherit; }

::selection { background: rgba(224,49,59,0.35); }

/* focus visibility */
button:focus-visible,
input:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ============================================================
   App shell
   ============================================================ */

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  padding: 28px clamp(16px, 4vw, 48px) 16px;
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(10, 11, 18, 0.92);
  backdrop-filter: blur(10px);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  max-width: 640px;
}

.brand-mark {
  font-size: 22px;
  color: var(--line-mcu);
  line-height: 1.5;
  filter: drop-shadow(0 0 8px rgba(224,49,59,0.6));
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 38px);
  letter-spacing: 0.5px;
  margin: 0 0 4px;
  line-height: 1;
}

.tagline {
  margin: 0;
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.5;
  max-width: 52ch;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--text-faint);
}

.search-box input {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13.5px;
  width: 170px;
  outline: none;
}
.search-box input::placeholder { color: var(--text-faint); }

.sort-toggle {
  display: inline-flex;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.sort-btn {
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.sort-btn:hover { color: var(--text); }
.sort-btn.is-active {
  background: var(--line-mcu);
  color: #fff;
}

/* legend / line filter chips */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px 6px 8px;
  cursor: pointer;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

.legend-chip .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-chip .count {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.legend-chip.is-off {
  opacity: 0.35;
}

/* ============================================================
   Timeline canvas
   ============================================================ */

.timeline-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: stretch;
}

.scroll-hint {
  position: absolute;
  top: 14px;
  right: clamp(16px, 4vw, 48px);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  pointer-events: none;
  animation: hint-fade 4s ease forwards;
}
@keyframes hint-fade {
  0%, 60% { opacity: 1; }
  100% { opacity: 0; }
}

.scroll-area {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 24px;
}

.ruler {
  position: relative;
  height: 40px;
  min-width: 100%;
}

.year-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border-soft);
}

.year-label {
  position: absolute;
  top: 10px;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
}

.canvas {
  position: relative;
  min-width: 100%;
}

.connectors-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.lane-track {
  position: absolute;
  height: 3px;
  border-radius: 3px;
  opacity: 0.9;
}

.lane-label {
  position: absolute;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.movie-node {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid var(--bg);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.15s ease;
}
.movie-node:hover,
.movie-node:focus-visible {
  transform: translate(-50%, -50%) scale(1.35);
  z-index: 5;
}
.movie-node.is-milestone {
  border-width: 3px;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.12);
}
.movie-node.is-upcoming {
  border-style: dashed;
  background: transparent !important;
  border-width: 2px;
}
.movie-node.is-dimmed { opacity: 0.15; }
.movie-node.is-matched {
  box-shadow: 0 0 0 5px rgba(255,255,255,0.25);
}

.node-label {
  position: absolute;
  font-family: var(--font-body);
  font-size: 10.5px;
  color: var(--text-dim);
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.15s ease;
}
.node-label.is-dimmed { opacity: 0.12; }

.year-marker-text {
  font-family: var(--font-mono);
  font-size: 20px;
  fill: var(--text-faint);
}

/* shelved / in-development rail */
.shelved-rail {
  width: 240px;
  flex-shrink: 0;
  border-left: 1px solid var(--border-soft);
  padding: 20px 18px;
  overflow-y: auto;
}
.shelved-rail h2 {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.4px;
  margin: 0 0 4px;
}
.shelved-sub {
  font-size: 11.5px;
  color: var(--text-faint);
  margin: 0 0 14px;
}
.shelved-card {
  background: var(--bg-panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.shelved-card:hover { border-color: var(--text-faint); }
.shelved-card .sc-title {
  font-weight: 700;
  font-size: 13.5px;
  margin-bottom: 3px;
}
.shelved-card .sc-status {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--line-xmen);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.mode-note {
  margin: 0 clamp(16px, 4vw, 48px) 20px;
  padding: 12px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--line-xmen);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.5;
  max-width: 720px;
}
.mode-note strong { color: var(--text); }

/* ============================================================
   Detail panel
   ============================================================ */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,5,9,0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 40;
}
.overlay.is-visible { opacity: 1; pointer-events: auto; }

.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(400px, 92vw);
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(.2,.8,.3,1);
  z-index: 50;
  overflow-y: auto;
  padding: 28px 26px;
}
.detail-panel.is-open { transform: translateX(0); }

.detail-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.detail-close:hover { color: var(--text); }

.detail-poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--border);
  margin-bottom: 18px;
  background: var(--bg-panel-2);
}

.detail-poster--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 64px;
}

.detail-line-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 5px 11px;
  border-radius: 999px;
  margin-bottom: 16px;
}

.detail-title {
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: 0.3px;
  line-height: 1.05;
  margin: 0 0 18px;
  padding-right: 30px;
}

.detail-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  font-size: 13px;
  margin-bottom: 20px;
}
.detail-meta dt {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding-top: 1px;
}
.detail-meta dd { margin: 0; color: var(--text); }

.detail-synopsis {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.status-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.status-released { color: #7fd97f; }
.status-upcoming { color: var(--line-xmen); }
.status-shelved { color: var(--text-faint); }

/* ============================================================
   Footer
   ============================================================ */

.app-footer {
  padding: 18px clamp(16px, 4vw, 48px) 28px;
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.6;
}
.app-footer p { margin: 3px 0; }
.app-footer code {
  font-family: var(--font-mono);
  background: var(--bg-panel);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 760px) {
  .header-top { flex-direction: column; }
  .search-box input { width: 120px; }
  .timeline-wrapper { flex-direction: column; }
  .shelved-rail {
    width: auto;
    border-left: none;
    border-top: 1px solid var(--border-soft);
  }
  .detail-panel { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ============================================================
   Floating Movie Poster Preview
   ============================================================ */

.poster-preview {
  /* fixed, not absolute: JS positions this from getBoundingClientRect(),
     which is viewport-relative — fixed keeps it correct at any scroll position */
  position: fixed;
  width: 170px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;

  /* anchored so its *bottom* edge sits at `top` (just above the node) */
  transform: translate(-50%, calc(-100% + 10px)) scale(0.92);

  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    visibility 0.18s ease;

  z-index: 9999;
}

.poster-preview.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -100%) scale(1);
}

.poster-preview img {
  display: block;
  width: 100%;
  height: auto;

  border-radius: 14px;

  border: 1px solid rgba(255,255,255,0.08);

  background: #111;

  box-shadow:
    0 22px 50px rgba(0,0,0,.65),
    0 8px 18px rgba(0,0,0,.35);

  user-select: none;
}

/* Small arrow under poster */

.poster-preview::after {

  content: "";

  position: absolute;

  left: 50%;

  bottom: -8px;

  transform: translateX(-50%);

  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid rgba(20,21,31,.95);

}

/* Mobile */

@media (max-width:760px){

  .poster-preview{

      width:140px;

  }

}