/* DC Finest Most-Wanted — Silver-Age pulp ballot
   Midnight navy, hot-red cover banner, gold vote ordinals, halftone texture. */

:root {
  --navy-900: #070b18;
  --navy-800: #0b1124;
  --navy-700: #111a35;
  --navy-600: #18244a;
  --line: #243156;
  --ink: #eaf0ff;
  --ink-dim: #9aa8d0;
  --ink-faint: #66759f;
  --blue: #3b82f6;
  --blue-bright: #5b9cff;
  --red: #e0263c;
  --red-deep: #b01228;
  --gold: #f5c518;
  --gold-deep: #c79a00;
  --radius: 14px;
  --shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.9);
  --maxw: 1500px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Archivo", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(59, 130, 246, 0.18), transparent 60%),
    radial-gradient(900px 600px at -5% 0%, rgba(224, 38, 60, 0.12), transparent 55%),
    var(--navy-900);
  min-height: 100vh;
}

/* Halftone dot overlay for pulp atmosphere */
.halftone {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image: radial-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1.3px);
  background-size: 7px 7px;
  mix-blend-mode: screen;
}

body > *:not(.halftone) { position: relative; z-index: 1; }

/* ---------- Masthead ---------- */
.masthead {
  border-bottom: 3px solid var(--red);
  background: linear-gradient(180deg, rgba(11, 17, 36, 0.92), rgba(7, 11, 24, 0.6));
  backdrop-filter: blur(6px);
}
.masthead-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px 26px 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.brand-kicker {
  font-family: "Oswald", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.42em;
  font-size: 12px;
  color: var(--gold);
}
.brand-title {
  font-family: "Anton", sans-serif;
  font-weight: 400;
  margin: 2px 0 4px;
  line-height: 0.9;
  font-size: clamp(34px, 6vw, 62px);
  letter-spacing: 0.01em;
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  color: #fff;
  text-shadow: 0 2px 0 var(--blue), 0 4px 18px rgba(59, 130, 246, 0.35);
}
.brand-title .banner {
  font-size: 0.46em;
  letter-spacing: 0.08em;
  color: #fff;
  background: linear-gradient(180deg, var(--red), var(--red-deep));
  padding: 6px 14px 4px;
  border-radius: 4px;
  transform: skewX(-7deg);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.18), 0 6px 14px -6px var(--red-deep);
}
.brand-sub {
  font-size: 13.5px;
  color: var(--ink-dim);
  font-style: italic;
}
.masthead-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  text-align: right;
}
.form-link {
  font-family: "Oswald", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 13px;
  color: var(--navy-900);
  background: var(--gold);
  padding: 9px 15px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 6px 16px -8px var(--gold-deep);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.form-link:hover { transform: translateY(-2px); box-shadow: 0 10px 20px -8px var(--gold-deep); }
.build-meta { font-size: 11.5px; color: var(--ink-faint); font-family: "Spline Sans Mono", monospace; }

/* ---------- Toolbar ---------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 26px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  background: rgba(7, 11, 24, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 6px; }
.tab {
  font-family: "Oswald", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-dim);
  background: transparent;
  border: none;
  padding: 10px 16px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  position: relative;
  transition: color 0.18s ease, background 0.18s ease;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: #fff; background: var(--navy-700); }
.tab.is-active::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px; bottom: -1px;
  height: 3px;
  background: var(--red);
  border-radius: 3px;
}
.tab-count {
  font-family: "Spline Sans Mono", monospace;
  font-size: 11px;
  background: var(--navy-600);
  color: var(--blue-bright);
  padding: 2px 7px;
  border-radius: 20px;
  margin-left: 4px;
}
.search-wrap { flex: 1; min-width: 220px; display: flex; align-items: center; gap: 12px; }
#search {
  flex: 1;
  background: var(--navy-800);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  padding: 11px 18px;
  font-family: "Archivo", sans-serif;
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
#search:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18); }
#search::placeholder { color: var(--ink-faint); }
.result-count { font-size: 12px; color: var(--ink-faint); font-family: "Spline Sans Mono", monospace; white-space: nowrap; }

.ballot-toggle {
  font-family: "Oswald", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  font-size: 14px;
  color: var(--navy-900);
  background: var(--gold);
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  display: none;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 18px -8px var(--gold-deep);
}
.ballot-pill {
  font-family: "Spline Sans Mono", monospace;
  background: var(--navy-900);
  color: var(--gold);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
}

/* ---------- Layout ---------- */
.layout {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 26px 80px;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 30px;
  align-items: start;
}

/* ---------- Grid + group dividers ---------- */
.grid { display: flex; flex-direction: column; gap: 26px; }
.group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}
.group-divider {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 6px 0 -2px;
}
.group-divider h3 {
  font-family: "Anton", sans-serif;
  font-weight: 400;
  font-size: 22px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  margin: 0;
}
.group-divider .rule { flex: 1; height: 2px; background: linear-gradient(90deg, var(--blue), transparent); }
.group-divider .tally {
  font-family: "Spline Sans Mono", monospace;
  font-size: 11px;
  color: var(--ink-faint);
}

/* ---------- Card ---------- */
.card {
  background: linear-gradient(180deg, var(--navy-700), var(--navy-800));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), transparent 70%);
  opacity: 0.7;
}
.card.is-ranked { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), var(--shadow); }
.card.is-ranked::before { background: linear-gradient(90deg, var(--gold), transparent 70%); opacity: 1; }

/* Cover strip — fanned stack of comics */
.covers {
  display: flex;
  height: 132px;
  align-items: flex-end;
  padding-left: 8px;
}
.covers .cover {
  width: 88px;
  height: 132px;
  margin-left: -42px;
  border-radius: 4px;
  background: var(--navy-600) center/cover no-repeat;
  border: 1px solid rgba(0, 0, 0, 0.5);
  box-shadow: 0 8px 16px -8px rgba(0, 0, 0, 0.9);
  transform: rotate(var(--rot, 0deg));
  transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1), margin 0.3s ease;
  position: relative;
  flex: 0 0 auto;
}
.covers .cover img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.covers .cover:first-child { margin-left: 0; }
.card:hover .covers .cover { margin-left: -28px; transform: rotate(0deg) translateY(-3px); }
.covers .cover.is-finest { box-shadow: 0 0 0 2px var(--gold), 0 8px 16px -8px rgba(0, 0, 0, 0.9); }
.covers .cover .ribbon {
  position: absolute;
  top: 7px; left: -5px;
  font-family: "Oswald", sans-serif;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--navy-900);
  background: var(--gold);
  padding: 2px 6px;
  border-radius: 2px;
  box-shadow: 0 3px 6px -2px rgba(0, 0, 0, 0.7);
}
.covers.is-empty {
  align-items: center;
  justify-content: center;
  color: var(--ink-faint);
  font-size: 12px;
  font-style: italic;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding-left: 0;
}

.card-body { display: flex; flex-direction: column; gap: 7px; }
.card-title {
  font-family: "Oswald", sans-serif;
  font-weight: 600;
  font-size: 17px;
  line-height: 1.12;
  color: #fff;
}
.card-title .era { color: var(--blue-bright); font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  font-family: "Spline Sans Mono", monospace;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--navy-600);
  color: var(--ink-dim);
  border: 1px solid var(--line);
}
.chip.year { color: var(--gold); border-color: rgba(245, 197, 24, 0.35); }
.chip.finest { color: var(--navy-900); background: var(--gold); border-color: var(--gold); font-weight: 600; }
.note {
  font-size: 12.5px;
  color: var(--ink-faint);
  font-style: italic;
  line-height: 1.35;
}
.stats { font-family: "Spline Sans Mono", monospace; font-size: 11px; color: var(--ink-faint); }
.stats b { color: var(--ink-dim); font-weight: 600; }

.card-foot { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.rank-btn {
  flex: 1;
  font-family: "Oswald", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: var(--navy-600);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, transform 0.08s ease;
}
.rank-btn:hover { background: var(--blue); border-color: var(--blue); color: #fff; }
.rank-btn:active { transform: scale(0.97); }
.rank-btn.is-ranked { background: var(--gold); border-color: var(--gold); color: var(--navy-900); }
.rank-btn.is-full { opacity: 0.4; cursor: not-allowed; }
.rank-ordinal {
  font-family: "Anton", sans-serif;
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy-900);
  font-size: 15px;
  flex: 0 0 auto;
  box-shadow: 0 4px 10px -4px var(--gold-deep);
}

/* ---------- Ballot ---------- */
.ballot {
  position: sticky;
  top: 78px;
  background: linear-gradient(180deg, var(--navy-700), var(--navy-800));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.ballot-head { display: flex; align-items: center; justify-content: space-between; }
.ballot-head h2 {
  font-family: "Anton", sans-serif;
  font-weight: 400;
  font-size: 24px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin: 0;
  color: #fff;
}
.ballot-head h2::before { content: "★ "; color: var(--gold); }
.ballot-x { display: none; background: none; border: none; color: var(--ink-dim); font-size: 26px; cursor: pointer; line-height: 1; }
.ballot-hint { font-size: 12px; color: var(--ink-faint); line-height: 1.45; margin: 8px 0 14px; }
.ballot-hint b { color: var(--ink-dim); }
.ballot-section { margin-bottom: 16px; }
.ballot-section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: "Oswald", sans-serif; text-transform: uppercase;
  letter-spacing: 0.06em; font-size: 13px; font-weight: 600; color: var(--ink-dim);
  border-bottom: 1px solid var(--line); padding-bottom: 5px; margin-bottom: 8px;
}
.cap { font-family: "Spline Sans Mono", monospace; font-size: 11px; color: var(--ink-faint); }
.cap.is-full { color: var(--gold); }
.ballot-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-height: 8px; }
.ballot-empty { font-size: 12px; color: var(--ink-faint); font-style: italic; padding: 4px 0; }
.ballot-item {
  display: flex; align-items: center; gap: 9px;
  background: var(--navy-600);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  animation: slidein 0.25s ease both;
}
@keyframes slidein { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
.ballot-item.is-dragging { opacity: 0.5; }
.bi-ord {
  font-family: "Anton", sans-serif;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--gold); color: var(--navy-900);
  display: grid; place-items: center; font-size: 12px; flex: 0 0 auto;
}
.bi-label { flex: 1; font-size: 12.5px; line-height: 1.2; color: var(--ink); }
.bi-label small { display: block; color: var(--ink-faint); font-size: 10.5px; }
.bi-move { display: flex; flex-direction: column; }
.bi-move button, .bi-remove {
  background: none; border: none; color: var(--ink-faint); cursor: pointer; padding: 0 3px; font-size: 12px; line-height: 1;
}
.bi-move button:hover, .bi-remove:hover { color: var(--ink); }
.bi-remove { font-size: 16px; }
.bi-handle { cursor: grab; color: var(--ink-faint); font-size: 13px; }

.ballot-actions { display: flex; gap: 8px; margin-top: 6px; }
.btn-copy {
  flex: 1;
  font-family: "Oswald", sans-serif; text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 600; font-size: 13px;
  color: var(--navy-900); background: var(--gold); border: none; border-radius: 8px;
  padding: 11px; cursor: pointer; box-shadow: 0 8px 16px -8px var(--gold-deep);
  transition: transform 0.12s ease;
}
.btn-copy:hover { transform: translateY(-1px); }
.btn-clear {
  font-family: "Oswald", sans-serif; text-transform: uppercase; letter-spacing: 0.05em;
  font-size: 13px; color: var(--ink-dim); background: transparent;
  border: 1px solid var(--line); border-radius: 8px; padding: 11px 14px; cursor: pointer;
}
.btn-clear:hover { color: var(--red); border-color: var(--red); }
.copied-toast {
  margin-top: 10px; font-size: 12px; color: var(--gold);
  background: rgba(245, 197, 24, 0.1); border: 1px solid rgba(245, 197, 24, 0.3);
  border-radius: 6px; padding: 8px 10px; text-align: center;
  opacity: 0; transform: translateY(6px); transition: opacity 0.25s ease, transform 0.25s ease;
}
.copied-toast.show { opacity: 1; transform: none; }

.ballot-scrim { display: none; }

.empty-state {
  text-align: center; padding: 60px 20px; color: var(--ink-faint);
  font-style: italic; grid-column: 1 / -1;
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .ballot-toggle { display: inline-flex; }
  .ballot {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(400px, 90vw);
    max-height: none;
    border-radius: 0;
    transform: translateX(105%);
    transition: transform 0.32s cubic-bezier(0.2, 0.7, 0.2, 1);
    z-index: 60;
  }
  .ballot.open { transform: none; }
  .ballot-x { display: block; }
  .ballot-scrim {
    display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease; z-index: 55;
  }
  .ballot-scrim.show { opacity: 1; pointer-events: auto; }
}
@media (max-width: 560px) {
  .masthead-inner { flex-direction: column; align-items: flex-start; }
  .masthead-meta { align-items: flex-start; text-align: left; }
  .group { grid-template-columns: 1fr; }
  .toolbar { gap: 10px; }
}
