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

/* ─── Tokens ─────────────────────────────────────────────── */
:root {
  --bg:          #0d1117;
  --bg-card:     #161b22;
  --bg-hover:    #1c2128;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --accent:      #3fb950;
  --border:      #30363d;
  --radius:      4px;
  --font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ─── Nav ────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13,17,23,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.nav {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 54px;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav-logo {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--text);
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  margin-left: auto;
}

.nav-links a {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.15s;
}

.nav-links a:hover,
.nav-links a.active { color: var(--text); }

/* ─── Main container ─────────────────────────────────────── */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* ─── Page header ────────────────────────────────────────── */
.page-header {
  margin-bottom: 2rem;
}

.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.stats-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.as-of-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.as-of-select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.82rem;
  font-family: var(--font);
  padding: 4px 8px;
  outline: none;
  cursor: pointer;
}

.as-of-select:focus {
  border-color: var(--text-muted);
}

/* ─── Origin block ───────────────────────────────────────── */
.origin {
  margin-bottom: 2.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 680px;
}

.origin p {
  margin-bottom: 0.5rem;
}

.origin blockquote {
  border-left: 3px solid var(--border);
  margin: 0.75rem 0 0;
  padding: 0.5rem 0 0.5rem 1rem;
  font-style: italic;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* ─── List filters (search + decades + tags) ─────────────── */
.list-filters {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.film-search {
  width: 100%;
  max-width: 400px;
  padding: 7px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}

.film-search:focus {
  border-color: var(--text-muted);
}

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

.decade-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* ─── Tag filter bar ─────────────────────────────────────── */
.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}

.tag-filter-btn {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tag-filter-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.tag-filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

.tag-clickable {
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tag-clickable:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

/* ─── Film grid (list view) ──────────────────────────────── */
.film-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 1.75rem 1rem;
}

.film-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Poster */
.film-poster {
  position: relative;
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  aspect-ratio: 2 / 3;
}

.film-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s;
}

.film-poster:hover img { opacity: 0.82; }

.film-poster-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-card);
}

.film-position {
  position: absolute;
  top: 5px;
  left: 5px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  line-height: 1.4;
}

/* Info below poster */
.film-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.film-title {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  transition: color 0.15s;
}

.film-title:hover { color: var(--accent); }

.film-year {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.film-watched {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 500;
}

/* Tags */
.film-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 2px;
}

.tag {
  font-size: 0.62rem;
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* ─── Film detail page ───────────────────────────────────── */
.back-link {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  transition: color 0.15s;
}

.back-link:hover { color: var(--text); }

.film-detail {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2.5rem;
  margin-bottom: 3rem;
  align-items: start;
}

.film-detail-poster img {
  width: 100%;
  border-radius: var(--radius);
  display: block;
}

.film-detail-poster-placeholder {
  width: 100%;
  aspect-ratio: 2 / 3;
  background: var(--bg-card);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 1rem;
  text-align: center;
}

.film-detail-title {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.film-detail-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.film-detail-tagline {
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.film-detail-position {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
  margin: 0.5rem 0;
}

.film-detail-info {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.watch-history {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.watch-history-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.watch-entry {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.watch-entry:last-child { border-bottom: none; }

.watch-entry-date {
  font-size: 0.85rem;
  font-weight: 600;
}

.watch-entry-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

@media (max-width: 600px) {
  .film-detail {
    grid-template-columns: 130px 1fr;
    gap: 1.25rem;
  }
  .film-detail-title { font-size: 1.25rem; }
}

/* ─── Diary ──────────────────────────────────────────────── */
.diary-year {
  margin-bottom: 2.5rem;
}

.diary-year-header {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-muted);
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.diary-month {
  margin-bottom: 2rem;
}

.diary-month-header {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.diary-entry {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 0.9rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  align-items: start;
}

.diary-entry:last-child { border-bottom: none; }

.diary-poster {
  display: block;
  width: 52px;
  flex-shrink: 0;
  border-radius: 3px;
  overflow: hidden;
  background: var(--bg-card);
  aspect-ratio: 2 / 3;
}

.diary-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.diary-poster-placeholder {
  width: 100%;
  height: 100%;
  background: var(--bg-hover);
}

.diary-details {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-top: 2px;
}

.diary-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  transition: color 0.15s;
}

.diary-title:hover { color: var(--accent); }

.diary-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.diary-rating {
  color: var(--accent);
  font-weight: 600;
}

.rewatch-badge {
  font-size: 0.65rem;
  padding: 1px 5px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
}

.diary-review {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-style: italic;
  line-height: 1.4;
}

/* ─── Members ────────────────────────────────────────────── */
.members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.member-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: border-color 0.15s;
}

.member-card:hover {
  border-color: var(--text-muted);
}

.member-name {
  font-size: 0.95rem;
  font-weight: 600;
}

.member-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.section-subhead {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ─── Stats ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.1rem 1.25rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.3rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1rem;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}

.chart-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.chart-wrap {
  position: relative;
}

/* ─── Footer ─────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  border-top: 1px solid var(--border);
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 680px) {
  .film-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 400px) {
  .film-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
