/* ============================================================
   base.css — reset + primitives shared by every page.
   Reads tokens.css. Never hardcodes a value.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-body);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3,h4 { color: var(--ink); font-weight: var(--weight-semi); margin: 0; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---- layout helpers ------------------------------------ */
.page      { max-width: var(--page-max); margin: 0 auto; padding: 0 var(--s6); }
.stack     { display: flex; flex-direction: column; }
.row       { display: flex; align-items: center; }
.spread    { display: flex; align-items: center; justify-content: space-between; }
.grow      { flex: 1; }
.wrap      { flex-wrap: wrap; }

/* ---- app shell (persistent, never re-renders) ---------- */
.shell {
  position: sticky; top: 0; z-index: 50;
  height: var(--shell-h);
  background: var(--scrim);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.shell-inner {
  max-width: var(--page-max); margin: 0 auto; height: 100%;
  padding: 0 var(--s6);
  display: flex; align-items: center; gap: var(--s6);
}
.brand {
  font-size: var(--text-base); font-weight: var(--weight-semi);
  color: var(--ink); letter-spacing: -.02em;
}

/* ---- buttons ------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s2);
  height: 36px; padding: 0 var(--s4);
  border-radius: var(--r-full);
  border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.btn:hover { background: var(--surface-hover); border-color: var(--ink-faint); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-muted); }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--ink); }
.btn-sm { height: 30px; padding: 0 var(--s3); font-size: var(--text-xs); }

/* ---- filter tabs (Wavedash-style) ---------------------- */
.tabs { display: flex; gap: var(--s2); flex-wrap: wrap; }
.tab {
  height: 32px; padding: 0 var(--s4);
  border-radius: var(--r-full);
  border: 1px solid transparent;
  background: transparent; color: var(--ink-muted);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  display: inline-flex; align-items: center;
  transition: all var(--fast) var(--ease);
}
.tab:hover { background: var(--bg-sunken); color: var(--ink); }
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }

/* ---- tag ----------------------------------------------- */
.tag {
  font-size: var(--text-xs); color: var(--ink-muted);
  font-weight: var(--weight-medium);
}
.tag-dot::after { content: "·"; margin: 0 var(--s2); color: var(--ink-faint); }
.tag-pill {
  padding: 2px var(--s2); border-radius: var(--r-sm);
  background: var(--bg-sunken); color: var(--ink-muted);
  font-size: var(--text-xs); font-weight: var(--weight-medium);
}

/* ---- live indicator ------------------------------------ */
.live { display: inline-flex; align-items: center; gap: var(--s1); color: var(--live); font-size: var(--text-xs); font-weight: var(--weight-medium); }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--live); }

/* ---- search -------------------------------------------- */
.search {
  display: flex; align-items: center; gap: var(--s2);
  height: 34px; padding: 0 var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-full);
  background: var(--bg-sunken); color: var(--ink-muted);
  font-size: var(--text-sm); min-width: 220px;
}
.search input { border: 0; background: transparent; outline: none; flex: 1; font: inherit; color: var(--ink); }
.kbd {
  font-family: var(--font-mono); font-size: 10px;
  padding: 2px 5px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-faint);
}

/* ---- section header ------------------------------------ */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--s5); }
.section-title { font-size: var(--text-lg); }
.section-meta { font-size: var(--text-sm); color: var(--ink-faint); }

/* ---- <theme-toggle> ------------------------------------ */
theme-toggle { display: inline-flex; }
/* shell toggle only — the on-art variant sizes itself */
theme-toggle:not(.on-art-host) .theme-btn {
  width: 32px; padding: 0; font-size: 15px; line-height: 1;
}

/* ---- signed-in account chip (no guest access) ---------- */
.account { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer;
           padding: var(--s1) var(--s2) var(--s1) var(--s1); border-radius: var(--r-full);
           transition: background var(--fast) var(--ease); }
.account:hover { background: var(--bg-sunken); }
.account-av { width: 26px; height: 26px; border-radius: 50%; background: var(--bg-sunken);
              border: 1px solid var(--line); display: grid; place-items: center;
              font-size: 10px; font-weight: var(--weight-semi); color: var(--ink-muted); }
.account-h { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--ink); }
@media (max-width: 720px) { .account-h { display: none; } }

/* ---- <ai-logo> ----------------------------------------- */
.logo { display: inline-flex; align-items: center; gap: var(--s2); color: var(--ink); }
.logo-mark { display: grid; place-items: center; color: var(--ink); }
.logo-mark svg { width: 1.15em; height: 1.15em; display: block; }
.logo-word {
  font-weight: var(--weight-medium);
  letter-spacing: -.03em;
  white-space: nowrap;
}
.logo-word b { font-weight: var(--weight-semi); }

/* the wordmark sizes with the logo, mark follows via em */
.logo-sm { font-size: var(--text-sm); }
.logo-md { font-size: var(--text-lg); }
.logo-lg { font-size: var(--text-2xl); }

a:hover > .logo, .brand:hover .logo { opacity: .75; }
.brand { display: inline-flex; }

/* ============================================================
   GLASS — the treatment for anything sitting over artwork.

   One ground for every on-art control: back button, theme
   toggle, action pills, rail buttons, nameplates. A tinted
   token alone is not enough — over a bright ceiling it
   vanishes, over dark wood it muddies. Deliberately NOT
   theme-token driven: the ground here is the photograph, not
   the page, so it stays constant in light and dark.
   ============================================================ */
.glass,
.on-art {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s3);
  height: 44px; padding: 0 var(--s4);
  border-radius: var(--r-full);
  background: rgba(0, 0, 0, 0.57);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: #fff;
  transition: background var(--fast) var(--ease), transform var(--fast) var(--ease);
  user-select: none;
}
.glass:hover, .on-art:hover { background: rgba(0, 0, 0, 0.72); color: #fff; }
.glass:active, .on-art:active { transform: scale(.97); }
.glass svg, .on-art svg { display: block; flex: none; }

/* icon-only: a circle, not a pill */
.glass-icon, .on-art-icon { width: 44px; height: 44px; padding: 0; gap: 0; }

/* the theme toggle over art — same glass, and specific enough
   to beat .btn-ghost's transparency */
theme-toggle.on-art-host .theme-btn,
theme-toggle.on-art-host button {
  width: 44px; height: 44px; padding: 0;
  border-radius: var(--r-full);
  background: rgba(0, 0, 0, 0.57);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow-md);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--fast) var(--ease);
}
theme-toggle.on-art-host button:hover { background: rgba(0, 0, 0, 0.72); }
theme-toggle.on-art-host svg { display: block; }

/* ---- .badge — a labelled state chip over artwork ------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 var(--s3) 0 var(--s2);
  border-radius: var(--r-full);
  background: rgba(0, 0, 0, 0.57);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.94);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: .01em;
  user-select: none;
  white-space: nowrap;
}
.badge svg { display: block; flex: none; opacity: .85; }

/* ---- <ambience-toggle> --------------------------------
   The room's music. Deliberately NOT a music player: no transport,
   no track list, no "now playing" bar. A game does not show you one
   — the place sounds like itself, and the only control anyone wants
   is quieter or off.

   So the footprint matches <theme-toggle> exactly (44px on art, 32px
   in a shell), and the volume slider is revealed on hover/focus
   rather than sitting in the chrome, because volume is set once and
   then forgotten. The track credit rides along in the popover, which
   is where crediting the artist belongs.
   -------------------------------------------------------- */
ambience-toggle { display: inline-flex; }
.amb-wrap { position: relative; display: inline-flex; }

.amb-btn {
  width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: var(--r-full);
  background: transparent; color: inherit;
  cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center;
  transition: background var(--fast) var(--ease),
              opacity var(--fast) var(--ease);
}
.amb-btn:hover { background: var(--bg-sunken); }
ambience-toggle[data-off] .amb-btn { opacity: .55; }

/* Over photography: the same glass as the theme toggle.

   NOTE the class name. This used to be `.amb-wrap.on-art`, but
   base.css already defines a generic `.on-art` — a 44px-tall glass
   PILL with horizontal padding. The wrapper therefore picked up a
   second glass background behind the button's own, plus the pill's
   side padding, rendering as three overlapping circles 78px wide.
   The wrapper is a positioning context only and must stay unstyled. */
.amb-wrap.amb-on-art .amb-btn {
  width: 44px; height: 44px;
  background: rgba(0, 0, 0, 0.57);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow-md);
  color: #fff;
}
.amb-wrap.amb-on-art .amb-btn:hover { background: rgba(0, 0, 0, 0.72); }
.amb-btn svg { display: block; }

/* the popover: volume + credit, on hover or keyboard focus */
.amb-pop {
  position: absolute; top: calc(100% + var(--s2)); right: 0;
  z-index: 60;
  display: flex; flex-direction: column; gap: var(--s2);
  padding: var(--s3);
  min-width: 168px;
  border-radius: var(--r-lg);
  background: rgba(18, 18, 22, 0.9);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  opacity: 0; pointer-events: none;
  transform: translateY(-4px);
  transition: opacity var(--fast) var(--ease),
              transform var(--fast) var(--ease);
}
.amb-wrap:hover .amb-pop,
.amb-wrap:focus-within .amb-pop {
  opacity: 1; pointer-events: auto; transform: none;
}

.amb-range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; margin: var(--s2) 0;
  border-radius: 2px; outline: none;
  background: rgba(255, 255, 255, 0.22);
}
.amb-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: #fff; cursor: pointer; border: 0;
}
.amb-range::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: #fff; cursor: pointer; border: 0;
}
.amb-credit {
  font-size: 10px; line-height: 1.4;
  color: rgba(255, 255, 255, 0.55);
}
