/* ==========================================================================
 * practice-screen.css — Interactive screen layer for small-group practice sets
 *
 * Enhances generated small-group continuation packets (lessons/<id>/practice.html)
 * with digital input fields, tactile multiple-choice selection, speech read-aloud,
 * scaffolded hints, and math scratchpad without compromising paper print geometry.
 * ========================================================================== */

@media screen {
  /* Page container breathing room on screens */
  .sp-page {
    margin: 20px auto;
    transition: box-shadow 0.2s ease;
  }

  /* ---- Sticky Top Toolbar ---- */
  .sp-work-toolbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #0f172a;
    color: #f8fafc;
    padding: 10px 18px;
    margin: -18px auto 16px;
    max-width: 760px;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-family: system-ui, -apple-system, sans-serif;
  }
  .sp-toolbar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
  }
  .sp-save-status {
    font-size: 11.5px;
    color: #38bdf8;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
  }
  .sp-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }
  .sp-tool-btn {
    appearance: none;
    background: #1e293b;
    color: #f1f5f9;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 650;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 34px;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  }
  .sp-tool-btn:hover {
    background: #334155;
    border-color: #475569;
  }
  .sp-tool-btn:active {
    transform: translateY(1px);
  }
  .sp-tool-btn--accent {
    background: #0369a1;
    border-color: #0284c7;
    color: #fff;
  }
  .sp-tool-btn--accent:hover {
    background: #075985;
  }

  /* ---- Interactive Multiple Choice Options ---- */
  .sp-opt {
    cursor: pointer;
    user-select: none;
    border-radius: 6px;
    padding: 6px 10px;
    margin: 3px 0;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    border: 1.5px solid transparent;
  }
  .sp-opt:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
  }
  .sp-opt.is-selected {
    background-color: #e0f2fe;
    border-color: #0284c7;
    font-weight: 600;
  }
  .sp-opt.is-selected .sp-bub {
    background-color: #0284c7;
    color: #fff;
    transform: scale(1.08);
  }
  .sp-bub {
    transition: transform 0.15s ease, background-color 0.15s ease;
  }

  /* ---- Interactive Digital Written Reasoning Inputs ---- */
  .sp-digital-input-wrap {
    margin: 8px 0 12px;
  }
  .sp-digital-input {
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.5;
    padding: 10px 12px;
    border: 1.5px solid #cbd5e1;
    border-radius: 6px;
    background: #f8fafc;
    color: var(--ink);
    resize: vertical;
    min-height: 58px;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  }
  .sp-digital-input:focus {
    outline: none;
    border-color: #0284c7;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
  }
  .sp-lines {
    display: none; /* Conceal print lines on screen when digital input exists */
  }

  /* ---- Interactive Cloze Inputs & Bank Chips ---- */
  .sp-cloze-input {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: #0369a1;
    border: none;
    border-bottom: 2px solid #0284c7;
    background: #f0f9ff;
    padding: 2px 6px;
    border-radius: 3px 3px 0 0;
    min-width: 110px;
    text-align: center;
    transition: border-color 0.15s ease, background 0.15s ease;
  }
  .sp-cloze-input:focus {
    outline: none;
    background: #e0f2fe;
    border-bottom-color: #0369a1;
  }
  .sp-bank-chips li {
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
  }
  .sp-bank-chips li:hover {
    background-color: #0284c7;
    color: #fff;
    border-color: #0284c7;
    transform: translateY(-1px);
  }

  /* ---- Interactive Self-Check Rating Buttons ---- */
  .sp-check table td:not(:first-child) {
    cursor: pointer;
    text-align: center;
    padding: 6px;
    transition: background 0.15s ease;
  }
  .sp-check table td:not(:first-child):hover {
    background: #f1f5f9;
  }
  .sp-rating-check-btn {
    appearance: none;
    border: 1.5px solid #cbd5e1;
    background: #fff;
    border-radius: 4px;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    color: transparent;
    transition: all 0.15s ease;
  }
  .sp-rating-check-btn.is-checked {
    background: #0284c7;
    border-color: #0284c7;
    color: #fff;
  }
  .sp-check-summary {
    margin-top: 10px;
    padding: 8px 12px;
    background: #f0fdf4;
    border-left: 4px solid #22c55e;
    border-radius: 0 6px 6px 0;
    font-size: 12px;
    font-weight: 600;
    color: #15803d;
  }

  /* ---- Audio Read-Aloud (Text-to-Speech) ---- */
  .sp-tts-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #475569;
    cursor: pointer;
    margin-left: 6px;
    vertical-align: middle;
    transition: all 0.15s ease;
  }
  .sp-tts-btn:hover {
    background: #0284c7;
    color: #fff;
    border-color: #0284c7;
  }
  .sp-tts-btn.is-speaking {
    background: #22c55e;
    color: #fff;
    border-color: #16a34a;
    animation: sp-pulse 1s infinite alternate;
  }
  @keyframes sp-pulse {
    from { opacity: 0.85; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1.04); }
  }

  /* ---- Multi-Step Scaffolded Hint Ladder ---- */
  .sp-hint-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: #fffbeb;
    border: 1px solid #fde047;
    color: #92400e;
    cursor: pointer;
    margin-left: 6px;
    vertical-align: middle;
    transition: all 0.15s ease;
  }
  .sp-hint-btn:hover {
    background: #fef08a;
  }
  .sp-hint-ladder {
    margin: 8px 0 10px;
    padding: 10px 14px;
    background: #fffbeb;
    border: 1px solid #fef08a;
    border-left: 4px solid #f59e0b;
    border-radius: 0 8px 8px 0;
    font-size: 12.5px;
    display: none;
  }
  .sp-hint-ladder.is-open {
    display: block;
  }
  .sp-hint-step {
    margin: 4px 0;
    display: flex;
    align-items: baseline;
    gap: 6px;
  }
  .sp-hint-badge {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #fef3c7;
    color: #92400e;
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid #fde68a;
    flex-shrink: 0;
  }

  /* ---- Digital Math Scratchpad Canvas Modal ---- */
  .sp-scratchpad-modal {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: min(540px, 94vw);
    height: 380px;
    background: #ffffff;
    border: 2px solid #0f172a;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.28);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
  }
  .sp-scratchpad-modal.is-open {
    display: flex;
  }
  .sp-scratchpad-header {
    background: #0f172a;
    color: #f8fafc;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .sp-scratchpad-title {
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .sp-scratchpad-tools {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .sp-scratchpad-body {
    flex: 1;
    position: relative;
    background: #ffffff;
    cursor: crosshair;
  }
  .sp-scratchpad-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
  }

  /* ---- Quick Math Reference Drawer ---- */
  .sp-reference-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(600px, 92vw);
    max-height: 85vh;
    background: #ffffff;
    border: 2px solid #1e293b;
    border-radius: 12px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    display: none;
    flex-direction: column;
    overflow: hidden;
  }
  .sp-reference-modal.is-open {
    display: flex;
  }
  .sp-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    z-index: 10000;
    display: none;
  }
  .sp-modal-backdrop.is-open {
    display: block;
  }
  .sp-reference-body {
    padding: 16px;
    overflow-y: auto;
    font-size: 13px;
  }
}

/* Print Overrides: preserve clean paper layout, print student work into blank lines */
@media print {
  .sp-work-toolbar,
  .sp-tts-btn,
  .sp-hint-btn,
  .sp-hint-ladder,
  .sp-scratchpad-modal,
  .sp-reference-modal,
  .sp-modal-backdrop {
    display: none !important;
  }
  .sp-lines {
    display: block !important;
  }
  .sp-digital-input {
    border: none;
    background: transparent;
    padding: 0;
    font-size: 12.5px;
  }
  .sp-opt.is-selected {
    font-weight: 700;
  }
  .sp-opt.is-selected .sp-bub {
    background: #000 !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
