/* Beta sign-up wall on lesson and test pages, plus the "how was this lesson?" nudge.
   Markup: tools/beta_gate.py. Behaviour: js/beta-gate.js. Mobile-first. */

html.beta-locked, html.beta-locked body { overflow: hidden; }

/* Overlay: hidden attribute wins until the script opens it */
.beta-gate:not([hidden]) {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(18, 48, 43, 0.42);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.beta-dialog {
  width: 100%; max-width: 520px; min-width: 0;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  display: grid; gap: 12px;
  padding: 22px 18px 10px;
  background: var(--card); color: var(--ink);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.beta-dialog:focus { outline: none; }
.beta-dialog h2 { font-size: clamp(1.4rem, 6vw, 1.85rem); }
.beta-intro { color: var(--ink-2); font-size: 1rem; }

.beta-form { display: grid; gap: 14px; margin-top: 4px; min-width: 0; }
.beta-form .btn { width: 100%; }
.beta-form .role input:focus-visible + span { outline-color: var(--leaf); }
.beta-hint { font-size: 0.85rem; color: var(--ink-3); }
.beta-err { font-size: 0.88rem; font-weight: 600; color: #8f2a19; }
.beta-consent { display: grid; gap: 6px; }
.beta-form .field input[aria-invalid="true"] { border-color: var(--red); }
.beta-form .role input[aria-invalid="true"] + span { border-color: var(--red); }
.beta-form .consent input[aria-invalid="true"] { outline: 2px solid var(--red); outline-offset: 2px; }
.beta-status { font-weight: 600; color: var(--leaf-strong); }
.beta-status:empty { display: none; }
.beta-status.is-error { color: #8f2a19; }
.beta-out { text-align: center; font-size: 0.9rem; }
.beta-out a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink-3); }

/* Where focus lands after unlocking (a heading made focusable by the script) */
.beta-focus:focus { outline: none; }

/* Toasts: the nudge and the thank-you after signing up */
.beta-toasts {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 55;
  display: grid; justify-items: center;
  pointer-events: none;
}
.beta-toast {
  pointer-events: auto;
  width: 100%; max-width: 420px;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 6px 8px 16px;
  background: var(--ink); color: #eef3ef;
  border-radius: 14px; box-shadow: var(--shadow-lg);
  font-size: 0.95rem; line-height: 1.45;
}
.beta-toast p { flex: 1; min-width: 0; padding: 4px 0; }
.beta-toast a { color: var(--hl); font-weight: 600; }
.beta-toast a:hover { color: #fff; }
.beta-toast :focus-visible { outline-color: var(--hl); }
.beta-toast-x {
  flex: none; width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: #fff;
  font: 400 1.5rem/1 var(--font-body); cursor: pointer;
}
.beta-toast-x:hover { background: rgba(255, 255, 255, 0.12); }

@media (prefers-reduced-motion: no-preference) {
  .beta-gate:not([hidden]) { animation: beta-fade 0.2s ease-out both; }
  .beta-dialog, .beta-toast { animation: beta-rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
}
@keyframes beta-fade { from { opacity: 0; } }
@keyframes beta-rise { from { opacity: 0; transform: translateY(12px); } }

@media (min-width: 720px) {
  .beta-dialog { padding: 28px 28px 12px; }
  .beta-toasts { left: 24px; right: auto; bottom: 24px; width: 420px; justify-items: start; }
}

body.projector .beta-toasts { display: none; }

@media print {
  .beta-gate, .beta-toasts { display: none !important; }
  html.beta-locked, html.beta-locked body { overflow: visible !important; }
}

/* Students: class code instead of the sign-up (beta-gate.js) */
.beta-class { display: grid; gap: 10px; padding: 12px 14px; border: 1px solid var(--line, #d9d4c7); border-radius: 12px; background: var(--paper-2, #f7f4ec); }
.beta-class-toggle { justify-self: start; min-height: 44px; padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: var(--leaf-strong); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.beta-class-form { display: grid; gap: 8px; }
.beta-class-form[hidden], .beta-form[hidden] { display: none; }
.beta-class-row { display: flex; gap: 8px; }
.beta-class-row input { width: 9ch; min-height: 44px; padding: 0 12px; border: 1px solid var(--line, #d9d4c7); border-radius: 10px; font: inherit; font-size: 1.1rem; letter-spacing: 0.12em; text-transform: uppercase; }
.beta-class-msg { font-weight: 600; color: var(--leaf-strong); }
.beta-class-msg:empty { display: none; }
.beta-class-msg.is-error { color: #8f2a19; }
/* Student view: teacher-only boxes stay out of sight */
.sp-student .reveal-box--teacher { display: none !important; }

/* Free-account wall and unit locks (js/sp-wall.js; only on pages built with SIGNUP_LIVE in tools/beta_gate.py) */
html.sp-wall-wait #main { visibility: hidden; }
#sp-wall [hidden] { display: none !important; }
.sp-wall-actions { display: grid; gap: 10px; margin-top: 2px; }
.sp-wall-actions .btn { width: 100%; justify-content: center; }
.sp-wall-actions .beta-signin { text-align: center; }
#sp-wall-note { font-weight: 600; color: var(--ink); }
