/* ============================================================
   SWEDBANK saderības tests — stili (v2: pilns augstums, 3D, tekstūra)
   Mērvienības: 1cqw = 10.8 dizaina px (1080 platums); vertikāli cqh.
   ============================================================ */

@font-face {
  font-family: "Swedbank Headline";
  src: local("Swedbank Headline Bold"), local("SwedbankHeadline-Bold"),
       url("assets/fonts/SwedbankHeadline-Bold.otf") format("opentype");
  font-weight: 700; font-display: swap;
}
@font-face {
  font-family: "Swedbank Headline";
  src: local("Swedbank Headline Black"), local("SwedbankHeadline-Black"),
       url("assets/fonts/SwedbankHeadline-Black.otf") format("opentype");
  font-weight: 900; font-display: swap;
}

:root {
  --par-x: 0; --par-y: 0; --bg-x: 0px; --bg-y: 0px;   /* parallax, uzstāda app.js */
  --cream: #FDF6EE;
  --orange: #FF5F00;
  --orange-2: #F4641C;
  --orange-text: #FB4F00;
  --yellow: #FDC92A;
  --teal: #31A3AE;
  --pink: #C5569A;
  --ink: #512B2B;
  --grid: rgba(81, 43, 43, .16);
  --font: "Swedbank Headline", "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  --ease-out: cubic-bezier(.22, .9, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.45, .5, 1);
  --ease-inout: cubic-bezier(.65, 0, .3, 1);
  /* papīra grauda tekstūra */
  --paper: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .10 0'/></filter><rect width='240' height='240' filter='url(%23n)'/></svg>");
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--cream);
  color: #fff;
  font-family: var(--font);
  font-weight: 700;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  display: grid; place-items: center;
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: var(--cell, 31px) var(--cell, 31px);
  background-position: calc(50% + var(--bg-x)) calc(0px + var(--bg-y));
}

/* ---------- skatuve: pilns augstums, platums no augstuma (9:16), bet ne platāks par ekrānu.
   overflow: visible — kartītes lido pāri visam ekrānam, nekas netiek apgriezts. ---------- */
.stage {
  position: relative;
  height: 100dvh;
  width: min(100vw, calc(100dvh * 9 / 16));
  container-type: size;
  user-select: none; -webkit-user-select: none;
}
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: block; }
#screen-start, #screen-quiz { perspective: 120cqw; perspective-origin: 50% 45%; }
#screen-start { z-index: 4; }
#screen-quiz { z-index: 3; }
#screen-result, #screen-detail { z-index: 2; }


/* ---------- kartīte = oranža papīra lapa ---------- */
.card {
  --dx: 0px; --dy: 0px; --rz: 0deg; --ry: 0deg; --rx: 0deg; --depth: 0; --lift: 1;
  --pk: calc(1 - var(--depth) * .3);                   /* parallax koeficients pēc dziļuma */
  --ppx: calc(var(--par-x) * .6cqw * var(--pk));
  --ppy: calc(var(--par-y) * .45cqw * var(--pk));
  position: absolute;
  left: 6.85cqw; top: 9.58cqh;
  width: 86.34cqw; height: 76.68cqh;
  background: linear-gradient(160deg, var(--orange) 0%, var(--orange) 70%, var(--orange-2) 100%);
  box-shadow:
    calc(var(--par-x) * -.5cqw) calc(2.4cqh + var(--par-y) * -.25cqh) 3.4cqh rgba(81, 43, 43, .20),
    calc(var(--par-x) * -.15cqw) .5cqh .9cqh rgba(81, 43, 43, .10),
    inset 0 0 0 1px rgba(255, 255, 255, .06);
  touch-action: none;
  cursor: grab;
  /* bez preserve-3d: 3D konteksts Chrome/Safari jauc hit-testu (kartīti nevar satvert) — kārtojam ar z-index */
  transform:
    translate3d(calc(var(--dx) + var(--ppx)), calc(var(--dy) + var(--ppy) + var(--depth) * 1.6cqh), calc(var(--depth) * -7cqw))
    rotateZ(var(--rz)) rotateY(var(--ry)) rotateX(var(--rx))
    scale(var(--lift));
  transition: transform .6s var(--ease-spring);
  will-change: transform;
}
.card::after {  /* papīra grauds */
  content: ""; position: absolute; inset: 0;
  background: var(--paper); background-size: 240px 240px;
  mix-blend-mode: multiply; opacity: .55; pointer-events: none;
}
.card.dragging { cursor: grabbing; transition: none; box-shadow: 0 4cqh 5cqh rgba(81,43,43,.26), 0 .8cqh 1.4cqh rgba(81,43,43,.12); }
.card.tilting:not(.dragging) { transition: transform .25s ease-out; }
.card.flying { pointer-events: none; z-index: 30 !important; }

/* elpošana sākuma kartītei */
@keyframes float {
  0%, 100% { --dy: 0px; --ry: -1.5deg; --rx: .6deg; }
  50%      { --dy: -.7cqh; --ry: 1.5deg; --rx: -.6deg; }
}
@property --dy { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --dx { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --ry { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@property --rx { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@property --rz { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.card.floating { animation: float 5s ease-in-out infinite; }
@keyframes wiggle {
  0%, 100% { --dx: 0px; --rz: 0deg; }
  30% { --dx: 3cqw; --rz: 2.2deg; }
  70% { --dx: -2.4cqw; --rz: -1.8deg; }
}
.card.wiggle { animation: wiggle 1.1s var(--ease-inout) 1; }

/* ---------- sākuma kartīte ---------- */
.start-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 3cqh 7cqw calc(15.5cqw + 6cqh);   /* apakšā vieta bultām */
}
.start-card > * { position: relative; z-index: 1; }
.logo { width: 47.6cqw; height: auto; margin-bottom: 4cqh; }
.start-title { margin: 0 0 3cqh; font-weight: 900; font-size: 10.9cqw; line-height: 1.12; white-space: pre-line; }
.start-lead { margin: 0 0 4.5cqh; width: 56cqw; font-size: 4cqw; line-height: 1.32; }
.hint-box {
  width: 71.8cqw; padding: 1.3cqh 4cqw;
  background: var(--yellow); font-size: 3.7cqw; line-height: 1.3;
}
.disclaimer {
  position: absolute; left: 8cqw; right: 8cqw; bottom: 3.4cqh; margin: 0;
  text-align: center; color: var(--ink);
  font-size: 2.5cqw; line-height: 1.4; opacity: .7;
}
.disclaimer a { color: var(--orange-text); text-decoration: none; white-space: nowrap; }
#screen-start.leaving .disclaimer, #screen-start.leaving .controls-start { opacity: 0; transition: opacity .4s; }
.disclaimer a:hover { text-decoration: underline; }

/* ienākšana ielādējot */
@keyframes rise { from { opacity: 0; translate: 0 3cqh; } to { opacity: 1; translate: 0 0; } }
#screen-start.active:not(.leaving) { animation: rise .9s var(--ease-out) both; }
#screen-start .disclaimer { animation: rise 1.1s .3s var(--ease-out) both; }

/* ---------- bultu pogas ---------- */
.controls { position: absolute; display: flex; justify-content: space-between; }
.controls-start { left: 8cqw; right: 8cqw; bottom: 3.8cqh; }
#screen-start .disclaimer { transform: translate(calc(var(--par-x) * .2cqw), calc(var(--par-y) * .15cqw)); }
.arrow-btn {
  appearance: none; border: 0; padding: 0; margin: 0; background: transparent; cursor: pointer;
  width: 15.5cqw; height: 15.5cqw; border-radius: 50%;
  transition: transform .15s ease-out;
  -webkit-tap-highlight-color: transparent;
}
.arrow-btn img { display: block; width: 100%; height: 100%; }
.arrow-btn.flip img { transform: scaleX(-1); }
.arrow-btn:hover { transform: scale(1.06); }
.arrow-btn:active { transform: scale(.92); transition-duration: .05s; }
.arrow-btn:focus-visible { outline: .4cqw solid #fff; outline-offset: .5cqw; }

/* ---------- jautājumu kartītes ---------- */
.stack { position: absolute; inset: 0; }
.q-card { z-index: calc(10 - var(--depth)); }
.q-card.behind { pointer-events: none; filter: brightness(calc(1 - var(--depth) * .06)); }
@keyframes cardEnter { from { opacity: 0; --dy: 3cqh; } to { opacity: 1; --dy: 0px; } }
.q-card.enter { animation: cardEnter .6s var(--ease-out) both; }

.q-card .statement {
  position: absolute; left: 50%; top: 43%;
  transform: translate(-50%, -50%);
  width: 70cqw; margin: 0; text-align: center;
  font-weight: 900; font-size: 6.1cqw; line-height: 1.22;
  text-shadow: 0 .2cqh .6cqh rgba(120, 40, 0, .18);
  transition: opacity .35s;
}
@keyframes textIn { from { opacity: 0; transform: translate(-50%, calc(-50% + 1.6cqh)); } to { opacity: 1; transform: translate(-50%, -50%); } }
.q-card.is-top .statement { animation: textIn .4s var(--ease-out) both; }
.q-card .counter { position: absolute; top: 2.6cqh; left: 0; right: 0; text-align: center; font-size: 2.8cqw; letter-spacing: .06em; opacity: .7; }
.q-card .progress { position: absolute; left: 0; top: 0; height: .45cqh; background: var(--yellow); transition: width .5s var(--ease-out); }

.stamp {
  position: absolute; top: 6cqh;
  padding: .8cqh 2.4cqw; border: .9cqw solid;
  font-weight: 900; font-size: 5cqw; letter-spacing: .04em;
  opacity: 0; pointer-events: none; z-index: 2;
  background: rgba(255,255,255,.08);
}
.stamp-yes { right: 6cqw; color: var(--teal); border-color: var(--teal); transform: rotate(12deg); }
.stamp-no  { left: 6cqw;  color: var(--pink); border-color: var(--pink); transform: rotate(-12deg); }

.controls-quiz {
  --p-yes: 0; --p-no: 0;
  left: 6.85cqw; width: 86.34cqw;
  top: calc(9.58cqh + 76.68cqh * .742);
  padding: 0 10.2cqw; z-index: 20;
  transform: translate(calc(var(--par-x) * .6cqw), calc(var(--par-y) * .45cqw));
  transition: opacity .5s;
}
.control {
  display: flex; flex-direction: column; align-items: center; gap: 1cqh;
  transform: scale(calc(1 + var(--p) * .14)) translateY(calc(var(--p) * -.6cqh));
  transition: transform .2s ease-out;
}
#ctl-no  { --p: var(--p-no); }
#ctl-yes { --p: var(--p-yes); }
.control-label { font-size: 3cqw; letter-spacing: .02em; opacity: calc(.75 + var(--p) * .25); }
.controls-quiz .arrow-btn img { transition: filter .2s; }

/* ---------- rezultāts ---------- */
.result-kicker, .result-quote { color: var(--orange-text); text-align: center; margin: 0; position: absolute; left: 50%; }
.result-kicker { top: 12.1cqh; font-size: 5.55cqw; }
.result-name {
  position: absolute; left: 0; right: 0; top: 18.4cqh; margin: 0; text-align: center;
  color: var(--yellow); font-weight: 900; font-size: 13cqw; line-height: 1; letter-spacing: -.01em;
  text-shadow: 0 .3cqh 0 rgba(200, 140, 0, .18);
}
.result-quote { top: 28.2cqh; width: 69cqw; font-size: 5.55cqw; line-height: 1.22; }
.animal-box { position: absolute; left: 50%; top: 35.4cqh; width: 76cqw; height: 76cqw; transform: translate(calc(-50% + var(--par-x) * 1cqw), calc(var(--par-y) * .7cqw)); }
.animal { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 1.4cqh 1.6cqh rgba(81,43,43,.18)); }
.animal.flip { transform: scaleX(-1); }
#result-animal { opacity: 0; }
#screen-result.ready #result-animal { opacity: 1; }

.cta {
  position: absolute; left: 15cqw; width: 70cqw; top: 81.9cqh; height: 5.6cqh;
  display: flex; align-items: center; justify-content: center; gap: 3cqw;
  background: var(--yellow); color: #fff; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-weight: 900; font-size: 5.55cqw; text-decoration: none;
  transition: transform .15s ease-out, filter .15s;
}
.cta:hover { filter: brightness(1.04); }
.cta:active { transform: scale(.98); transition-duration: .05s; }
.cta-arrow { width: 6.8cqw; height: auto; transition: transform .25s var(--ease-spring); }

/* otrā poga: dalīties ar 9:16 kartiņu — kontūra + kartiņas sīktēls, lai redzams, ka tiek dalīts attēls */
.cta-secondary {
  background: transparent; color: var(--orange-text);
  border: .55cqw solid var(--orange-text);
  font-size: 4.6cqw; gap: 2.4cqw;
}
.cta-secondary:hover { background: rgba(251, 79, 0, .06); filter: none; }
.cta-secondary:disabled { opacity: .6; cursor: default; }
.share-icon { width: 5.2cqw; height: 5.2cqw; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.share-thumb {
  width: 5.2cqw; height: 9.2cqw; object-fit: cover; object-position: top;
  border: .3cqw solid var(--orange-text); background: var(--cream);
  transform: rotate(6deg); margin-left: .6cqw;
}
#screen-result .cta-secondary { top: 89cqh; height: 5.6cqh; }
.ready #btn-share-result { transition-delay: 1s; }
.cta:hover .cta-arrow { transform: translateX(.8cqw); }

/* atklāšana pēc locīšanas — pakāpeniski */
.reveal { --tpx: calc(var(--par-x) * .3cqw); --tpy: calc(var(--par-y) * .2cqw); opacity: 0; transform: translate(var(--tpx), calc(1.4cqh + var(--tpy))); transition: opacity .8s var(--ease-out), transform .8s var(--ease-out); }
.result-kicker.reveal, .result-quote.reveal { transform: translate(calc(-50% + var(--tpx)), calc(1.4cqh + var(--tpy))); }
.ready .reveal { opacity: 1; transform: translate(var(--tpx), var(--tpy)); transition: opacity .8s var(--ease-out), transform .8s var(--ease-out); }
.ready .result-kicker.reveal, .ready .result-quote.reveal { transform: translate(calc(-50% + var(--tpx)), var(--tpy)); }
.ready .result-kicker { transition-delay: .1s; }
.ready .result-name   { transition-delay: .3s; }
.ready .result-quote  { transition-delay: .5s; }
.ready .cta           { transition-delay: .8s; }

/* ---------- detaļas ---------- */
@keyframes fadeUp { from { opacity: 0; translate: 0 2cqh; } to { opacity: 1; translate: 0 0; } }
#screen-detail.active > * { animation: fadeUp .6s var(--ease-out) both; }
#screen-detail.active > :nth-child(2) { animation-delay: .1s; }
#screen-detail.active > :nth-child(3) { animation-delay: .2s; }
.detail-desc {
  position: absolute; left: 7.5cqw; top: 10.5cqh; width: 46cqw; margin: 0;
  color: var(--orange-text); font-size: 4.4cqw; line-height: 1.32;
}
/* dzīvnieks pilnībā skatuves iekšpusē (dizainā tas izgāja pāri malai un tika apgriezts) */
.detail-animal-box { position: absolute; right: 4cqw; top: 6cqh; width: 44cqw; height: 44cqw; transform: translate(calc(var(--par-x) * 1cqw), calc(var(--par-y) * .7cqw)); }
.detail-desc { transform: translate(calc(var(--par-x) * .3cqw), calc(var(--par-y) * .2cqw)); }
.detail-flow { transform: translate(calc(var(--par-x) * .45cqw), calc(var(--par-y) * .3cqw)); }
.detail-flow {
  position: absolute; left: 0; right: 0; top: 32.6cqh; bottom: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2.4cqh;
}
.jobs-box {
  width: 70cqw; min-height: 28cqh; padding: 3cqh 5cqw 2.6cqh 8cqw;
  background: var(--yellow);
}
.jobs-title { margin: 0 0 2.4cqh; text-align: center; font-weight: 900; font-size: 5.55cqw; }
.jobs { margin: 0; padding: 0 0 0 4.4cqw; font-size: 4.6cqw; line-height: 1.5; }
.jobs li { padding-left: .4cqw; }
#screen-detail .cta { position: static; flex: none; height: 5.4cqh; }
.sticker { width: 58cqw; flex: none; margin-top: .6cqh; }
.detail-footer { margin-top: auto; padding-bottom: 1.8cqh; display: flex; justify-content: center; gap: 6cqw; }
.link-btn {
  appearance: none; background: none; border: 0; padding: .6cqh 1cqw; cursor: pointer;
  font: inherit; font-size: 2.9cqw; color: var(--ink); opacity: .7;
  text-decoration: underline; text-underline-offset: .3em;
}
.link-btn:hover { opacity: 1; }

/* ---------- LOCĪŠANAS SLĀNIS (origami) ---------- */
.fold-layer {
  position: absolute; inset: 0; z-index: 50;
  perspective: 95cqw; perspective-origin: 50% 42%;
  transform-style: preserve-3d;
  pointer-events: none;
}
.fold-layer > * { position: absolute; }
.paper::after {
  content: ""; position: absolute; inset: 0;
  background: var(--paper); background-size: 240px 240px;
  mix-blend-mode: multiply; opacity: .55; pointer-events: none;
}
.fold-layer .sheet { transition: box-shadow .5s; }
.fold-layer .flap { transform-style: preserve-3d; will-change: transform; }
.fold-layer .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
.fold-layer .face .gloss { position: absolute; inset: 0; opacity: 0; }
.fold-layer .table-shadow { filter: blur(1.6cqw); opacity: 0; background: rgba(70, 25, 0, .35); }
.fold-layer .fold-shadow { opacity: 0; }
.fold-layer .morph { will-change: clip-path, transform; background: var(--orange); }
.fold-layer .morph-shadow { filter: blur(2cqw); background: rgba(81,43,43,.22); opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .card, .reveal, .arrow-btn, .cta { transition-duration: .01s !important; }
  .card.floating, .card.wiggle, .controls-start .arrow-btn, .q-card.enter, .q-card.is-top .statement { animation: none !important; }
}

/* locīšanas izlaišana */
.skip-hint {
  position: absolute; left: 0; right: 0; bottom: 3cqh; z-index: 60;
  text-align: center; color: var(--ink); font-size: 2.8cqw; opacity: 0;
  transition: opacity .8s; pointer-events: none;
}
.skip-hint.on { opacity: .55; }
/* noscript (CSP: bez inline stiliem) */
.noscript { font-family: system-ui, sans-serif; padding: 2rem; text-align: center; color: var(--ink); }
.noscript a { color: var(--orange-text); }
