/* ==========================================================================
   Header actions · the cinematic menu · the top band of every page it opens
   The menu is a native modal <dialog> (main.js: initMenu). Desktop: the list on the left, each item's
   picture on the right, crossfading on hover / focus. Phone: every item is a strip of its picture.
   Choosing an item morphs its picture into the destination's .band (View Transitions API:
   view-transition-name "kf-morph", set by main.js on the two pictures in turn).
   Palette: ink and champagne carry it; cedar numbers, a moonlight hairline and one water-teal dot
   for the page you are on are the only accents.
   ========================================================================== */

/* ---------- Header: Design in 3D · Contact · Menu ---------- */

.header__actions {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2.4vw, 2.25rem);
}
.header__link {
  position: relative;
  display: none;
  align-items: center;
  min-height: 44px;
  color: rgba(244, 241, 234, 0.86);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: color 0.3s;
}
.header__link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0.18em;
  bottom: 10px;
  height: 1px;
  background: var(--moon);
  transform: scaleX(0);
  transform-origin: right center;
  transition: transform 0.5s var(--ease-out);
}
.header__link.is-current { color: var(--paper); }
.header__link.is-current::after { transform: scaleX(1); background: var(--champagne); }
@media (hover: hover) {
  .header__link:hover { color: var(--ivory); }
  .header__link:hover::after { transform: scaleX(1); transform-origin: left center; }
}
.header__cta { display: none; }
@media (min-width: 760px) {
  .header__cta { display: inline-flex; }
}
@media (min-width: 1000px) {
  .header__link { display: inline-flex; }
}

.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 44px;
  min-height: 44px;
  margin-right: -0.25rem;
  padding-inline: 0.25rem;
  color: var(--paper);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  transition: color 0.3s;
}
.nav-toggle__icon {
  position: relative;
  width: 26px;
  height: 7px;
}
.nav-toggle__icon::before,
.nav-toggle__icon::after {
  content: "";
  position: absolute;
  right: 0;
  height: 1px;
  background: currentColor;
  transition: width 0.45s var(--ease-out);
}
.nav-toggle__icon::before { top: 0; width: 100%; }
.nav-toggle__icon::after { top: 6px; width: 62%; background: var(--champagne); }
@media (hover: hover) {
  .nav-toggle:hover { color: var(--ivory); }
  .nav-toggle:hover .nav-toggle__icon::after { width: 100%; }
}
.nav-jump {
  display: none;
  align-items: center;
  min-height: 44px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
/* Without JS the menu can't open: this plain link goes to the footer's list of sections instead. */
html:not(.js) .nav-toggle { display: none; }
html:not(.js) .nav-jump { display: inline-flex; }

/* ---------- The menu ---------- */

.menu {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  overscroll-behavior: contain;
}
.menu::backdrop { background: rgba(5, 5, 6, 0.6); }
.menu:not([open]) { display: none; }

/* Opening: the dark comes down like a blind, then the list settles in, one line after another. */
.menu[open] { animation: menu-in 0.7s var(--ease-out) both; }
.menu.is-closing { animation: menu-out 0.36s var(--ease-in-out) both; }
@keyframes menu-in {
  from { clip-path: inset(0 0 100% 0); }
  to { clip-path: inset(0 0 0 0); }
}
@keyframes menu-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

.menu__inner {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
}

.menu__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
  border-bottom: 1px solid var(--rule);
}
.menu__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--paper);
  font-size: 0.875rem;
  font-weight: 300;
  letter-spacing: 0.34em;
}
.menu__brand img { width: 44px; height: 44px; }
.menu__close {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 44px;
  margin-right: -0.25rem;
  padding-inline: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  transition: color 0.3s;
}
.menu__x { position: relative; width: 18px; height: 18px; }
.menu__x::before,
.menu__x::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  top: 50%;
  height: 1px;
  background: currentColor;
  transform: rotate(45deg);
}
.menu__x::after { transform: rotate(-45deg); }
@media (hover: hover) {
  .menu__close:hover { color: var(--champagne); }
}

.menu__body {
  position: relative;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.menu__nav { padding: 1rem max(var(--gutter), env(safe-area-inset-right)) 1.5rem max(var(--gutter), env(safe-area-inset-left)); }
.menu__list { display: grid; gap: 0.5rem; }

.menu__item {
  opacity: 0;
  transform: translate(0, 0.9rem);
  transition: opacity 0.6s var(--ease-out), transform 0.8s var(--ease-out);
  transition-delay: calc(0.18s + var(--i, 0) * 0.045s);
}
.menu[open]:not(.is-closing) .menu__item { opacity: 1; transform: none; }

/* Phone and tablet: each item is a strip of its own picture, the name on the dark side. */
.menu__link {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  align-content: center;
  column-gap: 0.25rem;
  min-height: 88px;
  padding: 0.75rem 1rem 1.9rem;
  overflow: hidden;
  color: var(--text-strong);
  outline-offset: -2px;
}
.menu__tile {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--ink-2);
}
.menu__tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.78;
  transition: transform 1.2s var(--ease-out), opacity 0.6s var(--ease-out);
}
.menu__tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(10, 10, 10, 0.9) 0%, rgba(10, 10, 10, 0.74) 60%, rgba(10, 10, 10, 0.25) 100%);
}
.menu__tile .tag {
  left: auto;
  right: 0.5rem;
  bottom: 0.4rem;
  z-index: 2;
  padding: 0.2rem 0.5rem 0.25rem;
  font-size: 0.6875rem;
  line-height: 1.3;
  white-space: nowrap;
}
.menu__tile .tag--built { font-size: 0.625rem; }
.menu__tile .cgi { right: 0.6rem; bottom: 0.5rem; }
.menu__num {
  align-self: baseline;
  color: var(--cedar);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.16em;
}
.menu__name {
  align-self: baseline;
  font-size: 1.625rem;
  font-weight: 200;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 18px rgba(0, 0, 0, 0.5);
}
.menu__hint {
  grid-column: 2;
  color: rgba(244, 241, 234, 0.88);
  font-size: 0.8125rem;
  line-height: 1.4;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6);
}
.menu__link[aria-current="page"] .menu__num::after,
.menu__link.is-current .menu__num::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 0.4rem;
  border-radius: 50%;
  background: var(--water);
  vertical-align: middle;
  box-shadow: 0 0 10px rgba(95, 196, 189, 0.7);
}
.menu__link:active .menu__tile img { transform: scale(1.04); opacity: 0.95; }

.menu__stage { display: none; }

.menu__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 1.5rem;
  padding: 0.5rem max(var(--gutter), env(safe-area-inset-right)) calc(0.75rem + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  border-top: 1px solid var(--rule);
  color: var(--text);
  font-size: 0.875rem;
}
.menu__foot-label {
  flex-basis: 100%;
  padding-top: 0.5rem;
  color: var(--muted);
  font-size: 0.6875rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.menu__tel,
.menu__foot-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  transition: color 0.3s;
}
.menu__tel { color: var(--text-strong); font-size: 1.375rem; font-weight: 200; letter-spacing: 0.02em; }
@media (hover: hover) {
  .menu__tel:hover,
  .menu__foot-link:hover { color: var(--champagne); }
}
/* Small phones: the office line and the email live in the footer; the menu keeps Hristiyan. */
@media (max-width: 420px) {
  .menu__foot { gap: 0 1.25rem; }
  .menu__foot-link[href^="mailto:"],
  .menu__foot-link[href="tel:+447389840483"] { display: none; }
}
/* A phone held sideways (under 500 px tall): one line for Hristiyan, so the list keeps most of the screen
   (the two-line foot took a third of it and hid the third item, integrator walk 27.09). */
@media (max-height: 500px) and (max-width: 999.98px) {
  .menu__foot { flex-wrap: nowrap; gap: 0 1.25rem; padding-top: 0.25rem; padding-bottom: calc(0.25rem + env(safe-area-inset-bottom)); }
  .menu__foot-label { flex-basis: auto; padding-top: 0; white-space: nowrap; }
  .menu__foot-link[href^="mailto:"],
  .menu__foot-link[href="tel:+447389840483"] { display: none; }
}

/* Desktop: the list on the left, a large picture on the right (the one you point at). */
@media (min-width: 1000px) {
  .menu__body {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    overflow: hidden;
  }
  /* Nine items (KF Studio joined, R5). The list is centred with auto margins, not justify-content: when it is
     taller than the box the margins fall to 0 and it starts at the top, so item 01 can never sit above the
     scroll range (judge 27.09: at 1440×780 item 01 was hidden under the header). */
  .menu__nav {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: clamp(0.75rem, 2.4vh, 2.5rem) clamp(2rem, 4vw, 4rem) clamp(0.75rem, 2.4vh, 2.5rem) max(var(--gutter), env(safe-area-inset-left));
    overflow-y: auto;
  }
  .menu__list { gap: 0; margin-block: auto; border-top: 1px solid var(--rule); }
  .menu__link {
    grid-template-columns: 3.25rem minmax(0, 1fr);
    min-height: 0;
    padding: clamp(0.25rem, 0.9vh, 0.85rem) 0;
    overflow: visible;
    border-bottom: 1px solid var(--rule);
  }
  .menu__link::after {
    content: "";
    position: absolute;
    left: 3.25rem;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, var(--champagne), var(--moon-dim));
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.7s var(--ease-out);
  }
  .menu__tile { display: none; }
  .menu__name {
    font-size: clamp(1.5rem, min(4vh, 0.9rem + 1.9vw), 3.1rem);
    line-height: 1.12;
    text-shadow: none;
    transition: color 0.4s var(--ease-out), transform 0.7s var(--ease-out);
  }
  .menu__hint {
    color: var(--text-dim);
    font-size: 0.8125rem;
    text-shadow: none;
    transition: color 0.4s var(--ease-out), transform 0.7s var(--ease-out);
  }
  .menu__num { transition: color 0.4s var(--ease-out); }
  .menu__link.is-lit .menu__name,
  .menu__link:focus-visible .menu__name { color: var(--ivory); transform: translate3d(0.6rem, 0, 0); }
  .menu__link.is-lit .menu__hint,
  .menu__link:focus-visible .menu__hint { color: var(--moon); transform: translate3d(0.6rem, 0, 0); }
  .menu__link.is-lit .menu__num,
  .menu__link:focus-visible .menu__num { color: var(--champagne); }
  .menu__link.is-lit::after,
  .menu__link:focus-visible::after { transform: scaleX(1); }
  .menu__link:focus-visible { outline-offset: 4px; }

  .menu__stage {
    position: relative;
    display: block;
    margin: clamp(1rem, 3vh, 2rem) max(var(--gutter), env(safe-area-inset-right)) clamp(1rem, 3vh, 2rem) 0;
    overflow: hidden;
    background: var(--ink-2);
  }
  /* A gold hairline frame, drawn a few pixels inside the picture. */
  .menu__stage::after {
    content: "";
    position: absolute;
    inset: 12px;
    z-index: 2;
    border: 1px solid rgba(216, 199, 156, 0.28);
    pointer-events: none;
  }
  .menu__shot {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    transition: opacity 0.9s var(--ease-out);
  }
  .menu__shot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.08);
    transition: transform 2.4s var(--ease-out);
  }
  .menu__shot.is-on { z-index: 1; opacity: 1; }
  .menu__shot.is-on img { transform: scale(1.01); }
  .menu__shot::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(10, 10, 10, 0.55), rgba(10, 10, 10, 0) 38%);
  }
  .menu__label .cgi {
    right: 1.5rem;
    bottom: 1.4rem;
    z-index: 3;
    font-size: 0.625rem;
  }

  .menu__foot { gap: 0 2.25rem; }
  .menu__foot-label { flex-basis: auto; padding-top: 0; }
}

/* Laptop windows (a MacBook with browser chrome is ~780 px tall): the hints step aside so all nine names fit
   without scrolling, with room to breathe. */
@media (min-width: 1000px) and (max-height: 840px) {
  .menu__hint { display: none; }
}

/* ---------- The top band of every page the menu opens ---------- */

.band {
  position: relative;
  height: clamp(140px, 21svh, 230px);
  margin-bottom: clamp(1.75rem, 3.5vw, 3rem);
  overflow: hidden;
  background: var(--ink-2);
}
.band--tall { height: clamp(240px, 46svh, 520px); }
.band img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.07);
  transition: transform 2.6s var(--ease-out);
}
.band.is-in img { transform: none; }
/* Fades into the page below and lies quietly under the header above. */
.band::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(10, 10, 10, 0.4) 0%, rgba(10, 10, 10, 0) 28%),
    linear-gradient(to top, var(--ink) 0%, rgba(10, 10, 10, 0.35) 36%, rgba(10, 10, 10, 0) 64%);
}
.band .cgi {
  right: max(var(--gutter), env(safe-area-inset-right));
  bottom: 0.9rem;
  z-index: 2;
}
/* The band opens its block: no extra top padding above it. */
.home-block:has(> .band),
.faq:has(> .band) { padding-top: 0; }
.view.view:has(> .band) { padding-top: var(--masthead-full); }

/* ---------- The morph: the chosen picture becomes the band ---------- */

::view-transition-group(kf-morph) {
  animation-duration: 0.8s;
  animation-timing-function: cubic-bezier(0.7, 0, 0.2, 1);
}
::view-transition-old(kf-morph),
::view-transition-new(kf-morph) {
  width: 100%;
  height: 100%;
  object-fit: cover;
  overflow: clip;
}
::view-transition-old(kf-morph) { animation: kf-morph-out 0.8s cubic-bezier(0.7, 0, 0.2, 1) both; }
::view-transition-new(kf-morph) { animation: kf-morph-in 0.8s cubic-bezier(0.7, 0, 0.2, 1) both; }
@keyframes kf-morph-out { to { opacity: 0; } }
@keyframes kf-morph-in { from { opacity: 0; } }
/* While the picture travels, the rest of the page arrives more slowly behind it. */
html.is-morphing::view-transition-old(root) { animation: fade-out 0.45s var(--ease-in-out) both; }
html.is-morphing::view-transition-new(root) { animation: view-rise 0.8s 0.15s var(--ease-out) both; }

@media (prefers-reduced-motion: reduce) {
  .menu[open],
  .menu.is-closing { animation: none; }
  .menu__item,
  .menu__name,
  .menu__hint { transition: none; transform: none; }
  .menu[open] .menu__item { opacity: 1; }
  .menu__shot img,
  .band img { transform: none; transition: none; }
}

/* Landing on a block that opens with its band: the band meets the header's lower edge exactly
   (html's scroll-padding leaves a 1rem strip of the block above otherwise). */
.home-block:has(> .band),
.faq:has(> .band) { scroll-margin-top: -1rem; }
