/* frame.css, owner: track A. Holds: the shell slots, sidebar, icon rail, tab bar, app bar, page, page head, crumbs, footer, skip links, moved banner, notice bar, toasts (DESIGN_SPEC.md 5, 6, 8.5).
   Load order 3 of 15: base, primitives, frame, home, room, friends, center, table, rails, chat, coach, meld, peek, results, dialogs.
   The elements are built once by render/nav.js; this file shapes them by the width of the window. The table has no frame (nav.js takes it away). */

/* ---- the frame by band (3.3): width, gutter, page width ---- */
/* The phone gutter is 16 px, and never more than 5 percent of the width, so a 200 percent text size does not eat the page (web-b28-friends). */
@media (max-width: 599.98px) { :root { --nav-w: 0px; --page-pad: min(var(--sp-4), 5vw); } }
@media (min-width: 600px) { :root { --nav-w: 5rem; --page-pad: var(--sp-6); } }
@media (min-width: 1024px) { :root { --nav-w: 15rem; --page-pad: var(--sp-7); } }
@media (min-width: 1440px) { :root { --nav-w: 16rem; } }
@media (min-width: 1920px) { :root { --page-max: 96rem; } }
@media (min-width: 2800px) { :root { --page-max: 120rem; } }

/* ---- shell slots ---- */
#app { display: flex; flex-direction: column; flex: 1; min-height: 100vh; min-height: 100dvh; }
#phase-root { flex: 1; display: flex; flex-direction: column; min-height: 0; }
/* Inside the frame the page makes its own room (the table's clearance for the fixed hand rail, at the top of table.css, is not needed). */
.page__inner > #phase-root { padding-bottom: 0; }

/* ---- the frame ---- */
.frame { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); flex: 1; min-height: 100dvh; }
.frame__col { grid-column: 2; display: flex; flex-direction: column; min-width: 0; }
.frame--bare { grid-template-columns: minmax(0, 1fr); }
.frame--bare .frame__col { grid-column: 1; }
.frame--bare .nav, .frame--bare .appbar__profile { display: none; }
.page { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: var(--sp-6) var(--page-pad); }
.page__inner { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: var(--page-max); margin-inline: auto; }

/* ---- the icon rail (600 to 1023) is the plain .nav; the sidebar (1024 and up) and the tab bar (phone) change it ---- */
.nav {
  grid-column: 1; position: sticky; top: var(--moved-banner-h, 0px); align-self: start; z-index: var(--z-rail);
  display: flex; flex-direction: column; align-items: stretch; gap: var(--sp-3); height: calc(100dvh - var(--moved-banner-h, 0px)); overflow-y: auto;
  padding: var(--sp-3) var(--sp-2); background: var(--ink-0); border-right: 1px solid var(--hair);
}
.nav__brand { display: flex; align-items: center; justify-content: center; gap: var(--sp-3); min-height: var(--hit); padding: 0 var(--sp-2); color: var(--text); text-decoration: none; font: var(--t-title-2); }
.nav__mark { flex: none; width: 2.25rem; height: 2.25rem; border-radius: var(--r-md); }
.nav__brand-name, .nav__foot { display: none; }
.nav__items { display: grid; gap: var(--sp-1); list-style: none; }
.nav__item {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-1); width: 100%; height: 3.75rem; min-height: var(--hit); padding: var(--sp-1) 0;
  border: 0; border-radius: var(--r-lg); background: transparent; color: var(--text-dim); font: var(--t-label); text-decoration: none; text-align: center; cursor: pointer;
  transition: background-color var(--dur-fast), color var(--dur-fast);
}
.nav__item .i { flex: none; width: 1.5rem; height: 1.5rem; }
.nav__label { font: var(--t-eyebrow); font-weight: 600; text-transform: none; letter-spacing: 0; }
.nav__item .badge { position: absolute; top: var(--sp-1); right: var(--sp-2); margin: 0; }
.nav__item[aria-current="page"], .nav__item.is-open { background: var(--gold-wash); color: var(--text); }
.nav__item[aria-current="page"]::before {
  content: ""; position: absolute; left: calc(var(--sp-2) * -1); top: 50%; width: 3px; height: 1.5rem; translate: 0 -50%;
  border-radius: 0 var(--r-xs) var(--r-xs) 0; background: var(--gold);
}
.nav__item:active { background: var(--wash-press); }
span.nav__item { cursor: default; }
span.nav__item:active { background: var(--gold-wash); }
@media (hover: hover) and (pointer: fine) {
  .nav__item:where(:not([aria-current="page"], .is-open)):hover { background: var(--wash-hover); color: var(--text); }
  .nav__item:is([aria-current="page"], .is-open):hover { background-image: linear-gradient(var(--wash-hover), var(--wash-hover)); }   /* the current place keeps its gold wash; the hover wash goes on top (11) */
}
.nav__profile {
  display: flex; align-items: center; gap: var(--sp-3); min-height: var(--hit); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--hair);
  border-radius: var(--r-xl); background: var(--panel); color: var(--text); text-align: left; cursor: pointer;
}
.nav__profile.is-open { border-color: var(--gold-line); }
.nav__profile > .i { flex: none; width: 1rem; height: 1rem; color: var(--text-dim); }
.nav__who { flex: 1; display: grid; min-width: 0; }
.nav__name { font: var(--t-label); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav__record { font: var(--t-caption); color: var(--text-dim); }
.nav__legal { display: flex; flex-wrap: wrap; gap: 0 var(--sp-3); padding: 0 var(--sp-2); }
.nav__legal-link, .crumbs__link {
  display: inline-flex; align-items: center; min-height: var(--hit-sm); padding: 0; border: 0; background: none;
  color: var(--text-faint); font: var(--t-caption); text-decoration: none; text-align: left; cursor: pointer;
}
/* The hook class landing-feedback still carries Home's old rule (display: block; margin: 16px auto 8px); the sidebar's link is not that. */
.nav__legal .landing-feedback { display: inline-flex; margin: 0; }
@media (hover: hover) and (pointer: fine) { .nav__legal-link:hover, .crumbs__link:hover { color: var(--text); } }
@media (any-pointer: coarse) { .nav__legal-link, .crumbs__link { min-height: var(--hit); } .crumbs__link { min-width: var(--hit); justify-content: center; } }   /* a short word (Home) is still 44 wide, and sits in the middle of it */

/* The sidebar: the brand with its name, rows with the icon and label side by side, the profile and the legal links at the foot. */
@media (min-width: 1024px) {
  .nav { gap: var(--sp-5); padding: var(--sp-5) var(--sp-3) var(--sp-4); }
  .nav__brand { justify-content: flex-start; }
  .nav__brand-name { display: inline; }
  .nav__foot { display: grid; gap: var(--sp-3); margin-top: auto; }
  .nav__items { gap: var(--sp-1); }
  .nav__item { flex-direction: row; justify-content: flex-start; gap: var(--sp-3); height: 2.875rem; padding: 0 var(--sp-3); text-align: left; }   /* 46 (6.2): drawn with height, min-height stays on AC-13's scale (44) */
  .nav__item .i { width: 1.375rem; height: 1.375rem; }
  .nav__label { font: var(--t-label); }
  .nav__item .badge { position: static; margin-left: auto; }
  .nav__item[aria-current="page"]::before { left: calc(var(--sp-3) * -1); top: var(--sp-2); bottom: var(--sp-2); height: auto; translate: none; }   /* 30 tall on a 46 row */
}

/* ---- the phone: app bar on top, tab bar below ---- */
.appbar { display: none; }
.has-frame .appbar, .frame--bare .appbar { display: flex; }
.appbar {
  position: sticky; top: var(--moved-banner-h, 0px); z-index: var(--z-bar); align-items: center; justify-content: space-between; gap: var(--sp-3);
  min-height: var(--bar-h); padding: 0 var(--page-pad); background: var(--ink-92); border-bottom: 1px solid var(--hair); backdrop-filter: blur(12px);
}
.appbar__brand { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--hit); color: var(--text); text-decoration: none; font: var(--t-title-3); }
.appbar__profile { display: grid; place-items: center; width: var(--hit); height: var(--hit); padding: 0; border: 0; background: none; cursor: pointer; }
@media (min-width: 600px) { .has-frame .appbar { display: none; } }
@media (max-width: 599.98px) {
  .frame__col { padding-bottom: calc(var(--bar-h) + var(--safe-b)); }
  .frame--bare .frame__col { padding-bottom: 0; }
  .nav {
    position: fixed; top: auto; right: 0; bottom: 0; left: 0; height: calc(var(--bar-h) + var(--safe-b)); flex-direction: row; gap: 0; overflow: visible;
    padding: 0 0 var(--safe-b); border-right: 0; border-top: 1px solid var(--hair);
  }
  .nav__brand { display: none; }
  .nav__long { display: none; }   /* "Table" under 600 (6.3), "Your Table" from there up */
  .nav__items { flex: 1; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0; }
  .nav__item { gap: 0.125rem; height: var(--bar-h); border-radius: 0; }
  .nav__item[aria-current="page"], .nav__item.is-open { background: none; color: var(--gold-strong); }
  .nav__item[aria-current="page"] .i, .nav__item.is-open .i { color: var(--gold); }
  .nav__item[aria-current="page"]::before { display: none; }
  .nav__item .badge { left: 50%; right: auto; margin: 0 0 0 var(--sp-1); }
  .nav__item { min-width: 0; }
  .nav__label { max-width: 100%; font-size: max(12px, min(0.75rem, 3.6vw)); }   /* five labels in a 393 px bar: at Larger Text ("Settings" is 80 px at a 21 px label in a 78 px cell) the label follows the width, never under 12 px (fix round 2 M1) */
}

/* ---- page head, breadcrumb, footer ---- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3) var(--sp-5); margin-bottom: var(--sp-5); }
.page-head__title { flex: 1; min-width: 0; font: var(--t-title-1); }
.page-head__actions { display: flex; gap: var(--sp-2); margin-left: auto; }
.crumbs { flex-basis: 100%; }
.crumbs__list { display: flex; flex-wrap: wrap; align-items: center; list-style: none; }
.crumbs__item { display: inline-flex; align-items: center; gap: var(--sp-1); color: var(--text); font: var(--t-caption); }
.crumbs__item .i { width: 0.875rem; height: 0.875rem; margin-right: var(--sp-1); color: var(--text-faint); }   /* the chevron has the same room either side: 4 and 4, */
@media (any-pointer: coarse) { .crumbs__item .i { margin-right: var(--sp-2); } }   /* and 8 and 8 when the word sits in its 44 wide box */
.crumbs__link { color: var(--text-dim); }
.page-foot { display: flex; justify-content: center; padding: 0 var(--page-pad) var(--sp-5); }
.page-foot__legal { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 var(--sp-4); }
@media (min-width: 1024px) { .page-foot { display: none; } }
/* Home still carries its own legal row (track B removes it); one row is enough. */
.page:has(.landing-legal) + .page-foot { display: none; }

/* ---- skip links: the first two Tab stops, seen only when focused (6.7) ---- */
.skip-link {
  position: fixed; top: calc(var(--moved-banner-h, 0px) + var(--sp-2)); left: var(--sp-2); z-index: var(--z-toast); width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%);
  border-radius: var(--r-lg); background: transparent; color: var(--ink-on-gold); font: var(--t-label); text-decoration: none; white-space: nowrap;
}
/* Unseen until it has focus: then a 44 tall bar with a gold edge and gold text on the dark bar color (not a gold fill, so it is never one more gold fill on the screen, AC-06, and its
   gold ring is 3:1 or better against every background it can float over: a gold ring on a gold fill was 1.14:1, AC-05). */
.skip-link:focus { display: inline-flex; align-items: center; width: auto; height: auto; min-height: var(--hit); padding: 0 var(--sp-4); overflow: visible; clip-path: none; background: var(--ink-0); border: 2px solid var(--gold); color: var(--gold-strong); }
.skip-link:focus-visible { outline-color: var(--gold-strong); box-shadow: none; }

/* ========== MOVED BANNER (build 29, public/moved.js) ========== */
/* "Pinochle has a new address": a slim bar fixed to the top of the old website address, with Take Me There and Not Now. It makes its own room:
   moved.js sets --moved-banner-h to the bar's height and body.has-moved-banner pushes the page down by it (and shortens #app by the same amount).
   The sidebar and the app bar start below it (top: var(--moved-banner-h)). At a table the bar steps aside and gives the room back. */
.moved-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: var(--z-banner); display: flex; flex-direction: column; gap: var(--sp-2);
  padding: calc(var(--sp-2) + env(safe-area-inset-top, 0px)) calc(var(--sp-3) + env(safe-area-inset-right, 0px)) var(--sp-2) calc(var(--sp-3) + env(safe-area-inset-left, 0px));
  background: var(--panel-2); border-bottom: 1px solid var(--gold-line-55); box-shadow: var(--shadow-banner); color: var(--text);
}
.moved-banner-text { font-size: max(0.875rem, 12px); line-height: 1.35; }
.moved-banner-text strong { color: var(--gold-strong); font-weight: 700; overflow-wrap: anywhere; }
.moved-banner-actions { display: flex; gap: var(--sp-2); }
.moved-banner .btn { flex: 1 1 0; min-height: var(--hit); padding: calc(var(--sp-2) - 0.1rem) calc(var(--sp-4) - 0.1rem); font-size: max(0.9375rem, 12px); box-shadow: none; }
@media (min-width: 600px) {
  .moved-banner { flex-direction: row; align-items: center; justify-content: center; gap: var(--sp-4); }
  .moved-banner-text { max-width: 44rem; }
  .moved-banner .btn { flex: 0 0 auto; }
}
body.has-moved-banner { padding-top: var(--moved-banner-h, 0px); }
body.has-moved-banner #app { min-height: calc(100vh - var(--moved-banner-h, 0px)); min-height: calc(100dvh - var(--moved-banner-h, 0px)); }
body.has-moved-banner .frame { min-height: calc(100dvh - var(--moved-banner-h, 0px)); }
body.at-table .moved-banner { display: none; }
body.at-table.has-moved-banner { padding-top: 0; }
body.at-table.has-moved-banner #app { min-height: 100dvh; }

/* ========== NOTICE BAR (8.5): the disconnect and error bars of app.js ========== */
.notice { display: flex; align-items: center; justify-content: center; gap: var(--sp-3); min-height: 2.5rem; padding: var(--sp-1) var(--page-pad); font: var(--t-small); color: var(--text); text-align: center; }
.notice .i { flex: none; width: 1.25rem; height: 1.25rem; }
.notice--bad { background: linear-gradient(var(--bad-wash), var(--bad-wash)), var(--ink-0); }
.notice--gold { background: linear-gradient(var(--gold-wash), var(--gold-wash)), var(--ink-0); }
.reconnecting-banner, .error-banner { position: fixed; top: var(--moved-banner-h, 0px); left: 0; right: 0; z-index: var(--z-banner); border-bottom: 1px solid var(--bad-edge); }
/* In the frame the bar sits over the content column, not over the sidebar's brand, and on a phone (and under a brand bar) just below the app bar: 8.5 puts it under the top bar or the app bar. */
body.has-frame .reconnecting-banner, body.has-frame .error-banner { left: var(--nav-w); }
body.has-bare .reconnecting-banner, body.has-bare .error-banner { top: calc(var(--moved-banner-h, 0px) + var(--bar-h)); }
@media (max-width: 599.98px) { body.has-frame .reconnecting-banner, body.has-frame .error-banner { top: calc(var(--moved-banner-h, 0px) + var(--bar-h)); } }
.reconnecting-banner { animation: pulse 1s ease-in-out infinite alternate; }
.error-banner { flex-wrap: wrap; }
.error-banner .error-detail { flex-basis: 100%; font: var(--t-caption); opacity: 0.9; }
.error-banner button { min-height: var(--hit-sm); padding: 0 var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-md); background: transparent; color: var(--text); font: var(--t-label); cursor: pointer; }
@keyframes pulse { from { opacity: 0.7; } to { opacity: 1; } }

/* ========== TOASTS (8.5): a capsule, three at most; render/core.js sets --toast-i, the place in the stack ========== */
.toast {
  position: fixed; left: 50%; top: calc(var(--moved-banner-h, 0px) + var(--sp-4) + var(--toast-i, 0) * 3.5rem); z-index: var(--z-toast); transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--sp-2); width: max-content; max-width: min(92vw, 32rem); min-height: 3rem; padding: 0 var(--sp-5); border: 1px solid var(--line); border-radius: var(--r-full);
  background: var(--panel); box-shadow: var(--e-2); color: var(--text); font: var(--t-small); pointer-events: none;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 3.7s forwards;
}
.toast .i { flex: none; width: 1.25rem; height: 1.25rem; color: var(--gold); }
.toast-success .i { color: var(--good); }
.toast-error .i { color: var(--bad); }
/* In the frame a toast is at the top under the page (the tab bar's side of the phone is the bottom); at the table it hangs under the bar, never over the hand (8.5). */
body.at-table .toast { top: calc(var(--rail-top, 2.5rem) + var(--sp-3) + var(--toast-i, 0) * 3.5rem); bottom: auto; }
@media (max-width: 599.98px) {
  body.has-frame .toast { top: auto; bottom: calc(var(--bar-h) + var(--safe-b) + var(--sp-3) + var(--toast-i, 0) * 3.5rem); }
  body.has-bare .toast { top: auto; bottom: calc(var(--safe-b) + var(--sp-4) + var(--toast-i, 0) * 3.5rem); }
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ========== FORCED COLORS (12.3): washes and shadows are not drawn, so the current place is a border and a Highlight bar ========== */
@media (forced-colors: active) {
  .nav__item[aria-current="page"], .nav__item.is-open { border: 2px solid Highlight; }
  .nav__item[aria-current="page"]::before { background: Highlight; }
  .toast, .notice, .nav__profile { border: 1px solid CanvasText; }
}
