/* ════════════════════════════════════════════════════════
   FIFTHS — Responsive Layer
   Portrait-only mobile. Landscape shows a rotate prompt.
   Width-based queries so DevTools emulation works cleanly.
════════════════════════════════════════════════════════ */


/* ══ PORTRAIT LOCK ═══════════════════════════════════════
   Any touch-sized viewport in landscape: hide everything
   and show a polite "rotate" message. No layout to maintain.
════════════════════════════════════════════════════════ */
@media (max-width: 1024px) and (orientation: landscape) and (hover: none) and (pointer: coarse) {
  #app,
  #screen-landing            { display: none !important; }

  body::after {
    content:         "↻  Rotate to portrait";
    position:        fixed;
    inset:           0;
    z-index:         9999;
    background:      #0d0c16;
    color:           #555;
    font-size:       14px;
    font-family:     'Space Mono', monospace;
    letter-spacing:  0.12em;
    text-transform:  uppercase;
    display:         flex;
    align-items:     center;
    justify-content: center;
  }
}


/* ══ TABLET + PHONE (≤ 1024px) ═══════════════════════════
   Shared rules for anything smaller than a laptop.
════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {

  /* Build mode: not relevant at a jam */
  #v3-btn-build              { display: none !important; }
  #mode-build                { display: none !important; }

  /* Advanced controls panel: JS controls display via inline style.
     Never lock it with !important — that blocks the toggle.
     Button is hidden here; re-enabled as a pill on phone below. */
  #ui-adv                    { display: none !important; }

  /* Subtabs: easier to tap */
  .subtab                    { padding: 10px 6px; }

  /* Picker: full-width slide-up */
  .picker-panel {
    width:         100vw;
    border-radius: 16px 16px 0 0;
    max-height:    90vh;
  }

  /* Position map sidebar: not useful without a mouse */
  #pane-position             { display: none !important; }

  /* Touch-safe minimum tap sizes */
  .strum-btn  { min-height: 36px; }
  .capo-btn   { min-height: 30px; }
  .pos-btn    { min-height: 30px; min-width: 28px; }
  .tweak-btn  { min-height: 32px; }
  .sh-btn     { min-height: 30px; }
}


/* ══ DESKTOP (> 599px) — gear hidden, settings always open ══
════════════════════════════════════════════════════════ */
@media (min-width: 600px) {
  .gear-btn        { display: none !important; }
  .beat-gear-row   { display: none !important; }
  .settings-panel  { display: flex !important; flex-direction: column; }
  .sx-player-row   {
    display:         flex;
    flex-direction:  row;
    align-items:     center;
    justify-content: center;
    gap:             10px;
    padding:         8px 16px 10px;
  }
  .sx-stepper { display: flex; align-items: center; gap: 8px; }
  .settings-row {
    display:         flex;
    flex-wrap:       wrap;
    gap:             6px;
    align-items:     center;
    justify-content: center;
    padding:         4px 8px;
  }
  .divider-v   { width: 1px; height: 14px; background: var(--border); flex-shrink: 0; }
  .settings-label {
    font-size: 10px; letter-spacing: 1.5px;
    text-transform: uppercase; color: var(--dim2); flex-shrink: 0;
  }
  .play-step-btn { padding: 8px 18px !important; font-size: 11px !important; }
}



/* ══ PHONE PORTRAIT (≤ 599px) ════════════════════════════
   Single-column layout. All three tabs accessible.
════════════════════════════════════════════════════════ */
@media (max-width: 599px) {

  html, body  { overflow: auto; }
  #app        { overflow: hidden; }

  /* Solo tab: visible on phone — it's a core screen */
  /* (no hide rule — all three subtabs shown) */

  /* Advanced controls: voicing params need a mouse to be useful.
     The gear-based settings panel handles touch-mode settings.
     Keep the button and wrap hidden on all touch devices. */
  /* #ui-adv stays hidden from the ≤1024px rule above */


  /* ── Landing ──────────────────────────────────────────── */
  #screen-landing > div  { padding: 28px 20px; }


  /* ── Header ───────────────────────────────────────────── */
  .app-header            { padding: 5px 8px; gap: 4px; }
  .logo                  { font-size: 16px; letter-spacing: 3px; margin-right: 4px; }
  .logo span             { display: none; }
  .header-instruments {
    overflow-x:               auto;
    -webkit-overflow-scrolling: touch;
    gap:                      0;
    scrollbar-width:          none;
  }
  .header-instruments::-webkit-scrollbar { display: none; }
  .inst-btn              { padding: 5px 8px; font-size: 10px; flex-shrink: 0; }


  /* ── Now-playing bar ──────────────────────────────────── */
  .now-playing-bar  { height: 32px; gap: 6px; }
  .np-home-btn      { padding: 0 10px; font-size: 10px; letter-spacing: 1px; }
  .np-label         { display: none; }
  .np-pick-btn      { font-size: 8px; padding: 0 12px; letter-spacing: 1px; }


  /* ── Controls strip ───────────────────────────────────────
     Keep positions scrollable + "all controls" as a subtle
     pill at the far right. No label clutter.
  ─────────────────────────────────────────────────────── */
  .controls-strip {
    padding:    2px 8px;
    gap:        4px;
    flex-wrap:  nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-bottom: 1px solid var(--border);
  }
  .controls-strip::-webkit-scrollbar { display: none; }

  /* Hide the "Where on the neck?" label — positions speak for themselves */
  .cs-lbl     { display: none; }
  .cs-sep     { display: none; }

  /* Position buttons: compact but tappable */
  .pos-btn    { min-width: 26px; padding: 5px 2px; font-size: 8px; }

  /* "all controls ▾" — small pill, pushed right, low visual weight */
  #ui-adv {
    margin-left:   auto;
    flex-shrink:   0;
    font-size:     7px;
    padding:       3px 10px;
    min-height:    22px;
    line-height:   1;
    border-radius: 20px;
    opacity:       0.6;
    white-space:   nowrap;
    border:        1px solid rgba(255,255,255,0.12);
  }
  #ui-adv:active { opacity: 1; }


  /* ── Reasoning bar ────────────────────────────────────── */
  /* Hide the hint text on phone — screen space is precious */
  .reasoning-bar  { display: none; }


  /* ── Subtabs ──────────────────────────────────────────── */
  .subtab  { font-size: 8px; letter-spacing: 1px; padding: 10px 4px; }


  /* ── Sidebar → horizontal key + position strip ────────── */
  #pane-progressions         { flex-direction: column !important; }

  .play-sidebar {
    width:                    100%;
    flex-direction:           row;
    align-items:              center;
    padding:                  6px 10px;
    border-right:             none;
    border-bottom:            1px solid var(--border);
    height:                   auto;
    flex-shrink:              0;
    gap:                      12px;
    overflow-x:               auto;
    -webkit-overflow-scrolling: touch;
    background:               var(--surf3);
    scrollbar-width:          none;
  }
  .play-sidebar::-webkit-scrollbar { display: none; }

  .sb-sec {
    flex-direction: row;
    align-items:    center;
    gap:            6px;
    flex-shrink:    0;
  }
  .sb-lbl {
    font-size:      7px;
    letter-spacing: 1.5px;
    white-space:    nowrap;
  }

  /* Key circles */
  .key-btns-sidebar {
    flex-direction: row;
    flex-wrap:      nowrap;
    gap:            4px;
  }
  .key-btns-sidebar .circ {
    width:      32px;
    height:     32px;
    font-size:  9px;
    flex-shrink: 0;
  }

  /* Capo strip: first in row */
  .sb-sec:has(.capo-btns) { order: -1; flex-shrink: 0; }
  .capo-btns {
    flex-direction: row;
    flex-wrap:      nowrap;
    gap:            3px;
  }
  .capo-btn {
    width:       auto;
    padding:     5px 8px;
    white-space: nowrap;
    flex-shrink: 0;
  }


  /* ── Chord cards: 2-per-row, centered ────────────────── */
  .prog-scroll  { padding: 8px 8px 4px; }
  .prog-row     { gap: 8px; justify-content: center; }
  .prog-col     { width: calc(50% - 8px); flex-shrink: 0; }
  .prog-card    { padding: 8px 6px; }
  .cname        { font-size: 20px; }
  .ctab         { font-size: 10px; }

  /* Legend: center the interval dot row */
  .legend {
    display:         flex;
    flex-wrap:       wrap;
    justify-content: center;
    gap:             4px;
    padding:         6px 12px;
    text-align:      center;
  }


  /* ── Play Along + Solo panels ─────────────────────────── */


  /* Dashboard tiles */
  .dash-num   { font-size: clamp(22px, 7vw, 34px); }
  .dash-roman { font-size: clamp(22px, 7vw, 34px); }
  .dash-lbl   { font-size: 10px; letter-spacing: 2px; }

  /* Legend: hide */
  #play-legend { display: none !important; }

  /* ── BEAT + GEAR ROW ──────────────────────────────────── */
  .beat-gear-row {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding:         6px 12px;
    border-top:      1px solid var(--border);
  }
  .beat-dot { width: 10px; height: 10px; }
  .gear-btn {
    font-size:      8px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color:          var(--dim);
    background:     transparent;
    border:         1px solid var(--border);
    border-radius:  20px;
    padding:        4px 10px;
    cursor:         pointer;
  }
  .gear-btn:hover { color: var(--gold); border-color: rgba(232,199,106,0.4); }

  /* ── SETTINGS PANEL: hidden until tapped ─────────────── */
  .settings-panel {
    display:        none;
    flex-direction: column;
    gap:            0;
    border-top:     1px solid var(--border);
    background:     rgba(255,255,255,0.02);
  }
  .settings-panel.open { display: flex; }

  .settings-row {
    display:         flex;
    flex-wrap:       wrap;
    gap:             6px;
    align-items:     center;
    justify-content: center;
    padding:         8px 12px;
  }
  .settings-label {
    font-size:      7px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color:          var(--dim2);
    flex-shrink:    0;
  }
  .divider-v {
    width:      1px;
    height:     14px;
    background: var(--border);
    flex-shrink: 0;
  }

  /* SEE + HEAR row inside settings panel */
  .sh-row {
    display:         grid !important;
    grid-template-columns: 1fr 1fr;
    gap:             6px;
    padding:         6px 12px 8px;
    align-items:     center;
  }
  .sh-group { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
  .sh-label { font-size: 10px; letter-spacing: 2px; padding: 2px 4px; opacity: 0.6; flex-shrink: 0; }
  .sh-btns  { display: flex; gap: 4px; flex-wrap: nowrap; }
  .sh-btn   { font-size: 8px !important; padding: 5px 10px !important; min-height: 30px !important; }

  /* Secondary row: show inside settings panel, but hide the desktop extras */
  #play-secondary-row { display: none !important; }

  /* ── PLAYBACK ROW: always visible, big ───────────────── */
  .playback-row {
    display:         flex;
    align-items:     center;
    justify-content: center;
    gap:             8px;
    padding:         8px 12px 8px;
    border-top:      1px solid var(--border);
  }
  .play-main-btn {
    flex:            1 1 auto;
    max-width:       none !important;
    font-size:       14px !important;
    padding:         14px 12px !important;
    letter-spacing:  2px !important;
  }
  .play-step-btn {
    padding:   10px 18px !important;
    font-size: 14px !important;
    flex-shrink: 0;
  }

  /* Tighten general buttons inside settings */
  .settings-panel .strum-btn {
    min-height: 28px !important;
    padding:    3px 8px !important;
    font-size:  8px !important;
  }

  /* ── SOLO sound picker ────────────────────────────────── */
  #sx-title { display: none !important; }
  .sx-scale-btn span:last-child { display: none; }
  .sx-scale-btn { flex: 1 1 0; font-size: 10px; padding: 5px 6px; text-align: center; }

  /* ── SOLO player row: stack vertically ───────────────── */
  .sx-player-row {
    display:         flex;
    flex-direction:  column;
    align-items:     stretch;
    gap:             8px;
    padding:         10px 12px 12px;
    border-top:      1px solid var(--border);
  }
  #sx-scale-play-btn,
  #sx-prog-play-btn {
    width:           100% !important;
    font-size:       13px !important;
    padding:         13px 12px !important;
    letter-spacing:  2px !important;
    text-align:      center;
  }
  .sx-stepper {
    display:         flex;
    align-items:     center;
    justify-content: center;
    gap:             16px;
  }

  /* Sub-panels: shapes tab scrolls, play/solo fill remaining space */
  #sub-charts { flex: 1 1 0 !important; overflow-y: auto !important; }
  #sub-play, #sub-scale { flex: 1 1 0 !important; overflow-y: auto !important; }


  /* ── Picker ───────────────────────────────────────────── */
  .pk-song { width: 140px; }

  /* Show the prog-pad build buttons on mobile, hide inline pads */
  .prog-pad-btn        { display: inline-flex !important; }
  .inline-prog-pad     { display: none !important; }
  #prog-pad-overlay, #prog-pad-sheet { display: none; } /* JS controls open/close */
}


/* ══ TABLET (600px – 1024px) ═════════════════════════════
   Two-column layout stays. Just tighten the chrome.
════════════════════════════════════════════════════════ */
@media (min-width: 600px) and (max-width: 1024px) {

  .play-sidebar               { width: 52px; padding: 8px 4px; }
  .key-btns-sidebar .circ     { width: 34px; height: 34px; font-size: 9px; }
  .inst-btn                   { padding: 5px 7px; font-size: 10px; }
  .controls-strip             { padding: 3px 10px; }
  .prog-card                  { min-width: 120px; max-width: 160px; }

  /* Inline prog pad: 4+3 layout matches the mobile bottom sheet feel */
  .ipad-degrees               { grid-template-columns: repeat(4, 1fr) !important; }
  .pad-deg-btn                { padding: 14px 4px 12px !important; }
  .pad-deg-numeral            { font-size: 18px !important; }
}

/* Make button — desktop only */
@media (hover: none) and (pointer: coarse) {
  .spl-make-btn { display: none !important; }
  #sp-handle { display: block !important; }
}


/* ══ MOBILE FIXES FOR SESSION CHANGES ════════════════════
   Fixes for dashboard, player row, beat dots, inst-desc,
   prog-col inline styles, and perspective toggle.
════════════════════════════════════════════════════════ */
@media (max-width: 599px) {

  /* Beat dots inline in player row — hidden on mobile,
     the gear-row beat dots handle this on touch */
  #sx-beat-dots-inline { display: none !important; }

  /* Instrument desc — hide on mobile, header is already tight */
  #inst-desc { display: none !important; }

  /* Dashboard tiles — narrower on small screens */
  .dash-tile     { min-width: 60px; width: 60px; padding: 4px 8px; }
  .dash-tile-mid { min-width: 72px; width: 72px; }

  /* Solo stepper — Play through inside stepper:
     remove the 100% width override so it doesn't bust the row */
  .sx-stepper #sx-prog-play-btn {
    width: auto !important;
    flex: 1 1 auto;
    font-size: 13px !important;
    padding: 13px 12px !important;
  }

  /* Prog cards — override JS inline width so 2-col grid works */
  .prog-col {
    flex: 0 0 calc(50% - 8px) !important;
    width: calc(50% - 8px) !important;
    max-width: none !important;
    min-width: 0 !important;
  }

  /* Charts dashboard — hide on mobile to save space,
     the card content is enough at small size */
  #charts-dashboard { display: none !important; }

  /* Perspective toggle button — hide on mobile,
     small cards don't benefit from the effect */
  #perspective-toggle { display: none !important; }

  /* Quick picks in pads — already hidden via inline-prog-pad rule,
     but make sure the row itself doesn't ghost-space */
  .ipad-quick-row { display: none !important; }
}

/* ── PEDALBOARD RESPONSIVE ──────────────────────────────────── */
@media (max-width: 768px) {
  .pb-board { gap: 6px; }
  .pb-board .pb-pedal { min-width: 80px; padding: 6px 8px; }
  .pb-footswitch { width: 36px; height: 36px; }
  .pb-label { font-size: 10px; letter-spacing: 3px; }
  .pb-slider { min-width: 50px; }
  .eq-slider { height: 50px; }
  .pb-btn { font-size: 10px; padding: 5px 8px; }
  .pb-knob { font-size: 8px; padding: 4px 7px; }
}

@media (max-width: 480px) {
  .pb-board { gap: 4px; }
  .pb-board .pb-pedal { min-width: 70px; flex: 1 1 45%; max-width: none; padding: 6px 6px; }
  .pb-label { font-size: 9px; letter-spacing: 2px; }
  .pb-knob { font-size: 10px; padding: 3px 5px; }
  .pb-btn { font-size: 9px; padding: 4px 6px; }
  .pb-footswitch { width: 30px; height: 30px; }
}

/* Band toggles in playback row wrap nicely */
@media (max-width: 480px) {
  .band-toggle { padding: 3px 8px; font-size: 8px; }
}
