/* ==========================================================================
   Mobile Briefing Modal — `/brief` output viewer.
   Inherits the Footnote Canon popup-modal layer (same shape as
   build_doc_pdfs.py's HTML_TEMPLATE).
   ========================================================================== */

@media (max-width: 767px) {
  body.mbf-no-scroll { overflow: hidden; }

  .mbf-overlay {
    position: fixed;
    inset: 0;
    background: #0a2e2e;
    z-index: 11500;
    display: flex;
    flex-direction: column;
  }

  .mbf-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
  }

  .mbf-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 10px;
    background: #0f3636;
    border-bottom: 1px solid #1a5252;
  }

  .mbf-close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 0;
    color: #e0e0e8;
    border-radius: 22px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
  }
  .mbf-close:active { background: rgba(255, 255, 255, 0.08); }

  .mbf-titles {
    flex: 1;
    min-width: 0;
    padding-top: 4px;
  }

  .mbf-tag {
    font-size: 10px;
    font-weight: 700;
    color: #f0c270;
    text-transform: uppercase;
    letter-spacing: 0.1em;
  }

  .mbf-title {
    margin: 2px 0 1px;
    font-family: "Playfair Display", Georgia, serif;
    font-size: 18px;
    font-weight: 700;
    color: #e0e0e8;
    line-height: 1.2;
  }

  .mbf-date {
    font-size: 12px;
    color: #a8b0b8;
  }

  .mbf-mode-toggle {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid #1a5252;
    border-radius: 22px;
    padding: 2px;
    flex-shrink: 0;
    margin-top: 6px;
  }

  .mbf-mode-btn {
    appearance: none;
    background: transparent;
    border: 0;
    color: #a8b0b8;
    font-size: 12px;
    font-weight: 600;
    padding: 8px 12px;
    min-height: 36px;
    border-radius: 20px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mbf-mode-btn-active {
    background: #6DD4D4;
    color: #0a2e2e;
  }

  .mbf-mode-spacer { width: 8px; flex-shrink: 0; }

  /* Content. Briefing-modal is a doc-reader — prose needs readable L/R
     margins, not edge-to-edge. The 14px floor is intentional typography
     here, not the inset-leak class targeted by binary-hatching-pearl D2.
     This wrapper is exempt from the global edge-to-edge rule. */
  .mbf-content {
    flex: 1;
    overflow-y: auto;
    background: #0a2e2e;
    padding: 14px max(14px, env(safe-area-inset-left, 0px)) 14px max(14px, env(safe-area-inset-right, 0px));
  }

  .mbf-article {
    color: #e0e0e8;
    font-family: "Source Sans 3", -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.6;
  }

  .mbf-article h1, .mbf-article h2, .mbf-article h3 {
    font-family: "Playfair Display", Georgia, serif;
    color: #e8a040;
    line-height: 1.25;
    margin: 18px 0 8px;
  }
  .mbf-article h1 { font-size: 22px; }
  .mbf-article h2 { font-size: 19px; }
  .mbf-article h3 { font-size: 17px; }

  .mbf-article p { margin: 0 0 12px; }

  .mbf-article a {
    color: #6DD4D4;
    text-decoration: none;
    border-bottom: 1px dotted #6DD4D4;
  }

  /* Footnote ref styling (matches build_doc_pdfs.py CSS) */
  .mbf-article sup.footnote-ref a, .mbf-article .footnote-ref a {
    display: inline-block;
    min-width: 14px;
    padding: 0 5px;
    border-radius: 4px;
    background: rgba(139, 92, 246, 0.25);
    color: #c4b5fd;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.78em;
    line-height: 1.5;
  }

  .mbf-article .footnote {
    margin-top: 24px;
    padding-top: 12px;
    border-top: 1px solid #1a5252;
    font-size: 13px;
    color: #a8b0b8;
  }
  .mbf-article .footnote::before {
    content: "Notes & Attribution";
    display: block;
    font-family: "Playfair Display", Georgia, serif;
    font-size: 16px;
    color: #c4b5fd;
    font-weight: 700;
    margin-bottom: 8px;
  }
  .mbf-article .footnote ol { padding-left: 22px; }
  .mbf-article .footnote li { margin-bottom: 6px; }

  /* Listen-only poster (when no html_content / markdown) */
  .mbf-listen-poster {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
    color: #a8b0b8;
  }

  .mbf-listen-tag {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #f0c270;
    margin-bottom: 6px;
  }

  .mbf-listen-instr {
    font-size: 14px;
    color: #a8b0b8;
  }

  /* Audio bar — geometric echo of mdv-audio-bar (Bio State 3) */
  .mbf-audio-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px calc(env(safe-area-inset-bottom, 0px) + 10px);
    background: #0f3636;
    border-top: 1px solid #1a5252;
  }

  .mbf-play {
    width: 44px;
    height: 44px;
    border-radius: 22px;
    border: 0;
    background: #6DD4D4;
    color: #0a2e2e;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
  }
  .mbf-play:active { transform: scale(0.96); }

  .mbf-time {
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    color: #a8b0b8;
    min-width: 36px;
    text-align: center;
  }

  .mbf-scrub {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    height: 28px;
  }

  .mbf-scrub::-webkit-slider-runnable-track {
    height: 4px;
    background: #1a5252;
    border-radius: 2px;
  }

  .mbf-scrub::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 12px;
    background: #fff;
    border: 2px solid #6DD4D4;
    margin-top: -10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  }

  /* Footnote Canon popup attribution modal — same DOM shape as
     build_doc_pdfs.py CSS but tuned for mobile dark theme. */
  .mbf-attribution-modal.attribution-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    z-index: 11600;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }
  .mbf-attribution-modal.attribution-modal.open { display: flex; }

  .mbf-attribution-modal .attribution-modal-card {
    background: #1f2937;
    color: #e0e0e8;
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 22px 24px;
    border-top: 4px solid #8b5cf6;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    position: relative;
    font-size: 14px;
    line-height: 1.55;
  }

  .mbf-attribution-modal .attribution-modal-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #c4b5fd;
    font-weight: 700;
    margin-bottom: 8px;
  }

  .mbf-attribution-modal .attribution-modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: 0;
    color: #94a3b8;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
  }
}
