/* Stock Jumper - latz.dk */

/* ── Design tokens ───────────────────────────────────────── */

:root {
  --accent:        #00d97e;
  --accent-dim:    #00a85f;
  --accent-glow:   rgba(0, 217, 126, 0.15);
  --danger:        #ff3366;
  --danger-dim:    #cc1a4a;
  --danger-glow:   rgba(255, 51, 102, 0.15);

  --bg:            #000000;
  --bg-2:          #000000;
  --ground:        #0a0a0a;
  --border:        #1e1e1e;

  /* WCAG AA contrast ≥ 4.5:1 on #000 requires luminance ≥ 0.175 */
  --text:          #ffffff;   /* 21:1  ✓ */
  --text-dim:      #888888;   /* 4.9:1 ✓ */
  --text-muted:    #767676;   /* 4.6:1 ✓ - WCAG AA minimum */

  --header-h:      52px;
  --footer-h:      44px;
  --font:          'Noto Sans', sans-serif;

  --theme:         var(--accent);
  --theme-dim:     var(--accent-dim);
  --theme-glow:    var(--accent-glow);

  /* Play button follows toggle override, not --theme */
  --play-color:    var(--accent);
  --play-glow:     var(--accent-glow);
}

body.market-up {
  --theme:      var(--accent);
  --theme-dim:  var(--accent-dim);
  --theme-glow: var(--accent-glow);
}
body.market-down {
  --theme:      var(--danger);
  --theme-dim:  var(--danger-dim);
  --theme-glow: var(--danger-glow);
}

/* ── Reset ───────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 400;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ── App shell ───────────────────────────────────────────── */

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ── Header ──────────────────────────────────────────────── */

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

/* latz.dk logo */
.logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-img {
  height: 28px;
  width: auto;
  display: block;
}
.logo-text {
  font-size: 13px;
  font-weight: 300;
  letter-spacing: 0.05em;
  color: var(--text);
  margin-left: 8px;
}
.logo:hover { opacity: 0.7; }
.logo:focus-visible {
  outline: 2px solid var(--theme);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Ticker: label + % - same size, same weight, both white by default */
#market-ticker {
  display: flex;
  align-items: center;
  gap: 6px;
}

#ticker-label {
  font-size: 12px;
  font-weight: 400;
  color: var(--text);          /* white, same as change */
}

#ticker-change {
  font-size: 12px;
  font-weight: 400;
  color: var(--text);          /* white baseline; coloured when live data */
  transition: color 0.4s;
}
#ticker-change.up   { color: var(--accent); }
#ticker-change.down { color: var(--danger); }

/* ── Main / Canvas ───────────────────────────────────────── */

main {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* ── Overlay ─────────────────────────────────────────────── */

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
  z-index: 20;
  transition: opacity 0.25s;
}
#overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-inner {
  text-align: center;
  padding: 40px 28px;
  background: #000000;
  border: 1px solid rgba(255, 255, 255, 0.08);
  max-width: 420px;            /* wider so exchange row fits on one line */
  width: 90%;
  position: relative;
}

/* Thin theme-coloured inner border */
.overlay-inner::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid var(--theme);
  opacity: 0.25;
  pointer-events: none;
  transition: border-color 0.5s;
}

/* "Stock Jumper" - regular weight */
.overlay-inner h1 {
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--text);
  margin-bottom: 20px;
}

/* ── Exchange selector row ───────────────────────────────── */
/* All items match the same 12px text size so they read as one line */

.exchange-row {
  display: flex;
  align-items: baseline;
  gap: 5px;
  flex-wrap: nowrap;           /* keep on a single line */
  justify-content: center;
  margin-bottom: 20px;
  font-size: 12px;
}

/* Level row sits below the Play button */
.level-row {
  margin-top: 20px;
  margin-bottom: 0;
}

.exchange-tag {
  padding: 1px 7px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: var(--text);
  background: transparent;
  font-family: var(--font);
  font-size: 12px;             /* same as determines-text */
  font-weight: 400;
  letter-spacing: 0.03em;
  line-height: 1.6;            /* matches surrounding text height */
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  vertical-align: baseline;
}
.exchange-tag:hover:not(.active) {
  border-color: rgba(255, 255, 255, 0.85);
}
.exchange-tag.active {
  border-color: var(--theme);
  color: var(--theme);
  background: var(--theme-glow);
}
.exchange-tag:focus-visible {
  outline: 2px solid var(--theme);
  outline-offset: 2px;
}

/* ── Course override toggle switch ──────────────────────────
   Checked (on)  = green course
   Unchecked     = red course
   Colors are hardcoded - independent of --theme since the
   switch CONTROLS the theme.                                  */

.switch {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 15px;
  vertical-align: middle;
  flex-shrink: 0;
  cursor: pointer;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ff3366;         /* unchecked = red */
  transition: background 0.25s;
  cursor: pointer;
}
.slider:before {
  content: '';
  position: absolute;
  height: 11px;
  width: 11px;
  left: 2px;
  bottom: 2px;
  background: #ffffff;
  transition: transform 0.25s;
}
input:checked + .slider             { background: #00d97e; }
input:checked + .slider:before      { transform: translateX(13px); }
.slider.round                       { border-radius: 15px; }
.slider.round:before                { border-radius: 50%; }
.switch:focus-within .slider {
  outline: 2px solid var(--theme);
  outline-offset: 2px;
}

/* ── Footer divider │ ───────────────────────────────────── */
.footer-div {
  color: var(--text-muted);
  font-size: 11px;
}
.footer-override-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-right: 5px;
}

/* Level buttons - neutral, never follows market theme */
.level-tag {
  padding: 1px 7px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: rgba(255, 255, 255, 0.55);
  background: transparent;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.03em;
  line-height: 1.6;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  vertical-align: baseline;
}
.level-tag:hover:not(.active) {
  border-color: rgba(255, 255, 255, 0.6);
  color: rgba(255, 255, 255, 0.8);
}
.level-tag.active {
  border-color: rgba(255, 255, 255, 0.55);
  color: var(--text);
  background: rgba(255, 255, 255, 0.09);
}
.level-tag:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

/* Market status line (change %) */
.market-status {
  font-size: 13px;
  font-weight: 400;
  color: var(--theme);
  min-height: 20px;
  margin-bottom: 20px;
  transition: color 0.5s;
}

/* ── Play button ─────────────────────────────────────────── */

#start-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--play-color);
  color: var(--play-color);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.1em;
  padding: 12px 40px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s, border-color 0.3s;
  -webkit-tap-highlight-color: transparent;
  border-radius: 2px;
}
#start-btn:hover,
#start-btn:focus-visible {
  background: var(--play-glow);
  box-shadow: 0 0 20px var(--play-glow);
  outline: none;
}
#start-btn:active {
  background: var(--play-color);
  color: #000;
}

/* ── HUD ─────────────────────────────────────────────────── */

#hud {
  position: absolute;
  top: 14px;
  right: 18px;
  display: none;
  flex-direction: row;
  align-items: flex-start;
  gap: 22px;
  z-index: 5;
}
#hud.visible { display: flex; }

#score-wrap, #best-wrap, #checkpoint-wrap { text-align: right; }

/* Checkpoint wrap hidden by default - shown via JS when flag is collected */
#checkpoint-wrap { display: none; }

.hud-label {
  display: block;
  font-size: 9px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  margin-bottom: 1px;
}

#score {
  font-size: 22px;
  font-weight: 600;
  color: var(--theme);
  letter-spacing: 0.04em;
  transition: color 0.5s;
}
#best {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}
#checkpoint-icon {
  font-size: 18px;
  line-height: 1.2;
  display: block;
}

/* ── Footer ──────────────────────────────────────────────── */

#footer {
  flex-shrink: 0;
  min-height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  background: var(--bg);
  border-top: 1px solid var(--border);   /* global - matches game-explained footer */
}

#footer p {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);   /* #767676 - WCAG AA ✓ */
  letter-spacing: 0.02em;
  text-align: center;
  line-height: 1.7;
}

#footer a {
  font-size: 11px;             /* explicit - same as surrounding text */
  font-weight: 400;
  color: var(--text);          /* white - 21:1 ✓ */
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(255, 255, 255, 0.35);
  transition: text-decoration-color 0.2s;
}
#footer a:hover {
  text-decoration-color: var(--theme);
  color: var(--text);
}
#footer a:focus-visible {
  outline: 2px solid var(--theme);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Mobile footer: <br> hidden on desktop, shown on mobile */
.footer-br { display: none; }

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 480px) {
  #header        { padding: 0 14px; }
  .overlay-inner { padding: 28px 18px; }
  .overlay-inner h1 { font-size: 18px; }
  .exchange-row  { gap: 5px; }

  /* HUD: stack Score / Best / Checkpoint vertically, avoid overlap */
  #hud {
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    top: 10px;
    right: 12px;
  }
  #score { font-size: 18px; }
  #best  { font-size: 14px; }

  /* Footer: break before name on mobile */
  .footer-br { display: inline; }
}
