/* ============================================================================
   P2 v5 · screen chrome                                           p2-chrome.css
   The top bar in the style of an earlier prototype after its review (title at the left, a wide
   centred search with a Filter button, compact icon toggles at the right), the
   Regions popover (the three region cards, hidden until used), and the one
   movable pulse panel (banner, simulated clock, CLOCK and MOTION log sliders,
   playback buttons, the sampling numbers). Day and night use the page tokens.
   ========================================================================== */

/* ---- the top bar: brand · search · icons, full width; the inspector and the tool rail start under it ---- */
#top { position: fixed; z-index: 85; left: 10px; right: 10px; top: calc(10px + env(safe-area-inset-top, 0px)); height: 48px; box-sizing: border-box;
       display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 620px) minmax(max-content, 1fr); align-items: center; gap: 12px; padding: 5px 8px 5px 12px; }
#brand { min-width: 0; overflow: hidden; }
#brand h1 { margin: 0; font: 700 18px/1.1 var(--display); color: var(--ink); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#brand h1 span { color: var(--accent); }
#brand .sub { font: 10px/1.3 var(--mono); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tb-icons { justify-self: end; display: flex; align-items: center; gap: 3px; }
#tb-icons .sep { width: 1px; height: 26px; background: var(--line-2); margin: 0 3px; }

/* icon toggles: one footprint (an icon, a state word under it), a tooltip and an aria-label with the state */
.ibtn { width: 36px; height: 36px; padding: 3px 0 2px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center; color: var(--ink); }
.ibtn .ic { font: 700 15px/1 var(--body); }
.ibtn .st8 { font: 600 8.5px/1 var(--mono); letter-spacing: .02em; text-transform: lowercase; max-width: 34px; overflow: hidden; color: var(--ink-2); }
.ibtn:hover .st8 { color: var(--ink); }
.ibtn[aria-pressed="true"] .st8, .ibtn[aria-expanded="true"] .st8 { color: var(--bg); }
.btn.ibtn[aria-expanded="true"] { color: var(--bg); border-color: var(--ink); background: var(--ink); }
#btn-fp[data-state="pick"] { background: var(--warn); border-color: var(--warn); color: #fff; }
#btn-fp[data-state="pick"] .st8 { color: #fff; }
#simtoggle-slot { display: flex; }
#simtoggle-slot .mw-sim-pill { box-sizing: border-box; width: 40px; height: 36px; padding: 3px 0 2px !important; display: inline-flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 0 !important; box-shadow: none; white-space: nowrap; }
#simtoggle-slot .mw-sim-pill::before { content: '∿'; font: 700 16px/1 var(--body); color: var(--warn); }
#simtoggle-slot .mw-sim-pill i { display: none; }
#simtoggle-slot .mw-sim-pill span { font-size: 0 !important; line-height: 1; }
#simtoggle-slot .mw-sim-pill span b { font: 700 8.5px/1 var(--mono) !important; text-transform: uppercase; color: var(--ink); }
#simtoggle-slot .mw-sim-pill span b::before { content: 'sim '; }
#simtoggle-slot .mw-sim-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#btn-search { display: none; }

/* ---- search: wide, centred, strong contrast, the dropdown above every overlay (the top bar is z 85, the list z 90) ---- */
#searchbox { position: relative; min-width: 0; width: 100%; }
#search-row { display: flex; gap: 5px; }
#search { flex: 1 1 auto; min-width: 0; box-sizing: border-box; height: 36px; font: 600 13px var(--body); padding: 0 11px 0 32px; color: var(--ink); border: 2px solid var(--accent); border-radius: 3px;
          background: radial-gradient(circle, transparent 0 3.6px, var(--accent) 3.9px 5.3px, transparent 5.6px) no-repeat 8px calc(50% - 2px) / 12px 12px, linear-gradient(45deg, transparent 0 38%, var(--accent) 38% 62%, transparent 62%) no-repeat 16.5px calc(50% + 4px) / 6px 6px, var(--surface); }
#search::placeholder { color: var(--ink-2); opacity: 1; font-weight: 600; }
#search:focus, #search:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
#btn-filter { height: 36px; padding: 0 12px; font: 700 12px/1 var(--body); color: var(--ink); border: 2px solid var(--line-2); display: inline-flex; align-items: center; gap: 5px; }
#btn-filter[aria-pressed="true"] { color: var(--bg); border-color: var(--accent); background: var(--accent); }
#btn-filter .n { font: 700 10px/1 var(--mono); padding: 2px 4px; background: var(--bg); color: var(--ink); }
#search-results { position: absolute; z-index: 90; left: 0; right: 0; top: calc(100% + 5px); min-width: 380px; max-height: min(62vh, 520px); overflow: auto; margin: 0; padding: 0; list-style: none;
                  background: var(--surface); border: 2px solid var(--accent); box-shadow: 0 14px 34px rgba(7,17,36,.35); }
#search-results li { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px 7px 11px; border-bottom: 1px solid var(--line); border-left: 4px solid transparent; cursor: pointer; }
#search-results li b { font: 700 12.5px var(--body); color: var(--ink); word-break: break-word; }
#search-results li span { font: 500 10.5px var(--mono); color: var(--ink-2); }
#search-results li[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); border-left-color: var(--accent); }
#search-results li:hover { background: var(--surface-2); }
#search-results li.sr-head { cursor: default; flex-direction: row; flex-wrap: wrap; gap: 2px 6px; padding: 6px 10px; background: var(--chip-bg); font: 500 10.5px/1.35 var(--mono); color: var(--ink-2); }
#search-results li.sr-head b { font: 700 10.5px var(--mono); }

/* ---- the Regions chip and its popover (the three region cards, visibility, Parity, scale); hidden until used ---- */
#countries-wrap { position: relative; display: flex; }
#countries-pop { position: absolute; z-index: 92; right: 0; top: calc(100% + 9px); width: 304px; box-sizing: border-box; padding: 8px; display: flex; flex-direction: column; gap: 6px;
                 background: var(--surface); border: 1px solid var(--line-2); box-shadow: 0 14px 34px rgba(7,17,36,.32); font-size: 11.5px; color: var(--ink-2); }
#countries-pop[hidden] { display: none; }
#countries-pop::before { content: ''; position: absolute; right: 13px; top: -7px; width: 12px; height: 12px; background: var(--surface); border-left: 1px solid var(--line-2); border-top: 1px solid var(--line-2); transform: rotate(45deg); }
.cp-head { display: flex; align-items: baseline; gap: 6px; }
.cp-head b { font: 700 13px var(--display); color: var(--ink); }
.cp-head span { flex: 1; font: 500 10px/1.3 var(--mono); color: var(--ink-2); }
.cp-head button, #cp-parity button { all: unset; box-sizing: border-box; cursor: pointer; font: 600 11px/1 var(--body); color: var(--ink); border: 1px solid var(--line-2); background: var(--surface); padding: 5px 7px; }
.cp-head button:focus-visible, #cp-parity button:focus-visible, .cp-scale select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#hud-countries { display: flex; flex-direction: column; gap: 4px; }
.hud-c { display: flex; align-items: stretch; border: 1px solid var(--line-2); background: var(--surface); }
.hud-c.off { opacity: .62; }
.hud-c.stacked { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.hud-go { all: unset; box-sizing: border-box; cursor: pointer; flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 5px 8px; font: 500 10px/1.3 var(--mono); color: var(--ink-2); }
.hud-go:hover { background: var(--surface-2); }
.hud-go b { font: 700 12.5px/1.2 var(--display); color: var(--ink); }
.hud-go b i { font: 500 10px var(--mono); color: var(--ink-2); font-style: normal; }
.hud-go:focus-visible, .hud-eye:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.hud-eye { all: unset; box-sizing: border-box; cursor: pointer; width: 34px; display: grid; place-items: center; border-left: 1px solid var(--line-2); color: var(--ink); font: 700 15px/1 var(--body); }
.hud-eye[aria-pressed="false"] { color: var(--ink-2); }
.hud-sim { color: var(--warn); white-space: normal; }
#cp-parity { display: flex; align-items: center; gap: 0; }
#cp-parity button { border-right-width: 0; padding: 6px 8px; }
#cp-parity button:last-child { border-right-width: 1px; }
#cp-parity button[aria-checked="true"] { color: var(--bg); background: var(--ink); border-color: var(--ink); }
.cp-k { font: 700 10px/1 var(--mono); color: var(--ink); text-transform: uppercase; letter-spacing: .05em; width: 52px; flex: 0 0 auto; }
.cp-scale { display: flex; align-items: center; }
.cp-scale select { flex: 1 1 auto; min-width: 0; font: 600 11px var(--mono); background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); padding: 4px; }

/* ---- the pulse panel: one movable panel (left/top set by p2-app.js; docked = top centre of the free band) ---- */
#pulsedock { position: fixed; z-index: 43; left: calc(50% - 220px); top: calc(66px + env(safe-area-inset-top, 0px)); width: 440px; box-sizing: border-box; display: flex; flex-direction: column; border-left: 3px solid var(--warn); }
:root:not(.p2-sim) #pulsedock { display: none; }
#pulsedock.dragging { box-shadow: 0 18px 44px rgba(7,17,36,.38); opacity: .96; }
#pp-head { display: flex; align-items: center; gap: 6px; padding: 4px 5px 4px 6px; cursor: grab; user-select: none; touch-action: none; border-bottom: 1px solid var(--line);
           background: repeating-linear-gradient(135deg, var(--simhatch) 0 8px, transparent 8px 16px); }
#pp-head:active { cursor: grabbing; }
#pp-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#pp-head .grip { width: 10px; height: 16px; flex: 0 0 auto; opacity: .7; background: radial-gradient(circle, var(--ink-2) 1.1px, transparent 1.4px) 0 0 / 5px 5px; }
#simbanner-slot { flex: 1 1 auto; min-width: 0; display: flex; pointer-events: none; }
#simbanner-slot .mw-sim-banner { margin: 0; padding: 2px 8px; box-shadow: none; justify-content: flex-start; text-align: left; font-size: 10.5px; letter-spacing: .05em; max-width: 100%; }
#simbanner-slot .mw-sim-banner small { flex-basis: 100%; min-width: 0; font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#pp-sum { display: none; font: 700 10.5px/1 var(--mono); color: var(--ink); white-space: nowrap; }
#pp-sum i { font-style: normal; color: var(--ink-2); font-weight: 500; }
#pp-head button { all: unset; box-sizing: border-box; cursor: pointer; flex: 0 0 auto; width: 26px; height: 24px; display: grid; place-items: center; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: 700 12px var(--body); }
#pp-head button:hover { border-color: var(--accent); }
#pp-head button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#pulsedock[data-place="docked"] #pp-dock { opacity: .55; }
#pp-body { display: flex; flex-direction: column; gap: 3px; padding: 0 0 7px; }
/* the shared simulated clock lives inside the panel: play / pause, the UTC time, capture, the scrub with incident ticks */
#simclock-slot .mw-sim-clock { width: 100%; box-sizing: border-box; border: 0; border-bottom: 1px solid var(--line); box-shadow: none; background: transparent; backdrop-filter: none; padding: 6px 10px 6px; gap: 4px; }
/* its speed select is replaced by the CLOCK slider below (play, scrub and capture stay) */
#simclock-slot .mw-sim-clock select { display: none; }
/* CLOCK and MOTION: label · log slider with ticks · current value */
.pp-sl { display: grid; grid-template-columns: 62px 1fr 50px; align-items: center; gap: 8px; padding: 2px 10px 0; }
.pp-sl label { display: flex; flex-direction: column; gap: 2px; cursor: default; }
.pp-sl label b { font: 700 11px/1 var(--mono); color: var(--ink); text-transform: uppercase; letter-spacing: .06em; }
.pp-sl label small { font: 500 9.5px/1 var(--body); color: var(--ink-2); }
.pp-sl output { font: 700 15px/1 var(--mono); color: var(--ink); text-align: right; }
.pp-track { position: relative; padding-bottom: 13px; }
.pp-track input[type=range] { width: 100%; margin: 0; accent-color: var(--warn); cursor: pointer; }
#sl-motion { accent-color: var(--accent); }
.pp-track input[type=range]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pp-ticks { position: absolute; left: 8px; right: 8px; bottom: 0; height: 12px; pointer-events: none; }
.pp-ticks .tk { position: absolute; top: 0; width: 1px; height: 3px; background: var(--ink-2); }
.pp-ticks .tk.lab { height: 4px; background: var(--ink); }
.pp-ticks .tk b { position: absolute; top: 4px; left: 0; transform: translateX(-50%); font: 500 8.5px/1 var(--mono); color: var(--ink-2); white-space: nowrap; }
.pp-cap { margin: 0; padding: 1px 10px 0; font: 500 10px/1.35 var(--body); color: var(--ink-2); }
.pp-cap b { color: var(--ink); font-weight: 700; }
.pp-btns { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 2px 10px 0; }
.pbb { all: unset; box-sizing: border-box; cursor: pointer; font: 600 11px/1 var(--body); color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); padding: 6px 8px; min-width: 30px; text-align: center; }
.pbb:hover { border-color: var(--accent); }
.pbb:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#pb-play[aria-pressed="true"] { background: var(--warn); color: #fff; border-color: var(--warn); }
:root[data-theme="night"] #pb-play[aria-pressed="true"] { color: #1a1206; }
.pp-keys { margin-left: auto; font: 500 9.5px/1.3 var(--mono); color: var(--ink-2); }
.pp-keys kbd { font-size: 9px; padding: 0 3px; }
#playback.paused #pb-play { box-shadow: 0 0 0 2px color-mix(in srgb, var(--warn) 40%, transparent); }
#pb-sampling { margin: 3px 10px 0; padding: 4px 6px; font: 500 10px/1.4 var(--mono); color: var(--ink-2); border-left: 3px solid var(--warn); background: repeating-linear-gradient(135deg, var(--simhatch) 0 6px, transparent 6px 12px); }
#pb-sampling b { color: var(--ink); }
#pb-sampling .simw { color: var(--warn); font-weight: 700; letter-spacing: .04em; }
:root[data-theme="day"] #pb-sampling .simw { color: #8a5100; }
#pb-sampling .l2 { display: block; margin-top: 2px; font-size: 9.5px; }
/* collapsed: the header only, a chip that still says SIMULATED and both speeds */
#pulsedock.collapsed { width: auto; max-width: 440px; }
#pulsedock.collapsed #pp-body { display: none; }
#pulsedock.collapsed #pp-head { border-bottom: 0; }
#pulsedock.collapsed #simbanner-slot { flex: 0 0 auto; }
#pulsedock.collapsed #simbanner-slot .mw-sim-banner { padding: 1px 6px; font-size: 9.5px; letter-spacing: 0; white-space: nowrap; flex-wrap: nowrap; }
#pulsedock.collapsed #simbanner-slot .mw-sim-banner small { display: none; }
#pulsedock.collapsed #pp-sum { display: inline; font-size: 10px; }
#pulsedock.collapsed #pp-head { gap: 5px; }
#pulsedock.collapsed #pp-dock { display: none; }

/* ---- narrower desktops ---- */
@media (max-width: 1240px) { #brand .sub { display: none; } #top { grid-template-columns: minmax(0, 1fr) minmax(300px, 560px) minmax(max-content, 1fr); } }
@media (max-width: 1000px) and (min-width: 760px) { #brand h1 span { display: none; } #top { gap: 8px; } #tb-icons .sep { display: none; } }

/* ---- phone: icons only in the bar; the search opens under it; the popover and the pulse panel are full width ---- */
@media (max-width: 759px) {
  #top { left: 8px; right: 8px; top: calc(8px + env(safe-area-inset-top, 0px)); height: 44px; display: flex; gap: 3px; padding: 4px 5px; }
  #brand { display: none; }
  #tb-icons { flex: 1 1 auto; justify-content: space-between; gap: 2px; }
  #btn-fp, #btn-tour, #tb-icons .sep { display: none; }
  .ibtn { width: 32px; height: 34px; } #simtoggle-slot .mw-sim-pill { width: 36px; height: 34px; }
  #btn-search { display: inline-flex; }
  #searchbox { display: none; position: absolute; left: -1px; right: -1px; top: calc(100% + 4px); width: auto; padding: 6px; box-sizing: border-box; background: var(--surface); border: 1px solid var(--accent); }
  .p2-search-open #searchbox { display: block; }
  #search { font-size: 16px; }
  #search-results { position: absolute; left: 0; right: 0; min-width: 0; max-height: calc(100vh - 300px); }
  #countries-wrap { position: static; }
  #countries-pop { position: absolute; left: -1px; right: -1px; width: auto; top: calc(100% + 4px); }
  #countries-pop::before { display: none; }
  #pulsedock { left: 8px !important; right: 8px; top: calc(58px + env(safe-area-inset-top, 0px)) !important; width: auto; max-width: none; border-left-width: 3px; }
  #pulsedock.collapsed { width: auto; max-width: none; }
  #pp-dock, #pp-head .grip, .pp-keys, .pp-cap { display: none; }
  #pp-head { cursor: default; }
  #simclock-slot .mw-sim-clock { padding: 4px 8px; }
  .pp-sl { grid-template-columns: 52px 1fr 42px; gap: 6px; padding: 1px 8px 0; }
  #pb-sampling { margin: 2px 8px 0; }
  #pb-sampling .l2 { display: none; }
  .pp-btns { padding: 2px 8px 0; }
}
