/* ══════════════════════════════════════════════════════════════════════════
   PAGES — one shell for every main-menu destination.

   Boxes, Skills, History, Schedules, Account and Devices all sit in the same
   content column: one max width, one side gutter, centred in .main. Before
   this, Skills was 1080px wide and left-hugging, Schedules/History/Devices
   780px, Account 1020px, and Account/History opened as modals on desktop — so
   the content jumped sideways every time you changed page.

   The column is drawn with padding, not max-width: each page is also the
   scroller, and a capped scroller puts its scrollbar in the middle of the
   window. padding-inline: max(gutter, (100% - column) / 2) keeps the
   scroller full-bleed and the content centred.

   Loaded after index.html, schedules.css and skills.css. The #screen-home
   prefix is deliberate: it out-ranks the per-page shells in those files
   without !important.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  --page-max: 1120px;
  --page-x: clamp(16px, 4vw, 44px);
  --page-inline: max(var(--page-x), calc((100% - var(--page-max)) / 2));
  --page-top: 28px;
}

/* ── The column ───────────────────────────────────────────────────────── */
#screen-home .main > .page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: var(--page-top) var(--page-inline) 96px;
}
#screen-home .main > .page[hidden] { display: none; }
#screen-home.active .main > .page:not([hidden]) {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#screen-home .main > .page > h2,
#screen-home .main > .page .nv-head > h2,
#screen-home .acct-pane > h2 { margin: 0 0 6px; }
#screen-home .main > .page > .lede,
#screen-home .main > .page .net-card > .lede,
#screen-home .acct-pane > .lede { margin: 0 0 20px; max-width: 62ch; }

/* The Boxes chrome gets its own, wider column. A fleet of device cards is a
   dashboard, not a reading measure: in the 1120px page column eight boxes
   became four 265px cards with clipped names, parked in the middle of a
   2560px monitor. --page-inline can't be re-used with a different max (it is
   resolved once, on :root), so the same formula is restated here. */
#screen-home { --boxes-inline: max(var(--page-x), calc((100% - var(--boxes-max, 1720px)) / 2)); }
#screen-home .dtopbar { padding-inline: var(--boxes-inline); }
/* The grid is the scroller, so it must be full-bleed like every other page:
   the column comes from the padding alone. It used to keep index.html's
   max-width: 1500px as well, so the centring padding (measured against .main)
   was spent inside the capped box once .main grew past 1500px. */
#screen-home.active .grid { max-width: none; }
#screen-home.active .grid:not(.fit) { padding-inline: var(--boxes-inline); }
@media (min-width: 900px) {
  #screen-home.active .grid.fit { padding-inline: var(--boxes-inline); }
}

@media (max-width: 980px) {
  #screen-home .main > .page {
    padding: 20px var(--page-inline) calc(var(--nav-h) + 32px + env(safe-area-inset-bottom, 0px));
  }
  #screen-home .scenes,
  #screen-home .filters { padding-inline: var(--page-inline); }
}

/* ── Account: rail + pane inside the column ───────────────────────────── */
@media (min-width: 981px) {
  #screen-home .main > .acct-page {
    display: grid;
    grid-template-columns: 208px minmax(0, 1fr);
    column-gap: 40px;
    align-items: start;
  }
  #screen-home .acct-side { top: 0; padding-top: 2px; }
  #screen-home .acct-side .sb-label { padding-top: 0; }
  /* A form pane reads best at a measure, not 900px wide. */
  #screen-home .acct-body { max-width: 720px; }
}
@media (max-width: 980px) {
  /* The tab rail is full-bleed and sticky; only its items take the gutter. */
  #screen-home .main > .acct-page { padding: 0 0 calc(var(--nav-h) + 32px + env(safe-area-inset-bottom, 0px)); }
  #screen-home .acct-side { padding-inline: var(--page-inline); }
  #screen-home .acct-body { padding: 20px var(--page-inline) 0; }
}

/* ── Schedules: compose beside the list when there is room ────────────── */
@media (min-width: 1240px) {
  #screen-home .main > .sched-page:not([hidden]) {
    display: grid;
    grid-template-columns: minmax(340px, 400px) minmax(0, 1fr);
    column-gap: 28px;
    align-items: start;
    align-content: start;
  }
  #screen-home .sched-page > h2,
  #screen-home .sched-page > .lede { grid-column: 1 / -1; }
  #screen-home .sched-page > .sched-new { position: sticky; top: 0; margin: 0; }
  #screen-home .sched-page > .sched-list { margin-top: 0; min-width: 0; }
}

/* ── Phone field — flag + dial code, then the number ──────────────────── */
.phone-field {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}
.phone-field > input { flex: 1; min-width: 0; width: auto; }
.pf-cc {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px 0 13px;
  min-height: 48px;
  background: var(--well);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.pf-cc:hover { border-color: var(--border-hi); }
.phone-field.cc-focus .pf-cc { border-color: var(--on); box-shadow: 0 0 0 4px var(--on-soft); }
.pf-flag { font-size: 19px; line-height: 1; font-family: system-ui, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.pf-dial { letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.pf-chev { width: 10px; height: 6px; color: var(--ink-3); }
/* The real control: a native <select> stretched invisibly over the chip, so a
   tap anywhere on it opens the platform's own picker. */
.pf-cc select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 16px; /* iOS: <16px zooms the page on focus */
  background: none;
  box-shadow: none;
}
.pf-cc select:focus { box-shadow: none; }

/* ── Bottom nav: six destinations + the orb on a phone ────────────────── */
@media (max-width: 980px) {
  .lipi-nav-pill span {
    font-family: var(--sans, inherit);
    text-transform: none;
    letter-spacing: 0;
    font-size: 10px;
    font-weight: 500;
  }
}
@media (max-width: 360px) {
  .lipi-nav-pill span { font-size: 9px; }
}

/* ── Devices: long names end in an ellipsis instead of being cut mid-letter.
   The name was a flex container, and text-overflow never applies to one. ── */
.nv-who b { display: block; }
.nv-who b .net-verified { display: inline-flex; vertical-align: -2px; }

/* ── Modals ───────────────────────────────────────────────────────────── */
/* button.ghost / .primary set their own display, which beat the UA [hidden]
   rule — Rapido's "New puzzle" showed on the phone step. */
.modal-card [hidden] { display: none !important; }
/* Action rows: one line per button, so pills keep one height. */
.modal-card button { white-space: nowrap; }

/* ── Hands-free HUD ───────────────────────────────────────────────────── */
.hf-hud {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  z-index: 70;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: calc(100vw - 32px);
  padding: 9px 15px 9px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--pop);
  color: var(--ink);
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.55);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -6px);
  transition: opacity .16s var(--ease), transform .16s var(--ease);
}
.hf-hud.show { opacity: 1; transform: translate(-50%, 0); }
.hf-hud[hidden] { display: none; }
.hf-hud-t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hf-hud-ic {
  position: relative;
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
/* Hearing: a live green dot with a ring breathing out of it. */
.hf-hud[data-kind="hear"] { border-color: color-mix(in srgb, var(--on) 45%, transparent); }
.hf-hud[data-kind="hear"] .hf-hud-ic { background: var(--on); transform: scale(.55); }
.hf-hud[data-kind="hear"] .hf-hud-ic::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--on);
  animation: hfHudRing 1.1s cubic-bezier(0.2, 0.6, 0.3, 1) infinite;
}
@keyframes hfHudRing { from { transform: scale(.5); opacity: .9; } to { transform: scale(1.25); opacity: 0; } }
/* Working: a spinner. */
.hf-hud[data-kind="work"] .hf-hud-ic {
  border: 2px solid color-mix(in srgb, var(--on) 25%, transparent);
  border-top-color: var(--on);
  animation: hfHudSpin .7s linear infinite;
}
@keyframes hfHudSpin { to { transform: rotate(360deg); } }
/* Failed: red, and it stays readable for a few seconds. */
.hf-hud[data-kind="bad"] { border-color: color-mix(in srgb, var(--err, #ff5c7a) 55%, transparent); }
.hf-hud[data-kind="bad"] .hf-hud-ic { background: var(--err, #ff5c7a); color: #fff; }
@media (prefers-reduced-motion: reduce) {
  .hf-hud { transition: none; }
  .hf-hud-ic, .hf-hud-ic::after { animation: none !important; }
}

/* ── Boxes on a tablet: two cards a row ───────────────────────────────── */
/* One card per row is right on a phone, but at 641–980px it left a single
   ~700px card with four tiles stretched across it. Two columns give each card
   the ~330px it has on desktop. Full-width rows (room rail, hands-free teaser,
   a wide IR remote) still span both. */
@media (min-width: 641px) and (max-width: 980px) {
  #screen-home.active .grid:not(.fit) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #screen-home.active .grid > :not(.box),
  #screen-home.active .grid > .box[data-ir-wide] { grid-column: 1 / -1; }
}

/* ── Devices on a small phone ─────────────────────────────────────────── */
/* The card's name column had a 120px floor and the list a bare 1fr, so at
   320px the timer column was pushed off-screen. Let the name give way (it
   ellipsises) and keep the live timer whole. */
@media (max-width: 600px) {
  .nv-cards { grid-template-columns: minmax(0, 1fr); }
  .nv-card { grid-template-columns: 38px minmax(0, 1fr) auto; gap: 10px; padding: 12px 13px; }
  .nv-card .nv-ic { width: 38px; height: 38px; }
}
@media (max-width: 400px) {
  .nv-card .nv-dur b { font-size: 14px; }
  .nv-card .nv-dur small { font-size: 10px; }
}

/* ── Skills filter chips stay on one line ─────────────────────────────── */
@media (max-width: 480px) {
  .sk-filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: calc(-1 * var(--page-x)); padding-inline: var(--page-x); }
  .sk-filters::-webkit-scrollbar { display: none; }
  .sk-filters .net-chip { flex: none; }
}

/* ── Toast ────────────────────────────────────────────────────────────── */
/* left:50% leaves the box only half the viewport to size into, so a long
   message wrapped into a narrow column parked right of centre. Size to the
   text, cap at the column, and sit above the bottom nav on a phone. Sentences
   read better in the sans than in letter-spaced mono. */
#toast {
  width: max-content;
  max-width: min(520px, calc(100vw - 32px));
  font-family: var(--sans, inherit);
  font-size: 13px;
  letter-spacing: 0;
  line-height: 1.4;
  text-align: center;
  transition: opacity .18s var(--ease), transform .18s var(--ease);
}
@media (max-width: 980px) {
  #toast { bottom: calc(var(--nav-h) + 22px + env(safe-area-inset-bottom, 0px)); }
}
