/* Scener på fotona. Fotot är kartan: allt som ligger ovanpå är placerat i fotots egna bildpunkter (1300 px brett)
   och skalas med bilden, så att det träffar samma punkt vid alla bredder. */
/* ===== Gemensamma byggstenar ===== */
.spark path { fill: var(--glint); }
.spark { filter: drop-shadow(0 0 5px rgba(255, 236, 150, .9)); }
.burst-pop svg { display: block; width: 100%; height: auto; overflow: visible; filter: drop-shadow(0 3px 3px rgba(20, 34, 28, .3)); }
.burst-text { font-family: inherit; font-weight: 700; }

/* ===== Kortterminalen (cykel 10 s) ===== */
[data-scene="enhet"] { --cyc: 10s; }
.lcd { transform-origin: 50% 50%; mix-blend-mode: normal; }
.chk-glow { border-radius: 50%; background: radial-gradient(circle, var(--led-1), var(--led-2) 55%, rgba(63, 224, 168, 0) 74%); mix-blend-mode: screen; transform: rotate(-14deg); }
.chk-ring { border-radius: 50%; border: 3px solid var(--led-3); mix-blend-mode: screen; transform: rotate(-14deg); }
.hang { width: 0; height: 0; }
.hang .hook { position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.hang .string { position: absolute; left: -1px; top: 0; width: 3px; height: 98px; background: var(--green); transform-origin: 50% 0; }
.hang .s1 { transform: rotate(37.6deg); }
.hang .s2 { transform: rotate(-37.6deg); }
.hang .board { position: absolute; left: -82px; top: 78px; width: 164px; height: 72px; display: grid; place-items: center; background: var(--paper); border: 3px solid var(--green); border-radius: 6px; box-shadow: 4px 5px 0 var(--green); color: var(--green); font-size: 40px; letter-spacing: -.02em; }
.card { width: 525px; height: auto; transform-origin: 50% 50%; filter: drop-shadow(0 16px 12px rgba(10, 20, 15, .5)); transform: translate(-50%, -50%) translate(540px, -300px) rotate(16deg) scale(.88); }

@keyframes card-tap {
  0%, 4% { opacity: 0; transform: translate(-50%, -50%) translate(540px, -300px) rotate(16deg) scale(.88); }
  6% { opacity: 1; }
  17% { opacity: 1; transform: translate(-50%, -50%) translate(36px, -34px) rotate(3deg) scale(1.05); animation-timing-function: cubic-bezier(.5, 0, .9, .4); }
  21%, 31% { opacity: 1; transform: translate(-50%, -50%) translate(0, 0) rotate(0) scale(1); }
  39%, 100% { opacity: 0; transform: translate(-50%, -50%) translate(-460px, -230px) rotate(-14deg) scale(.9); }
}
/* Bildskärmen byter text som en riktig LCD: kort flimmer, sedan stabil, och tillbaka med ett nytt flimmer. */
@keyframes lcd-swap {
  0%, 21.5% { opacity: 0; filter: brightness(1); }
  22% { opacity: .9; filter: brightness(1.6); }
  22.8% { opacity: .15; filter: brightness(1); }
  23.6% { opacity: 1; filter: brightness(1.35); }
  25%, 63% { opacity: 1; filter: brightness(1); }
  64% { opacity: .4; }
  64.8% { opacity: 1; }
  66.5% { opacity: 1; filter: brightness(1.3); }
  67.4% { opacity: 0; filter: brightness(1); }
  100% { opacity: 0; }
}
@keyframes chk-glow { 0%, 21.5% { opacity: 0; } 22% { opacity: 1; } 64% { opacity: .55; } 70%, 100% { opacity: 0; } }
@keyframes chk-ring { 0%, 21.5% { opacity: 0; transform: rotate(-14deg) scale(.5); } 22% { opacity: .95; transform: rotate(-14deg) scale(.5); } 34%, 100% { opacity: 0; transform: rotate(-14deg) scale(2.2); } }
@keyframes pling {
  0%, 21.6% { opacity: 0; transform: translate(-50%, -50%) rotate(-14deg) scale(.3); }
  22% { opacity: 1; transform: translate(-50%, -50%) rotate(-14deg) scale(.3); animation-timing-function: cubic-bezier(.2, 1.5, .4, 1); }
  26% { opacity: 1; transform: translate(-50%, -50%) rotate(-6deg) scale(1.1); }
  28%, 34% { opacity: 1; transform: translate(-50%, -50%) rotate(-8deg) scale(1); }
  36%, 100% { opacity: 0; transform: translate(-50%, -50%) rotate(-8deg) scale(.85); }
}
@keyframes twinkle { 0%, 24% { opacity: 0; transform: scale(.2) rotate(0); } 28% { opacity: 1; transform: scale(1) rotate(30deg); } 36%, 100% { opacity: 0; transform: scale(.3) rotate(90deg); } }
@keyframes hang-in { from { opacity: 0; transform: rotate(-26deg); } to { opacity: 1; transform: rotate(-5deg); } }
@keyframes swing { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }

.is-live[data-scene="enhet"] .card { animation: card-tap var(--cyc) linear infinite; }
.is-live[data-scene="enhet"] .lcd { animation: lcd-swap var(--cyc) linear infinite; }
.is-live[data-scene="enhet"] .chk-glow { animation: chk-glow var(--cyc) linear infinite; }
.is-live[data-scene="enhet"] .chk-ring { animation: chk-ring var(--cyc) linear infinite; }
.is-live[data-scene="enhet"] .burst-pop { animation: pling var(--cyc) linear infinite; }
.is-live[data-scene="enhet"] .spark { animation: twinkle var(--cyc) linear var(--d) infinite; }
.is-live[data-scene="enhet"] .hang { animation: hang-in .9s var(--ease, cubic-bezier(.16, 1, .3, 1)) .4s both, swing 4.6s ease-in-out 1.3s infinite alternate; }

/* ===== Arbetsbordet (cykel 12 s) ===== */
[data-scene="labb"] { --cyc: 12s; }
.screen { overflow: hidden; }
@keyframes screen-on { to { opacity: 1; } }
.is-live[data-scene="labb"] .screen { animation: screen-on .6s ease-out .3s forwards; }
.s-build { background: linear-gradient(100deg, rgba(34,56,98,.92), rgba(54,86,140,.9)); box-shadow: inset 0 0 6px rgba(0,0,0,.35); }
.blocks { display: flex; gap: 5px; padding: 6px; height: 100%; box-sizing: border-box; }
.blocks i { display: block; border-radius: 3px; transform: scale(0); opacity: 0; transform-origin: 50% 100%; }
.blocks i:nth-child(1) { width: 56px; background: var(--yellow); }
.blocks i:nth-child(2) { width: 66px; background: var(--green); }
.blocks i:nth-child(3), .blocks i:nth-child(4), .blocks i:nth-child(5) { flex: 1; background: var(--paper); border: 2px solid var(--green); }
.blocks i:nth-child(6) { width: 30px; background: var(--green); }
@keyframes blk { 0% { opacity: 0; transform: scale(0); } 3% { opacity: 1; transform: scale(1.12); } 5%, 70% { opacity: 1; transform: scale(1); } 74%, 100% { opacity: 0; transform: scale(0); } }
.is-live[data-scene="labb"] .blocks i { animation: blk var(--cyc) ease-out calc(var(--i) * .25s + .6s) infinite; }

.s-chart { background: linear-gradient(100deg, rgba(232,242,246,.93), rgba(214,232,240,.9)); box-shadow: inset 0 0 5px rgba(20,40,60,.25); }
.s-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.s-chart .line { fill: none; stroke: var(--green); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.s-chart .area { fill: rgba(243, 221, 139, .75); opacity: 0; }
.s-chart .dot { fill: var(--yellow); stroke: var(--green); stroke-width: 2.5; opacity: 0; transform-box: fill-box; transform-origin: center; }
@keyframes draw { 0%, 8% { stroke-dashoffset: 1; opacity: 1; } 40%, 82% { stroke-dashoffset: 0; opacity: 1; } 88%, 100% { stroke-dashoffset: 1; opacity: 0; } }
@keyframes area-in { 0%, 30% { opacity: 0; } 42%, 82% { opacity: 1; } 88%, 100% { opacity: 0; } }
@keyframes dot-pop { 0%, 38% { opacity: 0; transform: scale(0); } 42% { opacity: 1; transform: scale(1.5); } 46%, 82% { opacity: 1; transform: scale(1); } 88%, 100% { opacity: 0; transform: scale(0); } }
.is-live[data-scene="labb"] .s-chart .line { animation: draw var(--cyc) ease-in-out 1s infinite; }
.is-live[data-scene="labb"] .s-chart .area { animation: area-in var(--cyc) linear 1s infinite; }
.is-live[data-scene="labb"] .s-chart .dot { animation: dot-pop var(--cyc) linear 1s infinite; }

.s-phone { background: var(--paper); box-shadow: inset 0 0 5px rgba(0,0,0,.3); }
.s-phone .page { padding: 5px; display: grid; gap: 5px; }
.s-phone b { display: block; height: 14px; background: var(--green); border-radius: 2px; }
.s-phone u { display: block; height: 28px; background: var(--yellow); border-radius: 3px; }
.s-phone s { display: block; height: 5px; background: var(--sage-line-2); border-radius: 3px; width: 80%; }
.s-phone s:nth-of-type(odd) { width: 62%; }
@keyframes scroll-page { 0%, 12% { transform: translateY(0); } 50%, 62% { transform: translateY(-64px); } 100% { transform: translateY(0); } }
.is-live[data-scene="labb"] .s-phone .page { animation: scroll-page 6s ease-in-out infinite; }

.note { color: var(--text); font-weight: 600; box-shadow: 0 7px 10px rgba(60, 40, 10, .25), 0 1px 0 rgba(0, 0, 0, .06); --rot: -5deg; transform: rotate(var(--rot)); transform-origin: 50% 50%; }
.n-todo { width: 214px; min-height: 212px; padding: 16px 18px; box-sizing: border-box; background: var(--yellow); font-size: 23px; line-height: 1.4; }
.n-todo .t { margin: 0 0 6px; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.n-todo p { margin: 0; display: flex; align-items: center; gap: 10px; }
.n-todo p span { width: 22px; height: 22px; border: 2px solid var(--green); border-radius: 4px; display: inline-grid; place-items: center; flex: none; }
.n-todo svg { width: 19px; height: 19px; fill: none; stroke: var(--green); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.n-todo svg path { stroke-dasharray: 24; stroke-dashoffset: 24; }
.n-flow { --rot: 4deg; width: 190px; min-height: 160px; padding: 16px 18px; box-sizing: border-box; background: var(--blue); font-size: 24px; line-height: 1.32; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.n-flow p { margin: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; white-space: nowrap; }
.n-flow p:not(:last-child)::after { content: "→"; color: var(--green); font-weight: 700; }
@keyframes note-land {
  0%, 9% { opacity: 0; transform: translateY(-90px) rotate(calc(var(--rot) - 9deg)) scale(1.3); }
  14% { opacity: 1; transform: translateY(0) rotate(var(--rot)) scale(.96, .9); animation-timing-function: ease-out; }
  17%, 82% { opacity: 1; transform: translateY(0) rotate(var(--rot)) scale(1); }
  88%, 100% { opacity: 0; transform: translateY(0) rotate(var(--rot)) scale(1); }
}
@keyframes tick { 0%, 28% { stroke-dashoffset: 24; } 31%, 82% { stroke-dashoffset: 0; } 88%, 100% { stroke-dashoffset: 24; } }
.is-live[data-scene="labb"] .n-todo { animation: note-land var(--cyc) linear .4s infinite; }
.is-live[data-scene="labb"] .n-flow { animation: note-land var(--cyc) linear 1s infinite; }
.is-live[data-scene="labb"] .n-todo p:nth-of-type(1) svg path { animation: tick var(--cyc) linear .4s infinite; }
.is-live[data-scene="labb"] .n-todo p:nth-of-type(2) svg path { animation: tick var(--cyc) linear 1.25s infinite; }
.is-live[data-scene="labb"] .n-todo p:nth-of-type(3) svg path { animation: tick var(--cyc) linear 2.1s infinite; }

/* ===== Kontoret (cykel 13 s) ===== */
[data-scene="kontor"] { --cyc: 13s; }
.peek { opacity: 1; clip-path: polygon(0 0, 1300px 0, 1300px 1383px, 910px 1280px, 0 1280px); }
.peek .robot { position: absolute; width: 560px; height: 550px; transform: translateY(210px); }
.peek .robot img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.r-arm { transform-origin: 47.4% 45.4%; }
.r-head { transform-origin: 32.3% 38.6%; }
@keyframes peek-rise { 0%, 6% { transform: translateY(210px); } 18%, 80% { transform: translateY(0); } 90%, 100% { transform: translateY(210px); } }
@keyframes peek-wave { 0%, 24% { transform: rotate(0); } 28% { transform: rotate(-128deg); } 32% { transform: rotate(-110deg); } 36% { transform: rotate(-140deg); } 40% { transform: rotate(-110deg); } 44% { transform: rotate(-140deg); } 48% { transform: rotate(-126deg); } 56% { transform: rotate(-126deg); } 62%, 100% { transform: rotate(0); } }
@keyframes peek-look { 0%, 18% { transform: rotate(0); } 22% { transform: rotate(-7deg); } 36% { transform: rotate(-3deg); } 56% { transform: rotate(8deg); } 68%, 100% { transform: rotate(0); } }
.is-live[data-scene="kontor"] .peek .robot { animation: peek-rise var(--cyc) cubic-bezier(.16, 1, .3, 1) .5s infinite; }
.is-live[data-scene="kontor"] .r-arm { animation: peek-wave var(--cyc) ease-in-out .5s infinite; }
.is-live[data-scene="kontor"] .r-head { animation: peek-look var(--cyc) ease-in-out .5s infinite; }

/* ===== Reducerad rörelse: stilla bilder med skyltarna på plats ===== */
.is-static .hang, .is-static .n-todo, .is-static .n-flow { opacity: 1; }
.is-static .hang { transform: rotate(-3deg); }
.is-static .n-todo svg path { stroke-dashoffset: 0; }
.is-static .peek { display: none; }
@media (prefers-reduced-motion: reduce) { .photo-stage .ov { animation: none !important; } }
