/* Amarof – javisko obrazovky Dnes (ui-stage.js): veľká postava stojí na scéne celý čas, dole leží balíček kariet
   lícom nadol, vytiahnutá karta leží pri postave. Scéna je tmavá v oboch témach (leží na nočnom pozadí Dnes),
   karty samy majú materiál témy (koža v Noci, pergamen v Pergamene). */
:root {
  --st-top: calc(57px + env(safe-area-inset-top, 0px));                       /* spodok hornej lišty */
  --st-dock: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px));          /* spodná navigácia (mobil) */
  --st-deck: 78px;                                                            /* výška balíčka */
  --st-w: min(72vw, 300px, 34svh);                                            /* šírka postavy na mobile */
  --st-h: calc(var(--st-w) * 1.3733);
  --st-band: clamp(150px, 26svh, 232px);                                      /* pás s postavou, ktorý ostáva hore */
  --st-gap: calc(var(--st-h) - var(--st-band) + 14px);                        /* nohy postavy pod pásom (len úplne hore) */
  --st-card: calc(var(--st-top) + var(--st-band) - 2px);                      /* kde leží vytiahnutá karta */
  --st-area: calc(100svh - var(--st-card) - var(--st-deck) - var(--st-dock)); /* voľná plocha medzi kartou a balíčkom */
}
@media (min-width: 1000px) {
  :root { --st-dock: 0px; --st-deck: 138px; --st-hero: calc(100svh - var(--st-top) - var(--st-deck) - 28px);
    --st-card: calc(var(--st-top) + 24px + var(--st-hero) * .07); }
}

body.on-dnes main { padding-bottom: calc(var(--st-deck) + var(--s-5)); }
:root:has(body.on-dnes) { scroll-padding-top: calc(var(--st-card) + 8px); scroll-padding-bottom: calc(var(--st-deck) + var(--st-dock) + 16px); }
.stage { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); }
.stage, .deck { --o-telo: #d4935f; --o-mysel: #a5bcd8; --o-vztahy: #cfa2c4; --o-duch: #a6c6a0; --o-povol: #b9a8dc; --o-posl: #d8b56e; }
.stage.is-mounting, .stage.is-mounting * { transition: none !important; }

/* ---------- postava na scéne ---------- */
.stage-hero { position: sticky; top: var(--st-top); z-index: 4; height: var(--st-band); margin: calc(var(--s-4) * -1) calc(var(--s-4) * -1) 0; pointer-events: none; }
/* pozadie pásu: tma siene so svetlom ohňa; úplne hore siaha až po nohy, po zoskoku ho zreže hrana stola */
.stage-scene, .stage-figwrap { position: absolute; inset: 0 0 calc(var(--st-gap) * -1) 0; transition: clip-path .5s cubic-bezier(.3, .8, .3, 1); }
.stage-scene { clip-path: inset(0); overflow: hidden;
  background: radial-gradient(ellipse 70% 62% at 50% 44%, rgba(255, 186, 104, .2), transparent 70%), linear-gradient(180deg, #100c09 0, #1a130d 46%, #120d09 100%); }
.stage-figwrap { clip-path: inset(-20px 0 0 0); }
.stage.is-down .stage-scene { clip-path: inset(0 0 var(--st-gap) 0); }
.stage.is-down .stage-figwrap { clip-path: inset(-20px 0 var(--st-gap) 0); }
.stage-light { position: absolute; left: 50%; top: -18%; width: 150%; height: 120%; translate: -50% 0; pointer-events: none;
  background: conic-gradient(from 180deg at 50% 0, transparent 150deg, rgba(255, 205, 130, .09) 168deg, rgba(255, 215, 150, .16) 180deg, rgba(255, 205, 130, .09) 192deg, transparent 210deg); }
.stage-ring { position: absolute; left: 50%; bottom: 9px; width: calc(var(--st-w) * 1.02); height: calc(var(--st-w) * .2); translate: -50% 0; border-radius: 50%;
  border: 1px solid rgba(227, 197, 138, .26); box-shadow: inset 0 0 26px rgba(255, 190, 110, .12), 0 0 0 7px rgba(227, 197, 138, .05); }
.stage-shadow { position: absolute; left: 50%; bottom: 20px; width: calc(var(--st-w) * .62); height: calc(var(--st-w) * .1); translate: -50% 0; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, .75), transparent 70%); }
.stage-fig { position: absolute; left: 50%; top: 8px; width: var(--st-w); translate: -50% 0; transform-origin: 50% 96%;
  transform: rotate(var(--lean, 0deg)); transition: translate .55s cubic-bezier(.3, 1.25, .5, 1), transform .4s ease-out; }
.stage.is-down .stage-fig { translate: calc(-50% - min(19vw, 150px)) 0; }
.stage .vista-hero { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; pointer-events: auto; border-radius: var(--r-2); }
.stage .vista-hero .hero-art { width: 100%; max-height: none; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .5)); }
.stage.is-past .vista-hero .hero-art { filter: sepia(.45) saturate(.75) drop-shadow(0 10px 14px rgba(0, 0, 0, .5)); }
/* hrana stola, za ktorú postava zoskočí: na ňu kladie karty */
.stage-ledge { position: absolute; left: 0; right: 0; bottom: -2px; height: 12px; opacity: 0; transition: opacity .35s;
  background: linear-gradient(180deg, #7a5a34 0, #4a3420 22%, #2a1c11 100%); border-top: 1px solid rgba(240, 215, 159, .55); }
.stage-ledge::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 16px; background: linear-gradient(180deg, rgba(0, 0, 0, .6), transparent); }
.stage.is-down .stage-ledge { opacity: 1; }
.stage-gap { height: var(--st-gap); }

/* hlava sleduje kurzor (inline transform z JS); reakcie do-* majú prednosť */
.stage .hero-art:not([class*="do-"]) .h-head { animation: none; transition: transform .25s ease-out; }
/* zoskok a ťahanie karty z balíčka */
.stage-fig.is-hop .vista-hero { animation: st-hop .6s cubic-bezier(.3, .7, .4, 1); }
@keyframes st-hop { 0% { transform: none; } 22% { transform: translateY(3%) scale(1.03, .95); } 52% { transform: translateY(-9%) scale(.98, 1.03); } 78% { transform: translateY(1.5%) scale(1.03, .96); } 100% { transform: none; } }
.stage-fig.is-pull .vista-hero { animation: st-pull .74s cubic-bezier(.3, .7, .3, 1); transform-origin: 50% 96%; }
.stage-fig.is-pull .hero-art:not([class*="do-"]) .h-shield { animation: st-pull-a .74s ease-in-out; }
.stage-fig.is-pull .hero-art:not([class*="do-"]) .h-wpn { animation: st-pull-b .74s ease-in-out; }
@keyframes st-pull { 0%, 100% { transform: none; } 30% { transform: translateY(2.5%) rotate(5deg) scale(1.02, .96); } 62% { transform: translateY(-2.5%) rotate(-2.5deg) scale(.99, 1.02); } }
@keyframes st-pull-a { 0%, 100% { transform: none; } 30% { transform: rotate(16deg); } 62% { transform: rotate(-24deg); } }
@keyframes st-pull-b { 0%, 100% { transform: none; } 30% { transform: rotate(-12deg); } 62% { transform: rotate(22deg); } }

/* bublina: vedľa hlavy, chvost k postave */
.stage .hero-bubble { left: 71%; top: 7%; transform: none; max-width: min(200px, 46vw); text-align: left; animation-name: st-bubble-in; }
.stage .hero-bubble.is-out { animation-name: st-bubble-out; }
.stage .hero-bubble::after { left: -7px; bottom: auto; top: 18px; transform: none; border: 7px solid transparent; border-left: 0; border-right-color: #f3ead8; }
.stage:not(.is-down) .hero-bubble { left: 64%; top: 1%; }
@keyframes st-bubble-in { from { opacity: 0; translate: -8px 0; } to { opacity: 1; translate: 0 0; } }
@keyframes st-bubble-out { from { opacity: 1; } to { opacity: 0; translate: 0 -8px; } }

/* ---------- lišta postavy (hlavička dňa) ---------- */
.stage-intro { position: relative; z-index: 2; display: grid; gap: var(--s-3); align-content: start; }
.stage .vista { grid-template-columns: minmax(0, 1fr); gap: var(--s-3); padding: var(--s-3) var(--s-3) var(--s-3);
  background: linear-gradient(180deg, rgba(34, 26, 19, .94), rgba(18, 13, 10, .94)); border: 1px solid color-mix(in srgb, #e3c58a 26%, transparent);
  border-radius: 10px; box-shadow: inset 0 1px 0 rgba(240, 215, 159, .16), 0 20px 36px -22px rgba(0, 0, 0, .9); }
.stage .vista > * { grid-column: 1 / -1; }
.stage-hint { display: flex; align-items: center; justify-content: center; gap: 10px; margin: var(--s-2) 0 var(--s-5); max-width: none; font-style: italic; font-size: var(--fs-s); color: #d8c9a8; text-shadow: 0 1px 8px rgba(0, 0, 0, .8); }
.stage-hint i { flex: none; width: 10px; height: 10px; border-right: 2px solid #e3c58a; border-bottom: 2px solid #e3c58a; transform: rotate(45deg); animation: st-nudge 1.6s ease-in-out infinite; }
@keyframes st-nudge { 0%, 100% { translate: 0 -3px; opacity: .6; } 50% { translate: 0 3px; opacity: 1; } }
@media (max-width: 559px) {
  .stage .traits { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
  .stage .trait { padding: 6px 0 2px; }
  .stage .trait-name { display: none; }
  .stage .vista-head { flex-wrap: nowrap; align-items: flex-end; }
  .stage .vista-today { justify-items: end; }
}

/* ---------- karty: každá má svoj úsek stránky; na stole leží len tá, ktorá je na rade ---------- */
.stage .today { position: relative; z-index: 2; display: block; }
.slot { min-height: calc(var(--st-area) * .66); padding-bottom: 30svh; }
.slot:last-child { min-height: var(--st-area); padding-bottom: 0; }
.slot > .sec { position: sticky; top: var(--st-card); scroll-margin-top: var(--st-card); align-content: start;
  padding: var(--s-4) var(--s-4) var(--s-5); border: 1px solid color-mix(in srgb, var(--c) 30%, var(--line)); border-radius: 10px;
  background-color: var(--panel); background-image: var(--tex); background-size: 384px; background-blend-mode: soft-light;
  box-shadow: var(--lift), 0 0 0 1px rgba(0, 0, 0, .4), 0 30px 50px -26px rgba(0, 0, 0, .95); transform-origin: 50% 50%; }
/* farebná stuha oblasti na hornom okraji karty */
.slot > .sec::before { content: ""; position: absolute; left: 18px; right: 18px; top: -1px; height: 3px; border-radius: 0 0 3px 3px; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--c) 18% 82%, transparent); opacity: .85; }
/* rub karty: je vidieť len počas letu z balíčka */
.slot > .sec::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; opacity: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--c) 55%, #2a1a12) 0 9%, transparent 9.6%),
    radial-gradient(circle at 50% 50%, transparent 0 13%, rgba(227, 197, 138, .5) 13% 13.8%, transparent 14.4%),
    repeating-linear-gradient(45deg, rgba(227, 197, 138, .13) 0 2px, transparent 2px 22px), repeating-linear-gradient(-45deg, rgba(227, 197, 138, .13) 0 2px, transparent 2px 22px),
    linear-gradient(160deg, #4a2f22, #2a1a12 60%, #1d120c);
  box-shadow: inset 0 0 0 2px rgba(227, 197, 138, .6), inset 0 0 0 10px #22150e, inset 0 0 0 12px rgba(227, 197, 138, .3); }
.stage.is-live .slot > .sec { opacity: 0; pointer-events: none; }
.stage.is-live .slot.is-active > .sec { opacity: 1; pointer-events: auto; }
.stage .slot > .sec.is-drawing { animation: st-draw .7s both; pointer-events: none; }
.stage .slot > .sec.is-drawing::after { animation: st-back .7s linear both; }
.stage .slot > .sec.is-stowing { animation: st-stow .32s cubic-bezier(.5, 0, .8, .4) both; }
@keyframes st-draw {
  0% { opacity: 1; transform: translate(var(--dx), var(--dy)) perspective(1600px) rotateY(180deg) rotate(7deg) scale(var(--ds)); animation-timing-function: cubic-bezier(.3, .1, .6, 1); }
  52% { opacity: 1; transform: translate(calc(var(--dx) * .28), calc(var(--dy) * .3 - 26px)) perspective(1600px) rotateY(90deg) rotate(2deg) scale(calc(var(--ds) * .35 + .65)); animation-timing-function: cubic-bezier(.2, .8, .3, 1.15); }
  100% { opacity: 1; transform: translate(0, 0) perspective(1600px) rotateY(0deg) rotate(0deg) scale(1); }
}
@keyframes st-back { 0%, 51.9% { opacity: 1; } 52%, 100% { opacity: 0; } }
@keyframes st-stow { 0% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(var(--ds)) rotate(-5deg); } }

/* ---------- balíček: karty lícom nadol na hrane stola ---------- */
.deck { position: fixed; z-index: 15; left: 0; right: 0; bottom: var(--st-dock); height: var(--st-deck); display: flex; justify-content: center; align-items: flex-start;
  gap: clamp(3px, 1.1vw, 16px); padding: 10px 8px 0; --dw: clamp(34px, 10.2vw, 46px);
  background: linear-gradient(180deg, rgba(8, 6, 4, 0) 0, rgba(8, 6, 4, .82) 20%, #3a2917 26%, #2a1c11 31%, #1b120b 100%); }
.deck::before { content: ""; position: absolute; left: 0; right: 0; top: 26%; height: 1px; background: linear-gradient(90deg, transparent, rgba(240, 215, 159, .6) 12% 88%, transparent); }
.deck::after { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 34px; margin-bottom: -26%; pointer-events: none; background: linear-gradient(180deg, transparent, rgba(8, 6, 4, .7)); z-index: -1; }
.deck-card { --c: var(--gold); --r: 0deg; position: relative; flex: 0 1 var(--dw); width: var(--dw); min-width: 0; aspect-ratio: 5 / 7; padding: 0; border: 0; background: none; color: #efe2c4; font: inherit; cursor: pointer;
  perspective: 500px; transform: rotate(var(--r)); transition: transform .22s cubic-bezier(.3, 1.3, .5, 1); -webkit-tap-highlight-color: transparent; }
.deck-card:nth-child(4n + 1) { --r: -2.5deg; } .deck-card:nth-child(4n + 2) { --r: 1.5deg; } .deck-card:nth-child(4n + 3) { --r: -1deg; } .deck-card:nth-child(4n) { --r: 2.5deg; }
.deck-card:hover, .deck-card:focus-visible { transform: translateY(-7px) rotate(0deg); }
.deck-card[aria-current="true"] { transform: translateY(-11px) rotate(0deg); }
.deck-card:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 3px; }
.deck-flip { position: absolute; inset: 0; border-radius: 5px; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.3, .8, .3, 1); box-shadow: 0 8px 10px -5px rgba(0, 0, 0, .85); }
.deck-card.is-up .deck-flip { transform: rotateY(180deg); }
.deck-card.is-turning .deck-flip { animation: st-turn .65s cubic-bezier(.3, .8, .3, 1); }
@keyframes st-turn { 0% { transform: rotateY(0deg) translateY(0); } 45% { transform: rotateY(90deg) translateY(-12px); } 100% { transform: rotateY(180deg) translateY(0); } }
.deck-back, .deck-face { position: absolute; inset: 0; display: grid; place-items: center; border-radius: inherit; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
.deck-back { background: repeating-linear-gradient(45deg, rgba(227, 197, 138, .13) 0 1px, transparent 1px 6px), repeating-linear-gradient(-45deg, rgba(227, 197, 138, .13) 0 1px, transparent 1px 6px),
    linear-gradient(160deg, #50332a, #2c1b13 60%, #1d120c);
  box-shadow: inset 0 0 0 1px rgba(227, 197, 138, .62), inset 0 0 0 3px #22150e, inset 0 0 0 4px rgba(227, 197, 138, .26); }
.deck-emb { display: grid; place-items: center; width: 62%; aspect-ratio: 1; border-radius: 50%; color: var(--c); background: radial-gradient(circle, #1a110b 0 58%, color-mix(in srgb, var(--c) 34%, #1a110b) 60% 100%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 70%, transparent), 0 0 10px color-mix(in srgb, var(--c) 30%, transparent); }
.deck-emb .ico { width: 58%; height: 58%; }
.deck-face { transform: rotateY(180deg); align-content: center; gap: 0; color: #2b2118; background: linear-gradient(160deg, #f6ecd4, #e0cda3);
  box-shadow: inset 0 0 0 1px rgba(90, 65, 15, .6), inset 0 0 0 3px #f1e5c8, inset 0 0 0 4px color-mix(in srgb, var(--c) 55%, #5a410f); }
.deck-face .ico { width: 42%; height: auto; aspect-ratio: 1; stroke-width: 1.8; color: color-mix(in srgb, var(--c) 40%, #2b2118); }
.deck-face b { font-family: var(--f-display); font-weight: 700; font-size: clamp(11px, 3vw, 14px); line-height: 1.1; letter-spacing: -.02em; }
.deck-card[aria-current="true"] .deck-flip { box-shadow: 0 0 0 2px #f0d79f, 0 0 18px rgba(255, 205, 120, .65), 0 10px 12px -5px rgba(0, 0, 0, .85); }
.deck-name { display: none; }

/* plávajúce štítky (stopky, otvorený deň) a hlásenia ležia nad balíčkom */
body.on-dnes .timerpill, body.on-dnes .daypill, body.on-dnes .toast { bottom: calc(var(--st-dock) + var(--st-deck) + 10px); }
body.on-dnes:has(#timerpill-host) .daypill, body.on-dnes:has(#timerpill-host) .toast, body.on-dnes:has(.daypill) .toast { bottom: calc(var(--st-dock) + var(--st-deck) + 72px); }

/* nízke okno (mobil naležato): postava sa posúva so stránkou, balíček je nižší */
@media (max-height: 520px) and (max-width: 999px) {
  .stage-hero { position: relative; top: 0; }
  :root { --st-card: calc(var(--st-top) + 8px); }
}

/* ---------- desktop: postava vľavo cez celú výšku, vpravo lišta a karty ---------- */
@media (min-width: 1000px) {
  .stage { grid-template-columns: minmax(340px, 39%) minmax(0, 1fr); column-gap: var(--s-7); align-items: start; }
  .stage-hero { grid-column: 1; grid-row: 1 / span 2; top: calc(var(--st-top) + 14px); height: var(--st-hero); margin: 0; }
  .stage-gap, .stage-ledge { display: none; }
  .stage-scene, .stage-figwrap { inset: 0; clip-path: none !important; overflow: visible; }
  .stage-scene { background: radial-gradient(ellipse 62% 48% at 50% 56%, rgba(255, 186, 104, .17), transparent 72%); }
  .stage-light { top: -6%; width: 190%; height: 104%; }
  .stage-fig, .stage.is-down .stage-fig { top: auto; bottom: 26px; width: min(112%, calc((var(--st-hero) - 40px) * .728), 540px); translate: -50% 0; }
  .stage-ring { bottom: 14px; width: min(112%, 520px); height: 74px; box-shadow: inset 0 0 40px rgba(255, 190, 110, .14), 0 0 0 10px rgba(227, 197, 138, .05); }
  .stage-shadow { bottom: 36px; width: min(66%, 320px); height: 34px; }
  .stage .hero-bubble, .stage:not(.is-down) .hero-bubble { left: 60%; top: 3%; max-width: 230px; font-size: var(--fs-s); }
  .stage-intro, .stage .today { grid-column: 2; }
  .stage-intro { min-height: calc(var(--st-hero) * .92); padding-top: 14px; }
  .stage .vista { padding: var(--s-4) var(--s-5); gap: var(--s-4); }
  .stage .traits { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stage .trait { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto; justify-items: start; align-items: center; column-gap: 10px; row-gap: 2px; padding: 10px 12px; }
  .stage .trait-ico { grid-row: 1 / span 2; }
  .stage .trait-ico .ico { width: 26px; height: 26px; }
  .stage .trait-name { font-family: var(--f-display); font-size: var(--fs-xs); letter-spacing: .04em; text-align: left; }
  .stage .trait .pips { grid-column: 2; grid-row: 2; }
  .stage .trait-today { grid-column: 3; grid-row: 1 / span 2; font-family: var(--f-display); font-size: var(--fs-s); }
  .stage-hint { margin-top: var(--s-4); }
  .slot { min-height: calc(var(--st-hero) * .6); padding-bottom: 28svh; }
  .slot:last-child { min-height: calc(100svh - var(--st-card) - var(--st-deck) - 8px); }
  .slot > .sec { padding: var(--s-5) var(--s-5) var(--s-6); }
  .deck { left: var(--rail); --dw: 76px; gap: 18px; padding-top: 12px; }
  .deck-flip { border-radius: 7px; }
  .deck-face b { font-size: 1.15rem; }
  .deck-name { display: block; position: absolute; left: -12px; right: -12px; top: calc(100% + 3px); font-size: var(--fs-xs); line-height: 1.1; text-align: center; color: #cdbd9b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .deck-card[aria-current="true"] .deck-name { color: #f0d79f; }
  body.on-dnes .timerpill, body.on-dnes .daypill, body.on-dnes .toast { bottom: calc(var(--st-deck) + 14px); }
}

@media (prefers-reduced-motion: reduce) {
  .stage-scene, .stage-figwrap, .stage-fig, .stage-ledge, .deck-card, .deck-flip { transition: none; }
  .stage-hint i { animation: none; }
  .stage .hero-bubble, .stage .hero-bubble.is-out { animation: none; opacity: 1; transform: none; }
}
