/* Reihe 47 - eigene Spielhaut auf den Hub-Tokens aus hub.css. */

html, body {
  height: 100%;
  margin: 0;
  background: var(--hub-bg);
  color: var(--hub-text);
  font-family: var(--hub-font);
  overscroll-behavior: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* --- HUD ---------------------------------------------------------------- */

#hud {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(340px, 62vw);
  pointer-events: none;
  z-index: 20;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 11px;
  border: 1px solid var(--hub-line);
  border-radius: var(--hub-radius-sm);
  background: color-mix(in srgb, var(--hub-bg) 72%, transparent);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  line-height: 1.15;
}

.chip small {
  font-size: 10px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--hub-faint);
}

.chip b {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

#signalBox {
  padding: 10px 12px;
  border: 1px solid var(--hub-line);
  border-radius: var(--hub-radius-sm);
  background: color-mix(in srgb, var(--hub-bg) 72%, transparent);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
}

.signal-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--hub-faint);
}

.signal-head b {
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--hub-text);
  font-variant-numeric: tabular-nums;
}

/* Vier Segmente statt Prozentbalken: bewusst grob. */
.signal-steps {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.signal-steps i {
  flex: 1;
  height: 9px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--hub-text) 13%, transparent);
  transition: background-color 200ms ease;
}

.signal-steps i.on { background: var(--hub-accent); }
#signalBox[data-step='3'] .signal-steps i.on { background: var(--hub-ok); }
#signalBox[data-step='4'] .signal-steps i.on { background: var(--hub-warn); }

#signalBox[data-state='fresh'] { animation: signalPulse 420ms ease; }

@keyframes signalPulse {
  0% { border-color: var(--hub-accent); transform: scale(1.015); }
  100% { border-color: var(--hub-line); transform: scale(1); }
}

.signal-hint {
  margin: 8px 0 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.signal-hint .trend {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .03em;
}

.signal-hint .trend[data-t='warmer'] {
  background: color-mix(in srgb, var(--hub-warn) 26%, transparent);
  color: var(--hub-warn);
}

.signal-hint .trend[data-t='colder'] {
  background: color-mix(in srgb, var(--hub-accent) 24%, transparent);
  color: var(--hub-accent);
}

.signal-hint .trend[data-t='same'] {
  background: color-mix(in srgb, var(--hub-text) 12%, transparent);
  color: var(--hub-muted);
}

/* Kondition: nur sichtbar, wenn sie nicht voll ist. */
#stamina {
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--hub-text) 14%, transparent);
  overflow: hidden;
}

#stamina i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--hub-ok);
  transition: width 90ms linear, background-color 200ms ease;
}

#stamina[data-winded='1'] i { background: var(--hub-danger); }

/* Fund-Moment */
#findBanner {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  /* oberes Drittel: der Blick soll auf dem Auto bleiben, nicht auf der Schrift */
  align-content: start;
  justify-items: center;
  padding-top: 16vh;
  pointer-events: none;
}

#findBanner[hidden] { display: none; }

#findBanner span {
  font-size: clamp(38px, 11vw, 104px);
  font-weight: 900;
  letter-spacing: -.03em;
  color: var(--hub-warn);
  text-shadow: 0 6px 34px rgba(0, 0, 0, .55), 0 2px 0 rgba(0, 0, 0, .3);
  animation: findPop 620ms cubic-bezier(.16, 1.4, .3, 1);
}

@keyframes findPop {
  0% { transform: scale(.4) rotate(-5deg); opacity: 0; }
  60% { transform: scale(1.12) rotate(1.5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.hints {
  margin: 8px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--hub-muted);
}

/* --- Karte -------------------------------------------------------------- */

#mapBox {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  top: 84px;
  padding: 8px;
  border: 1px solid var(--hub-line);
  border-radius: var(--hub-radius-sm);
  background: color-mix(in srgb, var(--hub-bg) 76%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 20;
}

#minimap {
  display: block;
  width: 150px;
  height: 150px;
  border-radius: 10px;
}

.map-caption {
  margin: 6px 2px 0;
  font-size: 11px;
  color: var(--hub-faint);
  text-align: center;
}

/* --- Meldungen ---------------------------------------------------------- */

#toast {
  position: fixed;
  left: 50%;
  top: 96px;
  transform: translateX(-50%);
  padding: 0;
  max-width: min(440px, 84vw);
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--hub-text);
  z-index: 30;
  pointer-events: none;
}

#toast:not(:empty) {
  padding: 9px 16px;
  border: 1px solid var(--hub-line-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--hub-bg) 84%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

#toast[data-kind='good'] { color: var(--hub-ok); }
#toast[data-kind='find'] { color: var(--hub-warn); }

/* --- Bedienleiste ------------------------------------------------------- */

#controls {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  align-items: flex-end;
  z-index: 25;
}

.ctl {
  position: relative;
  min-height: 52px;
  min-width: 52px;
  padding: 10px 18px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--hub-line-strong);
  border-radius: 16px;
  background: color-mix(in srgb, var(--hub-bg) 78%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--hub-text);
  font: inherit;
  font-weight: 650;
  font-size: 15px;
  cursor: pointer;
  overflow: hidden;
  touch-action: manipulation;
  transition: transform 120ms ease, background-color 150ms ease;
}

.ctl kbd {
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--hub-faint);
}

.ctl.primary {
  background: var(--hub-accent-fill);
  border-color: transparent;
  color: var(--hub-on-accent);
  min-width: 128px;
}

.ctl.primary kbd { color: color-mix(in srgb, var(--hub-on-accent) 76%, transparent); }
.ctl:active { transform: translateY(1px) scale(.98); }
.ctl:disabled { opacity: .55; cursor: default; }
.ctl:focus-visible { outline: 3px solid var(--hub-focus); outline-offset: 2px; }

/* Schluessel im Knopf: zuckt beim Druecken sichtbar. */
#keyIcon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  transform-origin: 50% 30%;
}

#keyIcon .key-btn { fill: currentColor; stroke: none; }

.ctl.primary[data-press='1'] #keyIcon { animation: keyPress 260ms ease; }

@keyframes keyPress {
  0% { transform: scale(1) rotate(0); }
  35% { transform: scale(.84) rotate(-9deg); }
  100% { transform: scale(1) rotate(0); }
}

#scanCooldown {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 0%;
  background: color-mix(in srgb, var(--hub-on-accent) 80%, transparent);
}

/* Touch-Stick: nur auf Zeigegeraeten ohne Maus sichtbar. */
#stick {
  position: fixed;
  left: 6vw;
  bottom: 12vh;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  border: 1px solid var(--hub-line-strong);
  background: color-mix(in srgb, var(--hub-bg) 55%, transparent);
  display: none;
  z-index: 24;
}

#stick i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--hub-text) 34%, transparent);
}

body[data-touch='1'] #stick { display: block; }

/* --- Overlays ----------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: color-mix(in srgb, var(--hub-bg) 76%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  overflow-y: auto;
}

.overlay[hidden] { display: none; }

.panel {
  width: min(460px, 100%);
  padding: 24px;
  border: 1px solid var(--hub-line);
  border-radius: var(--hub-radius);
  background: var(--hub-surface);
  box-shadow: var(--hub-shadow);
}

.panel.wide { width: min(620px, 100%); }

.panel h1, .panel h2 {
  margin: 0 0 6px;
  font-size: clamp(22px, 4vw, 30px);
  letter-spacing: -.02em;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.wallet { color: var(--hub-muted); font-size: 14px; }
.wallet b { color: var(--hub-text); font-variant-numeric: tabular-nums; }

.lead {
  margin: 0 0 14px;
  color: var(--hub-muted);
  line-height: 1.55;
}

.rules {
  margin: 0 0 18px;
  padding-left: 18px;
  color: var(--hub-muted);
  line-height: 1.75;
  font-size: 14.5px;
}

.rules b { color: var(--hub-text); }

.result {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 14px;
  margin: 0 0 18px;
  font-size: 15px;
}

.result dt { color: var(--hub-muted); }
.result dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.actions button {
  min-height: 46px;
  padding: 0 20px;
  border-radius: 14px;
  border: 1px solid var(--hub-line-strong);
  background: transparent;
  color: var(--hub-text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
}

.actions button.primary {
  background: var(--hub-accent-fill);
  border-color: transparent;
  color: var(--hub-on-accent);
}

.actions button:focus-visible { outline: 3px solid var(--hub-focus); outline-offset: 2px; }
.actions button:active { transform: translateY(1px); }

.fineprint {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--hub-faint);
}

/* --- Werkstatt ---------------------------------------------------------- */

.shop {
  list-style: none;
  margin: 16px 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: min(52vh, 420px);
  overflow-y: auto;
}

.shop li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 14px;
  align-items: center;
  padding: 11px 13px;
  border: 1px solid var(--hub-line);
  border-radius: 14px;
  background: var(--hub-surface-raised);
}

.shop .name { font-weight: 650; }
.shop .lvl {
  margin-left: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--hub-faint);
}
.shop .desc {
  grid-column: 1;
  font-size: 13px;
  color: var(--hub-muted);
  line-height: 1.4;
}
.shop .now { color: var(--hub-text); }

.shop button {
  grid-row: 1 / span 2;
  grid-column: 2;
  min-height: 46px;
  min-width: 104px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--hub-accent-fill);
  color: var(--hub-on-accent);
  font: inherit;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  touch-action: manipulation;
}

.shop button:disabled {
  background: transparent;
  border-color: var(--hub-line-strong);
  color: var(--hub-faint);
  cursor: default;
}

.shop button:focus-visible { outline: 3px solid var(--hub-focus); outline-offset: 2px; }

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  text-align: center;
}

@media (max-width: 720px) {
  #hud { top: 76px; max-width: 58vw; }
  #mapBox { top: 76px; }
  #minimap { width: 108px; height: 108px; }
  #controls { bottom: max(16px, env(safe-area-inset-bottom)); }
  .ctl.primary { min-width: 104px; }
}

/* Testmodus (nur mit ?debug) */
#debugBox {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 40;
  padding: 8px 11px;
  border: 1px solid var(--hub-warn);
  border-radius: 10px;
  background: color-mix(in srgb, var(--hub-bg) 86%, transparent);
  color: var(--hub-muted);
  font-size: 11.5px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  max-width: min(520px, 90vw);
}

#debugBox b { color: var(--hub-warn); }
#debugStats { margin-top: 4px; color: var(--hub-text); }

/* Dauervorteile beim Feierabend */
.perks {
  list-style: none;
  margin: 16px 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.perks button {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 14px;
  padding: 13px 15px;
  border: 1px solid var(--hub-line);
  border-radius: 14px;
  background: var(--hub-surface-raised);
  color: var(--hub-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.perks button:hover { border-color: var(--hub-accent); }
.perks button:focus-visible { outline: 3px solid var(--hub-focus); outline-offset: 2px; }
.perks .perk-name { font-weight: 650; }
.perks .perk-step { font-size: 12px; color: var(--hub-faint); }
.perks .perk-text { grid-column: 1 / -1; font-size: 13px; color: var(--hub-muted); line-height: 1.4; }

/* Gesperrte Upgrades bleiben sichtbar, damit man ein Ziel hat. */
.shop li.locked { opacity: .55; }
.shop li.locked .lock {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--hub-faint);
  text-align: right;
  min-width: 104px;
}

/* Praemienaufschluesselung */
.payout {
  list-style: none;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--hub-line);
  border-radius: 14px;
  background: var(--hub-surface-raised);
}

.payout li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  font-size: 14px;
  color: var(--hub-muted);
}

.payout li b { color: var(--hub-text); font-variant-numeric: tabular-nums; }
.payout li.total {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--hub-line);
  font-weight: 700;
  color: var(--hub-text);
  font-size: 15px;
}

/* Werkstatt-Kategorien */
.shop-group {
  margin: 14px 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--hub-faint);
}

.shop-group:first-child { margin-top: 0; }

.shop li.affordable { border-color: color-mix(in srgb, var(--hub-accent) 45%, transparent); }

@media (prefers-reduced-motion: reduce) {
  .signal-steps i,
  #stamina i,
  .ctl { transition: none; }

  #signalBox[data-state='fresh'],
  #findBanner span,
  .ctl.primary[data-press='1'] #keyIcon { animation: none; }
}
