/*
 * Device mode (js/device-mode.js): the prototype full screen on a real phone.
 * Everything is scoped to body.device-mode, so the framed desktop view is untouched.
 * The pill and sheet are Director tooling, so they use the Director Bar's dark
 * "tool" palette on purpose, never product tokens.
 */

/* ---------- platform baseline (mobile-native) ---------- */
html:has(body.device-mode) {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body.device-mode { overscroll-behavior: none; }
body.device-mode :is(button, a, [role="button"], select) { touch-action: manipulation; }
body.device-mode :is(button, [role="button"], .tabs__item, .chip) { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
/* iOS zooms into inputs under 16px and never zooms back. */
body.device-mode :is(input, textarea, select) { font-size: 16px; }

/* ---------- drop the Director Bar and the fake device frame ---------- */
body.device-mode #director { display: none; }
body.device-mode .stage { padding: 0; height: 100dvh; overflow: hidden; display: block; }
body.device-mode .frame-box { width: 100%; height: 100%; }
/* main.js layout() sizes the frame with inline styles for the scaled 390×844 view; the real screen wins here. */
body.device-mode #screen { width: 100% !important; height: 100% !important; transform: none !important; }
body.device-mode .device--phone { border-radius: 0; box-shadow: none; }
body.device-mode .device--phone .device__screen { border-radius: 0; }

/* Real status bar and home indicator instead of the drawn ones. */
body.device-mode .statusbar { padding: env(safe-area-inset-top, 0px) 0 0; min-height: 0; }
body.device-mode .statusbar > * { display: none; }
body.device-mode .tabs { height: calc(var(--size-bottom-tabs) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); }
/* 72px leaves room under the last row for the floating pill. */
body.device-mode .app__main { overscroll-behavior: contain; padding-bottom: calc(var(--space-8) + 72px + env(safe-area-inset-bottom, 0px)); }
body.device-mode .app__main:has(.sticky-cta) { padding-bottom: 0; }
body.device-mode .app:not(.app--tabs) .sticky-cta { padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px)); }

/* Spec & notes drawer goes full screen. */
body.device-mode.drawer-open .stage { padding-right: 0; }
body.device-mode .drawer { top: 0; width: 100%; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); overscroll-behavior: contain; }
body.device-mode.drawer-open .dm-pill { display: none; }

/* ---------- floating pill ---------- */
.dm-pill {
  --dm-y: 0px;
  position: fixed; z-index: 90; left: 50%;
  /* --dm-base clears the tab bar / sticky CTA (set in JS); --dm-y is how far the user dragged it up. */
  bottom: calc(var(--dm-base, 16px) + var(--dm-y));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  width: min(330px, calc(100vw - 32px)); padding: 6px 6px 6px 8px;
  border: 1px solid #353a48; border-radius: 999px;
  background: rgba(17, 19, 24, 0.92); color: #e7e9ee;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
  font: 13px/1.2 var(--font-ui); text-align: left; cursor: pointer;
  touch-action: none; /* the pill owns vertical drags */
  transition: transform 120ms var(--ease-standard), box-shadow 120ms var(--ease-standard);
}
.dm-pill:active { transform: translateX(-50%) scale(0.97); }
.dm-pill.is-dragging { transition: none; transform: translateX(-50%) scale(1.03); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45); }
.dm-pill__mark { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #172e60; color: #f7f4ec; font: 18px var(--font-brand); }
.dm-pill__text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.dm-pill__title, .dm-pill__sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-pill__title { font-weight: 600; }
.dm-pill__sub { color: #9aa1b2; font-size: 11.5px; }
.dm-pill__btn { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: #f3c24f; color: #111318; }

/* ---------- bottom sheet ---------- */
.dm-scrim { position: fixed; inset: 0; z-index: 91; background: rgba(10, 11, 14, 0.45); opacity: 0; transition: opacity var(--duration-overlay) var(--ease-exit); }
.dm-sheet {
  position: fixed; z-index: 92; left: 0; right: 0; bottom: 0;
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 24px); overflow-y: auto; overscroll-behavior: contain;
  display: grid; gap: 14px;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: #15171d; color: #e7e9ee; border-top: 1px solid #2b2f3a; border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.4);
  font: 14px/1.3 var(--font-ui);
  transform: translateY(100%);
  transition: transform 180ms var(--ease-exit);
}
.dm.is-open .dm-scrim { opacity: 1; transition: opacity var(--duration-overlay) var(--ease-enter); }
.dm.is-open .dm-sheet { transform: none; transition: transform 300ms var(--ease-enter); }
.dm-sheet__grip { width: 40px; height: 5px; border-radius: 3px; background: #3a3f4c; margin: 0 auto; }
.dm-sheet__head { display: flex; align-items: center; justify-content: space-between; }
.dm-sheet__head h2 { font: 400 20px var(--font-brand); color: #fff; }
.dm-field { display: grid; gap: 6px; }
.dm-field > span { color: #9aa1b2; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.dm-sheet select {
  width: 100%; min-width: 0; height: 44px; padding: 0 10px;
  background: #1e222c; color: #e7e9ee; border: 1px solid #353a48; border-radius: 10px;
}
.dm-seg { display: flex; gap: 6px; }
.dm-seg--wrap { flex-wrap: wrap; }
.dm-seg__btn, .dm-btn {
  min-height: 44px; padding: 0 14px; border-radius: 10px;
  background: #1e222c; color: #c9cdd8; border: 1px solid #353a48; cursor: pointer;
  transition: transform 100ms var(--ease-standard), background 100ms;
}
.dm-seg__btn:active, .dm-btn:active { transform: scale(0.97); background: #2a2f3b; }
.dm-seg__btn[aria-pressed="true"] { background: #f3c24f; color: #111318; border-color: #f3c24f; }
.dm-jump { display: flex; gap: 6px; }
.dm-jump select { flex: 1; }
.dm-jump .dm-btn { flex: none; width: 44px; padding: 0; font-size: 20px; }
.dm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dm-btn--primary { grid-column: 1 / -1; background: #f3c24f; color: #111318; border-color: #f3c24f; font-weight: 600; }
.dm-btn--primary:active { background: #e0b03f; }
.dm-btn--icon { width: 40px; min-height: 40px; padding: 0; border-radius: 50%; }
.dm-count { display: inline-block; min-width: 18px; margin-left: 4px; padding: 1px 6px; border-radius: 9px; background: #111318; color: #f3c24f; font-size: 11px; }
.dm-hint { color: #9aa1b2; font-size: 12px; }

@media (prefers-reduced-motion: reduce) {
  .dm-pill, .dm-scrim, .dm-sheet, .dm.is-open .dm-scrim, .dm.is-open .dm-sheet, .dm-seg__btn, .dm-btn { transition: none; }
}
