/* ============================================
   FONT
   ============================================ */
@font-face {
  font-family: 'Funnel Display';
  src: url('../fonts/FunnelDisplay-VariableFont_wght.woff2') format('woff2'),
       url('../fonts/FunnelDisplay-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ============================================
   SCOPE — all rules live under .carrot-anim
   Prevents collisions with Bricks global styles
   ============================================ */
.carrot-anim {
  font-family: 'Funnel Display', -apple-system, BlinkMacSystemFont, sans-serif;
  --color-bg-light: #ffffff;
  --color-bg-dark: #1a1a1e;
  --color-text-dark: #1a1a1e;
  --color-text-light: #ffffff;
  --color-text-muted: #6b6b72;
  --color-accent: #d4652a;
  --transition-base: 0.3s ease;
}

/* ============================================
   LOADING OVERLAY
   ============================================ */
.carrot-anim .loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 1000;
  background: var(--color-bg-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  transition: opacity 0.6s ease;
}

.carrot-anim .loading-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.carrot-anim .loading-overlay__label {
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  font-family: 'Funnel Display', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.carrot-anim .loading-overlay__bar {
  width: 180px;
  height: 2px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.carrot-anim .loading-overlay__fill {
  height: 100%;
  width: 0%;
  background: var(--color-accent);
  border-radius: 2px;
  transition: width 0.15s linear;
}

/* ============================================
   SCROLL STAGE
   ============================================ */
.carrot-anim .scroll-stage {
  position: relative;
  height: 1000vh;
  background: var(--color-bg-light);
}

.carrot-anim .scroll-stage__inner {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   BACKGROUND OVERLAY — white → dark
   ============================================ */
.carrot-anim .bg-overlay {
  position: absolute;
  inset: 0;
  background: var(--color-bg-dark);
  opacity: 0;
  z-index: 2;
  will-change: opacity;
  pointer-events: none;
}

/* ============================================
   VIDEO OVERLAY — dark scrim for text legibility
   ============================================ */
.carrot-anim .video-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  z-index: 4;
  will-change: opacity;
  pointer-events: none;
}

/* ============================================
   CANVAS SEQUENCE — PNG frame scrubber
   ============================================ */
.carrot-anim .canvas-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  will-change: transform, opacity;
}

.carrot-anim #frameCanvas {
  display: block;
  width: min(90vw, calc(90vh * (16 / 9)));
  height: auto;
  aspect-ratio: 16 / 9;
}

/* ============================================
   VIDEO — full screen, starts hidden
   ============================================ */
.carrot-anim .video-wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 1;
  will-change: opacity;
  opacity: 0;
  visibility: hidden;
}

.carrot-anim .video-wrap video {
  display: block;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  object-fit: cover;
  object-position: center;
}

/* ============================================
   EYEBROW
   ============================================ */
.carrot-anim .eyebrow {
  position: absolute;
  top: 10vh;
  left: 0;
  width: 100%;
  z-index: 5;
  text-align: center;
  will-change: opacity;
  padding: 0 1.25rem;
}

.carrot-anim .eyebrow__label {
  font-size: clamp(0.75rem, 2vw, 0.85rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
  font-weight: 500;
}

/* ============================================
   HEADLINES
   ============================================ */
.carrot-anim .headline {
  position: absolute;
  z-index: 5;
  width: 100%;
  text-align: center;
  padding: 0 1.5rem;
  opacity: 0;
  will-change: opacity, transform;
  pointer-events: none;
}

.carrot-anim .headline--top    { top: 14vh; }
.carrot-anim .headline--middle { top: 50%; translate: 0 -50%; }
.carrot-anim .headline--bottom { bottom: 12vh; }

.carrot-anim .headline__text {
  font-size: clamp(1.5rem, 3.4vw, 2.6rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--color-text-dark);
  transition: color 0.01s linear;
  text-wrap: balance;
  max-width: 25ch;
  margin: 0 auto;
}

.carrot-anim .headline__text--light { color: var(--color-text-light); }
.carrot-anim .headline__text--white { color: #fff; }

/* ============================================
   CTA LINE
   ============================================ */
.carrot-anim .cta-line {
  position: absolute;
  bottom: 8vh;
  left: 50%;
  translate: -50% 0;
  z-index: 5;
  text-align: center;
  opacity: 0;
  will-change: opacity;
  max-width: 90vw;
}

.carrot-anim .cta-line__text {
  font-size: clamp(0.8rem, 1.3vw, 0.95rem);
  color: var(--color-text-light);
}

.carrot-anim .cta-line__link {
  font-size: clamp(0.8rem, 1.3vw, 0.95rem);
  color: var(--color-accent);
  font-weight: 600;
  text-decoration: none;
  margin-left: 0.35rem;
  transition: color var(--transition-base);
}

.carrot-anim .cta-line__link:hover { color: var(--color-accent); }
.carrot-anim .cta-line__link::after { content: ' ›'; }
.carrot-anim .cta-line__link--light { color: var(--color-accent); }

/* ============================================
   ENDFRAME — iPad image
   ============================================ */
.carrot-anim .endframe-wrap {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  will-change: opacity, transform;
}

.carrot-anim .endframe-wrap img {
  max-width: 64vw;
  max-height: 52vh;
  width: auto;
  height: auto;
  display: block;
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.carrot-anim .scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--color-accent);
  z-index: 100;
  width: 0%;
  will-change: width;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .carrot-anim .scroll-stage        { height: 750vh; }
  .carrot-anim .headline--bottom    { bottom: 10vh; }
  .carrot-anim .cta-line            { bottom: 5vh; white-space: normal; }
  .carrot-anim .endframe-wrap img   { max-width: 74vw; max-height: 52vh; }
  .carrot-anim #frameCanvas         { width: min(95vw, calc(60vh * (16 / 9))); }
  .carrot-anim .headline__text      { font-size: clamp(1.9rem, 5vw, 2.6rem); }
}

@media (max-width: 480px) {
  .carrot-anim .scroll-stage        { height: 625vh; }
  .carrot-anim .headline--bottom    { bottom: 14vh; }
  .carrot-anim .cta-line            { bottom: 6vh; }
  .carrot-anim .cta-line__text,
  .carrot-anim .cta-line__link      { font-size: 0.8rem; }
  .carrot-anim .endframe-wrap img   { max-width: 76vw; max-height: 44vh; }
  .carrot-anim .headline__text      { font-size: clamp(2.5rem, 5vw, 4rem); }
}
