/* ==========================================================================
   SHARED COMPONENT LAYER
   --------------------------------------------------------------------------
   Structural patterns lifted from ZygApp so both products share a vocabulary.
   Everything here reads from the BRIDGE layer in tokens.css — no raw hex.

   Portable to ZygApp as-is: reassign the bridge variables and these components
   render in ZygApp's cyan/violet instead of zukApp's teal/plum.

   Load order: tokens.css → system.css → styles.css → page styles.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Atmosphere — the faint technical grid and two soft glows.
   This is ZygApp's most recognisable surface treatment. Pure CSS: no images,
   no JS, no measurable performance cost.
   Apply `class="atmos"` to <body>.
   -------------------------------------------------------------------------- */
.atmos {
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(111, 76, 255, 0.10) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 80% 80%, rgba(0, 212, 255, 0.05) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--fg);
  font-family: var(--font-sans);
}

/* z-index: -1, not 0. A position:fixed element with z-index:0 paints ABOVE
   in-flow, non-positioned content in the same stacking context — so at 0 this
   grid would sit on top of every paragraph on the page. Negative z-index puts
   it behind the content but still in front of the parent's background, which is
   exactly where it belongs. Same reasoning for #drift below. */
.atmos::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--zyg-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--zyg-grid-line) 1px, transparent 1px);
  background-size: var(--zyg-grid-size) var(--zyg-grid-size);
  pointer-events: none;
  z-index: -1;
}

/* Anything that must be explicitly lifted above the backdrop layers. */
.above-grid { position: relative; z-index: 1; }

/* Particle drift canvas — behind the content, in front of the background.
   Driven by static/js/drift.js, which no-ops on small screens and when the
   visitor prefers reduced motion. */
#drift {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
}

/* --------------------------------------------------------------------------
   Page shell
   -------------------------------------------------------------------------- */
.shell {
  position: relative;
  z-index: 1;
  max-width: var(--measure);
  margin: 0 auto;
  /* Top padding clears the 60px fixed nav plus ZygApp's 72px breathing room.
     Deliberately here rather than on <body> — see the note in partials/nav.html. */
  padding: 132px 24px 120px;
  /* styles.css sets `main { text-align: center }` globally. Long-form copy set
     centred is unreadable, so the shell resets it. */
  text-align: left;
}

/* Same reset for the legacy container pages now using the atmos treatment, and
   `overflow-x: auto` on main was producing a horizontal scrollbar on narrow
   viewports. */
.atmos main {
  text-align: left;
  overflow-x: clip;
}

@media (max-width: 860px) {
  .shell { padding: 104px 20px 80px; }
}

/* Legacy pages that still use `main.container.p-5` also need clearance for the
   fixed nav — 3rem of padding isn't enough on its own. */
.atmos main.container { padding-top: 108px; }
@media (max-width: 860px) {
  .atmos main.container { padding-top: 84px; }
}

.shell--narrow { max-width: 760px; }

/* --------------------------------------------------------------------------
   Eyebrow — the `// LABEL` mono kicker above a heading.
   Signals "this is a section" without spending a heading level on it.
   -------------------------------------------------------------------------- */
.eyebrow {
  font-family: var(--font-label);
  font-size: 0.7rem;
  letter-spacing: var(--zyg-tracking-label);
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.85;
  margin: 0 0 16px;
}
.eyebrow::before { content: '// '; opacity: 0.5; }

/* --------------------------------------------------------------------------
   Section label — small caps label with a rule that fades out to the right.
   Cheap way to divide a long page without heavy borders.
   -------------------------------------------------------------------------- */
.section-label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-label);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin: 72px 0 24px;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--zyg-hairline-soft), transparent);
}

/* --------------------------------------------------------------------------
   Headings
   -------------------------------------------------------------------------- */
.display {
  font-size: var(--zyg-display);
  font-weight: 700;
  letter-spacing: var(--zyg-tracking-tight);
  line-height: 1.1;
  margin: 0 0 16px;
}
.display--sm { font-size: var(--zyg-display-sm); }

/* Gradient-filled emphasis. Use on one or two words, never a whole heading —
   gradient text at length is hard to read and cheapens the effect. */
.grad {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.lede {
  color: var(--fg-muted);
  font-size: 1rem;
  line-height: 1.7;
  max-width: 60ch;
  margin: 0 0 24px;
}

.prose {
  color: var(--fg);
  font-size: 0.95rem;
  line-height: 1.75;
  max-width: 68ch;
}
.prose p { margin: 0 0 1.1em; }
.prose a {
  color: var(--accent-soft);
  text-decoration: none;
  border-bottom: 1px solid rgba(108, 180, 164, 0.3);
  transition: border-color var(--dur-instant) var(--ease-out),
              color var(--dur-instant) var(--ease-out);
}
.prose a:hover {
  color: var(--focus-ring);
  border-bottom-color: var(--focus-ring);
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

/* Glassmorphism + blue-violet rim lighting.
   The rim is a 1px inset ring that brightens on the top-left, which is where
   the page's radial glow sits — so the light has a plausible source rather than
   being decoration. Restrained: no glow on idle, only on hover. */
.card {
  position: relative;
  display: block;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: linear-gradient(
    160deg,
    rgba(226, 232, 240, 0.055) 0%,
    rgba(226, 232, 240, 0.018) 40%,
    rgba(8, 12, 20, 0.30) 100%
  );
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  box-shadow:
    inset 0 1px 0 rgba(0, 212, 255, 0.10),
    inset 1px 0 0 rgba(111, 76, 255, 0.06),
    0 8px 24px rgba(0, 0, 0, 0.28);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: transform var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.card:hover {
  transform: translateY(-3px);
  border-color: rgba(0, 212, 255, 0.28);
  box-shadow:
    inset 0 1px 0 rgba(0, 212, 255, 0.22),
    inset 1px 0 0 rgba(111, 76, 255, 0.16),
    0 12px 32px rgba(0, 0, 0, 0.36),
    0 0 0 1px rgba(111, 76, 255, 0.10);
  text-decoration: none;
  color: inherit;
}

/* Glass panel — same material, non-interactive. */
.glass {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: linear-gradient(
    160deg,
    rgba(226, 232, 240, 0.05) 0%,
    rgba(8, 12, 20, 0.28) 100%
  );
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  box-shadow: inset 0 1px 0 rgba(0, 212, 255, 0.10);
  padding: 28px;
}

/* Scanline texture — ZygApp uses this over card imagery. Very subtle. */
.card--scan::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    var(--zyg-scanline) 3px,
    var(--zyg-scanline) 4px
  );
  pointer-events: none;
}

.card__kicker {
  font-family: var(--font-label);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 10px;
}
.card__title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  color: var(--fg);
}
.card__body {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--fg-muted);
  margin: 0;
}
.card__meta {
  font-family: var(--font-label);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-top: 16px;
}

/* Media card: image top, text below, image desaturates until hover.
   Keeps zukApp's existing grayscale-to-colour behaviour. */
.card--media { padding: 0; }
.card--media img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  filter: var(--grayscale-idle);
  transition: filter var(--dur-fast) var(--ease-out),
              transform var(--dur-slow) var(--ease-out);
}
.card--media:hover img {
  filter: var(--grayscale-hover);
  transform: scale(1.04);
}
.card--media .card__inner { padding: 20px 24px 24px; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg);
  font-family: var(--font-label);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--dur-instant) var(--ease-out);
}
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
  transform: translateY(-2px);
}
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-deep);
  font-weight: 600;
}
.btn--primary:hover {
  filter: brightness(1.12);
  color: var(--bg-deep);
}
.btn__arrow { transition: transform var(--dur-instant) var(--ease-out); }
.btn:hover .btn__arrow { transform: translateX(3px); }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

/* --------------------------------------------------------------------------
   Key/value list — for "what this is" facts. Reads as engineered rather than
   decorative, which is the point.
   -------------------------------------------------------------------------- */
.spec {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: 10px 24px;
  font-size: 0.85rem;
  margin: 0;
}
.spec dt {
  font-family: var(--font-label);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-faint);
  padding-top: 3px;
}
.spec dd {
  margin: 0;
  color: var(--fg);
  line-height: 1.6;
}

@media (max-width: 560px) {
  .spec { grid-template-columns: 1fr; gap: 2px 0; }
  .spec dd { margin-bottom: 14px; }
}

/* --------------------------------------------------------------------------
   Long-page rendering cost. One line, real win: the browser skips layout and
   paint for offscreen sections entirely.
   -------------------------------------------------------------------------- */
.defer-render {
  content-visibility: auto;
  contain-intrinsic-size: auto 600px;
}
