/* =========================================================
   PHOTWORK FLIPBOOK — CSS FOR THE CURRENT MAIN.JS
   Book width and height are calculated by fitBookToScreen().
   This stylesheet intentionally does not set width/height on .book.
   ========================================================= */

*, *::after, *::before { box-sizing: border-box; }

body, html { width: 100%; max-width: 100%; min-height: 100%; margin: 0; overflow-x: hidden; background: #000; color: #fff; font-family: Arial,sans-serif; }

body { min-height: 100vh; min-height: 100dvh; }

.main { position: relative; isolation: isolate; display: flex; flex-direction: column; align-items: center; justify-content: space-between; width: 100%; max-width: 100vw; min-height: 100vh; min-height: 100dvh; padding: 0; gap: clamp(12px, 2vh, 24px); overflow: hidden; }

/* Outer book holder. JS sizes the actual .book element. */
#book { position: relative; z-index: 1; align-self: center; max-width: 100%; margin: auto; display: flex; justify-content: center; align-items: center; min-width: 0; }

/* The book dimensions are set inline by fitBookToScreen(). */
.book { position: relative; perspective: 1500px; transform-style: preserve-3d; transition: transform 1s ease-in-out; }

.book.open { transform: translateX(50%); }

.book.close { transform: translateX(100%); }

.book.open.portrait { transform: translateX(50%); }

.book.close.portrait { transform: translateX(100%); }
.page, .page * { cursor: pointer; }
/* Snow background */
#snowCanvas { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; }

/* Covers */
.back-cover, .front-cover { position: absolute; width: 100%; height: 100%; border-radius: 0 10px 10px 0; box-shadow: 0 0 10px #ffd76a; transform-origin: left; }

.front-cover { z-index: var(--reverse-count); transition: transform 1.5s; animation: turnEffect 2s ease-in-out; }

.back-cover { z-index: var(--reverse-count); transition: transform 1.5s,z-index 0.5s 0.5s; }

.book > .back-cover > .front-page, .book > .front-cover > .front-page { border-radius: 0 10px 10px 0; overflow: hidden; }

.book > .back-cover > .back-page, .book > .front-cover > .back-page { border-radius: 10px 0 0 10px; overflow: hidden; }

/* Pages and page faces */
.page { position: absolute; transform-origin: left; transform-style: preserve-3d; transform: rotateY(-20deg); }

.inner.page { width: 100%; height: 100%; border-radius: 10px; background: transparent; }

.page .blank { background: #fff; }

.page.first-half { transition: transform 1.5s; }

.page.last-half { transition: transform 1.5s,z-index 0.5s 0.5s; }

.page img { position: absolute; width: auto; height: 100%; }

.back-page, .front-page { position: absolute; width: 100%; height: 100%; overflow: hidden; background: #fff; backface-visibility: hidden; }

.front-page img { right: 0; }

.back-page { z-index: 99; transform: rotateY(180deg); }

.book > .inner.page > .front-page { border-radius: 0 10px 10px 0; overflow: hidden; background: transparent; }

.book > .inner.page > .back-page { border-radius: 10px 0 0 10px; overflow: hidden; background: transparent; }

#page1 img { right: unset; left: 0; }

.book .page { z-index: var(--reverse-count); }

/* Page labels */
.page label { position: absolute; bottom: 0; opacity: 0.8; font-size: 10px; font-weight: 700; -webkit-text-stroke: 1px #000; }

.front-page label { right: 0; }

.back-page label { left: 0; }

/* Open, close and page-turn animation */
.book.open .front-cover { transition: transform 1.5s,z-index 0.5s 0.5s; }

.book.open .page { box-shadow: -1px 0 4px rgba(99, 98, 98, 0.3); }

.book .page.turn { transform: rotateY(-170deg); z-index: var(--count); }

.book .page.first-half.turn { transition: transform 1.5s,z-index 0.5s 0.5s; }

.book .back-cover.turn, .book .page.last-half.turn { transition: transform 1.5s; }

@keyframes turnEffect {
  0%, 10% { transform: rotateY(-20deg); }
  60% { transform: rotateY(-40deg); }
  100% { transform: rotateY(-20deg); }
}

/* Toolbar buttons */
.album-nav-arrow, .album-tool-button { display: flex; flex: 0 0 35px; align-items: center; justify-content: center; width: 35px; height: 35px; padding: 0; color: #fff; font-size: 20px; background: transparent; border: 0; cursor: pointer; transition: background 0.2s,box-shadow 0.2s; }

.album-nav-arrow:hover, .album-tool-button:hover { background: rgba(6, 147, 255, 0.12); box-shadow: 0 0 12px rgba(6, 147, 255, 0.15); }

.album-toolbar button:focus-visible { outline: 2px solid #fff; }

/* Existing toolbar thumbnails */
.album-thumbnails { display: flex; flex: 1 1 auto; align-items: center; gap: 10px; min-width: 0; height: 100%; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; scroll-behavior: smooth; }

.album-thumbnails::-webkit-scrollbar { display: none; }

.album-thumb { position: relative; flex: 0 0 42px; width: 42px; height: 45px; padding: 0; overflow: visible; cursor: pointer; opacity: 0.78; background: #191919; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 5px; transition: opacity 0.2s,border-color 0.2s,transform 0.2s; }

.album-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }

.album-thumb.active { opacity: 1; border: 2px solid #fff; box-shadow: 0 0 9px rgba(6, 147, 255, 0.18); transform: translateY(-2px); }

.album-thumb-label { position: absolute; top: calc(100% + 3px); right: 0; left: 0; color: #dedede; font-size: 10px; font-weight: 600; line-height: 12px; text-align: center; white-space: nowrap; }

.album-thumb.active .album-thumb-label { color: #fff; }

/* Page counter */
.album-page-status { display: flex; flex: 0 0 auto; align-items: center; gap: 6px; padding: 0 10px; border-left: 1px solid rgba(255, 255, 255, 0.1); }

.album-current-page { min-width: 42px; padding: 7px 10px; font-size: 13px; text-align: center; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(6, 147, 255, 0.4); border-radius: 9px; }

.album-total-pages { color: #aaa; font-size: 13px; font-style: italic; white-space: nowrap; }

@media (min-width: 1100px) {
  .page label { font-size: 110px; }
}

/* Hide toolbar's original thumbnail strip; filmstrip drawer uses its own track. */
#albumToolbar .album-thumbnails { display: none!important; }

/* Filmstrip drawer */
.album-filmstrip { position: fixed; z-index: 1000; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom, 0px)); width: min(850px, calc(100vw - 32px)); max-height: 0; padding: 0 10px; overflow: hidden; visibility: hidden; opacity: 0; pointer-events: none; color: #fff; background: rgba(15, 16, 20, 0.94); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 16px; box-shadow: 0 110px 50px rgba(0, 0, 0, 0.55),inset 0 1px 0 rgba(255, 255, 255, 0.04); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); transform: translate(-50%, 12px); transition: max-height 280ms ease,padding 280ms ease,opacity 220ms ease,transform 280ms ease,visibility 280ms ease; }

.album-filmstrip.is-open { max-height: min(190px, 35dvh); padding: 12px 10px 10px; visibility: visible; opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }

.filmstrip-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 27px; margin-bottom: 10px; }

.filmstrip-heading { display: flex; align-items: center; gap: 9px; min-width: 0; }

.filmstrip-heading > .fa { color: #fff; font-size: 15px; }

.filmstrip-title { color: #fff; font-size: 13px; font-weight: 700; letter-spacing: 0.2px; }

.filmstrip-count { padding: 3px 7px; color: #d0d0d0; font-size: 10px; white-space: nowrap; background: rgba(255, 255, 255, 0.08); border-radius: 20px; }

.filmstrip-close { display: flex; flex: 0 0 29px; align-items: center; justify-content: center; width: 29px; height: 29px; padding: 0; color: #ddd; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 10px; cursor: pointer; transition: color 180ms ease,background 180ms ease; }

.filmstrip-close:hover { color: #fff; background: rgba(6, 147, 255, 0.12); }

.filmstrip-track { display: flex; align-items: flex-start; gap: 12px; width: 100%; min-width: 0; max-height: 115px; overflow-x: auto; overflow-y: hidden; padding: 3px 2px 10px; overscroll-behavior-x: contain; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: rgba(6, 147, 255, 0.55) transparent; -webkit-overflow-scrolling: touch; }

.filmstrip-track::-webkit-scrollbar { height: 4px; }
.filmstrip-track::-webkit-scrollbar-track { background: transparent; }
.filmstrip-track::-webkit-scrollbar-thumb { background: rgba(6, 147, 255, 0.55); border-radius: 10px; }

.filmstrip-thumb { position: relative; display: flex; flex: 0 0 76px; flex-direction: column; align-items: center; gap: 6px; width: 76px; min-width: 0; padding: 0; color: #c7c7c7; background: transparent; border: 0; cursor: pointer; opacity: 0.75; transition: opacity 180ms ease,transform 180ms ease; }

.filmstrip-thumb:hover { opacity: 1; transform: translateY(-2px); }

.filmstrip-thumb-frame { position: relative; display: flex; align-items: center; justify-content: center; width: 76px; height: 57px; padding: 3px; overflow: hidden; background: #242424; border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 7px; transition: border-color 180ms ease,box-shadow 180ms ease; }

.filmstrip-thumb-frame img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }

.filmstrip-thumb-placeholder { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; color: #bcbcbc; font-size: 11px; background: #303030; border-radius: 4px; }

.filmstrip-thumb.active { opacity: 1; }

.filmstrip-thumb.active .filmstrip-thumb-frame { border-color: #fff; box-shadow: 0 0 12px rgba(6, 147, 255, 0.22); }

.filmstrip-thumb.active .filmstrip-thumb-label { color: #fff; font-weight: 700; }

.filmstrip-thumb-label { display: block; max-width: 100%; overflow: hidden; color: #c5c5c5; font-size: 10px; line-height: 13px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }

.filmstrip-close:focus-visible, .filmstrip-thumb:focus-visible, .filmstrip-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* Floating controls */
.album-floating-controls { position: fixed; top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); z-index: 10000; display: flex; flex-direction: column; align-items: center; gap: 12px; }

.album-floating-controls .album-tool-button { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; color: #fff; background: rgba(0, 0, 0, 0.75); border: 0 solid rgba(6, 147, 255, 0.5); border-radius: 12px; font-size: 20px; cursor: pointer; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

.album-floating-controls .album-tool-button:hover { background: rgba(6, 147, 255, 0.2); }

/* Statistics panel */
.album-stats { position: fixed; top: 50%; right: max(16px, env(safe-area-inset-right)); transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px 8px; background: rgba(15, 15, 15, 0.88); border: 2px solid rgba(255, 255, 255, 0.12); border-radius: 15px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35),inset 0 1px 0 rgba(255, 255, 255, 0.04); z-index: 900; }

.album-stat-item { display: flex; flex-direction: column; align-items: center; gap: 5px; color: #fff; text-align: center; font-family: inherit; }

.album-stat-icon { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; width: 48px; height: 48px; flex-shrink: 0; box-sizing: border-box; border: 1px solid rgba(6, 147, 255, 0.65); border-radius: 50%; color: #fff; background: rgba(6, 147, 255, 0.06); box-shadow: 0 0 12px rgba(6, 147, 255, 0.06); }

.album-stat-icon i { font-size: 15px; line-height: 1; }

.album-stat-icon .album-stat-count { font-size: 10px; line-height: 1; font-weight: 700; color: #fff; white-space: nowrap; }

.album-stat-label { font-size: 10px; line-height: 1.2; color: rgba(255, 255, 255, 0.65); }

/* =========================================================
   RESPONSIVE CONTROLS
   Book dimensions remain owned by fitBookToScreen() in JS.
   ========================================================= */

@media (max-width: 900px) {
  body, html { width: 100%; max-width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
  .main { width: 100%; height: 100vh; height: 100svh; height: 100dvh; min-height: 0; padding: 0; gap: 0; justify-content: center; align-items: center; overflow: hidden; }
  #book { flex: 0 1 auto; min-width: 0; min-height: 0; margin: 0 auto; }
  .album-toolbar > * { min-width: 0; }
  .album-toolbar .album-page-status { flex: 0 0 auto; gap: 3px; padding: 0 3px; }
  .album-toolbar .album-current-page { min-width: 29px; padding: 5px 3px; font-size: 11px; }
  .album-toolbar .album-total-pages { font-size: 10px; }
  .album-floating-controls { top: max(8px, env(safe-area-inset-top, 0px)); right: max(8px, env(safe-area-inset-right, 0px)); gap: 6px; }
  .album-floating-controls .album-tool-button { width: 38px; height: 38px; font-size: 17px; border-radius: 10px; }
  .album-filmstrip { left: 50%; right: auto; bottom: calc(60px + env(safe-area-inset-bottom, 0px)); width: min(850px, calc(100vw - 16px)); max-width: calc(100vw - 16px); border-radius: 13px; }
  .album-filmstrip.is-open { max-height: min(180px, 32dvh); padding: 9px 9px 8px; }
  .filmstrip-header { gap: 8px; margin-bottom: 7px; }
  .filmstrip-track { gap: 8px; max-height: 100px; padding-bottom: 7px; }
  .filmstrip-thumb { flex-basis: 62px; width: 62px; gap: 4px; }
  .filmstrip-thumb-frame { width: 62px; height: 46px; }
  .filmstrip-thumb-label { font-size: 9px; line-height: 11px; }
  .album-stats { right: max(8px, env(safe-area-inset-right, 0px)); gap: 6px; padding: 7px 4px; }
  .album-stat-icon { width: 36px; height: 36px; }
  .album-stat-label { font-size: 9px; }
  .page label { font-size: clamp(7px, 1.8vw, 10px); }
}

/* Portrait */
@media (max-width: 900px) and (orientation: portrait) {
  .main { flex-direction: column; justify-content: center; align-items: center; padding: 0; }
  .album-stats { top: max(8px, env(safe-area-inset-top, 0px)); right: calc(54px + env(safe-area-inset-right, 0px)); left: max(8px, env(safe-area-inset-left, 0px)); bottom: auto; width: auto; max-width: calc(100vw - 72px); flex-direction: row; justify-content: flex-start; gap: 5px; padding: 5px 6px; overflow-x: auto; overflow-y: hidden; transform: none; border-width: 1px; border-radius: 12px; scrollbar-width: none; }
  .album-stats::-webkit-scrollbar { display: none; }
  .album-stat-item { flex: 0 0 auto; min-height: 0; width: 40px; gap: 2px; }
  .album-stat-icon { width: 30px; height: 30px; gap: 2px; }
  .album-stat-icon i { font-size: 11px; }
  .album-stat-icon .album-stat-count { font-size: 9px; }
  .album-stat-label { font-size: 7px; line-height: 1.05; white-space: nowrap; }
  .album-floating-controls { flex-direction: column; gap: 5px; }
  .album-floating-controls .album-tool-button { width: 36px; height: 36px; }
  .album-filmstrip { bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
  .album-filmstrip.is-open { max-height: min(160px, 28dvh); }
  .filmstrip-thumb { flex-basis: 58px; width: 58px; }
  .filmstrip-thumb-frame { width: 58px; height: 43px; }
}

/* Landscape */
@media (max-width: 1000px) and (orientation: landscape) {
  .main { flex-direction: column; justify-content: center; align-items: center; padding: 0; gap: 0; }
  .album-toolbar { left: max(8px, env(safe-area-inset-left, 0px)); right: max(8px, env(safe-area-inset-right, 0px)); bottom: max(6px, env(safe-area-inset-bottom, 0px)); min-height: 40px; padding: 4px 6px; gap: 4px; }
  .album-toolbar .album-nav-arrow, .album-toolbar .album-tool-button { flex-basis: 28px; width: 28px; height: 28px; font-size: 15px; }
  .album-toolbar .album-current-page { min-width: 26px; padding: 3px 2px; font-size: 10px; }
  .album-toolbar .album-total-pages { font-size: 9px; }
  .album-floating-controls { flex-direction: row; gap: 5px; }
  .album-floating-controls .album-tool-button { width: 32px; height: 32px; font-size: 15px; border-radius: 8px; }
  .album-filmstrip { bottom: calc(48px + env(safe-area-inset-bottom, 0px)); width: min(700px, calc(100vw - 16px)); }
  .album-filmstrip.is-open { max-height: min(128px, 36dvh); padding: 7px 8px; }
  .filmstrip-header { min-height: 22px; margin-bottom: 4px; }
  .filmstrip-title { font-size: 11px; }
  .filmstrip-count { font-size: 9px; }
  .filmstrip-track { max-height: 66px; gap: 7px; padding: 2px 2px 5px; }
  .filmstrip-thumb { flex-basis: 52px; width: 52px; gap: 3px; }
  .filmstrip-thumb-frame { width: 52px; height: 36px; padding: 2px; }
  .filmstrip-thumb-label { font-size: 8px; line-height: 9px; }
  .album-stats { top: 50%; right: max(5px, env(safe-area-inset-right, 0px)); left: auto; bottom: auto; width: 42px; max-width: 42px; padding: 4px 2px; gap: 3px; transform: translateY(-50%); border-width: 1px; border-radius: 11px; }
  .album-stat-item { width: 36px; min-height: 34px; gap: 1px; }
  .album-stat-icon { width: 27px; height: 27px; gap: 1px; }
  .album-stat-icon i { font-size: 10px; }
  .album-stat-icon .album-stat-count { font-size: 8px; }
  .album-stat-label { display: none; }
  .page label { font-size: 8px; }
}

/* Very narrow portrait screens */
@media (max-width: 360px) and (orientation: portrait) {
  .album-stats { right: calc(48px + env(safe-area-inset-right, 0px)); max-width: calc(100vw - 60px); gap: 3px; padding: 4px; }
  .album-stat-item { width: 35px; }
}

/* Very short screens */
@media (max-width: 900px) and (max-height: 460px) {
  .main { padding: 0; }
  .album-toolbar { min-height: 35px; padding: 3px 4px; }
  .album-toolbar .album-nav-arrow, .album-toolbar .album-tool-button { flex-basis: 25px; width: 25px; height: 25px; font-size: 13px; }
  .album-filmstrip { bottom: calc(41px + env(safe-area-inset-bottom, 0px)); }
  .album-filmstrip.is-open { max-height: min(105px, 30dvh); padding: 5px 6px; }
  .filmstrip-track { max-height: 52px; }
  .filmstrip-thumb { flex-basis: 43px; width: 43px; }
  .filmstrip-thumb-frame { width: 43px; height: 30px; }
  .filmstrip-thumb-label { display: none; }
  .album-stats { gap: 2px; padding: 3px 2px; }
  .album-stat-item { min-height: 27px; }
  .album-stat-icon { width: 23px; height: 23px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .front-cover { animation: none; }
  .album-thumbnails { scroll-behavior: auto; }
  .album-filmstrip,   .filmstrip-close,   .filmstrip-thumb, .filmstrip-thumb-frame { transition: none!important; }
  .filmstrip-track { scroll-behavior: auto; }
}
/* =========================================================
   PHOTWORK FLIPBOOK — FINAL RESPONSIVE TOOLBAR
   Replace the previously added toolbar override with this.
   ========================================================= */

.album-toolbar { position: fixed; z-index: 1000; left: 50%; right: auto; bottom: max(16px, env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: row; align-items: center; justify-content: space-between; width: min(850px, calc(100vw - 32px)); max-width: 100%; min-width: 0; padding: 7px 10px; gap: 6px; box-sizing: border-box; transform: translateX(-50%); color: #fff; background: rgba(12, 14, 18, 0.94); border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 16px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45),inset 0 1px 0 rgba(255, 255, 255, 0.05); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }

/* Prevent children from expanding the toolbar */
.album-toolbar > * { min-width: 0; }

/* Navigation and action buttons */
.album-toolbar .album-nav-arrow, .album-toolbar .album-tool-button { display: flex; flex: 0 0 36px; align-items: center; justify-content: center; width: 36px; min-width: 36px; height: 36px; padding: 0; font-size: 18px; color: #fff; background: rgba(255, 255, 255, 0.045); border: 1px solid rgba(255, 255, 255, 0.07); border-radius: 11px; transition: background 180ms ease,border-color 180ms ease,transform 180ms ease; }

.album-toolbar .album-nav-arrow:hover, .album-toolbar .album-tool-button:hover { background: rgba(6, 147, 255, 0.16); border-color: rgba(6, 147, 255, 0.45); }

/* Page counter */
.album-toolbar .album-page-status { display: flex; flex: 0 1 auto; align-items: center; justify-content: center; min-width: 0; gap: 5px; padding: 0 5px; overflow: hidden; }

.album-toolbar .album-current-page { flex: 0 1 auto; min-width: 34px; padding: 7px 6px; font-size: 12px; font-weight: 700; line-height: 1; text-align: center; white-space: nowrap; background: rgba(6, 147, 255, 0.10); border: 1px solid rgba(6, 147, 255, 0.4); border-radius: 9px; }

.album-toolbar .album-total-pages { flex: 0 1 auto; min-width: 0; color: #a7a7a7; font-size: 11px; white-space: nowrap; }

/* =========================================================
   TABLET AND MOBILE
   ========================================================= */

@media (max-width: 900px) {
  .album-toolbar { left: max(8px, env(safe-area-inset-left, 0px)); right: max(8px, env(safe-area-inset-right, 0px)); bottom: max(8px, env(safe-area-inset-bottom, 0px)); width: auto; max-width: none; padding: 5px 7px; gap: 5px; transform: none; border-radius: 14px; }
  .album-toolbar .album-nav-arrow, .album-toolbar .album-tool-button { flex-basis: 34px; width: 34px; min-width: 34px; height: 34px; font-size: 17px; border-radius: 10px; }
  .album-toolbar .album-page-status { gap: 3px; padding: 0 2px; }
  .album-toolbar .album-current-page { min-width: 30px; padding: 6px 4px; font-size: 11px; }
  .album-toolbar .album-total-pages { font-size: 10px; }
}

/* =========================================================
   SMALL MOBILE PHONES
   ========================================================= */

@media (max-width: 480px) {
  .album-toolbar { gap: 3px; padding: 5px; }
  .album-toolbar .album-nav-arrow, .album-toolbar .album-tool-button { flex-basis: 31px; width: 31px; min-width: 31px; height: 32px; font-size: 15px; }
  .album-toolbar .album-page-status { gap: 2px; padding: 0 1px; }
  .album-toolbar .album-current-page { min-width: 27px; padding: 5px 3px; font-size: 10px; }
  .album-toolbar .album-total-pages { font-size: 9px; }
}

/* =========================================================
   VERY NARROW PHONES
   ========================================================= */

@media (max-width: 360px) {
  .album-toolbar { gap: 2px; padding: 4px; }
  .album-toolbar .album-nav-arrow, .album-toolbar .album-tool-button { flex-basis: 28px; width: 28px; min-width: 28px; height: 30px; font-size: 14px; }
  .album-toolbar .album-total-pages { display: none; }
}

/* =========================================================
   MOBILE LANDSCAPE
   ========================================================= */

@media (max-width: 1000px) and (orientation: landscape) {
  .album-toolbar { left: max(8px, env(safe-area-inset-left, 0px)); right: max(8px, env(safe-area-inset-right, 0px)); bottom: max(6px, env(safe-area-inset-bottom, 0px)); width: auto; max-width: none; min-height: 40px; padding: 4px 6px; gap: 4px; transform: none; }
  .album-toolbar .album-nav-arrow, .album-toolbar .album-tool-button { flex-basis: 29px; width: 29px; min-width: 29px; height: 29px; font-size: 14px; }
  .album-toolbar .album-current-page { min-width: 25px; padding: 4px 2px; font-size: 10px; }
  .album-toolbar .album-total-pages { font-size: 9px; }
}

/* =========================================================
   SHORT LANDSCAPE SCREENS
   ========================================================= */

@media (max-width: 900px) and (max-height: 460px) {
  .album-toolbar { padding: 3px 5px; gap: 3px; border-radius: 11px; }
  .album-toolbar .album-nav-arrow, .album-toolbar .album-tool-button { flex-basis: 26px; width: 26px; min-width: 26px; height: 26px; font-size: 13px; }
  .album-toolbar .album-current-page { padding: 3px 2px; font-size: 9px; }
}

/* =========================================================
   RETURN TO FRONT COVER — RESPONSIVE
   ========================================================= */

#albumFirstPage { position: relative; display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; width: clamp(30px, 4vw, 36px); min-width: 0; height: clamp(30px, 4vw, 36px); padding: 0; overflow: visible; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

#albumFirstPage .fa-book { display: block; font-size: clamp(16px, 2vw, 19px); line-height: 1; pointer-events: none; }

#albumFirstPage .album-return-arrow { position: absolute; left: 3px; bottom: 3px; display: block; font-size: clamp(8px, 1.1vw, 10px); line-height: 1; color: #0693ff; background: #0c0e12; border-radius: 50%; padding: 2px; pointer-events: none; }

/* Desktop and tablet hover */
@media (hover: hover) and (pointer: fine) {
  #albumFirstPage:hover { background: rgba(6, 147, 255, 0.12); }
}

/* =========================================================
   CLICK ANIMATION
   ========================================================= */

.book-click-effect { position: fixed; left: 0; top: 0; width: 0; height: 0; z-index: 999999; pointer-events: none; }

.book-click-ring { position: absolute; width: 18px; height: 18px; left: -9px; top: -9px; border: 1.5px solid #d8b94e; border-radius: 50%; box-shadow: 0 0 4px rgba(255, 215, 106, 0.6),inset 0 0 3px rgba(255, 215, 106, 0.3); animation: bookClickRing 500ms ease-out forwards; }

.book-click-particle { position: absolute; left: 0; top: 0; width: var(--particle-size); height: var(--particle-size); border-radius: 50%; background: #ffd76a; filter: blur(2px); box-shadow: 0 0 5px rgba(255, 215, 106, 0.8); animation: bookClickParticle 1500ms ease-out forwards; }

@keyframes bookClickRing {
  0% { transform: scale(0.65); opacity: 0; }
  20% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(1.5); opacity: 0; }
}

@keyframes bookClickParticle {
  0% { transform: translate(0, 0) scale(0.6); opacity: 0; }
  20% { opacity: 0.8; }
  100% { transform: translate(         var(--particle-x),       var(--particle-y)     ) scale(0.7); opacity: 0; }
}

/* =========================================================
   TAP TO OPEN OVERLAY — RESPONSIVE
   ========================================================= */

.tap-to-open { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; /* Keep overlay above the book pages */ z-index: 100; /* Only the actual button receives pointer events */ pointer-events: none; opacity: 1; visibility: visible; transition: opacity 0.35s ease,visibility 0.35s ease; }

/* Button */
.tap-to-open button { pointer-events: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; /* Responsive button sizing */ gap: clamp(4px, 1vw, 7px); padding: clamp(8px, 1.5vw, 12px); /* Prevent button from exceeding available screen space */ max-width: calc(100% - 24px); max-height: calc(100% - 24px); box-sizing: border-box; border: 1px solid rgba(255, 215, 106, 0.8); border-radius: clamp(10px, 2vw, 15px); background: rgba(20, 15, 10, 0.72); color: #ffd76a; font-family: inherit; font-size: clamp(9px, 1.2vw, 10px); font-weight: 600; line-height: 1.2; text-align: center; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 8px 35px rgba(0, 0, 0, 0.35); transition: transform 0.25s ease,background 0.25s ease; }

/* Icon */
.tap-to-open button i { display: block; font-size: clamp(17px, 2.5vw, 20px); line-height: 1; }

/* Hover only on devices that actually support hover */
@media (hover: hover) and (pointer: fine) {
  .tap-to-open button:hover { background: rgba(20, 15, 10, 0.9); transform: scale(1.05); }
}

/* Press */
.tap-to-open button:active { transform: scale(0.96); }

/* Hidden state */
.tap-to-open.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

/* Accessibility */
#albumFirstPage:focus-visible, .tap-to-open button:focus-visible { outline: 2px solid #0693ff; outline-offset: 4px; }

/* =========================================================
   MOBILE PORTRAIT
   ========================================================= */

@media (max-width: 600px) and (orientation: portrait) {
  #albumFirstPage { width: 31px; height: 32px; }
  #albumFirstPage .fa-book { font-size: 17px; }
  #albumFirstPage .album-return-arrow { left: 2px; bottom: 2px; font-size: 9px; padding: 2px; }
  .tap-to-open button { gap: 5px; padding: 9px 10px; border-radius: 12px; font-size: 9px; }
  .tap-to-open button i { font-size: 18px; }
}

/* =========================================================
   MOBILE LANDSCAPE
   ========================================================= */

@media (max-width: 1000px) and (orientation: landscape) {
  #albumFirstPage { width: 29px; height: 29px; }
  #albumFirstPage .fa-book { font-size: 16px; }
  #albumFirstPage .album-return-arrow { left: 2px; bottom: 2px; font-size: 8px; padding: 1.5px; }
  .tap-to-open button { gap: 4px; padding: 7px 9px; border-radius: 10px; font-size: 8px; }
  .tap-to-open button i { font-size: 16px; }
}

/* =========================================================
   VERY SHORT LANDSCAPE SCREENS
   ========================================================= */

@media (max-width: 900px) and (max-height: 460px) {
  #albumFirstPage { width: 26px; height: 26px; }
  #albumFirstPage .fa-book { font-size: 14px; }
  #albumFirstPage .album-return-arrow { left: 1px; bottom: 1px; font-size: 7px; padding: 1.5px; }
  .tap-to-open button { gap: 3px; padding: 6px 8px; border-radius: 9px; font-size: 8px; }
  .tap-to-open button i { font-size: 14px; }
}

/* =========================================================
   VERY NARROW PHONES
   ========================================================= */

@media (max-width: 360px) {
  #albumFirstPage { width: 27px; height: 29px; }
  #albumFirstPage .fa-book { font-size: 15px; }
  #albumFirstPage .album-return-arrow { left: 1px; bottom: 1px; font-size: 7px; }
  .tap-to-open button { gap: 4px; padding: 7px 8px; font-size: 8px; }
  .tap-to-open button i { font-size: 15px; }
}

/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  .tap-to-open, .tap-to-open button { transition: none; }
  .book-click-particle, .book-click-ring { animation-duration: 1ms; }
}
