:root {
  --bg:            #ede8df;
  --bg-card:       #faf8f5;
  --bg-card-hover: #ffffff;
  --bg-header:     #111009;
  --bg-controls:   #faf8f5;
  --bg-muted:      #ddd5c8;

  --border:        #cec5b8;
  --border-hover:  #b5a89a;

  --text-primary:  #1a1410;
  --text-secondary:#6a5a50;
  --text-muted:    #a8998d;
  --text-on-dark:  #e8e0d5;
  --text-on-dark-2:#9e9080;

  --red:           #c0311f;
  --red-dim:       rgba(192,49,31,0.08);
  --red-border:    rgba(192,49,31,0.2);
  --red-glow:      rgba(192,49,31,0.18);

  --orange:        #b05a10;
  --orange-dim:    rgba(176,90,16,0.09);
  --orange-border: rgba(176,90,16,0.22);

  --green:         #236b42;
  --green-dim:     rgba(35,107,66,0.08);
  --green-border:  rgba(35,107,66,0.22);

  --blue:          #1a5f8c;
  --blue-dim:      rgba(26,95,140,0.08);
  --blue-border:   rgba(26,95,140,0.22);

  --radius:    8px;
  --radius-sm: 5px;
  --radius-xs: 3px;

  --shadow-card:  0 1px 2px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.07);
  --shadow-hover: 0 2px 4px rgba(0,0,0,0.06), 0 12px 28px rgba(0,0,0,0.14);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────── */

.site-header {
  background: var(--bg-header);
  padding: 56px 24px 44px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Subtle noise texture overlay */
.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  opacity: 0.4;
  pointer-events: none;
}

.header-inner {
  max-width: 1160px;
  margin: 0 auto;
  position: relative;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.signal-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  animation: blink 1.8s step-start infinite;
  box-shadow: 0 0 8px var(--red);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.signal-label {
  font-family: 'DM Sans', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.25em;
  color: var(--red);
  text-transform: uppercase;
}

.site-title {
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
  font-size: clamp(36px, 7.5vw, 82px);
  font-weight: 900;
  font-style: italic;
  line-height: 0.95;
  color: #fff;
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

.site-title .accent {
  color: var(--red);
  font-style: normal;
}

.site-subtitle {
  color: var(--text-on-dark-2);
  font-size: 15px;
  font-weight: 400;
  margin-bottom: 40px;
  letter-spacing: 0.01em;
}

/* Stats bar */
.stats-bar {
  display: inline-flex;
  align-items: stretch;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  overflow: hidden;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 32px;
}

.stat-divider {
  width: 1px;
  background: rgba(255,255,255,0.08);
  align-self: stretch;
}

.stat-num {
  font-family: 'Playfair Display', serif;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-on-dark);
}
.stat-num.stat-red    { color: #e05c4a; }
.stat-num.stat-orange { color: #d4834a; }
.stat-num.stat-green  { color: #4aab76; }

.stat-lbl {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-on-dark-2);
  margin-top: 4px;
}

/* ── Controls bar ────────────────────────────────────────── */

.controls-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250,248,245,0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
}

.controls-inner {
  max-width: 1160px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

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

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  padding: 8px 34px 8px 34px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.search-input:focus {
  border-color: var(--text-secondary);
  box-shadow: 0 0 0 3px rgba(106,90,80,0.1);
}

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

.search-clear {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
  display: none;
  transition: color 0.15s;
}

.search-clear:hover { color: var(--text-primary); }
.search-clear.visible { display: block; }

/* Filters */
.filter-wrap {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.filter-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
  background: rgba(0,0,0,0.03);
}

.filter-btn.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* Sort */
.sort-select {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  padding: 7px 12px;
  outline: none;
  transition: border-color 0.18s;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a8998d' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.sort-select:focus {
  border-color: var(--text-secondary);
}

/* ── Notes toggle ────────────────────────────────────────── */

.notes-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.notes-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.notes-toggle-track {
  position: relative;
  width: 34px;
  height: 20px;
  background: var(--bg-muted);
  border-radius: 10px;
  border: 1px solid var(--border);
  transition: background 0.18s, border-color 0.18s;
  flex-shrink: 0;
}

.notes-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  transition: transform 0.18s;
}

.notes-toggle input:checked ~ .notes-toggle-track {
  background: var(--text-secondary);
  border-color: var(--text-secondary);
}

.notes-toggle input:checked ~ .notes-toggle-track .notes-toggle-thumb {
  transform: translateX(14px);
}

.notes-toggle-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Hide notes when toggle is on */
body.hide-notes .info-block,
body.hide-notes .card-footer {
  display: none;
}

/* ── Main content ────────────────────────────────────────── */

.main-content {
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px 24px 56px;
}

.results-info {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
  min-height: 18px;
}

/* ── Show Grid ───────────────────────────────────────────── */

.shows-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

/* ── Show Card ───────────────────────────────────────────── */

.show-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s;
  animation: fadeUp 0.28s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.show-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border-hover);
}

/* ── Poster image ────────────────────────────────────────── */

.card-poster {
  position: relative;
  width: 100%;
  height: 195px;
  background: var(--bg-muted);
  overflow: hidden;
  flex-shrink: 0;
}

/* Coloured stripe at bottom of poster */
.card-poster::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 3;
  background: var(--border);
}
.show-card.cancelled .card-poster::after { background: var(--red); }
.show-card.ended     .card-poster::after { background: var(--green); }
.show-card.running   .card-poster::after { background: var(--blue); }

/* Subtle gradient at poster bottom */
.card-poster::before {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 0;
  right: 0;
  height: 70px;
  background: linear-gradient(to top, rgba(0,0,0,0.55) 0%, transparent 100%);
  z-index: 2;
  pointer-events: none;
}

.card-poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 1;
}

.card-poster.loaded img { opacity: 1; }

/* Placeholder while loading or on error */
.poster-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 0;
}

/* Shimmer while loading */
.card-poster:not(.loaded):not(.error) .poster-placeholder {
  background: linear-gradient(
    90deg,
    var(--bg-muted)  0%,
    #e8e0d2          50%,
    var(--bg-muted)  100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.poster-initial {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 96px;
  font-weight: 700;
  font-style: italic;
  line-height: 1;
  color: var(--border-hover);
  opacity: 0;
  user-select: none;
  transition: opacity 0.3s;
}

.card-poster.error .poster-placeholder {
  animation: none;
  background: linear-gradient(135deg, #e0d8ce 0%, #ede6dc 100%);
}

.card-poster.error .poster-initial {
  opacity: 1;
  color: #c5b9ac;
}

/* ── Card body ───────────────────────────────────────────── */

.card-body {
  padding: 16px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

/* Card header row */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.show-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
  flex: 1;
}

.status-badge {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 2px;
  flex-shrink: 0;
  white-space: nowrap;
  margin-top: 2px;
}

.status-badge.cancelled {
  background: var(--red);
  color: #fff;
}
.status-badge.ended {
  background: var(--green);
  color: #fff;
}
.status-badge.running {
  background: var(--blue);
  color: #fff;
}

/* Meta row */
.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.network-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
}

.years-text {
  font-size: 13px;
  color: var(--text-muted);
}

/* Genres */
.genres {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.genre-tag {
  font-size: 11px;
  font-weight: 400;
  padding: 2px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
}

/* Season info */
.season-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--red);
  letter-spacing: 0.01em;
}

.season-info .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--red-dim);
  border: 1px solid var(--red-border);
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
}

.season-info.saved { color: var(--green); }

.season-info.saved .icon {
  background: var(--green-dim);
  border-color: var(--green-border);
}

/* Cliffhanger / resolution block */
.info-block {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
}

.info-block.cliffhanger {
  background: var(--orange-dim);
  border: 1px solid var(--orange-border);
}

.info-block.resolution {
  background: var(--green-dim);
  border: 1px solid var(--green-border);
}

.info-block-icon {
  font-size: 13px;
  font-weight: 900;
  flex-shrink: 0;
  margin-top: 1px;
  font-style: normal;
}

.info-block.cliffhanger .info-block-icon { color: var(--orange); }
.info-block.resolution  .info-block-icon { color: var(--green); }

.info-block-label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.info-block.cliffhanger .info-block-label { color: var(--orange); }
.info-block.resolution  .info-block-label { color: var(--green); }

.info-block-note {
  font-size: 12px;
  line-height: 1.45;
}

.info-block.cliffhanger .info-block-note { color: #7a4010; }
.info-block.resolution  .info-block-note { color: #1a5c36; }

/* Card footer */
.card-footer {
  padding: 12px 16px 16px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.show-note {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ── No results ──────────────────────────────────────────── */

.no-results {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-muted);
}

.no-results-tv { display: inline-block; margin-bottom: 20px; }

.tv-screen {
  width: 64px;
  height: 50px;
  border: 3px solid var(--border);
  border-radius: 6px;
  margin: 0 auto 8px;
  position: relative;
  background: var(--bg-muted);
}

.tv-screen::after {
  content: '';
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
}

.no-results p {
  font-size: 15px;
  margin-top: 16px;
}

/* ── Footer ──────────────────────────────────────────────── */

.site-footer {
  background: var(--bg-header);
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 28px 24px;
  text-align: center;
  color: var(--text-on-dark-2);
  font-size: 13px;
  line-height: 1.8;
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 640px) {
  .site-header { padding: 36px 16px 28px; }

  .stats-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .stat-divider { display: none; }

  .stat-item { padding: 12px 16px; }
  .stat-item:nth-child(1),
  .stat-item:nth-child(3) { border-right: 1px solid rgba(255,255,255,0.08); }
  .stat-item:nth-child(1),
  .stat-item:nth-child(2) { border-bottom: 1px solid rgba(255,255,255,0.08); }

  .controls-inner { flex-direction: column; align-items: stretch; }
  .sort-select    { width: 100%; }
  .notes-toggle   { align-self: flex-start; }
  .shows-grid     { grid-template-columns: 1fr; }
  .main-content   { padding: 16px 16px 40px; }
}

@media (max-width: 400px) {
  .filter-wrap { display: grid; grid-template-columns: 1fr 1fr; }
}

/* ── Pagination ──────────────────────────────────────────────── */
.pagination-wrap {
  display: flex;
  justify-content: center;
  padding: 32px 0 8px;
}

.pagination-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  cursor: pointer;
  white-space: nowrap;
}

a.page-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-secondary);
}

.page-btn.page-current {
  background: var(--bg-header);
  color: #fff;
  border-color: var(--bg-header);
  font-weight: 600;
  cursor: default;
}

.page-btn.page-disabled {
  opacity: 0.35;
  cursor: default;
}

.page-btn.page-prev,
.page-btn.page-next {
  font-size: 13px;
}

.page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  color: var(--text-muted);
  font-size: 16px;
}

/* ── Spoiler warning overlay ─────────────────────────────────── */
#spoiler-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 10, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 24px;
  opacity: 1;
  transition: opacity 0.3s ease;
}

#spoiler-overlay.spoiler-dismissed {
  opacity: 0;
}

.spoiler-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}

.spoiler-icon {
  font-size: 36px;
  margin-bottom: 16px;
  color: var(--orange);
}

.spoiler-box h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-size: 26px;
  font-weight: 900;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.spoiler-box p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 12px;
  font-size: 15px;
}

.spoiler-box p:last-of-type {
  margin-bottom: 28px;
}

#spoiler-dismiss {
  background: var(--bg-header);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  width: 100%;
}

#spoiler-dismiss:hover {
  opacity: 0.85;
}
