/* ========================================
   AUTH — Supabase login + save (Brief 02)
   Self-contained: visibility via .is-hidden / .open, no reliance on app.js utils.
   ======================================== */
.is-hidden { display: none !important; }

/* ---- modal overlay ---- */
.auth-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(3px);
  padding: 24px;
}
.auth-overlay.open { display: flex; }

/* Brief 18: the modal wears the Assembly tokens (declared on .auth-overlay in style.css):
   white surface, 12 px radius, Stolzl title, brand-green act, orange focus. Same modal on
   every screen; only its styling changed. */
.auth-modal {
  position: relative;
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(46, 46, 46, 0.18), 0 4px 16px rgba(46, 46, 46, 0.08);
  padding: 32px 32px 28px;
  font-family: var(--font-body);
  color: var(--ink);
}
.auth-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--ink-soft);
}
.auth-close:hover { color: var(--ink); }
.auth-title {
  font-family: var(--font-display);
  font-weight: var(--w-medium);
  font-size: 26px; line-height: 32px; letter-spacing: -0.01em;
  color: var(--brand-green);
  margin: 0 0 4px;
}
.auth-subtitle { font-family: var(--font-detail); font-size: 14px; line-height: 20px; color: var(--ink-soft); margin: 0 0 16px; }

.auth-tabs {
  display: flex; gap: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px; padding: 4px; margin: 16px 0 20px;
}
.auth-tab {
  flex: 1; padding: 8px; border: none; cursor: pointer;
  background: transparent; border-radius: 999px;
  font-family: var(--font-body); font-size: 14px; font-weight: 500;
  color: var(--ink-soft); transition: all 0.2s ease;
}
.auth-tab.active {
  background: var(--surface); color: var(--brand-green);
  box-shadow: 0 1px 3px rgba(46,46,46,0.08);
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field span { font-family: var(--font-detail); font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.auth-field input {
  height: 48px; padding: 0 16px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface);
  color: var(--ink); font-family: var(--font-body); font-size: 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.auth-field input:focus {
  outline: none; border-color: var(--brand-green);
  box-shadow: 0 0 0 4px rgba(35,85,70,0.12);
}

.auth-terms {
  display: flex; align-items: flex-start; gap: 8px;
  font-family: var(--font-detail); font-size: 13px; color: var(--ink-soft); line-height: 1.4;
}
.auth-terms input { margin-top: 2px; accent-color: var(--brand-green); }
.auth-terms a { color: var(--brand-green); }

.auth-error {
  font-size: 12px; color: var(--coral);
  background: rgba(224,107,82,0.08); border-radius: 8px;
  padding: 8px 10px; margin: 0;
}

.auth-submit {
  margin-top: 4px; height: 52px; padding: 0 16px; border: none; cursor: pointer;
  background: var(--brand-green); color: var(--surface);
  border-radius: 12px; font-family: var(--font-body);
  font-size: 16px; font-weight: 500; transition: filter 0.2s ease;
}
.auth-submit:hover { filter: brightness(1.08); }
.auth-submit:focus-visible { outline: 3px solid var(--brand-orange); outline-offset: 2px; }
.auth-submit:disabled { opacity: 0.6; cursor: default; }

/* ---- the one account button, top right (Brief 235 r03, Linzie 7 Nov: one button) ----
   Signed out "Sign in / Sign up", signed in "My decodED": the same house orange with white words either way, so it reads
   as the same button (Linzie, 3 Nov: white text on every orange box). While My decodED is open it shows pressed. */
.topbar-right { position: relative; }
.topbar-login-btn,
body.on-welcome .topbar-login-btn,
.topbar-login-btn.signed-in,
body.on-welcome .topbar-login-btn.signed-in {
  background: var(--orange, #E28F2C); border-color: var(--orange, #E28F2C); color: var(--surface, #FFFFFF);
  font-weight: 600; white-space: nowrap;
}
.topbar-login-btn:hover,
body.on-welcome .topbar-login-btn:hover { filter: brightness(0.95); border-color: var(--orange, #E28F2C); color: var(--surface, #FFFFFF); background: var(--orange, #E28F2C); }
.topbar-login-btn[aria-expanded="true"] { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85); }
/* Brief 245: people asking to join, counted on the button. */
.login-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; margin-left: 6px;
  padding: 0 5px; border-radius: 999px; background: var(--surface, #FFFFFF); color: var(--green, #235546);
  font-size: 11px; font-weight: 700; line-height: 1;
}
/* Brief 81: the Pro chip, beside the account button while a school you have Pro on is open. */
.topbar-pro-chip {
  display: inline-flex; align-items: center; height: 24px; padding: 0 10px; margin-right: 8px;
  border: 1px solid var(--green, #235546); border-radius: 999px; color: var(--green, #235546);
  font-family: var(--font-body); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.topbar-pro-chip[hidden] { display: none; }
/* Brief 157 P1: forgot password */
.auth-forgot {
  align-self: flex-start; margin-top: -4px; padding: 0; border: 0; background: none;
  font: inherit; font-size: 0.85rem; color: var(--brand-green); text-decoration: underline; cursor: pointer;
}
.auth-forgot:focus-visible { outline: 3px solid var(--brand-orange); outline-offset: 2px; }
.auth-note { margin: 0; font-size: 0.9rem; color: var(--brand-green); }
#authTabs.is-hidden + .auth-form { margin-top: 14px; }

/* Brief 157: two editors at once */
.twin-conflict {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 3000;
  width: min(560px, calc(100vw - 32px)); padding: 14px 16px; border-radius: 12px;
  background: var(--surface, #fff); color: var(--ink); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  border-left: 4px solid var(--green); font-family: var(--font-body);
}
.twin-conflict p { margin: 0 0 10px; font-size: 14px; line-height: 1.45; }
.twin-conflict-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.twin-conflict-btn {
  padding: 7px 16px; border-radius: 999px; border: 1px solid var(--green); background: var(--green); color: #fff;
  font: 600 14px var(--font-body); cursor: pointer;
}
.twin-conflict-btn-quiet { background: transparent; color: var(--green); }
.twin-conflict-btn:focus-visible { outline: 3px solid var(--brand-orange); outline-offset: 2px; }
.twin-conflict-btn:disabled { opacity: 0.6; cursor: default; }


/* Brief 235 r03: My decodED inside the app (my-panel.js). It fills the workspace beside the left menu, under the top bar
   (the top bar stays above it, z-index 100), so the modules stay one tap away. */
.my-panel {
  position: fixed; right: 0; top: 56px; left: 0; bottom: 0; z-index: 95;
  background: var(--cream, #F4F2EE); border-top: 1px solid var(--divider, #E3DED4);
}
.my-panel[hidden] { display: none; }
.my-panel-frame { display: block; width: 100%; height: 100%; border: 0; background: transparent; }
.my-panel-close {
  position: absolute; top: 12px; right: 16px; z-index: 1; width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid var(--divider, #E3DED4); background: var(--surface, #fff); color: var(--ink, #2A2A2A);
  font: 400 22px/1 var(--font-body); cursor: pointer;
}
.my-panel-close:focus-visible { outline: 3px solid var(--orange, #E28F2C); outline-offset: 2px; }

/* Chris, 8 Nov: with My decodED open, the decodED logo is a way out (my-panel.js closes it; app.js goes on). */
body.my-panel-open .topbar-logo { cursor: pointer; }

/* ---- Brief 256 P2: Sign up = paying for Pro (One site / Multi-site / Academy trust) ---- */
.auth-modal.is-buy {
  max-width: 640px; max-height: calc(100vh - 32px); overflow-y: auto; scrollbar-gutter: stable; padding: 24px 32px 20px;
  display: flex; flex-direction: column;
}
.auth-modal.is-buy .auth-tabs { order: -1; margin: 0 32px 14px 0; }
.auth-modal.is-buy .auth-form { gap: 12px; }
.auth-modal.is-buy .auth-title { font-size: 22px; line-height: 28px; margin-bottom: 12px; }
.auth-modal.is-buy .auth-close { top: 30px; }
.auth-modal.is-buy .auth-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.auth-pair { display: flex; flex-direction: column; gap: 14px; }
.auth-modal.is-buy .auth-submit { background: var(--orange, #E28F2C); }
.auth-buy { display: flex; flex-direction: column; gap: 10px; }
.auth-modes {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 4px;
}
.auth-mode {
  padding: 8px 6px; border: 1px solid transparent; border-radius: 9px; background: transparent; cursor: pointer;
  font: 500 14px var(--font-body); color: var(--ink-soft);
}
.auth-mode.active { background: var(--surface); border-color: var(--orange, #E28F2C); color: var(--ink); font-weight: 600; }
.auth-mode:focus-visible, .auth-interval-btn:focus-visible, .auth-link:focus-visible, .auth-find-item:focus-visible {
  outline: 3px solid var(--orange, #E28F2C); outline-offset: 2px;
}
.auth-find { position: relative; }
.auth-find input {
  width: 100%; box-sizing: border-box; height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px;
  font: 15px var(--font-body); color: var(--ink); background: var(--surface);
}
.auth-find input:focus { outline: none; border-color: var(--brand-green); box-shadow: 0 0 0 4px rgba(35,85,70,0.12); }
.auth-find-list {
  position: absolute; z-index: 2; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,0.14);
  max-height: 260px; overflow-y: auto; scrollbar-gutter: stable;
}
.auth-find-list[hidden] { display: none; }
.auth-find-item {
  display: flex; justify-content: space-between; gap: 12px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; cursor: pointer; text-align: left; font: 14px var(--font-body); color: var(--ink);
}
.auth-find-item:hover { background: var(--bg); }
.auth-find-where, .auth-find-none { color: var(--ink-soft); font-size: 13px; white-space: nowrap; }
.auth-find-none { padding: 8px 10px; }
.auth-list { max-height: max(120px, min(196px, calc(100vh - 615px))); overflow-y: auto; scrollbar-gutter: stable; }
.auth-list:empty { display: none; }
.auth-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line);
  font: 14px var(--font-body); color: var(--ink); cursor: default;
}
.auth-row input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--brand-green); cursor: pointer; flex: none; }
.auth-row-name { flex: 1; min-width: 0; }
.auth-row-name b { font-weight: 500; }
.auth-row-about { margin-left: 8px; color: var(--ink-soft); font-size: 13px; }
.auth-row-price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.auth-row-unit { color: var(--ink-soft); font-size: 13px; }
.auth-row-all { border-bottom: 1px solid var(--ink-soft); }
.auth-row-all .auth-row-name { font-weight: 600; }
.auth-trust {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px;
  background: var(--bg); border-radius: 10px; font: 14px var(--font-body);
}
.auth-trust div { display: flex; flex-direction: column; gap: 2px; }
.auth-trust span { color: var(--ink-soft); font-size: 13px; }
.auth-link {
  padding: 0; border: 0; background: none; cursor: pointer; font: inherit; color: var(--brand-green); text-decoration: underline;
  white-space: nowrap;
}
.auth-hint { margin: 0; font: 13px var(--font-detail); color: var(--ink-soft); }
.auth-total {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px;
  border-top: 2px solid var(--ink); font: 15px var(--font-body); color: var(--ink);
}
.auth-total-sum { color: var(--ink-soft); font-size: 14px; }
.auth-total-sum b { font: 600 22px var(--font-display); color: var(--ink); }
.auth-total-left { display: flex; align-items: center; gap: 12px; }
.auth-interval { display: flex; gap: 4px; }
.auth-interval-btn {
  padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer;
  font: 500 13px var(--font-body); color: var(--ink-soft);
}
.auth-interval-btn.active { border-color: var(--orange, #E28F2C); background: var(--orange, #E28F2C); color: #fff; }
.auth-foot { margin: 0; text-align: center; font: 13px var(--font-detail); color: var(--ink-soft); }
.auth-foot a { color: var(--brand-green); }
@media (max-width: 560px) {
  .auth-modal.is-buy { padding: 20px 16px 16px; }
  .auth-modal.is-buy .auth-pair { grid-template-columns: 1fr; }
  .auth-row-about { display: block; margin-left: 0; }
}
