/* ============================================================
   NOLIQ — Main Stylesheet
   Parchment theme, high-contrast, youth-friendly
   ============================================================ */

:root {
  --parchment:  #fdf6e3;
  --parchment2: #f5ead0;
  --ink:        #1a1008;
  --ink-light:  #3d2b1f;
  --teal:       #0e7c7b;
  --teal-dark:  #085e5d;
  --teal-light: #e6f4f4;
  --gold:       #c8860a;
  --gold-light: #fff3cd;
  --red:        #b91c1c;
  --red-light:  #fde8e8;
  --green:      #166534;
  --green-light:#dcfce7;
  --border:     #d9c9a8;
  --shadow:     rgba(44,31,14,0.12);
  --radius:     12px;
  --radius-lg:  18px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--parchment);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
}

h1,h2,h3,.logo,.card-front,.card-back {
  font-family: 'Fredoka', sans-serif;
}

/* ── LAYOUT ───────────────────────────────────────────── */
.page-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 100px;
}

/* ── TOP NAV ──────────────────────────────────────────── */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--ink);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}
.top-nav .logo {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
}
.top-nav .logo span { color: var(--gold); }
.top-nav .nav-user {
  font-size: 13px;
  color: #ccc;
}

/* ── BOTTOM NAV ───────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--ink);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  z-index: 100;
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: #aaa;
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  padding: 4px 16px;
  border-radius: 8px;
  transition: color .15s;
}
.bottom-nav a .nav-icon { font-size: 20px; line-height: 1; }
.bottom-nav a.active, .bottom-nav a:hover { color: var(--gold); }

/* ── PANELS / CARDS ───────────────────────────────────── */
.panel {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px var(--shadow);
}
.panel-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 12px;
}

/* ── BUTTONS ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border-radius: var(--radius);
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform .1s, box-shadow .1s, background .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal-dark);
  box-shadow: 0 3px 0 var(--teal-dark);
}
.btn-primary:hover { background: var(--teal-dark); }
.btn-gold {
  background: var(--gold);
  color: #fff;
  border-color: #a06d08;
  box-shadow: 0 3px 0 #a06d08;
}
.btn-gold:hover { background: #a06d08; }
.btn-ghost {
  background: transparent;
  color: var(--ink-light);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--parchment2); }
.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: #991b1b;
  box-shadow: 0 3px 0 #991b1b;
}
.w-full { width: 100%; }
.mt-2 { margin-top: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ── FORMS ────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 5px;
  color: var(--ink-light);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  transition: border-color .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--teal);
}
.form-textarea { min-height: 90px; resize: vertical; }

/* ── ALERTS ───────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 12px;
}
.alert-error   { background: var(--red-light);   color: var(--red);   border: 1.5px solid #fca5a5; }
.alert-success { background: var(--green-light);  color: var(--green); border: 1.5px solid #86efac; }
.alert-info    { background: var(--teal-light);   color: var(--teal-dark); border: 1.5px solid #99d6d6; }
.alert-gold    { background: var(--gold-light);   color: var(--gold);  border: 1.5px solid #fcd34d; }

/* ── LOGIN PAGE ───────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--parchment);
}
.login-box {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 6px 24px var(--shadow);
}
.login-logo {
  font-family: 'Fredoka', sans-serif;
  font-size: 36px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  margin-bottom: 4px;
  letter-spacing: 2px;
}
.login-sub {
  text-align: center;
  color: var(--ink-light);
  font-size: 14px;
  margin-bottom: 24px;
}

/* ── FLASHCARD ────────────────────────────────────────── */
.flashcard-wrap {
  perspective: 1000px;
  cursor: pointer;
  margin: 20px 0;
}
.flashcard {
  width: 100%;
  min-height: 200px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .45s ease;
  border-radius: var(--radius-lg);
}
.flashcard.flipped { transform: rotateY(180deg); }
.card-front, .card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: 0 4px 16px var(--shadow);
  min-height: 200px;
}
.card-front {
  background: var(--ink);
  color: #fff;
  border: 2px solid var(--ink-light);
}
.card-back {
  background: var(--teal);
  color: #fff;
  border: 2px solid var(--teal-dark);
  transform: rotateY(180deg);
}
.card-hint {
  font-size: 11px;
  text-align: center;
  color: var(--ink-light);
  margin-top: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ── QUIZ OPTIONS ─────────────────────────────────────── */
.quiz-options {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}
.quiz-option {
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  transition: background .15s, border-color .15s;
}
.quiz-option:hover:not(:disabled) { background: var(--teal-light); border-color: var(--teal); }
.quiz-option.correct { background: var(--green-light); border-color: var(--green); color: var(--green); }
.quiz-option.wrong   { background: var(--red-light);   border-color: var(--red);   color: var(--red);   }
.quiz-option:disabled { cursor: not-allowed; }

/* ── MATCH GAME ───────────────────────────────────────── */
.match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}
.match-tile {
  padding: 14px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  color: var(--ink);
  transition: background .15s, border-color .15s;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.match-tile.selected  { background: var(--teal-light);  border-color: var(--teal); }
.match-tile.matched   { background: var(--green-light);  border-color: var(--green); color: var(--green); cursor: default; }
.match-tile.wrong-flash { background: var(--red-light);  border-color: var(--red); }

/* ── PROGRESS BAR ─────────────────────────────────────── */
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 16px;
}
.progress-fill {
  height: 100%;
  background: var(--teal);
  border-radius: 99px;
  transition: width .3s ease;
}

/* ── SET CARDS (dashboard) ────────────────────────────── */
.set-card {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.set-card:hover { border-color: var(--teal); box-shadow: 0 3px 12px var(--shadow); }
.set-card.selected { border-color: var(--teal); background: var(--teal-light); }
.set-card-title { font-family: 'Fredoka', sans-serif; font-size: 17px; font-weight: 600; color: var(--ink); }
.set-card-meta  { font-size: 12px; color: var(--ink-light); font-weight: 700; margin-top: 3px; }
.set-card-badge {
  background: var(--teal);
  color: #fff;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 10px;
  white-space: nowrap;
}

/* ── MODE BUTTONS ─────────────────────────────────────── */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}
.mode-btn {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 12px;
  cursor: pointer;
  text-align: center;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  color: var(--ink);
  font-size: 14px;
  transition: border-color .15s, background .15s;
}
.mode-btn .mode-icon { font-size: 28px; display: block; margin-bottom: 6px; }
.mode-btn:hover { border-color: var(--teal); background: var(--teal-light); }

/* ── ADMIN TABLE ──────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  background: var(--ink);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--parchment2); }

/* ── BADGE ────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.badge-admin   { background: var(--gold-light);  color: var(--gold); }
.badge-student { background: var(--teal-light);  color: var(--teal-dark); }

/* ── LOADING DOTS ─────────────────────────────────────── */
.loading-dots { display: inline-flex; gap: 4px; align-items: center; }
.loading-dots span {
  width: 7px; height: 7px;
  background: currentColor;
  border-radius: 50%;
  animation: dot-bounce .7s infinite alternate;
}
.loading-dots span:nth-child(2) { animation-delay: .15s; }
.loading-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes dot-bounce {
  from { transform: translateY(0); opacity: .5; }
  to   { transform: translateY(-5px); opacity: 1; }
}

/* ── SCORE SCREEN ─────────────────────────────────────── */
.score-screen {
  text-align: center;
  padding: 32px 20px;
}
.score-emoji { font-size: 64px; display: block; margin-bottom: 10px; }
.score-number {
  font-family: 'Fredoka', sans-serif;
  font-size: 52px;
  font-weight: 700;
  color: var(--teal);
  line-height: 1;
}
.score-label { font-size: 16px; color: var(--ink-light); margin-top: 4px; font-weight: 700; }

/* ── INSTALL BANNER ───────────────────────────────────── */
#install-banner {
  position: fixed;
  bottom: 68px; left: 12px; right: 12px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,.35);
  z-index: 200;
  font-size: 14px;
  font-weight: 700;
}
#install-banner button { flex-shrink: 0; }

/* ── UTILITIES ────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted  { color: var(--ink-light); font-size: 13px; }
.gap-2       { display: flex; gap: 10px; flex-wrap: wrap; }
.mt-3        { margin-top: 18px; }
.mb-2        { margin-bottom: 12px; }
.hidden      { display: none !important; }
hr.divider   { border: none; border-top: 1.5px solid var(--border); margin: 16px 0; }

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 480px) {
  .login-box { padding: 28px 20px; }
  .mode-grid { grid-template-columns: 1fr 1fr; }
  .match-grid { gap: 8px; }
  .match-tile { font-size: 13px; min-height: 60px; padding: 10px 8px; }
}
