/* ============================================================
   Sunday Manager - Learning App
   Lead design portovany z prototyp/index.html.
   3 typy screenov: mood (text+ken-burns), interactive (placeholder
   karta), chatbot (rainbow buttony).
   ============================================================ */

@font-face {
  font-family: 'Apotek';
  src: url('../visual-assets/ApotekComp_Black.otf') format('opentype');
  font-display: swap;
}
@font-face {
  font-family: 'NotoCond';
  src: url('../visual-assets/NotoSans_ExtraCondensedBold.otf') format('opentype');
  font-display: swap;
}

:root {
  --bg: #1c1430;
  --accent: #ffcf00;
  --accent2: #f5d000;
  --ink: #f4f1ea;
  --dim: rgba(255,255,255,.55);
  --panel: #3f9d96;
  --chat-bg: #241a36;
  --chat-bubble: #2c2740;
  /* fixny stack hore: topbar (chapter + progress) a pod nim headline pas */
  --top-stack: calc(env(safe-area-inset-top, 0px) + 82px);
  --hl-reserve: 104px;
  --content-top: calc(var(--top-stack) + var(--hl-reserve));
  --foot-stack: calc(env(safe-area-inset-bottom, 0px) + 72px); /* vyska footera pre spodny fade */
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg); /* pozadie rieoi fixna vrstva #bg (mimo masky feedu) */
  color: var(--ink);
  font-family: 'NotoCond', 'Noto Sans', sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}
.hidden { display: none !important; }

h1, h2 {
  font-family: 'Apotek', sans-serif;
  font-weight: normal;  /* Apotek ma 1 vahu; h1/h2 default bold by faux-zhrubol */
  text-transform: uppercase;
  line-height: .9;
  letter-spacing: .5px;
}
/* jednotny headline napriec appkou (zhodny s prototypom header h1) */
.screen h2 { font-size: min(10vw, 3.5rem); color: #fff; }

/* placeholder helper badge */
.ph-note {
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  font-family: 'NotoCond', sans-serif;
  font-size: .62rem;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: rgba(255,255,255,.5);
  background: rgba(0,0,0,.35);
  padding: 3px 8px;
  border-radius: 999px;
}

/* ===== Fixna vrstva pozadia (mimo feedu, takze ju maska feedu netyka) =====
   ken-burns table + scrim, ktory sa meni podla typu aktualneho screenu */
#bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
/* 2 vrstvy na crossfade medzi pozadiami (art per mood / table fallback) */
.bg-layer {
  position: absolute; inset: 0;
  background: url('../visual-assets/table-bcg3.jpg') center / cover no-repeat;
  /* okamzity start (ease-out), len zoom in, potom stop a drz koncovy stav */
  animation: kenburns 30s ease-out forwards;
  will-change: transform, opacity;
  opacity: 0;
  transition: opacity .5s ease;
}
#bgA { opacity: 1; } /* startovacia vrstva */
@keyframes kenburns {
  0%   { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.12) translate(-1.5%, -2%); }
}
.bg-scrim {
  position: absolute; inset: 0;
  background: transparent;
  transition: background .45s ease;
}
/* silnejsi zhora (headline) aj zdola (caption/text), svetlejsi v strede (art vidno) */
.bg-scrim.mode-mood { background: linear-gradient(180deg, rgba(12,8,22,.88) 0%, rgba(12,8,22,.5) 12%, rgba(12,8,22,.30) 26%, rgba(12,8,22,.46) 50%, rgba(12,8,22,.82) 72%, rgba(12,8,22,.96) 100%); }
.bg-scrim.mode-interactive { background: rgba(12,8,22,.12); }
.bg-scrim.mode-chatbot { background: var(--chat-bg); }

/* ===== Landing ===== */
.landing {
  position: fixed; inset: 0;
  z-index: 40;
  display: flex; flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
}
.landing-bg {
  position: absolute; inset: 0;
  background: url('../visual-assets/table-bcg3.jpg') center / cover no-repeat;
  animation: kenburns 22s ease-in-out infinite alternate;
}
.landing::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(12,8,22,.35) 0%, rgba(12,8,22,.6) 50%, rgba(12,8,22,.96) 100%);
}
.landing-inner {
  position: relative; z-index: 2;
  padding: 0 26px calc(env(safe-area-inset-bottom, 0px) + 46px);
  max-width: 560px; margin: 0 auto; width: 100%;
}
.landing-kicker {
  font-family: 'NotoCond', sans-serif;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--accent); font-size: .95rem; margin-bottom: 10px;
}
.landing h1 { font-size: clamp(2.6rem, 13vw, 4rem); color: #fff; }
.landing p { margin: 14px 0 26px; font-size: clamp(1.05rem, 4.6vw, 1.25rem); font-weight: bold; color: var(--ink); }
.landing-hint { margin-top: 16px; color: var(--dim); font-size: .9rem; text-transform: uppercase; letter-spacing: .5px; }

.btn-primary {
  font-family: 'Apotek', sans-serif;
  text-transform: uppercase; letter-spacing: .5px;
  font-size: 1.5rem;
  background: var(--accent2); color: #161616;
  border: none; border-radius: 12px;
  padding: 14px 40px; cursor: pointer;
  box-shadow: 0 8px 22px rgba(0,0,0,.4);
  transition: transform .15s;
}
.btn-primary:active { transform: scale(.97); }

/* ===== Top bar (zhodny s prototypom: modName nad 28px barber progressom) ===== */
#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 20;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 22px 6px;
  max-width: 520px; margin: 0 auto;
  text-align: center;
  pointer-events: none;
}
.chapter-name {
  font-family: 'NotoCond', sans-serif;
  text-transform: uppercase; letter-spacing: .5px;
  font-size: clamp(.84rem, 3.92vw, 1.015rem);
  line-height: 1; color: #fff;
  margin-bottom: 10px;
  height: 1em;       /* fixna vyska 1 riadku, aby dvojriadkovy roll neblikol */
  overflow: hidden;  /* clip pre roll animaciu nazvu kapitoly */
}
.cn-inner { display: block; will-change: transform; }
.cn-line { display: block; line-height: 1; height: 1em; } /* fixna vyska aj pre prazdny riadok (inak roll preskoci) */
.progress {
  height: 28px; border-radius: 999px;
  background: rgba(255,255,255,.38); overflow: hidden;
}
.progress .fill {
  position: relative; height: 100%; width: 0;
  border-radius: inherit; overflow: hidden;
  transition: width .4s cubic-bezier(.4,.9,.3,1);
}
.progress .fill::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: -66px;
  width: calc(100% + 66px);
  background: repeating-linear-gradient(60deg, #ffd400 0 14px, #ff9d00 14px 28px);
  animation: barber 1.8s linear infinite;
}
@keyframes barber { to { transform: translateX(32.33px); } }

/* intro pri prvom nacitani: progress bar sa odroluje zlava, caption fade-in */
#topbar.intro .progress { animation: progWipe .7s cubic-bezier(.4,.9,.3,1) both; }
@keyframes progWipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.screen.intro .body, .screen.intro .scene-caption { animation: capFade .8s ease .25s both; }
@keyframes capFade { from { opacity: 0; } to { opacity: 1; } }

/* ===== Feed (scroll-snap) ===== */
.feed {
  position: relative; z-index: 1; /* nad fixnou vrstvou #bg */
  height: 100dvh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  /* fade-out hore (pod headlinom) aj dole (pred footerom): content sa pri swipe-i
     rozplynie, nech nie je vidno ako ide poza headline/progress ani za footer */
  -webkit-mask-image: linear-gradient(to bottom,
    transparent calc(var(--content-top) - 64px),
    #000 var(--content-top),
    #000 calc(100% - var(--foot-stack) - 24px),
    transparent calc(100% - var(--foot-stack)));
          mask-image: linear-gradient(to bottom,
    transparent calc(var(--content-top) - 64px),
    #000 var(--content-top),
    #000 calc(100% - var(--foot-stack) - 24px),
    transparent calc(100% - var(--foot-stack)));
}
.feed::-webkit-scrollbar { display: none; }

.screen {
  position: relative;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ===== Fixny headline pas (mimo feedu, pod topbarom) =====
   Headline sa pri prepnuti screenu nehybe so scrollom; maskou sa
   zaroluje dolava (vymaze) a vyroluje doprava (novy text). */
.headline-band {
  position: fixed; left: 0; right: 0;
  top: var(--top-stack);
  z-index: 19;
  text-align: center;
  padding: 6px 22px 0;
  pointer-events: none;
}
.hl-inner {
  display: inline-block;
  font-family: 'Apotek', sans-serif;
  text-transform: uppercase; line-height: .9; letter-spacing: .5px;
  font-size: min(10vw, 3.5rem); color: #fff;
  max-width: 520px;
  clip-path: inset(0 0 0 0);
  transition: clip-path .42s cubic-bezier(.5, .05, .25, 1);
}
.hl-inner.rolled { clip-path: inset(0 100% 0 0); } /* zaroleny dolava = skryty */

/* ===== MOOD screen: text dole, zarovnany vlavo ===== */
.screen.mood { justify-content: flex-end; }
.screen.mood .body {
  position: relative; z-index: 2;
  padding: 0 26px calc(env(safe-area-inset-bottom, 0px) + 96px);
  max-width: 560px; width: 100%; margin: 0 auto;
  text-align: center;
  font-size: clamp(1.02rem, 4.4vw, 1.18rem); line-height: 1.2; font-weight: bold; color: var(--ink);
}
/* mensia medzera medzi odstavcami (namiesto celeho prazdneho riadku) */
.pgap { display: block; height: 1.2em; }

/* ===== INTERACTIVE screen: karta v strede medzi headlinom a footerom ===== */
.screen.interactive { align-items: center; padding-top: var(--content-top); }
.screen.interactive .stage {
  position: relative; z-index: 2;
  flex: 1; width: 100%;
  display: flex; align-items: center; justify-content: center;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 80px);
  transform: translateY(-2vh); /* posun karty/interaktivnych prvkov o 2vh hore */
}
/* interaktivny screen s popisom pod scenou (napr. c0s2):
   scena (placeholder) sa zmensi podla dostupnej vysky, nech sa vsetko zmesti */
.screen.interactive.has-caption .stage { padding-bottom: 0; min-height: 0; }
.screen.interactive.has-caption .card-ph {
  width: auto; height: 100%; max-height: 46vh;
  aspect-ratio: 745 / 1041;
}
.scene-caption {
  position: relative; z-index: 2;
  text-align: center;
  max-width: 520px; width: 100%; margin: 0 auto;
  padding: 0 26px calc(env(safe-area-inset-bottom, 0px) + 96px); /* zhodna spodna hrana s mood textom */
  white-space: pre-line; /* zachova zlom odstavca */
  font-size: clamp(1.02rem, 4.4vw, 1.18rem); line-height: 1.2; font-weight: bold; color: var(--ink);
}
.card-ph {
  position: relative;
  width: min(72vw, 340px, 52vh);
  aspect-ratio: 745 / 1041;
  border-radius: 14px;
  border: 2px dashed rgba(255,255,255,.35);
  background: rgba(255,255,255,.06);
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  box-shadow: 0 14px 28px rgba(0,0,0,.5);
}
.card-ph.real { border: none; background: none; box-shadow: none; }
.card-ph.real img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 14px 28px rgba(0,0,0,.5)); }
.card-ph .ph-label {
  font-family: 'NotoCond', sans-serif;
  text-transform: uppercase; letter-spacing: .5px;
  color: rgba(255,255,255,.7); font-size: .95rem; padding: 0 14px;
}
.tap-hint {
  position: relative; z-index: 2;
  margin: 0 auto calc(env(safe-area-inset-bottom, 0px) + 108px);
  color: var(--dim); font-size: .82rem;
  text-transform: uppercase; letter-spacing: .5px;
}

/* ===== CHATBOT screen (pozadie rieoi #bg scrim mode-chatbot) ===== */
.screen.chatbot {
  align-items: center;
}
.chat {
  flex: 1; width: 100%; max-width: 540px;
  padding: 8px 18px calc(env(safe-area-inset-bottom, 0px) + 116px);
  padding-top: var(--content-top);
  overflow-y: auto; scrollbar-width: none;
  display: flex; flex-direction: column; gap: 12px;
}
.chat::-webkit-scrollbar { display: none; }
.msg { display: flex; align-items: flex-end; gap: 8px; max-width: 88%; }
.msg .av { width: 34px; height: 34px; border-radius: 50%; border: 2px solid #fff; flex: none; object-fit: cover; }
.msg .bubble {
  background: var(--chat-bubble); color: var(--ink);
  padding: 10px 13px; border-radius: 14px;
  font-size: 1rem; line-height: 1.3;
}
.msg.user { align-self: flex-end; }
.msg.user .bubble { background: var(--accent2); color: #161616; border-bottom-right-radius: 4px; }
.msg.waldo .bubble { border-bottom-left-radius: 4px; }

.chat-options { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

/* rotating cropped rainbow button (port z fan-journey chatbot) */
@property --angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
@keyframes rotate-border { from { --angle: 0deg; } to { --angle: 360deg; } }
.opt-rainbow {
  position: relative;
  font-family: 'NotoCond', sans-serif;
  font-size: 1.02rem; letter-spacing: .3px;
  color: #fff; cursor: pointer;
  background: var(--chat-bubble);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 13px 16px; text-align: left;
}
.opt-rainbow::before {
  content: ''; position: absolute; inset: -2px;
  border-radius: 12px; border: 2px solid transparent;
  background:
    linear-gradient(var(--chat-bubble), var(--chat-bubble)) padding-box,
    conic-gradient(from var(--angle),
      transparent 0%, #ff5d5d 5%, #ffcf00 11%, #5ed4ff 17%, #b06bff 22%, transparent 27%) border-box;
  animation: rotate-border 4s linear infinite;
  pointer-events: none; z-index: -1;
}
.opt-rainbow:active { transform: scale(.98); }
.chat-cont {
  align-self: center;
  margin-top: 6px;
  font-family: 'NotoCond', sans-serif;
  text-transform: uppercase; letter-spacing: .5px;
  font-size: .8rem; color: var(--dim);
}

/* ===== Footer ===== */
#footer {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 22;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 0 18px calc(env(safe-area-inset-bottom, 0px) + 18px);
}
.fbtn {
  width: 54px; height: 54px; border-radius: 50%;
  background: #fff; border: none; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.fbtn span { display: block; width: 23px; height: 4px; border-radius: 1px; background: #111; transition: transform .35s cubic-bezier(.22,.9,.3,1), opacity .25s, background .35s; }
#burger.open { background: #161616; }
#burger.open span { background: #fff; }
#burger.open span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
#burger.open span:nth-child(2) { opacity: 0; }
#burger.open span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

.waldoBtn { position: relative; background: transparent; box-shadow: none; overflow: visible; filter: drop-shadow(0 6px 18px rgba(0,0,0,.35)); }
.waldoFace {
  position: relative; z-index: 2; width: 54px; height: 54px;
  border-radius: 50%; border: 3px solid #fff; background: #fff;
  object-fit: cover; pointer-events: none;
  /* attention wiggle synchronny s labelom (zhodne s prototypom) */
  animation: waldoWiggle 26.2s ease-in-out 2s infinite;
}
@keyframes waldoWiggle {
  0%    { transform: rotate(0); }
  0.6%  { transform: rotate(-9deg); }
  1.3%  { transform: rotate(7deg); }
  1.9%  { transform: rotate(-4deg); }
  2.6%  { transform: rotate(2deg); }
  3.2%  { transform: rotate(0); }
  100%  { transform: rotate(0); }
}
.waldoLabelWrap { position: absolute; z-index: 1; top: 50%; right: 24px; transform: translateY(-50%); overflow: hidden; }
.waldoLabel {
  display: block; background: #fff; color: #15182b;
  font-family: 'Apotek', sans-serif; font-weight: normal; text-transform: uppercase;
  font-size: 1.1rem; letter-spacing: .5px;
  line-height: 1; white-space: nowrap;
  padding: 8px 34px 8px 12px; border-radius: 8px;
  transform: translateX(100%);
  animation: labelLoop 26.2s cubic-bezier(.45,.05,.25,1) 2s infinite both;
}
/* zhodne s prototypom: 0.6s vysun, ~5s zobrazeny, 0.6s zasun, ~20s pauza */
@keyframes labelLoop {
  0%    { transform: translateX(100%); }
  2.3%  { transform: translateX(0); }
  21.4% { transform: translateX(0); }
  23.7% { transform: translateX(100%); }
  100%  { transform: translateX(100%); }
}

/* SWIPE UP label v strede footera, fade synchronny s Ask Waldo labelom:
   ked Waldo vychadza (2.3%) -> swipe fade na 0, ked sa vracia (23.5%) -> spat na 1 */
.swipe-label {
  align-self: center;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-family: 'Apotek', sans-serif;
  text-transform: uppercase; letter-spacing: 1px;
  font-size: 1rem; color: #fff;
  pointer-events: none; white-space: nowrap;
  transform: translateY(4px); /* cely element o 4px nizsie */
  animation: swipeFade 26.2s cubic-bezier(.45,.05,.25,1) 2s infinite both;
}
/* dvojita sipka hore nad textom, jemny bounce pre intuitivnost */
.swipe-label .chev { color: #fff; margin-top: -4px; animation: chevBounce 1.8s ease-in-out infinite; }
@keyframes chevBounce {
  0%, 100% { transform: translateY(1px); }
  50%      { transform: translateY(-1px); }
}
@keyframes swipeFade {
  0%    { opacity: 1; }
  2.3%  { opacity: 0; }
  21.4% { opacity: 0; }
  23.7% { opacity: 1; }
  100%  { opacity: 1; }
}

/* ===== Drawer ===== */
.menuBack, .waldoBack {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 24;
}
.menuBack.show, .waldoBack.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: min(80vw, 320px);
  background: #fff; color: #1d1d1b;
  border-radius: 0 18px 18px 0;
  padding: 26px 20px calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-105%);
  transition: transform .35s cubic-bezier(.22,.9,.3,1);
  z-index: 25; display: flex; flex-direction: column; overflow-y: auto;
}
.drawer.show { transform: translateX(0); }
.drawer h2 { font-family: 'Apotek', sans-serif; font-size: 1.5rem; text-transform: uppercase; margin-bottom: 14px; color: #111; }
.drawer a, .drawer button.chap {
  font-family: 'NotoCond', sans-serif; font-size: 1rem; text-align: left;
  color: #3d4145; text-decoration: none; background: none; border: none; cursor: pointer;
  padding: 11px 8px; border-radius: 10px; display: flex; gap: 10px; align-items: baseline;
}
.drawer button.chap .num { color: var(--panel); font-family: 'Apotek', sans-serif; }
.drawer button.chap.active { background: #f1efe9; color: #111; }
.drawer button.chap:active, .drawer a:active { background: #f1efe9; }
.drawer .sep { height: 1px; background: #e6e3da; margin: 12px 0; }

/* ===== Ask Waldo sheet ===== */
.waldoSheet {
  position: fixed; left: 50%; bottom: 0;
  transform: translate(-50%, 110%);
  width: min(94vw, 460px);
  background: #161616; color: var(--ink);
  border-radius: 18px 18px 0 0;
  padding: 22px 22px calc(env(safe-area-inset-bottom, 0px) + 92px);
  z-index: 26; transition: transform .4s cubic-bezier(.22,.9,.3,1);
  box-shadow: 0 -10px 30px rgba(0,0,0,.5);
  text-align: center;
}
.waldoSheet.show { transform: translate(-50%, 0); }
.waldoSheetFace { width: 60px; height: 60px; border-radius: 50%; border: 3px solid #fff; margin-bottom: 12px; }
.waldoSheet p { font-size: 1.08rem; line-height: 1.35; font-weight: bold; }
