/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg: #fdf9f0;
  --surface: #ffffff;
  --ink: #1a1209;
  --ink-light: #3a3020;
  --yellow: #f5c518;
  --yellow-dark: #c9a000;
  --red: #cc2200;
  --green: #1f6e1f;
  --muted: #888070;
  --shadow: 4px 4px 0 rgba(0, 0, 0, 0.18);
  --radius: 6px;
  --font-display: "Bangers", cursive;
  --font-body: "Cabin", sans-serif;
  --transition: 0.2s ease;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.06) 1px, transparent 1px);
  background-size: 20px 20px;
  color: var(--ink);
  padding: 0 0 80px;
}

/* ── Page Header ───────────────────────────────────────────── */
.page-header {
  background: var(--ink);
  color: var(--yellow);
  text-align: center;
  padding: 28px 20px 20px;
  border-bottom: 6px solid var(--yellow);
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3.8rem);
  letter-spacing: 3px;
  line-height: 1;
  text-shadow: 3px 3px 0 var(--yellow-dark);
}

/* ── Progress Bar ──────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--ink);
  padding: 10px 20px 14px;
  border-bottom: 4px solid var(--yellow);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.progress-label {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 1.5px;
  color: var(--yellow);
  white-space: nowrap;
}

.progress-track {
  flex: 1;
  min-width: 160px;
  height: 14px;
  background: #3a3020;
  border-radius: 7px;
  border: 2px solid var(--yellow-dark);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--yellow), var(--yellow-dark));
  border-radius: 7px;
  transition: width 0.4s ease;
}

.progress-count {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 1px;
  color: #ccc;
  white-space: nowrap;
}

/* ── Sticky Toolbar ────────────────────────────────────────── */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 3px solid var(--ink);
  padding: 10px 20px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 180px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  color: var(--muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 8px 10px 8px 32px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--bg);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#search-input:focus {
  border-color: var(--yellow-dark);
  box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.25);
}

#clear-search {
  display: none;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  padding: 2px;
}

#section-dropdown {
  padding: 8px 10px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.92rem;
  background: var(--bg);
  cursor: pointer;
  max-width: 220px;
  width: 100%;
}

.toolbar-btn {
  padding: 8px 14px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--yellow);
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 1px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}

.toolbar-btn:hover {
  background: var(--yellow);
  color: var(--ink);
}

/* ── Cover Image ───────────────────────────────────────────── */
.cover-img-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 26px 20px 12px;
}

.cover-img-wrap img {
  width: 100%;
  max-width: 420px;
  height: auto;
  border: 4px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ── Legend ────────────────────────────────────────────────── */
.legend {
  text-align: center;
  margin: 6px 20px 24px;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
}

.legend .collected {
  color: var(--red);
}

.legend .sep {
  color: var(--muted);
  font-weight: 400;
}

.legend .singles {
  color: var(--green);
}

/* ── Publisher Section ─────────────────────────────────────── */
.publisher-block {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
}

.publisher-heading {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  letter-spacing: 3px;
  text-align: center;
  padding: 24px 0 8px;
  border-bottom: 4px solid var(--ink);
  margin-bottom: 6px;
}

.publisher-image {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}

.publisher-image img {
  width: 100%;
  max-width: 300px;
  height: auto;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ── Comic Section (collapsible) ───────────────────────────── */
.comic-section {
  background: var(--surface);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  margin: 18px 0;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.comic-section.hidden-by-search {
  display: none;
}

.section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--ink);
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}

.section-toggle:hover {
  background: var(--ink-light);
}

.section-toggle h3 {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  letter-spacing: 2px;
  color: var(--yellow);
  flex: 1;
  margin: 0;
}

.section-badge {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--yellow);
  color: var(--ink);
  border-radius: 20px;
  padding: 2px 9px;
  white-space: nowrap;
  flex-shrink: 0;
}

.chevron {
  color: var(--yellow);
  font-size: 1.1rem;
  transition: transform var(--transition);
  flex-shrink: 0;
}

.comic-section.collapsed .chevron {
  transform: rotate(-90deg);
}

.section-body {
  padding: 14px 16px 16px;
}

.comic-section.collapsed .section-body {
  display: none;
}

.section-img {
  display: flex;
  justify-content: center;
  margin: 8px 0 14px;
}

.section-img img {
  width: 100%;
  max-width: 180px;
  height: auto;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.15);
}

/* ── Sub-headings (h4) ─────────────────────────────────────── */
.sub-heading {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 1.5px;
  text-align: center;
  margin: 18px 0 8px;
  padding: 4px 0;
  border-bottom: 2px solid var(--ink);
}

/* ── Event Label ───────────────────────────────────────────── */
.event-label {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 4vw, 2rem);
  letter-spacing: 3px;
  text-align: center;
  margin: 30px 0 0;
  padding: 10px;
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
}

/* ── List Items ────────────────────────────────────────────── */
ul.comic-list {
  list-style: none;
  padding: 0;
  margin: 6px 0;
}

ul.comic-list li {
  background: var(--bg);
  margin: 7px 0;
  padding: 10px 12px;
  border: 2px solid #d6cfc0;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: border-color var(--transition), background var(--transition);
}

ul.comic-list li:hover {
  border-color: var(--ink);
}

ul.comic-list li.hidden-by-search {
  display: none;
}

.comic-label {
  flex: 1;
  min-width: 0;
  font-style: italic;
  line-height: 1.4;
}

ul.comic-list li.is-checked {
  border-color: var(--green);
  background: #f0faf0;
}

ul.comic-list li.is-checked .comic-label {
  color: var(--green);
  font-weight: 600;
}

/* ── Inline badges (existing data uses these) ───────────────── */
.issues-badge {
  color: var(--green);
  font-style: normal;
  font-weight: 600;
}

.format-badge {
  color: var(--green);
  font-style: normal;
  font-weight: 700;
}

/* ── Owned Issues Inline Indicator ─────────────────────────── */
.owned-issues {
  color: #2f7d32;
  font-weight: 600;
  font-size: 0.9em;
  margin-left: 6px;
  white-space: nowrap;
}

/* ── Status wrap (Collected badge + hardcover icon) ────────── */
.status-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.status-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 14px;
  white-space: nowrap;
  user-select: none;
}

.status-badge.collected {
  background: var(--green);
  color: #fff;
}

.hardcover-icon {
  font-size: 0.9rem;
  line-height: 1;
}

/* ── Or-divider ────────────────────────────────────────────── */
.or-divider {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 10px 0;
  font-weight: 600;
  letter-spacing: 1px;
}

/* ── No-results message ────────────────────────────────────── */
#no-results {
  display: none;
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-size: 1.1rem;
}

/* ── Floating Back-to-Top ──────────────────────────────────── */
#back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  background: var(--ink);
  color: var(--yellow);
  border: 3px solid var(--yellow);
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
  transition: opacity var(--transition), transform var(--transition);
  opacity: 0;
  pointer-events: none;
  z-index: 200;
  text-decoration: none;
}

#back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

#back-to-top:hover {
  transform: translateY(-3px);
}

/* ── Search highlight ──────────────────────────────────────── */
mark {
  background: var(--yellow);
  color: var(--ink);
  border-radius: 2px;
  padding: 0 2px;
}

/* ── Print Styles ──────────────────────────────────────────── */
@media print {
  @page { margin: 1.5cm; }

  body {
    background: #fff;
    background-image: none;
    color: #000;
    padding: 0;
    font-size: 11pt;
  }

  .toolbar,
  .progress-bar-wrap,
  #back-to-top,
  .chevron,
  .cover-img-wrap,
  .publisher-image,
  .section-img {
    display: none !important;
  }

  .publisher-heading {
    font-size: 20pt;
    page-break-before: always;
    border-bottom: 2pt solid #000;
    margin-bottom: 12pt;
  }

  .publisher-heading:first-of-type {
    page-break-before: auto;
  }

  .comic-section {
    border: 1pt solid #999;
    box-shadow: none;
    margin: 8pt 0;
    page-break-inside: avoid;
  }

  .comic-section.collapsed .section-body {
    display: block !important;
  }

  ul.comic-list li {
    background: #fff;
    border: 0.5pt solid #ccc;
    padding: 4pt 8pt;
    margin: 3pt 0;
    page-break-inside: avoid;
  }

  ul.comic-list li.hidden-by-search {
    display: flex !important;
  }

  .page-header {
    background: #000;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    padding: 12pt 0 8pt;
    border-bottom: 3pt solid #000;
  }

  .page-header h1 {
    font-size: 26pt;
    text-shadow: none;
  }

  .legend {
    margin: 8pt 0;
  }
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 540px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  #section-dropdown {
    max-width: 100%;
  }

  .progress-bar-wrap {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .progress-track {
    width: 100%;
  }
}
