/* Úvodní příběh – pohádková kniha (public/tv/src/book.js) */
.book-ov {
  --ph: min(78vh, 62vw);            /* výška stránky */
  --pw: calc(var(--ph) / 1.36);     /* šířka stránky */
  --m: calc(var(--ph) * .022);      /* přesah desek */
  --ink: #3b2410; --rubric: #8e1f1c; --gold: #d9a84a;
  position: fixed; inset: 0; z-index: 60; overflow: hidden; pointer-events: none;
  background: rgba(12, 7, 3, .42);
  animation: bkDim 1.2s ease-out both;
}
@keyframes bkDim { from { background: rgba(12, 7, 3, 0); } }
/* svit svíček: teplé světlo uprostřed, tmavé okraje, jemné mihotání */
.book-light { position: absolute; inset: -5%;
  background: radial-gradient(ellipse 52% 56% at 50% 50%, rgba(255, 190, 110, .20), rgba(255, 150, 60, .06) 45%, rgba(20, 9, 2, .62) 72%, rgba(6, 3, 1, .93) 100%);
  animation: bkFlicker 4.2s ease-in-out infinite alternate; }
@keyframes bkFlicker { 0% { opacity: .94; transform: scale(1); } 30% { opacity: 1; } 55% { opacity: .9; transform: scale(1.012); } 80% { opacity: .98; } 100% { opacity: .92; transform: scale(1.004); } }
.book-motes i { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #ffd98a; box-shadow: 0 0 8px 2px rgba(255, 200, 110, .6);
  opacity: 0; animation: bkMote 9s ease-in-out infinite; }
@keyframes bkMote { 0% { opacity: 0; transform: translate(0, 0); } 20% { opacity: .7; } 80% { opacity: .5; } 100% { opacity: 0; transform: translate(30px, -120px); } }

.book-stage { position: absolute; left: 50%; top: 47%; width: calc(var(--pw) * 2); height: var(--ph);
  transform: translate(-50%, -50%); perspective: 2600px; perspective-origin: 50% 30%; }
.book-shadow { position: absolute; left: 4%; right: 4%; bottom: calc(var(--ph) * -.06); height: calc(var(--ph) * .1);
  background: radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, .7), transparent 70%); filter: blur(10px);
  opacity: 0; transform: scale(.4); transition: opacity .8s, transform .8s; }
.landed .book-shadow { opacity: 1; transform: scale(1); }

.book-fly { position: absolute; inset: 0; transform-style: preserve-3d; opacity: 0; }
.flying .book-fly, .landed .book-fly, .still .book-fly { opacity: 1; }
.flying .book-fly { animation: bkFly 2.3s cubic-bezier(.18, .75, .25, 1) both; }
@keyframes bkFly {
  0%   { opacity: 0; transform: translate3d(28vw, -95vh, -1600px) rotateX(70deg) rotateY(-50deg) rotateZ(-38deg) scale(.5); }
  12%  { opacity: 1; }
  55%  { transform: translate3d(4vw, -14vh, -300px) rotateX(35deg) rotateY(-10deg) rotateZ(-10deg) scale(.85); }
  80%  { transform: translate3d(-.6vw, 1.4vh, 60px) rotateX(-4deg) rotateY(3deg) rotateZ(2deg) scale(1.02); }
  92%  { transform: translate3d(0, -.4vh, 0) rotateX(1deg) rotateZ(-.5deg); }
  100% { opacity: 1; transform: none; }
}

/* ---------- kniha ---------- */
.book { position: absolute; inset: 0; transform-style: preserve-3d;
  transform: rotateX(9deg) translateX(-25%); transition: transform 2s cubic-bezier(.45, .05, .25, 1); }
.book.open { transform: rotateX(9deg) translateX(0); }
.still .book { transition: none; }
.board, .cv-front, .cv-back { background:
    radial-gradient(ellipse at 30% 25%, rgba(255, 170, 160, .16), transparent 55%),
    repeating-radial-gradient(circle at 20% 30%, rgba(0, 0, 0, .05) 0 2px, transparent 2px 5px),
    radial-gradient(ellipse at 50% 50%, #7e1c2e 0%, #5c1222 60%, #3a0914 100%);
  box-shadow: inset 0 0 calc(var(--ph) * .05) rgba(0, 0, 0, .55); }
.board { position: absolute; left: 50%; top: calc(var(--m) * -1); width: calc(var(--pw) + var(--m)); height: calc(var(--ph) + var(--m) * 2);
  border-radius: 0 10px 10px 0; transform: translateZ(-3px);
  box-shadow: inset 0 0 calc(var(--ph) * .05) rgba(0, 0, 0, .55), 0 26px 50px rgba(0, 0, 0, .6); }

.pg { position: absolute; width: var(--pw); height: var(--ph); color: var(--ink); overflow: hidden;
  background:
    radial-gradient(ellipse 40% 30% at 78% 84%, rgba(150, 100, 40, .10), transparent 70%),
    radial-gradient(ellipse 30% 22% at 18% 16%, rgba(150, 100, 40, .08), transparent 70%),
    radial-gradient(ellipse at 50% 42%, #fbf2d8 0%, #f3e3ba 55%, #e2c58c 100%); }
.pg-right { left: 50%; top: 0; border-radius: 0 6px 6px 0;
  box-shadow: 2px 2px 0 #eadbb2, 4px 4px 0 #d8c08c, 6px 6px 0 #ecdcb4, 8px 7px 0 #cdb27c, 10px 8px 0 #4a0d1a; }
.pg-right::after, .pg-left::after, .leaf .face::after { content: ''; position: absolute; inset: 0; pointer-events: none; }
.pg-right::after, .leaf .front::after { background: linear-gradient(90deg, rgba(70, 40, 10, .42), rgba(70, 40, 10, .12) 6%, transparent 14%); }
.pg-left::after, .leaf .back::after { background: linear-gradient(270deg, rgba(70, 40, 10, .42), rgba(70, 40, 10, .12) 6%, transparent 14%); }

/* desky: přední strana (kůže, zlatý rám, název) a vnitřní strana s levou stránkou */
.cover { position: absolute; left: 50%; top: calc(var(--m) * -1); width: calc(var(--pw) + var(--m)); height: calc(var(--ph) + var(--m) * 2);
  transform-origin: 0 50%; transform-style: preserve-3d; transform: translateZ(4px) rotateY(0deg);
  transition: transform 2s cubic-bezier(.5, .05, .3, 1); }
.book.open .cover { transform: translateZ(1px) rotateY(-180deg); }
.cv-front, .cv-back { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 0 10px 10px 0; }
.cv-back { transform: rotateY(180deg); border-radius: 10px 0 0 10px; }
.cv-back .pg-left { right: 0; top: var(--m); border-radius: 6px 0 0 6px;
  box-shadow: -2px 2px 0 #eadbb2, -4px 4px 0 #d8c08c, -6px 5px 0 #4a0d1a; }
.cv-front { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--gold);
  box-shadow: inset 0 0 calc(var(--ph) * .05) rgba(0, 0, 0, .55), inset calc(var(--ph) * .035) 0 calc(var(--ph) * .02) -4px rgba(0, 0, 0, .55), 0 20px 40px rgba(0, 0, 0, .5); }
.cv-front::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--ph) * .045);
  background: repeating-linear-gradient(180deg, transparent 0 14%, rgba(255, 210, 120, .35) 14% 15%, rgba(0, 0, 0, .35) 15% 16.5%, transparent 16.5% 25%),
    linear-gradient(90deg, rgba(0, 0, 0, .5), rgba(255, 255, 255, .06) 60%, rgba(0, 0, 0, .3)); }
.cv-frame { position: absolute; inset: calc(var(--ph) * .045) calc(var(--ph) * .04) calc(var(--ph) * .045) calc(var(--ph) * .075);
  border: 3px solid rgba(217, 168, 74, .85); outline: 1px solid rgba(217, 168, 74, .55); outline-offset: 6px; border-radius: 4px; }
.cv-front .cn { color: var(--gold); width: calc(var(--ph) * .09); height: calc(var(--ph) * .09); }
.cv-front .cn.tl, .cv-front .cn.bl { left: calc(var(--ph) * .085); }
.cv-front .cn.tl, .cv-front .cn.tr { top: calc(var(--ph) * .055); }
.cv-front .cn.tr, .cv-front .cn.br { right: calc(var(--ph) * .05); }
.cv-front .cn.bl, .cv-front .cn.br { bottom: calc(var(--ph) * .055); }
.cv-eyebrow { font-family: Cinzel, serif; letter-spacing: .32em; text-transform: uppercase; font-size: calc(var(--ph) * .022); opacity: .85; margin-left: calc(var(--ph) * .03); }
.cv-title { margin: calc(var(--ph) * .025) calc(var(--ph) * .07) calc(var(--ph) * .02) calc(var(--ph) * .1); font-family: Cinzel, serif; font-weight: 800;
  font-size: calc(var(--ph) * .074); line-height: 1.05; letter-spacing: .03em;
  background: linear-gradient(180deg, #fff3c4 0%, #f2c96a 40%, #b77d22 75%, #f6d98a 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 rgba(40, 6, 12, .9)) drop-shadow(0 0 10px rgba(255, 190, 90, .25)); }
.cv-emblem { width: calc(var(--ph) * .2); height: calc(var(--ph) * .2); margin: calc(var(--ph) * .015) 0 0 calc(var(--ph) * .03); filter: drop-shadow(0 2px 0 rgba(40, 6, 12, .8)); }
.cv-sub { margin: calc(var(--ph) * .03) calc(var(--ph) * .08) 0 calc(var(--ph) * .11); font-family: 'EB Garamond', Georgia, serif; font-style: italic;
  font-size: calc(var(--ph) * .03); color: #f0d49a; opacity: .9; }

/* ---------- obsah stránek ---------- */
.pg-in { position: absolute; inset: calc(var(--ph) * .05) calc(var(--ph) * .055); display: flex; flex-direction: column; overflow: hidden;
  padding: calc(var(--ph) * .035) calc(var(--ph) * .03) calc(var(--ph) * .055); }
.pg-in::before { content: ''; position: absolute; inset: 0; border: 2px solid rgba(110, 60, 20, .55); outline: 1px solid rgba(142, 31, 28, .4); outline-offset: -7px; pointer-events: none; }
.cn { position: absolute; width: calc(var(--ph) * .06); height: calc(var(--ph) * .06); color: #7a4a1c; display: block; }
.cn svg { width: 100%; height: 100%; display: block; }
.pg .cn.tl { left: -6px; top: -6px; } .pg .cn.tr { right: -6px; top: -6px; transform: scaleX(-1); }
.pg .cn.bl { left: -6px; bottom: -6px; transform: scaleY(-1); } .pg .cn.br { right: -6px; bottom: -6px; transform: scale(-1, -1); }
.cv-front .cn.tr { transform: scaleX(-1); } .cv-front .cn.bl { transform: scaleY(-1); } .cv-front .cn.br { transform: scale(-1, -1); }
.chap { font-family: Cinzel, serif; font-weight: 600; text-align: center; letter-spacing: .3em; text-transform: uppercase; color: var(--rubric);
  font-size: calc(var(--ph) * .021); margin-top: calc(var(--ph) * .02); }
.pg-head { margin: calc(var(--ph) * .012) 0 0; text-align: center; font-family: Cinzel, serif; font-weight: 800; color: #4a2410;
  font-size: calc(var(--ph) * .048); line-height: 1.12; text-shadow: 0 1px 0 rgba(255, 245, 210, .8); }
.divider { width: 62%; height: calc(var(--ph) * .028); margin: calc(var(--ph) * .018) auto; display: block; }
.pg-art { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.art-svg { width: 94%; max-height: 100%; filter: drop-shadow(0 1px 0 rgba(255, 240, 200, .6)); }
.party { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: calc(var(--ph) * .022) calc(var(--ph) * .03); width: 100%; }
.medal { display: flex; flex-direction: column; align-items: center; width: calc(var(--ph) * .16); text-align: center; }
.medal img { width: calc(var(--ph) * .13); height: calc(var(--ph) * .13); border-radius: 50%; object-fit: cover;
  border: 4px double #a7772c; box-shadow: 0 0 0 3px #f3e3ba, 0 0 0 5px rgba(142, 31, 28, .55), 0 6px 12px rgba(60, 30, 5, .35); filter: sepia(.25) saturate(.9); }
.party.n4 { padding: 0 12%; }
.party.n5 .medal img, .party.n6 .medal img { width: calc(var(--ph) * .11); height: calc(var(--ph) * .11); }
.medal b { margin-top: calc(var(--ph) * .012); font-family: Cinzel, serif; font-size: calc(var(--ph) * .024); color: #4a2410; }
.medal span { font-family: 'EB Garamond', Georgia, serif; font-style: italic; font-size: calc(var(--ph) * .019); color: #6b4520; }
.folio { position: absolute; left: 0; right: 0; bottom: calc(var(--ph) * .018); text-align: center; font-family: 'EB Garamond', Georgia, serif;
  font-style: italic; font-size: calc(var(--ph) * .02); color: #7a5228; }
.txt { font-family: 'EB Garamond', Georgia, 'Times New Roman', serif; font-size: calc(var(--ph) * .0345); line-height: 1.42; text-align: justify;
  hyphens: auto; -webkit-hyphens: auto; color: var(--ink); margin-top: calc(var(--ph) * .012); }
/* iluminovaná iniciála */
.initial { float: left; width: 1.95em; height: 1.95em; margin: .12em .32em .05em 0; position: relative; font-size: 1.62em; line-height: 1;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 220, 140, .25), transparent 50%),
    repeating-linear-gradient(45deg, rgba(255, 210, 120, .14) 0 2px, transparent 2px 7px),
    linear-gradient(160deg, #a52a2e, #6d1420);
  border: 3px double #d9a84a; border-radius: 3px; box-shadow: 0 2px 5px rgba(60, 20, 5, .4), inset 0 0 8px rgba(0, 0, 0, .35); }
.initial span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: Cinzel, serif; font-weight: 800;
  font-size: 1.35em; background: linear-gradient(180deg, #fff3c4, #e8b856 55%, #a8701c); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 1px 0 rgba(40, 6, 12, .9)); }
.finis { margin-top: auto; text-align: center; font-family: 'EB Garamond', Georgia, serif; font-style: italic; color: var(--rubric); font-size: calc(var(--ph) * .025); }
.finis .divider { margin-bottom: calc(var(--ph) * .006); }

/* ---------- listování ---------- */
.leaf { position: absolute; left: 50%; top: 0; width: var(--pw); height: var(--ph); transform-origin: 0 50%; transform-style: preserve-3d;
  transform: translateZ(2px) rotateY(0deg); transition: transform 1.4s cubic-bezier(.45, .05, .3, 1); }
.leaf.go { transform: translateZ(2px) rotateY(-180deg); }
.leaf .face { position: absolute; left: 0; top: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.leaf .back { transform: rotateY(180deg); }
.leaf .face::before { content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none; background: linear-gradient(90deg, rgba(60, 30, 5, 0), rgba(60, 30, 5, .35));
  opacity: 0; animation: bkLeafShade 1.4s ease-in-out; }
@keyframes bkLeafShade { 50% { opacity: 1; } }
.book.flipping .pg-right .pg-in { animation: bkUnder 1.4s ease-in-out; }
@keyframes bkUnder { 0% { filter: brightness(.7); } 100% { filter: none; } }
.book.fade .pg-in { opacity: 0; transition: opacity .25s; }
.pg-in { transition: opacity .35s; }

/* ---------- jiskry ---------- */
.trail i, .burst i { position: absolute; width: 10px; height: 10px; margin: -5px; pointer-events: none;
  background: radial-gradient(circle, #fffbe0 0 20%, #ffd36a 35%, rgba(255, 180, 60, 0) 70%);
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%); transform: scale(var(--s, 1)); opacity: 0; }
.flying:not(.landed) .trail i { animation: bkTwinkle 1.1s ease-in-out infinite; }
@keyframes bkTwinkle { 0%, 100% { opacity: 0; transform: scale(calc(var(--s) * .3)) rotate(0deg); } 50% { opacity: 1; transform: scale(calc(var(--s) * 2)) rotate(45deg); } }
.burst { position: absolute; left: 50%; top: 50%; }
.landed .burst i { animation: bkBurst 1.3s cubic-bezier(.1, .7, .3, 1) both; }
@keyframes bkBurst {
  0% { opacity: 1; transform: rotate(var(--a)) translateX(0) scale(calc(var(--s) * 2.4)); }
  100% { opacity: 0; transform: rotate(var(--a)) translateX(var(--d)) scale(calc(var(--s) * .4)); }
}
.still .burst, .still .trail { display: none; }

/* ---------- pata ---------- */
.book-foot { position: absolute; left: 50%; bottom: 2.2vh; transform: translateX(-50%); display: flex; align-items: center; gap: 18px;
  padding: 10px 24px; border-radius: 999px; background: rgba(30, 16, 8, .78); border: 1px solid rgba(217, 168, 74, .55);
  font-family: 'EB Garamond', Georgia, serif; font-size: 22px; color: #f0dcb0; opacity: 0; transition: opacity .8s; white-space: nowrap; }
.book-foot b { color: #ffd98a; font-weight: 600; }
.opened .book-foot { opacity: 1; }
.dots { display: flex; gap: 8px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid #d9a84a; }
.dots i.past { background: rgba(217, 168, 74, .45); }
.dots i.on { background: #ffd98a; box-shadow: 0 0 10px #ffb84a; }

/* ---------- odchod ---------- */
.book-ov.closing { animation: bkOut 1.1s ease-in forwards; }
.book-ov.closing .book-fly { animation: bkAway 1s cubic-bezier(.5, 0, .8, .4) forwards; }
@keyframes bkOut { to { background: rgba(12, 7, 3, 0); opacity: 0; } }
@keyframes bkAway { to { opacity: 0; transform: translate3d(0, -8vh, -500px) rotateX(20deg) scale(.8); } }

@media (prefers-reduced-motion: reduce) {
  .book-ov, .book-light, .book-motes i, .flying .book-fly, .book-ov.closing .book-fly { animation: none !important; }
  .book-ov.closing { animation: bkOut .3s linear forwards !important; }
  .book, .cover, .leaf { transition: none !important; }
  .book-motes { display: none; }
}
