/* ============================================================
   Control the Ball — Flipbook
   ============================================================ */

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

:root {
  --green-900: #0d3311;
  --green-800: #133f17;
  --green-700: #1b5e20;
  --green-600: #2e7d32;
  --green-500: #388e3c;
  --green-300: #a5d6a7;
  --green-50:  #eaf4ec;
  --cream:     #fff8e7;
  --gold-500:  #fbc02d;
  --gold-600:  #f9a825;
  --paper:     #fdfaf2;
  --ink:       #1a1a1a;
  --ink-soft:  #2c2c2c;
  --shadow-lg: 0 24px 60px rgba(0,0,0,.45);
  --shadow-md: 0 8px 24px rgba(0,0,0,.25);
  --book-max:  640px;
}

html { font-size: 16px; }

body {
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  color: #fff;
  min-height: 100vh;
  /* layered field-green ambient: radial vignette + diagonal gradient */
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(46,125,50,.55) 0%, transparent 70%),
    radial-gradient(ellipse 90% 80% at 50% 110%, rgba(0,0,0,.55) 0%, transparent 60%),
    linear-gradient(170deg, #154a1a 0%, #0a2810 60%, #061a09 100%);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* faint stitched-pitch lines (very subtle) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(0deg,
      rgba(255,255,255,.012) 0px,
      rgba(255,255,255,.012) 1px,
      transparent 1px,
      transparent 80px);
  z-index: 0;
}

/* ---------- Header ---------- */
.top-bar {
  position: relative;
  z-index: 5;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: rgba(0,0,0,.32);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: .85rem;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  border-radius: 8px;
  padding: 4px;
  margin: -4px;
  transition: background .15s;
}
.brand:hover { background: rgba(255,255,255,.06); }
.brand-mark {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--gold-500);
  color: var(--green-900);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: .02em;
  box-shadow: 0 2px 8px rgba(0,0,0,.3), inset 0 -2px 0 rgba(0,0,0,.12);
}
.brand-text {
  min-width: 0;
  line-height: 1.15;
}
.brand-eyebrow {
  display: block;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold-500);
}
.brand-title {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
}
.brand-sub {
  display: block;
  font-size: .72rem;
  color: rgba(255,255,255,.6);
  margin-top: 1px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}
.icon-btn,
.download-btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: .85rem;
  padding: .55rem .95rem;
  border-radius: 8px;
  transition: background .18s, transform .12s, color .18s;
  text-decoration: none;
  color: #fff;
}
.icon-btn {
  background: rgba(255,255,255,.08);
  color: #fff;
  padding: .55rem;
  width: 40px;
  height: 40px;
  justify-content: center;
}
.icon-btn--text {
  width: auto;
  padding: .55rem .9rem;
}
.icon-btn:hover { background: rgba(255,255,255,.18); }
.download-btn {
  background: var(--gold-500);
  color: var(--green-900);
  text-decoration: none;
}
.download-btn:hover { background: var(--gold-600); transform: translateY(-1px); }

/* ---------- Stage ---------- */
.stage {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 2rem 1.25rem 1rem;
  gap: 1rem;
}

.nav-arrow {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  color: #fff;
  font-size: 1.6rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .18s, transform .15s, opacity .2s;
  line-height: 1;
}
.nav-arrow svg { width: 22px; height: 22px; }
.nav-arrow:hover:not(:disabled) {
  background: rgba(255,255,255,.20);
  transform: scale(1.06);
}
.nav-arrow:disabled { opacity: .2; cursor: default; }

/* ---------- Book (slide style) ---------- */
.book {
  width: min(86vw, 70vh, var(--book-max));
  aspect-ratio: 1 / 1;
  position: relative;
  overflow: hidden;
  border-radius: 2px 6px 6px 2px;
  background: var(--paper);
  filter:
    drop-shadow(0 18px 28px rgba(0,0,0,.45))
    drop-shadow(0 4px 8px rgba(0,0,0,.3));
}

/* spine highlight on left edge */
.book::before {
  content: '';
  position: absolute;
  top: 2%;
  bottom: 2%;
  left: -6px;
  width: 12px;
  background: linear-gradient(90deg, rgba(0,0,0,.5), rgba(0,0,0,0));
  border-radius: 4px 0 0 4px;
  z-index: 2;
  filter: blur(2px);
  pointer-events: none;
}

.sheet {
  position: absolute;
  inset: 0;
  background: var(--paper);
  transition: transform .55s cubic-bezier(.32, .72, 0, 1);
  will-change: transform;
  cursor: pointer;
  /* soft inner edge shadow on the binding side + a hair on the right */
  box-shadow:
    inset 14px 0 18px -14px rgba(0,0,0,.18),
    inset -1px 0 0 rgba(0,0,0,.05);
}
.sheet img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.sheet.in   { transform: translateX(0); }
.sheet.out  { transform: translateX(-102%); }
.sheet.next { transform: translateX(102%); }

/* ---------- Footer: counter + thumbnails ---------- */
.footer {
  position: relative;
  z-index: 5;
  width: 100%;
  padding: .25rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
}

.page-info {
  display: flex;
  align-items: center;
  gap: .9rem;
  font-size: .85rem;
  font-weight: 700;
  color: rgba(255,255,255,.85);
  background: rgba(0,0,0,.35);
  padding: .45rem .9rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.08);
}
.page-info .dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,.35);
}

.thumbs {
  width: 100%;
  max-width: 1100px;
  display: flex;
  gap: 6px;
  padding: .35rem .25rem;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.25) transparent;
  justify-content: center;
}
.thumbs::-webkit-scrollbar { height: 6px; }
.thumbs::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.25);
  border-radius: 999px;
}

.thumb {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--paper);
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform .15s, border-color .15s, opacity .2s;
  opacity: .65;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.thumb:hover { opacity: 1; transform: translateY(-2px); }
.thumb.active {
  border-color: var(--gold-500);
  opacity: 1;
  box-shadow: 0 4px 14px rgba(251,192,45,.35);
}
.thumb .thumb-num {
  position: absolute;
  bottom: 0; right: 0;
  font-size: 8px;
  font-weight: 800;
  color: #fff;
  background: rgba(0,0,0,.55);
  padding: 1px 3px 0;
  border-radius: 3px 0 0 0;
  line-height: 1.2;
}

/* mobile prev/next */
.mobile-nav {
  display: none;
  gap: .6rem;
}
.mobile-nav button {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.1);
  color: #fff;
  padding: .55rem 1.2rem;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.mobile-nav button:disabled { opacity: .25; }

/* ---------- Fullscreen ---------- */
body.fs .top-bar,
body.fs .footer { display: none; }
body.fs .stage { padding: 1rem; }
body.fs .book { width: min(96vw, 96vh, 920px); }
body.fs .fs-exit { display: inline-flex; }
.fs-exit {
  display: none;
  position: fixed;
  top: 1rem; right: 1rem;
  z-index: 50;
  background: rgba(0,0,0,.5);
  color: #fff;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 999px;
  padding: .5rem .9rem;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  align-items: center;
  gap: .4rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .top-bar { padding: .75rem 1rem; }
  .brand-mark { width: 32px; height: 32px; font-size: .85rem; }
  .brand-eyebrow { font-size: .6rem; }
  .brand-title { font-size: .92rem; }
  .brand-sub { display: none; }
  .icon-btn--text span { display: none; }
  .icon-btn--text { width: 40px; padding: .55rem; justify-content: center; }
  .download-btn span { display: none; }
  .download-btn { padding: .55rem; width: 40px; height: 40px; justify-content: center; }
  .stage { padding: 1rem .5rem .5rem; gap: .25rem; }
  .nav-arrow { display: none; }
  .mobile-nav { display: flex; }
  .book { width: min(94vw, 70vh); }
  .thumb { width: 34px; height: 34px; }
  .thumb .thumb-num { font-size: 7px; }
}

@media (max-width: 420px) {
  .thumbs { gap: 4px; }
  .thumb { width: 28px; height: 28px; border-width: 1.5px; }
}

/* ---------- Print: full PDF reading ---------- */
@media print {
  body { background: white; color: black; }
  .top-bar, .footer, .nav-arrow, .fs-exit, .mobile-nav, .thumbs, .page-info { display: none !important; }
  .stage { padding: 0; }
  .book { width: 100%; aspect-ratio: 1/1; filter: none; overflow: visible; }
  .sheet { transform: none !important; position: relative; page-break-after: always; }
}
