/* ── Reset & Base ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Notebook / graph-paper background tokens (global) ──
   A school-workbook grid drawn in pure CSS (two fine line gradients =
   squares) over a soft paper base. Applied site-wide behind content via
   body::before below, EXCEPT on the active test screen. */
:root {
  --paper:      #FCFBF8;                 /* soft warm cream "paper" base */
  --grid-line:  rgba(99, 91, 80, 0.14);  /* soft warm taupe rule — present but gentle */
  --grid-size:  28px;                    /* square size */
}
body {
  font-family: 'General Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--paper);
  color: #1a1a2e;
  min-height: 100vh;
  isolation: isolate;            /* own stacking context: grid paints above paper, below content */
}
/* Fixed graph-paper grid behind ALL content (viewport-stable, like the
   reference app). A soft centre veil dims the middle so text reads with a
   little more contrast; a radial mask fades the grid out toward the edges
   (strongest at the left/right sides) so it never reaches the rim. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(ellipse 62% 54% at 50% 41%, rgba(241, 238, 230, 0.74) 0%, rgba(241, 238, 230, 0) 72%),
    linear-gradient(to right,  transparent 0, var(--grid-line) 1px, transparent 2px),
    linear-gradient(to bottom, transparent 0, var(--grid-line) 1px, transparent 2px);
  background-size: 100% 100%, var(--grid-size) var(--grid-size), var(--grid-size) var(--grid-size);
  background-repeat: no-repeat, repeat, repeat;
  filter: blur(0.4px);
  -webkit-mask-image: radial-gradient(ellipse 70% 92% at 50% 48%, #000 38%, transparent 95%);
          mask-image: radial-gradient(ellipse 70% 92% at 50% 48%, #000 38%, transparent 95%);
}
/* Exclude the test-taking screen: hide the grid and restore the plain bg. */
body:has(#test-screen.active) { background: #F6F7F9; }
body:has(#test-screen.active)::before { display: none; }

.screen { display: none; width: 100%; }
.screen.active { display: block; animation: screenFadeIn 0.35s ease-out; }

/* ── Global persistent Clerk UserButton ──────────────── */
#global-user-button {
  position: fixed;
  top: 0;
  right: 32px;
  height: 53px;
  z-index: 200;
  display: none; /* shown via JS when signed in */
  align-items: center;
}
@media (max-width: 600px) {
  #global-user-button { right: 16px; height: 49px; }
}
@keyframes screenFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════
   APP LAYOUT SYSTEM — Shared across all product screens
   ══════════════════════════════════════════════════════ */

/* ── App Navigation Bar ─────────────────────────────── */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  /* Match the landing nav: translucent frosted paper so the grid reads through. */
  background: rgba(252, 252, 251, 0.72);
  backdrop-filter: blur(14px) saturate(1.05);
  -webkit-backdrop-filter: blur(14px) saturate(1.05);
  border-bottom: 1px solid rgba(17, 24, 39, 0.07);
}
.app-nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.app-nav-logo {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.3px;
  background: none;
  border: none;
  cursor: default;
}
.app-nav-home {
  cursor: pointer;
  transition: color 0.15s;
}
.app-nav-home:hover { color: #4361ee; }
.app-nav-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  overflow: hidden;
}
.app-nav-back {
  background: none;
  border: none;
  color: #6B7280;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.app-nav-back:hover {
  color: #4361ee;
  background: rgba(67,97,238,0.06);
}
.app-nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  padding-right: 40px;
}

/* ── Breadcrumb Bar ──────────────────────────────────── */
.breadcrumb-bar {
  /* Match the landing/app nav frosted paper. */
  background: rgba(252, 252, 251, 0.72);
  backdrop-filter: blur(10px) saturate(1.05);
  -webkit-backdrop-filter: blur(10px) saturate(1.05);
  border-bottom: 1px solid rgba(17, 24, 39, 0.07);
  padding: 0 40px;
}
.breadcrumb-bar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #9CA3AF;
}
.breadcrumb-bar a {
  color: #6B7280;
  text-decoration: none;
  font-weight: 500;
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
  transition: color 0.15s, background 0.15s;
}
.breadcrumb-bar a:hover {
  color: #4361ee;
  background: rgba(67,97,238,0.06);
}
.breadcrumb-sep {
  font-size: 11px;
  color: #D1D5DB;
  user-select: none;
}
.breadcrumb-current {
  color: #374151;
  font-weight: 500;
}
@media (max-width: 768px) {
  .breadcrumb-bar { padding: 0 24px; }
}
@media (max-width: 600px) {
  .breadcrumb-bar { padding: 0 16px; }
  .breadcrumb-bar-inner { font-size: 12px; }
}

/* ── App Sections (full-width bands) ─────────────────── */
.app-section {
  width: 100%;
  padding: 48px 40px;
}
.app-section--white { background: #FFFFFF; }
.app-section--neutral { background: transparent; }  /* reveal the paper + grid */

/* ── App Content Grid ────────────────────────────────── */
.app-grid {
  max-width: 1280px;
  margin: 0 auto;
}
.app-section-center {
  text-align: center;
}

/* ── App Page Headings ───────────────────────────────── */
.app-page-title {
  font-size: 30px;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.3px;
  margin-bottom: 12px;
}
.app-page-sub {
  font-size: 15px;
  color: #6B7280;
  line-height: 1.65;
  margin-bottom: 32px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* ── App Band Heading ────────────────────────────────── */
.app-band-heading {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9CA3AF;
  margin-bottom: 16px;
  text-align: center;
}

/* ── Language Dropdown ────────────────────────────────── */
.lang-toggle {
  position: relative;
  margin-bottom: 0;
}
.lang-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  border: 1.5px solid #E5E7EB;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.lang-trigger:hover { border-color: #bfc4cc; }
.lang-trigger:focus-visible { outline: 2px solid #4361ee; outline-offset: 2px; }
.lang-toggle.open .lang-trigger { border-color: #4361ee; box-shadow: 0 0 0 3px rgba(67,97,238,0.12); }
.lang-trigger-globe {
  width: 16px; height: 16px;
  flex-shrink: 0;
  opacity: 0.55;
}
.lang-trigger-chevron {
  width: 12px; height: 12px;
  flex-shrink: 0;
  opacity: 0.4;
  transition: transform 0.2s;
}
.lang-toggle.open .lang-trigger-chevron { transform: rotate(180deg); }

.lang-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  max-height: 320px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.04);
  padding: 4px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
  z-index: 200;
}
.lang-toggle.open .lang-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.lang-dropdown::-webkit-scrollbar { width: 6px; }
.lang-dropdown::-webkit-scrollbar-track { background: transparent; }
.lang-dropdown::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 3px; }

.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
  text-align: left;
}
.lang-option:hover { background: #F3F4F6; }
.lang-option.active { background: #EEF2FF; color: #4361ee; font-weight: 600; }
.lang-option-code {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #9CA3AF;
  min-width: 32px;
}
.lang-option.active .lang-option-code { color: #4361ee; }
.lang-option-check {
  margin-left: auto;
  width: 14px; height: 14px;
  opacity: 0;
}
.lang-option.active .lang-option-check { opacity: 1; color: #4361ee; }

/* ── Link Button ─────────────────────────────────────── */
.btn-link {
  background: none;
  border: none;
  color: #4361ee;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}
.btn-link:hover { text-decoration: underline; }
