/*
 * 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 */
.site-main-home {
  padding: 0;
}

.home-hero {
  background: linear-gradient(135deg, var(--eq-primary) 0%, #7c3aed 55%, #db2777 100%);
  color: #fff;
  padding: 4rem 0 4.5rem;
}

.home-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.8rem;
  font-weight: 700;
  opacity: 0.85;
  margin-bottom: 0.75rem;
}

.home-title {
  font-size: clamp(2.25rem, 5vw, 3.75rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
}

.home-title span {
  color: var(--eq-accent);
}

.home-lead {
  font-size: 1.15rem;
  max-width: 38rem;
  opacity: 0.92;
  margin-bottom: 1.75rem;
}

.home-note {
  margin: 0;
  opacity: 0.9;
}

.home-note a {
  color: #fff;
  font-weight: 600;
}

.home-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.home-stat {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--eq-radius);
  padding: 1.1rem 1rem;
  color: #fff;
  text-decoration: none;
  backdrop-filter: blur(4px);
}

a.home-stat:hover {
  background: rgba(255, 255, 255, 0.22);
}

.home-stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
}

.home-stat-label {
  font-size: 0.85rem;
  opacity: 0.85;
}

.home-levels {
  grid-column: 1 / -1;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.home-section + .home-section {
  margin-top: 3rem;
}

.home-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.home-topic {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--eq-border);
  border-radius: 999px;
  background: var(--eq-surface);
  color: var(--eq-text);
  text-decoration: none;
  font-weight: 500;
}

.home-topic:hover {
  border-color: var(--eq-primary);
  color: var(--eq-primary);
}

/* 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;
}

/* Legal pages */
.legal-page {
  max-width: 48rem;
  line-height: 1.7;
}

.legal-page h2 {
  font-size: 1.25rem;
  margin-top: 2rem;
}

.legal-page h3 {
  font-size: 1.05rem;
  margin-top: 1.25rem;
}

/* Listening */
.audio-player {
  background: var(--eq-bg);
  border: 1px solid var(--eq-border);
  border-radius: calc(var(--eq-radius) - 0.25rem);
  padding: 0.75rem;
  margin-bottom: 1rem;
  overflow: hidden; /* sits next to the floated cover image */
}

.transcript {
  clear: both;
  border-top: 1px solid var(--eq-border);
  padding-top: 1rem;
  margin-top: 1rem;
  line-height: 1.75;
}

.transcript-line {
  margin-bottom: 0.5rem;
}

.transcript-speaker {
  color: var(--eq-primary);
}

.transcript-hint {
  clear: both;
  padding-top: 0.5rem;
}

/* Grammar */
.grammar-groups {
  columns: 3 22rem;
  column-gap: 1.5rem;
}

.grammar-group {
  break-inside: avoid;
  margin-bottom: 1.5rem;
}

.grammar-topic-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--eq-border);
}

.grammar-topic-row:last-child {
  border-bottom: 0;
}

.grammar-topic-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--eq-text);
  text-decoration: none;
  font-weight: 500;
}

.grammar-thumb {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 0.5rem;
  object-fit: cover;
}

.grammar-thumb-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--eq-bg);
  color: var(--eq-muted);
}

.grammar-topic-link:hover {
  color: var(--eq-primary);
}

.grammar-topic-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.level-dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--level-color, var(--eq-muted));
}

.lesson-body {
  line-height: 1.75;
}

.lesson-body h2 {
  font-size: 1.2rem;
  margin-top: 1.5rem;
}

.lesson-body table {
  width: 100%;
  margin: 0.75rem 0 1rem;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.lesson-body th,
.lesson-body td {
  border: 1px solid var(--eq-border);
  padding: 0.4rem 0.6rem;
  vertical-align: top;
}

.lesson-body th {
  background: var(--eq-bg);
}

.lesson-body em {
  color: #374151;
}

.exercise-sets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.exercise-set-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--eq-border);
  border-radius: 999px;
  color: var(--eq-text);
  text-decoration: none;
  background: var(--eq-surface);
}

.exercise-set-link.is-current {
  border-color: var(--eq-primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

/* Grammar timelines (SVG) */
.timelines {
  clear: both;
  display: grid;
  gap: 0.75rem;
  margin: 0.5rem 0 1.25rem;
}

.timeline {
  background: var(--eq-bg);
  border: 1px solid var(--eq-border);
  border-radius: calc(var(--eq-radius) - 0.25rem);
  padding: 0.75rem 1rem 0.5rem;
  margin: 0;
}

.timeline-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.timeline-svg {
  width: 100%;
  height: auto;
  max-width: 640px;
  display: block;
}

.timeline-example {
  margin: 0.25rem 0 0;
  color: var(--eq-muted);
}

.timeline-svg .tl-axis {
  stroke: var(--eq-text);
  stroke-width: 2;
}

.timeline-svg .tl-axis-head {
  fill: var(--eq-text);
}

.timeline-svg .tl-now {
  stroke: #dc2626;
  stroke-width: 2;
}

.timeline-svg .tl-mark {
  stroke: var(--eq-muted);
  stroke-dasharray: 4 4;
}

.timeline-svg .tl-label,
.timeline-svg .tl-axis-label,
.timeline-svg .tl-mark-label {
  font: 13px system-ui, sans-serif;
  fill: var(--eq-text);
  /* light outline keeps labels readable over lines */
  paint-order: stroke;
  stroke: var(--eq-bg);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.timeline-svg .tl-axis-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  fill: var(--eq-muted);
}

.timeline-svg .tl-now-label {
  fill: #dc2626;
  font-weight: 700;
}

.timeline-svg .tl-stroke {
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.timeline-svg .tl-item-0.tl-fill { fill: var(--eq-primary); }
.timeline-svg .tl-item-0.tl-stroke { stroke: var(--eq-primary); }
.timeline-svg .tl-item-1.tl-fill { fill: #db2777; }
.timeline-svg .tl-item-1.tl-stroke { stroke: #db2777; }
.timeline-svg .tl-item-2.tl-fill { fill: #0d9488; }
.timeline-svg .tl-item-2.tl-stroke { stroke: #0d9488; }
.timeline-svg .tl-item-3.tl-fill { fill: #d97706; }
.timeline-svg .tl-item-3.tl-stroke { stroke: #d97706; }

/* Topic cards (home) */
.topic-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--eq-surface);
  border: 1px solid var(--eq-border);
  border-radius: var(--eq-radius);
  overflow: hidden;
  color: var(--eq-text);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

.topic-card img,
.topic-card-empty {
  aspect-ratio: 1 / 1;
  width: 100%;
  object-fit: cover;
}

.topic-card-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--eq-bg);
  color: var(--eq-muted);
  font-size: 2rem;
}

.topic-card-name {
  padding: 0.6rem 0.75rem;
  font-weight: 600;
  font-size: 0.95rem;
}

/* Google sign-in button (Google branding: white, coloured G) */
.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: #fff;
  color: #1f1f1f;
  border: 1px solid #747775;
  font-weight: 500;
  box-shadow: 0 1px 2px rgb(60 64 67 / 0.15);
  transition: background-color 0.15s, box-shadow 0.15s;
}
.btn-google:hover,
.btn-google:focus-visible {
  background: #f8faff;
  color: #1f1f1f;
  border-color: #4285f4;
  box-shadow: 0 1px 3px rgb(60 64 67 / 0.3), 0 4px 8px rgb(66 133 244 / 0.15);
}
.btn-google:active { background: #eef3fe; color: #1f1f1f; border-color: #4285f4; }
.btn-google-logo { width: 20px; height: 20px; flex-shrink: 0; }

/* Common mistakes: ✗ wrong / ✓ right examples in grammar lessons */
.ex-wrong,
.lesson-body .ex-wrong em { color: #c62828; }
.ex-right,
.lesson-body .ex-right em { color: #2e7d32; }
.ex-wrong,
.ex-right { font-weight: 500; }

/* Level filter buttons: same colours as the level badges on the cards */
.btn-level {
  --bs-btn-color: var(--level-color);
  --bs-btn-border-color: var(--level-color);
  --bs-btn-bg: transparent;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--level-color);
  --bs-btn-hover-border-color: var(--level-color);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--level-color);
  --bs-btn-active-border-color: var(--level-color);
  font-weight: 500;
}

/* Overall progress next to "My progress" in the header */
.progress-badge {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.8em;
  font-weight: 600;
  color: #fff;
  line-height: 1.4;
}
.progress-low { background: #dc3545; }
.progress-mid { background: #f5b301; color: #1f1f1f; }
.progress-high { background: #198754; }

/* Contact form */
.contact-page {
  max-width: 40rem;
}

.contact-hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* How it works */
.hiw-hero {
  padding: 3rem 0 3.25rem;
}

.hiw-hero .home-lead {
  margin-bottom: 0;
}

.hiw-card {
  background: var(--eq-surface);
  border: 1px solid var(--eq-border);
  border-radius: var(--eq-radius);
  padding: 1.25rem;
}

.hiw-card-accent {
  border-color: var(--eq-primary);
  box-shadow: 0 0 0 1px var(--eq-primary);
}

.hiw-level {
  border-top: 4px solid var(--level-color);
}

.hiw-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1rem;
}

.hiw-step {
  position: relative;
  background: var(--eq-surface);
  border: 1px solid var(--eq-border);
  border-radius: var(--eq-radius);
  padding: 1.25rem;
}

.hiw-step p {
  margin: 0;
  color: var(--eq-muted);
}

.hiw-step-num {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--eq-primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  display: grid;
  place-items: center;
}

.hiw-step-icon {
  display: block;
  font-size: 1.75rem;
  color: var(--eq-primary);
  margin-bottom: 0.5rem;
}

.hiw-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--eq-muted);
  margin-left: 0.25rem;
  white-space: nowrap;
}

.hiw-list {
  padding-left: 1.1rem;
}

.hiw-list li + li {
  margin-top: 0.35rem;
}

.hiw-list-check {
  list-style: none;
  padding-left: 0;
}

.hiw-list-check li {
  position: relative;
  padding-left: 1.6rem;
}

.hiw-list-check li::before {
  content: "\F26E"; /* bi-check-lg */
  font-family: bootstrap-icons;
  position: absolute;
  left: 0;
  color: var(--eq-level-beginner);
}

.hiw-soon {
  color: var(--eq-muted);
}

.hiw-soon .bi {
  color: var(--eq-accent);
}

.hiw-tips {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.75rem 1.5rem;
}

.hiw-tips .bi {
  color: var(--eq-accent);
  margin-right: 0.35rem;
}
