/* ── Design tokens ──────────────────────────────────────────── */
:root {
  --c-dark:    #3b3f45;
  --c-text:    #2d2d2d;
  --c-muted:   #8a8a8a;
  --c-bg:      #f4f4f0;
  --c-surface: #fafaf8;
  --c-border:  #ddd;
  --c-white:   #fff;
  --radius:    8px;
  --shadow:    0 2px 16px rgba(0, 0, 0, 0.08);
  --max-w:     1060px;
  --pad:       2rem 2.5rem;
}

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

[hidden] { display: none !important; }

/* ── Loading overlay ────────────────────────────────────────── */
#loadingOverlay {
  position: fixed;
  inset: 0;
  background: rgba(244, 244, 240, 0.82);
  backdrop-filter: blur(3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 999;
}

#loadingOverlay[hidden] { display: none !important; }

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #ddd;
  border-top-color: var(--c-dark);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.loading-text {
  font-size: 0.9rem;
  color: var(--c-muted);
  font-weight: 500;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Page ───────────────────────────────────────────────────── */
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  gap: 2rem;
}

/* ── Shared card shell ──────────────────────────────────────── */
.container,
.movie-detail,
.results-section,
.subtitle-section {
  width: 100%;
  max-width: var(--max-w);
  background: var(--c-white);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

/* ════════════════════════════════════════════════════════════ */
/*  SEARCH CARD                                                */
/* ════════════════════════════════════════════════════════════ */

.container { overflow: hidden; }

header {
  background: var(--c-dark);
  color: #f0ede8;
  padding: var(--pad);
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

header p {
  margin-top: 0.35rem;
  font-size: 0.875rem;
  color: #b0acaa;
}

.search-form {
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.search-row {
  display: flex;
  gap: 0.6rem;
}

.search-row input { flex: 1; min-width: 0; }

/* ── Fields ───────────────────────────────────────────────── */
.field-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b6b6b;
  display: block;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--c-border);
  border-radius: 6px;
  font-size: 0.95rem;
  color: var(--c-text);
  background: var(--c-surface);
  transition: border-color 0.18s, box-shadow 0.18s;
  appearance: none;
  -webkit-appearance: none;
}

input::placeholder { color: #bbb; }

input:focus,
select:focus {
  outline: none;
  border-color: #7a8a99;
  box-shadow: 0 0 0 3px rgba(122, 138, 153, 0.15);
  background: var(--c-white);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  padding: 0.65rem 1.1rem;
  background: var(--c-dark);
  color: #f0ede8;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 0.18s;
}

.btn:hover  { background: #2d3035; }
.btn:active { background: #22262a; }
.btn:disabled { background: #7a8a99; cursor: default; }

.btn--sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
}

/* ── Messages ─────────────────────────────────────────────── */
.msg-box {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
}

.msg-box--error {
  background: #fef2f2;
  border-left: 4px solid #dc2626;
  color: #991b1b;
}

.msg-box--empty {
  background: var(--c-bg);
  border-left: 4px solid var(--c-border);
  color: var(--c-muted);
}

/* ════════════════════════════════════════════════════════════ */
/*  RESULTS TABLE                                              */
/* ════════════════════════════════════════════════════════════ */

.results-section { overflow: hidden; }

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.4rem 2.5rem 0;
}

.movies-heading {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--c-dark);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.results-count {
  font-size: 0.78rem;
  color: var(--c-muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.ratings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 1rem;
}

.ratings-table thead th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--c-muted);
  padding: 0 0.75rem 0.6rem;
  border-bottom: 1.5px solid var(--c-border);
}

.ratings-table tbody tr {
  border-bottom: 1px solid #f0ede8;
  transition: background 0.12s;
  cursor: pointer;
}

.ratings-table tbody tr:hover  { background: var(--c-bg); }
.ratings-table tbody tr.active { background: #eef1f5; }

.ratings-table tbody td {
  padding: 0.55rem 0.75rem;
  vertical-align: middle;
}

.poster-thumb {
  width: 36px;
  height: 54px;
  object-fit: cover;
  border-radius: 4px;
  background: #e0ddd8;
  display: block;
}

.title-cell {
  font-weight: 600;
  line-height: 1.35;
}

.year-cell, .imdb-cell {
  white-space: nowrap;
  color: var(--c-muted);
  font-size: 0.82rem;
}

.imdb-cell strong { color: var(--c-dark); font-size: 0.88rem; }

.chip-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.chip {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  white-space: nowrap;
}

.chip--genre {
  background: #eef1f5;
  color: #3b3f45;
}

/* ── Pagination ─────────────────────────────────────────────── */
.ratings-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.2rem 2.5rem 1.6rem;
  border-top: 1px solid #f0ede8;
  margin-top: 0.4rem;
}

.pagination-info {
  font-size: 0.82rem;
  color: var(--c-muted);
}

/* ── Phonetic banner ────────────────────────────────────────── */
.phonetic-banner {
  margin: 0.8rem 2.5rem 0;
  padding: 0.45rem 0.9rem;
  background: #fffbea;
  border-left: 3px solid #e8c30b;
  border-radius: 4px;
  font-size: 0.8rem;
  color: #7a6000;
  font-style: italic;
}

/* ── Role chip ──────────────────────────────────────────────── */
.role-chip {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.22rem 0.65rem;
  border-radius: 20px;
  border: 1px solid;
  white-space: nowrap;
  display: inline-block;
  letter-spacing: 0.03em;
}

/* ════════════════════════════════════════════════════════════ */
/*  PERSON DETAIL                                              */
/* ════════════════════════════════════════════════════════════ */

.movie-detail { padding: 0; }

.movie-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--pad);
  padding-bottom: 0;
}

.movie-detail-content {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  padding: var(--pad);
  padding-top: 1.2rem;
}

.section-toggle {
  margin-left: auto;
  background: none;
  border: 1.5px solid var(--c-border);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  color: var(--c-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}

.section-toggle:hover { border-color: var(--c-dark); color: var(--c-dark); }

.detail-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  flex-shrink: 0;
  width: 200px;
}

.detail-poster {
  width: 100%;
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  object-fit: cover;
  object-position: top center;
  display: block;
  aspect-ratio: 3 / 4;
  background: #e0ddd8;
}

.detail-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  font-size: 0.88rem;
}

.detail-title {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.3;
}

.detail-meta {
  display: flex;
  gap: 2.5rem;
}

.detail-col {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.meta-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--c-muted);
}

.detail-plot {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-top: 0.8rem;
  border-top: 1px solid #ebebeb;
}

.bio-text {
  color: #3a3a3a;
  line-height: 1.65;
  font-size: 0.86rem;
}

.bio-expand-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 700;
  color: var(--c-dark);
  font-size: 0.82rem;
  padding: 0 1px;
  vertical-align: baseline;
}

.bio-expand-btn:hover { text-decoration: underline; }

/* ── Deep Face section ──────────────────────────────────────── */
.detail-deepface {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.deepface-divider {
  border: none;
  border-top: 1px solid #ebebeb;
  margin: 0;
}

.deepface-heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--c-muted);
}

.deepface-status {
  font-size: 0.8rem;
  color: var(--c-muted);
  font-style: italic;
}

.deepface-grid {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.deepface-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.88rem;
}

.df-has-tooltip {
  cursor: help;
  text-decoration: underline dotted var(--c-muted);
  text-underline-offset: 3px;
}

/* ════════════════════════════════════════════════════════════ */
/*  RATINGS HISTOGRAM SECTION                                  */
/* ════════════════════════════════════════════════════════════ */

.ratings-grid {
  display: flex;
  gap: 2.5rem;
  flex-wrap: wrap;
  padding-top: 1.2rem;
}

.ratings-card {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.ratings-card-stats {
  display: flex;
  gap: 1.6rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--c-dark);
  line-height: 1.1;
}

.stat-scale {
  font-size: 0.72rem;
  color: var(--c-muted);
}

/* ── Histogram bars (shared with ../rs pattern) ─────────── */
.hist-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.28rem;
}

.hist-label {
  font-size: 0.72rem;
  color: var(--c-muted);
  width: 2.2rem;
  text-align: right;
  flex-shrink: 0;
}

.hist-track {
  flex: 1;
  height: 10px;
  background: #efefec;
  border-radius: 4px;
  overflow: hidden;
}

.hist-bar {
  height: 100%;
  background: var(--c-dark);
  border-radius: 4px;
  transition: width 0.35s ease;
  min-width: 2px;
}

.hist-count {
  font-size: 0.68rem;
  color: var(--c-muted);
  width: 2.2rem;
  flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════════ */
/*  FILMOGRAPHY SECTION                                        */
/* ════════════════════════════════════════════════════════════ */

.subtitle-section { padding: 0; }

.subtitle-content {
  padding: 0 2.5rem 1.8rem;
  overflow-x: auto;
}

.tab-loading {
  padding: 1.5rem 0;
  color: var(--c-muted);
  font-size: 0.85rem;
}
