/**
 * Quiz App & Catalog Design System
 * Friendly, Energetic & Game-Like (Sunny Gold + Deep Navy)
 * Typography: Self-Hosted Quicksand & Nunito (Zero Remote Calls)
 * 100% Static, Free-Tier Friendly & Zero-Data Architecture
 */

/* ==========================================================================
   1. Self-Hosted Typography (Quicksand, Nunito, Sora)
   ========================================================================== */
@font-face {
  font-family: 'Quicksand';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('./fonts/quicksand-600.woff2') format('woff2');
}

@font-face {
  font-family: 'Quicksand';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('./fonts/quicksand-700.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/nunito-400.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('./fonts/nunito-600.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('./fonts/nunito-700.woff2') format('woff2');
}

@font-face {
  font-family: 'Sora';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('./fonts/sora-700.woff2') format('woff2');
}

/* ==========================================================================
   2. Design Tokens (:root)
   ========================================================================== */
:root {
  /* Font Stacks */
  --font-title: 'Quicksand', system-ui, -apple-system, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, sans-serif;
  --font-brand: 'Sora', 'Quicksand', system-ui, sans-serif;

  /* Color Palette */
  --bg-page: #fafaf9;                /* Pale warm, friendly background */
  --bg-card: #ffffff;                /* Pure white surface */

  /* Deep Indigo / Navy Header & Text */
  --color-navy: #1e1b4b;             /* Deepest indigo */
  --color-navy-surface: #312e81;     /* Header surface accent */
  --color-navy-text: #1e1b4b;

  /* Primary Accent: Sunny Gold / Amber */
  --color-gold: #f59e0b;             /* Primary action gold */
  --color-gold-hover: #d97706;       /* Gold hover */
  --color-gold-light: #fef3c7;       /* Gold badge / background tint */
  --color-gold-glow: rgba(245, 158, 11, 0.25);

  /* Status Colors */
  --color-success: #10b981;
  --color-success-bg: #ecfdf5;
  --color-error: #ef4444;
  --color-error-bg: #fef2f2;

  /* Neutrals */
  --text-main: #1e1b4b;              /* Navy main heading color */
  --text-body: #374151;              /* Slate 700 */
  --text-muted: #6b7280;             /* Slate 500 */
  --border-subtle: #f1f5f9;
  --border-strong: #e2e8f0;

  /* Friendly Shape Language (Generous Rounding & Soft Shadow) */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 18px;                 /* Generously rounded card corners */
  --radius-pill: 9999px;

  --shadow-card: 0 2px 4px rgba(30, 27, 75, 0.04), 0 6px 12px rgba(30, 27, 75, 0.03);
  --shadow-card-hover: 0 8px 16px rgba(30, 27, 75, 0.06), 0 16px 24px rgba(30, 27, 75, 0.04);

  /* Interaction Curve */
  --ease-shared: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 180ms;
}

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

html {
  font-family: var(--font-body);
  background-color: var(--bg-page);
  color: var(--text-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   4. Deep Indigo / Navy Header (Site Name in Sora, Nothing Else)
   ========================================================================== */
.catalog-header {
  background-color: var(--color-navy);
  color: #ffffff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(30, 27, 75, 0.15);
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.15rem 1.25rem;
  display: flex;
  align-items: center;
}

.site-title {
  font-family: var(--font-brand);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}

/* ==========================================================================
   5. Main Stage & Flat Responsive Quiz Grid
   ========================================================================== */
.catalog-main {
  flex: 1;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.quiz-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 640px) {
  .quiz-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 960px) {
  .quiz-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ==========================================================================
   6. Friendly Quiz Card Component
   ========================================================================== */
.quiz-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); /* Generously rounded corners */
  box-shadow: var(--shadow-card);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  position: relative;
  transition: transform var(--duration-fast) var(--ease-shared), box-shadow var(--duration-fast) var(--ease-shared), border-color var(--duration-fast) var(--ease-shared);
}

@media (hover: hover) {
  .quiz-card:hover {
    transform: translateY(-3px) scale(1.025);
    box-shadow: var(--shadow-card-hover);
    border-color: #cbd5e1;
  }

  .quiz-card:hover .btn-start {
    background-color: var(--color-gold-hover);
    box-shadow: 0 4px 14px var(--color-gold-glow);
  }
}

.quiz-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.quiz-title {
  font-family: var(--font-title);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-navy);
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.quiz-description {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-body);
  line-height: 1.5;
  margin-bottom: 1.75rem;
  flex-grow: 1;
}

/* Start Quiz Button (Sunny Gold Fill, Deep Navy Text) */
.btn-start {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 48px; /* Comfortable 48px touch target */
  width: 100%;
  background-color: var(--color-gold);
  color: var(--color-navy);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  pointer-events: none; /* Whole card anchor handles the click */
  transition: background-color var(--duration-fast) var(--ease-shared), box-shadow var(--duration-fast) var(--ease-shared);
}

/* ==========================================================================
   7. Interactive Quiz Session Components
   ========================================================================== */
.quiz-session-wrapper {
  max-width: 660px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.quiz-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.link-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--color-navy);
  text-decoration: none;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  min-height: 44px;
}
.link-back:hover {
  color: var(--color-gold-hover);
}

.quiz-step-counter {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
}

.quiz-progress-track {
  width: 100%;
  height: 8px;
  background-color: #e2e8f0;
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-gold), #f59e0b);
  border-radius: var(--radius-pill);
  transition: width 240ms var(--ease-shared);
}

.question-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 2rem;
}

.question-fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

.question-legend {
  font-family: var(--font-title);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-navy);
  line-height: 1.4;
  margin-bottom: 1.5rem;
  width: 100%;
}

.options-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.option-item {
  position: relative;
}

.option-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  min-height: 52px;
  background-color: #f8fafc;
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  font-family: var(--font-body);
  transition: border-color var(--duration-fast) var(--ease-shared), background-color var(--duration-fast) var(--ease-shared);
}

.option-row:hover {
  border-color: var(--color-gold);
  background-color: #ffffff;
}

.option-letter {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background-color: #ffffff;
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-navy);
  flex-shrink: 0;
}

.option-text {
  font-size: 1rem;
  color: var(--text-main);
  font-weight: 600;
  flex: 1;
}

.option-radio:checked + .option-row {
  border-color: var(--color-gold);
  background-color: var(--color-gold-light);
}

.option-radio:checked + .option-row .option-letter {
  background-color: var(--color-gold);
  border-color: var(--color-gold);
  color: var(--color-navy);
}

/* Correct & Wrong Answer Styling */
.option-row.is-correct {
  background-color: var(--color-success-bg) !important;
  border-color: var(--color-success) !important;
}
.option-row.is-correct .option-letter {
  background-color: var(--color-success);
  border-color: var(--color-success);
  color: #ffffff;
}

.option-row.is-wrong {
  background-color: var(--color-error-bg) !important;
  border-color: var(--color-error) !important;
}
.option-row.is-wrong .option-letter {
  background-color: var(--color-error);
  border-color: var(--color-error);
  color: #ffffff;
}

.feedback-panel {
  margin-top: 1.25rem;
  padding: 1.25rem 1.35rem;
  border-radius: var(--radius-md);
  border-left: 4px solid var(--color-gold);
  background-color: #f8fafc;
  animation: fadeIn 180ms ease-out;
}
.feedback-panel.correct {
  border-left-color: var(--color-success);
  background-color: var(--color-success-bg);
}
.feedback-panel.wrong {
  border-left-color: var(--color-error);
  background-color: var(--color-error-bg);
}

.feedback-title {
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.feedback-title.correct { color: #065f46; }
.feedback-title.wrong { color: #991b1b; }

.feedback-text {
  font-size: 0.95rem;
  color: var(--text-body);
  line-height: 1.5;
}

.quiz-action-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.btn-primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.75rem 1.75rem;
  border-radius: var(--radius-md);
  background-color: var(--color-gold);
  color: var(--color-navy);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-shared), box-shadow var(--duration-fast) var(--ease-shared);
}
.btn-primary-action:hover:not(:disabled) {
  background-color: var(--color-gold-hover);
  box-shadow: 0 4px 14px var(--color-gold-glow);
}
.btn-primary-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Results Screen */
.results-card {
  text-align: center;
  padding: 2.75rem 2rem;
}

.results-score-box {
  width: 115px;
  height: 115px;
  border-radius: 50%;
  margin: 0 auto 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: var(--color-gold-light);
  border: 3px solid var(--color-gold);
}

.results-score-num {
  font-family: var(--font-title);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--color-navy);
  line-height: 1;
}

.results-score-tag {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-navy);
  margin-top: 0.2rem;
}

.results-heading {
  font-family: var(--font-title);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-navy);
  margin-bottom: 0.5rem;
}

.results-summary-text {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

.results-review-list {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 2rem;
}

.review-item {
  padding: 1rem 1.15rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background-color: #f8fafc;
}
.review-item.correct {
  border-color: #a7f3d0;
  background-color: var(--color-success-bg);
}
.review-item.wrong {
  border-color: #fecaca;
  background-color: var(--color-error-bg);
}

.review-q {
  font-family: var(--font-title);
  font-weight: 700;
  color: var(--color-navy);
  font-size: 0.95rem;
}

.review-detail {
  font-size: 0.88rem;
  margin-top: 0.25rem;
  color: var(--text-body);
}

.results-actions-row {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   8. Minimal Footer
   ========================================================================== */
.catalog-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  background-color: var(--bg-card);
}

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