/* Homepage hero — Figma Hero_Section (454:13215) */

.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Fill viewport; distribute extra space so content stays visually centered */
  min-height: var(--hero-min-height-fill);
  padding: calc(var(--hero-padding-y) + var(--navbar-height)) var(--padding)
    calc(var(--hero-padding-y) + 20px);
  box-sizing: border-box;
  background: transparent;
  overflow: hidden;
}

/* Static hero photo — full bleed behind content */
.hero__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.hero__bg-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

/* Cloud layer — upper sky area; horizontal drift driven by js/hero-clouds.js */
.hero__clouds {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.hero__cloud {
  position: absolute;
  width: min(28vw, 220px);
  height: auto;
  max-width: none;
  will-change: transform;
}

.hero__cloud--1 {
  top: 30%;
  left: 8%;
  width: min(32vw, 260px);
}

.hero__cloud--2 {
  top: 34%;
  right: 8%;
  left: auto;
  width: min(26vw, 200px);
}

.hero__cloud--3 {
  top: 50%;
  left: 28%;
  width: min(24vw, 190px);
}

.hero__cloud--4 {
  top: 20%;
  right: 22%;
  left: auto;
  width: min(20vw, 160px);
}

@media (max-width: 768px) {
  .hero__clouds {
    display: none;
  }
}

.hero__inner {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--hero-intro-balance-gap);
  width: 100%;
  max-width: var(--max-width);
  text-align: center;
  min-height: 0;
}

/* Upper hero block: reviews + headline + subtitle + actions (stack gap does not affect balance spacing) */
.hero__intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--hero-stack-gap);
  width: 100%;
  max-width: 100%;
}

/* --- Store ratings (Reviews_Wrapper) --- */
.hero__reviews {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px 5px;
}

.hero__review-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px;
  border-radius: var(--radius-inner);
  color: var(--color-black);
  text-decoration: none;
  transition: background var(--transition);
}

.hero__review-link:hover {
  background: rgba(255, 255, 255, 0.3);
}

.hero__review-link:focus-visible {
  background: rgba(255, 255, 255, 0.3);
  outline: 2px solid var(--color-blue-dark);
  outline-offset: 2px;
}

.hero__store-icon {
  flex-shrink: 0;
  display: block;
}

.hero__review-text {
  font-size: var(--font-body);
  line-height: 1.4;
  white-space: nowrap;
}

.hero__review-rating {
  font-weight: 700;
}

.hero__review-meta {
  color: var(--color-black);
  font-weight: 400;
}

/* --- Headline --- */
.hero__headline {
  margin: 0;
  max-width: 100%;
  font-size: var(--font-hero-display);
  font-weight: 700;
  line-height: var(--font-hero-display-leading);
  letter-spacing: var(--font-hero-display-tracking);
  color: var(--color-black);
}

.hero__headline-line {
  display: block;
}

/* Hebrew typewriter headline: hug content so the line stays visually centered as width changes */
.hero__headline--he {
  direction: rtl;
  unicode-bidi: isolate;
  display: inline-flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  width: max-content;
  max-width: 100%;
  margin-inline: auto;
  box-sizing: border-box;
  text-align: center;
}

/* English headline: same centered hug, but LTR so caret sits on the right */
.hero__headline--en {
  direction: ltr;
  unicode-bidi: isolate;
}

.hero__headline-prefix {
  flex: 0 0 auto;
  white-space: pre;
}

/* English headline: rely on the single HTML whitespace between spans */

.hero__headline-typed {
  flex: 0 0 auto;
  display: inline-block;
  text-align: start;
  vertical-align: baseline;
  font-weight: 700;
  white-space: nowrap;
}

.hero__headline-typed:not(.hero__headline-typed--done)::after {
  content: '|';
  display: inline;
  font-weight: 300;
  margin-inline-start: 1px;
  opacity: 1;
  animation: hero-headline-caret 1s step-end infinite;
}

.hero__headline-typed--done::after {
  content: none;
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .hero__headline-typed::after {
    content: none;
    animation: none;
  }
}

@keyframes hero-headline-caret {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

/* --- Subtitle --- */
.hero__subtitle {
  margin: 0;
  max-width: 100%;
  font-size: var(--font-main);
  font-weight: 400;
  line-height: 1.2;
  color: var(--color-black);
}

@media (min-width: 769px) {
  .hero__subtitle {
    white-space: nowrap;
  }
}

/* ===================================================================
   Balance_Wrapper — frosted-glass wallet card (Figma 454:13226)
   =================================================================== */
.hero__balance {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--padding);
  /* Inner row: 6×40px flags + 5 gaps + next + balance padding — keep in sync with PAGE_SIZE in js/hero-carousel.js */
  width: min(400px, 100%);
  max-width: 100%;
  padding: var(--padding);
  border-radius: var(--padding);
  background: rgba(255, 255, 255, 0.64);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    0 0 40px rgba(0, 0, 0, 0.25),
    inset 4px 4px 11px rgba(255, 255, 255, 0.63);
  box-sizing: border-box;
  will-change: transform;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Wallet inner card */
.hero__wallet {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 36px 12px;
  background: rgba(255, 255, 255, 0.64);
  border-radius: var(--radius-inner);
  box-sizing: border-box;
}

/* Amount display */
.hero__amount-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero__amount-label {
  font-size: var(--font-body);
  font-weight: 400;
  line-height: 1;
  color: var(--color-black);
}

.hero__amount-value-wrap {
  overflow: hidden;
}

.hero__amount-value {
  display: block;
  font-size: var(--font-display);
  font-weight: 400;
  line-height: 1;
  margin: 6px 0;
  color: var(--color-black);
  direction: ltr;
  unicode-bidi: isolate;
}

@keyframes amount-enter {
  from {
    transform: translateY(40%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.hero__amount-value.is-entering {
  animation: amount-enter 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Currency chip (arrow + name + small flag) */
.hero__currency-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 9999px;
  background: rgba(250, 253, 252, 0.6);
  margin-top: 4px;
}

.hero__chip-name {
  font-size: var(--font-body);
  color: var(--color-black);
  white-space: nowrap;
}

.hero__chip-flag {
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  flex-shrink: 0;
  display: block;
}

/* Finance action buttons (decorative) */
.hero__finance-actions {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 25px;
}

.hero__finance-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.hero__finance-icon {
  display: block;
  width: 45px;
  height: 45px;
  border-radius: 9999px;
  box-shadow: 0 2px 4px var(--color-dark-grey);
}

.hero__finance-label {
  font-size: var(--font-body);
  font-weight: 400;
  color: var(--color-black);
  text-align: center;
  white-space: nowrap;
}

/* ===================================================================
   Flag carousel (Figma 454:13245)
   =================================================================== */
.hero__flags {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: var(--padding) 0;
  max-width: 100%;
  box-sizing: border-box;
}

.hero__flag,
.hero__flag-next {
  opacity: 0;
  translate: 0 var(--nav-category-enter-shift);
  transition:
    opacity var(--nav-category-enter-duration) var(--nav-category-enter-ease),
    translate var(--nav-category-enter-duration) var(--nav-category-enter-ease),
    scale 0.2s ease;
  transition-delay: calc(var(--flag-i, 0) * var(--nav-category-stagger) + var(--nav-category-base-delay));
}

.hero__flags--entered .hero__flag,
.hero__flags--entered .hero__flag-next {
  opacity: 1;
  translate: 0;
}

.hero__flag {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  border: 2px solid var(--color-bg);
  padding: 0;
  background: none;
  box-sizing: border-box;
}

.hero__flag--active {
  border-color: var(--color-black);
}

.hero__flag:hover {
  scale: 1.1;
}

.hero__flag img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 9999px;
  pointer-events: none;
}

/* Progress bar overlay — fills left→right inside the circular flag */
.hero__flag-progress {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 100%;
  background: rgba(19, 24, 26, 0.7);
  pointer-events: none;
}

.hero__flag--active .hero__flag-progress {
  animation: flag-fill 8s linear forwards;
}

/* Pause progress in sync with JS carousel pause (hover / tab) — avoids full bar with no advance */
.hero__balance--carousel-paused .hero__flag--active .hero__flag-progress {
  animation-play-state: paused;
}

@keyframes flag-fill {
  from { width: 0; }
  to { width: 100%; }
}

/* "Next page" circle button — inherits glow + scale from .btn--secondary */
.hero__flag-next {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  border: none;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

/* Fade-out on last flag only when “more” chevron exists (extra pages) */
.hero__flags:has(.hero__flag-next) .hero__flag:last-of-type {
  -webkit-mask-image: linear-gradient(to right, transparent, black 60%);
  mask-image: linear-gradient(to right, transparent, black 60%);
}

/* ===================================================================
   Responsive
   =================================================================== */

/* 1080p-class laptops: trim vertical rhythm so the hero fits one screen without nudging the page */
@media (min-width: 769px) and (max-height: 1040px) {
  .hero {
    --hero-padding-y: 44px;
    --hero-stack-gap: 14px;
    --hero-intro-balance-gap: 38px;
    padding-top: calc(var(--hero-padding-y) + var(--navbar-height));
    padding-bottom: calc(var(--hero-padding-y) + 12px);
  }

  .hero__wallet {
    padding: 32px 12px;
  }

  .hero__finance-actions {
    gap: 18px;
  }
}

@media (min-width: 769px) and (max-height: 940px) {
  .hero {
    --hero-padding-y: 34px;
    --hero-stack-gap: 12px;
    --hero-intro-balance-gap: 34px;
    padding-top: calc(var(--hero-padding-y) + var(--navbar-height));
    padding-bottom: calc(var(--hero-padding-y) + 10px);
  }

  .hero__wallet {
    padding: 28px 12px;
  }

  .hero__headline {
    font-size: clamp(2.5rem, 4.5vw + 1.25rem, 5.75rem);
  }
}

@media (max-width: 768px) {
  .hero {
    --hero-padding-y: 40px;
    --hero-intro-balance-gap: 36px;
    min-height: min(var(--hero-min-height), max(100svh - 72px, 520px));
  }

  .hero__subtitle {
    font-size: var(--font-main-sm);
    white-space: normal;
  }

  .hero__review-text {
    white-space: normal;
    text-align: center;
  }

  .hero__actions {
    flex-direction: column;
    width: 100%;
    max-width: none;
    align-items: stretch;
  }

  .hero__action {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    justify-content: center;
    display: flex;
  }

  .hero__balance {
    width: 100%;
  }

  .hero__wallet {
    padding: 32px var(--padding);
  }

  .hero__amount-value {
    font-size: 48px;
  }
}

@media (max-width: 380px) {
  .hero__reviews {
    flex-wrap: nowrap;
    gap: 4px;
  }

  .hero__review-link {
    padding: 4px;
    gap: 4px;
  }

  .hero__review-text {
    white-space: nowrap;
  }

  .hero__review-meta {
    display: none;
  }
}

/* Progressively hide flags (PAGE_SIZE 6 in DOM) to keep a single row on narrow viewports */
@media (max-width: 480px) {
  .hero__flag:nth-child(n+6) { display: none; }
  .hero__flag:nth-child(6) { mask-image: none !important; -webkit-mask-image: none !important; }
  .hero__flag:nth-child(5) {
    -webkit-mask-image: linear-gradient(to right, transparent, black 60%);
    mask-image: linear-gradient(to right, transparent, black 60%);
  }
}

@media (max-width: 400px) {
  .hero__flag:nth-child(n+5) { display: none; }
  .hero__flag:nth-child(5) { mask-image: none !important; -webkit-mask-image: none !important; }
  .hero__flag:nth-child(4) {
    -webkit-mask-image: linear-gradient(to right, transparent, black 60%);
    mask-image: linear-gradient(to right, transparent, black 60%);
  }
}

@media (max-width: 340px) {
  .hero__finance-actions {
    --finance-scale: clamp(0.72, 100vw / 385, 0.9);
    gap: clamp(10px, 2.8vw, 18px);
    transform: scale(var(--finance-scale));
    transform-origin: center top;
    margin-bottom: calc((1 - var(--finance-scale)) * -2.75rem);
  }

  .hero__flag:nth-child(n+4) { display: none; }
  .hero__flag:nth-child(4) { mask-image: none !important; -webkit-mask-image: none !important; }
  .hero__flag:nth-child(3) {
    -webkit-mask-image: linear-gradient(to right, transparent, black 60%);
    mask-image: linear-gradient(to right, transparent, black 60%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero {
    transition: none;
  }
  .hero__cloud {
    will-change: auto;
    transform: none !important;
  }
  .hero__flag--active .hero__flag-progress {
    animation: none;
    width: 100%;
  }
  .hero__amount-value.is-entering {
    animation: none;
  }
}
