/* ==========================================================================
   PaxBus+ — Fluid scaling (DPI / zoom resilient)
   Windows 150–175% shrinks CSS viewport (1920@175% ≈ 1097px) while ui-core
   still uses many px units — those feel gigantic. density.js sets --ui-zoom
   so the whole .pb-app shell compresses to mockup density.
   ========================================================================== */

:root {
  --ui-zoom: 1;
  --fluid-scale: 1;

  /* Typography — mockup-tight ceilings */
  --fluid-text-xs: clamp(0.68rem, 0.66rem + 0.1vw, 0.75rem);
  --fluid-text-sm: clamp(0.8rem, 0.78rem + 0.12vw, 0.9rem);
  --fluid-text-base: clamp(0.9rem, 0.88rem + 0.12vw, 1rem);
  --fluid-text-md: clamp(0.92rem, 0.9rem + 0.15vw, 1.05rem);
  --fluid-text-lg: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  --fluid-h4: clamp(1rem, 0.96rem + 0.25vw, 1.2rem);
  --fluid-h3: clamp(1.15rem, 1.05rem + 0.45vw, 1.45rem);
  --fluid-h2: clamp(1.25rem, 1.15rem + 0.55vw, 1.65rem);
  --fluid-h1: clamp(1.85rem, 1.65rem + 0.9vw, 2.55rem);
  --fluid-display: clamp(1.9rem, 1.7rem + 1vw, 2.75rem);
  --fluid-page-title: clamp(2rem, 1.75rem + 1vw, 2.65rem);

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.35rem;
  --space-6: 1.75rem;
  --space-7: 2.25rem;
  --space-8: 2.75rem;

  /* Layout chrome */
  --container-x: clamp(1rem, 2vw, 2rem);
  --container-max: min(90rem, 100%);
  --grid-gap: clamp(0.75rem, 0.65rem + 0.4vw, 1.1rem);
  --section-y: clamp(1.35rem, 1.15rem + 0.6vw, 2rem);
  --card-min: clamp(10rem, 9rem + 2vw, 12.5rem);
  --card-min-lg: clamp(11rem, 10rem + 2.5vw, 14rem);
  --rail-card-w: clamp(9rem, 8rem + 3vw, 12.5rem);
  --media-radius: 0.85rem;

  --pad-x: var(--container-x);
  --page-px: var(--container-x);
  --max-w: min(90rem, 100%);
  --topbar-h: 3.75rem;
  --player-h: 4.5rem;
  --mobilenav-h: 3.75rem;
  --bnav-h: var(--mobilenav-h);
  /* Narrower rail leaves room for content at ~1100 CSS px */
  --sidebar-w: clamp(13.5rem, 12.5rem + 1vw, 15.5rem);
  --sidebar-collapsed-w: 4.5rem;
  --radius: 0.75rem;
  --radius-lg: 1rem;
}

/* Whole-app density scale — desktop DPI only (density.js sets --ui-zoom: 1 on phones) */
.pb-app {
  zoom: var(--ui-zoom, 1);
}
html[data-shell='mobile'] .pb-app {
  zoom: 1;
}

@supports not (zoom: 1) {
  .pb-app {
    transform: scale(var(--ui-zoom, 1));
    transform-origin: 0 0;
    width: calc(100% / var(--ui-zoom, 1));
    min-height: calc(100dvh / var(--ui-zoom, 1));
  }
}

/* Extra tightening inside the DPI-zoomed laptop band */
@media (max-width: 1280px) and (min-width: 801px) {
  :root {
    --sidebar-w: 13.25rem;
    --container-x: 1rem;
    --section-y: 1.15rem;
    --grid-gap: 0.75rem;
    --fluid-page-title: 2.15rem;
    --fluid-h1: 2rem;
    --fluid-display: 2.15rem;
    --topbar-h: 3.25rem;
    --player-h: 4rem;
    --card-min: 9.5rem;
    --card-min-lg: 11rem;
  }

  html {
    font-size: 93.75%; /* 15px — rem chrome shrinks with density */
  }

  .pb-sidebar {
    padding: 1rem 0.7rem 0.75rem;
  }

  .pb-nav__item {
    height: 2.25rem;
    font-size: 0.8125rem;
    padding-inline: 0.65rem;
  }

  .pb-nav__label {
    margin: 0.85rem 0.65rem 0.4rem;
  }

  .pb-view {
    padding-top: 1.1rem;
  }

  .pb-page-head {
    gap: 0.85rem;
    margin-bottom: 1rem;
    flex-wrap: nowrap;
    align-items: flex-end;
  }

  .pb-page-title,
  .pb-page-head h1 {
    font-size: 2.05rem !important;
  }

  .pb-page-head .pb-lede {
    max-width: 40ch;
    font-size: 0.9rem;
  }

  .pb-page-head__aside {
    flex-shrink: 0;
  }

  .pb-spotlight {
    grid-template-columns: minmax(110px, 150px) minmax(0, 1fr) !important;
    gap: 1rem !important;
    padding: 0.95rem !important;
    margin-bottom: 1.15rem !important;
  }

  .pb-spotlight__art,
  .pb-spotlight--wide .pb-spotlight__art,
  .pb-spotlight--square .pb-spotlight__art {
    max-width: 150px !important;
  }

  .pb-spotlight__title {
    font-size: 1.35rem !important;
  }

  .pb-head-stat {
    padding: 0.45rem 0.7rem;
  }

  .pb-head-stat b {
    font-size: 0.95rem;
  }

  .pb-btn {
    height: 2.35rem;
    padding-inline: 0.95rem;
    font-size: 0.8125rem;
  }

  .pb-topbar {
    height: 3.25rem;
  }
}

html[data-density='compact'] .pb-page-title,
html[data-density='compact'] .pb-page-head h1 {
  font-size: 1.9rem !important;
}

html[data-density='compact'] .pb-spotlight {
  grid-template-columns: minmax(100px, 136px) minmax(0, 1fr) !important;
}

html[data-density='compact'] .pb-spotlight__art,
html[data-density='compact'] .pb-spotlight--wide .pb-spotlight__art,
html[data-density='compact'] .pb-spotlight--square .pb-spotlight__art {
  max-width: 136px !important;
}

@media (min-width: 1600px) {
  :root {
    --container-x: clamp(1.5rem, 2.5vw, 2.75rem);
    --container-max: min(96rem, 100%);
    --max-w: min(96rem, 100%);
  }
}

/* True phone / small tablet / phone landscape — not DPI-zoomed laptops */
@media (max-width: 800px),
  (max-width: 1200px) and (max-height: 500px) and (orientation: landscape) {
  :root {
    --sidebar-w: 0px;
    --container-x: clamp(0.9rem, 3.5vw, 1.15rem);
    --section-y: 1.15rem;
    --ui-zoom: 1;
  }
}

@media (max-width: 640px) {
  :root {
    --container-x: clamp(0.8rem, 4vw, 1rem);
    --card-min: clamp(8.5rem, 42vw, 10.5rem);
    --fluid-page-title: clamp(1.75rem, 7vw, 2.15rem);
  }
}

@media (max-width: 520px) {
  :root {
    --player-h: 4.25rem;
    --mobilenav-h: 3.6rem;
  }
}

@media (max-height: 480px) and (orientation: landscape) {
  :root {
    --topbar-h: 2.85rem;
    --section-y: 0.9rem;
    --player-h: 3.75rem;
  }
}

/* ── Base ──────────────────────────────────────────────────────────────── */
html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-size: var(--fluid-text-base) !important;
  line-height: 1.55;
  overflow-x: hidden;
  max-width: 100%;
}

/* Crush leftover hardcoded px chrome so density zoom isn't fighting 44px buttons */
.pb-btn {
  height: 2.5rem;
  font-size: 0.875rem !important;
}
.pb-nav__item {
  height: 2.5rem;
  font-size: 0.84rem !important;
}
.pb-search-trigger,
.pb-topbar__actions > button,
.pb-topbar__menu {
  width: 2.35rem;
  height: 2.35rem;
}

img,
video,
canvas,
svg,
iframe {
  max-width: 100%;
  height: auto;
}

img,
video {
  display: block;
}

.pb-app,
.pb-shell,
.pb-view,
.pb-main,
.pb-section,
.pb-hero,
.pb-hero > *,
.pb-page-head,
.pb-spotlight,
.pb-music-hero,
.pb-continue-read,
.pb-chat,
.pb-chat > *,
.pb-rail,
.app,
.tech-frame,
.destinations,
.dest-view,
.games-view-container,
.dest-body,
.dest-toolbar,
.library-shelves,
.library-block,
.home-panel,
.home-main,
.main-content,
.ui-main,
main {
  min-width: 0;
  max-width: 100%;
}

/* ── Shell ─────────────────────────────────────────────────────────────── */
.pb-shell {
  margin-left: var(--sidebar-w);
}

.pb-sidebar {
  width: var(--sidebar-w);
}

.pb-topbar {
  height: var(--topbar-h);
  padding-inline: var(--pad-x);
}

.pb-view {
  width: 100%;
  max-width: min(var(--container-max), 100%);
  margin-inline: auto;
  padding: var(--section-y) var(--pad-x)
    calc(var(--player-h) + clamp(2rem, 3vw, 3.5rem));
}

.pb-section {
  margin-top: var(--section-y);
}

.pb-brand__mark,
.pb-topbar__brand img {
  height: clamp(1.55rem, 1.45rem + 0.35vw, 1.9rem);
  width: auto;
  max-width: 100%;
}

/* ── Type ──────────────────────────────────────────────────────────────── */
.pb-page-title,
.pb-page-head h1 {
  font-size: var(--fluid-page-title) !important;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.pb-hero__title,
.pb-music-hero__title {
  font-size: var(--fluid-display);
  line-height: 1.05;
}

.pb-spotlight__title {
  font-size: clamp(1.35rem, 1.2rem + 0.6vw, 1.85rem) !important;
  line-height: 1.15;
}

.games-featured-title {
  font-size: clamp(1.35rem, 1.2rem + 0.7vw, 2rem);
}

.pb-h2,
.pb-section__title,
.ui-section-title {
  font-size: var(--fluid-h2);
  line-height: 1.15;
}

.pb-h3,
.pb-card__title,
.card-title,
.pax-card-title,
.news-card-title {
  font-size: var(--fluid-h4);
  line-height: 1.25;
}

.pb-lede,
.pb-hero__desc,
.games-featured-desc,
.pb-spotlight__desc {
  font-size: var(--fluid-text-md);
  max-width: min(52ch, 100%);
}

.pb-eyebrow,
.pb-nav__label,
.games-featured-chip {
  font-size: var(--fluid-text-xs);
}

.pb-nav__item,
.pb-btn,
.media-tools input,
.media-tools select {
  font-size: var(--fluid-text-sm);
}

/* ── Grids ─────────────────────────────────────────────────────────────── */
.pb-pick-grid,
.pb-game-grid,
.pb-media-grid,
.pb-media-grid--wide,
.pb-media-grid--poster,
.pb-media-grid--square,
.pb-media-grid--contain,
.pb-media-grid--library,
.content-grid-6,
.dest-body .content-grid-6,
.pb-stats-strip {
  gap: var(--grid-gap);
}

.content-grid-6,
.dest-body .content-grid-6 {
  display: grid;
  grid-template-columns: repeat(
    auto-fill,
    minmax(min(100%, var(--card-min)), 1fr)
  );
}

.pb-game-grid,
.pb-pick-grid {
  grid-template-columns: repeat(
    auto-fill,
    minmax(min(100%, var(--card-min-lg)), 1fr)
  );
}

.pb-media-grid--wide,
.pb-media-grid--poster,
.pb-media-grid--square,
.pb-media-grid--contain,
.pb-media-grid--library {
  grid-template-columns: repeat(
    auto-fill,
    minmax(min(100%, var(--card-min)), 1fr)
  );
}

.pb-rail--continue > *,
.pb-rail--poster > *,
.pb-rail--rank > *,
.pb-rail--album > * {
  width: var(--rail-card-w);
  flex: none;
}

.pb-rail {
  gap: var(--grid-gap);
}

.dest-body,
.library-shelves,
.games-view-container {
  gap: var(--space-5);
}

.home-main,
.main-content,
.ui-main {
  padding: var(--section-y) var(--pad-x);
}

.pb-player {
  height: var(--player-h);
}

.pb-mobile-nav {
  height: calc(var(--mobilenav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 800px),
  (max-width: 1200px) and (max-height: 500px) and (orientation: landscape) {
  .pb-view {
    padding-bottom: calc(
      var(--player-h) + var(--mobilenav-h) + clamp(1.75rem, 3vw, 2.75rem)
    );
  }

  .pb-player,
  .pb-app.sidebar-collapsed .pb-player {
    bottom: calc(var(--mobilenav-h) + env(safe-area-inset-bottom, 0px));
    left: 0;
  }

  .pb-page-head {
    flex-wrap: wrap;
  }

  .pb-shell {
    margin-left: 0;
  }
}

@media (max-width: 700px) {
  .pb-hero {
    grid-template-columns: 1fr;
  }

  .pb-hero__art {
    order: -1;
    justify-self: start;
    max-width: min(10rem, 40vw);
  }
}

@media (max-width: 640px) {
  .pb-spotlight,
  .pb-music-hero {
    grid-template-columns: 1fr !important;
  }

  .content-grid-6,
  .pb-pick-grid,
  .pb-game-grid {
    grid-template-columns: repeat(
      auto-fill,
      minmax(min(100%, 9.25rem), 1fr)
    );
  }
}

@media (max-width: 420px) {
  .content-grid-6,
  .pb-pick-grid,
  .pb-game-grid,
  .quick-access-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .pb-view {
    animation: none;
  }
}
