/* texture.css — the atmosphere layer for the Skyframe home page.
   Substrate lighting (key + fill + breathing phosphor bloom), drifting
   lattice, the rest-state exposure grade for photography, sectional light
   hierarchy, and the shared surface-elevation language.
   Loads last by design: it composes over every other module using only
   the --*-rgb channel triplets from tokens.css. */

/* ------------------------------------------------------------------ */
/* Fixed atmosphere layers                                             */
/* ------------------------------------------------------------------ */

.site-substrate,
.site-lattice,
.site-atmos {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

/* Substrate — the lighting rig. One phosphor key light high right
   (echoing the sensor lens), one cool paper fill low left, and a faint
   skylight falloff so the page reads top-lit, not floodlit. */
.site-substrate {
  z-index: var(--z-substrate);
  background:
    radial-gradient(56rem 40rem at 84% -8%, rgba(var(--phosphor-rgb), 0.07), transparent 70%),
    radial-gradient(46rem 46rem at 6% 44%, rgba(var(--paper-rgb), 0.034), transparent 68%),
    linear-gradient(180deg, rgba(var(--paper-rgb), 0.017), transparent 24rem),
    var(--ink);
}

/* Breathing key light — additive bloom that swells over ~18s.
   Opacity-only, so it stays on the compositor; reduced-motion users
   simply keep the base substrate light. */
.site-substrate::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(70rem 50rem at 88% -12%, rgba(var(--phosphor-rgb), 0.05), transparent 72%);
  opacity: 0;
  animation: substrate-breathe 18s var(--ease-in-out-quart) infinite alternate;
}

@keyframes substrate-breathe {
  to { opacity: 1; }
}

/* Lattice — the survey grid, strongest near the sky. */
.site-lattice {
  z-index: var(--z-lattice);
  opacity: 0.4;
  background-image:
    linear-gradient(rgba(var(--phosphor-rgb), 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--phosphor-rgb), 0.035) 1px, transparent 1px),
    linear-gradient(rgba(var(--paper-rgb), 0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--paper-rgb), 0.012) 1px, transparent 1px);
  background-position: 0 0, 0 0, 0 0, 0 0;
  background-size: 64px 64px, 64px 64px, 16px 16px, 16px 16px;
  mask-image: linear-gradient(to bottom, black 0%, rgba(0, 0, 0, 0.7) 38%, rgba(0, 0, 0, 0.16) 100%);
  animation: lattice-drift var(--dur-marquee) var(--ease-linear) infinite;
}

/* Atmos — a viewport vignette above the content, below the header.
   Ink-only: it grounds the corners and lets panel shadows melt into
   the frame instead of floating on flat black. */
.site-atmos {
  z-index: var(--z-nav); /* ties with the header, which wins by DOM order */
  background:
    radial-gradient(135% 100% at 50% 38%, transparent 60%, rgba(var(--ink-rgb), 0.5) 100%),
    linear-gradient(180deg, rgba(var(--ink-rgb), 0.36), transparent 9rem);
}

/* ------------------------------------------------------------------ */
/* Header glass — the fixed nav must never let content strike through. */
/* ------------------------------------------------------------------ */
/* The scrolled state is graded to read opaque even where               */
/* backdrop-filter is unavailable; blur stays as an enhancement.        */

.site-header {
  background: linear-gradient(180deg, rgba(var(--ink-rgb), 0.82), rgba(var(--ink-rgb), 0.44) 64%, transparent);
  /* The instrument panel is on from frame one. Intro tweens (motion.js /
     even-home.js both run a from() fade-slide on the header) can freeze at
     frame one under held global timelines — a 0.72-opacity header is how
     section text strikes through the nav. Paint integrity wins over a
     350ms entrance: pin it. */
  opacity: 1 !important;
  transform: none !important;
}

.site-header.is-scrolled {
  background:
    linear-gradient(180deg, rgba(var(--paper-rgb), 0.035), transparent),
    rgb(var(--ink-rgb));
  /* The plate is opaque, so the blur adds nothing — and headless/software
     rasterizers drop a backdrop-filtered element's background entirely,
     which is exactly the strike-through failure mode. */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.site-header.nav-is-open {
  background: rgb(var(--ink-rgb));
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* ------------------------------------------------------------------ */
/* Rest-state exposure grade                                           */
/* ------------------------------------------------------------------ */
/* The photography must read at rest, not only on hover. Mid-tones are
   lifted to roughly the hover grade; hover keeps its further step (the
   phosphor cone, edge light and baseline live in tiles.css). Shades are
   re-aimed, not thickened: local pockets seat the HUD readouts while
   the frame as a whole breathes. */

/* The hero plate never rests translucent: the intro from() tweens
   (even-home.js / motion.js) can freeze at frame one and park the media
   at 0.66 opacity — the exact exposure crush flagged in review. Pin the
   plate; the scale settle may still play. */
.hero-media {
  opacity: 1 !important;
}

.hero-image {
  filter: saturate(0.82) contrast(1.03) brightness(1.12);
}

.hero-media-shade {
  background:
    linear-gradient(90deg, rgba(var(--ink-rgb), 0.42), transparent 40%),
    linear-gradient(0deg, rgba(var(--ink-rgb), 0.58), transparent 30%),
    linear-gradient(180deg, rgba(var(--ink-rgb), 0.3), transparent 24%);
}

.hero-media-atmos::before {
  background:
    radial-gradient(38rem 30rem at 74% 52%, rgba(var(--phosphor-rgb), 0.18), transparent 68%),
    radial-gradient(30rem 22rem at 10% 96%, rgba(var(--phosphor-rgb), 0.06), transparent 70%);
}

.service-media {
  filter: grayscale(0.16) saturate(0.8) contrast(1.04) brightness(1.02);
}

.service-consulting .service-media {
  filter: grayscale(0.3) saturate(0.7) contrast(1.06) brightness(0.86);
}

/* Shade re-aim: bottom seat for body copy, left seat for headlines, and
   a top-right pocket so the coordinates readout never fights the sky. */
.service-shade {
  background:
    linear-gradient(180deg, rgba(var(--ink-rgb), 0.5), transparent 26%),
    linear-gradient(0deg, rgba(var(--ink-rgb), 0.94) 2%, rgba(var(--ink-rgb), 0.5) 40%, rgba(var(--ink-rgb), 0.1) 72%),
    linear-gradient(90deg, rgba(var(--ink-rgb), 0.48), transparent 58%),
    radial-gradient(26rem 15rem at 100% 0%, rgba(var(--ink-rgb), 0.52), transparent 74%);
}

.chapter-visual > picture > img {
  filter: saturate(0.66) contrast(1.07) brightness(0.95);
}

.chapter-intelligence > picture > img {
  filter: saturate(0.85) contrast(1.04) brightness(0.98);
}

/* ------------------------------------------------------------------ */
/* Sectional light hierarchy                                           */
/* ------------------------------------------------------------------ */
/* Sections are transparent over the substrate; ink washes occlude the
   lattice and lighting to push a section back, paper/phosphor washes
   pull it forward. The page reads: lit workshop (services), route under
   survey light (pathways), deep lab under an overhead cone (systems),
   night sea with a beacon (mission), landing pad horizon (contact). */

.services {
  background-image:
    radial-gradient(64rem 30rem at 10% -4%, rgba(var(--paper-rgb), 0.032), transparent 70%),
    linear-gradient(180deg, transparent 72%, rgba(var(--ink-rgb), 0.5) 100%);
}

.pathways {
  background-image:
    radial-gradient(52rem 26rem at 50% -2%, rgba(var(--phosphor-rgb), 0.03), transparent 72%),
    linear-gradient(180deg, rgba(var(--ink-rgb), 0.4), transparent 22rem);
}

/* Deep lab: a lit seam at the border, an overhead cone falling onto the
   accordion, edges sinking back into ink. */
.systems {
  background-image:
    radial-gradient(48rem 9rem at 50% 0%, rgba(var(--phosphor-rgb), 0.05), transparent 74%),
    radial-gradient(64rem 36rem at 30% 12%, rgba(var(--paper-rgb), 0.026), transparent 70%),
    linear-gradient(180deg, rgba(var(--ink-rgb), 0.45), transparent 24%, transparent 72%, rgba(var(--ink-rgb), 0.55)),
    radial-gradient(72rem 42rem at 80% 28%, rgba(var(--phosphor-rgb), 0.025), transparent 70%);
}

/* Night sea: the signal beacon sits high right, above the doctrine
   panel; a second low glow answers from the shore. */
.mission {
  background-image:
    radial-gradient(46rem 30rem at 72% 12%, rgba(var(--phosphor-rgb), 0.06), transparent 70%),
    radial-gradient(48rem 30rem at 12% 100%, rgba(var(--phosphor-rgb), 0.04), transparent 72%),
    linear-gradient(180deg, rgba(var(--ink-rgb), 0.45), transparent 30%);
}

/* Landing pad: keep contact's own composed wash (incl. the centerline)
   and add a low horizon glow rising behind the form. Scoped to desktop
   so mission-contact's mobile recomposition stays authoritative. */
@media (min-width: 981px) {
  .contact {
    background:
      linear-gradient(90deg, transparent 49.95%, var(--hairline-soft) 50%, transparent 50.05%),
      radial-gradient(circle at 18% 36%, rgba(var(--phosphor-rgb), 0.08), transparent 27rem),
      radial-gradient(44rem 26rem at 80% 96%, rgba(var(--phosphor-rgb), 0.05), transparent 72%),
      radial-gradient(46rem 22rem at 58% -6%, rgba(var(--paper-rgb), 0.024), transparent 70%),
      var(--charcoal);
  }
}

/* Footer keeps its own phosphor horizon (footer.css); add the paper
   skylight above it so the wordmark sinks between two light sources. */
.site-footer {
  background-image:
    radial-gradient(70rem 22rem at 50% -4%, rgba(var(--paper-rgb), 0.024), transparent 72%),
    radial-gradient(58rem 20rem at 50% 100%, rgba(var(--phosphor-rgb), 0.08), transparent 72%);
}

/* ------------------------------------------------------------------ */
/* Surface elevation language                                          */
/* ------------------------------------------------------------------ */
/* Raised plates share one treatment: a 1px paper skylight along the top
   edge, a faint sheen falling from it, and soft ink occlusion outside —
   atmosphere swallowing light around the object, never a hard drop. */

.service-matrix,
.system-accordions,
.hero-media {
  box-shadow:
    0 2.4rem 5rem -2.2rem rgba(var(--ink-rgb), 0.9),
    0 -1.6rem 4rem -2.4rem rgba(var(--ink-rgb), 0.75);
}

.service-card {
  box-shadow: inset 0 1px 0 rgba(var(--paper-rgb), 0.055);
  background-image: linear-gradient(180deg, rgba(var(--paper-rgb), 0.024), transparent 34%);
}

.system-panel {
  box-shadow: inset 0 1px 0 rgba(var(--paper-rgb), 0.05);
  background-image: linear-gradient(180deg, rgba(var(--paper-rgb), 0.02), transparent 30%);
}

.principles,
.project-form {
  box-shadow:
    inset 0 1px 0 rgba(var(--paper-rgb), 0.055),
    0 2.4rem 5rem -2.2rem rgba(var(--ink-rgb), 0.9),
    0 -1.6rem 4rem -2.4rem rgba(var(--ink-rgb), 0.75);
}

/* The doctrine panel and intake form get the volumetric treatment the
   cube renders enjoy: a phosphor key light high right, cool fill low
   left, falling onto the plate instead of flat panel paint. */
.principles {
  background:
    radial-gradient(32rem 22rem at 86% -12%, rgba(var(--phosphor-rgb), 0.09), transparent 68%),
    radial-gradient(30rem 20rem at -6% 112%, rgba(var(--paper-rgb), 0.035), transparent 70%),
    var(--panel);
}

.project-form {
  background-image:
    radial-gradient(30rem 20rem at 90% -14%, rgba(var(--phosphor-rgb), 0.075), transparent 70%),
    radial-gradient(26rem 18rem at -8% 108%, rgba(var(--paper-rgb), 0.03), transparent 70%),
    linear-gradient(180deg, rgba(var(--paper-rgb), 0.03), transparent 7rem);
}

/* Chapter cards keep their module's rising occlusion; add the skylight. */
.chapter-card {
  box-shadow:
    inset 0 1px 0 rgba(var(--paper-rgb), 0.05),
    0 -1.2rem 2.8rem rgba(var(--ink-rgb), 0.72);
}

/* ------------------------------------------------------------------ */
/* Hardware ghosts — the third act of the material story               */
/* ------------------------------------------------------------------ */
/* Inside the open accordion panel the hardware emerges from the dark,
   alethia-style: heavily graded, masked into the panel's right half,
   under the ghost ordinal and the content. Static, desktop only. */

@media (min-width: 761px) {
  .system-panel::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image: image-set(
      url("../../img/skyframe-sensor-macro.webp") type("image/webp"),
      url("../../img/skyframe-sensor-macro.png") type("image/png")
    );
    background-position: 88% 42%;
    background-repeat: no-repeat;
    background-size: cover;
    filter: grayscale(0.68) contrast(1.08) brightness(0.78);
    opacity: 0;
    mask-image: radial-gradient(62% 125% at 86% 56%, black 0%, rgba(0, 0, 0, 0.72) 45%, transparent 76%);
    -webkit-mask-image: radial-gradient(62% 125% at 86% 56%, black 0%, rgba(0, 0, 0, 0.72) 45%, transparent 76%);
    transition: opacity var(--dur-8) var(--ease-in-out-quart);
  }

  .system-panel:nth-child(2n)::after {
    background-image: image-set(
      url("../../img/skyframe-ai-pipeline.webp") type("image/webp"),
      url("../../img/skyframe-ai-pipeline.png") type("image/png")
    );
    background-position: 64% 48%;
  }

  .system-panel.is-active::after {
    opacity: 0.2;
  }
}

/* ------------------------------------------------------------------ */
/* Scanline + dither accents (diegetic HUD instruments only)           */
/* ------------------------------------------------------------------ */

/* Proof rail — recessed instrument groove with a faint CRT raster. */
.proof-rail {
  background-image: repeating-linear-gradient(0deg, rgba(var(--ink-rgb), 0.28) 0 1px, transparent 1px 4px);
  box-shadow:
    inset 0 0.9rem 1.5rem -0.9rem rgba(var(--ink-rgb), 0.9),
    inset 0 -0.9rem 1.5rem -0.9rem rgba(var(--ink-rgb), 0.9);
}

/* HUD chips on the chapter visuals — hairline scan raster. */
.chapter-node {
  background-image: repeating-linear-gradient(0deg, rgba(var(--phosphor-rgb), 0.08) 0 1px, transparent 1px 3px);
}

/* Impact card — halftone dot screen so the phosphor plate reads as
   printed material, not flat fill. */
.chapter-impact {
  background-image: radial-gradient(rgba(var(--ink-rgb), 0.13) 1px, transparent 1.6px);
  background-size: 6px 6px;
}

/* ------------------------------------------------------------------ */
/* Responsive + print                                                  */
/* ------------------------------------------------------------------ */

@media (max-width: 760px) {
  .site-atmos {
    background:
      radial-gradient(150% 100% at 50% 40%, transparent 64%, rgba(var(--ink-rgb), 0.4) 100%),
      linear-gradient(180deg, rgba(var(--ink-rgb), 0.3), transparent 7rem);
  }

  .site-substrate {
    background:
      radial-gradient(34rem 26rem at 92% -6%, rgba(var(--phosphor-rgb), 0.065), transparent 70%),
      radial-gradient(30rem 30rem at 0% 38%, rgba(var(--paper-rgb), 0.03), transparent 68%),
      linear-gradient(180deg, rgba(var(--paper-rgb), 0.016), transparent 18rem),
      var(--ink);
  }
}

@media print {
  .site-atmos {
    display: none !important;
  }
}
