/* =========================================================
   ISTORIJA — biblioteka sa knjigama
   ========================================================= */
:root {
  --paper: #efe5cc;
  --paper-2: #e2d5b5;
  --ink: #2b2416;
  --ink-soft: #5b4d33;
  --f-book: "EB Garamond", Georgia, "Times New Roman", serif;
}

.nav--always { display: flex; }
.nav--always a { white-space: nowrap; }
@media (max-width: 520px) {
  .bk { --w: min(38vw, 160px); --d: 22px; }
  .shelf__books { gap: 44px 34px; }
  .cover__frame { inset: 7px; gap: 5px; padding: 8px 6px; }
  .cover__sub { font-size: .7rem; }
  .cover__top { display: none; }
}
@media (max-width: 1023px) { .nav--always a { padding: 12px 4px; font-size: .68rem; } }

/* ---------- Uvod ---------- */
.h-intro { position: relative; min-height: 88dvh; display: grid; align-items: center; padding: 120px 0 72px; overflow: hidden; }
.h-intro__emblem {
  position: absolute; right: -12%; top: 50%; width: min(80vw, 760px); transform: translateY(-50%) rotate(-8deg);
  opacity: .16; filter: sepia(.4) saturate(.8);
  -webkit-mask-image: radial-gradient(circle, #000 35%, transparent 70%); mask-image: radial-gradient(circle, #000 35%, transparent 70%);
  animation: floatEmblem 14s ease-in-out infinite alternate;
}
@keyframes floatEmblem { to { transform: translateY(-53%) rotate(-3deg); } }
.h-intro__emblem img { width: 100%; height: auto; }
.h-intro__inner { position: relative; display: grid; gap: 22px; justify-items: start; }
.h-intro__inner .mono { color: var(--gold); }
.h-intro__title { font-weight: 600; }
.h-intro__title { font-size: clamp(3rem, 9vw, 7rem); color: var(--cream); animation: introUp 1s var(--ease-out) both; }
.h-intro__title em { font-style: normal; color: var(--gold); }
.h-intro__lead { font-family: var(--f-book); font-size: clamp(1.15rem, 2.2vw, 1.4rem); color: var(--cream-2); max-width: 46ch; animation: introUp 1s var(--ease-out) .15s both; }
.h-intro .btn { animation: introUp 1s var(--ease-out) .3s both; }
.h-intro .btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@keyframes introUp { from { opacity: 0; transform: translateY(30px); } }

/* ---------- Polica ---------- */
.library { padding-block: 80px 40px; }
.library__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 40px; }
.library__head .mono { color: var(--gold); }
.shelf { position: relative; }
.shelf__books { list-style: none; margin: 0; padding: 30px 8px 0; display: flex; justify-content: center; align-items: flex-end; flex-wrap: wrap; gap: 48px clamp(28px, 5vw, 64px); }
.shelf__books li { position: relative; animation: bookIn .9s var(--ease-out) both; animation-delay: calc(var(--i) * 120ms + 200ms); }
.shelf__books li::after { content: ""; position: absolute; left: 6%; right: -4%; bottom: -10px; height: 16px; border-radius: 50%; background: rgba(0,0,0,.55); filter: blur(8px); z-index: -1; }
@keyframes bookIn { from { opacity: 0; transform: translateY(40px); } }
.shelf__board {
  position: relative; height: 22px; margin-top: 2px;
  background: linear-gradient(180deg, #4a3a26, #2a2015 60%, #17110a);
  border-top: 1px solid rgba(220, 192, 138, .35);
  box-shadow: 0 30px 40px -18px rgba(0,0,0,.9);
}
.shelf__board::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 10px; background: linear-gradient(180deg, rgba(0,0,0,.5), transparent); }
@media (max-width: 700px) { .shelf__board { display: none; } .shelf__books li { padding-bottom: 6px; } }

/* Knjiga na polici (3D) */
.bk {
  --w: clamp(150px, 17vw, 196px); --d: 30px;
  position: relative; display: block; width: var(--w); aspect-ratio: 1 / 1.46;
  border: 0; padding: 0; background: none; perspective: 1100px;
}
.bk__body {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transform: rotateY(26deg); transition: transform .7s var(--ease-out);
}
.bk:hover .bk__body, .bk:focus-visible .bk__body { transform: rotateY(6deg) translateY(-16px) translateZ(30px); }
.bk:focus-visible { outline: none; }
.bk:focus-visible .bk__front { box-shadow: 0 0 0 3px var(--gold), inset 8px 0 12px rgba(0,0,0,.45); }
.bk__body::after { content: ""; position: absolute; inset: 0; background: #0d0f09; transform: translateZ(calc(var(--d) * -1)); border-radius: 3px; }

.bk__front, .book__cover-front {
  position: absolute; inset: 0; border-radius: 2px 6px 6px 2px; overflow: hidden;
  background:
    linear-gradient(90deg, rgba(0,0,0,.45) 0, rgba(255,255,255,.08) 4%, transparent 9%),
    radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.14), transparent 60%),
    var(--c);
  box-shadow: inset 8px 0 12px rgba(0,0,0,.45), inset 0 0 40px rgba(0,0,0,.35);
}
.bk__front::before, .book__cover-front::before { content: ""; position: absolute; inset: 0; background-image: var(--camo); background-size: 160px; opacity: .12; mix-blend-mode: multiply; }
.bk__front::after { content: ""; position: absolute; right: 22%; bottom: -1px; width: 12px; height: 0; background: linear-gradient(var(--gold-2), var(--gold)); }
.bk__front::after { display: none; }
.bk__ribbon { position: absolute; right: 26%; bottom: -26px; width: 12px; height: 34px; background: linear-gradient(var(--gold), #8f6f35); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%); transition: transform .5s var(--ease-out); z-index: -1; }
.bk:hover .bk__ribbon { transform: translateY(-14px); }

.bk__spine {
  position: absolute; top: 0; bottom: 0; left: calc(var(--d) * -1); width: var(--d);
  transform-origin: right center; transform: rotateY(-90deg);
  background: linear-gradient(90deg, rgba(0,0,0,.35), rgba(255,255,255,.08) 45%, rgba(0,0,0,.4)), var(--c);
  display: grid; place-items: center; overflow: hidden;
}
.bk__spine span { writing-mode: vertical-rl; transform: rotate(180deg); font-family: var(--f-display); font-weight: 600; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-2); white-space: nowrap; }
.bk__pages {
  position: absolute; top: 4px; bottom: 4px; left: 100%; width: calc(var(--d) - 2px);
  transform-origin: left center; transform: rotateY(90deg);
  background: repeating-linear-gradient(90deg, #e8dcc0 0 2px, #cfc2a2 2px 3px);
}

/* Korice — sadržaj */
.cover__frame {
  position: absolute; inset: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 10px; text-align: center;
  border: 1px solid rgba(220, 192, 138, .75);
  box-shadow: inset 0 0 0 3px rgba(0,0,0,.15), inset 0 0 0 4px rgba(220, 192, 138, .45);
}
.cover__top { font-size: .55rem; color: var(--gold-2); opacity: .85; }
.cover__emblem { width: 34%; height: auto; border-radius: 50%; box-shadow: 0 0 0 2px rgba(220, 192, 138,.6), 0 6px 14px rgba(0,0,0,.4); filter: sepia(.25); }
.cover__title {
  font-family: var(--f-serif); font-weight: 600; line-height: 1.08; font-size: clamp(1.05rem, 1.6vw, 1.35rem);
  background: linear-gradient(180deg, #e8d3a6, #c6a15b 60%, #94763e); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 1px 0 rgba(0,0,0,.15);
}
.cover__sub { font-family: var(--f-book); font-style: italic; font-size: .82rem; color: var(--cream-2); line-height: 1.3; }
.cover__years { font-size: .58rem; color: var(--gold); }

/* ---------- Vremenska linija ---------- */
.timeline { padding-block: 80px 100px; }
.tl { list-style: none; margin: 36px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0; border-top: 1px solid var(--line-strong); }
.tl li { position: relative; padding: 26px 18px 26px 0; display: grid; gap: 6px; }
.tl li::before { content: ""; position: absolute; top: -5px; left: 0; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px var(--bg); }
.tl__y { font-family: var(--f-display); font-weight: 700; font-size: 2rem; color: var(--gold); line-height: 1; }
.tl__t { font-family: var(--f-book); font-size: 1.08rem; color: var(--cream-2); line-height: 1.35; }
.tl__note { margin-top: 28px; font-size: .85rem; color: var(--text-muted); max-width: 70ch; }

/* =========================================================
   ČITAČ
   ========================================================= */
.reader { position: fixed; inset: 0; z-index: var(--z-modal); display: grid; place-items: center; transition: opacity .25s; }
.reader.is-closing { opacity: 0; }
.reader__backdrop { position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(28, 33, 20, .92), rgba(6, 8, 4, .97)); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fadeIn2 .3s ease both; }
.reader__ui { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; padding: 12px 16px 16px; max-height: 100dvh; }
.reader__bar { display: flex; justify-content: space-between; align-items: center; width: min(100%, 900px); }
.reader__bar .mono { color: var(--gold); }
.reader__nav { display: flex; align-items: center; gap: 22px; }
.reader__nav .mono { color: var(--cream); min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.pager-btn { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line-strong); background: rgba(5,9,6,.5); color: var(--cream); display: grid; place-items: center; transition: border-color var(--dur-fast), color var(--dur-fast); }
.pager-btn:hover:not([disabled]) { border-color: var(--gold); color: var(--gold); }
.pager-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pager-btn[disabled] { opacity: .3; cursor: default; }

.book-stage { perspective: 2600px; padding: 14px; }
.book {
  --pw: min(44vw, 440px);
  --ph: min(calc(100dvh - 170px), calc(var(--pw) * 1.42));
  position: relative; width: calc(var(--pw) * 2); height: var(--ph);
  transform-style: preserve-3d; cursor: pointer; touch-action: pan-y;
}
.book.is-single { --pw: min(calc(100vw - 48px), 440px); width: var(--pw); }
.book::before {
  content: ""; position: absolute; inset: -12px -14px; border-radius: 8px; transform: translateZ(-3px);
  background: linear-gradient(90deg, rgba(0,0,0,.35), transparent 10%, transparent 90%, rgba(0,0,0,.35)), var(--c, #3c4a26);
  box-shadow: 0 50px 90px -20px rgba(0,0,0,.9), inset 0 0 0 1px rgba(220, 192, 138,.25);
}
.book::after { content: ""; position: absolute; left: -3px; right: -3px; bottom: -6px; height: 6px; transform: translateZ(-1px); background: repeating-linear-gradient(0deg, #d9cba8 0 1px, #bfb08c 1px 2px); border-radius: 0 0 3px 3px; }
.book__page { position: absolute; top: 0; width: var(--pw); height: 100%; }
.book__page--left { left: 0; }
.book__page--right { right: 0; }
.is-single .book__page--left { display: none; }
.is-single .book__page--right { left: 0; right: auto; }
.book__spine { position: absolute; top: 0; bottom: 0; left: 50%; width: 46px; transform: translateX(-50%) translateZ(1px); pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(60,45,20,.18) 35%, rgba(30,20,8,.38) 50%, rgba(60,45,20,.18) 65%, transparent); }
.is-single .book__spine { display: none; }

/* Listovi koji se okreću */
.leaf { position: absolute; top: 0; width: var(--pw); height: 100%; transform-style: preserve-3d; z-index: 5; }
.leaf--right { left: 50%; transform-origin: left center; }
.leaf--left { left: 0; transform-origin: right center; }
.is-single .leaf--right { left: 0; }
.leaf__face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.leaf__back { transform: rotateY(180deg); }
.leaf__shade { position: absolute; inset: 0; opacity: 0; pointer-events: none; background: linear-gradient(90deg, rgba(0,0,0,.4), transparent 70%); }
.leaf--left .leaf__shade { background: linear-gradient(270deg, rgba(0,0,0,.4), transparent 70%); }

/* Korice koje se otvaraju */
.book__cover { position: absolute; top: 0; left: 50%; width: var(--pw); height: 100%; transform-origin: left center; transform-style: preserve-3d; z-index: 10; }
.is-single .book__cover { left: 0; }
.book__cover-front, .book__cover-back { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.book__cover-front { border-radius: 2px 8px 8px 2px; }
.book__cover-front .cover__frame { inset: 18px; gap: 16px; }
.book__cover-front .cover__title { font-size: clamp(1.6rem, 3.4vw, 2.6rem); }
.book__cover-front .cover__sub { font-size: 1.1rem; }
.book__cover-front .cover__top, .book__cover-front .cover__years { font-size: .72rem; }
.book__cover-back { position: absolute; inset: 0; transform: rotateY(180deg); background: #1c2214; border-radius: 8px 2px 2px 8px; }
.book__cover-back::before { content: ""; position: absolute; inset: 0; background-image: var(--camo); background-size: 200px; opacity: .3; }

/* ---------- Stranica (papir) ---------- */
.pg {
  position: relative; height: 100%; display: flex; flex-direction: column; overflow: hidden;
  padding: clamp(18px, 3.4vw, 34px) clamp(18px, 3.4vw, 36px) clamp(14px, 2.4vw, 24px);
  font-family: var(--f-book); color: var(--ink);
  background:
    radial-gradient(ellipse at 30% 15%, rgba(255,255,255,.4), transparent 55%),
    radial-gradient(ellipse at 80% 90%, rgba(150,120,70,.16), transparent 60%),
    var(--paper);
  cursor: pointer;
}
/* sjenka uz povez — lijeva strana knjige ima sjenku desno, desna lijevo */
.book__page--left .pg, .leaf--right .leaf__back .pg, .leaf--left .leaf__front .pg { box-shadow: inset -26px 0 30px -18px rgba(60,40,10,.45); border-radius: 4px 0 0 4px; }
.book__page--right .pg, .leaf--right .leaf__front .pg, .leaf--left .leaf__back .pg { box-shadow: inset 26px 0 30px -18px rgba(60,40,10,.45); border-radius: 0 4px 4px 0; }
.pg::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .35; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .45 0 0 0 0 .3 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.pg__head { display: flex; justify-content: space-between; gap: 12px; font-family: var(--f-mono); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: #8a6a3a; border-bottom: 1px solid rgba(90,70,40,.25); padding-bottom: 8px; margin-bottom: clamp(10px, 2vw, 18px); }
.pg__body { position: relative; z-index: 1; flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #b9a77d transparent; padding-right: 4px; }
.pg__body h3 { font-family: var(--f-serif); font-weight: 600; font-size: clamp(1.4rem, 2.5vw, 1.9rem); color: #24331f; margin: 0 0 12px; line-height: 1.1; }
.pg__body p { font-size: clamp(1rem, 1.5vw, 1.12rem); line-height: 1.55; margin: 0 0 .75em; text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
.pg__body p:first-of-type::first-letter { float: left; font-family: var(--f-serif); font-weight: 600; font-size: 3.3em; line-height: .82; padding: 6px 8px 0 0; color: #8f6f35; }
.pg__body em { color: #5a3b12; }
.pg__num { position: relative; z-index: 1; text-align: center; font-size: .92rem; color: #8a6a3a; margin-top: 8px; }
.pg__num::before, .pg__num::after { content: "—"; margin: 0 8px; opacity: .5; }

.pg--title, .pg--end { align-items: center; justify-content: center; text-align: center; gap: 14px; }
.pg--title h3, .pg--end h3 { font-family: var(--f-serif); font-weight: 600; font-size: clamp(1.9rem, 3.6vw, 2.8rem); color: #24331f; line-height: 1.05; }
.pg__sub { font-style: italic; font-size: 1.2rem; color: var(--ink-soft); }
.pg__orn { color: #8f6f35; letter-spacing: .4em; }
.pg__rule { width: 90px; height: 1px; background: #8f6f35; }
.pg--title .mono, .pg--end .mono { color: #8a6a3a; }
.pg--title img, .pg--end img { position: relative; z-index: 1; border-radius: 50%; filter: sepia(.3); opacity: .9; }
.pg__hint { margin-top: 10px; }
.pg--end p { font-size: 1.2rem; color: var(--ink-soft); }
.pg--endpaper { align-items: center; justify-content: center; gap: 12px; background: #1c2214; color: var(--gold); border-radius: 4px 0 0 4px; }
.pg--endpaper::before { content: ""; position: absolute; inset: 0; background-image: var(--camo); background-size: 220px; opacity: .28; }
.pg--endpaper::after { display: none; }
.pg--endpaper img { position: relative; width: 44%; height: auto; border-radius: 50%; box-shadow: 0 0 0 3px rgba(220, 192, 138,.4); }
.pg--endpaper .mono { position: relative; color: var(--gold-2); }
.pg__ex { position: relative; font-family: var(--f-display); font-size: 1.4rem; letter-spacing: .2em; text-transform: uppercase; }
.pg--blank { }

@media (prefers-reduced-motion: reduce) {
  .bk__body { transform: none; }
  .h-intro__emblem { animation: none; }
}
