/**
 * Production Styling – English Placement Test
 * Mobile-first, accessible, minimal
 */

/* ────────────────────────────────────────
   RESET & DEFAULTS
   ──────────────────────────────────────── */

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  color: #333;
  background-color: #f7f7f7;
}

/* ────────────────────────────────────────
   LAYOUT: APP CONTAINER
   ──────────────────────────────────────── */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: #fff;
}

.screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
}

.screen[hidden] {
  display: none;
}

/* ────────────────────────────────────────
   HEADER: STRUCTURE
   ──────────────────────────────────────── */

header {
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #1a1a1a;
  line-height: 1.3;
}

header .subtitle {
  margin: 0.25rem 0 0 0;
  font-size: 0.875rem;
  color: #666;
}

/* ────────────────────────────────────────
   PROGRESS BAR
   ──────────────────────────────────────── */

.progress-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.progress-bar {
  height: 6px;
  background-color: #e8e8e8;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: #2563eb;
  transition: width 0.3s ease;
  border-radius: 3px;
}

/* ────────────────────────────────────────
   HEADER: TIMER DISPLAY
   ──────────────────────────────────────── */

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.header-title {
  flex: 1;
}

.timer-display {
  font-size: 0.875rem;
  color: #666;
  font-family: "Menlo", "Monaco", "Courier New", monospace;
  font-weight: 500;
  white-space: nowrap;
  padding: 0.5rem 0.75rem;
  background-color: #f5f5f5;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
}

/* ────────────────────────────────────────
   MAIN: CONTENT AREA
   ──────────────────────────────────────── */

main {
  flex: 1;
  padding: 2rem 1.5rem;
  overflow-y: auto;
}

section {
  width: 100%;
}

/* ────────────────────────────────────────
   TYPOGRAPHY
   ──────────────────────────────────────── */

h2 {
  margin: 0 0 1.25rem 0;
  font-size: 1.375rem;
  font-weight: 600;
  color: #1a1a1a;
}

h3 {
  margin: 1.5rem 0 0.75rem 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #1a1a1a;
}

h3:first-child {
  margin-top: 0;
}

p {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  line-height: 1.6;
}

p:last-child {
  margin-bottom: 0;
}

ul, ol {
  margin: 0 0 1rem 0;
  padding-left: 1.5rem;
}

li {
  margin: 0.5rem 0;
  line-height: 1.6;
}

strong {
  font-weight: 600;
  color: #1a1a1a;
}

/* ────────────────────────────────────────
   BUTTONS
   ──────────────────────────────────────── */

.button {
  display: inline-block;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.button:focus {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button-primary {
  background-color: #2563eb;
  color: white;
}

.button-primary:hover:not(:disabled) {
  background-color: #1d4ed8;
}

.button-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.button-secondary {
  background-color: #e8e8e8;
  color: #333;
}

.button-secondary:hover:not(:disabled) {
  background-color: #d8d8d8;
}

.button-small {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* ────────────────────────────────────────
   FOOTER: BUTTON LAYOUT
   ──────────────────────────────────────── */

footer {
  padding: 1.5rem;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

footer .button {
  flex: 0 0 auto;
}

@media (max-width: 480px) {
  footer {
    flex-direction: column;
  }
  footer .button {
    width: 100%;
  }
}

/* ────────────────────────────────────────
   QUESTION SCREEN: LAYOUT
   ──────────────────────────────────────── */

#question-container {
  margin-bottom: 2rem;
}

#question-text {
  font-size: 1.125rem;
  font-weight: 500;
  margin-bottom: 1.5rem;
  color: #1a1a1a;
  line-height: 1.7;
}

/* ────────────────────────────────────────
   AUDIO BUTTON
   ──────────────────────────────────────── */

#audio-container {
  margin-bottom: 1.5rem;
}

#btn-play-audio {
  background-color: #e8e8e8;
  color: #333;
}

#btn-play-audio:hover:not(:disabled) {
  background-color: #d8d8d8;
}

/* ────────────────────────────────────────
   ANSWER OPTIONS: LAYOUT
   ──────────────────────────────────────── */

#answers-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.option-label {
  display: flex;
  align-items: flex-start;
  padding: 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  background-color: #fff;
}

.option-label:hover {
  border-color: #b0b0b0;
  background-color: #fafafa;
}

.option-label input {
  accent-color: #2563eb;
  width: 20px;
  height: 20px;
  margin-right: 0.75rem;
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
}

.option-label input:focus {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.option-label input:checked {
  background-color: #2563eb;
}

.option-text {
  flex: 1;
  font-size: 1rem;
  line-height: 1.5;
  color: #333;
}

/* Selected state */
.option-label input:checked ~ .option-text {
  font-weight: 500;
  color: #1a1a1a;
}

.option-label:has(input:checked) {
  border-color: #2563eb;
  background-color: #f0f7ff;
}

/* ────────────────────────────────────────
   FREE RESPONSE INPUT
   ──────────────────────────────────────── */

.free-response-input {
  width: 100%;
  padding: 0.875rem;
  font-size: 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.free-response-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ────────────────────────────────────────
   RESULT SCREEN: LAYOUT
   ──────────────────────────────────────── */

#result-container {
  margin: 2rem 0;
}

.result-level {
  background-color: #f0f7ff;
  border-left: 4px solid #2563eb;
  padding: 1.5rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
}

.result-label {
  margin: 0 0 0.5rem 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.result-value {
  margin: 0;
  font-size: 3rem;
  font-weight: 700;
  color: #2563eb;
  line-height: 1;
}

.result-description {
  margin: 0.75rem 0 0 0;
  font-size: 1rem;
  color: #333;
}

.result-stat {
  background-color: #fff;
  border: 1px solid #e0e0e0;
  padding: 1.25rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.stat-label {
  margin: 0 0 0.5rem 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: #666;
}

.stat-value {
  margin: 0;
  font-size: 1.875rem;
  font-weight: 700;
  color: #1a1a1a;
}

.stat-note {
  margin: 0.5rem 0 0 0;
  font-size: 0.875rem;
  color: #999;
}

/* ────────────────────────────────────────
   LOADING SCREEN
   ──────────────────────────────────────── */

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e0e0e0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#loading-message {
  font-size: 1.125rem;
  font-weight: 500;
  color: #1a1a1a;
}

.loading-subtitle {
  font-size: 0.875rem;
  color: #666;
}

/* ────────────────────────────────────────
   WELCOME / INSTRUCTIONS SCREENS
   ──────────────────────────────────────── */

.subtitle {
  color: #666;
  font-size: 0.95rem;
}

/* ────────────────────────────────────────
   ERROR MESSAGES
   ──────────────────────────────────────── */

.error-message {
  background-color: #fee2e2;
  border-left: 4px solid #dc2626;
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.error-text {
  margin: 0;
  color: #991b1b;
  font-size: 0.95rem;
}

/* ────────────────────────────────────────
   RESPONSIVE: MOBILE
   ──────────────────────────────────────── */

@media (max-width: 640px) {
  html {
    font-size: 15px;
  }

  header {
    padding: 1rem 1rem;
  }

  header h1 {
    font-size: 1.25rem;
  }

  main {
    padding: 1.5rem 1rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  #question-text {
    font-size: 1rem;
  }

  .timer-display {
    font-size: 0.75rem;
    padding: 0.4rem 0.6rem;
  }

  footer {
    padding: 1rem;
    gap: 0.75rem;
  }

  .button {
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
  }

  .result-value {
    font-size: 2.5rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }
}

/* ────────────────────────────────────────
   ACCESSIBILITY: HIGH CONTRAST MODE
   ──────────────────────────────────────── */

@media (prefers-contrast: more) {
  .option-label {
    border-width: 3px;
  }

  .button {
    border: 2px solid currentColor;
  }

  #question-text {
    font-weight: 600;
  }
}

/* ────────────────────────────────────────
   ACCESSIBILITY: REDUCED MOTION
   ──────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .progress-fill {
    transition: none;
  }

  .button:active:not(:disabled) {
    transform: none;
  }

  .spinner {
    animation: none;
    border-top-color: transparent;
  }
}
