/* Popotater — tokens, type, app shell (top bar, bottom nav, service dock). */
@font-face { font-family: Cera; src: url(/fonts/Cera-LIGHT.ttf) format('truetype'); font-weight: 300; font-display: swap; }
@font-face { font-family: Cera; src: url(/fonts/Cera-REGULAR.ttf) format('truetype'); font-weight: 400 500; font-display: swap; }
@font-face { font-family: Cera; src: url(/fonts/Cera-BOLD.ttf) format('truetype'); font-weight: 600 800; font-display: swap; }

:root {
  --bg: #07080e;
  --bg-2: #0c0e17;
  --panel: #12141f;
  --panel-2: #1a1d2c;
  --panel-3: #232739;
  --line: rgba(160, 170, 255, .11);
  --line-2: rgba(160, 170, 255, .2);
  --ink: #f5f6fc;
  --ink-2: #c9cde0;
  --muted: #9095ae;
  --faint: #5f6482;
  --cyan: #6fe3ff;
  --blue: #5b7cff;
  --violet: #9b6bff;
  --pink: #ff5fb4;
  --gold: #ffcf5c;
  --good: #4ade80;
  --bad: #ff6b81;
  /* Brand gradient (from the TV logo) */
  --brand: linear-gradient(110deg, #1267a1 0%, #3d55bb 38%, #783cb3 70%, #9c286e 100%);
  --glow: linear-gradient(90deg, #3fd0ff, #5b7cff 35%, #a35bff 68%, #ff4fb8);
  --glass: rgba(24, 27, 42, .72);
  --glass-line: rgba(255, 255, 255, .09);
  --radius: 14px;
  --gutter: 16px;
  --nav-h: 66px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --max: 1240px;
  color-scheme: dark;
}
@media (min-width: 760px) { :root { --gutter: 32px; } }

* { box-sizing: border-box; }
/* clip (not hidden) so iOS can't pan sideways and sticky headers still work */
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; overflow-x: clip; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 400 15px/1.45 Cera, ui-sans-serif, system-ui, -apple-system, sans-serif;
  /* Zai's rule: numbers are always full-height (lining), never old-style. */
  font-variant-numeric: lining-nums; font-feature-settings: "lnum" 1;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; font-variant-numeric: lining-nums; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 6px; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }
p { margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.grad-text { background: var(--glow); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

svg.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i.fill { fill: currentColor; stroke: none; }

/* ---- top bar ---- */
#topbar {
  /* Side padding matches the page content edges, so search / + line up with it on wide screens. */
  position: sticky; top: 0; z-index: 30; height: calc(60px + var(--safe-t));
  padding: var(--safe-t) max(var(--gutter), calc((100vw - var(--max)) / 2 + var(--gutter))) 0;
  /* Logo centred; left/right slots stay equal so it is truly centred. */
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  transition: background .25s, backdrop-filter .25s;
}
#topbar.scrolled { background: rgba(7, 8, 14, .82); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4); box-shadow: 0 1px 0 var(--line); }
body.over-hero #topbar:not(.scrolled) { background: linear-gradient(rgba(0,0,0,.45), transparent); }
body.immersive #topbar { position: fixed; left: 0; right: 0; }
.brand { display: flex; align-items: center; }
.brand img { width: 40px; height: 40px; border-radius: 10px; }
/* Instagram-style: search left, logo centre, + right. */
.top-btn { width: 42px; height: 42px; display: grid; place-items: center; color: var(--ink); border-radius: 50%; transition: background .2s; }
.top-btn:hover { background: rgba(255, 255, 255, .08); }
.top-btn svg.i { width: 26px; height: 26px; stroke-width: 2.1; }
.top-btn.left { justify-self: start; margin-left: -8px; }
.top-btn.right { justify-self: end; margin-right: -8px; }
.top-btn.right svg.i { width: 30px; height: 30px; stroke-width: 2; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--glass); border: 1px solid var(--glass-line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.icon-btn:hover { background: rgba(40, 44, 66, .85); }

/* ---- avatars ---- */
.avatar {
  --a1: #2f8cff; --a2: #7a3fc4;
  width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--a1), var(--a2)); color: #fff; font-weight: 700; font-size: 16px; letter-spacing: .02em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}
.avatar.sm { width: 36px; height: 36px; font-size: 13px; }
.avatar.xs { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 76px; height: 76px; font-size: 28px; }
.avatar.xl { width: 104px; height: 104px; font-size: 38px; }
.avatar[data-c="1"] { --a1: #ff5fb4; --a2: #7a3fc4; }
.avatar[data-c="2"] { --a1: #3fd0ff; --a2: #2a5bd7; }
.avatar[data-c="3"] { --a1: #ffb347; --a2: #e8456b; }
.avatar[data-c="4"] { --a1: #4ade80; --a2: #0e8f8f; }
.avatar[data-c="5"] { --a1: #a35bff; --a2: #3d55bb; }
.avatar[data-c="6"] { --a1: #ff7a59; --a2: #b0247a; }
.avatar[data-c="7"] { --a1: #6fe3ff; --a2: #9b6bff; }

/* ---- view ---- */
#view { min-height: 70vh; padding: 0 0 calc(var(--nav-h) + 40px + var(--safe-b)); outline: none; }
#view.with-dock { padding-bottom: calc(var(--nav-h) + 120px + var(--safe-b)); }
/* 'backwards' so no transform lingers after the fade (it would trap position:fixed children). */
.page { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); animation: page-in .35s ease backwards; }
.page.bleed { padding: 0; max-width: none; }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 10px 0 18px; }
.page-head h1 { font-size: 34px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
@media (min-width: 760px) { .page-head h1 { font-size: 42px; } }

/* ---- bottom nav (floating glass pill + search orb, like Queue) ---- */
#nav {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: calc(14px + var(--safe-b));
  display: flex; justify-content: center; align-items: center; gap: 10px; padding: 0 12px; pointer-events: none;
}
.nav-pill {
  pointer-events: auto; background: rgba(20, 22, 36, .78); border: 1px solid var(--glass-line);
  backdrop-filter: blur(22px) saturate(1.6); -webkit-backdrop-filter: blur(22px) saturate(1.6);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55), 0 0 30px rgba(95, 54, 197, .12);
}
.nav-pill { display: flex; gap: 2px; padding: 5px; border-radius: 32px; height: var(--nav-h); flex: 0 1 auto; min-width: 0; }
.nav-pill a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  width: 72px; flex: 0 1 72px; min-width: 0; border-radius: 27px; color: var(--ink-2); font-size: 12px; font-weight: 500; transition: color .2s, background .25s;
}
.nav-pill a svg.i { width: 23px; height: 23px; }
.nav-pill a:hover { color: #fff; }
.nav-pill a.active { background: var(--brand); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 6px 18px rgba(90, 60, 200, .35); }
.nav-pill a span:not(.avatar) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Profile tab: just the avatar, a little larger than the other icons. */
.nav-pill .me-tab { width: 64px; flex: 0 0 64px; }
.nav-pill .avatar.nav { width: 38px; height: 38px; font-size: 15px; }
.nav-pill a.me-tab.active { background: none; box-shadow: none; }
.nav-pill a.me-tab.active .avatar { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px #fff; }
@media (max-width: 400px) { .nav-pill a { font-size: 11px; } :root { --nav-h: 62px; } }
@media (min-width: 900px) {
  /* Desktop: icon + label side by side, each tab as wide as its label. */
  .nav-pill a { width: auto; flex: 0 0 auto; flex-direction: row; gap: 8px; padding: 0 18px; font-size: 14px; }
  .nav-pill a span:not(.avatar) { overflow: visible; }
  }

/* ---- service dock (Trending only) ---- */
#dock {
  position: fixed; z-index: 39; left: 0; right: 0; bottom: calc(var(--nav-h) + 26px + var(--safe-b));
  display: flex; justify-content: center; pointer-events: none;
  transition: transform .3s ease, opacity .3s;
}
#dock.away { transform: translateY(20px); opacity: 0; }
#dock.away .dock-inner { pointer-events: none; }
.dock-inner { pointer-events: auto; display: flex; gap: 8px; padding: 6px; overflow-x: auto; scrollbar-width: none; max-width: calc(100% - 24px); border-radius: 20px;
  background: rgba(14, 16, 26, .6); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--glass-line); }
.dock-inner::-webkit-scrollbar { display: none; }
.dock-btn { width: 48px; height: 48px; flex: none; border-radius: 13px; overflow: hidden; display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: var(--panel-2); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); transition: transform .15s, box-shadow .2s; }
.dock-btn img { width: 100%; height: 100%; object-fit: cover; }
.dock-btn:hover { transform: translateY(-2px); }
.dock-btn.active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px #fff; }

/* ---- toast ---- */
#toast {
  position: fixed; z-index: 90; left: 50%; bottom: calc(var(--nav-h) + 34px + var(--safe-b)); transform: translate(-50%, 20px);
  background: #eef1ff; color: #14182b; padding: 11px 16px; border-radius: 14px; font-weight: 500; box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  opacity: 0; pointer-events: none; transition: .25s; display: flex; gap: 12px; align-items: center; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { color: #4a3bd1; font-weight: 700; }

/* ---- layer: sheets, overlays ---- */
#layer:empty { display: none; }
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(3, 4, 8, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; z-index: 61; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: #131624; border-radius: 26px 26px 0 0; border: 1px solid var(--line); border-bottom: 0;
  padding: 10px 20px calc(24px + var(--safe-b)); animation: sheet-up .32s cubic-bezier(.2, .9, .3, 1) both;
}
.sheet::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--panel-3); margin: 0 auto 14px; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@media (min-width: 700px) {
  .sheet { left: 50%; bottom: auto; top: 50%; width: 520px; transform: translate(-50%, -50%); border-radius: 26px; border-bottom: 1px solid var(--line); animation: pop .25s ease both; }
  .sheet::before { display: none; }
  @keyframes pop { from { opacity: 0; transform: translate(-50%, -46%) scale(.97); } }
}
.sheet h2 { font-size: 22px; margin-bottom: 4px; }
.sheet .sub { color: var(--muted); margin-bottom: 18px; }
.full {
  position: fixed; z-index: 62; inset: 0; background: var(--bg); overflow-y: auto; overscroll-behavior: contain; animation: fade .2s ease both;
}
