/* =========================================================
   Practice Box [ PB ] — Premium Glassmorphism / 3D Theme
   ========================================================= */

/* ---------- Design Tokens ---------- */
:root {
  --font-head: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  --radius: 20px;
  --radius-sm: 14px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 0.3s;

  --accent: #6366f1;
  --accent-2: #22d3ee;
  --success: #22c55e;
  --danger: #ef4444;
}

/* ---------- Dark Theme (default) ---------- */
[data-theme='dark'] {
  --bg: #0b0f1a;
  --bg-2: #0e1424;
  --text: #eef2ff;
  --text-muted: #9aa6c4;
  --glass-bg: rgba(22, 30, 52, 0.55);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-hi: rgba(255, 255, 255, 0.06);
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.75);
  --glow: 0 0 30px rgba(99, 102, 241, 0.45);
  --option-bg: rgba(30, 40, 68, 0.7);
  --option-border: rgba(255, 255, 255, 0.09);
  --track-bg: rgba(255, 255, 255, 0.08);
}

/* ---------- Light Theme ---------- */
[data-theme='light'] {
  --bg: #eef1f9;
  --bg-2: #ffffff;
  --text: #101528;
  --text-muted: #5b6480;
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.9);
  --glass-hi: rgba(255, 255, 255, 0.55);
  --shadow: 0 20px 45px -22px rgba(31, 41, 92, 0.35);
  --glow: 0 0 26px rgba(99, 102, 241, 0.25);
  --option-bg: rgba(255, 255, 255, 0.75);
  --option-border: rgba(31, 41, 92, 0.08);
  --track-bg: rgba(31, 41, 92, 0.1);
}

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

html,
body {
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  overflow-x: hidden;
}

h1,
h2,
h3 {
  font-family: var(--font-head);
  letter-spacing: -0.02em;
}

button,
select,
textarea {
  font-family: inherit;
}

/* ---------- Animated Background ---------- */
.bg-aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: radial-gradient(circle at 50% -10%, var(--bg-2), var(--bg) 60%);
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  will-change: transform;
}

.orb-1 {
  width: 42vw;
  height: 42vw;
  top: -10vw;
  left: -8vw;
  background: radial-gradient(circle, var(--accent), transparent 70%);
  animation: drift 22s var(--ease) infinite alternate;
}

.orb-2 {
  width: 38vw;
  height: 38vw;
  bottom: -12vw;
  right: -6vw;
  background: radial-gradient(circle, var(--accent-2), transparent 70%);
  animation: drift 26s var(--ease) infinite alternate-reverse;
}

.orb-3 {
  width: 30vw;
  height: 30vw;
  top: 40%;
  left: 55%;
  background: radial-gradient(circle, #a855f7, transparent 70%);
  opacity: 0.32;
  animation: drift 30s var(--ease) infinite alternate;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(var(--glass-border) 1px, transparent 1px),
    linear-gradient(90deg, var(--glass-border) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 40%, black, transparent 80%);
  opacity: 0.5;
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(6vw, 5vh, 0) scale(1.15);
  }
}

/* ---------- Layout Shell ---------- */
.app-shell {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 24px 18px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- Glass Surface ---------- */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-hi);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
}

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  padding: 18px 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.pb-logo {
  position: relative;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(145deg, var(--accent), #4338ca);
  box-shadow: var(--glow), inset 0 2px 4px rgba(255, 255, 255, 0.35),
    inset 0 -3px 6px rgba(0, 0, 0, 0.35);
  transform: translateZ(0);
  animation: logoFloat 5s var(--ease) infinite alternate;
}

.pb-logo__text {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 20px;
  color: #fff;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.pb-logo__ring {
  position: absolute;
  inset: -4px;
  border-radius: 20px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  opacity: 0;
  animation: pulseRing 3s var(--ease) infinite;
}

@keyframes logoFloat {
  from {
    transform: translateY(0) rotate(-2deg);
  }
  to {
    transform: translateY(-5px) rotate(2deg);
  }
}

@keyframes pulseRing {
  0% {
    opacity: 0.6;
    transform: scale(0.9);
  }
  70% {
    opacity: 0;
    transform: scale(1.25);
  }
  100% {
    opacity: 0;
  }
}

.brand__title {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand__title h1 {
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 800;
}

.brand__tag {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 13px;
  color: var(--accent-2);
  letter-spacing: 1px;
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.select-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.select-field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding-left: 4px;
}

.select-wrap {
  position: relative;
}

.glass-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--option-bg);
  border: 1px solid var(--option-border);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 40px 11px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-width: 130px;
  box-shadow: inset 0 1px 0 var(--glass-hi), 0 6px 14px -8px rgba(0, 0, 0, 0.45);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}

.glass-select:hover,
.glass-select:focus {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--glow), inset 0 1px 0 var(--glass-hi);
  outline: none;
}

.glass-select option {
  background: var(--bg-2);
  color: var(--text);
}

.chevron {
  position: absolute;
  right: 14px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

/* ---------- Theme Toggle ---------- */
.theme-toggle {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  align-self: flex-end;
}

.theme-toggle__track {
  display: block;
  width: 66px;
  height: 34px;
  border-radius: 999px;
  background: var(--option-bg);
  border: 1px solid var(--option-border);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.3);
  position: relative;
  transition: all var(--dur) var(--ease);
}

.theme-toggle__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), #4338ca);
  display: grid;
  place-items: center;
  box-shadow: var(--glow), inset 0 1px 2px rgba(255, 255, 255, 0.4);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}

[data-theme='light'] .theme-toggle__thumb {
  transform: translateX(32px);
  background: linear-gradient(145deg, #fbbf24, #f59e0b);
}

.theme-toggle__thumb svg {
  position: absolute;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.icon-moon {
  opacity: 1;
  transform: scale(1);
}
.icon-sun {
  opacity: 0;
  transform: scale(0.4);
}

[data-theme='light'] .icon-moon {
  opacity: 0;
  transform: scale(0.4);
}
[data-theme='light'] .icon-sun {
  opacity: 1;
  transform: scale(1);
}

/* ---------- Dashboard ---------- */
.dashboard {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 20px 24px;
  flex-wrap: wrap;
}

.dash-block {
  flex: 1 1 240px;
  min-width: 220px;
}

.dash-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

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

.progress-track {
  flex: 1;
  height: 12px;
  border-radius: 999px;
  background: var(--track-bg);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.7);
  transition: width 0.5s var(--ease);
}

.progress-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.dash-divider {
  width: 1px;
  align-self: stretch;
  background: var(--glass-border);
}

.dash-block--stats {
  display: flex;
  gap: 28px;
  flex: 0 1 auto;
  min-width: auto;
}

.stat {
  text-align: center;
}

.stat-value {
  font-family: var(--font-head);
  font-size: 30px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

.stat-value--type {
  font-size: 18px;
  padding-top: 6px;
}

/* ---------- Quiz Container ---------- */
.quiz {
  padding: 30px;
  min-height: 340px;
  display: flex;
  flex-direction: column;
}

/* State panels */
.state-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  color: var(--text-muted);
  min-height: 280px;
}

.state-panel--hidden {
  display: none;
}

.spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid var(--track-bg);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.state-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 26px;
  color: #fff;
  background: linear-gradient(145deg, var(--danger), #b91c1c);
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.5);
}

/* Question view */
.question-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 22px;
  animation: fadeSlide 0.4s var(--ease);
}

@keyframes fadeSlide {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.q-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.q-index {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--option-bg);
  border: 1px solid var(--option-border);
  color: var(--text-muted);
}

.q-type-pill {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--glow);
}

.q-text {
  font-size: clamp(19px, 2.6vw, 24px);
  font-weight: 700;
  line-height: 1.45;
  text-wrap: balance;
}

/* ---------- MCQ Options ---------- */
.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  padding: 18px 18px;
  border-radius: var(--radius-sm);
  background: var(--option-bg);
  border: 1px solid var(--option-border);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: inset 0 1px 0 var(--glass-hi), 0 10px 22px -14px rgba(0, 0, 0, 0.6);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  transform-style: preserve-3d;
}

.option:not(:disabled):hover {
  transform: translateY(-4px) translateZ(10px);
  border-color: var(--accent);
  box-shadow: var(--glow), inset 0 1px 0 var(--glass-hi);
}

.option:disabled {
  cursor: default;
}

.option__key {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--track-bg);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 14px;
  transition: all var(--dur) var(--ease);
}

.option.correct {
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 18%, var(--option-bg));
  box-shadow: 0 0 26px rgba(34, 197, 94, 0.55);
  transform: translateY(-2px);
}

.option.correct .option__key {
  background: var(--success);
  color: #fff;
}

.option.incorrect {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 16%, var(--option-bg));
  box-shadow: 0 0 26px rgba(239, 68, 68, 0.5);
}

.option.incorrect .option__key {
  background: var(--danger);
  color: #fff;
}

.option.dimmed {
  opacity: 0.55;
}

/* ---------- Short Question ---------- */
.short-block {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.short-input {
  width: 100%;
  resize: vertical;
  min-height: 110px;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  background: var(--option-bg);
  border: 1px solid var(--option-border);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.28);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.short-input::placeholder {
  color: var(--text-muted);
}

.short-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--glow), inset 0 2px 6px rgba(0, 0, 0, 0.28);
}

.answer-reveal {
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  background: color-mix(in srgb, var(--accent) 12%, var(--option-bg));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  box-shadow: var(--glow);
  animation: dropIn 0.4s var(--ease);
}

@keyframes dropIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.answer-reveal__label,
.explanation__label {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 6px;
}

.answer-reveal__text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* ---------- Explanation Banner ---------- */
.explanation {
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  background: var(--option-bg);
  border: 1px solid var(--option-border);
  border-left: 3px solid var(--accent-2);
  animation: dropIn 0.4s var(--ease);
}

.explanation p {
  font-size: 14.5px;
  color: var(--text);
  line-height: 1.55;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 14px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    opacity var(--dur) var(--ease);
}

.btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-3d {
  background: var(--option-bg);
  border: 1px solid var(--option-border);
  box-shadow: inset 0 1px 0 var(--glass-hi), 0 8px 18px -10px rgba(0, 0, 0, 0.6);
}

.btn-3d:not(:disabled):hover {
  transform: translateY(-4px) translateZ(10px);
  box-shadow: var(--glow), inset 0 1px 0 var(--glass-hi);
}

.btn-3d:not(:disabled):active {
  transform: translateY(-1px);
}

.btn-primary {
  align-self: flex-start;
  background: linear-gradient(135deg, var(--accent), #4338ca);
  color: #fff;
  box-shadow: var(--glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-primary:hover {
  transform: translateY(-4px) translateZ(10px);
  box-shadow: 0 0 34px rgba(99, 102, 241, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--option-border);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Navigation ---------- */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
}

.btn-nav {
  min-width: 130px;
}

.nav-counter {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 15px;
  color: var(--text-muted);
}

/* ---------- Footer ---------- */
.app-footer {
  text-align: center;
  padding-top: 6px;
}

.app-footer p {
  font-size: 13px;
  color: var(--text-muted);
}

.app-footer span {
  color: var(--accent-2);
  font-weight: 700;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
  }
  .controls {
    justify-content: space-between;
  }
  .options-grid {
    grid-template-columns: 1fr;
  }
  .dashboard {
    flex-direction: column;
    align-items: stretch;
  }
  .dash-divider {
    width: 100%;
    height: 1px;
  }
  .dash-block--stats {
    justify-content: space-around;
  }
  .quiz {
    padding: 22px 18px;
  }
  .btn-nav span {
    display: none;
  }
  .btn-nav {
    min-width: 54px;
  }
}
