/* Movie Vault - the same black, dark red and gold as the old app, with
   bigger, easier-to-read text (Atkinson Hyperlegible, made for people
   with low vision). Dark only, like before. */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/static/fonts/atkinson-hyperlegible-next-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg: #160202;          /* very dark red, as before */
  --card: #0b0b0b;
  --raised: #161616;
  --border: #2c2c2c;
  --text: #fafafa;
  --muted: #c4c4c4;
  --gold: #d2ab37;
  --gold-ink: #1c1505;    /* text on gold */
  --red: #d21212;         /* family stars */
  --tmdb: #b8962f;        /* TMDb stars: the gold, a little quieter */
  --empty-star: #555;
  --danger: #ef5350;
  --radius: 12px;
  --header: 68px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Atkinson Hyperlegible Next", Verdana, system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
img { display: block; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ------------------------------------------------------------ header */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  padding-top: env(safe-area-inset-top);
  height: calc(var(--header) + env(safe-area-inset-top));
  background: rgba(22, 2, 2, 0.96);
  border-bottom: 1px solid #2a0c0c;
}

.logo {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--gold);
  cursor: pointer;
}
.logo svg { width: 34px; height: 34px; }

.search {
  flex: 1;
  min-width: 0;
  position: relative;
}
.search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 48px;
  padding: 0 12px 0 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
}
.search input::placeholder { color: #9a9a9a; }

.back-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 48px;
  padding: 0 14px 0 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-weight: 700;
  cursor: pointer;
  max-width: 220px;
}
.back-btn svg { width: 24px; height: 24px; flex: none; }
.spacer { flex: 1; }

.add-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 54px;
  height: 48px;
  border: 0;
  border-radius: 10px;
  background: var(--gold);
  color: var(--gold-ink);
  cursor: pointer;
}
.add-btn svg { width: 28px; height: 28px; }

.me-btn {
  flex: none;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  font-weight: 700;
  font-size: 20px;
  cursor: pointer;
}

.menu {
  position: fixed;
  z-index: 30;
  top: calc(var(--header) + env(safe-area-inset-top) - 4px);
  right: 10px;
  width: min(300px, calc(100vw - 20px));
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--raised);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
}
.menu .who { margin: 0 0 4px; font-weight: 700; font-size: 20px; }
.menu .sub { margin: 0 0 14px; color: var(--muted); font-size: 16px; }

.offline-note {
  margin: 0;
  padding: 8px 14px;
  background: #3b2a05;
  color: #ffe7a3;
  font-size: 16px;
  text-align: center;
}

/* ------------------------------------------------------------ page */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 12px calc(40px + env(safe-area-inset-bottom));
}

h1 { margin: 6px 0 14px; font-size: 30px; line-height: 1.2; }
h2 { margin: 30px 0 12px; font-size: 23px; line-height: 1.25; }

.muted { color: var(--muted); }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.count { color: var(--muted); font-size: 16px; }

.select-wrap { position: relative; display: inline-block; }
.select-wrap select {
  appearance: none;
  height: 48px;
  padding: 0 44px 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
}
.select-wrap svg {
  position: absolute;
  right: 12px;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--muted);
}

/* ------------------------------------------------------------ the grid of posters */

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

.card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #1d1d1d;
  border-radius: var(--radius);
  background: var(--card);
  text-decoration: none;
}
.card:active { border-color: var(--gold); }
@media (hover: hover) { .card:hover { border-color: rgba(210, 171, 55, 0.6); } }

.poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: var(--raised);
}
.no-poster {
  display: grid;
  place-items: center;
  color: #444;
}
.no-poster svg { width: 40%; height: auto; }

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 6px 10px 7px;
}
.card-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.card-title .year { font-weight: 400; color: var(--muted); }

/* The two score rows on a poster share one grid: stars, number, label.
   Both rows of stars are the same width, so they line up, and they take
   whatever space the (small) numbers leave. */
.scores {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: 3px;
  row-gap: 5px;
}
.scores .score-row { display: contents; }
.scores .stars { display: block; width: 100%; }
.scores .num { justify-self: end; font-weight: 700; font-size: 13px; line-height: 1; }
.scores .label { justify-self: start; color: var(--muted); font-size: 11.5px; line-height: 1; }
.scores .score-row.none { display: block; grid-column: 1 / -1; color: var(--muted); font-size: 14px; }

.stars svg { display: block; width: 100%; height: auto; }
.stars .empty { fill: var(--empty-star); }
.stars.family .full { fill: var(--red); }
.stars.tmdb .full { fill: var(--tmdb); }

.empty-state {
  margin: 30px auto;
  max-width: 460px;
  padding: 30px 20px;
  border: 2px dashed #3a3a3a;
  border-radius: var(--radius);
  text-align: center;
}

/* ------------------------------------------------------------ a movie's page */

.movie-top {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.movie-top .poster-box { flex: 0 0 38%; max-width: 230px; }
.movie-top .poster { border-radius: 10px; }
.movie-top h1 { margin: 0 0 4px; font-size: 26px; overflow-wrap: anywhere; }
.movie-top .year { margin: 0 0 8px; font-size: 20px; color: var(--muted); }
.movie-top .added { margin: 0; font-size: 15px; color: var(--muted); }

.big-score { margin-top: 18px; }
.big-score .what { margin: 0 0 2px; font-size: 16px; color: var(--muted); }
.big-score .line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.big-score .stars { width: min(100%, 290px); }
.big-score .num { font-size: 22px; font-weight: 700; }
.big-score .of { font-size: 16px; color: var(--muted); }

.overview { margin: 20px 0 0; font-size: 18px; }

/* Ratings chart: one column per score from 1 to 10. */
.chart-box {
  padding: 14px 12px 10px;
  border: 1px solid #1d1d1d;
  border-radius: var(--radius);
  background: var(--card);
}
.chart-box svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-box .bar { fill: var(--red); }
.chart-box .hit { fill: transparent; cursor: pointer; }
.chart-box .hit:hover + .bar, .chart-box .picked .bar { fill: #ff3b3b; }
.chart-box .axis { stroke: #3a3a3a; stroke-width: 1; }
.chart-box .tick { fill: var(--muted); font-size: 13px; text-anchor: middle; }
.chart-box .value { fill: var(--text); font-size: 13px; font-weight: 700; text-anchor: middle; }
.chart-note { margin: 8px 2px 0; min-height: 1.45em; font-size: 16px; color: var(--muted); }

.reviews { display: grid; gap: 12px; }
.review {
  padding: 14px;
  border: 1px solid #1d1d1d;
  border-radius: var(--radius);
  background: var(--card);
}
.review.mine { border-color: rgba(210, 171, 55, 0.45); }
.review-head { display: flex; align-items: center; gap: 12px; }
.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #111;
  font-weight: 700;
  font-size: 17px;
}
.review-head .name { margin: 0; font-weight: 700; font-size: 19px; }
.review-head .when { margin: 0; font-size: 15px; color: var(--muted); }
.review .score-line { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.review .score-line .stars { width: min(70%, 220px); }
.review .score-line .num { font-weight: 700; }
.review .text { margin: 10px 0 0; overflow-wrap: anywhere; white-space: pre-line; }
.review .actions { display: flex; gap: 10px; margin-top: 12px; }

/* ------------------------------------------------------------ buttons and forms */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--raised);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn svg { width: 22px; height: 22px; }
.btn.primary { border-color: var(--gold); background: var(--gold); color: var(--gold-ink); }
.btn.danger { border-color: #7a1f1f; background: #2a0909; color: #ffb4b4; }
.btn.small { min-height: 44px; padding: 0 14px; font-size: 16px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: default; }

.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.button-row .btn { flex: 1 1 140px; }

.manage { margin-top: 34px; padding-top: 18px; border-top: 1px solid #2a2a2a; }
.manage .button-row .btn { flex: 1 1 100%; }

.panel {
  max-width: 560px;
  margin: 0 auto;
}

.field { margin: 0 0 16px; }
.field label, .field .label { display: block; margin: 0 0 6px; font-weight: 700; }
.field .hint { margin: -2px 0 8px; font-size: 16px; color: var(--muted); }
.field input, .field textarea {
  width: 100%;
  min-height: 50px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
}
.field textarea { min-height: 130px; resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; margin: -4px 0 16px; cursor: pointer; }
.check input { width: 24px; height: 24px; accent-color: var(--gold); }

.form-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #3a0b0b;
  color: #ffd2d2;
}

/* Star picker: ten big buttons. */
.picker { display: flex; gap: 2px; max-width: 420px; }
.picker button {
  flex: 1 1 0;
  min-width: 0;
  aspect-ratio: 1;
  max-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--empty-star);
}
.picker button.on { color: var(--red); }
.picker svg { width: 100%; height: 100%; fill: currentColor; }
.picked-value { margin: 8px 0 0; font-size: 20px; font-weight: 700; }
.picked-value .muted { font-weight: 400; font-size: 16px; }

.film-pick { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.film-pick .poster { width: 84px; border-radius: 8px; flex: none; }
.film-pick h1 { margin: 0; font-size: 24px; }
.film-pick p { margin: 4px 0 0; color: var(--muted); }

/* Search results when adding a movie. */
.search-form { display: flex; gap: 8px; margin-bottom: 16px; }
.search-form input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
}
.results { display: grid; gap: 8px; }
.result {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px;
  border: 1px solid #1d1d1d;
  border-radius: var(--radius);
  background: var(--card);
  text-align: left;
  cursor: pointer;
}
.result .poster { width: 60px; border-radius: 6px; flex: none; }
.result .info { flex: 1; min-width: 0; }
.result .t { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.result .y { margin: 2px 0 0; color: var(--muted); font-size: 16px; }
.result .note { margin: 4px 0 0; color: var(--gold); font-size: 15px; }
.result > svg { flex: none; width: 26px; height: 26px; color: var(--gold); }

.credit { margin: 26px 0 0; font-size: 14px; color: #8a8a8a; text-align: center; }

/* ------------------------------------------------------------ sign-in, loading */

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.sign-in {
  width: 100%;
  max-width: 420px;
  padding: 26px 22px;
  border: 2px solid rgba(210, 171, 55, 0.25);
  border-radius: 16px;
  background: var(--card);
}
.sign-in .mark { width: 72px; height: 72px; margin: 0 auto 10px; border-radius: 16px; }
.sign-in h1 { text-align: center; color: var(--gold); margin-bottom: 4px; }
.sign-in .intro { margin: 0 0 22px; text-align: center; color: var(--muted); }

.loading { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
.loading img { width: 76px; height: 76px; border-radius: 16px; }

/* ------------------------------------------------------------ messages */

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 24px);
  padding: 12px 18px;
  border-radius: 12px;
  background: #f4f0e2;
  color: #141414;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--raised);
  color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
dialog h2 { margin: 0 0 10px; }
dialog p { margin: 0; color: var(--muted); }
