/* ─────────────────────────────────────────────────────────────
   biolab · quiz page styles
───────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500&family=Space+Mono:wght@400;700&family=DynaPuff:wght@400..700&display=swap');

:root {
  --bg: #07070e;
  --panel: #0e0c1c;
  --panel-2: #141228;
  --text: #dcd8ee;
  --muted: #5e5b78;
  --accent: #8872e8;
  --accent-dim: rgba(136, 114, 232, 0.1);
  --green: #5aad82;
  --amber: #b89050;
  --red: #b85f5f;
  --border: rgba(255, 255, 255, 0.06);
  --border-2: rgba(255, 255, 255, 0.09);
  --font-head: 'DynaPuff', sans-serif;
  --font-mono: 'DM Sans', sans-serif;
  --radius: 10px;
}

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

html {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Background ─────────────────────────────────────────────── */

.neuron-bg {
  position: fixed;
  inset: -5%;
  background-image: url('../assets/neurons-bg.svg');
  background-size: cover;
  background-position: center;
  filter: blur(3px);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}

/* ── Nav ────────────────────────────────────────────────────── */

.quiz-nav {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.18s;
}

.back-link:hover {
  color: var(--text);
}

.nav-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.5;
}

/* ── Main layout ────────────────────────────────────────────── */

main {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 24px 60px;
  width: 100%;
}

/* ── Quiz panel ─────────────────────────────────────────────── */

.quiz-panel {
  width: min(580px, 100%);
  padding: 2rem;
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.04);
  animation: panel-in 0.3s cubic-bezier(0.34, 1.2, 0.64, 1);
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Screens ────────────────────────────────────────────────── */

/* !important ensures hidden always wins regardless of specificity */
.quiz-screen[hidden] {
  display: none !important;
}

/* ── Start screen ───────────────────────────────────────────── */

.quiz-start-icon {
  font-size: 2rem;
  color: var(--accent);
  opacity: 0.8;
  margin-bottom: 0.75rem;
  line-height: 1;
}

.quiz-title {
  font-family: 'DynaPuff', sans-serif;
  font-weight: 600;
  font-size: 1.6rem;
  margin: 0 0 0.5rem;
  color: #eeeaff;
  letter-spacing: -0.02em;
}

.quiz-subtitle {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.7;
  margin: 0 0 1.5rem;
}

.quiz-filter-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.quiz-filter-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.quiz-select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border-2);
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: border-color 0.2s;
  appearance: none;
  padding-right: 1.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%237a8499'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.4rem center;
}

.quiz-select:focus {
  border-color: var(--accent);
  outline: none;
}

/* ── Buttons ────────────────────────────────────────────────── */

.quiz-btn-primary {
  width: 100%;
  padding: 0.72rem 1.2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.quiz-btn-primary:hover {
  background: #4a79ee;
}

.quiz-btn-primary:active {
  transform: scale(0.98);
}

.quiz-btn-secondary {
  flex: 1;
  padding: 0.65rem 1rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
}

.quiz-btn-secondary:hover {
  color: var(--text);
  border-color: var(--text);
}

/* ── Question screen ────────────────────────────────────────── */

.quiz-toprow {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.quiz-progress-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.quiz-progress-bar {
  flex: 1;
  height: 5px;
  background: var(--panel-2);
  border-radius: 100px;
  overflow: hidden;
}

.quiz-progress-bar>div {
  height: 100%;
  background: var(--accent);
  border-radius: 100px;
  transition: width 0.4s ease;
}

.quiz-progress-label {
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
}

.quiz-score-live {
  font-size: 0.72rem;
  color: var(--green);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.quiz-quit-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.quiz-quit-btn:hover {
  color: var(--text);
  border-color: var(--text);
}

.quiz-meta-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.quiz-category-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.55rem;
  background: rgba(91, 138, 255, 0.12);
  color: var(--accent);
  border: 1px solid rgba(91, 138, 255, 0.25);
  border-radius: 100px;
  letter-spacing: 0.05em;
}

.quiz-difficulty-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.55rem;
  border-radius: 100px;
  border: 1px solid;
  letter-spacing: 0.05em;
}

.quiz-question-text {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 400;
  line-height: 1.75;
  color: #fff;
  margin: 0 0 1.25rem;
  overflow-wrap: break-word;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.7rem 0.85rem;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text);
  transition: border-color 0.18s, background 0.18s;
  text-align: left;
  width: 100%;
  font-family: var(--font-mono);
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.quiz-option .opt-letter {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--muted);
  margin-top: 1px;
  transition: all 0.18s;
}

.quiz-option.correct {
  border-color: var(--green);
  background: rgba(61, 255, 160, 0.08);
}

.quiz-option.correct .opt-letter {
  background: var(--green);
  color: #000;
  border-color: var(--green);
}

.quiz-option.wrong {
  border-color: var(--red);
  background: rgba(255, 107, 107, 0.08);
}

.quiz-option.wrong .opt-letter {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.quiz-option:disabled {
  cursor: default;
}

.quiz-explanation {
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  font-size: 0.75rem;
  line-height: 1.75;
  color: #b0bcd4;
  font-family: var(--font-mono);
  margin-bottom: 0.9rem;
  animation: fade-in 0.3s ease;
}

.quiz-explanation.hidden {
  display: none;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.quiz-next {
  margin-top: 0;
}

/* ── Results screen ─────────────────────────────────────────── */

.quiz-result-ring-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 1.25rem;
}

.quiz-result-percent {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.5rem;
  color: #fff;
}

.quiz-result-headline {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.3rem;
  text-align: center;
  margin: 0 0 0.4rem;
  color: #fff;
}

.quiz-result-sub {
  text-align: center;
  color: var(--muted);
  font-size: 0.83rem;
  margin: 0 0 1.25rem;
  line-height: 1.6;
}

.quiz-result-breakdown {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.quiz-result-chip {
  padding: 0.3rem 0.75rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  border: 1px solid;
}

.quiz-result-btns {
  display: flex;
  gap: 0.75rem;
}

.quiz-result-btns .quiz-btn-primary,
.quiz-result-btns .quiz-btn-secondary {
  flex: 1;
  width: auto;
}

/* ── Screen layout ──────────────────────────────────────────── */

/* Start + results: centered card */
#quiz-start:not([hidden]),
#quiz-results:not([hidden]) {
  display: flex;
  width: 100%;
  justify-content: center;
}

/* Question screen: sidebar + content row */
#quiz-question:not([hidden]) {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 1.25rem;
  width: 100%;
  max-width: 1020px;
}

/* ── Sidebar ────────────────────────────────────────────────── */

.quiz-sidebar {
  flex-shrink: 0;
  width: 168px;
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  padding: 1rem 0.75rem;
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-title {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 0 0.1rem 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.35rem 0.5rem;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sidebar-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.sidebar-item--current {
  background: var(--accent-dim);
  border-color: rgba(91, 138, 255, 0.3);
  color: var(--accent);
}

.sidebar-item--open {
  color: var(--muted);
}

.sidebar-item--correct {
  color: var(--green);
  border-color: rgba(61, 255, 160, 0.2);
  background: rgba(61, 255, 160, 0.05);
}

.sidebar-item--wrong {
  color: var(--red);
  border-color: rgba(255, 107, 107, 0.2);
  background: rgba(255, 107, 107, 0.05);
}

.sidebar-num {
  font-size: 0.68rem;
  opacity: 0.7;
  min-width: 14px;
}

.sidebar-type-dot {
  font-size: 0.62rem;
  opacity: 0.65;
  margin-left: auto;
}

.sidebar-quit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
}

.sidebar-quit-btn:hover {
  color: var(--red);
  border-color: rgba(255, 107, 107, 0.4);
}

/* ── Quiz content panel ─────────────────────────────────────── */

.quiz-content {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  padding: 1.5rem 1.5rem 1.25rem;
  animation: panel-in 0.3s cubic-bezier(0.34, 1.2, 0.64, 1);
}

/* ── Type badge ─────────────────────────────────────────────── */

.quiz-type-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.55rem;
  border-radius: 100px;
  border: 1px solid;
  letter-spacing: 0.05em;
}

/* ── Nav buttons row ────────────────────────────────────────── */

.quiz-nav-btns {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.quiz-btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 0.9rem;
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
}

.quiz-btn-back:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.quiz-btn-back:disabled {
  opacity: 0.3;
  cursor: default;
}

/* Next button: not full-width inside nav row */
.quiz-nav-btns .quiz-btn-primary {
  width: auto;
}

/* ── Fill-in-the-blank ──────────────────────────────────────── */

.blank-input {
  display: inline-block;
  min-width: 100px;
  max-width: 180px;
  padding: 0.15rem 0.45rem;
  margin: 0 0.2rem;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  text-align: center;
  vertical-align: middle;
  transition: border-color 0.18s;
  outline: none;
}

.blank-input:focus {
  border-color: var(--accent);
}

.blank-input.blank-correct {
  border-color: var(--green);
  color: var(--green);
  background: rgba(61, 255, 160, 0.07);
}

.blank-input.blank-wrong {
  border-color: var(--red);
  color: var(--red);
  background: rgba(255, 107, 107, 0.07);
}

.blank-hint {
  display: inline-block;
  margin-left: 0.3rem;
  font-size: 0.72rem;
  color: var(--green);
  font-family: var(--font-mono);
  vertical-align: middle;
  opacity: 0.85;
}

.blank-submit,
.order-submit {
  margin-top: 0.85rem;
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.blank-submit:hover,
.order-submit:hover {
  background: #4a79ee;
}

.blank-submit:active,
.order-submit:active {
  transform: scale(0.98);
}

/* ── Ordering / drag-and-drop ───────────────────────────────── */

.order-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 0.5rem;
}

.order-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text);
  cursor: grab;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  user-select: none;
}

.order-item[draggable="false"] {
  cursor: default;
}

.order-item.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.order-item.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 1px rgba(91, 138, 255, 0.2);
}

.order-item.correct {
  border-color: var(--green);
  background: rgba(61, 255, 160, 0.07);
}

.order-item.wrong {
  border-color: var(--red);
  background: rgba(255, 107, 107, 0.07);
}

.drag-handle {
  color: var(--muted);
  font-size: 1rem;
  flex-shrink: 0;
  opacity: 0.5;
  letter-spacing: -2px;
}

.order-item-text {
  flex: 1;
  line-height: 1.5;
}

.order-item-badge {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.order-item-badge--correct {
  background: var(--green);
  color: #000;
}

.order-item-badge--wrong {
  background: var(--red);
  color: #fff;
}

/* ── Responsive ─────────────────────────────────────────────── */

/* Narrow: stack sidebar above content */
@media (max-width: 700px) {
  main {
    padding: 16px 12px 40px;
  }

  #quiz-question:not([hidden]) {
    flex-direction: column;
    gap: 0.75rem;
  }

  .quiz-sidebar {
    width: 100%;
    position: static;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }

  .sidebar-item {
    width: auto;
    min-width: 34px;
    justify-content: center;
    padding: 0.28rem 0.4rem;
  }

  .sidebar-type-dot {
    display: none;
  }

  .quiz-content {
    width: 100%;
  }

  .quiz-panel {
    padding: 1.25rem;
  }

  .quiz-result-btns {
    flex-direction: column;
  }
}

/* Very small / squished: tighten further */
@media (max-width: 420px) {
  .quiz-nav {
    padding: 14px 16px;
  }

  .quiz-content {
    padding: 1rem 1rem 0.9rem;
  }

  .quiz-panel {
    padding: 1rem;
    border-radius: 12px;
  }

  .quiz-question-text {
    font-size: 0.82rem;
  }

  .quiz-option {
    font-size: 0.75rem;
    padding: 0.6rem 0.7rem;
  }

  .quiz-title {
    font-size: 1.25rem;
  }
}
