/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img { display: block; max-width: 100%; }

/* ── Design tokens ────────────────────────────────────────────── */
:root {
  --bg:        #08090E;
  --surface:   #0F1118;
  --card:      #14192A;
  --card-hi:   #1C2338;
  --border:    #252D45;
  --border-hi: #3A4564;

  --cream:     #EDE8DC;
  --muted:     #606A84;
  --faint:     #363D55;

  --gold:      #D4A843;
  --gold-dim:  rgba(212, 168, 67, 0.15);
  --rose:      #B85B74;
  --rose-dim:  rgba(184, 91, 116, 0.15);

  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body:    'Lora', Georgia, serif;
  --font-mono:    'DM Mono', 'Courier New', monospace;

  --radius: 2px;
  --transition: 0.18s ease;
}

/* ── Base ─────────────────────────────────────────────────────── */
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(ellipse at 50% 0%, transparent 50%, rgba(0,0,0,0.55) 100%);
}

/* ── Layout ───────────────────────────────────────────────────── */
.page {
  position: relative;
  z-index: 2;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────────── */
.header {
  padding: 72px 0 52px;
  text-align: center;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 18px;
  opacity: 0.9;
}

.site-title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(64px, 10vw, 108px);
  line-height: 0.92;
  letter-spacing: -0.015em;
  color: var(--cream);
}

.site-title em {
  font-style: italic;
  color: var(--gold);
}

.tagline {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
  margin-top: 24px;
}

/* Header rule */
.header-rule {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 48px;
}

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

.rule-line:last-child {
  background: linear-gradient(270deg, transparent, var(--border));
}

.rule-diamond {
  font-size: 8px;
  color: var(--gold);
  opacity: 0.7;
}

/* ── Main ─────────────────────────────────────────────────────── */
.main { flex: 1; padding: 56px 0 40px; }

/* ── Search ───────────────────────────────────────────────────── */
.search-section {
  display: flex;
  justify-content: center;
  margin-bottom: 72px;
}

.search-outer {
  width: 100%;
  max-width: 580px;
  position: relative;
}

.search-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--gold);
  transition: border-color var(--transition), background var(--transition);
}

.search-field:focus-within {
  background: var(--card);
  border-color: var(--border-hi);
  border-bottom-color: var(--gold);
}

.search-icon {
  position: absolute;
  left: 16px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
  flex-shrink: 0;
  transition: color var(--transition);
}

.search-field:focus-within .search-icon { color: var(--gold); }

.search-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 18px 20px 18px 44px;
  font-family: var(--font-body);
  font-size: 17px;
  color: var(--cream);
  caret-color: var(--gold);
}

.search-input::placeholder { color: var(--faint); }

/* ── Search Dropdown ──────────────────────────────────────────── */
.search-dropdown {
  position: absolute;
  top: calc(100% + 1px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border-hi);
  border-top: none;
  z-index: 50;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0,0,0,0.5);
}

.search-dropdown.hidden { display: none; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--card-hi); }

.di-thumb {
  width: 34px;
  height: 51px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface);
}

.di-thumb-placeholder {
  width: 34px;
  height: 51px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 15px;
  color: var(--muted);
}

.di-info { flex: 1; min-width: 0; }

.di-name {
  font-size: 14px;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.di-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.di-badge {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 2px;
}

.badge-person { background: var(--gold-dim); color: var(--gold); }
.badge-movie  { background: var(--rose-dim); color: var(--rose); }

.di-year {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

/* ── Output section ───────────────────────────────────────────── */
.output { min-height: 260px; }

/* ── Loading ──────────────────────────────────────────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 80px 0;
}

.loading-state.hidden { display: none; }

/* Film reel spinner */
.film-reel {
  position: relative;
  width: 56px;
  height: 56px;
}

.reel-hub {
  position: absolute;
  inset: 16px;
  background: var(--card);
  border: 2px solid var(--gold);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.9s linear infinite;
}

.reel-spokes {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--border);
  animation: spin-rev 2s linear infinite;
}

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

.loading-text {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 16px;
  color: var(--cream);
  opacity: 0.7;
}

.loading-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-top: -16px;
}

.ellipsis::after {
  content: '';
  display: inline-block;
  width: 1.8em;
  animation: dots 1.6s steps(4, end) infinite;
}
@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

/* ── Degrees hero ─────────────────────────────────────────────── */
.result-state.hidden { display: none; }

.degrees-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 40px 0 52px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 52px;
  animation: fade-up 0.5s ease-out both;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.degrees-number {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(80px, 12vw, 120px);
  line-height: 1;
  color: var(--gold);
  font-style: italic;
}

.degrees-right {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.degrees-word {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(24px, 3.5vw, 36px);
  color: var(--cream);
  font-style: italic;
  line-height: 1.2;
}

.degrees-of {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.degrees-from {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--rose);
}

/* ── Path track ───────────────────────────────────────────────── */
.path-track {
  display: flex;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 32px;
  gap: 0;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar but keep functionality */
.path-track { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.path-track::-webkit-scrollbar { height: 3px; }
.path-track::-webkit-scrollbar-track { background: transparent; }
.path-track::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Path node ────────────────────────────────────────────────── */
.path-node {
  flex-shrink: 0;
  width: 152px;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  animation: node-in 0.45s cubic-bezier(0.2, 0, 0, 1) both;
}

@keyframes node-in {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Stagger delays assigned inline via JS */

.node-card {
  background: var(--card);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
  cursor: default;
}

.path-node.is-target .node-card {
  border-color: var(--gold);
  box-shadow:
    0 0 0 1px var(--gold),
    0 0 32px rgba(212, 168, 67, 0.12);
}

.node-poster-wrap {
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: var(--surface);
  position: relative;
}

.node-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.node-card:hover .node-poster { transform: scale(1.04); }

.node-poster-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--faint);
}

/* Target badge overlay */
.target-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--gold);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 7.5px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 3px 6px;
}

.node-info {
  padding: 11px 12px 13px;
  border-top: 1px solid var(--border);
}

.path-node.is-target .node-info {
  border-top-color: var(--gold);
  background: rgba(212,168,67,0.04);
}

.node-badge {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 5px;
  display: block;
}

.node-badge.badge-person { color: var(--gold); }
.node-badge.badge-movie  { color: var(--rose); }

.node-name {
  font-size: 13px;
  line-height: 1.4;
  color: var(--cream);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.node-year {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Connector ────────────────────────────────────────────────── */
.path-connector {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 56px;
  /* vertically aligned with midpoint of poster */
  padding-top: 80px;
  gap: 5px;
}

.connector-shaft {
  width: 100%;
  height: 1px;
  background: var(--rose);
  position: relative;
}

.connector-shaft::after {
  content: '›';
  position: absolute;
  right: -5px;
  top: -9px;
  color: var(--rose);
  font-size: 16px;
  line-height: 1;
}

.connector-label {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

/* ── Not Found ────────────────────────────────────────────────── */
.not-found.hidden { display: none; }

.not-found {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
}

.nf-inner { text-align: center; max-width: 340px; }

.nf-ornament {
  display: block;
  font-size: 28px;
  color: var(--muted);
  margin-bottom: 20px;
  opacity: 0.5;
}

.nf-title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 36px;
  font-style: italic;
  color: var(--cream);
  margin-bottom: 12px;
}

.nf-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
}

/* ── Footer ───────────────────────────────────────────────────── */
.footer {
  padding: 28px 0 32px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.footer a {
  color: var(--gold);
  text-decoration: none;
  opacity: 0.8;
  transition: opacity var(--transition);
}

.footer a:hover { opacity: 1; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  .page { padding: 0 16px; }
  .header { padding: 48px 0 36px; }

  .tagline br { display: none; }

  .degrees-hero { gap: 16px; padding: 32px 0 40px; margin-bottom: 40px; }
  .degrees-number { font-size: 80px; }
  .degrees-word { font-size: 24px; }

  .path-node { width: 128px; }
  .path-connector { width: 44px; }
}
