/* ============================================================
   Comiat · Homeflix — cinematic farewell board
   ============================================================ */

:root {
  --bg: #12100b;
  --bg-soft: #1a1711;
  --bg-card: #1e1a13;
  --ink: #f0e9db;
  --ink-dim: #b7ac97;
  --ink-faint: #7d735f;
  --amber: #e8b45a;
  --amber-hot: #f2c87c;
  --danger: #e0704f;
  --line: rgba(240, 233, 219, 0.09);
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Archivo", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --radius: 12px;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.75);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scrollbar-color: var(--ink-faint) transparent; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- atmosphere ---------- */

.grain {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0.055;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 0.9s steps(4) infinite;
}

@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 1%); }
  50% { transform: translate(1%, -2%); }
  75% { transform: translate(-1%, -1%); }
  100% { transform: translate(0, 0); }
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 59;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 10%, transparent 55%, rgba(6, 5, 3, 0.55) 100%);
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  padding: 88px clamp(20px, 5vw, 64px) 40px;
  text-align: center;
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--amber);
  opacity: 0;
  animation: rise 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.15s forwards;
}

.title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(64px, 13vw, 150px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin-top: 12px;
  background: linear-gradient(180deg, var(--ink) 30%, var(--ink-dim) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  opacity: 0;
  animation: rise 1s cubic-bezier(0.22, 1, 0.36, 1) 0.28s forwards;
}

.sub {
  margin-top: 18px;
  font-size: clamp(15px, 2vw, 18px);
  color: var(--ink-dim);
  font-weight: 400;
  opacity: 0;
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.45s forwards;
}

.summary {
  margin-top: 22px;
  min-height: 28px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 19px;
  color: var(--amber-hot);
  opacity: 0;
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.6s forwards;
}

.hero-foot {
  margin-top: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  opacity: 0;
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.72s forwards;
}

.updated {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.refresh {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: 600 12px/1 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 15px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.refresh:hover { color: var(--amber-hot); border-color: rgba(232, 180, 90, 0.45); background: rgba(232, 180, 90, 0.06); }
.refresh.spinning svg { animation: spin 0.8s linear infinite; }

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

/* ---------- user chip (top right, plex mode) ---------- */

.user {
  position: fixed;
  top: 18px;
  right: clamp(16px, 3vw, 32px);
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 7px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(18, 16, 11, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 12px 30px -14px rgba(0, 0, 0, 0.8);
  animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.user-avatar-wrap {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 120% at 50% 0%, #2a2417, #1b1710);
}

.user-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.user-avatar-letter {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--amber);
}

.user-name {
  font: 600 13px/1 var(--sans);
  letter-spacing: 0.04em;
  color: var(--ink);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user .logout { margin-left: 2px; }

/* ---------- app / day sections ---------- */

.app {
  padding: 12px clamp(0px, 2vw, 24px) 90px;
}

.day {
  margin-top: 56px;
  opacity: 0;
  animation: rise 0.8s cubic-bezier(0.22, 1, 0.36, 1) var(--delay, 0s) forwards;
}

.day-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 0 clamp(20px, 5vw, 64px);
  flex-wrap: wrap;
}

.day-label {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(24px, 3.2vw, 34px);
  letter-spacing: -0.01em;
}

.day-label::first-letter { color: var(--amber); }

.day-date {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.day-count {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
}

.day-rule {
  flex: 1 1 100%;
  height: 1px;
  margin-top: 14px;
  background: linear-gradient(90deg, var(--line), transparent);
}

/* ---------- tracks (poster rows) ---------- */

.tracks {
  margin-top: 22px;
  display: flex;
  gap: 22px;
  overflow-x: auto;
  padding: 6px clamp(20px, 5vw, 64px) 26px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 180, 90, 0.35) transparent;
}
.tracks::-webkit-scrollbar { height: 6px; }
.tracks::-webkit-scrollbar-track { background: transparent; }
.tracks::-webkit-scrollbar-thumb { background: rgba(232, 180, 90, 0.3); border-radius: 3px; }

.card {
  flex: 0 0 auto;
  width: clamp(150px, 17vw, 196px);
  text-decoration: none;
  color: inherit;
  scroll-snap-align: start;
  border-radius: var(--radius);
  outline-offset: 4px;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 0%, #262117 0%, #1b1710 55%, #141109 100%);
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s ease;
}

.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1.001);
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), filter 0.4s ease;
}

.card:hover .poster img { transform: scale(1.06); filter: brightness(0.78); }
.card:hover .poster { box-shadow: 0 26px 55px -16px rgba(0, 0, 0, 0.85); }
.card:hover { transform: translateY(-6px); }
.card:focus-visible { outline: 2px solid var(--amber); }

.poster-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 46px;
  font-weight: 600;
  color: var(--amber);
  opacity: 0.85;
}

.card-hint {
  position: absolute;
  inset: auto 0 0 0;
  padding: 26px 12px 12px;
  background: linear-gradient(transparent, rgba(10, 8, 5, 0.92));
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;
  color: var(--amber-hot);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
.card:hover .card-hint, .card:focus-visible .card-hint { opacity: 1; transform: translateY(0); }

.card-title {
  margin-top: 12px;
  font-family: var(--serif);
  font-size: 16.5px;
  font-weight: 500;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  margin-top: 3px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
}

/* ---------- states ---------- */

.state {
  padding: 90px clamp(20px, 5vw, 64px);
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 24px;
  color: var(--ink-dim);
}

.skeleton-row { margin: 56px clamp(20px, 5vw, 64px) 0; opacity: 0.55; }
.skeleton-bar {
  width: 200px; height: 22px; border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-soft), var(--bg-card), var(--bg-soft));
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}
.skeleton-track {
  margin-top: 22px; height: 250px; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bg-soft), var(--bg-card), var(--bg-soft));
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}
.skeleton-row + .skeleton-row { margin-top: 46px; }

@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- footer ---------- */

.foot {
  padding: 40px clamp(20px, 5vw, 64px) 46px;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  border-top: 1px solid var(--line);
}
.heart { color: var(--danger); }

/* ---------- motion ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .card, .card img { transition: none; }
  .hero, .title, .sub, .summary, .hero-foot, .day { animation-duration: 0.01s; }
}

/* ---------- login ---------- */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(90% 80% at 50% 20%, rgba(30, 26, 19, 0.55), rgba(10, 8, 5, 0.88));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.login-card {
  text-align: center;
  max-width: 420px;
  padding: 44px 36px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(30, 26, 19, 0.92), rgba(22, 19, 13, 0.92));
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.9);
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.login-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(42px, 9vw, 64px);
  line-height: 1;
  margin: 12px 0 8px;
}

.login-sub {
  color: var(--ink-dim);
  font-size: 14.5px;
  line-height: 1.6;
}

.plex-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 26px;
  background: var(--amber);
  color: #17130b;
  font: 600 13px/1 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 0;
  border-radius: 999px;
  padding: 14px 26px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.2s ease;
}
.plex-btn:hover { background: var(--amber-hot); transform: translateY(-2px); }
.plex-btn svg { width: 18px; height: 18px; }

.app.blurred .skeleton,
.app.blurred .day { filter: blur(2px); }

.logout { margin-left: 2px; }
.hidden { display: none !important; }

/* ---------- login: popup flow ---------- */

.login-status {
  margin-top: 16px;
  min-height: 20px;
  font-size: 13.5px;
  color: var(--ink-faint);
  line-height: 1.5;
}
.login-status.err { color: var(--danger); }

.spinner {
  width: 28px;
  height: 28px;
  margin: 24px auto 4px;
  border-radius: 50%;
  border: 3px solid rgba(232, 180, 90, 0.25);
  border-top-color: var(--amber);
  animation: spin 0.8s linear infinite;
}

.login-card .plex-btn:disabled { opacity: 0.65; cursor: default; transform: none; }

.login-link {
  color: var(--amber-hot);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.login-link:hover { color: var(--amber); }
