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

:root {
  /* Letterboxd palette */
  --bg:             #14181c;   /* page/outer background */
  --surface:        #2c3440;   /* cards, table rows, header bar */
  --surface-alt:    #20272e;   /* subtle alt surface, row hover */
  --border:         rgba(255, 255, 255, 0.07);

  /* Text */
  --text:           #ffffff;
  --text-body:      #99aabb;
  --text-dim:       #678;

  /* Accent colours */
  --green:          #00e054;   /* progress bar, watched, active */
  --green-dark:     #00b020;   /* hover */
  --blue:           #40bcf4;   /* links */
  --orange:         #ff8000;

  /* Semantic aliases */
  --accent:         var(--green);
  --link:           var(--blue);
  --danger:         #c44;

  --font: -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 3px;
  --gap:    1.5rem;
}

/* ── Base ────────────────────────────────────────────────────────────── */
html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  background-color: var(--bg);
  color: var(--text-body);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Layout shell ────────────────────────────────────────────────────── */
.shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

/* ── Header ──────────────────────────────────────────────────────────── */
.header {
  background: var(--surface);
  margin: 0 -1.5rem 2.5rem;    /* bleed to page edges */
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Three-dot Letterboxd motif */
.header-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.header-dots span {
  display: block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.header-dots span:nth-child(1) { background: var(--green); }
.header-dots span:nth-child(2) { background: var(--blue); }
.header-dots span:nth-child(3) { background: var(--orange); }

.header-title {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
}

.header-subtitle {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 1px;
}

.header-updated {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* ── Divider ─────────────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* ── Section labels ──────────────────────────────────────────────────── */
.section-label {
  /* Reset button defaults */
  appearance: none;
  background: none;
  border: none;
  border-radius: 0;
  font-family: var(--font);
  text-align: left;
  width: 100%;

  /* Keep existing label styling */
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: color 0.15s;
}

.section-label:hover {
  color: var(--text-body);
}

/* Chevron indicator */
.section-chevron {
  display: inline-block;
  flex-shrink: 0;
  width: 0.6em;
  height: 0.6em;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);  /* ▾ expanded */
  transition: transform 0.2s ease;
  position: relative;
  top: -1px;
}

.section-label--collapsed .section-chevron {
  transform: rotate(-45deg);  /* ▸ collapsed */
}

@media (prefers-reduced-motion: reduce) {
  .section-chevron { transition: none; }
  .section-label   { transition: none; }
}

/* ── Controls bar ────────────────────────────────────────────────────── */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.8rem;
  background: var(--surface);
  color: var(--text-body);
  border: 1px solid var(--border);
  border-radius: 14px;          /* pill */
  font-family: var(--font);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.toggle-btn:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.toggle-btn--active,
.toggle-btn[aria-pressed="true"] {
  background: rgba(0, 224, 84, 0.12);
  color: var(--green);
  border-color: var(--green-dark);
}

.toggle-btn--active:hover,
.toggle-btn[aria-pressed="true"]:hover {
  border-color: var(--green);
}

/* ── Stat cards ──────────────────────────────────────────────────────── */
.stat-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 2.5rem;
  overflow: hidden;
}

.stat-card {
  flex: 1 1 160px;
  padding: 1.4rem 1.5rem 1.2rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 300;
  line-height: 1;
  color: var(--text);
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
}

/* ── Empty / error states ────────────────────────────────────────────── */
.state-placeholder {
  padding: 2rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-body);
  font-size: 0.85rem;
}

.state-placeholder strong {
  display: block;
  color: var(--text);
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}

.state-error {
  border-left: 3px solid var(--danger);
}

/* ── Unified table ───────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table.unified-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

.unified-table thead th {
  padding: 0.6rem 1rem;
  text-align: left;
  font-size: 0.63rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.unified-table thead th:hover { color: var(--text-body); }

.unified-table thead th.sorted-asc::after  { content: " ↑"; color: var(--green); }
.unified-table thead th.sorted-desc::after { content: " ↓"; color: var(--green); }

.unified-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.unified-table tbody tr:last-child { border-bottom: none; }
.unified-table tbody tr:hover      { background: var(--surface-alt); }

.unified-table td {
  padding: 0.65rem 1rem;
  color: var(--text-body);
  vertical-align: middle;
}

.unified-table td.col-label {
  font-size: 0.88rem;
  color: var(--text);
}

.unified-table td.col-progress {
  min-width: 140px;
}

/* Progress bar — thin green Letterboxd bar */
.unified-bar-wrap {
  height: 6px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.25rem;
}

.unified-bar {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width 0.6s ease;
}

.unified-bar.near-complete {
  background: linear-gradient(90deg, var(--green-dark), var(--green));
  box-shadow: 0 0 6px rgba(0, 224, 84, 0.35);
}

.unified-bar-pct {
  font-size: 0.72rem;
  color: var(--text-dim);
  display: block;
}

.unified-table td.col-watched {
  font-size: 0.82rem;
  color: var(--text-body);
  text-align: right;
  white-space: nowrap;
}

.unified-table td.col-rem {
  font-size: 0.82rem;
  color: var(--text-dim);
  text-align: right;
}

/* Row links */
.row-link {
  color: var(--blue);
  text-decoration: none;
}
.row-link:hover {
  color: var(--green);
  text-decoration: underline;
  text-decoration-color: var(--green-dark);
  text-underline-offset: 3px;
}

/* ── Loading spinner ─────────────────────────────────────────────────── */
.loading-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-dim);
  font-size: 0.8rem;
  padding: 1rem 0;
}

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--surface);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 540px) {
  .stat-value { font-size: 1.7rem; }
  .stat-card  { padding: 1.1rem 1.2rem; }
  .shell      { padding: 0 1rem 3rem; }
  .header     { margin: 0 -1rem 2rem; padding: 0.75rem 1rem; }
}

/* ── Reduced motion ──────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .unified-bar { transition: none; }
  .spinner     { animation: none; }
  .toggle-btn  { transition: none; }
}
