/* Graph Set styles - heating curve activity
 * WCAG 2.1 AA compliant
 */

* { box-sizing: border-box; }

:root {
  /* Colors chosen for 4.5:1+ contrast against backgrounds */
  --primary: #1e3a8a;          /* dark blue, 9.4:1 on white */
  --primary-hover: #1e40af;
  --accent: #0e7490;            /* darker cyan, 5.6:1 on white */
  --bg: #f8fafc;
  --card: #ffffff;
  --light-bg: #eff6ff;
  --border: #64748b;            /* darker for visibility, 4.76:1 against white */
  --text: #0f172a;              /* near-black, 18:1 on white */
  --muted: #475569;             /* 7.5:1 on white */
  --success: #15803d;           /* darker green, 5.5:1 on white */
  --success-bg: #dcfce7;
  --success-text: #14532d;      /* 9:1 on success-bg */
  --error: #b91c1c;             /* darker red, 6:1 on white */
  --error-bg: #fee2e2;
  --error-text: #7f1d1d;        /* 9:1 on error-bg */
  --info-text: #1e3a8a;
  --plateau-melt: #bae6fd;
  --plateau-boil: #fed7aa;
  --focus: #2563eb;
}

html { font-size: 100%; }       /* respect user's font size preference */

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  line-height: 1.6;
  font-size: 1rem;
}

/* Skip link for keyboard users */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--primary);
  color: white;
  padding: 0.75rem 1.25rem;
  z-index: 100;
  text-decoration: none;
  font-weight: 600;
  border-radius: 0 0 0.5rem 0;
}
.skip-link:focus {
  top: 0;
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

/* Visually hidden, available to screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Universal high-contrast focus indicator */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 1.25rem;
}

header[role="banner"] {
  background: var(--primary);
  color: white;
  padding: 1.4rem 1.75rem;
  border-radius: 0.75rem;
  margin-bottom: 1.4rem;
}
header h1 { margin: 0 0 0.4rem 0; font-size: 1.5rem; font-weight: 700; }
header .subtitle { margin: 0; font-size: 0.875rem; color: white; }

/* Progress track: real buttons, keyboard accessible */
.progress-track {
  display: flex;
  gap: 0.4rem;
  background: var(--card);
  padding: 0.6rem 0.85rem;
  border-radius: 0.625rem;
  margin-bottom: 1.125rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.progress-step {
  flex: 1;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.55rem 0.4rem;
  border-radius: 0.4rem;
  background: #e2e8f0;
  color: var(--text);
  border: 2px solid transparent;
  cursor: not-allowed;
  font-family: inherit;
  min-height: 2.5rem;
}
.progress-step.completed {
  background: var(--success);
  color: white;
  cursor: pointer;
}
.progress-step.completed:hover { background: #166534; }
.progress-step.active {
  background: var(--primary);
  color: white;
  border-color: white;
  cursor: default;
}
.progress-step:disabled { opacity: 1; }

/* Card */
.card {
  background: var(--card);
  border-radius: 0.75rem;
  padding: 1.5rem 1.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 1rem;
  border: 1px solid #e2e8f0;
}
.card h2 { color: var(--primary); margin-top: 0; font-size: 1.375rem; }

.intro {
  font-size: 1rem;
  color: var(--text);
  background: var(--light-bg);
  padding: 0.875rem 1rem;
  border-radius: 0.5rem;
  border-left: 4px solid var(--accent);
  margin-bottom: 0.875rem;
}

.question {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 0.625rem;
  padding: 1rem 1.125rem;
  margin-bottom: 0.875rem;
}
.question-prompt {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.625rem;
  color: var(--text);
}
.q-num {
  display: inline-block;
  background: var(--primary);
  color: white;
  min-width: 1.625rem;
  height: 1.625rem;
  padding: 0 0.375rem;
  border-radius: 50%;
  text-align: center;
  font-size: 0.85rem;
  line-height: 1.625rem;
  margin-right: 0.5rem;
  font-weight: 700;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.choice {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.7rem 0.875rem;
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
  min-height: 2.75rem;
  background: white;
}
.choice:hover {
  border-color: var(--accent);
  background: var(--light-bg);
}
.choice:focus-within {
  border-color: var(--focus);
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}
.choice input[type="radio"] {
  margin-top: 0.25rem;
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.choice.selected {
  border-color: var(--primary);
  background: var(--light-bg);
  border-width: 2.5px;
}
/* Correct/incorrect: never color alone, always include text mark */
.choice.correct { border-color: var(--success); background: var(--success-bg); }
.choice.correct .answer-mark { color: var(--success-text); font-weight: 700; }
.choice.incorrect { border-color: var(--error); background: var(--error-bg); }
.choice.incorrect .answer-mark { color: var(--error-text); font-weight: 700; }
.answer-mark {
  margin-left: auto;
  font-size: 0.875rem;
  white-space: nowrap;
}

textarea {
  width: 100%;
  min-height: 5.5rem;
  padding: 0.625rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
  color: var(--text);
  background: white;
}
textarea:focus-visible { border-color: var(--focus); }

.feedback {
  margin-top: 0.625rem;
  padding: 0.7rem 0.95rem;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  border-left: 4px solid var(--accent);
}
.feedback.info { background: var(--light-bg); color: var(--info-text); border-left-color: var(--accent); }
.feedback.success { background: var(--success-bg); color: var(--success-text); border-left-color: var(--success); }

.btn {
  background: var(--primary);
  color: white;
  border: 2px solid var(--primary);
  padding: 0.65rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 0.5rem;
  cursor: pointer;
  font-family: inherit;
  min-height: 2.75rem;
  min-width: 6rem;
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn:disabled { background: #94a3b8; border-color: #94a3b8; cursor: not-allowed; }
.btn.secondary { background: white; color: var(--primary); border: 2px solid var(--primary); }
.btn.secondary:hover { background: var(--light-bg); }
.btn-row {
  display: flex;
  gap: 0.625rem;
  margin-top: 1rem;
  justify-content: space-between;
  align-items: center;
}

.graph-stage {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 0.625rem;
  padding: 0.75rem;
  margin: 0.875rem 0;
}
svg.heating-graph { width: 100%; height: auto; display: block; }

/* Visible text description of the graph - benefits everyone */
.graph-description {
  font-size: 0.9rem;
  color: var(--muted);
  padding: 0.625rem 0.75rem;
  margin-top: 0.5rem;
  background: #f1f5f9;
  border-radius: 0.4rem;
  border-left: 3px solid var(--accent);
}
.graph-description strong { color: var(--text); }

.stage-label {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 0.3rem 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.8125rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.score-card { text-align: center; padding: 1.875rem 1.25rem; }
.score-big { font-size: 4rem; font-weight: 700; color: var(--primary); line-height: 1; margin: 0.875rem 0; }
.score-detail { font-size: 1rem; color: var(--muted); margin-bottom: 1.125rem; }
.section-scores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin: 1.25rem 0;
  text-align: left;
}
.section-score {
  background: var(--light-bg);
  padding: 0.875rem;
  border-radius: 0.5rem;
  border-left: 3px solid var(--accent);
}
.section-score-label {
  font-size: 0.75rem;
  color: var(--text);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.section-score-value {
  font-size: 1.375rem;
  color: var(--primary);
  font-weight: 700;
  margin-top: 0.125rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
  font-weight: 500;
}
.alert.error {
  background: var(--error-bg);
  color: var(--error-text);
  border-left: 4px solid var(--error);
}

@media (max-width: 640px) {
  .app { padding: 0.75rem; }
  header[role="banner"] { padding: 1rem 1.125rem; }
  header h1 { font-size: 1.2rem; }
  .card { padding: 1rem 1.125rem; }
  .progress-track { padding: 0.5rem; gap: 0.25rem; }
  .progress-step { font-size: 0.7rem; padding: 0.45rem 0.15rem; }
  .btn-row { flex-direction: column-reverse; align-items: stretch; }
  .btn { width: 100%; }
  .score-big { font-size: 3rem; }
}

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

@media (forced-colors: active) {
  .btn { border: 2px solid ButtonText; }
  .choice { border: 2px solid ButtonText; }
  .choice.selected { border: 3px solid Highlight; }
  .progress-step.active { border: 3px solid Highlight; }
}

@media print {
  .progress-track, .btn-row { display: none; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ==========================================
   Two-column DoK layout: graph + questions
   ========================================== */

.dok-split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 1.25rem;
  align-items: start;
  margin-top: 0.875rem;
}

.dok-graph-col {
  /* Stay visible while questions scroll on desktop */
  position: sticky;
  top: 0.625rem;
}

.dok-graph-col .graph-stage {
  margin: 0 0 0.625rem 0;
}

.dok-graph-col .graph-description {
  margin-top: 0;
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
}

.dok-questions-col {
  min-width: 0; /* prevent overflow inside grid cells */
}

.dok-questions-col .question {
  margin-bottom: 1rem;
}

.dok-questions-col .btn-row {
  margin-top: 1rem;
}

/* Stack on tablet/mobile */
@media (max-width: 900px) {
  .dok-split-layout {
    grid-template-columns: 1fr;
  }
  .dok-graph-col {
    position: static; /* don't sticky on mobile - takes too much vertical space */
  }
}
