/* Księga Rodu — samodzielna księga online z lektorem (krem, granat, złoto, biurko w tle). */
@font-face { font-family: "Alegreya SC"; src: url("fonts/AlegreyaSC-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Alegreya Sans"; src: url("fonts/AlegreyaSans-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Alegreya Sans"; src: url("fonts/AlegreyaSans-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
:root {
  --krem: #f6f1e6; --granat: #16203A; --zloto: #C9A258; --zloto-jasne: #DDBB7A;
  --serif: "Alegreya SC", Georgia, serif; --sans: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
  --pasek: 54px; --dol: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font-family: var(--sans); color: var(--granat); background: #e9dfcb url("img/bureau.webp") center / cover no-repeat fixed; }
@media (max-width: 760px) { body { background-image: url("img/bureau-m.webp"); } }
button { font: inherit; }
.czytnik { height: 100%; height: 100dvh; display: flex; flex-direction: column; position: relative; }
.czytnik:fullscreen { background: #e9dfcb url("img/bureau.webp") center / cover no-repeat; }

/* górny pasek */
.pasek { height: var(--pasek); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 14px; background: rgba(17, 29, 59, .97); color: var(--krem); position: relative; z-index: 20; }
.logo { font-family: var(--serif); font-size: 1.2rem; white-space: nowrap; display: inline-flex; align-items: center; }
.logo img { width: 30px; height: 35px; margin-right: .45rem; }
.logo > span { color: var(--zloto-jasne); margin-left: .25em; }
.tytul { font-family: var(--serif); font-size: 1.02rem; opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; border-left: 1px solid rgba(221, 187, 122, .35); padding-left: 12px; }
.pasek-prawo { margin-left: auto; display: flex; gap: 4px; flex: none; }
.ikona { display: inline-flex; align-items: center; gap: 6px; height: 38px; min-width: 38px; padding: 0 10px; border-radius: 999px; border: 0; background: transparent; color: var(--krem); cursor: pointer; }
.ikona:hover, .ikona[aria-expanded="true"] { background: rgba(255, 255, 255, .1); }
.ikona svg, .lk-ikona svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--zloto-jasne); outline-offset: 2px; }
@media (max-width: 640px) { .ikona .tekst { display: none; } .tytul { font-size: .92rem; } }
@media (max-width: 420px) { .logo { font-size: 0; } .logo img { margin: 0; } .ikona { padding: 0 6px; min-width: 34px; } .pasek { gap: 8px; padding: 0 8px; } }

/* spis treści */
.spis { position: absolute; top: calc(var(--pasek) + 8px); right: 12px; z-index: 30; width: min(360px, calc(100vw - 24px)); max-height: calc(100% - var(--pasek) - var(--dol) - 20px); overflow: auto; background: rgba(250, 247, 239, .98); border-radius: 14px; box-shadow: 0 18px 50px rgba(0, 0, 0, .3); padding: 14px 8px 8px; }
.spis[hidden] { display: none; }
.spis-tytul { font-family: var(--serif); font-size: 1.15rem; padding: 0 12px 8px; border-bottom: 1px solid rgba(22, 32, 58, .12); }
.spis ol { list-style: none; margin: 6px 0 0; padding: 0; }
.spis button { width: 100%; display: flex; justify-content: space-between; gap: 12px; text-align: left; padding: 8px 12px; border: 0; background: none; border-radius: 8px; color: var(--granat); cursor: pointer; font-size: .98rem; }
.spis button:hover, .spis button:focus-visible { background: rgba(184, 145, 63, .14); outline: none; }
.spis button.aktywny { font-weight: 700; color: #8a6a2c; }
.spis .nr { color: #8a8678; font-size: .88rem; flex: none; }
.spis-legenda { font-size: .82rem; color: #6b6a64; margin: 6px 12px 2px; }

/* scena */
.scena { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 12px 0; position: relative; }
.ksiega-ramka { width: var(--szer, 90vw); max-width: 100%; flex: none; position: relative; }
.ksiega-ramka::after { content: ""; position: absolute; left: 4%; right: 4%; bottom: -14px; height: 28px; z-index: -1; background: radial-gradient(ellipse at center, rgba(40, 28, 10, .38), transparent 70%); filter: blur(4px); }
.ksiega { margin: 0 auto; }
.strona { background: #f4efe3; overflow: hidden; position: relative; }
.strona > img { width: 100%; height: 100%; object-fit: contain; display: block; opacity: 0; transition: opacity .25s; user-select: none; -webkit-user-drag: none; }
.strona > img.zaladowana { opacity: 1; }
.strona.ladowanie { background: #f4efe3 linear-gradient(110deg, transparent 40%, rgba(255, 255, 255, .55) 50%, transparent 60%) 0 0 / 250% 100%; animation: lsk 1.4s linear infinite; }
@keyframes lsk { to { background-position: -150% 0; } }
.strzalka { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer; z-index: 5; background: rgba(22, 32, 58, .85); color: var(--zloto-jasne); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); }
.strzalka:disabled { opacity: .25; cursor: default; }
.strzalka svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 760px) { .strzalka { display: none; } .scena { padding: 8px 6px 0; } }

/* animacje na stronach */
.anim { position: absolute; overflow: hidden; pointer-events: none; }
.anim .kadr { position: absolute; inset: 0; background-repeat: no-repeat; }
.anim.zdjecie .kadr { transform-origin: var(--ox, 50%) var(--oy, 50%); }
.strona.widoczna .anim.zdjecie .kadr { animation: przyblizenie 22s ease-in-out infinite alternate; }
@keyframes przyblizenie { from { transform: scale(1); } to { transform: scale(1.09); } }
.anim.odkryj { background: var(--tlo, #f4efe3); }
.anim.odkryj .kadr { clip-path: inset(0 0 0 0); }
.strona.widoczna .anim.odkryj.prawo .kadr { animation: odkryjPrawo 3.4s cubic-bezier(.45, .05, .35, 1) .5s both; }
.strona.widoczna .anim.odkryj.gora .kadr { animation: odkryjGora 3.8s cubic-bezier(.45, .05, .35, 1) .5s both; }
.anim.odkryj.gotowe { background: none; }
@keyframes odkryjPrawo { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes odkryjGora { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) { .anim { display: none; } .strona.ladowanie { animation: none; } }

/* dolny pasek: lektor + licznik */
.dol { height: var(--dol); flex: none; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 0 10px; }
.lektor { display: flex; align-items: center; gap: 10px; background: rgba(22, 32, 58, .92); color: var(--krem); border-radius: 999px; padding: 6px 8px 6px 6px; width: min(560px, 100%); box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.lk-graj { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--zloto); color: var(--granat); cursor: pointer; display: grid; place-items: center; }
.lk-graj svg { width: 22px; height: 22px; fill: currentColor; }
.lk-graj .i-pauza, .lektor.gra .lk-graj .i-graj { display: none; }
.lektor.gra .lk-graj .i-pauza { display: block; }
.lk-graj:disabled { opacity: .4; cursor: default; }
.lk-srodek { flex: 1; min-width: 0; display: grid; gap: 5px; }
.lk-tekst { font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lk-tekst b { color: var(--zloto-jasne); font-weight: 700; }
.lk-pasek { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .18); overflow: hidden; cursor: pointer; }
.lk-pasek i { display: block; height: 100%; width: 0; background: var(--zloto-jasne); }
.lk-ikona { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: var(--krem); cursor: pointer; display: grid; place-items: center; }
.lk-ikona .krzyz, .lk-ikona[aria-pressed="true"] .fala { display: none; }
.lk-ikona[aria-pressed="true"] .krzyz { display: inline; }
.lk-ikona[aria-pressed="true"] { color: #e6a0a0; }
.lk-auto { flex: none; border: 1px solid rgba(221, 187, 122, .45); background: transparent; color: var(--krem); border-radius: 999px; padding: .3rem .7rem; font-size: .82rem; cursor: pointer; white-space: nowrap; }
.lk-auto b { color: var(--zloto-jasne); }
.lk-auto[aria-pressed="false"] b { color: #c9c3b6; }
.licznik { flex: none; background: rgba(22, 32, 58, .85); color: var(--krem); padding: .2rem .8rem; border-radius: 999px; font-variant-numeric: tabular-nums; font-size: .9rem; }
@media (max-width: 560px) { .licznik { display: none; } .lk-auto { padding: .3rem .5rem; } .lektor { gap: 6px; } }

/* ekran startowy */
.start { position: absolute; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(22, 32, 58, .35); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.start[hidden] { display: none; }
.start-karta { background: rgba(250, 247, 239, .97); border-radius: 20px; box-shadow: 0 30px 70px rgba(0, 0, 0, .4); padding: 26px; display: grid; gap: 26px; align-items: center; max-width: 760px; width: 100%; }
@media (min-width: 640px) { .start-karta { grid-template-columns: 220px 1fr; padding: 32px; } }
.start-okladka { width: 100%; max-width: 220px; margin: 0 auto; border-radius: 3px 8px 8px 3px; box-shadow: 0 18px 40px rgba(0, 0, 0, .35); display: block; }
@media (max-width: 639px) { .start-okladka { max-width: 130px; } }
.start-marka { font-family: var(--serif); display: flex; align-items: center; gap: .45rem; font-size: 1.05rem; }
.start-marka img { width: 26px; height: 30px; }
.start-marka span { color: #8a6a2c; }
.start h1 { font-family: var(--serif); font-size: clamp(1.8rem, 6vw, 2.6rem); margin: .4rem 0 .2rem; line-height: 1.1; }
.start-pod { margin: 0 0 1.2rem; color: #4d4f57; font-size: 1.05rem; }
.knop { display: flex; align-items: center; justify-content: center; gap: .5rem; width: 100%; border: 0; border-radius: 999px; padding: .95rem 1.4rem; font-weight: 700; font-size: 1.08rem; cursor: pointer; }
.knop svg { width: 20px; height: 20px; fill: currentColor; }
.knop-zloto { background: var(--zloto); color: var(--granat); box-shadow: 0 10px 24px rgba(160, 120, 40, .35); }
.knop-zloto:hover { background: var(--zloto-jasne); }
.knop-cichy { background: transparent; color: var(--granat); margin-top: .6rem; text-decoration: underline; font-weight: 400; font-size: 1rem; padding: .5rem; }
.start-info { font-size: .88rem; color: #6b6a64; margin: .8rem 0 0; }

/* powiększenie strony */
.zoom-doos { position: fixed; inset: 0; z-index: 1000; background: rgba(12, 16, 28, .95); }
.zoom-doos[hidden] { display: none; }
.zoom-podium { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; cursor: zoom-in; padding: 12px 12px 76px; }
.zoom-doos.gezoomd .zoom-podium { cursor: grab; }
.zoom-inhoud { transform-origin: 50% 50%; will-change: transform; display: flex; gap: 2px; max-width: 100%; max-height: 100%; }
.zoom-inhoud img { display: block; max-height: calc(100vh - 100px); max-height: calc(100dvh - 100px); max-width: 100%; width: auto; height: auto; user-select: none; -webkit-user-drag: none; pointer-events: none; background: #f4efe3; }
.zoom-inhoud.dwie img { max-width: 50%; }
.zoom-knoppen { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 10px; }
.zoom-knoppen button { width: 48px; height: 48px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .35); background: rgba(27, 34, 54, .9); color: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer; }
.zoom-knoppen button:disabled { opacity: .35; }
