/* =====================================================================
   STARK-JAMESHA Hologram Desk — phone layout (additive, self-contained)
   ---------------------------------------------------------------------
   Problem this solves: on a phone, EXAMINATION (.panel--right, bottom
   7.5rem), CYPHER (.ops-console, bottom ~11rem) and the PROJECTOR LIBRARY
   rack are all fixed to the lower half of the viewport at once. They
   overlap and squeeze the hologram into the top third of the screen.

   Approach: below 820px, those three become a single bottom sheet with a
   tab bar (DESK / EXAM / CYPHER / LIBRARY). Only one is on screen at a
   time, and DESK shows none of them so the hologram gets the full
   viewport. Nothing is moved in the DOM - panels stay exactly where they
   are and keep their ids, listeners and behaviour; this file only
   repositions them and toggles visibility from a class on <body>.

   Remove by deleting the desk-mobile.css <link> and deskMobile.js
   <script> from index.html. Nothing else depends on it.
   ===================================================================== */

@media (max-width: 820px) {

  /* ---- tab bar ------------------------------------------------------ */

  .mtabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: flex;
    gap: 1px;
    background: rgba(3, 10, 16, 0.96);
    border-top: 1px solid var(--accent-dim, rgba(0, 200, 240, 0.35));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    backdrop-filter: blur(6px);
  }

  .mtabs__btn {
    flex: 1 1 0;
    /* 44px minimum touch target */
    min-height: 44px;
    padding: 0.5rem 0.25rem;
    background: transparent;
    border: 0;
    border-top: 2px solid transparent;
    color: var(--fg-dim, #6fb8c9);
    font-family: 'Share Tech Mono', ui-monospace, monospace;
    font-size: 12px;
    letter-spacing: 1.5px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mtabs__btn[aria-selected="true"] {
    color: var(--accent, #00c8f0);
    border-top-color: var(--accent, #00c8f0);
    background: rgba(0, 200, 240, 0.08);
  }

  /* ---- shared bottom-sheet treatment -------------------------------- */

  .panel--right,
  .ops-console,
  .asset-rack {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    width: auto !important;
    max-width: none !important;
    /* sit directly on top of the tab bar */
    bottom: calc(44px + env(safe-area-inset-bottom, 0px)) !important;
    top: auto !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    max-height: 58vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    z-index: 55;
  }

  /* Default (DESK tab): hide all three, hologram gets the whole screen */
  .panel--right,
  .ops-console,
  .asset-rack {
    display: none !important;
  }

  body.mtab-exam .panel--right { display: block !important; }
  body.mtab-cypher .ops-console { display: block !important; }
  body.mtab-lib .asset-rack { display: block !important; }

  /* The left dossier panel stays out of the way on phones (the base
     stylesheet already hides it under 560px; do it for all phone widths
     so the tab set stays predictable). */
  .panel--left {
    display: none !important;
  }

  /* Desktop keyboard hints are not useful on a touch device and cost
     vertical space at the bottom of the screen. */
  .hud-bottom {
    display: none !important;
  }

  /* ---- per-panel tweaks --------------------------------------------- */

  /* CYPHER must never be collapsed-by-JS *and* hidden by the tab system
     at the same time, or the tab would look broken. Force it open when
     its tab is active. */
  body.mtab-cypher .ops-console .ops-console__body {
    display: block !important;
  }

  body.mtab-cypher .ops-console__toggle {
    display: none;
  }

  .ops-console {
    --ops-width: auto;
  }

  .ops-log {
    max-height: 26vh;
  }

  /* Bigger touch targets inside the ops console */
  .ops-chips button,
  .ops-ptt,
  .ops-form button,
  .ops-voice-row button,
  .ops-console__mode,
  .ops-console__tts,
  .ops-console__wake {
    min-height: 40px;
  }

  .ops-input {
    min-height: 40px;
    /* 16px prevents iOS Safari from auto-zooming on focus */
    font-size: 16px;
  }

  .ops-voice-select {
    min-height: 40px;
    font-size: 14px;
  }

  /* Asset rack: comfortable 2-up grid instead of cramped wrapping flex */
  .asset-rack__row {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .asset-btn {
    min-width: 0 !important;
    min-height: 56px;
    flex: none !important;
  }

  /* EXAMINATION controls: full-width rows, larger hit areas */
  .panel--right .panel__body--controls {
    padding-bottom: 0.75rem;
  }

  .panel--right input[type="range"] {
    width: 100%;
    min-height: 36px;
  }

  /* Control rows: stack label above input so sliders get full width */
  .panel--right .ctrl {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .panel--right .ctrl input[type="range"] {
    flex: 1 1 55%;
  }

  .panel--right .ctrl input[type="checkbox"] {
    /* easier to hit than the default ~13px box */
    width: 22px;
    height: 22px;
  }

  /* Camera presets (Home / Front / Edge / Back) -> 2x2 grid */
  .view-seg {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
  }

  .view-seg__btn {
    min-height: 44px;
  }

  /* ---- top HUD: keep it compact so the stage stays tall ------------- */

  .hud-top {
    padding: 0.4rem 0.6rem;
  }

  .hud-top__center {
    display: none;
  }
}

/* Very small phones: give the sheet a little more room and tighten type */
@media (max-width: 380px) {
  .mtabs__btn {
    font-size: 11px;
    letter-spacing: 1px;
  }

  .panel--right,
  .ops-console,
  .asset-rack {
    max-height: 62vh;
  }
}

/* Landscape phones are short: cap the sheet so the hologram stays visible */
@media (max-width: 920px) and (orientation: landscape) {
  .panel--right,
  .ops-console,
  .asset-rack {
    max-height: 70vh;
  }

  .ops-log {
    max-height: 30vh;
  }
}

/* Respect reduced-motion preferences for the sheet transition */
@media (prefers-reduced-motion: reduce) {
  .mtabs__btn {
    transition: none !important;
  }
}
