* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  background: #111;
  color: #fff;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 64px;
  flex-shrink: 0;
  background: #111;
  color: #fff;
  border-bottom: 1px solid #333;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  position: relative;
  z-index: 50;
}

.brand {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 5px;
}

.subtitle {
  font-size: 16px;
  color: #999;
  border-left: 1px solid #444;
  padding-left: 20px;
}

.icon-btn {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: #ddd;
  font-size: 26px;
  cursor: pointer;
}

main {
  flex: 1;
  min-height: 0;
  background: #111;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 20px 8px;
}

.viewer-wrap {
  position: relative;
  width: 100%;
  height: min(82vh, 900px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
}

.book {
  position: relative;
  background: #000;
  perspective: 2200px;
  transform-origin: center;
  isolation: isolate;
}

.page {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  background: #000;
  overflow: hidden;
  user-select: none;
  border: 0;
}

.page.left {
  left: 0;
  border-right: 1px solid rgba(255,255,255,.08);
  box-shadow: 7px 0 16px rgba(0,0,0,.42);
}

.page.right {
  right: 0;
  border-left: 1px solid rgba(255,255,255,.08);
  box-shadow: -7px 0 16px rgba(0,0,0,.42);
}

.page img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
  pointer-events: none;
}

.page.blank {
  background: #000;
}

/* New spread is the visual base underneath the turning sheet. */
.under-page {
  z-index: 1;
}

.old-stationary {
  z-index: 5;
}

/* =========================================
   3D FLIP
   ========================================= */

.flip-wrapper {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  z-index: 20;

  transform-style: preserve-3d;
  backface-visibility: hidden;

  transition:
    transform 900ms cubic-bezier(.22,.68,.18,1),
    box-shadow 900ms cubic-bezier(.22,.68,.18,1);

  pointer-events: none;
}

.flip-wrapper.next {
  right: 0;
  transform-origin: left center;
  transform: rotateY(0deg);
  box-shadow: -3px 0 10px rgba(0,0,0,.16);
}

.flip-wrapper.next.animate {
  transform: rotateY(-180deg);
  box-shadow: 14px 0 32px rgba(0,0,0,.45);
}

.flip-wrapper.prev {
  left: 0;
  transform-origin: right center;
  transform: rotateY(0deg);
  box-shadow: 3px 0 10px rgba(0,0,0,.16);
}

.flip-wrapper.prev.animate {
  transform: rotateY(180deg);
  box-shadow: -14px 0 32px rgba(0,0,0,.45);
}

.flip-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  transform-style: preserve-3d;
  backface-visibility: hidden;
}

.flip-front {
  transform: rotateY(0deg);
}

.flip-back {
  transform: rotateY(180deg);
}

.flip-image-page {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

.flip-image-page img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
  pointer-events: none;
}

.flip-wrapper::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;

  background: linear-gradient(
    to right,
    rgba(0,0,0,0) 40%,
    rgba(0,0,0,.08) 70%,
    rgba(0,0,0,.30) 100%
  );

  opacity: 0;
  transition: opacity 400ms ease;
}

.flip-wrapper.animate::after {
  opacity: 1;
}

/* Navigation */

.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);

  width: 52px;
  height: 52px;

  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #333;

  font-size: 38px;
  line-height: 1;
  cursor: pointer;
  z-index: 40;

  box-shadow: 0 4px 18px rgba(0,0,0,.35);

  transition:
    transform .2s ease,
    box-shadow .2s ease;
}

.nav-btn:hover {
  transform: translateY(-50%) scale(1.06);
  box-shadow: 0 6px 22px rgba(0,0,0,.45);
}

.nav-btn:disabled {
  opacity: .3;
  cursor: default;
}

.nav-btn.prev { left: 10px; }
.nav-btn.next { right: 10px; }

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.controls button {
  border: 1px solid #ddd;
  background: #fff;
  color: #222;
  border-radius: 6px;
  padding: 8px 13px;
  cursor: pointer;
  font-size: 14px;
  transition: background .15s ease, transform .15s ease;
}

.controls button:hover {
  background: #f2f2f2;
}

.controls button:active {
  transform: scale(.97);
}

.controls button:disabled {
  opacity: .45;
  cursor: default;
}

.controls span {
  min-width: 60px;
  text-align: center;
  color: #aaa;
  font-size: 14px;
}

.hint {
  margin: 5px 0 0;
  color: #666;
  font-size: 11px;
}

@media (max-width: 700px) {
  body {
    overflow: auto;
  }

  .topbar {
    height: 56px;
    padding: 0 16px;
  }

  .brand {
    font-size: 23px;
  }

  .brand-logo {
    width: 92px;
    max-width: 25vw;
    height: 32px;
    max-height: 32px;
  }

  .home-btn {
    height: 28px;
    padding: 0 9px;
    font-size: 11px;
  }

  .subtitle {
    display: none;
  }

  main {
    padding: 10px;
  }

  .viewer-wrap {
    width: 100vw;
    height: 75vh;
  }

  .nav-btn {
    width: 44px;
    height: 44px;
    font-size: 32px;
  }

  .nav-btn.prev { left: 4px; }
  .nav-btn.next { right: 4px; }

  .controls {
    flex-wrap: wrap;
  }

  .hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flip-wrapper {
    transition-duration: 1ms;
  }

  .nav-btn {
    transition: none;
  }
}


/* =========================================================
   MOBILE V3
   Na mobile sa nemení šírka booku. Mení sa iba obrázok v
   rovnakom, stále rovnako veľkom kontajneri.
   ========================================================= */

@media (max-width: 700px) {
  .book.mobile-page {
    background: #000;
    overflow: visible;
  }

  .book.mobile-page .mobile-single-page {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: #000;
    overflow: hidden;
    will-change: opacity, transform;
  }

  .book.mobile-page .mobile-single-page img {
    width: 100%;
    height: 100%;
    object-fit: fill;
  }

  .book.mobile-page .mobile-page-out {
    opacity: .72;
    transition: opacity 45ms ease-out;
  }

  .book.mobile-page .mobile-page-in-next {
    opacity: 0;
    transform: translateX(14px);
  }

  .book.mobile-page .mobile-page-in-prev {
    opacity: 0;
    transform: translateX(-14px);
  }

  .book.mobile-page .mobile-page-in-active {
    opacity: 1;
    transform: translateX(0);
    transition:
      opacity 160ms ease-out,
      transform 160ms ease-out;
  }

  .topbar {
    height: 42px;
    min-height: 42px;
    padding: 0 12px;
  }

  .brand {
    font-size: 16px;
    letter-spacing: 1.6px;
  }

  .subtitle {
    display: none;
  }

  .icon-btn {
    width: 32px;
    height: 30px;
    font-size: 17px;
  }

  .nav-btn {
    width: 38px;
    height: 54px;
    border-radius: 8px;
    background: rgba(10,10,10,.42);
    font-size: 34px;
  }

  .nav-btn.prev { left: 5px; }
  .nav-btn.next { right: 5px; }

  .controls {
    height: 40px;
    min-height: 40px;
    gap: 4px;
  }

  .controls button {
    height: 28px;
    min-width: 30px;
    padding: 0 7px;
    font-size: 12px;
  }

  #firstBtn,
  #lastBtn,
  #zoomOut,
  #zoomReset,
  #zoomIn {
    display: none;
  }

  #pageCounter {
    min-width: 50px;
    font-size: 12px;
  }

  .hint {
    display: none;
  }
}

@media (max-width: 700px) and (orientation: landscape) {
  .topbar {
    height: 34px;
    min-height: 34px;
  }

  .controls {
    height: 30px;
    min-height: 30px;
  }

  .nav-btn {
    height: 46px;
  }
}


/* =========================================================
   MOBILE V4
   Fixed one-page geometry + all pages preloaded in one stack.
   Desktop styles above remain unchanged.
   ========================================================= */

@media (max-width: 700px) {
  .book.mobile-page {
    flex: 0 0 auto;
    perspective: none;
    transform: none;
    background: #000;
    overflow: hidden;
  }

  .book.mobile-page .mobile-stage {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
  }

  .book.mobile-page .mobile-page-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: none;
    transition: opacity 160ms ease;
    will-change: opacity;
  }

  .book.mobile-page .mobile-page-layer.is-active {
    opacity: 1;
    visibility: visible;
    z-index: 2;
  }

  .book.mobile-page .mobile-page-layer.is-leaving {
    opacity: 0;
    visibility: visible;
    z-index: 1;
  }

  .book.mobile-page .mobile-page-layer img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
    background: #000;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
  }
}


/* THERMOX header logo — explicit sizing */
.brand-logo {
  display: block;
  flex: 0 0 auto;
  width: 140px;
  max-width: 20vw;
  height: auto;
  max-height: 46px;
  object-fit: contain;
}

/* Phone landscape warning */
.orientation-warning {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  align-items: center;
  justify-content: center;
  padding: 28px;
  text-align: center;
  background: #111;
  color: #fff;
}
.orientation-warning-inner {
  width: min(420px, 90vw);
}
.orientation-icon {
  font-size: 58px;
  line-height: 1;
  margin-bottom: 22px;
  color: #ddd;
}
.orientation-warning h1 {
  margin: 0 0 12px;
  font-size: 24px;
  font-weight: 700;
}
.orientation-warning p {
  margin: 0;
  color: #aaa;
  font-size: 14px;
  line-height: 1.55;
}


/* Header HOME button */
.home-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 10px;
  border: 1px solid #555;
  border-radius: 7px;
  color: #ddd;
  background: #1a1a1a;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
}

.home-btn:hover {
  background: #242424;
  border-color: #999;
  color: #fff;
}

@media (max-width: 700px) {
  .brand-logo {
    width: 96px;
    max-width: 25vw;
    max-height: 32px;
  }

  .home-btn {
    height: 28px;
    padding: 0 9px;
    font-size: 11px;
  }
}


/* Phone landscape lock - phones only; tablets remain unrestricted */
.orientation-warning { display:none !important; }
html.phone-landscape .orientation-warning {
  display:flex !important;
  position:fixed !important;
  inset:0 !important;
  z-index:999999 !important;
}
html.phone-landscape body > *:not(.orientation-warning) {
  visibility:hidden !important;
  pointer-events:none !important;
}
html.phone-landscape, html.phone-landscape body {
  overflow:hidden !important;
}
