/* game.css — Two Islands game page */

:root {
  --good1-color: var(--color-primary);    /* green — Good 1 */
  --good2-color: #a35b12;                 /* warm terracotta — Good 2 */
  --good2-color-tint: #f2e2d0;
  --country-a-flag: linear-gradient(135deg, #0b6b3a 0%, #08542d 100%);
  --country-b-flag: linear-gradient(135deg, #a35b12 0%, #7d4210 100%);
}
:root[data-theme="dark"], html[data-theme="dark"] {
  --good1-color: #3ecf7d;
  --good2-color: #e5a462;
  --good2-color-tint: #3a2a1a;
  --country-a-flag: linear-gradient(135deg, #3ecf7d 0%, #1d7d4a 100%);
  --country-b-flag: linear-gradient(135deg, #e5a462 0%, #a35b12 100%);
}

/* Good label color helpers */
.good1-label { color: var(--good1-color); font-weight: 600; }
.good2-label { color: var(--good2-color); font-weight: 600; }
.dot { display:inline-block; width:.5rem; height:.5rem; border-radius:9999px; margin-right:.35rem; vertical-align: baseline; }
.dot-good1 { background: var(--good1-color); }
.dot-good2 { background: var(--good2-color); }

/* Hero override just for game */
.game-hero { padding-block: clamp(var(--space-10), 6vw, var(--space-16)); border-bottom: 1px solid oklch(from var(--color-border) l c h / .5); }
.game-title { font-family: var(--font-display); font-weight: 600; font-size: var(--text-2xl); letter-spacing: -0.025em; line-height: 1.05; max-width: 22ch; margin-bottom: var(--space-5); }
.game-title em { font-style: italic; color: var(--color-primary); font-weight: 400; }
.game-lede { font-size: var(--text-lg); color: var(--color-text-muted); max-width: 62ch; margin-bottom: var(--space-6); }

/* Mode switch */
.mode-switch { display: inline-flex; gap: 4px; padding: 4px; background: var(--color-surface-offset); border-radius: var(--radius-full); }
.mode-btn { padding: var(--space-2) var(--space-4); border-radius: var(--radius-full); font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted); }
.mode-btn.is-active { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-sm); }

/* Section wrapping */
.game-section { padding-block: var(--space-10); }
.game-shell { display: flex; flex-direction: column; gap: var(--space-8); }

/* Advanced-only elements hidden in easy */
body[data-mode="easy"] [data-only="advanced"] { display: none !important; }

/* Scenario picker */
.scenario-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
.scenario-label { font-size: var(--text-sm); color: var(--color-text-muted); font-weight: 600; }
.scenario-select { padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); border: 1px solid var(--color-border); background: var(--color-bg); color: var(--color-text); font-size: var(--text-sm); font-family: var(--font-body); }

/* Country cards */
.countries { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: var(--space-6); }
.country-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-xl); padding: var(--space-6); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: var(--space-5); }
.country-head { display: flex; align-items: center; gap: var(--space-3); }
.country-flag { width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--country-a-flag); flex-shrink: 0; }
.country-flag.flag-B { background: var(--country-b-flag); }
.country-name { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; line-height: 1.1; margin: 0; }
.country-sub { font-size: var(--text-sm); color: var(--color-text-muted); margin: 0; }

/* Labor sliders */
.labor-block { display: flex; flex-direction: column; gap: var(--space-2); }
.labor-legend { display: flex; align-items: center; justify-content: space-between; font-size: var(--text-sm); color: var(--color-text-muted); }
.labor-values { font-family: var(--font-mono); color: var(--color-text); font-size: var(--text-xs); }
.labor-slider, .terms-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px;
  background: linear-gradient(to right, var(--good1-color) var(--fill,50%), var(--good2-color) var(--fill,50%));
  border-radius: 9999px; outline: none;
}
.labor-slider::-webkit-slider-thumb, .terms-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 9999px;
  background: var(--color-surface); border: 2px solid var(--color-text); cursor: pointer;
  box-shadow: var(--shadow-md);
}
.labor-slider::-moz-range-thumb, .terms-slider::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 9999px;
  background: var(--color-surface); border: 2px solid var(--color-text); cursor: pointer;
}
.terms-slider { background: linear-gradient(to right, var(--color-surface-offset), var(--color-surface-offset)); }

/* Production table */
.prod-table { width: 100%; font-size: var(--text-sm); }
.prod-table th, .prod-table td { padding: var(--space-2) var(--space-3); text-align: left; border-bottom: 1px solid var(--color-divider); }
.prod-table thead th { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .1em; color: var(--color-text-muted); font-weight: 600; }
.prod-table tbody th { font-weight: 400; color: var(--color-text-muted); }
.prod-table td { font-family: var(--font-mono); }
.prod-table td.figure { font-weight: 600; color: var(--color-text); }

/* PPF chart */
.ppf { width: 100%; height: auto; background: var(--color-surface-2); border-radius: var(--radius-md); padding: 0; }

/* Advantage callout */
.advantage-callout { padding: var(--space-5) var(--space-6); background: var(--color-primary-highlight); border-left: 4px solid var(--color-primary); border-radius: var(--radius-md); }
.advantage-eyebrow { font-size: var(--text-xs); letter-spacing: .18em; text-transform: uppercase; color: var(--color-primary); font-weight: 600; margin-bottom: var(--space-2); }
.advantage-callout p { font-size: var(--text-base); margin: 0; max-width: none; }

/* Trade panel */
.trade-panel { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-xl); padding: var(--space-8); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: var(--space-6); }
.trade-head { display: flex; flex-direction: column; gap: var(--space-2); }
.trade-title { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 600; letter-spacing: -.02em; line-height: 1.1; margin: 0; }
.trade-lede { color: var(--color-text-muted); font-size: var(--text-base); margin: 0; max-width: 60ch; }

.trade-controls { display: grid; grid-template-columns: 1fr; gap: var(--space-5); }
@media (min-width: 720px) { .trade-controls { grid-template-columns: 1.4fr 1fr; gap: var(--space-8); } }
.terms-block, .volume-block { display: flex; flex-direction: column; gap: var(--space-3); }
.terms-label { font-size: var(--text-sm); color: var(--color-text-muted); font-weight: 500; }
.terms-label [data-role="terms-value"], .terms-label [data-role="volume-value"] { font-family: var(--font-mono); color: var(--color-text); font-weight: 600; }

.terms-scale { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-3); font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-text-muted); }
.scale-bar { position: relative; height: 8px; background: var(--color-surface-offset); border-radius: 9999px; overflow: hidden; }
.scale-window { position: absolute; top: 0; bottom: 0; background: oklch(from var(--color-primary) l c h / .35); }
.scale-tick { position: absolute; top: -2px; bottom: -2px; width: 3px; background: var(--color-text); border-radius: 2px; }

/* Results */
.results-table { width: 100%; font-size: var(--text-sm); border-radius: var(--radius-md); overflow: hidden; }
.results-table th, .results-table td { padding: var(--space-3) var(--space-4); text-align: left; border-bottom: 1px solid var(--color-divider); }
.results-table thead th { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .1em; color: var(--color-text-muted); font-weight: 600; background: var(--color-surface-2); }
.results-table tbody th { font-weight: 400; color: var(--color-text-muted); }
.results-table td { font-family: var(--font-mono); font-weight: 600; }
.results-section-row th { font-family: var(--font-body); font-weight: 700; color: var(--color-text); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .1em; background: var(--color-surface-2); padding-top: var(--space-3); padding-bottom: var(--space-3); }
.cell-gain { color: var(--color-primary); }
.cell-loss { color: #b23a3a; }
:root[data-theme="dark"] .cell-loss { color: #ef6b6b; }

/* Verdict banner */
.verdict-banner { padding: var(--space-5) var(--space-6); border-radius: var(--radius-lg); border: 1px solid var(--color-border); background: var(--color-surface-2); }
.verdict-banner.is-win { background: var(--color-primary-highlight); border-color: var(--color-primary); }
.verdict-banner.is-lose { background: var(--good2-color-tint); border-color: var(--good2-color); }
.verdict-eyebrow { font-size: var(--text-xs); letter-spacing: .18em; text-transform: uppercase; font-weight: 600; margin-bottom: var(--space-2); color: var(--color-text-muted); }
.verdict-banner.is-win .verdict-eyebrow { color: var(--color-primary); }
.verdict-banner.is-lose .verdict-eyebrow { color: var(--good2-color); }
.verdict-banner p { font-size: var(--text-base); margin: 0; max-width: none; }

/* Custom inputs */
.custom-inputs { padding: var(--space-4) var(--space-5); background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
.custom-inputs summary { font-size: var(--text-sm); font-weight: 600; cursor: pointer; color: var(--color-text-muted); }
.custom-inputs[open] summary { margin-bottom: var(--space-4); color: var(--color-text); }
.custom-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-3); }
.custom-grid label { display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-xs); color: var(--color-text-muted); }
.custom-grid input { padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); border: 1px solid var(--color-border); background: var(--color-bg); color: var(--color-text); font-family: var(--font-mono); }

/* Notes section */
.notes-section { border-top: 1px solid oklch(from var(--color-border) l c h / .5); }
.notes-title { font-family: var(--font-display); font-weight: 600; font-size: var(--text-xl); letter-spacing: -.02em; margin-bottom: var(--space-4); }
.notes-source { font-size: var(--text-sm); color: var(--color-text-faint); margin-top: var(--space-4); }

/* Footer polish */
.footer-links { display: flex; gap: var(--space-5); flex-wrap: wrap; }

/* ============================================================
   Guided walkthrough
   ============================================================ */

/* Small button variant used inside the card */
.btn-sm { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); border-radius: var(--radius-full); }

/* Root overlay — sits above the page, but pointer-events pass through
   to the highlighted anchor so the player can actually interact. */
.walkthrough {
  position: fixed; inset: 0;
  z-index: 900;
  pointer-events: none;
}

/* The spotlight is a fixed-position dimming layer with a "hole" cut out
   over the current anchor using a radial-gradient mask, so we can still
   click through the hole. */
.walkthrough-spotlight {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: none;
  transition: clip-path 320ms cubic-bezier(.16, 1, .3, 1);
  /* clip-path is set inline by JS with a polygon that excludes the anchor rect */
}
:root[data-theme="dark"] .walkthrough-spotlight { background: rgba(0, 0, 0, 0.65); }

/* Ring around the current anchor */
.wt-ring {
  position: fixed;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 4px oklch(from var(--color-primary) l c h / 0.25), var(--shadow-lg);
  pointer-events: none;
  z-index: 901;
  transition: top 320ms cubic-bezier(.16, 1, .3, 1),
              left 320ms cubic-bezier(.16, 1, .3, 1),
              width 320ms cubic-bezier(.16, 1, .3, 1),
              height 320ms cubic-bezier(.16, 1, .3, 1),
              opacity 220ms;
}
.wt-ring.is-pulsing::after {
  content: "";
  position: absolute; inset: -6px;
  border: 2px solid var(--color-primary);
  border-radius: inherit;
  animation: wt-pulse 1.6s ease-out infinite;
  opacity: 0;
}
@keyframes wt-pulse {
  0%   { transform: scale(1);   opacity: 0.9; }
  100% { transform: scale(1.15); opacity: 0;   }
}

/* Card containing the step content */
.walkthrough-card {
  position: fixed;
  z-index: 902;
  max-width: 380px;
  min-width: 280px;
  padding: var(--space-5) var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  transition: top 320ms cubic-bezier(.16, 1, .3, 1),
              left 320ms cubic-bezier(.16, 1, .3, 1),
              opacity 220ms;
}
.wt-progress {
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-primary);
  font-weight: 600;
  margin-bottom: var(--space-2);
}
.wt-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-lg);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-2);
}
.wt-body {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.55;
  margin: 0 0 var(--space-5);
  max-width: none;
}
.wt-body strong { color: var(--color-text); font-weight: 600; }

.wt-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.wt-nav { display: flex; gap: var(--space-2); }
.wt-nav .btn, .wt-actions > .btn { pointer-events: auto; }
[data-role="wt-back"][disabled] { opacity: 0.4; pointer-events: none; }

/* "Do this now" cue attached to the card when we're waiting for the player */
.wt-cue {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-primary);
  padding: var(--space-2) var(--space-3);
  background: var(--color-primary-highlight);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-3);
}
.wt-cue::before {
  content: "";
  width: 8px; height: 8px; border-radius: 9999px;
  background: var(--color-primary);
  animation: wt-blink 1.2s ease-in-out infinite;
}
@keyframes wt-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* Restart walkthrough button — floating bottom-right, easy mode only */
.restart-walkthrough[hidden] { display: none !important; }
.restart-walkthrough {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 500;
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
}
.restart-walkthrough:hover {
  color: var(--color-text);
  border-color: var(--color-primary);
}

/* Also make sure [hidden] on the walkthrough root actually hides it */
.walkthrough[hidden] { display: none !important; }

/* Mobile: card sits at the bottom instead of near the anchor */
@media (max-width: 720px) {
  .walkthrough-card {
    left: var(--space-4) !important;
    right: var(--space-4);
    bottom: var(--space-4);
    top: auto !important;
    max-width: none;
  }
  .restart-walkthrough {
    bottom: var(--space-4);
    right: var(--space-4);
  }
}
