/* ==========================================================================
   English Level Test Stylesheet
   Designed in harmony with the Teacher Julia website aesthetic:
   Warm paper palette, Playfair Display + Plus Jakarta Sans typography,
   editorial cards, refined borders, and sapphire navy accents.
   ========================================================================== */

:root {
  /* Brand Theme Tokens matching main site */
  --paper: #F7F5F0;
  --white: #FFFFFF;
  --greige: #EFECE6;
  --ink: #1C1B1A;
  --ink-soft: #6E6B65;
  --sapphire: #162B4D;
  --sapphire-dark: #122847;
  --line: rgba(28, 27, 26, 0.08);
  --line-strong: rgba(28, 27, 26, 0.15);
  
  /* Status Accents */
  --warning: #C25E38;
  --warning-soft: rgba(194, 94, 56, 0.12);
  --success: #1b7454;
  --success-soft: rgba(27, 116, 84, 0.12);

  /* Typography */
  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Transitions & Shadows */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-sm: 0 2px 8px rgba(28, 27, 26, 0.03);
  --shadow-md: 0 8px 24px rgba(28, 27, 26, 0.05);
  --shadow-lg: 0 16px 36px rgba(28, 27, 26, 0.08);
  --shadow-xl: 0 24px 50px rgba(28, 27, 26, 0.12);
}

/* Base Reset & Typography */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background-color: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
}

/* Container */
.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

@media (min-width: 640px) {
  .container {
    padding: 0 32px;
  }
}

/* ==========================================================================
   Fixed Header with Back Button
   ========================================================================== */
.test-header-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(247, 245, 240, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  transition: all 250ms var(--ease);
}

.nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.back-to-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 9999px;
  background: var(--white);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: all 200ms var(--ease);
}

.back-to-main:hover {
  background: var(--greige);
  color: var(--sapphire);
  transform: translateX(-2px);
  border-color: rgba(22, 43, 77, 0.2);
}

.test-header-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--sapphire);
  letter-spacing: -0.01em;
}

@media (max-width: 640px) {
  .test-header-nav {
    padding: 10px 0;
  }
  .back-to-main {
    padding: 6px 14px;
    font-size: 0.8rem;
  }
  .test-header-title {
    font-size: 0.95rem;
  }
}

/* ==========================================================================
   Page Structure
   ========================================================================== */
.page {
  display: none;
  min-height: 100vh;
  padding-top: 88px;
  padding-bottom: 60px;
}

.page.active {
  display: block;
  animation: fadeIn 350ms var(--ease);
}

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

/* Section Badges */
.section-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  border-radius: 9999px;
  background: var(--greige);
  border: 1px solid var(--line);
  color: var(--sapphire);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 18px;
}

/* ==========================================================================
   Welcome Page
   ========================================================================== */
.welcome-content {
  max-width: 820px;
  margin: 0 auto;
  text-align: center;
  padding: 24px 0 40px;
}

.hero-section {
  margin-bottom: 40px;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 4.5vw, 3.1rem);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 16px;
}

.hero-description {
  font-size: clamp(1rem, 1.8vw, 1.15rem);
  color: var(--ink-soft);
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.65;
}

/* Test Info Grid */
.test-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 36px;
}

.info-card {
  background: var(--white);
  border-radius: 24px;
  padding: 28px 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: all 250ms var(--ease);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.info-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: rgba(22, 43, 77, 0.15);
}

.info-icon {
  font-size: 2rem;
  margin-bottom: 12px;
  line-height: 1;
}

.info-card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.info-card p {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--sapphire);
  margin: 0;
  letter-spacing: -0.01em;
}

/* Test Structure Card */
.test-structure {
  background: var(--white);
  border-radius: 24px;
  padding: 32px 28px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  margin-bottom: 40px;
  text-align: left;
}

.test-structure h2 {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  margin-bottom: 24px;
}

.structure-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.structure-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-radius: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  transition: all 200ms var(--ease);
}

.structure-item:hover {
  background: var(--greige);
}

.section-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
}

.section-count {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--sapphire);
  background: var(--white);
  padding: 5px 14px;
  border-radius: 9999px;
  border: 1px solid var(--line);
  white-space: nowrap;
}

.start-section {
  text-align: center;
}

.test-note {
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

@media (max-width: 768px) {
  .test-info-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .info-card {
    padding: 22px 18px;
  }
  .test-structure {
    padding: 24px 18px;
  }
  .structure-item {
    padding: 14px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 26px;
  border-radius: 9999px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 220ms var(--ease);
}

.btn:disabled {
  opacity: 0.45 !important;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-large {
  padding: 16px 36px;
  font-size: 1.05rem;
}

.btn-primary {
  background: var(--sapphire);
  color: var(--white);
  box-shadow: 0 4px 14px rgba(22, 43, 77, 0.22);
}

.btn-primary:hover {
  background: var(--ink);
  color: var(--white);
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(28, 27, 26, 0.25);
}

.btn-secondary {
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--greige);
  color: var(--sapphire);
  transform: translateY(-1px);
}

.btn-warning {
  background: var(--warning);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(194, 94, 56, 0.25);
}

.btn-warning:hover {
  background: #a84b29;
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--sapphire);
  border: 1.5px solid var(--sapphire);
}

.btn-outline:hover {
  background: var(--sapphire);
  color: var(--white);
  transform: translateY(-1px);
}

/* ==========================================================================
   Test Page
   ========================================================================== */
.test-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--white);
  border-radius: 20px;
  padding: 18px 24px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.test-progress {
  flex: 1;
}

.progress-info {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.progress-info span {
  color: var(--ink);
  font-weight: 700;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--greige);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--sapphire);
  border-radius: 9999px;
  transition: width 280ms var(--ease);
}

.test-timer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--sapphire);
  padding: 6px 14px;
  border-radius: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.timer-icon {
  font-size: 1.1rem;
}

#timeRemaining.timer-warning {
  color: #B45309;
}

#timeRemaining.timer-danger {
  color: var(--warning);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Question Navigation Panel */
.question-nav-panel {
  background: var(--white);
  border-radius: 22px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.question-nav-panel h4 {
  font-family: var(--font-heading);
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 14px;
}

.nav-buttons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.nav-btn {
  width: 40px;
  height: 40px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 180ms var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn.unanswered {
  background: var(--paper);
  color: var(--ink-soft);
  border-color: var(--line);
}

.nav-btn.unanswered:hover {
  background: var(--greige);
  color: var(--ink);
}

.nav-btn.answered {
  background: var(--sapphire);
  color: var(--white);
  border-color: var(--sapphire);
}

.nav-btn.current {
  background: var(--white);
  color: var(--sapphire);
  border: 2px solid var(--sapphire);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(22, 43, 77, 0.2);
  z-index: 2;
}

.nav-legend {
  display: flex;
  gap: 18px;
  font-size: 0.82rem;
  color: var(--ink-soft);
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-color.answered {
  background: var(--sapphire);
}

.legend-color.current {
  background: var(--white);
  border: 2px solid var(--sapphire);
}

.legend-color.unanswered {
  background: var(--paper);
  border: 1px solid var(--line-strong);
}

/* Question Content Container */
.question-container {
  max-width: 820px;
  margin: 0 auto;
}

.question-content {
  background: var(--white);
  border-radius: 28px;
  padding: 36px 32px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.question-number {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sapphire);
  margin-bottom: 12px;
}

.question-context {
  background: var(--paper);
  border-left: 4px solid var(--sapphire);
  padding: 20px 22px;
  border-radius: 16px;
  margin-bottom: 24px;
  line-height: 1.65;
  font-size: 0.96rem;
  color: var(--ink);
}

.question-context h4 {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sapphire);
  margin-bottom: 8px;
}

.question-text {
  font-family: var(--font-heading);
  font-size: clamp(1.2rem, 2.4vw, 1.55rem);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.45;
  margin-bottom: 26px;
}

.options-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--paper);
  border: 1.5px solid transparent;
  border-radius: 18px;
  padding: 14px 20px;
  cursor: pointer;
  transition: all 180ms var(--ease);
}

.option-item:hover {
  background: var(--greige);
  border-color: rgba(22, 43, 77, 0.2);
  transform: translateX(3px);
}

.option-item.selected {
  background: var(--white);
  border-color: var(--sapphire);
  box-shadow: 0 4px 16px rgba(22, 43, 77, 0.1);
}

.option-letter {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--greige);
  color: var(--sapphire);
  font-weight: 700;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 180ms var(--ease);
}

.option-item.selected .option-letter {
  background: var(--sapphire);
  color: var(--white);
}

.option-text {
  font-size: 1rem;
  color: var(--ink);
  font-weight: 500;
  line-height: 1.4;
}

/* Test Navigation Bar */
.test-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.nav-center {
  flex: 1;
  text-align: center;
}

@media (max-width: 640px) {
  .test-progress-header {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
    gap: 12px;
  }
  .test-timer {
    align-self: flex-start;
  }
  .question-content {
    padding: 24px 18px;
  }
  .option-item {
    padding: 12px 14px;
    gap: 12px;
  }
  .test-navigation {
    flex-wrap: wrap;
  }
  .nav-center {
    order: 3;
    width: 100%;
    margin-top: 8px;
  }
  .nav-center .btn {
    width: 100%;
  }
}

/* ==========================================================================
   Results Page
   ========================================================================== */
.results-content {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
  padding: 20px 0 40px;
}

.results-header {
  margin-bottom: 28px;
}

.results-header h1 {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}

.score-circle {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: var(--sapphire);
  color: var(--white);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
  box-shadow: 0 12px 32px rgba(22, 43, 77, 0.28);
}

.score-number {
  font-family: var(--font-heading);
  font-size: 3.2rem;
  font-weight: 700;
  line-height: 1;
}

.score-total {
  font-size: 0.88rem;
  opacity: 0.8;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* Level Card */
.level-card {
  background: var(--white);
  border-radius: 28px;
  padding: 36px 28px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  margin-bottom: 28px;
}

.level-badge {
  display: inline-block;
  padding: 6px 20px;
  border-radius: 9999px;
  background: var(--greige);
  color: var(--sapphire);
  font-size: 1.25rem;
  font-weight: 700;
  border: 1px solid var(--line);
  margin-bottom: 14px;
}

.level-card h2 {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 2.5vw, 1.85rem);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 12px;
}

.level-card p {
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.65;
  max-width: 580px;
  margin: 0 auto;
}

/* Stats */
.results-stats {
  background: var(--white);
  border-radius: 24px;
  padding: 20px 28px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  margin-bottom: 32px;
}

.stat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.stat-item:last-child {
  border-bottom: none;
}

.stat-label {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.stat-value {
  font-weight: 700;
  color: var(--sapphire);
  font-size: 1.05rem;
}

/* Action Buttons */
.results-actions h3 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 18px;
}

.action-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .level-card {
    padding: 24px 18px;
  }
  .results-stats {
    padding: 16px 18px;
  }
  .action-buttons {
    flex-direction: column;
  }
  .action-buttons .btn {
    width: 100%;
  }
}

/* ==========================================================================
   Warning Modal
   ========================================================================== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(28, 27, 26, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
  animation: modalFadeIn 220ms var(--ease);
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: var(--white);
  border-radius: 28px;
  padding: 36px 30px;
  max-width: 480px;
  width: 100%;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xl);
  text-align: center;
  animation: modalScaleUp 240ms var(--ease);
}

@keyframes modalScaleUp {
  from {
    transform: scale(0.95);
  }
  to {
    transform: scale(1);
  }
}

.modal-content h3 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--warning);
  margin-bottom: 12px;
}

#warningText {
  color: var(--ink);
  font-size: 0.98rem;
  margin-bottom: 12px;
}

.unanswered-list {
  background: var(--warning-soft);
  color: var(--warning);
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  margin: 14px 0 16px;
  word-break: break-word;
}

.warning-note {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-bottom: 24px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

@media (max-width: 480px) {
  .modal-content {
    padding: 26px 20px;
  }
  .modal-actions {
    flex-direction: column;
  }
  .modal-actions .btn {
    width: 100%;
  }
}
