@import url("https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700&family=Barlow:wght@400;500;600;700&display=swap");

:root {
  --bg: #f7f3f3;
  --surface: #ffffff;
  --line: #d7c5cb;
  --text: #18275c;
  --muted: #5c657d;
  --accent: #a51d43;
  --brand-navy: #243778;
  --brand-burgundy: #a51d43;
  --danger: #a51d43;
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

@font-face {
  font-family: "Playpen Sans";
  src: url("./fonts/PlaypenSans-wght.ttf") format("truetype");
  font-display: swap;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Barlow", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
}

.app-body {
  position: relative;
  height: 100vh;
  display: flex;
  flex-direction: column;
  isolation: isolate;
  overflow: hidden;
}

.app-body.library-active {
  min-height: 100vh;
  height: auto;
  overflow: auto;
}

.app-body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("https://res.cloudinary.com/dozcy2jve/image/upload/v1777494466/images/xxx_Panda_Buck_Playbook.pdf_uksa6j.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.14;
  pointer-events: none;
  z-index: -1;
}

.brand-logo {
  width: 68px;
  flex: 0 0 auto;
  height: auto;
  object-fit: contain;
  z-index: 2;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.16));
  pointer-events: none;
}

.brand-watermark {
  position: fixed;
  right: 5px;
  bottom: 4px;
  margin: 0;
  font-size: 8px;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: rgba(36, 55, 120, 0.74);
  z-index: 35;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.45);
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  clip: rect(0, 0, 0, 0);
  overflow: hidden;
}

.btn {
  border: 1px solid rgba(36, 55, 120, 0.3);
  background: rgba(255, 255, 255, 0.94);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--text);
  font-family: "Barlow Condensed", sans-serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.btn:hover {
  border-color: var(--brand-burgundy);
  background: var(--brand-burgundy);
  color: #ffffff;
}

.btn.danger {
  border-color: #fecaca;
  color: var(--danger);
}

.viewer-main,
.admin-main {
  max-width: none;
  margin: 0 auto;
  padding: 24px;
}

.library-main {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 42px 32px 72px;
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.library-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.library-eyebrow,
.book-card-type {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand-burgundy);
}

.library-brand h1 {
  margin: 2px 0 0;
  font-size: 26px;
  line-height: 1;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.library-admin-link {
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.library-intro {
  max-width: 650px;
  margin: 80px 0 44px;
}

.library-intro h2 {
  margin: 8px 0 12px;
  max-width: 550px;
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.04;
  letter-spacing: -0.045em;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
}

.library-intro > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
}

.book-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 28px;
}

.book-card {
  min-width: 0;
}

.book-card-cover {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #dfddd5;
  border-radius: 4px;
  box-shadow: 12px 14px 0 rgba(124, 74, 36, 0.12), 0 18px 30px rgba(31, 24, 18, 0.22);
  transform: translateY(0);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.book-card-cover:hover,
.book-card-cover:focus-visible {
  transform: translateY(-6px);
  box-shadow: 14px 18px 0 rgba(124, 74, 36, 0.15), 0 25px 36px rgba(31, 24, 18, 0.25);
}

.book-card-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-card-open {
  position: absolute;
  inset: auto 12px 12px;
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  color: #fff;
  background: rgba(17, 24, 39, 0.88);
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.book-card-cover:hover .book-card-open,
.book-card-cover:focus-visible .book-card-open {
  opacity: 1;
  transform: translateY(0);
}

.book-card-details {
  padding-top: 18px;
}

.book-card-details h3 {
  margin: 6px 0;
  font-size: 20px;
  line-height: 1.12;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 24px;
  font-weight: 700;
}

.book-card-details h3 a {
  color: inherit;
  text-decoration: none;
}

.book-card-details > p:not(.book-card-type) {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.book-card-pages {
  display: block;
  margin-top: 14px;
  color: #7b7067;
  font-size: 12px;
  font-weight: 700;
}

.viewer-main {
  flex: 1;
  width: 100%;
  padding-top: 8px;
  padding-bottom: 28px;
  display: flex;
  flex-direction: column;
}

.viewer-toolbar,
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.viewer-toolbar {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 25;
  background: transparent;
  backdrop-filter: none;
  padding: 4px 6px;
  margin-bottom: 0;
  gap: 10px;
}

.page-status {
  width: auto;
  text-align: left;
  flex: 0 0 auto;
  margin-bottom: 0;
}

.page-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

#goto-page {
  width: 72px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.goto-select {
  display: none !important;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mobile-actions {
  display: none !important;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.book-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 48px;
  margin-top: 8px;
  margin-bottom: 28px;
  overflow: visible;
}

.book-shell::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120px;
  height: min(78%, 760px);
  transform: translate(-50%, -50%);
  background:
    radial-gradient(
      ellipse 60% 100% at center,
      rgba(0, 0, 0, 0.12) 0%,
      rgba(0, 0, 0, 0.07) 22%,
      rgba(0, 0, 0, 0.02) 48%,
      rgba(0, 0, 0, 0) 74%
    );
  mix-blend-mode: multiply;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
  transition: opacity 220ms ease, transform 220ms ease;
}

.book-shell.is-flipping::after {
  opacity: 0.26;
  transform: translate(-50%, -50%) scaleX(1.06);
}

#flipbook {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  border-radius: 0;
  overflow: visible;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.16);
  transform: translateX(var(--cover-shift, 0px));
  transition: transform 520ms cubic-bezier(0.22, 0.61, 0.36, 1);
  perspective: 2200px;
  will-change: transform;
  position: relative;
  z-index: 12;
}

.edge-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 1px solid rgba(15, 23, 42, 0.28);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.88);
  color: #ffffff;
  font-size: 30px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 15;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
  transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.edge-nav:hover {
  border-color: rgba(255, 255, 255, 0.62);
  background: rgba(17, 24, 39, 0.96);
  transform: translateY(-50%) scale(1.06);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.34);
}

.edge-nav:active {
  transform: translateY(-50%) scale(0.94);
  background: #0f172a;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.28);
}

.edge-nav-left {
  left: 12px;
}

.edge-nav-right {
  right: 12px;
}


.page {
  background: #fff;
  overflow: hidden;
  border-radius: 0;
  box-shadow:
    inset -10px 0 14px -12px rgba(0, 0, 0, 0.2),
    inset 10px 0 14px -12px rgba(0, 0, 0, 0.18);
}

.page img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  pointer-events: none;
  border-radius: 0;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.order-page {
  display: grid;
  place-items: center;
  padding: clamp(28px, 6vw, 72px);
  text-align: center;
  background: linear-gradient(145deg, #fff6e9, #e8caa3);
}

.order-page-content {
  max-width: 460px;
}

.order-page-eyebrow {
  margin: 0 0 14px;
  color: #7c4a24;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.order-page h2 {
  margin: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1;
  letter-spacing: -0.045em;
}

.order-page p:not(.order-page-eyebrow) {
  margin: 18px 0 26px;
  color: #5d4431;
  font-size: 17px;
  line-height: 1.45;
}

.order-book-btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 21px;
  background: var(--brand-burgundy);
  color: #fff;
  cursor: pointer;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 18px rgba(165, 29, 67, 0.24);
}

.order-book-btn:hover,
.order-book-btn:focus-visible {
  background: var(--brand-navy);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

#flipbook .stf__parent,
#flipbook .stf__wrapper,
#flipbook .stf__block,
#flipbook .stf__item {
  overflow: hidden !important;
}

@media (min-width: 769px) {
  .viewer-main {
    padding-top: 16px;
  }

  .viewer-toolbar {
    z-index: 2;
  }

  .book-shell {
    padding-top: 52px;
    margin-top: 24px;
  }

  .page {
    overflow: visible;
  }

  #flipbook .stf__parent,
  #flipbook .stf__wrapper,
  #flipbook .stf__block,
  #flipbook .stf__item {
    overflow: visible !important;
  }

  #flipbook {
    z-index: 30;
  }
}

#flipbook .stf__item.-left .page {
  box-shadow:
    inset -18px 0 24px -16px rgba(0, 0, 0, 0.3),
    inset 5px 0 10px -10px rgba(0, 0, 0, 0.08);
}

#flipbook .stf__item.-right .page {
  box-shadow:
    inset 18px 0 24px -16px rgba(0, 0, 0, 0.3),
    inset -5px 0 10px -10px rgba(0, 0, 0, 0.08);
}

.auth-section,
.upload-panel,
.admin-grid .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.auth-section,
.upload-panel {
  padding: 18px;
  margin-bottom: 18px;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form input {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.message {
  color: var(--danger);
  min-height: 20px;
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 2px dashed var(--line);
  border-radius: 10px;
  background: #f9fafb;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
}

.dropzone.dragover {
  border-color: var(--accent);
  color: var(--accent);
  background: #eff6ff;
}

.hint {
  color: var(--muted);
  margin: 8px 0 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.card {
  padding: 10px;
}

.drag-handle {
  font-size: 12px;
  color: var(--muted);
  cursor: grab;
  user-select: none;
  margin-bottom: 8px;
}

.card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.card-footer {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.page-num {
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 768px) {
  body {
    height: auto;
    overflow-x: hidden;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .app-body {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .viewer-main,
  .admin-main {
    padding: 8px;
  }

  .library-main {
    padding: 24px 20px 48px;
  }

  .library-header {
    align-items: flex-start;
  }

  .library-brand h1 {
    font-size: 21px;
  }

  .library-admin-link {
    margin-top: 8px;
    font-size: 12px;
  }

  .library-intro {
    margin: 58px 0 34px;
  }

  .library-intro > p:last-child {
    font-size: 15px;
  }

  .book-library-grid {
    grid-template-columns: minmax(0, 280px);
  }

  .book-card-open {
    opacity: 1;
    transform: none;
  }

  .viewer-main {
    display: block;
    padding-top: 44px;
    padding-bottom: 6px;
  }

  .viewer-toolbar,
  .admin-header {
    flex-direction: row;
    align-items: center;
  }

  .viewer-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: transparent;
    backdrop-filter: none;
    padding: 4px 6px;
    margin-bottom: 2px;
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .page-controls {
    width: auto;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .book-shell {
    flex: 1;
    min-height: 0;
    padding: 0 8px;
    margin-top: -12px;
    margin-bottom: 18px;
    overflow: hidden;
  }

  .edge-nav {
    display: none;
  }

  .edge-nav-left {
    left: 6px;
  }

  .edge-nav-right {
    right: 6px;
  }

  .brand-logo {
    width: 48px;
    margin-left: 0;
  }

  .page-status {
    display: none;
  }

  #prev-page,
  #next-page,
  #download-pdf,
  #share-page,
  #goto-page,
  #goto-btn {
    display: none;
  }

  .goto-select {
    display: inline-block !important;
    min-width: 96px;
  }

  .mobile-actions {
    display: inline-block !important;
    min-width: 94px;
  }

  #flipbook .page,
  #flipbook .page * {
    font-size: 0 !important;
    line-height: 0 !important;
  }

  #flipbook {
    transform: scale(var(--mobile-zoom, 1));
    transform-origin: top center;
    transition: transform 180ms ease;
    touch-action: pan-y pinch-zoom;
  }
}
