/*
 * Homepage shell: document scrolling, page background and the charcoal
 * marble zone that runs from the hero to the end of Services.
 *
 * Scroll model: the document (window) scrolls. The original scrolled <body>
 * inside an overflow-hidden <html>; every scroll-linked behaviour reads
 * window.scrollY instead. Anchor jumps stay instant (no smooth
 * scroll-behavior), exactly as they behaved in the original.
 * See docs/components/home-opening.md.
 */

:root {
  /* Fixed header row reserved above the hero. */
  --home-header-reveal: clamp(70px, 5.46875vw, 105px);
}

/* 1080p and 2160p bands: the opening keeps its 1280x720 composition and
   scales as a whole by the smaller viewport ratio. */
@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) {
  :root {
    --home-scale-720: min(calc(100vw / 1280), calc(100vh / 720));
    --home-header-reveal: calc(70 * var(--home-scale-720));
  }
}

html {
  overflow-x: hidden;
  overflow-anchor: none;
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-height: 100%;
  /* Clip sideways overflow (hero image bleed, LIFT layers, orbit ring) as the
     original's scrolling <body> did. Without this, mobile browsers widen the
     layout viewport and zoom the page out. `clip` keeps the window as the
     scroller (no new scroll container), so position: sticky still works. */
  overflow-x: clip;
  font-family: var(--font-sans);
  color: var(--cream);
}

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

img {
  display: block;
  max-width: 100%;
}

/* Page background, fixed to the viewport (in the original it was painted by
   the scrolling <body> box, so it never moved). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 0%, var(--warm-stone), transparent 36rem),
    linear-gradient(180deg, var(--page-bg-top) 0%, var(--page-bg-bottom) 100%);
}

/* ── Charcoal marble zone ─────────────────────────────────────────────── */

.home-charcoal {
  position: relative;
  display: block;
  isolation: isolate;
}

/* Desktop: marble fixed behind the scrolling content, darkened by two
   vignette layers. */
.home-charcoal__background {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  background-image:
    radial-gradient(ellipse 72% 58% at 0% 0%, rgb(0 0 0 / 0.38) 0%, rgb(0 0 0 / 0.18) 34%, transparent 62%),
    radial-gradient(ellipse at 50% 35%, var(--charcoal-warm) 0%, var(--charcoal-warm-mid) 18%, var(--charcoal-warm-soft) 32%, var(--charcoal-warm-faint) 48%, transparent 62%),
    radial-gradient(ellipse at 50% 85%, var(--charcoal-warm-mid) 0%, var(--charcoal-warm-dim) 22%, transparent 45%),
    radial-gradient(ellipse at 50% 0%, var(--charcoal-deep) 0%, var(--charcoal-deep-mid) 14%, var(--charcoal-deep-soft) 26%, var(--charcoal-deep-faint) 40%, transparent 55%),
    linear-gradient(rgb(0 0 0 / 0.02), rgb(0 0 0 / 0.02)),
    url("../../images/002-dt-stone.webp");
}

.home-charcoal__background::before,
.home-charcoal__background::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.home-charcoal__background::before {
  z-index: 1;
  background:
    linear-gradient(180deg, rgb(0 0 0 / 0.26) 0%, rgb(0 0 0 / 0.2) 24%, rgb(0 0 0 / 0.22) 48%, rgb(0 0 0 / 0.36) 76%, rgb(0 0 0 / 0.52) 100%),
    linear-gradient(180deg, transparent 0%, rgb(0 0 0 / 0.24) 72%, rgb(0 0 0 / 0.4) 100%);
}

.home-charcoal__background::after {
  z-index: 2;
  background: radial-gradient(ellipse 88% 62% at 50% 38%, rgb(0 0 0 / 0.4) 0%, rgb(0 0 0 / 0.28) 32%, rgb(0 0 0 / 0.12) 56%, transparent 74%);
}

.home-charcoal__content {
  position: relative;
  z-index: 2;
  /* The fixed header takes no layout space; reserve its row here. */
  padding-top: var(--home-header-reveal);
}

/* Phones and touch tablets: a flat warm-charcoal gradient covering the whole
   zone instead of the fixed marble (cheap to composite while scrolling). */
@media (max-width: 1180px), (pointer: coarse) and (min-width: 768px) {
  .home-charcoal__background {
    position: absolute;
    background-color: #17120e;
    background-image:
      radial-gradient(ellipse 82% 34% at 50% 12%, rgb(83 55 34 / 0.28), transparent 70%),
      linear-gradient(180deg, #17120e 0%, #100d0a 58%, #090807 100%);
  }
}

/* Keep Safari's document canvas dark when scroll locking causes a repaint.
   The existing fixed gradient still paints above this fallback. Keep the
   default color scheme so the transparent Our Role iframe stays transparent. */
@media (pointer: coarse) and (min-width: 768px) and (max-width: 1400px) and (orientation: landscape) {
  html { background-color: #100d09; }
}
