/* =========================================================================
   SAG #0611 (v4) — GLASS · NAVY & MAROON · SKATER BACKGROUND
   System fonts · transform/opacity motion · iPhone-first
   ========================================================================= */

:root {
  --navy: #14213d;
  --navy-deep: #0b1326;
  --maroon: #7a2336;
  --maroon-deep: #5a1827;
  --maroon-light: #f0b4c0;      /* lys maroon-nuance til tekst på mørkt glas */

  --ink: #f5f7fc;
  --ink-muted: rgba(228, 234, 246, 0.76);

  --glass: rgba(255, 255, 255, 0.10);
  --glass-strong: rgba(255, 255, 255, 0.16);
  --glass-line: rgba(255, 255, 255, 0.24);
  --glass-hi: rgba(255, 255, 255, 0.55);

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.22, 1.08, 0.36, 1);

  --blur: blur(22px) saturate(160%);
  --glass-shadow:
    inset 1px 1px 0 var(--glass-hi),
    inset 0 0 14px rgba(255, 255, 255, 0.07),
    0 10px 28px rgba(3, 8, 20, 0.32);
}

/* ------------------------- Reset & base ------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  background: var(--navy-deep);
}

body {
  min-height: 100dvh;
  background: var(--navy-deep);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.5;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

button, input {
  font-family: inherit;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
  background: none;
  border: none;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 2px;
}

/* ------------------------- Baggrund + skøjteløber ------------------------- */
.ice-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(60% 42% at 10% 6%, rgba(122, 35, 54, 0.60), transparent 70%),
    radial-gradient(70% 52% at 96% 28%, rgba(44, 78, 150, 0.55), transparent 72%),
    radial-gradient(80% 55% at 25% 102%, rgba(122, 35, 54, 0.38), transparent 70%),
    linear-gradient(180deg, #0f1b36 0%, #0b1326 100%);
}

#rink {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* ------------------------- Shell & progress ------------------------- */
.shell {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    max(16px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0 22px;
}
.topbar[hidden] { display: none; }

.progress-segments {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  max-width: 168px;
}

.seg {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}

.seg-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 400ms var(--ease), background-color 300ms var(--ease);
}
.seg.is-current .seg-fill { background: var(--maroon-light); transform: scaleX(1); }
.seg.is-complete .seg-fill { background: rgba(255, 255, 255, 0.92); transform: scaleX(1); }

.progress-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ------------------------- Skærme & typografi ------------------------- */
.stage-host { flex: 1; display: flex; flex-direction: column; position: relative; }

.screen, .screen-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
}

.screen-body { display: flex; flex-direction: column; gap: 24px; }

.intro-body { margin-top: auto; margin-bottom: auto; padding: 24px 0; }

.screen-header { display: flex; flex-direction: column; gap: 10px; }

.eyebrow {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--maroon-light);
  font-variant-numeric: tabular-nums;
}

.eyebrow-on-navy {
  align-self: flex-start;
  padding: 5px 12px;
  border-radius: 999px;
  background-color: rgba(122, 35, 54, 0.45);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.35);
}

.title {
  font-size: 34px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-shadow: 0 2px 18px rgba(3, 8, 20, 0.35);
}
.title-on-navy { color: var(--ink); }

.subtitle {
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink-muted);
}
.subtitle-on-navy { color: var(--ink); opacity: 0.88; }

.body-copy { font-size: 17px; line-height: 1.5; color: var(--ink); }

/* ------------------------- Glas-overflader ------------------------- */
.suspect-card,
.score-slots-card,
.jump-pill,
.cipher-card,
.solved-card,
.hint-card,
.ev-tile,
.vault-slot,
.finale-copy,
.text-input,
.stepper-btn,
.keypad-key,
.btn-secondary {
  background-color: var(--glass);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 48%);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-line);
  box-shadow: var(--glass-shadow);
  color: var(--ink);
}

/* ------------------------- Knapper ------------------------- */
.action-dock {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.secondary-actions { display: flex; flex-direction: column; gap: 8px; }
.secondary-actions:empty { display: none; }

.btn {
  width: 100%;
  min-height: 56px;
  padding: 0 20px;
  border-radius: 18px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: transform 200ms var(--ease-spring), background-color 200ms var(--ease), opacity 200ms var(--ease);
}

.btn-primary {
  background-color: var(--maroon);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0) 55%);
  border: 1px solid rgba(255, 255, 255, 0.30);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 12px 28px rgba(122, 35, 54, 0.45);
  color: #fff;
}
.btn-primary:active:not(:disabled) { transform: scale(0.97); background-color: var(--maroon-deep); }

.btn-secondary { min-height: 48px; }
.btn-secondary:active:not(:disabled) { transform: scale(0.97); background-color: var(--glass-strong); }

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-text {
  align-self: center;
  min-height: 48px;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--maroon-light);
  cursor: pointer;
  border-radius: 12px;
  transition: transform 200ms var(--ease-spring);
}
.btn-text[hidden] { display: none; }
.btn-text:active { transform: scale(0.97); }

/* ------------------------- Bevis 1: mistænkte ------------------------- */
.suspect-list { display: flex; flex-direction: column; gap: 10px; }

.suspect-card {
  width: 100%;
  min-height: 76px;
  border-radius: 20px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  text-align: left;
  cursor: pointer;
  transition: transform 200ms var(--ease-spring), background-color 200ms var(--ease), border-color 200ms var(--ease);
}
.suspect-card:active { transform: scale(0.98); }

.suspect-card.is-selected {
  background-color: rgba(122, 35, 54, 0.55);
  border-color: rgba(255, 255, 255, 0.55);
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid var(--glass-line);
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.suspect-content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.suspect-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.suspect-name { font-size: 17px; font-weight: 600; color: var(--ink); }
.suspect-meta { display: inline-flex; align-items: center; gap: 8px; }
.suspect-badge { font-size: 13px; font-weight: 500; color: var(--ink-muted); font-variant-numeric: tabular-nums; }

.suspect-check { width: 20px; height: 20px; color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.check-svg { width: 18px; height: 18px; }
.check-path { stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset 260ms var(--ease); }
.suspect-card.is-selected .check-path { stroke-dashoffset: 0; }

.suspect-statement { font-size: 15px; line-height: 1.45; color: var(--ink-muted); }

/* ------------------------- Bevis 2: scoreark ------------------------- */
.score-slots-card {
  border-radius: 20px;
  padding: 6px 16px;
  display: flex;
  flex-direction: column;
}

.score-slot {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  padding: 6px 2px;
  text-align: left;
  font-size: 17px;
  color: var(--ink);
  transition: transform 200ms var(--ease-spring);
}
.score-slot:last-child { border-bottom: none; }

.slot-num { width: 22px; font-size: 14px; font-weight: 600; color: var(--maroon-light); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.slot-Rule { flex: 1; height: 1px; border-bottom: 1.5px dotted rgba(255, 255, 255, 0.25); }
.score-slot.is-filled { cursor: pointer; font-weight: 600; }
.score-slot.is-filled:active { transform: scale(0.98); }
.slot-name { flex: 1; }

.jump-pool { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.jump-pill {
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 200ms var(--ease-spring), opacity 200ms var(--ease), background-color 200ms var(--ease);
}
.jump-pill:active:not(:disabled) { transform: scale(0.98); background-color: var(--glass-strong); }
.jump-pill.is-placed { opacity: 0.38; cursor: default; box-shadow: none; }

/* ------------------------- Bevis 3 + 4: input og kode ------------------------- */
.field-group { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 14px; font-weight: 600; color: var(--ink); }

.text-input {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  border-radius: 16px;
  font-size: 18px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  transition: border-color 200ms var(--ease), background-color 200ms var(--ease);
}
.text-input::placeholder { color: rgba(228, 234, 246, 0.55); font-weight: 400; }
.text-input:focus { outline: 2px solid rgba(255, 255, 255, 0.9); outline-offset: 2px; background-color: var(--glass-strong); }

.cipher-stack { display: flex; flex-direction: column; gap: 14px; }

.cipher-card {
  border-radius: 20px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.cipher-card-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-muted); }
.cipher-text { font-size: 20px; font-weight: 600; letter-spacing: 0.12em; font-variant-numeric: tabular-nums; word-break: break-word; }
.cipher-text.is-coded { color: var(--ink); }
.cipher-text.is-decoded { color: var(--maroon-light); transition: opacity 120ms var(--ease); }
.cipher-text.is-decoded.is-fading { opacity: 0.25; }

.stepper-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 2px 4px; }

.stepper-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 24px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 200ms var(--ease-spring), background-color 200ms var(--ease), opacity 200ms var(--ease);
}
.stepper-btn:active:not(:disabled) { transform: scale(0.95); background-color: var(--glass-strong); }
.stepper-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.stepper-readout { font-size: 16px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; text-align: center; }

/* ------------------------- Løst-skærm, hints, fejl ------------------------- */
.solved-card {
  border-radius: 24px;
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}
.solved-digit-label { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-muted); }
.solved-digit { font-size: 64px; line-height: 1.1; font-weight: 600; color: var(--maroon-light); font-variant-numeric: tabular-nums; animation: digitReveal 320ms var(--ease-spring) both; }
.solved-count { font-size: 14px; font-weight: 500; color: var(--ink-muted); font-variant-numeric: tabular-nums; }

.error-msg { font-size: 15px; line-height: 1.45; color: var(--ink); text-align: center; animation: fadeIn 200ms var(--ease) both; }

.hints-list { display: flex; flex-direction: column; gap: 10px; }
.hint-card { border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.hint-card.hint-enter { animation: hintSlideFade 240ms var(--ease) both; }
.hint-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--maroon-light); font-variant-numeric: tabular-nums; }
.hint-text { font-size: 15px; line-height: 1.45; color: var(--ink-muted); }

/* ------------------------- Pengeskab + finale ------------------------- */
.ev-tiles-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ev-tile { border-radius: 18px; padding: 10px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ev-tile-label { font-size: 12px; font-weight: 500; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.ev-tile-digit { font-size: 22px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

.vault-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.vault-slot {
  height: 72px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  line-height: 1;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: border-color 200ms var(--ease), background-color 200ms var(--ease);
}
.vault-slot.is-active { border: 2px solid rgba(255, 255, 255, 0.8); }
.vault-slot.is-filled { background-color: rgba(122, 35, 54, 0.55); border-color: rgba(255, 255, 255, 0.55); }
.vault-slot.slot-pulse { animation: slotPulse 200ms var(--ease-spring); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.keypad-key {
  height: 64px;
  border-radius: 20px;
  background-color: rgba(20, 33, 61, 0.55);
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: transform 200ms var(--ease-spring), background-color 200ms var(--ease);
}
.keypad-key:active { transform: scale(0.96); background-color: var(--glass-strong); }
.keypad-key.is-aux { background-color: var(--glass); font-size: 16px; }
.keypad-key.is-ok {
  background-color: var(--maroon);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0) 55%);
  font-size: 17px;
  color: #fff;
}
.keypad-key.is-ok:active { background-color: var(--maroon-deep); }

.finale-body { margin-top: auto; margin-bottom: auto; padding: 24px 0; }
.solved-badge-wrap { display: flex; align-items: center; }

.solved-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border-radius: 999px;
  background-color: var(--maroon);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0) 55%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 10px 24px rgba(122, 35, 54, 0.5);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  animation: badgeSpring 420ms var(--ease-spring) both;
}

.finale-copy { border-radius: 24px; padding: 22px; }
.culprit-name { color: var(--maroon-light); font-weight: 700; }

/* ------------------------- Bevægelse (kun transform + opacity) ------------------------- */
.screen-exit {
  opacity: 0;
  transform: translateX(-16px);
  transition: opacity 220ms var(--ease), transform 220ms var(--ease);
  pointer-events: none;
}

/* Skærmen flytter sig kun (ingen opacity), så glassets blur virker under indgangen */
.screen-enter { animation: screenIn 320ms var(--ease) both; }
.screen-enter .stagger { animation: staggerFadeUp 300ms var(--ease) calc(var(--i, 0) * 40ms) both; }

/* Beholdere med glas-børn: animér børnene i stedet for beholderen */
.screen-enter :is(.suspect-list, .jump-pool, .cipher-stack, .ev-tiles-row, .vault-slots, .keypad, .field-group, .action-dock).stagger {
  animation: none;
}
.screen-enter :is(.suspect-list, .jump-pool, .cipher-stack, .ev-tiles-row, .vault-slots, .keypad, .field-group, .action-dock).stagger > * {
  animation: staggerFadeUp 300ms var(--ease) calc(var(--i, 0) * 40ms + var(--c, 0) * 35ms) both;
}
.screen-enter .stagger > :nth-child(2)  { --c: 1; }
.screen-enter .stagger > :nth-child(3)  { --c: 2; }
.screen-enter .stagger > :nth-child(4)  { --c: 3; }
.screen-enter .stagger > :nth-child(5)  { --c: 4; }
.screen-enter .stagger > :nth-child(6)  { --c: 5; }
.screen-enter .stagger > :nth-child(7)  { --c: 6; }
.screen-enter .stagger > :nth-child(8)  { --c: 7; }
.screen-enter .stagger > :nth-child(9)  { --c: 8; }
.screen-enter .stagger > :nth-child(10) { --c: 9; }
.screen-enter .stagger > :nth-child(11) { --c: 10; }
.screen-enter .stagger > :nth-child(12) { --c: 11; }

@keyframes screenIn {
  from { transform: translateX(16px); }
  to   { transform: translateX(0); }
}
@keyframes staggerFadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes digitReveal {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes badgeSpring {
  0%   { opacity: 0; transform: scale(0.6); }
  75%  { opacity: 1; transform: scale(1.035); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes slotPulse {
  0%   { transform: scale(0.92); }
  60%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}
@keyframes hintSlideFade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes shakeHorizontal {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.shake-target { animation: shakeHorizontal 300ms var(--ease); }
.shake-vault  { animation: shakeHorizontal 240ms var(--ease); }

/* ------------------------- Reduced motion ------------------------- */
@media (prefers-reduced-motion: reduce) {
  .screen-exit { transform: none !important; }
  .screen-enter { animation: none !important; }
  .screen-enter .stagger,
  .screen-enter .stagger > * { animation: fadeIn 220ms ease both !important; }
  .solved-digit, .solved-badge, .hint-card.hint-enter { animation: fadeIn 220ms ease both !important; }
  .vault-slot.slot-pulse, .shake-target, .shake-vault { animation: none !important; }
  .btn:active:not(:disabled), .btn-text:active, .suspect-card:active,
  .score-slot.is-filled:active, .jump-pill:active:not(:disabled),
  .stepper-btn:active:not(:disabled), .keypad-key:active { transform: none !important; }
}

/* Hvis browseren ikke kan lave glas: giv panelerne en mørkere fyldfarve */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .suspect-card, .score-slots-card, .jump-pill, .cipher-card, .solved-card, .hint-card,
  .ev-tile, .vault-slot, .finale-copy, .text-input, .stepper-btn, .keypad-key, .btn-secondary {
    background-color: rgba(20, 33, 61, 0.82);
  }
}
