/* ==========================================================================
   AVKAP
   One typeface (DM Sans). White paper, near-black ink, deep slate accents.
   The footage carries the warmth: no gradients, no glows, no scrim.
   Below the hero the page is ruled by horizontal hairlines only.
   ========================================================================== */

/* ---------- Fonts ------------------------------------------------------- */

@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
  src: url("assets/fonts/dm-sans-v17-latin-variable.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Arial resized to DM Sans metrics, so the font swap does not move the layout. */
@font-face {
  font-family: "DM Sans Fallback";
  src: local("Arial");
  size-adjust: 104.53%;
  ascent-override: 94.9%;
  descent-override: 29.66%;
  line-gap-override: 0%;
}

/* ---------- Tokens ------------------------------------------------------ */

:root {
  --paper: #ffffff;
  --ink: #101c22; /* near-black: headline, tagline */
  --slate: #163441; /* accents: masthead, wordmark colour, footer field */
  --slate-2: #235267;
  --grey: #707070; /* wordmarks at rest */
  --muted: #5b6b73;
  --rule: #dee3e4;
  --sky: #e9d5b7; /* average of the footage sky, shown before the poster paints */

  /* Never narrower than a phone's notch or rounded corner needs. */
  --gutter: max(
    clamp(1.25rem, 4.5vw, 4.5rem),
    env(safe-area-inset-left, 0px),
    env(safe-area-inset-right, 0px)
  );
  --masthead-h: 5.5rem;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font: "DM Sans", "DM Sans Fallback", "Helvetica Neue", Arial, sans-serif;
}

@media (max-width: 47.99rem) {
  :root {
    --masthead-h: 3.5rem;
  }
}

/* ---------- Base -------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  /* Keeps focused links and in-page targets clear of the pinned masthead. */
  scroll-padding-top: calc(min(4rem, var(--masthead-h)) + 0.5rem);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  font-optical-sizing: auto;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

h1,
h2,
p,
ul {
  margin: 0;
}

a {
  color: inherit;
}

::selection {
  background: var(--slate);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--slate);
  outline-offset: 6px;
}

/* Sections that only receive focus from the skip link or an in-page link. */
[tabindex="-1"]:focus {
  outline: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.875rem 1.125rem;
  background: var(--slate);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
  transform: translateY(-250%);
}

.skip-link:focus {
  transform: none;
  outline-color: #fff;
  outline-offset: -5px;
}

/* ---------- Masthead ---------------------------------------------------- */

/* Over the hero the masthead belongs to the footage and scrolls away with
   it, so it never slides across the headline or the aircraft. */
.masthead {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--masthead-h);
  padding-inline: var(--gutter);
  color: var(--slate);
}

/* The white plate behind it once it is pinned. */
.masthead::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  opacity: 0;
}

/* Past the hero it returns as a compact plate pinned to the top. */
.masthead.is-stuck {
  position: fixed;
  height: min(4rem, var(--masthead-h));
  animation: masthead-in 0.45s var(--ease-out) both;
}

.masthead.is-stuck::before {
  opacity: 1;
}

.masthead.is-stuck.is-leaving {
  animation: masthead-out 0.25s ease-in both;
}

@keyframes masthead-in {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: none;
  }
}

@keyframes masthead-out {
  from {
    transform: none;
  }
  to {
    transform: translateY(-100%);
  }
}

.masthead__brand {
  padding-block: 0.75rem;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.3em;
  text-decoration: none;
}

.masthead__nav {
  display: flex;
  gap: clamp(1.25rem, 3vw, 2.75rem);
  margin-right: -0.18em; /* cancels the tracking after the last letter */
}

.masthead__nav a {
  position: relative;
  padding-block: 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
}

.masthead__nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0.18em;
  bottom: 0.5rem;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: 100% 50%;
  transition: transform 0.35s var(--ease-out);
}

.masthead__nav a:hover::after,
.masthead__nav a:focus-visible::after {
  transform: scaleX(1);
  transform-origin: 0 50%;
}

/* ---------- Hero -------------------------------------------------------- */

.hero {
  position: relative;
  height: 100vh; /* fallback for browsers without svh */
  height: 100svh;
  min-height: 22rem;
  overflow: hidden;
  color: var(--ink);
  /* A 24 by 14 pixel still of the footage: the first paint is already the sky. */
  background: var(--sky)
    url("data:image/webp;base64,UklGRmYAAABXRUJQVlA4IFoAAADQAwCdASoYAA4APt1cp0yopSOiMAgBEBuJQBOmUABpuZAoyOlS4VAA/uqM2VZwsMOp1+ay+wV6tPCaZI+9NUYFGSJ6r5QR861KlNQdogOaBzLI4RPw5kn7hAA=")
    center / cover no-repeat;
}

.hero__media {
  position: absolute;
  inset: 0;
  /* The poster also sits behind the video, so nothing flashes while it buffers. */
  background: url("assets/hero-poster.jpg") 100% 50% / cover no-repeat;
  will-change: transform;
}

.hero__video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 100% 50%; /* keeps the right winglet in frame */
  transform-origin: 71% 43%; /* the aircraft */
}

/* The headline rides just above the footage horizon, in the bright sky. */
.hero__inner {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: 60%;
}

.hero__title {
  font-size: clamp(1.75rem, min(1rem + 4vw, 8.2vh), 6rem);
  font-size: clamp(1.75rem, min(1rem + 4vw, 8.2svh), 6rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

/* Each line is a mask: the text rises into view from below its own baseline. */
.line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.14em; /* room for descenders inside the mask */
  margin-bottom: -0.14em;
}

.line__in {
  display: block;
}

/* Pause and play control for the background video: quiet until needed. */
.hero__toggle {
  position: absolute;
  right: var(--gutter);
  bottom: clamp(1.25rem, 3vw, 2rem);
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(22, 52, 65, 0.55);
  color: #fff;
  cursor: pointer;
  transition: background-color 0.25s ease;
}

.hero__toggle[hidden] {
  display: none;
}

.hero__toggle:hover,
.hero__toggle:focus-visible {
  background: var(--slate);
}

.hero__toggle:focus-visible {
  outline-offset: 3px;
}

.hero__toggle svg {
  grid-area: 1 / 1;
}

.hero__toggle[data-state="playing"] .icon-play,
.hero__toggle[data-state="paused"] .icon-pause {
  display: none;
}

/* Squarer landscape screens crop the sky on the left, which brings the wing
   in under the headline: lift the headline a little to keep clear air. */
@media (min-aspect-ratio: 5/4) and (max-aspect-ratio: 7/5) {
  .hero__inner {
    bottom: 63%;
  }
}

/* Portrait and near-square screens: a shorter hero keeps the whole fuselage
   in frame, and the headline moves up into the sky above the aircraft. */
@media (max-aspect-ratio: 5/4) {
  .hero {
    height: min(100vh, 150vw);
    height: min(100svh, 150vw);
    min-height: 26rem;
  }

  .hero__media {
    background-position: 78% 50%;
  }

  .hero__video {
    object-position: 78% 50%;
    transform-origin: 60% 43%;
  }

  .hero__inner {
    top: calc(var(--masthead-h) + 0.25rem);
    bottom: auto;
  }

  .hero__title {
    font-size: clamp(1.875rem, 8.4vw, 3.25rem);
  }
}

/* Portrait tablets: a little less height shows more of the frame, so the
   left winglet is not cut by the screen edge. */
@media (max-aspect-ratio: 5/4) and (min-width: 48rem) {
  .hero {
    height: min(100vh, 120vw);
    height: min(100svh, 120vw);
  }

  .hero__inner {
    top: calc(var(--masthead-h) + 1rem);
  }
}

/* A phone on its side: compact masthead, smaller headline pinned under it. */
@media (max-height: 30rem) and (min-aspect-ratio: 5/4) {
  :root {
    --masthead-h: 3.5rem;
  }

  .hero__inner {
    top: calc(var(--masthead-h) + 0.5rem);
    bottom: auto;
  }

  .hero__title {
    font-size: clamp(1.5rem, 7.2vh, 2rem);
  }
}

/* The narrowest phones: the portfolio is already in view below the hero. */
@media (max-width: 22.49rem) {
  .masthead__nav a[href="#portfolio"] {
    display: none;
  }
}

/* ---------- Portfolio --------------------------------------------------- */

.portfolio {
  position: relative;
  padding: clamp(5rem, 9vw, 8.5rem) var(--gutter) 0;
  background: var(--paper);
}

.grid {
  --draw: 1; /* 0 to 1: how far the hairlines have drawn in */
  position: relative;
  max-width: 82.5rem;
  margin-inline: auto;
}

.grid__rule {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--rule);
  transform: scaleX(var(--draw));
}

.grid__rule--top {
  top: 0;
}

.grid__rule--mid {
  top: 50%;
}

.grid__rule--end {
  bottom: 0;
}

/* Quarter rules: only the two-column tablet layout has four rows. */
.grid__rule--q1,
.grid__rule--q3 {
  display: none;
}

/* Four over three. Eight columns, each cell spans two, and the second row
   starts half a cell in: every name in it sits exactly under a tick above. */
.marks {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mark {
  position: relative;
  grid-column: span 2;
  container-type: inline-size;
}

.mark:nth-child(5) {
  grid-column: 2 / span 2;
}

/* Vertical dividers shrink to short ticks between neighbours. */
.mark + .mark::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 1px;
  height: 4rem;
  margin-top: -2rem;
  background: var(--rule);
  transform: scaleY(var(--draw));
}

.mark:nth-child(5)::before {
  content: none;
}

.mark__body {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: clamp(10.5rem, 13vw, 12rem);
  padding: 1.5rem 1rem;
  text-decoration: none;
  outline-offset: -0.75rem;
}

/* The wordmark: capitals, one weight, one size for all seven. */
.mark__name {
  position: relative;
  display: inline-block;
  max-width: 100%;
  margin-right: -0.1em; /* cancels the tracking after the last letter */
  color: var(--slate);
  font-size: 1.25rem; /* fallback for browsers without container units */
  font-size: clamp(1.0625rem, 7.4cqi, 1.5rem);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
  transition: transform 0.22s var(--ease-out), color 0.22s ease;
}

/* A real logo dropped into .mark__name takes the same slot. */
.mark__logo {
  display: block;
  width: 56cqi;
  height: 2.75rem;
  object-fit: contain;
  transition: filter 0.22s ease;
}

/* North-east arrow, hung outside the centred name: linked companies only. */
.mark__arrow {
  position: absolute;
  left: 100%;
  top: -0.05em;
  width: 0.42em;
  height: 0.42em;
  margin-left: 0.2em;
  color: var(--slate-2);
  opacity: 0.75;
  transition: opacity 0.22s ease, transform 0.22s var(--ease-out);
}

/* One line about the company. In the page for assistive technology,
   shown only on hover or keyboard focus. */
.mark__desc {
  position: absolute;
  left: 0.5rem;
  right: 0.5rem;
  top: calc(50% + 1.15rem);
  color: var(--muted);
  font-size: 0.8125rem;
  font-size: clamp(0.8125rem, 4.3cqi, 0.875rem);
  line-height: 1.45;
  letter-spacing: 0.01em;
  text-align: center;
  text-wrap: balance;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s var(--ease-out);
}

/* Keyboard focus mirrors hover. */
.mark__body:focus-visible .mark__name {
  transform: translateY(-6px);
}

.mark__body:focus-visible .mark__desc {
  opacity: 1;
  transform: none;
}

.mark__body:focus-visible .mark__arrow {
  opacity: 1;
  transform: none;
}

/* Pointer devices: greyscale at rest, full colour and a slight lift on hover.
   Touch devices have no hover, so they keep the full colour above. */
@media (hover: hover) and (pointer: fine) {
  .mark__name {
    color: var(--grey);
  }

  .mark__logo {
    filter: grayscale(1) opacity(0.68);
  }

  .mark__arrow {
    opacity: 0;
    transform: translate(-3px, 3px);
  }

  .mark__body:hover .mark__name,
  .mark__body:focus-visible .mark__name {
    color: var(--slate);
    transform: translateY(-6px);
    transition-duration: 0.35s;
  }

  .mark__body:hover .mark__logo,
  .mark__body:focus-visible .mark__logo {
    filter: grayscale(0) opacity(1);
    transition-duration: 0.35s;
  }

  .mark__body:hover .mark__desc {
    opacity: 1;
    transform: none;
    transition-duration: 0.35s;
    transition-delay: 0.06s;
  }

  .mark__body:hover .mark__arrow,
  .mark__body:focus-visible .mark__arrow {
    opacity: 1;
    transform: none;
    transition-duration: 0.35s;
  }
}

/* Tablets: two columns, four rows, the seventh name centred under the tick. */
@media (min-width: 40rem) and (max-width: 63.99rem) {
  .grid {
    max-width: 46rem;
  }

  .grid__rule--q1,
  .grid__rule--q3 {
    display: block;
  }

  .grid__rule--q1 {
    top: 25%;
  }

  .grid__rule--q3 {
    top: 75%;
  }

  .marks {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .mark,
  .mark:nth-child(5) {
    grid-column: span 2;
  }

  .mark:nth-child(7) {
    grid-column: 2 / span 2;
  }

  /* A tick only between the two names of a row. */
  .mark:nth-child(odd)::before {
    content: none;
  }

  .mark:nth-child(even)::before {
    content: "";
  }

  .mark__body {
    min-height: 9.5rem;
  }
}

/* Phones: a single ruled list. */
@media (max-width: 39.99rem) {
  .grid__rule--mid {
    display: none;
  }

  .marks {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: auto;
  }

  .mark,
  .mark:nth-child(5) {
    grid-column: auto;
  }

  .mark + .mark {
    border-top: 1px solid var(--rule);
  }

  .mark + .mark::before {
    content: none;
  }

  .mark__body {
    min-height: 5.5rem;
    padding-block: 1rem;
  }

  .mark__desc {
    display: none;
  }

  .mark__body:hover .mark__name,
  .mark__body:focus-visible .mark__name {
    transform: none;
  }
}

/* ---------- Tagline band ------------------------------------------------ */

/* One line of tracked capitals between the last rule and the footer. */
.band {
  padding: clamp(4.5rem, 8vw, 7.5rem) var(--gutter);
  background: var(--paper);
}

.band__text {
  margin-inline: auto;
  padding-left: 0.26em; /* optical centring for tracked capitals */
  color: var(--ink);
  font-size: clamp(0.9375rem, 0.6rem + 1.1vw, 1.5rem);
  font-weight: 400;
  line-height: 1.7;
  letter-spacing: 0.26em;
  text-align: center;
  text-transform: uppercase;
  text-wrap: balance;
}

/* ---------- Footer: the one slate field on the page --------------------- */

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  min-height: 5.5rem;
  padding: 1.25rem var(--gutter);
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  background: var(--slate);
  color: #fff;
}

.footer :focus-visible {
  outline-color: #fff;
}

.footer__mail {
  position: relative;
  padding-block: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.footer__mail::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.5rem;
  height: 1px;
  background: currentColor;
  opacity: 0.45;
  transition: opacity 0.35s ease;
}

.footer__mail:hover::after,
.footer__mail:focus-visible::after {
  opacity: 1;
}

.footer__legal {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.75rem;
  line-height: 1.5;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

@media (max-width: 40rem) {
  .footer {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding-block: 1.75rem;
    padding-bottom: max(1.75rem, env(safe-area-inset-bottom));
  }
}

/* ---------- Motion states ----------------------------------------------- */

/* Elements that animate in on load are hidden before first paint, but only
   where scripting is on and motion is welcome. If main.js never arrives,
   the failsafe animation reveals them anyway. Two routes to the same rule:
   the "js" class set by the one-line script in the head, and the scripting
   media query for browsers that support it. */
@media (prefers-reduced-motion: no-preference) {
  html.js:not(.is-loaded) .pre {
    opacity: 0;
    animation: pre-failsafe 0.8s ease 3.2s forwards;
  }
}

@media (scripting: enabled) and (prefers-reduced-motion: no-preference) {
  html:not(.is-loaded) .pre {
    opacity: 0;
    animation: pre-failsafe 0.8s ease 3.2s forwards;
  }
}

@keyframes pre-failsafe {
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    scroll-behavior: auto !important;
  }

  .mark__name,
  .mark__arrow,
  .mark__desc {
    transition-duration: 0.15s !important;
    transition-delay: 0s !important;
    transform: none !important;
  }
}
