/* ══════════════════════════════════════════════════════════════════
   WIDGET SHELL (mobile/tablet ≤1024px)
   ── Reusable mobile-first shell for Anna R. Dudley's interactive widgets.
      Inspired by Reigns and other phone-game UI patterns: bottom-zone
      action, persistent state visualization at top, progress dots,
      history chips, swipeable card deck, designed shareable result card.

      Each widget includes this stylesheet alongside widget-shell.js,
      then declares its own widget-specific persistent visualization
      (radar / clock / depth indicator / budget bar / etc.) and screen
      content. The shell handles the frame; the widget fills it.

      Used by: red-team-simulator, precedent-machine,
               explainability-gap, data-poisoning-red-team,
               six-hour-clock.
   ══════════════════════════════════════════════════════════════════ */

.mobile-sim { display: none; }

@media (max-width: 1024px) {
  .mobile-sim {
    display: flex;
    flex-direction: column;
    background: var(--stone);
    margin-top: 72px;
    min-height: calc(100vh - 72px);
  }

  /* ── Header: progress dots + exit ── */
  .ms-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--white);
    border-bottom: 1px solid var(--rule-light);
  }
  .ms-progress { display: flex; gap: 8px; align-items: center; }
  .ms-progress-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--rule-light);
    transition: background 0.3s ease, transform 0.3s ease;
  }
  .ms-progress-dot.active    { background: var(--bronze);  transform: scale(1.3); }
  .ms-progress-dot.completed { background: var(--forest); }
  .ms-exit {
    font-family: 'Inter', sans-serif;
    font-size: 11px; font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    letter-spacing: 0.5px;
  }

  /* ── Decision history strip (chips of completed decisions) ── */
  .ms-history-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    background: var(--white);
    padding: 10px 20px;
    border-bottom: 1px solid var(--rule-light);
    min-height: 32px;
  }
  .ms-history-strip:empty { display: none; }
  .ms-history-strip-label {
    font-family: 'Inter', sans-serif;
    font-size: 9px; font-weight: 700;
    letter-spacing: 1.8px; text-transform: uppercase;
    color: var(--text-muted);
    margin-right: 4px;
  }
  .ms-history-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: var(--forest);
    background: rgba(168,136,90,0.14);
    padding: 5px 10px;
    border-radius: 12px;
    animation: msChipIn 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }
  .ms-history-chip svg {
    width: 11px; height: 11px;
    flex-shrink: 0;
    color: var(--bronze);
  }
  @keyframes msChipIn {
    from { opacity: 0; transform: scale(0.7) translateY(-6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
  }

  /* ── Persistent visualization zone (radar / clock / depth bar / budget bar / etc.) ── */
  .ms-persistent-zone {
    background: var(--white);
    padding: 14px 20px 10px;
    border-bottom: 1px solid var(--rule-light);
    text-align: center;
  }
  .ms-persistent-label {
    font-family: 'Inter', sans-serif;
    font-size: 9px; font-weight: 700;
    letter-spacing: 2px; text-transform: uppercase;
    color: var(--bronze);
    margin-bottom: 4px;
  }

  /* ── Lede screen (the entry / premise) ── */
  .ms-lede-screen {
    flex: 1;
    padding: 36px 28px;
    background: var(--stone);
    display: flex; flex-direction: column;
    justify-content: center;
  }
  .ms-lede-tag {
    font-family: 'Inter', sans-serif;
    font-size: 10px; font-weight: 700;
    letter-spacing: 2.5px; text-transform: uppercase;
    color: var(--bronze);
    margin-bottom: 14px;
  }
  .ms-lede-title {
    font-family: 'Fraunces', serif;
    font-weight: 300; font-size: 38px;
    color: var(--forest);
    line-height: 1.05; margin-bottom: 22px;
    font-optical-sizing: auto;
  }
  .ms-lede-title em {
    color: var(--bronze);
    font-style: italic; font-weight: 400;
  }
  .ms-lede-body {
    font-family: 'Source Serif 4', serif;
    font-size: 17px; line-height: 1.65;
    color: var(--text-primary);
    border-left: 3px solid var(--bronze);
    padding-left: 18px;
    margin-bottom: 28px;
  }
  .ms-begin-btn {
    width: 100%;
    background: var(--forest);
    color: var(--white);
    border: none; border-radius: 6px;
    padding: 16px 20px;
    font-family: 'Inter', sans-serif;
    font-weight: 600; font-size: 15px;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background 0.2s ease;
  }
  .ms-begin-btn:active { background: #0d1f17; }

  /* ── Decision card stack ── */
  .ms-cards {
    flex: 1;
    background: var(--stone);
    display: flex; flex-direction: column;
  }
  .ms-context {
    padding: 18px 24px 12px;
    background: var(--white);
    border-bottom: 1px solid var(--rule-light);
  }
  .ms-context-tag {
    font-family: 'Inter', sans-serif;
    font-size: 10px; font-weight: 700;
    letter-spacing: 2.5px; text-transform: uppercase;
    color: var(--bronze);
    margin-bottom: 4px;
  }
  .ms-context-title {
    font-family: 'Fraunces', serif;
    font-weight: 400; font-size: 22px;
    color: var(--forest);
    line-height: 1.25;
    margin-bottom: 6px;
  }
  .ms-context-desc {
    font-family: 'Source Serif 4', serif;
    font-size: 14px; line-height: 1.5;
    color: var(--text-muted);
  }

  .ms-card-deck {
    position: relative;
    flex: 1;
    margin: 16px 16px 8px;
    min-height: 230px;
  }
  .ms-card {
    position: absolute;
    top: 0; left: 0; right: 0;
    background: var(--white);
    border: 1px solid var(--rule-light);
    border-radius: 8px;
    padding: 22px 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
    transition: transform 0.35s cubic-bezier(0.4,0,0.2,1), opacity 0.3s ease;
    user-select: none;
    touch-action: pan-y;
  }
  .ms-card.prev   { transform: translateX(-110%); opacity: 0; pointer-events: none; }
  .ms-card.next   { transform: translateX( 110%); opacity: 0; pointer-events: none; }
  .ms-card.active { transform: translateX(0);     opacity: 1; }
  .ms-card-counter {
    font-family: 'Inter', sans-serif;
    font-size: 10px; font-weight: 700;
    letter-spacing: 1.8px; text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
  }
  .ms-card-title {
    font-family: 'Fraunces', serif;
    font-weight: 400; font-size: 22px;
    color: var(--forest);
    line-height: 1.25;
    margin-bottom: 10px;
  }
  .ms-card-desc {
    font-family: 'Source Serif 4', serif;
    font-size: 15px; line-height: 1.55;
    color: var(--text-secondary);
    margin-bottom: 18px;
    min-height: 70px;
  }
  .ms-card-cta {
    width: 100%;
    background: var(--forest);
    color: var(--white);
    border: none; border-radius: 6px;
    padding: 13px 20px;
    font-family: 'Inter', sans-serif;
    font-weight: 600; font-size: 13px;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background 0.2s ease;
  }
  .ms-card-cta:active { background: #0d1f17; }

  .ms-deck-nav {
    display: flex; align-items: center; justify-content: center;
    gap: 16px;
    padding: 6px 0 18px;
  }
  .ms-arrow {
    background: rgba(168,136,90,0.12);
    border: none;
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--bronze);
    cursor: pointer;
    transition: background 0.2s ease;
  }
  .ms-arrow:disabled { opacity: 0.3; cursor: not-allowed; }
  .ms-arrow:active:not(:disabled) { background: rgba(168,136,90,0.28); }
  .ms-arrow svg { width: 18px; height: 18px; }
  .ms-deck-pos {
    font-family: 'Inter', sans-serif;
    font-size: 11px; font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 1px;
    min-width: 44px; text-align: center;
  }

  /* ── Result screen ── */
  .ms-result {
    flex: 1;
    padding: 22px 18px 32px;
    background: var(--stone);
    display: flex; flex-direction: column;
    gap: 14px;
  }
  .ms-result-card {
    background: var(--forest);
    border-radius: 10px;
    padding: 26px 24px;
    color: var(--white);
  }
  .ms-result-tag {
    font-family: 'Inter', sans-serif;
    font-size: 10px; font-weight: 700;
    letter-spacing: 2.5px; text-transform: uppercase;
    color: var(--bronze);
    margin-bottom: 14px;
  }
  .ms-result-posture {
    font-family: 'Fraunces', serif;
    font-weight: 400; font-style: italic;
    font-size: 26px;
    line-height: 1.25;
    margin-bottom: 18px;
  }
  .ms-result-choices {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-bottom: 18px;
  }
  .ms-result-chip {
    font-family: 'Inter', sans-serif;
    font-size: 11px; font-weight: 600;
    color: rgba(255,255,255,0.9);
    background: rgba(168,136,90,0.2);
    padding: 5px 11px;
    border-radius: 12px;
  }
  .ms-result-assessment {
    font-family: 'Source Serif 4', serif;
    font-size: 16px; line-height: 1.7;
    color: rgba(255,255,255,0.92);
    border-top: 1px solid rgba(168,136,90,0.3);
    padding-top: 16px;
  }
  .ms-result-actions {
    display: flex; gap: 10px;
  }
  .ms-action-btn {
    flex: 1;
    padding: 14px 12px;
    border: none; border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-weight: 600; font-size: 13px;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: opacity 0.2s ease;
  }
  .ms-action-btn.primary {
    background: var(--bronze);
    color: var(--forest);
  }
  .ms-action-btn.secondary {
    background: var(--white);
    color: var(--forest);
    border: 1px solid var(--rule-light);
  }
  .ms-action-btn:active { opacity: 0.85; }

  /* ── Toast (share confirmation) ── */
  .ms-share-toast {
    position: fixed;
    bottom: 24px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--forest);
    color: var(--white);
    padding: 12px 20px;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 13px; font-weight: 600;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    z-index: 1000;
  }
  .ms-share-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Reduced motion: disable transitions/animations in the mobile shell */
@media (prefers-reduced-motion: reduce) {
  .ms-card, .ms-progress-dot, .ms-share-toast, .ms-history-chip {
    transition: none !important;
    animation: none !important;
  }
}
