/* style2.css
   SECTION 1: MOBILE & BASE STYLES (Default)
   SECTION 2: DESKTOP OVERRIDES (At the bottom)
*/

/* =========================================
   1. CORE VARIABLES & BASE STYLES (MOBILE)
   ========================================= */
:root {
  --bg: #f6f9ff;
  --panel: #ffffff;
  --card: #ffffff;
  --text: #0b1220;
  --muted: #6b7280;
  --accent: #3b82f6;
  --border: #e6eef8;
  --success: #10b981;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
  --glass: rgba(15, 23, 42, 0.03);
  --maxWidth: 1200px;
  --font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial;
  --tap-padding: 14px;
}

body.dark {
  --bg: #071023;
  --panel: #0f1724;
  --card: #0b1220;
  --text: #e6eef8;
  --muted: #9ca3af;
  --border: #122031;
  --shadow: 0 10px 30px rgba(2, 6, 23, 0.6);
  --glass: rgba(255, 255, 255, 0.02);
}

* {
  box-sizing: border-box;
}

/* STRICT PAGE SCROLL LOCK */
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  /* No left/right wobble */
  overflow-y: auto;
  /* vertical scroll allowed */
  -webkit-overflow-scrolling: touch;
  position: relative;
}

a {
  color: inherit;
  text-decoration: none;
}

/* APP WRAPPER (Mobile Default: Single Column) */
.app {
  width: 100%;
  min-height: 100%;
  max-width: var(--maxWidth);
  margin: 0 auto;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr;
  /* Stacked layout */
  gap: 16px;
  overflow: visible;
}

/* MAIN CARD */
.card.main {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  height: auto;
  min-height: 60vh;
  overflow: visible;
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
}

/* =========================================
   COMPONENT: QUESTION PALETTE (CAROUSEL)
   ========================================= */
.palette-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 8px 0;
  background: var(--bg);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--glass);
}

/* Mobile Scroll Buttons (< >) */
.scroll-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: bold;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  user-select: none;
}

.scroll-btn:active {
  background: var(--border);
  transform: scale(0.95);
}

/* The Palette List */
#qPalette {
  flex: 1;
  display: flex;
  gap: 8px;
  padding: 4px;
  width: 100%;
  flex-wrap: nowrap;
  /* Mobile: Single Row */
  overflow-x: auto;
  /* Mobile: Scrollable */
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

#qPalette::-webkit-scrollbar {
  display: none;
}

.q-pill {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  user-select: none;
  flex-shrink: 0;
}

/* =========================================
   COMPONENT: QUESTION BOX (INTERNAL SCROLL)
   ========================================= */
.question-box {
  margin-top: 12px;
  padding: 14px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(3, 10, 30, 0.04);

  /* Internal Scrolling Logic */
  height: auto;
  max-height: 55vh;
  /* Cap height */
  overflow-y: auto;
  /* Scroll inside if long */
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.qcontent img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
  margin-bottom: 12px;
}

/* =========================================
   COMPONENT: SIDEBAR (OFF-CANVAS)
   ========================================= */
.left {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  max-width: 86%;
  transform: translateX(-110%);
  /* Hidden by default */
  transition: transform 320ms cubic-bezier(.2, .9, .2, 1);
  z-index: 1200;
  padding: 18px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.06);
  overflow-y: auto;
  border-radius: 0 12px 12px 0;
}

body.sidebar-open .left {
  transform: translateX(0);
}

body.sidebar-open::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.36);
  z-index: 1100;
}

/* Hamburger Menu */
.hamburger {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  font-size: 18px;
  margin-right: 6px;
}

/* =========================================
   UI ELEMENTS (BUTTONS, TEXT, CHIPS)
   ========================================= */
.brand {
  margin: 0 0 4px 0;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.2px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.label {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: calc(var(--tap-padding) - 2px) 16px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.08);
}

.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: calc(var(--tap-padding) - 4px) 12px;
  border-radius: 10px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chip {
  background: var(--panel);
  border-radius: 999px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  font-size: 13px;
}

/* Lists & Categories */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding-bottom: 10px;
}

.cat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}

.cat.active {
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.06);
}

/* Options */
.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.opt {
  padding: 14px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  font-size: 16px;
  transition: transform .12s, box-shadow .12s;
  user-select: none;
}

.opt.selected {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.06);
}

.opt.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.06);
}

.opt.wrong {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.05);
}

.opt .multi-badge {
  margin-left: auto;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* Progress & Footer */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.progress {
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 6px 0 14px;
}

.progress>i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width .35s ease;
}

.footer {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* Status Colors */
.q-unvisited {
  border-color: #e2e8f0;
  color: #64748b;
}

.q-review {
  background: #f3e8ff !important;
  /* soft purple */
  border-color: #a855f7 !important;
  /* vivid purple border */
  color: #6b21a8 !important;
  /* deep purple text */
}

.q-answered {
  background: #ecfdf5;
  border-color: #34d399;
  color: #047857;
}

.q-current {
  outline: 3px solid rgba(59, 130, 246, 0.3);
  border-color: #3b82f6;
  color: #3b82f6;
  transform: scale(1.05);
}

/* Misc Views */
.results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-top: 12px;
}

.stat {
  background: var(--panel);
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.review-item {
  padding: 12px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

#historyView .list {
  max-height: 60vh;
  overflow: auto;
  padding: 8px;
}

.history-item {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  margin-bottom: 8px;
}

.hidden {
  display: none !important;
}

#hintArea {
  display: none;
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  background: var(--glass);
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 13px;
}


/* =========================================
   2. DESKTOP & TABLET OVERRIDES
   ========================================= */

/* TABLET & UP (Layout Changes) */
@media (min-width: 769px) {

  /* 1. Reset Palette Wrapper (Remove borders/bg) */
  .palette-wrapper {
    background: transparent;
    padding: 0;
    border: none;
  }

  /* 2. Hide Mobile Scroll Buttons */
  .scroll-btn {
    display: none !important;
  }

  /* 3. Palette becomes Grid */
  #qPalette {
    flex-wrap: wrap;
    /* Allow wrapping */
    justify-content: center;
    /* Center Items */
    overflow-x: hidden;
    /* No scroll needed */
  }

  /* 4. Results Grid split */
  .results-grid {
    grid-template-columns: 1fr 360px;
  }
}

/* DESKTOP (Sidebar Changes) */
@media (min-width: 921px) {

  /* 1. App becomes 2-column Grid */
  .app {
    grid-template-columns: 300px 1fr;
    padding: 20px;
  }

  /* 2. Make Sidebar Static (Always visible) */
  .left {
    position: relative;
    transform: none;
    width: 100%;
    max-width: none;
    border-radius: 12px;
    z-index: 1;
    border: none;
    height: auto;
  }

  /* 3. Hide Hamburger */
  .hamburger {
    display: none;
  }

  /* 4. Card Adjustments */
  .card.main {
    margin-left: 0;
  }
}

/* SMALL PHONES TWEAKS */
@media (max-width: 600px) {
  :root {
    --tap-padding: 16px;
  }

  .brand {
    font-size: 20px;
  }

  .btn,
  .opt {
    font-size: 15px;
  }

  .left {
    width: 86%;
  }
}

/* =======================
   STRICT MOBILE SCROLL FIX
   ======================= */

/* 1. Prevent horizontal movement anywhere */
html,
body {
  overflow-x: hidden !important;
  width: 100%;
  max-width: 100%;
  position: relative;
}

/* 2. Palette stays inside its boundary (prevents screen from shifting) */
#qPalette {
  overflow-x: auto !important;
  overflow-y: hidden !important;
  white-space: nowrap;
  flex-wrap: nowrap !important;
  max-width: 100%;
  width: 100%;
  display: flex;
}

/* 3. Prevent parent containers from expanding wider than screen */
.q-palette,
.palette-wrapper,
.question-top,
.question-box,
.card.main,
.app {
  max-width: 100% !important;
  overflow-x: hidden !important;
}

/* 4. Prevent children inside palette from stretching the container */
.q-pill {
  flex-shrink: 0 !important;
}

/* 5. Make scrollbars small on mobiles */
@media (max-width: 600px) {
  #qPalette {
    scrollbar-width: thin !important;
  }

  #qPalette::-webkit-scrollbar {
    height: 5px !important;
  }
}

.qcontent img {
  max-width: 100%;
  max-height: 200px;
  /* ✔ limit height */
  width: auto;
  height: auto;
  object-fit: contain;
  /* ✔ prevents distortion */
  display: block;
  margin: 0 auto 12px;
  /* ✔ centers image */
  border-radius: 10px;
}

.question-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.q-left {
  flex: 1;
}

.q-right {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  min-width: 80px;
}

.timer {
  font-size: 18px;
  font-weight: 700;
}

.timer-icon {
  font-size: 18px;
  opacity: 0.7;
}

@media (max-width: 480px) {
  .q-right {
    min-width: 60px;
  }

  .timer {
    font-size: 16px;
  }
}