/* ==========================================================================
   Bursdagskort til Leon — stil
   Fargene og fontene kan justeres her, men alt innhold styres i script.js.
   ========================================================================== */

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

:root {
  --bg: #17130e;
  --tre-mork: #4a3320;
  --tre-lys: #7a5533;
  --pergament: #f3e6c9;
  --pergament-mork: #e4d1a8;
  --blekk: #3a2a18;
  --gull: #e8b84b;
  /* --su settes av script.js = 1 % av scenens bredde (skala-enhet) */
  --su: 10px;
}

html, body { height: 100%; }

body {
  font-family: "Baloo 2", "Avenir Next", "Trebuchet MS", sans-serif;
  background: radial-gradient(ellipse at 50% 30%, #241c12 0%, var(--bg) 70%);
  color: var(--pergament);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* --- Tittel ------------------------------------------------------------- */

.topp {
  flex: 0 0 auto;
  text-align: center;
  padding: 10px 12px 6px;
}

.topp h1 {
  font-size: clamp(20px, 3.6vw, 34px);
  font-weight: 800;
  color: var(--gull);
  letter-spacing: 0.5px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* --- Scenen (bakgrunnsbildet + luker) ----------------------------------- */

.scene-ramme {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px 10px;
}

.scene {
  position: relative;
  aspect-ratio: 3 / 2;
  /* Bredden settes av script.js slik at hele bildet alltid er synlig */
  width: 100%;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
}

.scene .bakgrunn {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

/* --- Luker --------------------------------------------------------------- */

.luke {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%);
  width: calc(var(--su) * 11);
  min-width: 48px;
  aspect-ratio: 5 / 6;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  perspective: calc(var(--su) * 60);
  z-index: 5;
}

/* Åpningen bak lukebladet: gjennomsiktig grå så bakgrunnen fortsatt synes */
.luke-opning {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8%;
  border-radius: 6% / 5%;
  background: rgba(60, 58, 55, 0.38);
  border: 2px dashed rgba(243, 230, 201, 0.55);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.35);
}

/* Liten hjelpetekst i åpnede luker */
.luke.apen .luke-opning::after {
  content: "Klikk for å åpne igjen";
  font-size: calc(var(--su) * 1.05);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  color: rgba(243, 230, 201, 0.95);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

/* Selve lukebladet: gjennomsiktig gyllent "glass" så bakgrunnen synes */
.luke-blad {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6%;
  border-radius: 6% / 5%;
  background: rgba(122, 85, 51, 0.42);
  border: 2px dashed rgba(232, 184, 75, 0.75);
  box-shadow:
    inset 0 0 12px rgba(0, 0, 0, 0.3),
    0 3px 10px rgba(0, 0, 0, 0.35);
  transform-origin: left center;
  transition: transform 0.45s ease-out;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.luke-tekst {
  font-size: calc(var(--su) * 1.35);
  font-weight: 700;
  line-height: 1.15;
  color: var(--pergament);
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  word-break: break-word;
}

/* Puls/glød på uåpnede luker så man skjønner at de kan trykkes */
.luke:not(.apen) .luke-blad {
  animation: luke-puls 2.4s ease-in-out infinite;
}

@keyframes luke-puls {
  0%, 100% { box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.3), 0 3px 10px rgba(0, 0, 0, 0.35); }
  50% { box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.2), 0 0 18px 4px rgba(232, 184, 75, 0.5); }
}

/* Åpnet luke: bladet svinger opp rundt venstre hengsel og blir stående */
.luke.apen .luke-blad {
  animation: none;
  transform: rotateY(-107deg);
}

.luke.apen { cursor: pointer; }

/* --- Gavehaugen ---------------------------------------------------------- */

.haug {
  position: absolute;
  right: 0.5%;
  bottom: 1%;
  width: calc(var(--su) * 34);
  height: calc(var(--su) * 30);
  z-index: 4;
  pointer-events: none;
}

.haug-innhold { position: absolute; inset: 0; }

.haug-gjenstand {
  position: absolute;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
}

.haug-gjenstand img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 3px;
}

.haug-gjenstand.gavebilde img { border-radius: 0; }

.haug-gjenstand.gavebilde {
  border-radius: 8px;
  border: 2px solid rgba(243, 230, 201, 0.85);
  background: #fff;   /* hvit bakgrunn så gaver med gjennomsiktig bakgrunn synes godt */
  padding: 4%;
  overflow: hidden;   /* zoomede bilder holder seg innenfor rammen */
}

.haug-teller {
  position: absolute;
  z-index: 500;   /* alltid øverst i haugen */
  right: 2%;
  bottom: 2%;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(20, 14, 8, 0.78);
  border: 1px solid rgba(232, 184, 75, 0.6);
  color: var(--gull);
  font-size: calc(var(--su) * 1.5);
  font-weight: 700;
  white-space: nowrap;
}

/* --- Gavepanelet ---------------------------------------------------------- */

.overlegg[hidden] { display: none; }

.overlegg {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 7, 4, 0.55);
  animation: fade-inn 0.25s ease-out;
}

@keyframes fade-inn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.panel {
  width: min(78vw, 560px);
  max-height: min(86vh, 86svh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 18px;
  padding: 22px 24px 20px;
  background:
    linear-gradient(175deg, var(--pergament) 0%, var(--pergament-mork) 100%);
  border: 3px solid var(--tre-mork);
  box-shadow:
    inset 0 0 0 2px rgba(122, 85, 51, 0.35),
    0 18px 50px rgba(0, 0, 0, 0.6);
  color: var(--blekk);
  animation: panel-inn 0.3s ease-out;
}

@keyframes panel-inn {
  from { opacity: 0; transform: translateY(26px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

.panel-fra {
  font-size: clamp(19px, 2.6vw, 24px);
  font-weight: 800;
  color: var(--tre-mork);
  text-align: center;
  margin-bottom: 10px;
}

.panel-hilsen {
  font-size: clamp(14px, 1.9vw, 17px);
  font-weight: 500;
  line-height: 1.45;
  white-space: pre-line;
  margin-bottom: 14px;
}

.panel-gave {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

/* Klikkbart gavebilde i panelet */
.gave-knapp {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.15s ease-out;
}

.gave-knapp:not(:disabled):active { transform: scale(1.05); }
.gave-knapp:disabled { cursor: default; }

/* Den hvite rammen rundt gavebildet i panelet */
.gave-kort {
  display: block;
  width: min(60vw, 240px);
  border-radius: 12px;
  border: 3px solid var(--tre-lys);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  background: #fff;   /* hvit bakgrunn så gaver med gjennomsiktig bakgrunn synes godt */
  padding: 10px;
  overflow: hidden;   /* zoomede bilder holder seg innenfor rammen */
}

.gave-kort img {
  display: block;
  width: 100%;
  height: auto;
}

.panel-hint {
  text-align: center;
  font-size: clamp(13px, 1.7vw, 15px);
  font-style: italic;
  color: rgba(58, 42, 24, 0.75);
  margin-bottom: 10px;
}

/* Seddelbunken i panelet */
.seddel-bunke {
  position: relative;
  width: min(78%, 320px);
  aspect-ratio: 2 / 1.35;
}

.seddel {
  position: absolute;
  left: 50%;
  top: 55%;
  width: 82%;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  transform: translate(-50%, -50%) rotate(var(--rot)) translateY(var(--lift));
  transition: transform 0.2s ease-out;
}

.seddel img {
  display: block;
  width: 100%;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.seddel:active { transform: translate(-50%, -55%) rotate(var(--rot)) translateY(var(--lift)) scale(1.04); }

.alle-sedler-tekst {
  font-weight: 700;
  color: var(--tre-mork);
  text-align: center;
  padding: 12px 0;
}

.panel-teller {
  text-align: center;
  font-weight: 700;
  color: var(--tre-mork);
  margin-bottom: 12px;
}

.takk-knapp {
  display: block;
  margin: 0 auto;
  padding: 10px 26px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--tre-lys), var(--tre-mork));
  color: var(--pergament);
  font-family: inherit;
  font-size: clamp(15px, 2vw, 18px);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease-out;
}

.takk-knapp:not(:disabled):active { transform: scale(0.96); }

.takk-knapp:disabled {
  opacity: 0.45;
  cursor: default;
}

.takk-knapp .kryss {
  display: inline-block;
  margin-left: 8px;
  opacity: 0.8;
}

/* --- Nullstillingsknapp (vises når alle luker er åpnet) -------------------- */

.nullstill-knapp {
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 40;
  padding: 6px 14px;
  border: 1px solid rgba(232, 184, 75, 0.5);
  border-radius: 999px;
  background: rgba(30, 22, 13, 0.85);
  color: var(--pergament);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.8;
}

.nullstill-knapp:hover, .nullstill-knapp:active { opacity: 1; }

/* --- Flygende gaver (klones og animeres med JS) --------------------------- */

.flyver {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  will-change: transform;
}

.flyver img { display: block; width: 100%; border-radius: 4px; }

/* --- Konfetti ------------------------------------------------------------- */

.konfetti-bit {
  position: fixed;
  top: -20px;
  z-index: 200;
  pointer-events: none;
  border-radius: 2px;
}
