/* ==========================================================================
   IVAS — grid, sections, hero + banner cards
   ========================================================================== */

.shell {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Rev4 §4.1: one rhythm. .section--tight used to be .45 of --section-y; it is
   kept as a class so the markup does not change, but it no longer differs. */
.section, .section--tight { padding-block: calc(var(--section-y) * .55); }
.section--dark {
  background: var(--chrome);
  color: var(--on-dark);
}
.section--dark h1, .section--dark h2, .section--dark h3 { color: var(--on-dark); }
.section--dark .muted { color: var(--on-dark-muted); }
.section--sunken { background: var(--bg-sunken); }

.grid12 {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gutter);
}

.section-head { margin-bottom: var(--section-head-gap); }
.section-head h2 { max-width: 20ch; }
.section-head p { margin-top: 1rem; }

/* ==========================================================================
   Hero / banner card  (§5 — faithful to the reference layout)
   ========================================================================== */

.hero {
  position: relative;
  height: 100vh;
  height: 100svh;
  padding: var(--frame);
  background: var(--bg);
}
.banner {
  position: relative;
  height: 70svh;
  min-height: 520px;
  padding: var(--frame);
  background: var(--bg);
}
@media (min-width: 768px) { .banner { height: 78svh; } }
.banner--compact { height: 56svh; min-height: 420px; }
/* §5.2 — the card used to meet the light page on a hard edge. A short tint
   carried under it softens the join. Fading the card's own bottom pixels to
   the page colour was rejected: the breadcrumb, the title word and the lead
   all sit in exactly that band and would have lost their contrast. */
.banner::after {
  content: ''; position: absolute; left: 0; right: 0; top: 100%;
  height: clamp(40px, 6vw, 90px); z-index: 1; pointer-events: none;
  background: linear-gradient(180deg, rgba(var(--navy-rgb), .07), rgba(var(--navy-rgb), 0));
}

.hero__card,
.banner__card {
  position: relative;
  height: 100%;
  width: 100%;
  border-radius: var(--r-card);
  overflow: hidden;
  isolation: isolate;
  background: var(--chrome);
  display: grid;
  /* rev3: a long product name in the wordmark widened the auto column to
     2500px and pushed the nav off the card; the column is the card */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto 1fr auto;
  color: var(--on-dark);
}

/* --- slides --------------------------------------------------------------- */
.hero__slides { position: absolute; inset: 0; z-index: 0; }
.hero__slide {
  position: absolute; inset: 0;
  opacity: 0;
  transition: opacity 1200ms var(--ease-in-out);
}
.hero__slide.is-active { opacity: 1; }
.hero__slide img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: var(--focal, 50% 50%);
  /* Rev1 §2.1 — the photos are high-noon bright; a touch off the saturation
     and a touch onto the contrast stops the scrim reading as grey haze. */
  filter: saturate(.94) contrast(1.02);
}
/* Ken Burns — alternating origin, only when motion is allowed */
.has-motion .hero__slide.is-active img { animation: kenburns 7600ms linear both; }
.has-motion .hero__slide:nth-child(even).is-active img { animation-name: kenburns-alt; }
@keyframes kenburns {
  from { transform: scale(1.08) translate3d(1%, -.6%, 0); }
  to   { transform: scale(1)    translate3d(0, 0, 0); }
}
@keyframes kenburns-alt {
  from { transform: scale(1.08) translate3d(-1%, .6%, 0); }
  to   { transform: scale(1)    translate3d(0, 0, 0); }
}

/* --- scrim (§2) ----------------------------------------------------------
   Three stacked layers, not one flat wash, tinted with --navy-900 rather than
   black so the photograph stays warm-neutral instead of muddy:
     1. vertical  — heavy under the header, heavier under the bottom row,
                    almost open across the middle where the wordmark sits
     2. horizontal— a left wash for the corner micro-copy and the statement
     3. base tint — a flat 20% floor so nothing on the card is ever raw photo
   --scrim-strength scales all three per slide (§2.2). It is a registered
   custom property, so it tweens with the 1200ms crossfade instead of popping.
   The un-calc'd declaration first is the fallback for engines that will not
   take calc() inside rgba(). */
.hero__card::before,
.banner__card::before {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(var(--navy-rgb), .62) 0%, rgba(var(--navy-rgb), .26) 26%,
                            rgba(var(--navy-rgb), .26) 50%, rgba(var(--navy-rgb), .74) 100%),
    linear-gradient(90deg,  rgba(var(--navy-rgb), .42) 0%, rgba(var(--navy-rgb), 0) 46%,
                            rgba(var(--navy-rgb), 0) 72%, rgba(var(--navy-rgb), .30) 100%),
    rgba(var(--navy-rgb), .20);
  background:
    linear-gradient(180deg,
      rgba(var(--navy-rgb), calc(.62 * var(--scrim-strength, 1))) 0%,
      rgba(var(--navy-rgb), calc(.26 * var(--scrim-strength, 1))) 26%,
      rgba(var(--navy-rgb), calc(.26 * var(--scrim-strength, 1))) 50%,
      rgba(var(--navy-rgb), calc(.74 * var(--scrim-strength, 1))) 100%),
    /* both edges, not only the left: the right corner carries the second line
       of micro-copy and the stat cards, and it measured 3.9:1 unwashed */
    linear-gradient(90deg,
      rgba(var(--navy-rgb), calc(.42 * var(--scrim-strength, 1))) 0%,
      rgba(var(--navy-rgb), 0) 46%,
      rgba(var(--navy-rgb), 0) 72%,
      rgba(var(--navy-rgb), calc(.30 * var(--scrim-strength, 1))) 100%),
    rgba(var(--navy-rgb), calc(.20 * var(--scrim-strength, 1) + var(--scrim)));
  transition: --scrim-strength 1200ms var(--ease-in-out);
}

/* §5.1 — inner banners carry the page title and lead directly on the photo,
   so their scrim runs one step stronger than the hero's. */
.banner__card::before {
  background:
    linear-gradient(180deg, rgba(var(--navy-rgb), .58) 0%, rgba(var(--navy-rgb), .34) 30%,
                            rgba(var(--navy-rgb), .34) 52%, rgba(var(--navy-rgb), .78) 100%),
    linear-gradient(90deg,  rgba(var(--navy-rgb), .46) 0%, rgba(var(--navy-rgb), 0) 50%,
                            rgba(var(--navy-rgb), 0) 74%, rgba(var(--navy-rgb), .32) 100%),
    rgba(var(--navy-rgb), .22);
  background:
    linear-gradient(180deg,
      rgba(var(--navy-rgb), calc(.58 * var(--scrim-strength, 1))) 0%,
      rgba(var(--navy-rgb), calc(.34 * var(--scrim-strength, 1))) 30%,
      rgba(var(--navy-rgb), calc(.34 * var(--scrim-strength, 1))) 52%,
      rgba(var(--navy-rgb), calc(.78 * var(--scrim-strength, 1))) 100%),
    linear-gradient(90deg,
      rgba(var(--navy-rgb), calc(.46 * var(--scrim-strength, 1))) 0%,
      rgba(var(--navy-rgb), 0) 50%,
      rgba(var(--navy-rgb), 0) 74%,
      rgba(var(--navy-rgb), calc(.32 * var(--scrim-strength, 1))) 100%),
    rgba(var(--navy-rgb), calc(.22 * var(--scrim-strength, 1) + var(--scrim)));
}

/* §2.4 — an extra local wash directly behind the top bar, so the pill nav and
   the logo keep their contrast even where a slide is blown out up there. It
   gets its own multiplier because the brightest band of a photo is often not
   where its overall exposure sits: ivas-3 is the darkest slide overall (mean
   relative luminance 0.271) yet has the brightest top band (0.455, p90 0.924)
   because of the shop lighting. */
.hero__card::after,
.banner__card::after {
  content: ''; position: absolute; inset: 0 0 auto 0; z-index: 1;
  /* deep enough to cover the corner micro-copy row, not just the pill nav:
     the right-hand line sat at 3.9:1 over ivas-3's blown-out ceiling lights */
  height: clamp(160px, 26%, 300px); pointer-events: none;
  background: linear-gradient(180deg, rgba(var(--navy-rgb), .34) 0%, rgba(var(--navy-rgb), 0) 100%);
  background: linear-gradient(180deg,
    rgba(var(--navy-rgb), calc(.34 * var(--scrim-top, 1))) 0%,
    rgba(var(--navy-rgb), 0) 100%);
  transition: --scrim-top 1200ms var(--ease-in-out);
}

/* --- top bar -------------------------------------------------------------- */
/* Rev1 §1.2 — three tracks, not a flex row. `minmax(0, 1fr)` on both side
   tracks is what makes the centring exact: a bare `1fr` is `minmax(auto, 1fr)`,
   so the wider cluster (the actions) floors its own track at min-content and
   pushes the middle track off the card axis by half the difference. With a 0
   minimum the free space is always split evenly, so navCentre == cardCentre by
   construction. The cost is that the clusters must genuinely fit — hence the
   size step and the collapse breakpoint below. */
.hero__top {
  position: relative; z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center; gap: 16px;
  padding: clamp(14px, 2.2vw, 30px) clamp(14px, 2.4vw, 32px);
}
.hero__logo {
  justify-self: start;
  display: flex; align-items: center; gap: .6rem;
}
.hero__logo img { width: auto; height: clamp(48px, 3.8vw, 68px); }
/* Rev4 §4: below the pill nav the bar is [logo] … [actions]. With the nav
   hidden the actions used to fall into the middle track, which left the logo
   a third of the bar and squeezed it to 73% of its width on phones. */
@media (max-width: 1279px) {
  .hero__top { display: flex; justify-content: space-between; }
  .hero__logo img { max-width: none; }
}

.hero__nav { display: none; justify-self: center; }
/* Rev2 §3.2 — seven pills at 16px plus the right cluster need about 1720px of
   card when the nav is centred on the card axis, so narrower screens step down in
   order: phone + map move out first (both stay in the hero's mobile menu, the
   footer and the contact page), then the pills get tighter, then the language
   switcher moves to the menu, and only then does the nav collapse. Widths come from
   the measured slack in _work/qa-rev2.js, not from arithmetic. */
.hero__circles { display: flex; gap: 8px; }
@media (min-width: 1280px) {
  .hero__nav { display: flex; gap: var(--pill-gap); }
}
@media (max-width: 1859px) { .hero__circles { display: none; } }
@media (min-width: 1520px) and (max-width: 1663px) {
  :root { --pill-fs: .95rem; --pill-h: 40px; --pill-px: 13px; --pill-gap: 4px; --circle: 42px;
          --cta-h: 44px; --cta-fs: .94rem; --cta-i: 36px; --cta-pl: 16px; }
}
@media (min-width: 1424px) and (max-width: 1519px) {
  :root { --pill-fs: .9rem; --pill-h: 40px; --pill-px: 11px; --pill-gap: 3px; --circle: 40px;
          --cta-h: 44px; --cta-fs: .9rem; --cta-i: 36px; --cta-pl: 14px; }
  .header-pill { --pill-fs: .86rem; --pill-h: 36px; --pill-px: 11px; --pill-gap: 3px;
                 --circle: 36px; --cta-h: 40px; --cta-fs: .86rem; --cta-i: 32px; --cta-pl: 14px; }
  .hero__top { padding-inline: 24px; column-gap: 12px; }
  .hero__actions .lang { margin-right: 8px; }
  .pill__chev { width: 11px; height: 11px; margin-right: -3px; }
}
@media (min-width: 1280px) and (max-width: 1365px) { .hero__actions .lang { display: none; } }
@media (min-width: 1280px) and (max-width: 1423px) {
  :root { --pill-fs: .875rem; --pill-h: 38px; --pill-px: 10px; --pill-gap: 3px; --circle: 38px;
          --cta-h: 42px; --cta-fs: .875rem; --cta-i: 34px; --cta-pl: 14px; }
  .header-pill { --pill-fs: .82rem; --pill-h: 34px; --pill-px: 8px; --pill-gap: 2px;
                 --circle: 34px; --cta-h: 38px; --cta-fs: .82rem; --cta-i: 30px; --cta-pl: 12px;
                 width: calc(100% - 24px); }
  .header-pill .cta__icon { display: none; }
  .header-pill .cta { padding-right: 12px; }
  .hero__top { padding-inline: 20px; column-gap: 10px; }
  /* rev3: with Demit fasade out of the nav the switcher fits again from 1366 */
  .hero__logo img { height: 48px; }
  .pill__chev { width: 11px; height: 11px; margin-right: -3px; }
}

/* Short desktop viewports (1366x625, 1440x720 and friends). The card is a
   fixed 100svh, so a 625px screen has to fit the same four rows as a 1080px
   one — and the wordmark row, being the 1fr, is what gets squeezed to nothing.
   Tightening the chrome and putting the stat cards side by side gives it back
   about 130px, which is the difference between a 20%-wide word and a full one. */
@media (min-width: 1024px) and (max-height: 800px) {
  .hero__top { padding-block: 14px; }
  .hero__micro { font-size: .72rem; }
  .hero__micro p { max-width: 24ch; }
  .hero__bottom { padding-block: 14px; gap: 10px; }
  .hero__stats { grid-template-columns: 1fr 1fr; }
  .stat-card { width: auto; min-width: 150px; padding: 10px 13px; }
  .stat-card__num { font-size: 1.5rem; }
  .stat-card__label { margin-top: .3rem; font-size: .66rem; }
  .hero__statement { font-size: clamp(1rem, 1.2vw + .5rem, 1.3rem); }
  .hero__controls { margin-bottom: .4rem; }
}

.hero__actions { justify-self: end; display: flex; align-items: center; gap: 8px; }
/* §5.6: on phones the top bar is [logo] (⌕) (☰) — the primary CTA lives at the
   bottom of the card instead, so it does not crowd the bar. */
@media (max-width: 767px) {
  .hero__actions > .cta, .hero__actions > .has-badge { display: none; }
}

/* --- corner micro-copy ---------------------------------------------------- */
.hero__micro {
  position: relative; z-index: 3;
  display: flex; justify-content: space-between; gap: 2rem;
  padding: 0 clamp(14px, 2.4vw, 32px);
  font-size: clamp(.74rem, .35vw + .66rem, .82rem);
  line-height: 1.45;
  color: var(--on-dark-muted);
}
.hero__micro p { margin: 0; max-width: 22ch; }
.hero__micro .right { text-align: right; display: none; }
@media (min-width: 768px) { .hero__micro .right { display: block; } }

/* --- giant wordmark ------------------------------------------------------- */
.hero__wordmark {
  position: relative; z-index: 2;
  display: grid; place-items: center;
  padding-inline: clamp(8px, 1.6vw, 24px);
  min-height: 0;
  pointer-events: none;
}
.wordmark {
  position: relative;
  width: 100%;
  display: block;
  text-align: center;
  white-space: nowrap;
  font-weight: 600;
  letter-spacing: -.05em;
  line-height: .82;
  /* JS fits this to ~90% of the card width; clamp is the no-JS fallback */
  font-size: clamp(4.5rem, 21vw, 19rem);
  /* the lower half dissolves so the scene reads "through" the letters */
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 50%, transparent 95%);
          mask-image: linear-gradient(180deg, #000 0%, #000 50%, transparent 95%);
}
.wordmark__base {
  display: inline-block;          /* so its box equals the text, for the fitter */
  color: rgba(var(--white-rgb), var(--wm-opacity, .32));
}
.wordmark__blend {
  position: absolute; inset: 0;
  color: var(--on-dark);
  mix-blend-mode: soft-light;
}

/* On short desktop screens the 80% word is taller than its row. It hangs from the
   top of the row, so the overflow lands in the lower half, which the mask fades out. */
@media (min-width: 1024px) and (max-height: 800px) { .hero__wordmark { align-items: start; } }

/* Rev2 §2.2 — the clamp above is only the no-JS size. With JS the word stays
   unpainted until the fitter has run, so it never paints once at the clamp size and
   again at the fitted one. The delayed animation is the failsafe. */
.js .wordmark:not(.is-fit) { visibility: hidden; animation: wm-failsafe 1ms linear 1.5s forwards; }
@keyframes wm-failsafe { to { visibility: visible; } }

/* --- bottom row ----------------------------------------------------------- */
.hero__bottom {
  position: relative; z-index: 3;
  display: grid;
  gap: clamp(14px, 2vw, 22px);
  padding: clamp(14px, 2.2vw, 30px) clamp(14px, 2.4vw, 32px);
  align-items: end;
}
/* Rev1 §3.2 — the hero is exactly one viewport tall, so its bottom row shares
   the foot of the screen with the fixed AI FAB, the back-to-top button and (on
   mobile) the dock. It reserves the full height of that UI at every width, not
   just below 1024. */
.hero__bottom {
  padding-bottom: calc(var(--bottom-ui-h) + env(safe-area-inset-bottom, 0px));
}
/* Banners are 70-78svh, so the fixed row sits below them and only the mobile
   dock can reach their foot. */
@media (max-width: 1023px) {
  .banner__bottom {
    padding-bottom: calc(clamp(14px, 2.2vw, 30px) + env(safe-area-inset-bottom, 0px));
  }
}
@media (min-width: 1024px) {
  .hero__bottom {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: end;
  }
  .hero__bottom > :nth-child(2) { justify-self: center; }
  .hero__bottom > :nth-child(3) { justify-self: end; }
}

.hero__statement {
  font-size: clamp(1.05rem, 1.5vw + .6rem, 1.6rem);
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: -.02em;
  margin: 0;
  max-width: 18ch;
  color: var(--on-dark);
}

/* slider controls */
.hero__controls {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: .6rem;
}
.hero__bars { display: flex; gap: 5px; }
.hero__bar {
  width: 30px; height: 3px; border-radius: 2px;
  background: rgba(var(--white-rgb), .28);
  overflow: hidden;
}
.hero__bar i {
  display: block; height: 100%; width: 0;
  background: var(--accent);
}
.hero__bar.is-active i { width: 100%; transition: width 6500ms linear; }
.hero__bar.is-done i { width: 100%; }
.hero__count { color: var(--on-dark-faint); font-size: .72rem; }

/* edge arrows (rev2 §4.2): for a moving mouse or keyboard focus, never touch */
.hero__arrow {
  position: absolute; top: 50%; z-index: 4;
  width: 56px; height: 56px; margin-top: -28px;
  display: grid; place-items: center; border-radius: 50%;
  color: var(--on-dark);
  background: rgba(var(--navy-rgb), .38);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
          backdrop-filter: blur(14px) saturate(1.1);
  border: 1px solid rgba(var(--white-rgb), .35);
  opacity: 0; pointer-events: none;
  transition: opacity 150ms linear, background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.hero__arrow svg { width: 24px; height: 24px; }
.hero__arrow--prev { left: clamp(14px, 1.6vw, 28px); }
.hero__arrow--next { right: clamp(14px, 1.6vw, 28px); }
.arrows-on .hero__arrow { opacity: 1; pointer-events: auto; }
.hero__arrow:focus-visible { opacity: 1; pointer-events: auto; }
.hero__arrow:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
@media (pointer: coarse) { .hero__arrow { display: none; } }

/* stat cards */
.hero__stats { display: grid; gap: 10px; }
@media (max-width: 1023px) {
  .hero__stats { grid-template-columns: 1fr 1fr; order: -1; }
}

/* --- banner specifics ----------------------------------------------------- */
.banner__card { grid-template-rows: auto auto 1fr auto; }
.banner__bottom {
  position: relative; z-index: 3;
  display: grid; gap: 16px; align-items: end;
  padding: clamp(14px, 2.2vw, 30px) clamp(14px, 2.4vw, 32px);
}
@media (min-width: 900px) {
  .banner__bottom { grid-template-columns: minmax(0, 1.4fr) auto; }
  .banner__bottom > :last-child { justify-self: end; }
}
/* muted, not faint: it is navigation sitting on a photograph at 12.5px, and
   at the faint tier it measured 2.6-3.9:1 over the brighter banners */
.breadcrumb {
  display: flex; flex-wrap: wrap; gap: .4rem .6rem;
  font-size: .78rem; color: var(--on-dark-muted); margin-bottom: .6rem;
}
/* Without this the unclassed anchors fall through to the global link rule and
   render blue-on-photograph, which is unreadable over the banner. */
.breadcrumb a { color: inherit; text-decoration: none; }
.breadcrumb a:hover { color: var(--on-dark); text-decoration: underline; }
.breadcrumb li + li::before { content: '/'; margin-inline-end: .6rem; opacity: .5; }
.breadcrumb li { display: inline-flex; }

.banner__lead {
  font-size: clamp(1rem, 1vw + .7rem, 1.3rem);
  line-height: 1.4; color: var(--on-dark); max-width: 34ch; margin: 0;
}
/* Rev4 §4.3: the calculator page swaps in its own lead after load; every one
   of the nine is two lines, so the space is reserved and the banner no longer
   jumps (Lighthouse CLS was 0.36 on kalkulator.html) */
.banner__lead[data-calc-lead] { min-height: 2.8em; }

/* ==========================================================================
   Page transition layer + preloader
   ========================================================================== */
.transition-layer {
  position: fixed; inset: 0; z-index: var(--z-transition);
  pointer-events: none; display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(3, 1fr);
  visibility: hidden;
}
.transition-layer.is-active { visibility: visible; }
.transition-layer i {
  background: var(--chrome);
  transform: scaleY(0);
  transform-origin: bottom;
}
