:root {
  --panel: rgba(15, 23, 42, 0.103);
  --panel-border: rgba(255, 255, 255, 0.10);
  --text: #eef2ff;
  --muted: rgba(238, 242, 255, 0.78);

  --grid-gap: clamp(10px, 0.8vw, 16px);
  --delay-step: 120ms;

  /* Master for layout */
  --card-min-width: 350px;
  --card-height: 72vh;
  --podium-height: 15vh;

  /* Master for budsjettlinje */
  --target-coins: 9;
  --stack-target-line: rgba(255, 255, 255, 0.95);

  /* Hvor stor gullstabelen skal være relativt til card-min-width */
  --stack-scale-from-card: 0.34;

  /* Fast bunnstripe */
  --totalsales-height: 8vh;
}

/* Reset */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

/* Side */
body.cash-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  font-family: Inter, system-ui, sans-serif;
  color: var(--text);

  background-image: url('lybg.jpg');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  background-attachment: fixed;
}

.cash-page::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(2, 6, 23, 0.24),
    rgba(2, 6, 23, 0.12) 30%,
    rgba(2, 6, 23, 0.28) 100%
  );
  pointer-events: none;
  z-index: -1;
}

/* Full bredde */
.site-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding-inline: clamp(16px, 1.2vw, 28px);
}

.site-header {
  flex: 0 0 auto;
  padding: 12px 0 25px;
}

.site-header .site-shell {
  display: flex;
  justify-content: center;   /* 🔥 dette er nøkkelen */
  align-items: center;
  gap: 20px;
  text-align: left;
}

/* Logo */
.site-header p:first-child {
  margin: 0;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

.site-header p:first-child img {
  display: block;
  height: clamp(40px, 3.5vw, 70px);
  width: auto;
}

/* Tekst */
.site-header h1 {
  margin: 0;
  font-size: 30pt;
  line-height: 1;
}

.site-header p:last-child {
  margin: 0;
  font-size: 14pt;
  color: var(--muted);
}

.site-main {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  min-height: 0;
  padding: 6px 0 12px;
  overflow: hidden;
}

.site-footer {
  flex: 0 0 auto;
  padding: 0 0 calc(var(--totalsales-height) + 10px);
}

.site-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

/* Horisontal scene */
.money-grid-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
}

.money-grid-scroll::-webkit-scrollbar {
  height: 10px;
}

.money-grid-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.money-grid-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.money-grid {
  width: max(
    100%,
    calc(var(--cols) * var(--card-min-width) + (var(--cols) - 1) * var(--grid-gap))
  );
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(var(--card-min-width), 1fr));
  gap: var(--grid-gap);
  align-items: end;
}

/* Kort */
.cash-card {
  height: var(--card-height);
  min-height: 380px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;

  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 0;
  padding: 6px;
  overflow: hidden;
  backdrop-filter: blur(4px);
}

.cash-stage {
  position: relative;
  height: 100%;
  min-height: 0;
  padding-bottom: calc(var(--podium-height) + 8px);

  /*
    Kritisk:
    All delt geometri må ligge her, siden .budget-plane og .money-column
    er søsken i markupen.
  */

  /* Myntbredde skaleres direkte fra card-min-width */
  --stack-width: clamp(
    38px,
    calc(var(--card-min-width) * var(--stack-scale-from-card)),
    96px
  );

  /* Gullmynt: SVG viewBox 220 x 96 */
  --gold-coin-width: var(--stack-width);
  --gold-coin-height: calc(var(--gold-coin-width) * 96 / 220);

  /*
    Hvor mye én gullmynt bygger oppover i stabelen.
    Høy nok til at den ser stablet ut, lav nok til at myntene overlapper.
  */
  --gold-stack-step: calc(var(--gold-coin-height) * 0.36);

  /*
    Budsjettlinjen skal ligge ved toppen av mynt nr. 10:
    9 steg + hel myntehøyde
  */
  --budget-line-height: calc(
    ((var(--target-coins) - 1) * var(--gold-stack-step)) + var(--gold-coin-height)
  );

  /* Sølvmynt: SVG viewBox 220 x 88 */
  --silver-coin-width: calc(var(--gold-coin-width) * 0.86);
  --silver-coin-height: calc(var(--silver-coin-width) * 88 / 220);
  --silver-stack-step: calc(var(--silver-coin-height) * 0.36);

  /*
    Stackene må være høye nok til hele toppmynten.
    Ellers ser budsjettlinjen feil ut fordi myntene klippes.
  */
  --gold-stack-height: calc(200 * var(--gold-stack-step) + var(--gold-coin-height));
  --silver-stack-height: calc(200 * var(--silver-stack-step) + var(--silver-coin-height));
}

/* Budsjettflate */
.budget-plane {
  position: absolute;
  left: 50%;
  bottom: calc(var(--podium-height) + 6px);
  transform: translateX(-50%);
  width: 82%;
  height: var(--budget-line-height);

  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.05),
    rgba(255, 255, 255, 0.02)
  );
  border-radius: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.10);
  border-right: 1px solid rgba(255, 255, 255, 0.10);
  border-top: 1px solid rgba(255, 255, 255, 0.10);

  z-index: 1;
  pointer-events: none;
}

.budget-plane::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      to top,
      rgba(255, 255, 255, 0.1) 0,
      rgba(255, 255, 255, 0.1) 1px,
      transparent 1px,
      transparent calc(var(--budget-line-height) / 10)
    );
  pointer-events: none;
}

.budget-plane::after {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  top: -2px;
  height: 3px;
  background: var(--stack-target-line);
  box-shadow:
    0 0 8px rgba(255, 255, 255, 0.35),
    0 0 16px rgba(255, 255, 255, 0.16);
  pointer-events: none;
}

/* Myntscene */
.money-column {
  position: absolute;
  left: 50%;
  bottom: calc(var(--podium-height) + 6px);
  transform: translateX(-50%);
  width: 100%;

  display: flex;
  justify-content: center;
  align-items: end;
  gap: clamp(8px, 0.45vw, 14px);

  z-index: 3;
}

.money-stack-group {
  display: flex;
  justify-content: center;
  flex: 1 1 0;
  min-width: 0;
}

/* Stabler */
.coin-stack,
.silvercoin-stack {
  position: relative;
  overflow: visible;  
}

.coin-stack {
  --coin-width: var(--gold-coin-width);
  --coin-height: var(--gold-coin-height);
  --stack-step: var(--gold-stack-step);
  width: var(--coin-width);
  height: var(--gold-stack-height);
}

.silvercoin-stack {
  --coin-width: var(--silver-coin-width);
  --coin-height: var(--silver-coin-height);
  --stack-step: var(--silver-stack-step);
  width: var(--coin-width);
  height: var(--silver-stack-height);
  margin-bottom: -0.7vh;
}

.coin,
.silvercoin {
  position: absolute;
  left: 50%;
  bottom: calc(var(--i) * var(--stack-step));
  transform: translateX(-50%);
  opacity: 0;
  will-change: transform, opacity;
  
}

.coin {
  width: var(--coin-width);
  animation: coin-drop 0.8s ease-out forwards;
  animation-delay: calc(var(--i) * var(--delay-step));
}

.silvercoin {
  width: var(--coin-width);
  animation: coin-drop 0.7s ease-out forwards;
  animation-delay: calc(var(--i) * var(--delay-step));
  
}

.coin-svg,
.silvercoin-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Podie */
.podium {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 88%;
  height: var(--podium-height);

  background: #000030;
  border-radius: 0px;
  padding: 2vh;

  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;

  text-align: left;
  z-index: 4;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18);
}

.podium-name {
  font-weight: 700;
  font-size: clamp(15pt, 2vw, 20px);
  line-height: 1.5;
  height: 10vh;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.podium-metrics {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.podium-line {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: clamp(12pt, 2vw, 15px);
  line-height: 1.15;
  color: rgba(255, 255, 255, 0.92);
}

.podium-label {
  opacity: 0.9;
  text-align: left;
  min-width: 0;
  flex: 1 1 auto;
}

.podium-value {
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  flex: 0 0 auto;
}

/* Total sales */
.totalsales {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;

  color: white;
  background-color: rgba(0, 0, 0, 0.92);
  display: block;
  width: 100%;
  min-height: var(--totalsales-height);
  font-size: clamp(18pt, 2vw, 45px);
  text-align: center;
  padding: 2vh 1rem;
}




@keyframes coin-drop {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-50vh);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Lavere flater */
@media (max-height: 820px) {
  :root {
    --card-height: clamp(340px, 68vh, 640px);
    --podium-height: 150px;
  }
}

@media (max-height: 680px) {
  :root {
    --card-height: 320px;
    --podium-height: 150px;
    --card-min-width: 168px;
    --totalsales-height: 72px;
  }

  .site-header {
    padding: 8px 0 6px;
  }

  .site-header h1 img {
    max-height: 42px;
  }

  .site-header p,
  .site-footer p {
    font-size: 0.74rem;
  }
}


