/* =================================================================
   style.css
   Nightingale Nursery School — Interschool Quiz Score Calculator
   -----------------------------------------------------------------
   Shared design system: tokens, base styles, buttons, forms, toasts,
   modals, and the full Live Scoreboard (public) layout + animations.
   admin.css builds on top of these tokens for the admin-only shell.
   ================================================================= */

/* ---------------------------------------------------------------
   1. Design tokens
   --------------------------------------------------------------- */
:root {
  /* Brand palette (from brief) */
  --color-primary: #0f172a;        /* Dark Blue */
  --color-primary-soft: #1e293b;
  --color-secondary: #1e3a8a;      /* Royal Blue */
  --color-secondary-bright: #2f5fd6;
  --color-accent: #d4af37;         /* Gold */
  --color-accent-soft: #f2cb57;
  --color-bg: #eef2f7;             /* Light Gray */
  --color-surface: #ffffff;

  --color-text: #101827;
  --color-text-muted: #62708a;
  --color-text-invert: #f8fafc;
  --color-border: #e2e8f0;

  --color-success: #16a34a;
  --color-danger: #dc2626;
  --color-danger-soft: #fee2e2;

  --font-display: "Sora", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --radius-pill: 999px;

  --shadow-soft: 0 14px 34px -14px rgba(15, 23, 42, 0.22);
  --shadow-card: 0 3px 14px rgba(15, 23, 42, 0.07);
  --shadow-gold: 0 0 0 2px rgba(212, 175, 55, 0.55), 0 12px 30px -10px rgba(212, 175, 55, 0.45);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

html.dark-mode {
  --color-bg: #0b1220;
  --color-surface: #131c2e;
  --color-text: #eef2f7;
  --color-text-muted: #93a3bd;
  --color-border: #24304a;
  --color-primary-soft: #1a2437;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------------------------------------------------------
   2. Reset & base
   --------------------------------------------------------------- */
* , *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s var(--ease-out), color 0.3s var(--ease-out);
}
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }
img { max-width: 100%; display: block; }
a { color: inherit; }
::selection { background: var(--color-accent-soft); color: var(--color-primary); }

/* ---------------------------------------------------------------
   3. Buttons
   --------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-pill);
  padding: 11px 20px;
  font-size: 0.92rem;
  font-weight: 600;
  transition: transform 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out), background 0.2s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn--primary {
  background: linear-gradient(135deg, var(--color-secondary), var(--color-secondary-bright));
  color: #fff;
  box-shadow: 0 8px 20px -8px rgba(30, 58, 138, 0.6);
}
.btn--primary:hover { box-shadow: 0 10px 24px -8px rgba(30, 58, 138, 0.7); }
.btn--ghost {
  background: transparent;
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
}
.btn--ghost:hover { border-color: var(--color-secondary); color: var(--color-secondary); }
.btn--danger {
  background: var(--color-danger);
  color: #fff;
}
.btn--danger-outline {
  background: transparent;
  color: var(--color-danger);
  border: 1.5px solid var(--color-danger-soft);
}
.btn--danger-outline:hover { background: var(--color-danger-soft); }
.btn--block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn__spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
  text-decoration: none;
  transition: border-color 0.2s, transform 0.15s;
}
.icon-btn:hover { border-color: var(--color-accent); transform: translateY(-1px); }

/* ---------------------------------------------------------------
   4. Forms
   --------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field--inline { margin-bottom: 0; min-width: 220px; }
.field__label { font-size: 0.82rem; font-weight: 600; color: var(--color-text-muted); }
.field__label em { font-weight: 400; font-style: italic; opacity: 0.8; }
.field__input {
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 0.95rem;
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field__input:focus {
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.15);
}

/* ---------------------------------------------------------------
   5. Toasts
   --------------------------------------------------------------- */
.toast-container {
  position: fixed;
  top: 18px; right: 18px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
  max-width: min(360px, 90vw);
}
.toast {
  background: var(--color-primary);
  color: #fff;
  padding: 13px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-soft);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out);
}
.toast--visible { opacity: 1; transform: translateY(0); }
.toast--success { background: var(--color-success); }
.toast--error { background: var(--color-danger); }
.toast--info { background: var(--color-secondary); }

/* ---------------------------------------------------------------
   6. Modals
   --------------------------------------------------------------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(10, 15, 28, 0.55);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s var(--ease-out);
  z-index: 10000;
  padding: 20px;
}
.modal.is-open { opacity: 1; pointer-events: all; }
.modal__panel {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 26px;
  width: min(420px, 100%);
  box-shadow: var(--shadow-soft);
  transform: translateY(14px) scale(0.98);
  transition: transform 0.25s var(--ease-out);
}
.modal.is-open .modal__panel { transform: translateY(0) scale(1); }
.modal__title { font-size: 1.15rem; margin-bottom: 16px; }
.modal__title span { color: var(--color-secondary); }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------------------------------------------------------------
   7. Login page
   --------------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 15% 15%, rgba(212,175,55,0.12), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(47,95,214,0.18), transparent 50%),
    var(--color-primary);
  padding: 20px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 40px 34px;
  box-shadow: var(--shadow-soft);
}
.login-card__brand { text-align: center; margin-bottom: 26px; }
.login-card__crest { font-size: 2.2rem; margin-bottom: 6px; }
.login-card__eyebrow { color: var(--color-secondary); font-weight: 700; font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; }
.login-card__title { font-size: 1.5rem; margin: 6px 0 6px; }
.login-card__subtitle { color: var(--color-text-muted); font-size: 0.9rem; }
.login-form__hint { text-align: center; color: var(--color-text-muted); font-size: 0.8rem; margin-top: 14px; }

/* ---------------------------------------------------------------
   8. Loader
   --------------------------------------------------------------- */
.loader {
  position: fixed; inset: 0;
  background: var(--color-primary);
  color: var(--color-text-invert);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  z-index: 5000;
  transition: opacity 0.4s var(--ease-out), visibility 0.4s;
}
.loader.is-hidden { opacity: 0; visibility: hidden; }
.loader__crest { font-size: 2.6rem; animation: pulse 1.6s ease-in-out infinite; }
.loader__text { font-size: 0.95rem; opacity: 0.8; letter-spacing: 0.02em; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1;} 50% { transform: scale(1.12); opacity: 0.7;} }

/* ---------------------------------------------------------------
   9. Scoreboard shell
   --------------------------------------------------------------- */
.scoreboard-body {
  min-height: 100vh;
  background: var(--color-bg);
  position: relative;
  overflow-x: hidden;
}
.scoreboard-bg {
  position: fixed; inset: 0;
  background:
    radial-gradient(circle at 10% 0%, rgba(30,58,138,0.10), transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(212,175,55,0.12), transparent 40%);
  pointer-events: none;
  z-index: 0;
}
.scoreboard-header {
  position: relative; z-index: 1;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-soft));
  color: var(--color-text-invert);
  padding: 26px 5vw 34px;
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  border-bottom: 3px solid var(--color-accent);
}
.scoreboard-header__eyebrow {
  color: var(--color-accent-soft);
  font-weight: 700; font-size: 0.82rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.scoreboard-header__title {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  font-weight: 800;
  line-height: 1.15;
}
.scoreboard-header__round {
  margin-top: 8px;
  display: inline-block;
  background: rgba(212, 175, 55, 0.18);
  border: 1px solid rgba(212, 175, 55, 0.5);
  color: var(--color-accent-soft);
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
}
.scoreboard-header__meta { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.scoreboard-clock {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #fff;
  background: rgba(255,255,255,0.08);
  padding: 8px 18px;
  border-radius: var(--radius-md);
}
.scoreboard-header__actions { display: flex; gap: 8px; }
.scoreboard-header__actions .icon-btn { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.2); color: #fff; }

.scoreboard-main {
  position: relative; z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 5vw 60px;
}

.scoreboard-footer {
  position: relative; z-index: 1;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 18px 20px 34px;
}
.scoreboard-footer__dot { margin: 0 8px; opacity: 0.5; }

.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: 60px 20px;
  font-size: 1rem;
}

/* ---------------------------------------------------------------
   10. Podium (top 3)
   --------------------------------------------------------------- */
.podium {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-bottom: 34px;
}
.podium-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 26px 22px;
  box-shadow: var(--shadow-card);
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
}
.podium-card__rank-badge {
  font-size: 1.9rem;
  line-height: 1;
  margin-bottom: 10px;
}
.podium-card__team {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
}
.podium-card__school {
  color: var(--color-text-muted);
  font-size: 0.88rem;
  margin-top: 3px;
}
.podium-card__score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.4rem;
  margin-top: 14px;
  color: var(--color-secondary);
}
.podium-card--gold {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-gold);
  order: -1;
}
.podium-card--gold .podium-card__score { color: var(--color-accent); }
.podium-card--gold::before {
  content: "";
  position: absolute; inset: -40% -40% auto -40%;
  height: 160%;
  background: radial-gradient(circle, rgba(212,175,55,0.16), transparent 60%);
  animation: goldGlow 2.8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes goldGlow {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.06); }
}
.podium-card__trophy { position: absolute; top: 18px; right: 20px; font-size: 1.6rem; }
.podium-card--silver { border-color: #c7d2e0; }
.podium-card--silver .podium-card__score { color: #64748b; }
.podium-card--bronze { border-color: #d8b48a; }
.podium-card--bronze .podium-card__score { color: #b5764a; }

/* ---------------------------------------------------------------
   10b. Team list — one row per team, alphabetical (public + admin)
   --------------------------------------------------------------- */
.team-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.team-row {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 16px 22px;
  box-shadow: var(--shadow-card);
  border: 2px solid transparent;
  position: relative;
  flex-wrap: wrap;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out), border-color 0.25s;
}
.team-row__rank {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-text-muted);
  background: var(--color-bg);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  min-width: 46px;
  text-align: center;
  flex-shrink: 0;
}
.team-row__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  min-width: 90px;
}
.team-row__school {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  flex: 1;
  min-width: 140px;
}
.team-row__score-wrap {
  display: flex;
  align-items: baseline;
  gap: 6px;
  position: relative;
  margin-left: auto;
}
.team-row__score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--color-secondary);
}
.team-row__score-label { color: var(--color-text-muted); font-size: 0.8rem; }
.team-row__trophy { position: absolute; top: -10px; right: -6px; font-size: 1.2rem; }

.team-row--leader { border-color: var(--color-accent); box-shadow: var(--shadow-gold); }
.team-row--leader .team-row__score { color: var(--color-accent); }

.team-row.is-glowing { animation: cardGlow 0.9s var(--ease-out); }

.team-row__actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; margin-top: 4px; }
.team-row__actions .btn { padding: 8px 14px; font-size: 0.8rem; }

@media (min-width: 640px) {
  .team-row__rank { min-width: 56px; }
  .team-row__score { font-size: 1.8rem; }
}

/* ---------------------------------------------------------------
   11. Team grid + cards (legacy card layout, kept for reuse)
   --------------------------------------------------------------- */
.team-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
.team-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 20px 20px 22px;
  box-shadow: var(--shadow-card);
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out), border-color 0.25s;
}
.team-card__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.team-card__rank {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-text-muted);
  background: var(--color-bg);
  padding: 4px 11px;
  border-radius: var(--radius-pill);
}
.team-card__name { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; margin-top: 10px; }
.team-card__school { color: var(--color-text-muted); font-size: 0.86rem; margin-top: 2px; }
.team-card__score-row { display: flex; align-items: baseline; gap: 6px; margin-top: 16px; position: relative; }
.team-card__score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.1rem;
  color: var(--color-secondary);
}
.team-card__score-label { color: var(--color-text-muted); font-size: 0.82rem; }
.team-card--leader { border-color: var(--color-accent); box-shadow: var(--shadow-gold); }
.team-card--leader .team-card__score { color: var(--color-accent); }
.team-card__trophy { position: absolute; top: 16px; right: 16px; font-size: 1.3rem; }

.team-card.is-glowing { animation: cardGlow 0.9s var(--ease-out); }
@keyframes cardGlow {
  0% { box-shadow: 0 0 0 0 rgba(212,175,55,0.55); }
  40% { box-shadow: 0 0 0 10px rgba(212,175,55,0.18); }
  100% { box-shadow: 0 0 0 0 rgba(212,175,55,0); }
}

.score-float {
  position: absolute;
  right: 0; top: -4px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--color-success);
  animation: floatUp 1.1s var(--ease-out) forwards;
  pointer-events: none;
}
.score-float--negative { color: var(--color-danger); }
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(6px); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-38px); }
}

.team-card__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.team-card__actions .btn { padding: 8px 14px; font-size: 0.8rem; }

/* ---------------------------------------------------------------
   12. Responsive — Tablet (≥640px) & Desktop (≥1024px)
   --------------------------------------------------------------- */
@media (min-width: 640px) {
  .team-grid { grid-template-columns: repeat(2, 1fr); }
  .podium { grid-template-columns: repeat(3, 1fr); align-items: end; }
  .podium-card--gold { padding-top: 34px; }
}

@media (min-width: 1024px) {
  .team-grid { grid-template-columns: repeat(3, 1fr); }
  .team-grid--public { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1400px) {
  .team-grid--public { grid-template-columns: repeat(5, 1fr); }
}
