/*
 * main.css — EconRecall canonical stylesheet
 * One file, shared by every page and every game. Light theme with a
 * dark navy nav/footer (Recall family convention), emerald/gold accents
 * evoking finance and market history rather than RecallArena's blue.
 */

:root {
  --navy: #0f1b2d;
  --bg: #f6f7f5;
  --bg-card: #ffffff;
  --bg-inset: #f1f3f0;
  --border: #dbe0da;
  --text: #10201c;
  --text-muted: #5c6b66;
  --accent: #0f9d58;
  --accent-hover: #0c7d46;
  --gold: #c9a227;
  --success: #0f9d58;
  --error: #c1272d;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(15, 27, 45, 0.08);
  --max-width: 1100px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

.er-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Header / nav ── */

.er-header {
  background: var(--navy);
}

.er-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  max-width: var(--max-width);
  margin: 0 auto;
}

.er-logo {
  font-size: 1.4rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.er-logo span {
  color: var(--gold);
}

.er-nav {
  display: flex;
  gap: 24px;
}

.er-nav a {
  color: rgba(255, 255, 255, 0.75);
  font-weight: 600;
  font-size: 0.95rem;
}

.er-nav a:hover {
  color: #ffffff;
}

/* ── Hero ── */

.er-hero {
  text-align: center;
  padding: 64px 20px 40px;
}

.er-hero h1 {
  font-size: 2.4rem;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
  color: var(--text);
}

.er-hero p {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 620px;
  margin: 0 auto;
}

/* ── Game grid ── */

.er-category-heading {
  max-width: var(--max-width);
  margin: 40px auto 0;
  padding: 0 20px;
  font-size: 1.3rem;
  color: var(--text);
}

.er-category-heading:first-of-type {
  margin-top: 8px;
}

.er-category-sub {
  max-width: var(--max-width);
  margin: 4px auto 0;
  padding: 0 20px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.er-game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  padding: 20px 20px 64px;
  max-width: var(--max-width);
  margin: 0 auto;
}

.er-game-card {
  position: relative;
  display: block;
  height: 180px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  color: #ffffff;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  background: linear-gradient(135deg, #1f3d2b, #0f1b2d);
  border-top: 3px solid var(--gold);
}

a.er-game-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 28px rgba(15, 27, 45, 0.25);
}

.er-card-icon {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 3.4rem;
  line-height: 1;
}

.er-card-year {
  position: absolute;
  top: 14px;
  right: 16px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--gold);
  font-weight: 800;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 999px;
}

.er-card-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 16px 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0));
}

.er-card-info h3 {
  margin: 0 0 3px;
  font-size: 1rem;
  font-weight: 800;
  color: #ffffff;
}

.er-card-info p {
  margin: 0;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Footer ── */

.er-footer {
  background: var(--navy);
  padding: 28px 20px 40px;
  text-align: center;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.85rem;
}

.er-footer a {
  color: rgba(255, 255, 255, 0.9);
}

/* ── Scenario game screen ── */

.er-game-shell {
  max-width: 1000px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

.er-game-header {
  max-width: 720px;
  margin: 0 auto 24px;
}

.er-game-header h1 {
  margin: 0 0 6px;
  font-size: 1.6rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.er-game-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.er-game-row {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  justify-content: center;
}

.er-game-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  max-width: 680px;
  width: 100%;
}

.er-scenario-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  font-weight: 700;
}

.er-scenario-year {
  color: var(--gold);
  background: rgba(201, 162, 39, 0.12);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
}

#er-progress {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.er-scenario-context {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0 0 16px;
  padding: 14px 16px;
  background: var(--bg-inset);
  border-left: 3px solid var(--navy);
  border-radius: 4px;
}

.er-scenario-prompt {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 20px;
  color: var(--text);
}

.er-choices {
  display: grid;
  gap: 12px;
}

.er-choice-btn {
  background: var(--bg-card);
  border: 1.5px solid var(--navy);
  color: var(--text);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.er-choice-btn:hover:not(:disabled) {
  background: var(--navy);
  color: #ffffff;
}

.er-choice-btn:disabled {
  cursor: default;
  opacity: 0.6;
}

.er-outcome-banner {
  margin: 0 0 20px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: rgba(15, 157, 88, 0.1);
  border: 1px solid rgba(15, 157, 88, 0.35);
  font-size: 0.95rem;
}

.er-outcome-banner.er-outcome-low {
  background: rgba(193, 39, 45, 0.08);
  border-color: rgba(193, 39, 45, 0.3);
}

.er-continue-btn {
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 12px 22px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.er-continue-btn:hover {
  background: #1a2c45;
}

/* ── Results screen ── */

.er-results-card {
  text-align: center;
}

.er-results-card h2 {
  margin: 0 0 4px;
  color: var(--text-muted);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.er-results-score {
  font-size: 3rem;
  font-weight: 800;
  margin: 0;
  color: var(--accent);
}

.er-results-sub {
  color: var(--text-muted);
  margin: 4px 0 24px;
}

.er-decision-log {
  text-align: left;
  margin: 24px 0;
  padding: 20px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.er-decision-log h3 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.er-decision-log ol {
  margin: 0;
  padding: 0 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.er-share-card {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.9rem;
  margin: 0 0 16px;
  color: var(--text);
}

.er-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 12px 22px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.er-btn:hover {
  background: var(--accent-hover);
}

.er-email-capture {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.er-email-capture label {
  font-weight: 600;
  font-size: 0.95rem;
}

.er-email-row {
  display: flex;
  gap: 10px;
}

.er-email-row input[type="email"] {
  flex: 1;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  font-size: 0.95rem;
}

.er-email-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

.er-email-success {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--success);
  font-weight: 700;
  text-align: left;
}

/* ── Legal / static pages ── */

.er-doc {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 20px 80px;
}

.er-doc h1 {
  font-size: 1.8rem;
  margin: 0 0 8px;
}

.er-doc h2 {
  font-size: 1.15rem;
  margin: 32px 0 8px;
}

.er-doc p, .er-doc li {
  color: var(--text-muted);
  font-size: 0.98rem;
}

/* ── Programmatic learn pages ── */

.er-learn-play-cta {
  margin: 16px 0 8px;
}

.er-learn-section {
  margin-top: 8px;
}

.er-learn-related {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.er-learn-related h3 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.er-learn-related ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.er-learn-related li a {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 600;
}

/* ── Drag-the-curve engine (js/curve-engine.js) ── */

.er-curve-graph {
  margin: 4px 0 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* The SVG uses a viewBox and scales to this width, so the graph stays
     legible on a phone without a second set of coordinates. */
  overflow: hidden;
}

.er-curve-graph svg {
  display: block;
  width: 100%;
  height: auto;
  /* Without this, dragging a handle on a touch device scrolls the page
     instead of moving the curve. */
  touch-action: none;
}

.er-curve-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.er-curve-axis {
  stroke: var(--text-muted);
  stroke-width: 1.5;
}

.er-curve-axis-label {
  fill: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

.er-curve-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
}

.er-curve-dashed {
  stroke-dasharray: 7 5;
}

.er-curve-label {
  font-size: 12px;
  font-weight: 700;
}

.er-curve-point {
  stroke: var(--bg-card);
  stroke-width: 2;
}

/* Curve tones. Demand/supply keep the conventional textbook pairing so the
   graphs read the same way a student's course materials do. */
.er-tone-demand { stroke: #1f6feb; }
.er-tone-supply { stroke: var(--error); }
.er-tone-world  { stroke: var(--text-muted); }
.er-tone-accent { stroke: var(--accent); }
.er-tone-neutral { stroke: var(--navy); }

text.er-tone-demand { fill: #1f6feb; stroke: none; }
text.er-tone-supply { fill: var(--error); stroke: none; }
text.er-tone-world  { fill: var(--text-muted); stroke: none; }
text.er-tone-accent { fill: var(--accent); stroke: none; }
text.er-tone-neutral { fill: var(--navy); stroke: none; }

circle.er-tone-demand { fill: #1f6feb; }
circle.er-tone-supply { fill: var(--error); }
circle.er-tone-world  { fill: var(--text-muted); }
circle.er-tone-accent { fill: var(--accent); }
circle.er-tone-neutral { fill: var(--navy); }

.er-curve-marker {
  fill: var(--gold);
  stroke: var(--bg-card);
  stroke-width: 2;
}

.er-curve-marker-line {
  stroke: var(--gold);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
}

/* An invisible, generously sized hit target around each handle — an 11px
   circle is a precise mouse target but a poor thumb target. */
.er-curve-handle-hit {
  fill: transparent;
  cursor: grab;
}

/* Set on the <svg> itself while a drag is live — the handle nodes are
   replaced on every redraw, so a class on them would not survive. */
svg.er-dragging .er-curve-handle-hit,
svg.er-dragging .er-curve-handle {
  cursor: grabbing;
}

.er-curve-handle {
  stroke: var(--bg-card);
  stroke-width: 3;
  cursor: grab;
  transition: r 0.12s ease;
}

.er-curve-handle:hover,
.er-curve-handle:focus {
  r: 14;
  outline: none;
}

.er-curve-handle:focus {
  stroke: var(--gold);
}

.er-curve-controls {
  display: grid;
  gap: 10px;
  margin: 12px 0 16px;
}

.er-curve-slider-row label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.er-curve-slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.er-curve-readout {
  margin: 0 0 20px;
  padding: 14px 16px;
  background: var(--bg-inset);
  border-radius: var(--radius);
  border-left: 3px solid var(--navy);
}

.er-curve-readout-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 3px 0;
}

.er-curve-readout-row dt {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.er-curve-readout-row dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.er-curve-readout-row.er-readout-good dd { color: var(--success); }
.er-curve-readout-row.er-readout-warn dd { color: var(--error); }

/* ── Match/sort engine (js/match-engine.js) ── */

.er-match-howto {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: -12px 0 18px;
}

.er-match-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px;
  min-height: 64px;
  background: var(--bg-inset);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.er-match-item {
  background: var(--bg-card);
  border: 1.5px solid var(--navy);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  text-align: left;
  cursor: grab;
  /* Without this a drag on touch scrolls the page instead of moving the item. */
  touch-action: none;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.er-match-item:hover {
  background: var(--navy);
  color: #ffffff;
}

.er-match-item.er-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(15, 157, 88, 0.25);
}

.er-match-item:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.er-match-item.er-match-dragging {
  /* pointer-events:none is load-bearing: elementFromPoint during a drag has
     to see the target underneath, not the item being dragged. */
  pointer-events: none;
  cursor: grabbing;
  z-index: 5;
  position: relative;
  box-shadow: 0 8px 24px rgba(15, 27, 45, 0.25);
}

@keyframes er-match-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.er-match-item.er-match-shake {
  animation: er-match-shake 0.32s ease;
  border-color: var(--error);
}

.er-match-targets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.er-match-target {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.er-match-target.er-match-armed {
  border-color: var(--accent);
  border-style: dashed;
}

.er-match-target.er-match-over {
  background: rgba(15, 157, 88, 0.08);
  border-color: var(--accent);
  border-style: solid;
}

.er-match-drop {
  display: block;
  width: 100%;
  background: none;
  border: none;
  font-family: inherit;
  text-align: left;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--text);
}

.er-match-drop:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: -3px;
}

.er-match-target-label {
  display: block;
  font-weight: 700;
  font-size: 0.98rem;
}

.er-match-target-sub {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.er-match-placed {
  list-style: none;
  margin: 0;
  padding: 0 14px 12px;
}

.er-match-placed:empty {
  padding: 0;
}

.er-match-placed li {
  font-size: 0.88rem;
  padding: 6px 10px;
  border-radius: 6px;
  margin-top: 6px;
}

.er-match-placed li.er-match-correct {
  background: rgba(15, 157, 88, 0.12);
  border-left: 3px solid var(--success);
}

/* Revealed after three wrong tries — scored zero, so it must not read as a win. */
.er-match-placed li.er-match-revealed {
  background: rgba(201, 162, 39, 0.14);
  border-left: 3px solid var(--gold);
  color: var(--text-muted);
}

.er-match-feedback {
  min-height: 48px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--bg-inset);
  font-size: 0.92rem;
  margin-bottom: 16px;
}

.er-match-feedback.er-match-correct {
  background: rgba(15, 157, 88, 0.1);
  border: 1px solid rgba(15, 157, 88, 0.35);
}

.er-match-feedback.er-match-wrong {
  background: rgba(193, 39, 45, 0.08);
  border: 1px solid rgba(193, 39, 45, 0.3);
}

.er-match-feedback.er-match-revealed {
  background: rgba(201, 162, 39, 0.12);
  border: 1px solid rgba(201, 162, 39, 0.35);
}

@media (prefers-reduced-motion: reduce) {
  .er-match-item.er-match-shake { animation: none; }
  .er-match-item { transition: none; }
}

.er-disclaimer-bar {
  background: #ffffff;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.er-disclaimer-bar strong {
  color: var(--text);
}

/* ── Responsive ── */

@media (max-width: 1040px) {
  .er-game-shell,
  .er-game-row {
    max-width: 680px;
  }
}

@media (max-width: 640px) {
  .er-hero h1 {
    font-size: 1.8rem;
  }

  .er-header-inner {
    flex-direction: column;
    gap: 10px;
  }

  .er-game-grid {
    grid-template-columns: 1fr;
  }

  .er-email-row {
    flex-direction: column;
  }
}
