/* ============================================================
   SMC — Home page sections
   ============================================================ */

/* ---------- Hero ---------- */
.hero {
  background: var(--surface-tint);
}

.hero__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: clamp(2.5rem, 5vw, 5rem);
  padding-block: clamp(2rem, 4vw, 3rem);
}

.hero__content {
  flex: 1 1 360px;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.hero__title {
  max-width: 18ch;
}

.hero__text {
  max-width: 46ch;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
}

.hero__media {
  flex: 1 1 340px;
  display: flex;
  justify-content: center;
}

/* ---------- Hero carousel ----------
   Crossfading shots of the products and of real installations. The sources
   have nothing in common geometrically — 16:9, two 3:4 portraits, one 4:3 —
   so a fixed 5:4 frame crops them all to a single shape and the page never
   reflows as they swap. */
.hero-carousel {
  position: relative;
  width: 100%;
  max-width: 460px;
  aspect-ratio: 5 / 4;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-white);
}

.hero-carousel__slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 700ms var(--ease);
}

.hero-carousel__slide.is-active {
  opacity: 1;
}

/* Each shot frames its subject differently, so a centred crop suits none of
   them. The percentages below were measured against where the subject
   actually sits in each source, not eyeballed. */

/* Products sit at 26–84% of the width, off to the right of centre. */
.hero-carousel__slide--range {
  object-position: 67% center;
}

/* A centred crop gives a third of the frame to the ceiling. */
.hero-carousel__slide--skid {
  object-position: center 78%;
}

/* The tank's crown sits at 12% of the source height, so a centred crop —
   which starts at 20% — decapitates it. */
.hero-carousel__slide--tank {
  object-position: center 16%;
}

/* The only cut-out subject in the set: it has no surroundings to give it
   scale, so filling the frame made it read as far more zoomed-in than the
   photographs. Contained and inset, it carries the same weight as the rest. */
.hero-carousel__slide--pump {
  object-fit: contain;
  padding: 8%;
}

/* Two shots are studio renders on near-white; the controls sitting on them
   would otherwise vanish. A gradient along the bottom edge carries the dots
   on every frame without darkening the subject. */
.hero-carousel::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 38%;
  z-index: 1;
  background: linear-gradient(to top, rgba(15, 15, 15, 0.6), rgba(15, 15, 15, 0));
  pointer-events: none;
}

/* Controls appear only once the script is running — without JS they would be
   inert, so the carousel falls back to a plain still image. */
.hero-carousel__arrow,
.hero-carousel__dots {
  display: none;
}

.hero-carousel.is-ready .hero-carousel__arrow {
  display: grid;
}

.hero-carousel.is-ready .hero-carousel__dots {
  display: flex;
}

.hero-carousel__arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  border-radius: var(--radius-pill);
  /* Opaque enough to clear 3:1 against white even on the studio shot, whose
     backdrop sits around #E9E9E9 right where the arrows land. */
  background: rgba(15, 15, 15, 0.5);
  color: var(--text-on-dark);
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}

.hero-carousel__arrow:hover {
  background: rgba(15, 15, 15, 0.7);
}

.hero-carousel__arrow--prev { left: var(--space-3); }
.hero-carousel__arrow--next { right: var(--space-3); }

.hero-carousel__arrow svg {
  display: block;
  width: 20px;
  height: 20px;
}

.hero-carousel__dots {
  position: absolute;
  inset: auto 0 var(--space-4) 0;
  z-index: 2;
  justify-content: center;
  gap: var(--space-2);
}

.hero-carousel__dot {
  display: grid;
  place-items: center;
  width: 26px; /* touch target around an 8px dot */
  height: 26px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.hero-carousel__dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.5);
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.hero-carousel__dot.is-active::before {
  background: var(--text-on-dark);
  transform: scale(1.25);
}

/* The ring has to read on both a dark workshop photo and a white studio
   backdrop, so it pairs a white outline with a dark halo. */
.hero-carousel__arrow:focus-visible,
.hero-carousel__dot:focus-visible::before {
  outline: 2px solid var(--text-on-dark);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(15, 15, 15, 0.45);
}

@media (prefers-reduced-motion: reduce) {
  .hero-carousel__slide {
    transition: none;
  }
}

/* ---------- Applicazioni cards ---------- */
.apps__title {
  margin-bottom: var(--space-10);
}

.apps__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-8);
}

.app-card {
  position: relative; /* anchor for the stretched-link overlay */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-8);
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  min-height: 280px;
  cursor: pointer;
  transition: transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

/* Make the whole card clickable: the "Scopri" link's ::after covers it.
   Keeps a single real anchor (no nested interactive elements). */
.app-card__cta::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 1;
}

.app-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 40px rgba(18, 43, 96, 0.1);
}

.app-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.app-card__icon {
  width: 48px;
  height: 48px;
  align-self: flex-start;
  object-fit: contain;
  object-position: left center;
}

.app-card__title {
  color: var(--text-heading);
}

.app-card__desc {
  color: var(--text-muted);
}

.app-card__cta {
  align-self: flex-end;
  color: var(--navy-dark);
  font-size: 1rem;
  font-weight: var(--fw-semibold);
}

.app-card__cta .cta-link__arrow {
  width: 20px;
}

/* ---------- 30+ stat ---------- */
.stat__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: clamp(2rem, 5vw, 4.5rem);
}

.stat__number {
  font-size: var(--fs-stat);
  font-weight: var(--fw-semibold);
  line-height: 1;
  color: var(--navy-primary);
  flex-shrink: 0;
}

.stat__text {
  flex: 1 1 360px;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.stat__text p {
  color: var(--text-body);
}

/* ---------- Brands ---------- */
.brands__title {
  text-align: center;
  color: var(--text-body);
  letter-spacing: 0.04em;
  margin-bottom: var(--space-14);
}

.brands__grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-12) var(--space-8);
}

.brand-item {
  position: relative; /* anchor for the stretched-link overlay */
  flex: 1 1 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

/* Whole brand tile clickable via the "Scopri" link's ::after overlay */
.brand-item .cta-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* Fixed-height slot: vertically centers logos so their optical centers align
   across the row, regardless of each logo's individual height. */
.brand-item__plate {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 96px;
}

/* Base logo treatment. Heights are tuned per brand below so the *visible*
   artwork lands at a consistent optical size (~46px tall) — the source SVGs
   share a 220x92 canvas but fill it very differently. */
.brand-item__logo {
  width: auto;
  max-width: 100%;
  object-fit: contain;
  filter: grayscale(1);
  opacity: 0.85;
  transition: filter var(--dur) var(--ease), opacity var(--dur) var(--ease);
}

.brand-item__logo--fiorini { height: 88px; }
.brand-item__logo--kelvion { height: 64px; }
.brand-item__logo--wtk     { height: 90px; }

.brand-item:hover .brand-item__logo,
.brand-item:focus-within .brand-item__logo {
  filter: grayscale(0);
  opacity: 1;
}

/* "Scopri" revealed on hover/focus — the whole tile is already clickable,
   so the label stays quiet until the user shows intent. */
.brand-item .cta-link {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.brand-item:hover .cta-link,
.brand-item:focus-within .cta-link {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .brand-item .cta-link { transform: none; }
}

/* Touch devices have no hover: keep logos in colour and "Scopri" always shown. */
@media (hover: none) {
  .brand-item__logo { filter: grayscale(0); opacity: 1; }
  .brand-item .cta-link { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .apps__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .apps__grid {
    grid-template-columns: 1fr;
  }

  .brand-item {
    flex-basis: 40%;
  }

  /* No reliable hover on phones: keep logos in colour and "Scopri" shown. */
  .brand-item__logo { filter: grayscale(0); opacity: 1; }
  .brand-item .cta-link { opacity: 1; transform: none; }

  /* Buttons go full-width and stack, per the Figma mobile design */
  .hero__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .hero__actions .btn {
    width: 100%;
  }
}
