/* Main edit points: colors, max width, gaps, and background image. */
:root {
  --paper: #f7f3e8; /* Warmer, more natural aged paper tone */
  --ink: #111111;
  --muted-ink: #555555;
  --line: rgba(0, 0, 0, 0.06);
  --accent: #d83413;
  --accent-soft: #fff1ed;
  --panel: rgba(247, 243, 232, 0.96);
  --max-width: 1000px; 
  --section-gap: clamp(60px, 9vw, 96px);
  --progress-percent: 14.48%;
  --page-background: var(--paper);
  --yellow-band: url("assets/fundal-web.jpg") no-repeat;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page-background);
  color: var(--ink);
  font-family: 'Inter', Arial, sans-serif;
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--page-background);
}

/* Add a very subtle grain texture to make the 'white' feel organic and premium */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.025;
  pointer-events: none;
}

a,
button {
  color: inherit;
  font: inherit;
}

a {
  text-decoration: none;
}

button {
  border: 0;
  cursor: pointer;
}

.fundraiser-page {
  position: relative;
  overflow-x: hidden;
  background: var(--paper);
  padding-bottom: 0; /* Handled by wrapper/footer */
}

.section-narrow {
  width: min(calc(100% - 42px), var(--max-width));
  margin-inline: auto;
}

.hero {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  padding-top: clamp(26px, 4vw, 46px);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  text-transform: uppercase;
}

.logo-image {
  display: block;
  width: clamp(84px, 13vw, 126px);
  height: auto;
}

.page-title {
  width: min(100%, clamp(286px, 54vw, 520px));
  margin: 6px 0 clamp(20px, 3vw, 32px);
  color: var(--accent);
  font-family: "Permanent Marker", "Comic Sans MS", cursive;
  font-size: clamp(3.6rem, 11vw, 6.5rem);
  font-weight: 400;
  line-height: 0;
  text-align: center;
}

.page-title img {
  display: block;
  width: 100%;
  height: auto;
}

/* ── Hero Reel ──────────────────────────────────────────────
   Desktop: wider look (680px) with fixed-height feel.
   Chromium: using width/height attributes in HTML + object-fit: cover
   is the most reliable way to prevent the "smart zoom" glitch. */
.reel-section {
  /* Match the 1280/2245 ratio: 
     If height is constrained to 70vh, width must be 70vh * 0.57 */
  width: min(680px, 92vw, calc(70vh * 1280 / 2245));
  margin: 0 auto;
}

.reel-shell {
  position: relative;
  width: 100%;
  /* Match video metadata exactly (1280 / 2245) to prevent any cropping/zoom */
  aspect-ratio: 1280 / 2245; 
  max-height: 70vh; 
  background: #000;
  box-shadow: 0 18px 38px rgba(16, 16, 16, 0.1);
  border-radius: 20px;
  overflow: hidden;
  isolation: isolate;
  margin-bottom: 80px; 
}

.reel-media {
  display: block;
  /* Removed object-fit and transform. 
     Scaling is now handled by fixVideoScaling() in index.html to 
     bypass the Chromium "Smart Zoom" rendering bug. */
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: fill; /* Safety: force video to match calculated JS pixels */
  background: #000;
}

.reel-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  cursor: pointer;
}

.mute-toggle {
  position: absolute;
  top: 16px !important;
  right: 16px !important;
  bottom: auto !important;
  z-index: 20;
  width: 40px;
  height: 40px;
  padding: 8px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  color: white;
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.mute-toggle:hover {
  background: rgba(0, 0, 0, 0.6);
  transform: scale(1.1);
}

.mute-toggle svg {
  width: 24px;
  height: 24px;
}

.reel-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 20px; /* Hit area */
  z-index: 25;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
}

.reel-progress-fill {
  width: 0%;
  height: 4px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(255, 128, 0, 0.4);
  transition: height 0.2s ease;
}

.reel-progress:hover .reel-progress-fill {
  height: 6px;
}

.qr-link:focus-visible,
.carousel-arrow:focus-visible,
.carousel-dots a:focus-visible {
  outline: 4px solid color-mix(in srgb, var(--accent), white 42%);
  outline-offset: 4px;
}

/* ── Intro section + Yellow Band #1 ────────────────────────
   The ::before pseudo-element creates the first yellow band.
   top: -420px pulls it up so the band's top edge lands at
   the exact horizontal midpoint of the 420px-tall reel.
   On mobile, the reel is shorter so we adjust top: -355px.  */
.intro-copy {
  position: relative;
  isolation: isolate;
  padding-top: clamp(80px, 10vw, 120px); 
}

.intro-copy::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: -420px;
  bottom: clamp(-120px, -15vw, -80px);
  left: 50%;
  width: 100vw;
  background: var(--yellow-band);
  background-size: cover;
  background-position: center 28%;
  transform: translateX(-50%);
  opacity: 1;
}
.wins-strip {
  position: absolute;
  top: 0;
  left: 0;
  /* Reduced offset to prevent iPad bleed */
  transform: translateX(-5%) rotate(-4deg);
  display: block;
  width: min(320px, 60vw);
  height: auto;
  z-index: 10;
}

.wins-stars {
  display: block;
  width: 100%;
  height: auto;
}

.wins-strip strong {
  display: none; 
}

p {
  max-width: 76ch;
  margin: 0;
  font-size: clamp(0.95rem, 1.6vw, 1.1rem);
  font-weight: 500;
  line-height: 1.6;
}

p:nth-of-type(even) {
  max-width: 72ch;
}

.copy-block {
  display: grid;
  gap: 1.4rem;
}

.copy-block p strong {
  font-weight: 700;
}

.closing-line {
  font-family: "Permanent Marker", cursive;
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  color: var(--accent);
  margin-top: 2rem;
  line-height: 1.4;
}

.goal {
  position: relative;
  z-index: 1;
  padding-top: var(--section-gap);
}

.volleyball {
  position: absolute;
  top: clamp(6px, 2.5vw, 18px);
  right: 0;
  /* Pull in for iPad */
  transform: translateX(5%);
  width: clamp(82px, 13vw, 118px);
  aspect-ratio: 1;
  animation: ball-drop 3.8s ease-in-out infinite;
}

.volleyball img {
  display: block;
  width: 100%;
  height: auto;
}

@keyframes ball-drop {
  0%, 100% { translate: 0 -10px; rotate: -5deg; }
  48% { translate: 0 12px; rotate: 8deg; }
}

.progress-meter {
  --progress-width: min(100%, max(0%, var(--progress-percent)));
  position: relative;
  padding-top: clamp(24px, 5vw, 40px);
  margin-bottom: 32px;
}

.progress-track {
  position: relative;
  height: 18px;
  overflow: visible;
  border: 2px solid var(--ink);
  background: white;
  border-radius: 999px;
}

.progress-fill {
  position: absolute;
  top: 50%;
  left: -2px;
  width: var(--progress-width);
  height: 12px;
  min-width: 24px;
  border-radius: 999px;
  background: var(--accent);
  transform: translateY(-50%);
}

.progress-numbers {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 11px;
  font-family: 'Inter', sans-serif;
  font-size: clamp(1.1rem, 2.4vw, 1.6rem);
  font-weight: 800;
  color: var(--ink);
}

.goal p {
  margin-top: clamp(18px, 3vw, 30px);
}

/* ── Donation Panel ─────────────────────────────────────────
   Layout strategy:
   - .donation-inner uses place-items: center so QR is
     always the mathematical center of the screen.
   - .qr-centering-box width: fit-content means the box is
     exactly the QR square width; margin-inline:auto centers it.
   - .donate-callout is position:absolute, so it does NOT
     affect the parent's intrinsic size / centering.
   - Yellow Band #2 anchored via ::before at top:50% of the
     QR box, which equals the QR's vertical midpoint.
   - Arrow tip alignment: translateY(-10.27%) shifts the
     image up so the tip (at 10.27% image height) lands on
     the QR's Y-axis midline.                               */
/* ── Bottom Section & Yellow Band #2 ────────────────────────
   The .page-bottom-wrapper ensures the yellow background 
   always reaches the absolute bottom of the page, even 
   on tall devices like Pixel 7 Pro, while clipping any
   unwanted bleed.                                           */
.page-bottom-wrapper {
  position: relative;
  isolation: isolate;
  overflow: clip; /* Clip the bottom bleed of the long background */
  margin-top: clamp(62px, 10vw, 104px);
}

.page-bottom-wrapper::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 170px; /* Anchored roughly to the QR midline */
  bottom: 0;
  left: 50%;
  width: 100vw;
  background: var(--yellow-band);
  background-repeat: repeat-y;
  background-size: 100% auto;
  background-position: center top;
  transform: translateX(-50%);
  opacity: 1;
}

.donation-panel {
  position: relative;
  /* Local isolation removed to allow QR background to go behind siblings */
  border-top: 2px solid var(--line);
}

.donation-inner {
  position: relative;
  display: grid;
  min-height: clamp(232px, 34vw, 340px);
  place-items: center;
}

.qr-centering-box {
  position: relative;
  width: fit-content; 
  margin-inline: auto;
}

.donate-button {
  display: block;
  width: clamp(150px, 25vw, 230px);
  aspect-ratio: 1;
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  background: white;
  border: 4px solid white;
  box-shadow: 
    0 12px 28px rgba(0, 0, 0, 0.12),
    0 4px 8px rgba(0, 0, 0, 0.08),
    inset 0 0 0 1px rgba(0,0,0,0.05);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  animation: button-pulse 3s infinite;
}


.donate-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
  display: block;
}

/* Subtle gloss overlay to make it look polished */
.donate-button::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 50%);
  pointer-events: none;
  opacity: 0.6;
  transition: opacity 0.3s ease;
  z-index: 1;
}

.donate-button:hover {
  transform: translateY(-8px) scale(1.04);
  box-shadow: 
    0 25px 50px rgba(0, 0, 0, 0.18),
    0 10px 20px rgba(0, 0, 0, 0.12);
  border-color: rgba(216, 52, 19, 0.1);
}

.donate-button:hover img {
  transform: scale(1.05);
}

.donate-button:active {
  transform: translateY(2px) scale(0.96);
  box-shadow: 
    0 5px 15px rgba(0, 0, 0, 0.1),
    inset 0 0 10px rgba(0,0,0,0.05);
  transition: all 0.1s ease;
}

/* Desktop: callout positioned to the LEFT of the QR.
   Arrow tip (at 10.27% of image height) targets the QR midline. */
.donate-callout {
  position: absolute;
  right: calc(100% + 14px);
  top: 50%; 
  /* The arrow tip is at 10.27% image height. Shift up by 10.27% to put tip on the midline. */
  transform: translateY(-10.27%) rotate(-6deg); 
  width: clamp(120px, 22vw, 200px);
  z-index: 10;
  pointer-events: none;
  animation: arrow-bounce 2s infinite ease-in-out;
}

.donation-panel::before {
  display: none; /* Removed in favor of QR-anchored version */
}

.accent-stars {
  position: absolute;
  right: 0;
  transform: translateX(5%) rotate(3deg);
  bottom: -40px; 
  width: clamp(140px, 26vw, 250px);
  z-index: 10;
}

/* ── Gallery & Carousel ─────────────────────────────────────
   Desktop: cinematic 16:9 aspect ratio.
   Mobile (≤480px): 4:5 portrait to fill the screen better.
   Carousel loops infinitely using cloned first/last slides.  */
.gallery {
  position: relative;
  z-index: 1;
  padding-top: clamp(34px, 7vw, 74px);
}

.gallery-sun {
  display: block;
  width: min(312px, 66vw);
  height: auto;
  margin-inline: auto;
}

.top-sun { margin-bottom: 24px; }
.bottom-sun { margin-top: 24px; }

.carousel-container {
  position: relative;
  width: min(1000px, 100%);
  margin-inline: auto;
  margin-bottom: 2rem;
}

.carousel {
  display: grid;
  grid-auto-columns: 100%;
  grid-auto-flow: column;
  width: 100%;
  max-width: 1000px;
  margin-inline: auto;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  cursor: grab;
}

.carousel::-webkit-scrollbar { display: none; }

.slide {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 100%;
  scroll-snap-align: center;
  padding: 10px 0;
}

.photo-card {
  position: relative;
  width: 100%;
  max-width: 1000px;
  margin: 0;
  overflow: hidden;
  border-radius: 20px;
  background: white;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
}

/* Desktop: cinematic 16:9 */
.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.carousel-arrow {
  position: absolute;
  bottom: 24px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1.5px solid white;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  backdrop-filter: blur(8px);
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}

.carousel-arrow.prev { left: 24px; }
.carousel-arrow.next { right: 24px; }

.carousel-arrow svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.5; }

.carousel-dots {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 16px;
  pointer-events: none;
}

.carousel-dots a {
  pointer-events: auto;
  width: 10px;
  height: 10px;
  border: 1.5px solid white;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.carousel-dots a.active { background: white; transform: scale(1.3); }

.site-footer {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  padding-top: clamp(24px, 4vw, 56px);
  padding-bottom: clamp(24px, 4vw, 56px);
}

.logo-footer .logo-image { width: clamp(88px, 14vw, 136px); }

/* ── Tablet / Small Desktop (≤ 620px) ──────────────────── */
@media (max-width: 620px) {
  .section-narrow { width: min(calc(100% - 32px), var(--max-width)); }
  
  .reel-section {
    /* On mobile, allow a taller 9:16 feel to fill the screen better */
    width: 92vw;
    max-width: 420px;
  }
  
  .reel-shell { 
    margin-bottom: 40px; 
    aspect-ratio: 9 / 16;
    max-height: 75vh;
  }
  
  .intro-copy { padding-top: 100px; }
  .intro-copy::before { 
    top: -355px; 
  }
  
  .wins-strip { 
    position: absolute; 
    top: 20px; 
    left: 0; 
    transform: translateX(-10%) rotate(-4deg);
    width: 180px;
    display: block;
    margin: 0;
    z-index: 10;
  }
  
  .volleyball { top: -20px; right: 0; transform: translateX(10%); width: 80px; }
  
  .donation-panel::before { 
    display: none;
  }
  
  /* ── Mobile Donation Layout ─────────────────────────────
     On mobile the "Donate" callout stacks ABOVE the QR code,
     remains centered, and uses a subtle rotation.
     The QR remains perfectly centered (margin-inline: auto).
     overflow: hidden on the page prevents any bleed.        */
  .page-bottom-wrapper::before {
    top: 110px; /* Aligned to QR midline on mobile */
  }

  .qr-centering-box {
    display: block;
    width: fit-content; 
    max-width: 100%;
    margin-inline: auto;
    position: relative;
  }

  /* Mobile: callout positioned to the LEFT of the QR, similar to desktop but tighter */
  .donate-callout { 
    position: absolute !important;
    right: calc(100% - 14px) !important; 
    top: 50% !important;
    display: block !important;
    width: clamp(100px, 28vw, 120px) !important;
    margin: 0 !important;
    transform: translateY(-10.27%) rotate(-10deg);
    pointer-events: none;
    z-index: 10;
    animation: arrow-bounce-mobile 2s infinite ease-in-out !important;
  }


  .donate-button {
    animation: button-pulse 2.2s infinite; /* Slightly faster pulse to grab attention on mobile */
  }

  .qr-link {
    width: min(160px, 45vw);
    margin-inline: auto;
    flex-shrink: 0;
  }
  
  .accent-stars {
    position: absolute;
    bottom: -45px;
    right: 0;
    width: 150px;
    transform: rotate(3deg);
    display: block;
    margin: 0;
    z-index: 10;
  }

  .carousel-container {
    margin-bottom: 40px;
  }
}

/* ── Mobile Portrait (≤ 480px) — Galaxy S25 & similar ──── */
@media (max-width: 480px) {
  .carousel-container { width: 100vw; margin-inline: calc(50% - 50vw); margin-bottom: 40px; }
  .photo-card { border-radius: 20px !important; border: none; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08); }

  /* Mobile: portrait 4:5 fills the screen better */
  .photo-card img { aspect-ratio: 4 / 5; }
  
  /* Touch-friendly: larger tap targets */
  .carousel-arrow { width: 44px; height: 44px; bottom: 16px; }
  .carousel-arrow.prev { left: 16px; }
  .carousel-arrow.next { right: 16px; }
  .carousel-dots { bottom: 28px; gap: 10px; }

  /* Ensure dot tap area is at least 44px */
  .carousel-dots a {
    width: 12px;
    height: 12px;
    padding: 8px;
    background-clip: content-box;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .volleyball { animation: none; }
}

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

@keyframes button-pulse {
  0% { box-shadow: 0 0 0 0 rgba(216, 52, 19, 0.4), 0 12px 28px rgba(0, 0, 0, 0.12); }
  70% { box-shadow: 0 0 0 20px rgba(216, 52, 19, 0), 0 12px 28px rgba(0, 0, 0, 0.12); }
  100% { box-shadow: 0 0 0 0 rgba(216, 52, 19, 0), 0 12px 28px rgba(0, 0, 0, 0.12); }
}

@keyframes arrow-bounce {
  0%, 100% { transform: translateY(-10.27%) rotate(-6deg) translateX(0); }
  50% { transform: translateY(-10.27%) rotate(-6deg) translateX(-15px); }
}

@keyframes arrow-bounce-mobile {
  0%, 100% { transform: translateY(-10.27%) rotate(-10deg) translateX(0); }
  50% { transform: translateY(-10.27%) rotate(-10deg) translateX(-8px); }
}

@keyframes label-pulse {
  0%, 100% { opacity: 0; }
  35%, 65% { opacity: 1; }
}
