/* Front page sections. Also loaded by the handbook's website level, on top of
   its own stylesheets instead of main.css, so it may only use the general
   tokens. */

.hero, .split, .cards, .quote-band, .customers {
  .inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
  }

  .eyebrow {
    margin: 0;
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--brand);
  }

  h1, h2 {
    margin: 12px 0 0;
    font-size: clamp(var(--text-4xl), 3.2vw, var(--text-6xl));
    line-height: var(--leading-tight);
    font-weight: var(--weight-bold);
    letter-spacing: -0.02em;
    color: var(--ink);
    text-wrap: balance;
  }

  .lede {
    margin: 16px 0 0;
    font-size: clamp(var(--text-lg), 1.4vw, var(--text-xl));
    line-height: var(--leading-normal);
    color: var(--ink-soft);
  }

  .body {
    margin: 16px 0 0;
    font-size: var(--text-lg);
    line-height: var(--leading-normal);
    color: var(--ink-soft);
  }

  .mark {
    display: block;
    width: 32px;
    height: 26px;
    color: var(--brand);
  }

  .name {
    display: block;
    font-weight: var(--weight-semibold);
    line-height: var(--leading-snug);
    color: var(--ink);
  }

  .role {
    display: block;
    margin-top: 2px;
    line-height: var(--leading-snug);
    color: var(--ink-soft);
  }

  /* Large portraits next to a quote: a print in a white frame. */
  .portrait {
    object-fit: cover;
    border: 8px solid #fff;
    box-shadow: 0 20px 44px color-mix(in srgb, var(--ink) 20%, transparent);
  }
}

/* Main action is red on these light bands, unlike on the red top bar. */
.hero .btn.primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  box-shadow: 0 2px 6px color-mix(in srgb, var(--brand) 28%, transparent);

  &:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
    color: #fff;
    box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 38%, transparent);
  }
}

.hero .btn.video-cta {
  background: #fff;
  color: var(--brand);
  border-color: var(--brand);

  .play {
    width: 24px;
    height: 24px;
    margin-left: -2px;
    flex-shrink: 0;
  }

  &:hover {
    background: var(--brand-tint);
    border-color: var(--brand-dark);
    color: var(--brand-dark);
  }
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--brand);
  text-decoration: none;
  transition: gap .12s ease;

  &:hover { gap: 12px; }

  .arrow {
    width: 16px;
    height: 11px;
  }
}

/* ---------- Hero: Inge's quote, the buttons and the tablet beside the fire ---------- */
.hero {
  position: relative;
  z-index: 0;
  overflow: hidden;
  background: var(--bg-soft);

  /* Wide: quote and tablet on the left, buttons top right, all on the
     photo, which bleeds out to the window edges. */
  .inner {
    /* As wide as the left column. */
    --tablet-w: calc((min(100vw, var(--max-width)) - 112px) * 8 / 12);
    display: grid;
    grid-template-columns: minmax(0, 8fr) minmax(0, 4fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "statement statement" "tablet .";
    column-gap: 64px;
    padding-block: 48px 64px;
  }

  /* Across both columns: quote, name and buttons left, centred on the
     portrait right. The quote starts in line with the tablet's screen,
     7.5% in from its bezel. */
  .statement {
    grid-area: statement;
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px;
    grid-template-rows: 1fr auto auto auto auto 1fr;
    grid-template-areas: ". portrait" "mark portrait" "quote portrait" "caption portrait" "cta portrait" ". portrait";
    align-items: start;
    column-gap: 56px;
    margin: 0 0 0 calc(var(--tablet-w) * 0.075);
    color: #fff;
    /* A tight shadow for the letter edges and a soft one for the patchy
       smoke behind them. */
    text-shadow:
      0 1px 3px color-mix(in srgb, var(--ink) 70%, transparent),
      0 2px 24px color-mix(in srgb, var(--ink) 80%, transparent);


    .mark {
      width: 36px;
      height: 29px;
    }

    .words { display: contents; }
    .mark { grid-area: mark; }

    blockquote {
      grid-area: quote;
      margin: 16px 0 0;
      max-width: 30em;
      font-size: clamp(var(--text-2xl), 2.4vw, var(--text-4xl));
      line-height: var(--leading-snug);
      font-weight: var(--weight-semibold);
      letter-spacing: -0.01em;
      text-wrap: pretty;
    }

    figcaption {
      grid-area: caption;
      margin-top: 16px;
    }

    .face { display: contents; }

    /* Round, close on his face, to the right of the quote. */
    .portrait {
      grid-area: portrait;
      width: 240px;
      margin-top: 16px;
      aspect-ratio: 1;
      border-width: 6px;
      border-radius: 50%;
    }

    .name {
      color: inherit;
      font-size: var(--text-lg);
    }

    .role {
      color: inherit;
      opacity: 0.85;
      font-size: var(--text-base);
    }

    /* Name and role on one line. */
    figcaption {
      .name, .role { display: inline; }
      .role { margin-left: 8px; }
    }
  }

  .cta {
    grid-area: cta;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
    text-shadow: none;
  }

  .tablet {
    grid-area: tablet;
    width: var(--tablet-w);
    margin-top: 40px;
    /* Safari clips a drop shadow to the element's box, so the box is padded
       out past the shadow; the negative margins keep the layout as is. The
       padding is on a wrapper: on the <img> itself, Safari squashes it. */
    box-sizing: content-box;
    padding: 0 48px 80px;
    margin-inline: -48px;
    margin-bottom: -80px;
    pointer-events: none;
    filter: drop-shadow(0 26px 40px color-mix(in srgb, var(--ink) 45%, transparent));

    img { width: 100%; }
  }

  .photo {
    grid-area: 1 / 1 / -1 / -1;
    position: relative;
    /* Under the shading behind the quote, which comes first in the page. */
    z-index: -2;
    margin: -48px calc(50% - 50vw) -64px;

    /* Pins the left edge of the worst flames, at (1440, 1350) in the
       3127 x 2085 original, just right of the tablet at any width. */
    img {
      --x: calc((100vw - min(100vw, var(--max-width))) / 2 + 24px + var(--tablet-w) * 1.05);
      /* The helicopter is 740px right of the flames: zoom out to keep it in
         view, but never so far the photo leaves the left edge uncovered. */
      --w: max(min(var(--tablet-w) * 3.9, (100vw - 96px - var(--x)) * 3127 / 740), var(--x) * 3127 / 1440);
      position: absolute;
      left: calc(var(--x) - var(--w) * 1440 / 3127);
      /* The hero ends 400px below the flames, at y 1750 in the original,
         wherever the zoom puts them: just past the burned area, before most
         of the intact houses. */
      bottom: calc(var(--w) * -335 / 3127);
      width: var(--w);
      max-width: none;
      height: auto;
    }

    /* Darkens from the window's left edge to the tablet's right edge: the
       text stays legible and the intact houses fade, the fire doesn't. In
       the margin of a wide window it is solid, so no houses show beside
       the tablet; it starts fading 200px before the content column. */
    &::after {
      --edge: calc((100vw - min(100vw, var(--max-width))) / 2 + 24px);
      content: "";
      position: absolute;
      inset: 0;
      background: linear-gradient(to right,
        var(--ink) calc(var(--edge) - 200px),
        color-mix(in srgb, var(--ink) 85%, transparent) var(--edge),
        transparent calc(var(--edge) + var(--tablet-w)));
    }

    figcaption {
      position: absolute;
      z-index: 1;
      right: 8px;
      bottom: 0;
      padding: 2px 6px;
      border-radius: 3px 3px 0 0;
      font-size: var(--text-xs);
      color: #fff;
      background: color-mix(in srgb, black 55%, transparent);
    }
  }
}

/* ---------- Split: photo beside copy ---------- */
.split {
  padding: 80px 0;

  .inner {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 64px;
    align-items: center;
  }

  &.reverse .inner { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
  &.reverse .media { order: 1; }

  .media {
    width: 100%;
    border-radius: 14px;
  }

  .body, .lede {
    max-width: 460px;
    font-size: clamp(var(--text-lg), 1.4vw, var(--text-xl));
  }

  .lede + .body { margin-top: 24px; }

  .contact-buttons { margin-top: 24px; }
}

/* ---------- Cards ---------- */
.cards {
  background: var(--bg-soft);
  padding: 80px 0;

  h2 { max-width: 680px; }

  .row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    margin-top: 32px;
  }

  .card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
  }

  .media {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    object-position: 50% 30%;
    border-bottom: 1px solid var(--border);
  }

  /* A portrait screenshot in an iPhone bezel, cut off by the bottom edge. */
  .media.phone {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: hidden;
    padding-top: 32px;
    background: var(--bg-soft);
  }

  .phone-wrap {
    position: relative;
    flex: none;
    width: 42%;
    aspect-ratio: 600 / 1136;
    background: url("/images/features/iphone-frame.7cc04f763a2dbc03aebf365d47ff60eafdc1188eb9f8a11db4095941277a5cfb.webp") center/contain no-repeat;

    .screen {
      position: absolute;
      inset: 6.51% 6.5% 2.82% 6.17%;
      overflow: hidden;
      background: #fff;
      border-radius: 26px;
    }

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

  .content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    padding: 32px;
  }

  h3 {
    margin: 0;
    font-size: var(--text-2xl);
    line-height: var(--leading-snug);
    font-weight: var(--weight-bold);
    color: var(--ink);
  }

  .body { margin-top: 12px; }
  .text-link { margin-top: 8px; }
  .content > :has(+ .quote) { margin-bottom: 24px; }

  .quote {
    margin: auto 0 0;
    padding-top: 24px;
    border-top: 1px solid var(--border);

    blockquote {
      margin: 0;
      font-size: var(--text-lg);
      line-height: var(--leading-normal);
      font-weight: var(--weight-medium);
      color: var(--ink);
      quotes: "\201C" "\201D";
      text-wrap: pretty;

      &:lang(nb) { quotes: "«" "»"; }
      &:lang(de) { quotes: "\201E" "\201C"; }
      &::before { content: open-quote; }
      &::after { content: close-quote; }
    }

    figcaption {
      display: flex;
      align-items: center;
      gap: 16px;
      margin-top: 16px;

      img {
        flex: none;
        width: 64px;
        height: 64px;
        border-radius: 50%;
        object-fit: cover;
      }
    }

    .name { font-size: var(--text-base); }
    .role { font-size: var(--text-sm); }
  }
}

/* ---------- Quote band: one user, large ---------- */
.quote-band {
  background: var(--bg-soft);
  padding: 80px 0;

  .inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 32px 64px;
  }

  .portrait {
    flex: 0 1 320px;
    min-width: 0;
    aspect-ratio: 1 / 1.03;
  }

  .statement {
    flex: 1 1 440px;
    min-width: 0;
    margin: 0;

    .mark {
      width: 36px;
      height: 29px;
      margin-top: 16px;
    }

    blockquote {
      margin: 16px 0 0;
      font-size: clamp(var(--text-2xl), 2.2vw, var(--text-4xl));
      line-height: var(--leading-snug);
      font-weight: var(--weight-semibold);
      letter-spacing: -0.01em;
      text-wrap: pretty;
    }

    figcaption {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 16px 32px;
      margin-top: 24px;
    }

    .name { font-size: var(--text-xl); }
    .role { font-size: var(--text-lg); }

    .logo {
      width: auto;
      height: 64px;
    }
  }
}

/* ---------- Customer list ---------- */
.customers {
  padding: 64px 0;

  .groups {
    display: flex;
    flex-wrap: wrap;
    gap: 32px 64px;
    margin-top: 24px;
  }

  .group {
    flex: 1 1 260px;
    min-width: 0;

    &:first-child { flex: 3 1 560px; }
  }

  h3 {
    margin: 0 0 12px;
    font-size: var(--text-md);
    line-height: var(--leading-snug);
    font-weight: var(--weight-regular);
    color: var(--ink-soft);
  }

  ul {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px 32px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--text-base);
    line-height: var(--leading-snug);
    font-weight: var(--weight-semibold);
    color: var(--ink);
  }
}

/* ---------- Narrow screens ---------- */
/* Just above the narrow layout, pinning the photo's bottom leaves a gap at
   the top: pin its top instead, and keep less space below the tablet. */
@media (min-width: 1000px) and (max-width: 1199px) {
  .hero {
    .inner { padding-bottom: 32px; }

    .photo {
      margin-bottom: -32px;

      img {
        top: 0;
        bottom: auto;
      }
    }
  }
}

@media (max-width: 999px) {
  /* Narrow: the same idea stacked. The quote, with a small portrait by the
     name, on the photo; then the tablet, two thirds of it over the photo's
     bottom edge with the flames in the gap above it; then the buttons. */
  .hero {
    .inner {
      --tablet-w: min(100vw - 48px, 560px);
      grid-template-columns: auto minmax(0, 1fr);
      grid-template-rows: auto;
      grid-template-areas:
        "mark mark"
        "quote quote"
        "portrait caption"
        "tablet tablet"
        "cta cta";
      column-gap: 12px;
      padding-block: 32px 56px;
    }

    .statement { display: contents; }

    .statement blockquote,
    .statement figcaption {
      text-shadow:
        0 1px 3px var(--ink),
        0 0 16px var(--ink),
        0 0 32px color-mix(in srgb, var(--ink) 80%, transparent);
    }

    .statement blockquote { max-width: none; }

    .statement .portrait {
      align-self: center;
      width: 56px;
      margin: 16px 0 0;
      border-width: 3px;
    }

    /* Name and role on one line if both fit; otherwise the role moves
       below the name as a whole rather than breaking after a few words. */
    .statement figcaption {
      align-self: center;
      display: flex;
      flex-wrap: wrap;
      align-items: baseline;
      column-gap: 8px;

      .name, .role { display: block; }
      .role { margin: 0; }
    }

    .cta { margin-top: 32px; }

    .tablet {
      justify-self: start;
      margin-top: 160px;
    }

    .photo {
      grid-area: 1 / 1 / 5 / -1;
      margin: -32px calc(50% - 50vw) calc(var(--tablet-w) * 0.684 / 3);

      img {
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: 70% 100%;
      }

      /* Turned up along the right edge, in the strip beside the tablet. */
      figcaption {
        right: 0;
        bottom: 0;
        padding: 6px 2px;
        border-radius: 0;
        font-size: calc(var(--text-xs) * 0.85);
        writing-mode: vertical-rl;
        transform: rotate(180deg);
      }

      /* Only a light shade from the top left: the text carries its own
         dark glow, so the sky top right and the flames stay visible. */
      &::after {
        background: linear-gradient(to bottom right,
          color-mix(in srgb, var(--ink) 60%, transparent),
          color-mix(in srgb, var(--ink) 30%, transparent) 35%,
          transparent 55%);
      }
    }
  }
}

@media (max-width: 879px) {
  .split, .cards, .quote-band { padding: 56px 0; }

  /* Still side by side, with tighter spacing and smaller copy. */
  .split {
    .inner { gap: 32px; }
    .lede, .body { font-size: var(--text-base); }
  }

  .cards .row { grid-template-columns: minmax(0, 1fr); }

  /* Stacked over the quote: centred and smaller, like the hero portrait. */
  .quote-band .portrait {
    flex-basis: 80%;
    max-width: 320px;
    margin-inline: auto;
  }
}

@media (max-width: 719px) {
  /* Stacked, but no wider than a phone column plus some, so the photo
     doesn't fill the screen on small tablets. */
  .split .inner,
  .split.reverse .inner {
    grid-template-columns: minmax(0, 1fr);
    max-width: calc(480px + 48px);
  }
  .split.reverse .media { order: 0; }
}

@media (max-width: 599px) {
  .hero {
    .inner {
      --tablet-w: calc((100vw - 48px) * 0.8);
      padding-top: 20px;
    }

    .photo { margin-top: -20px; }

    .statement .mark {
      width: 26px;
      height: 21px;
    }

    .statement blockquote { margin-top: 8px; }

    .statement .portrait { width: 68px; }
    .statement blockquote { font-size: var(--text-xl); }
    .tablet { margin-top: 120px; }

    .tablet {
      filter: drop-shadow(0 12px 20px color-mix(in srgb, var(--ink) 35%, transparent));
    }
  }

  .cards .content { padding: 24px; }
  .customers .group:first-child { flex-basis: 100%; }
}
