/*
 * EnQuizzy styles.
 * Design tokens live in :root so a future design can be applied
 * by changing variables instead of rewriting components.
 */

:root {
  --eq-primary: #4f46e5;
  --eq-primary-hover: #4338ca;
  --eq-accent: #f59e0b;
  --eq-text: #1f2937;
  --eq-muted: #6b7280;
  --eq-bg: #f8fafc;
  --eq-surface: #ffffff;
  --eq-border: #e5e7eb;
  --eq-radius: 0.75rem;
  --eq-header-height: 64px;

  --eq-level-beginner: #16a34a;
  --eq-level-intermediate: #2563eb;
  --eq-level-advanced: #9333ea;

  /* map tokens onto Bootstrap */
  --bs-primary: var(--eq-primary);
  --bs-primary-rgb: 79, 70, 229;
  --bs-link-color: var(--eq-primary);
  --bs-link-hover-color: var(--eq-primary-hover);
  --bs-body-color: var(--eq-text);
  --bs-body-bg: var(--eq-bg);
  --bs-border-radius: var(--eq-radius);
}

.btn-primary {
  --bs-btn-bg: var(--eq-primary);
  --bs-btn-border-color: var(--eq-primary);
  --bs-btn-hover-bg: var(--eq-primary-hover);
  --bs-btn-hover-border-color: var(--eq-primary-hover);
  --bs-btn-active-bg: var(--eq-primary-hover);
  --bs-btn-active-border-color: var(--eq-primary-hover);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-main {
  flex: 1 0 auto;
}

/* Full-width layout: same side padding everywhere */
.site-gutter {
  padding-left: 1rem;
  padding-right: 1rem;
}

@media (min-width: 992px) {
  .site-gutter {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

/* Header */
.site-header {
  background: var(--eq-surface);
  border-bottom: 1px solid var(--eq-border);
  min-height: var(--eq-header-height);
}

.site-logo {
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--eq-text);
  letter-spacing: -0.02em;
}

.site-logo span {
  color: var(--eq-primary);
}

/* Footer */
.site-footer {
  background: var(--eq-surface);
  border-top: 1px solid var(--eq-border);
  font-size: 0.9rem;
}

/* Home */
.home-hero {
  padding: 4rem 0;
}

.home-hero .lead {
  max-width: 40rem;
}

/* Auth pages (allauth): narrow centered card */
.auth-page {
  max-width: 30rem;
  margin-top: 2rem;
  margin-bottom: 2rem;
  background: var(--eq-surface);
  border: 1px solid var(--eq-border);
  border-radius: var(--eq-radius);
  padding: 2rem !important;
}

.auth-providers {
  list-style: none;
  padding: 0;
}

/* Badges */
.level-badge {
  background: var(--level-color, var(--eq-muted));
  color: #fff;
  font-weight: 600;
}

.category-badge {
  font-weight: 500;
  border: 1px solid var(--eq-border);
}

/* Content cards (reading list, related texts) */
.content-card {
  border-color: var(--eq-border);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
}

.content-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.content-card .card-img-top {
  aspect-ratio: 3 / 2;
  height: auto;
  object-fit: cover;
}

.card-img-placeholder {
  aspect-ratio: 3 / 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--eq-bg);
  color: var(--eq-muted);
  font-size: 2.5rem;
}

.content-card .card-title a {
  color: var(--eq-text);
  text-decoration: none;
}

.score-good { color: #16a34a; }
.score-ok { color: #d97706; }
.score-low { color: #dc2626; }

.page-intro {
  max-width: 42rem;
}

.ad-slot {
  margin: 1rem 0;
  text-align: center;
  overflow: hidden;
}

/* Development placeholder for an empty / inactive ad slot */
.ad-placeholder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 90px;
  padding: 0.75rem;
  border: 2px dashed #f59e0b;
  border-radius: var(--eq-radius);
  background: repeating-linear-gradient(45deg, #fffbeb, #fffbeb 10px, #fef3c7 10px, #fef3c7 20px);
  color: #92400e;
  font-size: 0.875rem;
}

.ad-placeholder code {
  color: inherit;
}

.ad-placeholder-state {
  opacity: 0.75;
}

.ad-placeholder[data-slot$='-sidebar'] {
  min-height: 250px;
}

/*
 * Study layout: text + quiz.
 * Large screens: side by side, each pane scrolls on its own and fills the screen height.
 * Small screens: quiz below the text, each pane still scrolls on its own.
 */
.study-layout {
  --study-gap: 1.5rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--study-gap);
}

.study-pane {
  background: var(--eq-surface);
  border: 1px solid var(--eq-border);
  border-radius: var(--eq-radius);
  padding: 1.25rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  max-height: 75vh;
  scrollbar-gutter: stable;
}

.study-pane:focus-visible {
  outline: 2px solid var(--eq-primary);
  outline-offset: 2px;
}

@media (min-width: 992px) {
  .study-layout {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  }

  .study-pane {
    /* screen height minus header, breadcrumb and page padding */
    height: calc(100vh - var(--eq-header-height) - 6rem);
    max-height: none;
    min-height: 28rem;
  }
}

/* Square cover image in the top-left corner of the text; the text wraps around it on the right. */
.study-image {
  float: left;
  width: min(42%, 320px);
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: calc(var(--eq-radius) - 0.25rem);
  margin: 0 1.25rem 0.75rem 0;
}

.study-content {
  display: flow-root; /* contains the floated image */
}

.study-content .ad-slot {
  clear: both;
}

.reading-body {
  font-size: 1.075rem;
  line-height: 1.8;
}

/* Quiz */
.quiz-header {
  margin-bottom: 1rem;
}

.quiz-questions {
  counter-reset: none;
  margin: 0;
}

.quiz-question {
  border: 1px solid var(--eq-border);
  border-radius: calc(var(--eq-radius) - 0.25rem);
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.quiz-question fieldset {
  margin: 0;
}

.quiz-question-text {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  float: none;
  width: 100%;
}

.quiz-number {
  color: var(--eq-primary);
  margin-right: 0.25rem;
}

.quiz-option {
  margin-bottom: 0.25rem;
}

.quiz-gap {
  max-width: 20rem;
}

.quiz-question.is-missing {
  border-color: #f59e0b;
}

.quiz-question.is-correct {
  border-color: #16a34a;
  background: #f0fdf4;
}

.quiz-question.is-wrong {
  border-color: #dc2626;
  background: #fef2f2;
}

.quiz-feedback {
  margin-top: 0.5rem;
}

.is-correct .quiz-feedback { color: #15803d; }
.is-wrong .quiz-feedback { color: #b91c1c; }

.quiz-explanation {
  color: var(--eq-muted);
  margin-top: 0.25rem;
}

.quiz-score {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
}

.quiz-actions {
  display: flex;
  gap: 0.5rem;
  position: sticky;
  bottom: -1.25rem;
  background: var(--eq-surface);
  padding: 0.75rem 0;
}

/* Dashboard */
.panel {
  background: var(--eq-surface);
  border: 1px solid var(--eq-border);
  border-radius: var(--eq-radius);
  padding: 1.25rem;
}

.stat-tile {
  background: var(--eq-surface);
  border: 1px solid var(--eq-border);
  border-radius: var(--eq-radius);
  padding: 1rem 1.25rem;
  height: 100%;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.2;
}

.stat-of {
  font-size: 1rem;
  font-weight: 600;
  color: var(--eq-muted);
}

.stat-label {
  color: var(--eq-muted);
  font-size: 0.875rem;
}

.stat-row + .stat-row {
  margin-top: 1rem;
}

.stat-row.is-disabled {
  opacity: 0.55;
}

.stat-progress {
  height: 0.6rem;
}
