/* PANEL-90 Phase 9, Workstream BD — mobile chrome + the
   slim-top / tablet LAW (items 188, 190, 192, 193, 198 and
   the design law 202–206). This file layers OVER item 27's
   basic mobile pass in panel60.css, which is NOT edited:
   where the two disagree on phone/tablet viewports (tap
   targets 44px there, 48px here), THIS file wins because
   the coordinator loads it after panel60.css.

   SCOPE LAW: every rule in this file lives inside a media
   query. The phone query is max-width 760px, the tablet
   query is 761px to 1100px, and one min-width 1101px query
   only hides elements this workstream itself adds (the
   thumb bar, the menu button) on desktop. No existing
   desktop rule is touched: above 1100px the panel renders
   exactly as it did before this file existed.

   HOW THE SLIM BAR IS BUILT (item 202): base.html has no
   single slim-header element. Its header furniture is the
   sidebar block (brand mark + view chip + the whole side
   nav) followed by the topbar block (role chip, preview
   banner, label-focus chip, the search form, the userbox
   link row) — five stacked bands on a phone today. On
   phone and tablet viewports the rules below compose ONE
   52px row out of the two blocks that already exist: the
   sidebar becomes a fixed slim strip showing only the ESC
   brand mark, and the topbar becomes a fixed slim strip
   in the SAME row beside it, showing only the search, the
   notification bell and one menu button. The role chip,
   the view chip, the label-focus chip and the userbox link
   row are hidden on these viewports (their destinations
   live on in the menu panel, the thumb bar and More). The
   side nav itself becomes a drop-down panel under the bar,
   opened by the menu button (mobile60bd.js toggles the
   p60bd-menu-open class on the body; the button is the
   p60bd-menubtn hook named in snippets/bd.txt, injected by
   the JS when the merge has not added it yet).

   CHROME BUDGET (item 206) — the math, stated once:
     top bar            52px
     one notice line    32px   (at most one, item 203)
     total top chrome   84px
   A small phone viewport is 667px tall: 15 percent of
   667px is 100px, and 84px is under it (84 / 667 is about
   12.6 percent). A tablet viewport is 768px tall at its
   shortest common size: 15 percent is 115px, and 84px is
   under that too. So the first screen is at least 85
   percent work on both. The budget lives in the custom
   properties below (p60bd-bar-h, p60bd-notice-h,
   p60bd-chrome-max) and the sticky offsets and paddings
   in this file are computed from them, never restated as
   bare numbers. */

/* ================================================================
   PHONE — max-width 760px
   ================================================================ */
@media (max-width: 760px) {
  :root {
    --p60bd-bar-h: 52px;
    --p60bd-notice-h: 32px;
    --p60bd-chrome-max: 84px; /* 52px bar + 32px notice = 84px, under 100px (15% of 667px) */
    --p60bd-target: 48px;
    --p60bd-thumb-h: 56px;
    --p60bd-chrome-h: var(--p60bd-bar-h); /* JS raises this to 84px while a notice line shows */
  }

  /* ---- item 206: the first screen is work ---- */
  .mainwrap {
    padding-top: var(--p60bd-chrome-h);
    padding-bottom: calc(var(--p60bd-thumb-h) + env(safe-area-inset-bottom));
  }
  .mainwrap main { padding-top: 0.7rem; }

  /* ---- item 202: ONE slim top bar, single row ----
     The sidebar strip carries the ESC mark; the topbar
     strip carries search + bell + menu in the same row. */
  .sidebar {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--p60bd-bar-h); z-index: 66;
    display: flex; align-items: center;
    padding: 0 0.5rem; overflow: visible;
    border-right: none; border-bottom: 1px solid var(--gold-hair, #3a2f14);
    transition: transform 0.22s ease;
  }
  .sidebar .brand { margin: 0; font-size: 0; flex: none; }
  .sidebar .brand .esc-logo { width: 38px; }
  .sidebar .view-chip { display: none; }
  .topbar {
    position: fixed; top: 0; left: 52px; right: 0;
    min-height: var(--p60bd-bar-h); z-index: 65;
    display: flex; align-items: center; flex-wrap: wrap;
    gap: 0.4rem; padding: 0 0.5rem;
    background: var(--pp-chrome, rgba(8, 8, 10, 0.92));
    border-bottom: 1px solid var(--line);
    transition: transform 0.22s ease;
  }
  /* the stacked bands fold away: role chip + focus chip
     are chrome, not work — destinations survive in the
     menu panel and on More (the /m/chrome page) */
  .topbar .role-chip { display: none; }
  .topbar .desk-focus-chip { display: none; }
  .topbar .userbox {
    margin-left: 0; white-space: nowrap; font-size: 0;
    display: flex; align-items: center;
  }
  .topbar .userbox a,
  .topbar .userbox .view-as,
  .topbar .userbox .lang-switch { display: none; }
  .topbar .userbox a.notify-bell {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: var(--p60bd-target); min-height: var(--p60bd-target);
    font-size: 1.05rem; margin-left: 0;
  }
  /* one menu button (hook class p60bd-menubtn; added by
     the merge or injected by mobile60bd.js) */
  .p60bd-menubtn {
    flex: none; display: inline-flex; align-items: center;
    justify-content: center;
    min-width: var(--p60bd-target); min-height: var(--p60bd-target);
    width: var(--p60bd-target); height: var(--p60bd-target);
    padding: 0; font-size: 1.25rem; line-height: 1;
  }
  /* the side nav is a drop-down panel under the bar,
     never a stacked block of its own */
  .sidebar .side-nav {
    position: fixed; top: var(--p60bd-bar-h); left: 0; right: 0;
    max-height: 0; overflow: hidden; visibility: hidden;
    background: var(--pp-chrome, #101014);
    border-bottom: 1px solid var(--gold-hair, #3a2f14);
    transition: max-height 0.22s ease, visibility 0.22s;
    display: block; padding: 0 0.6rem;
  }
  body.p60bd-menu-open .sidebar .side-nav {
    max-height: 72vh; overflow-y: auto; visibility: visible;
    padding-bottom: 0.6rem;
  }

  /* ---- item 204: hide-on-scroll ----
     mobile60bd.js adds p60bd-header-hidden to the body
     scrolling down and removes it scrolling up. Both
     halves of the composed bar tuck away together. */
  body.p60bd-header-hidden .sidebar,
  body.p60bd-header-hidden .topbar {
    transform: translateY(-100%);
  }

  /* ---- item 203: banners never stack ----
     Inside the top-chrome container at most ONE notice
     line renders: the first p60bd-notice stays as a slim
     32px line, every later one is suppressed (they belong
     to the Home feed). The preview banner in base.html's
     topbar is the existing element that takes the
     p60bd-notice hook class in the merge. */
  .p60bd-topchrome .p60bd-notice {
    flex: 0 0 100%; order: 5;
    background: var(--pp-chrome, rgba(8, 8, 10, 0.92));
    height: var(--p60bd-notice-h); max-height: var(--p60bd-notice-h);
    display: flex; align-items: center; gap: 0.5rem;
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
    font-size: 0.82rem; padding: 0 0.6rem; margin: 0;
    border-radius: 0;
  }
  .p60bd-topchrome .p60bd-notice ~ .p60bd-notice {
    display: none !important;
  }
  .p60bd-notice .p60bd-notice-x {
    min-width: var(--p60bd-target); min-height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  /* the affordance line a page can show when notices were
     suppressed: they live on Home, this says so */
  .p60bd-more-notices {
    display: block; font-size: 0.82rem; padding: 0.35rem 0.6rem;
    min-height: 32px;
  }

  /* ---- item 198: search-first header ----
     The search form leads the slim row and takes the
     space; focusing it (JS adds p60bd-search-open to the
     top chrome) expands it in place across the row. */
  .topbar .topsearch {
    order: -1; flex: 1 1 auto; min-width: 0;
    display: flex; align-items: center; gap: 0.35rem;
  }
  .topbar .topsearch label { flex: 1; flex-direction: row; min-width: 0; font-size: 0; }
  .topbar .topsearch input {
    flex: 1; min-width: 0; min-height: var(--p60bd-target);
    font-size: 1rem;
  }
  .topbar .topsearch button {
    min-width: var(--p60bd-target); min-height: var(--p60bd-target);
    flex: none;
  }
  .p60bd-topchrome.p60bd-search-open .topsearch { flex: 1 1 100%; }
  .p60bd-topchrome.p60bd-search-open .p60bd-menubtn,
  .p60bd-topchrome.p60bd-search-open .userbox { display: none; }

  /* ---- item 190: big-target pass ----
     Every critical action is thumb-sized: at least 48px
     in the tap dimension. No hover-only actions: anything
     revealed on hover in the desktop CSS is simply
     visible here (panels render their controls inline). */
  .topbar a, .topbar button,
  .sidebar .side-nav a,
  .btn, button, .btn.small, button.btn,
  .pager a, .pager .cur, .pager span.cur,
  .card form button[type="submit"],
  .q-actions .btn,
  select, input[type="text"], input[type="search"],
  input[type="email"], input[type="url"],
  input[type="password"], input[type="number"],
  input[type="date"] {
    min-height: 48px;
  }
  .sidebar .side-nav a {
    display: flex; align-items: center;
    min-height: 48px; padding-top: 0; padding-bottom: 0;
  }
  .btn, button, .btn.small {
    min-width: 48px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  input[type="checkbox"], input[type="radio"] {
    min-width: 28px; min-height: 28px;
  }
  .pin-x { min-width: 48px; min-height: 48px; }

  /* ---- item 188: bottom thumb bar ----
     Five slots, fixed to the bottom, one-handed reach,
     clear of the phone's home indicator via the safe-area
     inset. Markup: templates/p60bd_thumbbar.html. */
  .p60bd-thumbbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 70;
    display: flex; align-items: stretch;
    height: calc(var(--p60bd-thumb-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--pp-chrome, rgba(8, 8, 10, 0.97));
    border-top: 1px solid var(--gold-hair, #3a2f14);
  }
  .p60bd-thumbbar .p60bd-thumb-item {
    flex: 1 1 0; min-width: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 2px;
    min-height: 48px; padding: 4px 2px;
    color: var(--fg, #f4f1ea); text-decoration: none;
    font-size: 0.68rem; line-height: 1.15; text-align: center;
  }
  .p60bd-thumbbar .p60bd-thumb-ic { font-size: 1.2rem; line-height: 1; }
  .p60bd-thumbbar .p60bd-thumb-item.active,
  .p60bd-thumbbar .p60bd-thumb-item[aria-current="page"] {
    color: var(--accent, #f5b301); font-weight: 700;
    box-shadow: inset 0 2px 0 var(--accent, #f5b301);
  }

  /* ---- item 192: compact release cards ----
     Pages opt in with p60bd-card: artwork left, title +
     status stacked, and the ONE owed thing as its own
     full-width line — nothing else competes with it. */
  .p60bd-cardlist {
    display: flex; flex-direction: column; gap: 0.6rem;
  }
  .p60bd-card {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    grid-template-areas: "art main" "owed owed";
    gap: 0.35rem 0.7rem; align-items: center;
    background: var(--card, #161618);
    border: 1px solid var(--line, #26262b);
    border-radius: var(--radius, 12px);
    padding: 0.6rem 0.7rem; margin: 0;
  }
  .p60bd-card-art {
    grid-area: art; width: 56px; height: 56px;
    border-radius: 8px; object-fit: cover; display: block;
    background: var(--pp-hairline, #26262b);
  }
  .p60bd-card-main { grid-area: main; min-width: 0; }
  .p60bd-card-title {
    font-weight: 700; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis;
  }
  .p60bd-card-status { font-size: 0.85rem; color: var(--muted, #9a968c); }
  .p60bd-card-owed {
    grid-area: owed; font-size: 0.9rem; font-weight: 600;
    color: var(--accent, #f5b301);
  }
  .p60bd-card .p60bd-card-actions { grid-area: owed; }
  .p60bd-card a, .p60bd-card button { min-height: 48px; }

  /* ---- item 193: sticky action bar ----
     Pages opt in with p60bd-actionbar around their
     Submit / Approve / Save controls: it pins to the
     bottom of long pages and forms, ABOVE the thumb bar. */
  .p60bd-actionbar {
    position: sticky;
    bottom: calc(var(--p60bd-thumb-h) + env(safe-area-inset-bottom));
    z-index: 40;
    display: flex; gap: 0.5rem; flex-wrap: wrap;
    align-items: center;
    background: var(--pp-chrome, rgba(8, 8, 10, 0.96));
    border-top: 1px solid var(--line, #26262b);
    padding: 0.5rem 0.6rem;
    margin: 0 -0.6rem;
  }
  .p60bd-actionbar .btn, .p60bd-actionbar button {
    flex: 1 1 auto; min-height: 48px;
  }

  /* ---- partner shell (pp_base) slimming, same law ----
     The partner shell has its own two-band header; on
     phones it collapses to the same single slim row and
     its nav folds behind the same menu state. */
  .pp-head {
    position: sticky; top: 0; z-index: 65;
    min-height: var(--p60bd-bar-h); padding: 4px 10px;
  }
  .pp-head .pp-logo { height: 36px; width: 36px; }
  .pp-head h1 { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pp-nav { display: none; }
  body.p60bd-menu-open .pp-nav {
    display: flex; position: sticky; top: var(--p60bd-bar-h); z-index: 64;
    max-height: 72vh; overflow-y: auto;
  }
  .pp-nav a { min-height: 48px; display: inline-flex; align-items: center; }
  .pp-main { padding-bottom: calc(var(--p60bd-thumb-h) + env(safe-area-inset-bottom) + 12px); }
}

/* ================================================================
   TABLET — 761px to 1100px
   Same slim top (item 202), same budget (item 206), plus the
   real two-pane layout (item 205): never a stretched phone
   UI, never a squeezed desktop one. No thumb bar here —
   the bottom bar is a phone pattern (item 188); tablet
   navigation is the slim top's menu button plus the pane
   layout itself.
   ================================================================ */
@media (min-width: 761px) and (max-width: 1100px) {
  :root {
    --p60bd-bar-h: 52px;
    --p60bd-notice-h: 32px;
    --p60bd-chrome-max: 84px; /* 52px bar + 32px notice = 84px, under 115px (15% of 768px) */
    --p60bd-target: 48px;
    --p60bd-chrome-h: var(--p60bd-bar-h);
  }

  /* ---- items 202 + 206: one slim row, work first ---- */
  .layout { grid-template-columns: 1fr; }
  .mainwrap { padding-top: var(--p60bd-chrome-h); min-width: 0; }
  .sidebar {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--p60bd-bar-h); z-index: 66;
    display: flex; align-items: center;
    padding: 0 0.7rem; overflow: visible;
    border-right: none; border-bottom: 1px solid var(--gold-hair, #3a2f14);
    transition: transform 0.22s ease;
  }
  .sidebar .brand { margin: 0; flex: none; display: flex; align-items: center; gap: 0.5rem; }
  .sidebar .brand .esc-logo { width: 52px; }
  .sidebar .view-chip { display: none; }
  .topbar {
    position: fixed; top: 0; left: 196px; right: 0;
    min-height: var(--p60bd-bar-h); z-index: 65;
    display: flex; align-items: center; flex-wrap: wrap;
    gap: 0.5rem; padding: 0 0.7rem;
    background: var(--pp-chrome, rgba(8, 8, 10, 0.92));
    border-bottom: 1px solid var(--line);
    transition: transform 0.22s ease;
  }
  .topbar .role-chip { display: none; }
  .topbar .desk-focus-chip { display: none; }
  .topbar .userbox {
    margin-left: 0; white-space: nowrap; font-size: 0;
    display: flex; align-items: center;
  }
  .topbar .userbox a,
  .topbar .userbox .view-as,
  .topbar .userbox .lang-switch { display: none; }
  .topbar .userbox a.notify-bell {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: var(--p60bd-target); min-height: var(--p60bd-target);
    font-size: 1.05rem; margin-left: 0;
  }
  .p60bd-menubtn {
    flex: none; display: inline-flex; align-items: center;
    justify-content: center;
    min-width: var(--p60bd-target); min-height: var(--p60bd-target);
    width: var(--p60bd-target); height: var(--p60bd-target);
    padding: 0; font-size: 1.25rem; line-height: 1;
  }
  .sidebar .side-nav {
    position: fixed; top: var(--p60bd-bar-h); left: 0;
    width: 320px; max-width: 86vw;
    max-height: 0; overflow: hidden; visibility: hidden;
    background: var(--pp-chrome, #101014);
    border-right: 1px solid var(--gold-hair, #3a2f14);
    border-bottom: 1px solid var(--gold-hair, #3a2f14);
    transition: max-height 0.22s ease, visibility 0.22s;
    display: block; padding: 0 0.6rem;
  }
  body.p60bd-menu-open .sidebar .side-nav {
    max-height: 78vh; overflow-y: auto; visibility: visible;
    padding-bottom: 0.6rem;
  }

  /* ---- item 204: hide-on-scroll ---- */
  body.p60bd-header-hidden .sidebar,
  body.p60bd-header-hidden .topbar {
    transform: translateY(-100%);
  }

  /* ---- item 203: banners never stack ---- */
  .p60bd-topchrome .p60bd-notice {
    flex: 0 0 100%; order: 5;
    background: var(--pp-chrome, rgba(8, 8, 10, 0.92));
    height: var(--p60bd-notice-h); max-height: var(--p60bd-notice-h);
    display: flex; align-items: center; gap: 0.5rem;
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
    font-size: 0.85rem; padding: 0 0.7rem; margin: 0;
    border-radius: 0;
  }
  .p60bd-topchrome .p60bd-notice ~ .p60bd-notice {
    display: none !important;
  }
  .p60bd-notice .p60bd-notice-x {
    min-width: var(--p60bd-target); min-height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .p60bd-more-notices {
    display: block; font-size: 0.85rem; padding: 0.35rem 0.7rem;
    min-height: 32px;
  }

  /* ---- item 198: search-first header ---- */
  .topbar .topsearch {
    order: -1; flex: 1 1 auto; min-width: 0;
    display: flex; align-items: center; gap: 0.4rem;
  }
  .topbar .topsearch label { flex: 1; flex-direction: row; min-width: 0; }
  .topbar .topsearch input {
    flex: 1; min-width: 0; min-height: var(--p60bd-target);
    font-size: 1rem;
  }
  .topbar .topsearch button {
    min-width: var(--p60bd-target); min-height: var(--p60bd-target);
    flex: none;
  }
  .p60bd-topchrome.p60bd-search-open .topsearch { flex: 1 1 100%; }
  .p60bd-topchrome.p60bd-search-open .p60bd-menubtn,
  .p60bd-topchrome.p60bd-search-open .userbox { display: none; }

  /* ---- item 190: big-target pass ---- */
  .topbar a, .topbar button,
  .sidebar .side-nav a,
  .btn, button, .btn.small, button.btn,
  .pager a, .pager .cur, .pager span.cur,
  .card form button[type="submit"],
  .q-actions .btn,
  select, input[type="text"], input[type="search"],
  input[type="email"], input[type="url"],
  input[type="password"], input[type="number"],
  input[type="date"] {
    min-height: 48px;
  }
  .sidebar .side-nav a {
    display: flex; align-items: center;
    min-height: 48px; padding-top: 0; padding-bottom: 0;
  }
  .btn, button, .btn.small {
    min-width: 48px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .pin-x { min-width: 48px; min-height: 48px; }

  /* ---- the thumb bar is a phone pattern: off on tablet ---- */
  .p60bd-thumbbar { display: none; }

  /* ---- item 192: compact cards, two-up where they fit ---- */
  .p60bd-cardlist {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 0.7rem;
  }
  .p60bd-card {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    grid-template-areas: "art main" "owed owed";
    gap: 0.35rem 0.7rem; align-items: center;
    background: var(--card, #161618);
    border: 1px solid var(--line, #26262b);
    border-radius: var(--radius, 12px);
    padding: 0.6rem 0.7rem; margin: 0;
  }
  .p60bd-card-art {
    grid-area: art; width: 56px; height: 56px;
    border-radius: 8px; object-fit: cover; display: block;
    background: var(--pp-hairline, #26262b);
  }
  .p60bd-card-main { grid-area: main; min-width: 0; }
  .p60bd-card-title {
    font-weight: 700; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis;
  }
  .p60bd-card-status { font-size: 0.85rem; color: var(--muted, #9a968c); }
  .p60bd-card-owed {
    grid-area: owed; font-size: 0.9rem; font-weight: 600;
    color: var(--accent, #f5b301);
  }
  .p60bd-card a, .p60bd-card button { min-height: 48px; }

  /* ---- item 193: sticky action bar (no thumb bar to
     clear on tablet, so it pins to the very bottom) ---- */
  .p60bd-actionbar {
    position: sticky;
    bottom: env(safe-area-inset-bottom);
    z-index: 40;
    display: flex; gap: 0.5rem; flex-wrap: wrap;
    align-items: center;
    background: var(--pp-chrome, rgba(8, 8, 10, 0.96));
    border-top: 1px solid var(--line, #26262b);
    padding: 0.5rem 0.6rem;
    margin: 0 -0.6rem;
  }
  .p60bd-actionbar .btn, .p60bd-actionbar button {
    flex: 1 1 auto; min-height: 48px;
  }

  /* ---- item 205: real tablet two-pane layout ----
     Pages opt in: a p60bd-twopane wrapper holding a
     p60bd-twopane-list and a p60bd-twopane-detail. The
     list stays put (sticky under the slim bar) while the
     detail scrolls — a true two-pane, only in this
     tablet query. */
  .p60bd-twopane {
    display: grid;
    grid-template-columns: minmax(280px, 38%) minmax(0, 1fr);
    gap: 1rem; align-items: start;
  }
  .p60bd-twopane-list {
    position: sticky;
    top: calc(var(--p60bd-chrome-h) + 8px);
    max-height: calc(100vh - var(--p60bd-chrome-h) - 24px);
    overflow-y: auto; min-width: 0;
  }
  .p60bd-twopane-detail { min-width: 0; }

  /* ---- partner shell (pp_base) slimming, same law ---- */
  .pp-head {
    position: sticky; top: 0; z-index: 65;
    min-height: var(--p60bd-bar-h); padding: 4px 14px;
  }
  .pp-head .pp-logo { height: 38px; width: 38px; }
  .pp-nav { display: none; }
  body.p60bd-menu-open .pp-nav {
    display: flex; position: sticky; top: var(--p60bd-bar-h); z-index: 64;
    max-height: 72vh; overflow-y: auto;
  }
  .pp-nav a { min-height: 48px; display: inline-flex; align-items: center; }
}

/* ================================================================
   DESKTOP — min-width 1101px
   Only the elements this workstream adds are hidden here.
   Nothing that existed before this file is restyled.
   ================================================================ */
@media (min-width: 1101px) {
  .p60bd-thumbbar { display: none; }
  .p60bd-menubtn { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .topbar, .sidebar .side-nav { transition: none; }
}
