/* ============================================================================
   PianoBoss — M3.1 Mobile Lesson Player (phone landscape ≤ 767 px)
   Per M2 blueprint. Same DOM, same engine — this stylesheet ONLY activates
   the mobile-landscape full-bleed lesson layout. Desktop, tablet, and phone
   portrait are unaffected.
   ========================================================================= */

/* The body class `m31-active` is set by mobile-lesson.js when a lesson is
   open AND viewport matches mobile-landscape. All M3.1 styles are scoped to
   it so we can never bleed into desktop or tablet. */

/* --- Stop overlay: lives in DOM but hidden by default everywhere -------- */
.m31-lesson-stop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.m31-lesson-stop-overlay[aria-hidden="false"] { display: flex; }
.m31-stop-card {
  background: linear-gradient(180deg, #1a1a22 0%, #0c0c12 100%);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 16px;
  padding: 28px 28px 22px;
  width: min(360px, 88vw);
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: m31-stop-in 0.22s ease-out;
}
@keyframes m31-stop-in {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.m31-stop-icon { font-size: 34px; line-height: 1; margin-bottom: 10px; }
.m31-stop-title {
  font-size: 18px; font-weight: 700; color: var(--text);
  margin-bottom: 18px; letter-spacing: 0.3px;
}
.m31-stop-actions { display: flex; flex-direction: column; gap: 10px; }
.m31-stop-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  font-size: 15px; font-weight: 600;
  padding: 13px 18px; border-radius: 10px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background 0.12s, transform 0.08s;
}
.m31-stop-btn:active { transform: scale(0.98); background: rgba(255,255,255,0.14); }
.m31-stop-btn.primary {
  background: linear-gradient(180deg, var(--brass-hi), var(--brass));
  color: #1a1a22;
  border-color: rgba(212, 175, 55, 0.5);
}

/* --- Mobile landscape lesson play: the actual layout overrides ---------- */
@media (max-width: 767px) and (orientation: landscape) {

  /* When a lesson is active in mobile-landscape, body gets `m31-active`. */
  body.m31-active { overflow: hidden; }
  body.m31-active header,
  body.m31-active footer,
  body.m31-active .container > *:not(#piano-shell):not(#view-lesson) {
    display: none !important;
  }
  body.m31-active .container {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  /* The lesson view itself becomes a thin top bar only.
     The rich lesson-prompt content moves into a drawer body. */
  body.m31-active #view-lesson.active {
    display: block;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 38px;
    padding: 0;
    background: rgba(10, 10, 18, 0.95);
    border-bottom: 1px solid var(--line);
    z-index: 100;
    overflow: hidden;
  }
  body.m31-active .lesson-main {
    display: flex;
    align-items: center;
    height: 38px;
    padding: 0 8px 0 0;
    gap: 8px;
  }
  body.m31-active .lesson-header {
    display: flex; align-items: center; gap: 8px;
    flex: 1; min-width: 0; height: 100%;
    padding: 0;
    border: none; background: transparent;
  }
  body.m31-active .lesson-header > div {
    flex: 1; min-width: 0;
    display: flex; align-items: center; gap: 6px;
  }
  body.m31-active #lesson-title {
    font-size: 13px; font-weight: 600;
    margin: 0; padding: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    flex: 1; min-width: 0;
  }
  body.m31-active #lesson-instruction { display: none; }
  body.m31-active #lesson-back-btn {
    flex-shrink: 0;
    padding: 6px 10px;
    font-size: 12px;
    height: 28px;
    margin: 0 0 0 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
  }
  /* The verbose prompt body is hidden in play mode — it's accessible via
     the lesson drawer if the student wants context. */
  body.m31-active .lesson-prompt { display: none; }

  /* --- Stop button + score in top bar ---------------------------------- */
  .m31-topbar-stop,
  .m31-topbar-score {
    flex-shrink: 0;
    height: 28px;
    display: inline-flex;
    align-items: center;
    font-size: 12px; font-weight: 600;
    padding: 0 10px;
    border-radius: 6px;
  }
  .m31-topbar-stop {
    background: rgba(255, 90, 70, 0.18);
    color: #ff7e6e;
    border: 1px solid rgba(255, 90, 70, 0.32);
    cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .m31-topbar-stop:active { background: rgba(255,90,70,0.32); }
  .m31-topbar-score {
    background: rgba(212, 175, 55, 0.14);
    color: var(--brass-hi);
    border: 1px solid rgba(212, 175, 55, 0.3);
    min-width: 64px; justify-content: center;
  }

  /* --- Piano shell takes the rest of the screen ------------------------ */
  body.m31-active #piano-shell {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    top: 38px; left: 0; right: 0; bottom: 0;
    margin: 0;
    padding: 6px 8px 8px;
    border-radius: 0;
    background: linear-gradient(180deg, #0a0a12 0%, #050508 100%);
    border: none;
    z-index: 50;
  }
  body.m31-active .falling-stage {
    flex: 1 1 auto;
    height: auto !important;
    min-height: 0;
    border-radius: 8px;
    margin-bottom: 6px;
  }
  body.m31-active .piano-wrap,
  body.m31-active #piano-shell .piano-wrap { padding: 0; }
  body.m31-active .piano {
    height: 130px !important;  /* fits in landscape vertical budget */
  }
  body.m31-active .controls {
    display: none;  /* hidden in play mode; available via drawer */
  }

  /* --- Edge handles ---------------------------------------------------- */
  body.m31-active .m31-edge {
    position: fixed;
    top: 38px;
    bottom: 0;
    width: 16px;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brass);
    font-size: 14px;
    background: linear-gradient(90deg, rgba(212,175,55,0.15), transparent);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }
  body.m31-active .m31-edge.right {
    right: 0; left: auto;
    background: linear-gradient(270deg, rgba(212,175,55,0.15), transparent);
  }
  body.m31-active .m31-edge.left { left: 0; }

  /* --- Drawers: sidebar (left) + takeaways (right) -------------------- */
  body.m31-active .lesson-sidebar,
  body.m31-active .lesson-right-panel {
    position: fixed !important;
    top: 38px !important;
    bottom: 0 !important;
    width: min(78vw, 360px) !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 16px !important;
    z-index: 200;
    overflow-y: auto;
    background: linear-gradient(180deg, #131321 0%, #0a0a12 100%);
    border: none;
    border-radius: 0;
    transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.25, 1);
  }
  body.m31-active .lesson-sidebar {
    left: 0 !important; right: auto !important;
    border-right: 1px solid rgba(212,175,55,0.25);
    transform: translateX(-105%);
  }
  body.m31-active .lesson-right-panel {
    right: 0 !important; left: auto !important;
    border-left: 1px solid rgba(212,175,55,0.25);
    transform: translateX(105%);
  }
  body.m31-active.m31-drawer-left .lesson-sidebar { transform: translateX(0); }
  body.m31-active.m31-drawer-right .lesson-right-panel { transform: translateX(0); }

  /* --- Drawer backdrop ------------------------------------------------- */
  body.m31-active .m31-backdrop {
    position: fixed;
    inset: 38px 0 0 0;
    background: rgba(0,0,0,0.55);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s;
  }
  body.m31-active.m31-drawer-left .m31-backdrop,
  body.m31-active.m31-drawer-right .m31-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* --- Hide the M1.3 portrait nudge while playing in landscape -------- */
  body.m31-active .landscape-nudge { display: none !important; }
}

/* --- Phone PORTRAIT during a lesson: clean rotate-to-play prompt ------- */
@media (max-width: 767px) and (orientation: portrait) {
  body.m31-portrait-prompt #view-lesson.active {
    text-align: center;
  }
  /* The M1.3 landscape nudge banner already covers the soft prompt at the
     top of screen — no extra UI needed for v1. The student can play in
     portrait if they prefer; nothing forces them to rotate. */
}
