/* ==========================================================================
   MOVIE+ design tokens
   Palette: near-black cinema charcoal, marquee-gold accent, film-reel teal.
   Display type: Oswald (condensed, marquee-poster feel) — body: Inter.
   Motif: the perforated "ticket stub" edge, used sparingly on hero cards.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1e2530;
  --border: #2a323f;
  --text: #f3f1ec;
  --text-muted: #8c93a1;
  --gold: #e8a33d;
  --gold-dim: #7a5a29;
  --teal: #3fa796;
  --red: #e2574c;
  --green: #5cb87a;

  --radius: 10px;
  --radius-lg: 16px;
  --font-display: 'Oswald', 'Arial Narrow', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;

  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg: #f5f4f1;
  --surface: #ffffff;
  --surface-2: #ecebe6;
  --border: #ddd9d0;
  --text: #17181a;
  --text-muted: #6b6f76;
  --gold-dim: #f0d9ad;
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --bg: #f5f4f1;
    --surface: #ffffff;
    --surface-2: #ecebe6;
    --border: #ddd9d0;
    --text: #17181a;
    --text-muted: #6b6f76;
    --gold-dim: #f0d9ad;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
}

a { color: inherit; }
button { font-family: var(--font-body); }

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------------------------------------------------------------------- */
/* Top navigation                                                         */
/* ---------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.03em;
  display: flex;
  align-items: baseline;
  gap: 2px;
}
.brand .plus { color: var(--gold); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.coffee-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.coffee-btn:hover { border-color: var(--gold); }

.account-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
}

/* Primary nav (desktop: inline under topbar; mobile: bottom tab bar) */
.primary-nav {
  display: flex;
  gap: 4px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 10px;
}
.nav-link {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
}
.nav-link.active { color: var(--text); background: var(--surface-2); border-color: var(--border); }

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gold);
  color: #1a1408;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  z-index: 30;
}
.fab .icon { width: 26px; height: 26px; }

/* ---------------------------------------------------------------------- */
/* Icons -- CSS-masked SVGs so color follows the theme automatically.     */
/* To use your own icons: replace the file at the same path in            */
/* public/icons/nav/ (keep it roughly square; a single-color line/glyph   */
/* SVG works best since mask-image ignores color and keeps only shape).   */
/* ---------------------------------------------------------------------- */
.icon {
  display: inline-block;
  width: 22px;
  height: 22px;
  background-color: currentColor;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  flex-shrink: 0;
}
.icon-home { -webkit-mask-image: url('/public/icons/nav/home.svg'); mask-image: url('/public/icons/nav/home.svg'); }
.icon-calendar { -webkit-mask-image: url('/public/icons/nav/calendar.svg'); mask-image: url('/public/icons/nav/calendar.svg'); }
.icon-watchlist { -webkit-mask-image: url('/public/icons/nav/watchlist.svg'); mask-image: url('/public/icons/nav/watchlist.svg'); }
.icon-settings { -webkit-mask-image: url('/public/icons/nav/settings.svg'); mask-image: url('/public/icons/nav/settings.svg'); }
.icon-coffee { -webkit-mask-image: url('/public/icons/nav/coffee.svg'); mask-image: url('/public/icons/nav/coffee.svg'); }
.icon-account { -webkit-mask-image: url('/public/icons/nav/account.svg'); mask-image: url('/public/icons/nav/account.svg'); }
.icon-plus { -webkit-mask-image: url('/public/icons/nav/plus.svg'); mask-image: url('/public/icons/nav/plus.svg'); }

.bottom-tabs .icon { width: 20px; height: 20px; }
.coffee-btn .icon, .account-btn .icon { width: 16px; height: 16px; }

.bottom-tabs {
  display: none;
}

@media (max-width: 480px) {
  #sync-label { display: none; }
  .brand { font-size: 19px; }
  .topbar-inner { gap: 8px; }
  .account-btn span#account-label { display: none; }
}

@media (max-width: 720px) {
  .primary-nav { display: none; }
  .bottom-tabs {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 20;
  }
  .bottom-tabs .nav-link {
    flex: 1;
    text-align: center;
    border-radius: 0;
    font-size: 11px;
    padding: 10px 4px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
  }
  .bottom-tabs .nav-link.active { background: transparent; color: var(--gold); }
  main { padding-bottom: 108px; }
  .fab { bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------------------------------------------------------------------- */
/* Cards + ticket stub motif                                              */
/* ---------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.ticket-stub {
  position: relative;
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  overflow: visible;
}
.ticket-stub::after {
  content: '';
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  background: var(--bg);
  border-radius: 50%;
  border: 1px solid var(--border);
}
.ticket-stub::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  background: var(--bg);
  border-radius: 50%;
  border: 1px solid var(--border);
}

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; margin-top: 16px; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { font-family: var(--font-display); font-size: 28px; }
.stat-value.gold { color: var(--gold); }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------------- */
/* Forms                                                                  */
/* ---------------------------------------------------------------------- */

label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--font-body);
}
input:focus, select:focus, textarea:focus, button:focus-visible, .nav-link:focus-visible, .option-chip:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
.field { margin-bottom: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1a1408; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

.option-chip {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 14px;
}
.option-chip.selected { border-color: var(--gold); color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, var(--surface-2)); }
.chip-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------------------------------------------------------------------- */
/* Movie cards                                                            */
/* ---------------------------------------------------------------------- */

.movie-row {
  display: flex;
  gap: 14px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  align-items: center;
}
.movie-poster {
  width: 48px; height: 72px;
  border-radius: 6px;
  background: var(--surface-2);
  object-fit: cover;
  flex-shrink: 0;
}
.movie-row.planned { opacity: 0.55; }
.movie-title { font-weight: 600; }
.movie-meta { font-size: 13px; color: var(--text-muted); }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
}
.badge.watched { color: var(--green); }
.badge.planned { color: var(--gold); }

.stars { color: var(--gold); letter-spacing: 2px; font-size: 15px; }

/* ---------------------------------------------------------------------- */
/* Calendar                                                               */
/* ---------------------------------------------------------------------- */

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--text-muted); padding-bottom: 4px; }
.cal-cell {
  min-height: 96px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  background: var(--surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cal-cell.outside { opacity: 0.35; }
.cal-cell.today { border-color: var(--gold); }
.cal-date { font-size: 12px; color: var(--text-muted); }
.cal-chip {
  font-size: 10.5px;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--surface-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-chip.planned { opacity: 0.5; }
.cal-more { font-size: 10.5px; color: var(--text-muted); }

@media (max-width: 640px) {
  .cal-grid { grid-template-columns: repeat(7, 1fr); gap: 3px; }
  .cal-cell { min-height: 56px; padding: 4px; }
  .cal-chip { display: none; }
  .cal-cell .cal-dot-row { display: flex; gap: 2px; flex-wrap: wrap; }
  .cal-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
  .cal-dot.planned { background: var(--text-muted); }
}

/* ---------------------------------------------------------------------- */
/* Guided add-movie prompts                                               */
/* ---------------------------------------------------------------------- */

.prompt-screen { max-width: 480px; margin: 0 auto; padding: 32px 4px; }
.prompt-question { font-family: var(--font-display); font-size: 24px; margin-bottom: 18px; }
.prompt-progress { display: flex; gap: 4px; margin-bottom: 24px; }
.prompt-progress span { flex: 1; height: 3px; background: var(--border); border-radius: 2px; }
.prompt-progress span.done { background: var(--gold); }

/* ---------------------------------------------------------------------- */
/* Sheets / modals                                                        */
/* ---------------------------------------------------------------------- */

.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50;
}
@media (min-width: 640px) { .sheet-backdrop { align-items: center; } }
.sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 640px) { .sheet { border-radius: 16px; } }
.sheet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.close-x { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .btn { margin-top: 14px; }

.sync-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.sync-dot.synced { background: var(--green); }
.sync-dot.syncing { background: var(--gold); animation: pulse 1.2s infinite; }
.sync-dot.error { background: var(--red); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

.toast {
  position: fixed;
  bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 60;
}

section.page { padding: 24px 0 48px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
