/* SyllabusGrinder — IGCSE Revision App */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Nunito', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 800px at 20% 10%, #d4c3f5 0%, transparent 60%),
    radial-gradient(900px 600px at 90% 100%, #a98be0 0%, transparent 55%),
    linear-gradient(160deg, #c4b2ed 0%, #9d80d8 60%, #8a6cd0 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

#root {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;         /* centre the app column horizontally */
}

/* Per-screen wrapper (holds the shell + dev tweaks panel). Must be width-
   constrained so the in-app horizontal scrollers can't stretch the page. */
.sn-root {
  position: relative;
  width: 100%;
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;         /* centre the shell horizontally */
  justify-content: center;     /* …and vertically, so the card sits centred on
                                  tall desktop windows (the shell is capped below
                                  viewport height, so this never clips/scrolls) */
}

/* App shell — replaces the simulated iPhone frame. On a phone it fills the
   whole screen; on a wide screen it becomes a centered phone-width column. */
.sn-shell {
  position: relative;
  width: 100%;            /* fill the phone screen exactly (no max-width here) */
  min-width: 0;           /* flex item: don't grow to content width (would overflow) */
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* Full-bleed at EVERY width: the app fills the screen edge-to-edge — no centered
   card, no backdrop framing, no side edges/glow/vignette. The base .sn-shell
   (width:100%, height:100dvh, no radius/shadow) already does this, so larger
   screens just inherit it. */
#root { padding: 0; }

/* hide scrollbars for in-app scrollers */
.sn-scroll-x {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sn-scroll-x::-webkit-scrollbar { display: none; }

.sn-scroll-y {
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sn-scroll-y::-webkit-scrollbar { display: none; }

/* Screen container clipped to phone screen */
.sn-app {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  font-family: 'Nunito', system-ui, sans-serif;
  overflow: hidden;
  /* Clear the device's real status bar / notch (0 on desktop). */
  padding-top: max(env(safe-area-inset-top, 0px), 12px);
  background: var(--sn-app-bg);
  color: var(--sn-ink);
  transition: background 0.32s ease, color 0.32s ease;
}

/* Light mode tokens */
.sn-app[data-mode="light"] {
  --sn-app-bg: linear-gradient(180deg, #efe9ff 0%, #e2d6ff 100%);
  --sn-surface: #ffffff;
  --sn-surface-2: #f7f2ff;
  --sn-divider: rgba(107, 79, 187, 0.12);
  --sn-ink: #2a1e4a;
  --sn-ink2: #5b4d7a;
  --sn-muted: #8b81a8;
  --sn-tint: rgba(107, 79, 187, 0.10);
  --sn-tint-strong: rgba(107, 79, 187, 0.16);
}

/* Dark mode tokens */
.sn-app[data-mode="dark"] {
  --sn-app-bg: linear-gradient(180deg, #181230 0%, #0f0a22 100%);
  --sn-surface: #221a40;
  --sn-surface-2: #2c2350;
  --sn-divider: rgba(255, 255, 255, 0.10);
  --sn-ink: #f3eeff;
  --sn-ink2: #c8bfe5;
  --sn-muted: #8c82b3;
  --sn-tint: rgba(155, 127, 212, 0.18);
  --sn-tint-strong: rgba(155, 127, 212, 0.28);
}

/* Adjust shadows in dark mode so cards still feel lifted */
.sn-app[data-mode="dark"] .sn-card-shadow {
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.42);
}

/* Screen content area scrolls */
.sn-content {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: none;
  padding-bottom: 110px; /* leave room for tab bar */
}
.sn-content::-webkit-scrollbar { display: none; }

/* Pop animation when a screen mounts */
@keyframes sn-slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.sn-mount {
  animation: sn-slide-up 0.32s cubic-bezier(.2,.7,.2,1) both;
  /* Force a clean compositor layer so the transform fade-in doesn't leave a faint
     "ghost" copy on some GPUs/mobile browsers. */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-style: flat;
}
@media (prefers-reduced-motion: reduce) {
  .sn-mount { animation: none; }
}

@keyframes sn-pop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
.sn-pop { animation: sn-pop 0.4s cubic-bezier(.2,.7,.2,1) both; }

@keyframes sn-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.sn-shake { animation: sn-shake 0.4s; }

@keyframes sn-sparkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.85; }
  50% { transform: scale(1.15) rotate(15deg); opacity: 1; }
}
.sn-sparkle { animation: sn-sparkle 2.4s ease-in-out infinite; transform-origin: center; }

@keyframes sn-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.sn-float { animation: sn-float 3.2s ease-in-out infinite; }

/* Tap feedback */
.sn-tap { transition: transform 0.12s ease, box-shadow 0.18s ease; cursor: pointer; user-select: none; }
.sn-tap:active { transform: scale(0.96); }
/* Keyboard focus ring (mouse clicks don't trigger :focus-visible, so this only
   shows for keyboard/AT users — see a11y.jsx). */
.sn-tap:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid #6B4FBB;
  outline-offset: 2px;
  border-radius: 12px;
}

/* ── School Admin dashboard — full-screen takeover (escapes the phone column),
   responsive sidebar. Inherits the app's CSS vars via the .sn-app ancestor. ── */
.sn-admin {
  position: fixed; inset: 0; z-index: 500;
  display: flex; flex-direction: column;
  background: var(--sn-app-bg, #efe9ff);
  color: var(--sn-ink, #2a1e4a);
}
.sn-admin-nav {
  display: flex; flex-direction: row; align-items: center; gap: 6px;
  padding: 10px; overflow-x: auto; flex-shrink: 0;
  background: var(--sn-surface, #fff);
  box-shadow: 0 2px 12px rgba(80, 50, 160, 0.08);
}
.sn-admin-nav::-webkit-scrollbar { display: none; }
.sn-admin-brand { display: flex; align-items: center; gap: 8px; padding: 0 8px; flex-shrink: 0; }
.sn-admin-brand-text { display: none; }
.sn-admin-navitem {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 12px; border: none; background: transparent;
  color: var(--sn-ink2, #5b4d7a); font-weight: 800; font-size: 13px; font-family: inherit;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.sn-admin-navitem[data-active="true"] { background: var(--sn-tint, rgba(107,79,187,0.12)); color: #6B4FBB; }
.sn-admin-main {
  flex: 1; overflow-y: auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
}
@media (min-width: 840px) {
  .sn-admin { flex-direction: row; }
  .sn-admin-nav {
    flex-direction: column; align-items: stretch; width: 234px;
    overflow-x: hidden; overflow-y: auto; padding: 18px 12px; gap: 4px;
  }
  .sn-admin-brand { padding: 4px 10px 16px; }
  .sn-admin-brand-text { display: block; }
  .sn-admin-navitem { width: 100%; }
  .sn-admin-main { padding: 30px 36px; max-width: 1100px; }
}

/* Spinner */
@keyframes sn-spin { to { transform: rotate(360deg); } }
.sn-spin { animation: sn-spin 0.9s linear infinite; }

/* Loading skeleton shimmer (parent dashboard, and reusable elsewhere) */
.sg-skel { position: relative; overflow: hidden; }
.sg-skel::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  transform: translateX(-100%); animation: sg-shimmer 1.3s infinite;
}
@keyframes sg-shimmer { 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .sg-skel::after { animation: none; } }

/* Quick-tile animations (Join Quiz / Leaderboard / Achievements) */
@keyframes sn-tile-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
.sn-tile-bob { animation: sn-tile-bob 3s ease-in-out infinite; }

@keyframes sn-icon-pop {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.14) rotate(-8deg); }
}
.sn-icon-pop { animation: sn-icon-pop 2.4s ease-in-out infinite; transform-origin: center; }

@keyframes sn-icon-bounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
  60% { transform: translateY(1px); }
}
.sn-icon-bounce { animation: sn-icon-bounce 1.8s ease-in-out infinite; }

@keyframes sn-icon-wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-12deg); }
  75% { transform: rotate(12deg); }
}
.sn-icon-wiggle { animation: sn-icon-wiggle 2s ease-in-out infinite; transform-origin: 50% 80%; }

/* sweeping shine across a tile */
@keyframes sn-shine-sweep {
  0% { transform: translateX(-160%) skewX(-20deg); }
  55%, 100% { transform: translateX(320%) skewX(-20deg); }
}
.sn-shine {
  position: absolute; top: 0; bottom: 0; left: 0; width: 35%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.38), transparent);
  animation: sn-shine-sweep 3.4s ease-in-out infinite;
  pointer-events: none;
}

/* Number badge pulse */
@keyframes sn-pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(107,79,187,0.45); }
  100% { box-shadow: 0 0 0 14px rgba(107,79,187,0); }
}
.sn-pulse-ring { animation: sn-pulse-ring 1.6s ease-out infinite; }

/* Progress bar fill */
.sn-progress {
  height: 8px;
  background: rgba(107,79,187,0.12);
  border-radius: 999px;
  overflow: hidden;
}
.sn-progress > div {
  height: 100%;
  background: linear-gradient(90deg, #6b4fbb, #9b7fd4);
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(.2,.7,.2,1);
}

@keyframes sn-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes sn-sheet-up {
  from { transform: translateY(100%); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}

@keyframes sn-confetti {
  0% { transform: translate(0, -20px) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx, 0), 320px) rotate(720deg); opacity: 0; }
}
.sn-confetti-piece {
  position: absolute;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  animation: sn-confetti 1.6s ease-out forwards;
}
