/*
 * Site header — the KIWITILE brand (left) and the KT logo menu button (right).
 *
 * The header is fixed, transparent and lets clicks through except on its two
 * controls. Every dimension is authored at the 1280×720 composition and
 * multiplied by one unit, --header-u:
 *   - default: 1px at ≤1280 wide, growing with the width up to 1.5px at 1920;
 *   - homepage (.site-header--home) in the 1080p and 2160p bands: the uncapped
 *     1280×720 scale min(100vw/1280, 100vh/720), so the masthead keeps its
 *     approved proportions at 1920×1080 and 3840×2160.
 *
 * After scrolling, header.js adds body.is-brand-vertical and the eight brand
 * letters pivot from a horizontal word into a vertical rail.
 */

:root {
  --header-u: clamp(1px, calc(100vw / 1280), 1.5px);
  /* Height of the fixed header row; pages use it to reserve that space. */
  --header-height: calc(70 * var(--header-u));
}

.site-header {
  --header-logo-size: calc(82 * var(--header-u));
  --header-logo-nudge-x: calc(4 * var(--header-u));
  --header-logo-nudge-y: calc(3 * var(--header-u));
  --brand-size: calc(28 * var(--header-u));
  --brand-ease: cubic-bezier(0.7, 0, 0.3, 1);

  position: fixed;
  inset: 0 0 auto;
  z-index: 9012;
  box-sizing: border-box;
  height: var(--header-height);
  padding: 0 calc(18 * var(--header-u)) 0 calc(24 * var(--header-u));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  pointer-events: none;
}

body.is-menu-open .site-header {
  /* Above the open menu panel so the KT button stays usable as "close". */
  z-index: 2147481002;
}

.site-header__start,
.site-header__end {
  pointer-events: auto;
}

.site-header__start {
  position: relative;
  display: flex;
  align-items: center;
  /* Mobile homepage: header.js moves the brand up with the page scroll. */
  transform: translate3d(0, var(--header-follow-y, 0px), 0);
}

.site-header__end {
  position: absolute;
  top: 0;
  right: calc(16 * var(--header-u));
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* ----- Brand: eight absolutely placed letters ----- */

.site-header__brand {
  position: relative;
  display: block;
  box-sizing: border-box;
  width: calc(220 * var(--header-u));
  height: calc(34 * var(--header-u));
  color: inherit;
  font-family: var(--font-serif);
  font-size: var(--brand-size);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.18em;
  text-decoration: none;
  text-transform: uppercase;
  text-shadow: 0 1px 1px rgb(0 0 0 / 0.45), 0 -1px 0 rgb(255 255 255 / 0.14);
  filter: drop-shadow(0 0 4px rgb(255 245 210 / 0.25));
  transform-origin: left center;
  transition:
    width 900ms var(--brand-ease),
    height 900ms var(--brand-ease),
    transform 900ms var(--brand-ease);
}

.site-header__letter {
  --x: 0;
  --y: 0;
  position: absolute;
  top: 0;
  left: 0;
  font-family: var(--font-serif);
  font-size: var(--brand-size);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 0 1px 1px rgb(0 0 0 / 0.55), 0 3px 10px rgb(0 0 0 / 0.28);
  transform: translate(calc(var(--x) * var(--header-u)), calc(var(--y) * var(--header-u)));
  transition: transform 900ms var(--brand-ease), opacity 700ms ease;
}

.site-header__letter--bronze {
  color: #e5c477;
  -webkit-text-fill-color: #e5c477;
  -webkit-text-stroke: 0.2px #e5c477;
  text-shadow: 0 0 8px rgb(229 196 119 / 0.18);
}

.site-header__letter--silver {
  color: #c9c6bd;
  -webkit-text-stroke: 0.35px rgb(20 10 4 / 0.15);
  filter: brightness(1.06) contrast(1.04);
}

/* Horizontal word: letter offsets in 1280-composition pixels. */
.site-header__letter:nth-child(2) { --x: 24; transition-delay: 20ms; }
.site-header__letter:nth-child(3) { --x: 36; transition-delay: 40ms; }
.site-header__letter:nth-child(4) { --x: 68; transition-delay: 60ms; }
.site-header__letter:nth-child(5) { --x: 83; transition-delay: 80ms; }
.site-header__letter:nth-child(6) { --x: 104; transition-delay: 100ms; }
.site-header__letter:nth-child(7) { --x: 118; transition-delay: 120ms; }
.site-header__letter:nth-child(8) { --x: 139; transition-delay: 140ms; }

/* Vertical rail. */
body.is-brand-vertical .site-header__brand {
  width: calc(34 * var(--header-u));
  height: calc(220 * var(--header-u));
  opacity: 0.7;
  transform: translate(calc(-17 * var(--header-u)), calc(60 * var(--header-u))) scale(0.8);
}

body.is-brand-vertical .site-header__letter:nth-child(2) { --x: 4; --y: 24; }
body.is-brand-vertical .site-header__letter:nth-child(3) { --x: -2.5; --y: 48; }
body.is-brand-vertical .site-header__letter:nth-child(4) { --x: 4; --y: 72; }
body.is-brand-vertical .site-header__letter:nth-child(5) { --x: 0; --y: 96; }
body.is-brand-vertical .site-header__letter:nth-child(6) { --x: 4; --y: 120; }
body.is-brand-vertical .site-header__letter:nth-child(7) { --x: 2; --y: 144; }
body.is-brand-vertical .site-header__letter:nth-child(8) { --x: 2; --y: 168; }

/* ----- KT logo menu button ----- */

.site-header__menu-button {
  position: relative;
  z-index: 2;
  box-sizing: border-box;
  width: var(--header-logo-size);
  height: var(--header-logo-size);
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  cursor: pointer;
  line-height: 0;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 200ms ease;
}

/* Dark disc behind the transparent logo artwork. */
.site-header__menu-button::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  width: calc(var(--header-logo-size) * 0.632);
  height: calc(var(--header-logo-size) * 0.632);
  border-radius: 50%;
  background: linear-gradient(113deg, rgb(42 32 23 / 0.96), rgb(16 13 10 / 0.98));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.1);
  transform: translate(-50%, -50%) translate3d(var(--header-logo-nudge-x), var(--header-logo-nudge-y), 0);
  pointer-events: none;
}

.site-header__menu-button:focus-visible {
  outline: 2px solid #f1c77d;
  outline-offset: 5px;
}

.site-header__menu-button[aria-expanded="true"] {
  box-shadow: 0 10px 22px rgb(0 0 0 / 0.42), 0 0 18px rgb(228 160 85 / 0.18);
}

.site-header__logo {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  transform: translate3d(var(--header-logo-nudge-x), var(--header-logo-nudge-y), 0);
  backface-visibility: hidden;
  will-change: transform, filter;
  user-select: none;
  pointer-events: none;
  -webkit-user-drag: none;
  transition: transform 180ms ease, filter 180ms ease;
}

/* ----- Large screens ----- */

/* ≥1921×1081: the brand type follows the site-wide high-res type scale while
   its geometry stays at the 1920 caps. */
@media (min-width: 1921px) and (min-height: 1081px) {
  .site-header {
    --brand-size: clamp(42px, min(2.1875vw, 3.888889vh), 60.9px);
  }
}

/* Homepage at 1080p and 2160p: the whole masthead keeps its 1280×720
   proportions. */
@media (min-width: 1600px) and (max-width: 2200px) and (min-height: 900px) and (max-height: 1250px),
       (min-width: 3200px) and (max-width: 4400px) and (min-height: 1800px) and (max-height: 2500px) {
  body:has(.site-header--home) {
    --header-u: min(calc(100vw / 1280), calc(100vh / 720));
    --header-height: calc(70 * var(--header-u));
  }

  .site-header--home {
    --brand-size: calc(28 * var(--header-u));
  }
}
