/* =========================================================
   NetRoom — Capabilities illustration set (shared card + media styles)
   Scoped to #nr-root, prefixed .cap-. Reused by both the full
   /capabilities/ page grid and the homepage teaser section.
   Relies exclusively on tokens from netroom.css (--grad, --bg-2, --line,
   --r-lg, --a1, --a2, --fg-dim, --fg-mute, --fg-faint, --ease) — no new
   colors are introduced here, so light/dark theming is inherited for free.
   ========================================================= */

/* ---- Grid host + span utilities ------------------------------------- */
#nr-root .cap-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 210px;
  gap: 20px;
  /* No grid-auto-flow: dense on purpose — DOM order must equal visual
     order (WCAG 1.3.2 / 2.4.3). Card order in the caller decides layout. */
}
#nr-root .cap-grid--teaser {
  /* 4 columns, matching .cap-grid above (not 3): with the teaser's fixed
     item spans (2x1, 1x1, 1x1, 2x2, 2x1, 1x1) a 3-column track count leaves
     a permanent sparse-packing hole mid-grid — the video (2x2) tile can only
     start at column 1 or 2 of a 3-col row, and neither position lets the
     row above/below it close cleanly with the remaining 1x1/2x1 tiles. 4
     columns is the same track count already proven gap-free on the full
     /capabilities/ grid (all spans there are 1/2/4, an exact divisor of 4)
     and it stays gap-free here too — verified by hand-simulating the CSS
     Grid sparse auto-placement algorithm for this exact item order. Keep
     the item order and this column count in sync if either ever changes.
  */
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 190px;
}
#nr-root .cap-tile--1x1 { grid-column: span 1; grid-row: span 1; }
#nr-root .cap-tile--2x1 { grid-column: span 2; grid-row: span 1; }
#nr-root .cap-tile--2x2 { grid-column: span 2; grid-row: span 2; }
#nr-root .cap-tile--4x1 { grid-column: span 4; grid-row: span 1; }

/* ---- Card shell -------------------------------------------------------
   Same visual family as .model-card / .card: --bg-2 panel, --line border,
   --r-lg radius, arrow revealed on hover. */
#nr-root .cap-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  /* Not space-between: with the icon out of flow on 2x1/4x1 (position:
     absolute, see below), .cap-body is the ONLY normal-flow child there —
     space-between then collapses to flex-start (nothing to distribute
     space between), leaving the text pinned to the TOP with a large empty
     gap below it before the border. 1x1/video tiles keep the icon in flow,
     so with two children space-between DOES push .cap-body to the bottom —
     same rule, two different-looking outcomes. margin-top:auto on
     .cap-body below produces the "pinned to the bottom, same 20px gap to
     the border" result uniformly regardless of how many flow siblings a
     given tile shape has. */
  justify-content: flex-start;
  gap: 12px;
  padding: 20px;
  overflow: hidden;
  color: inherit;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  scroll-margin-top: 88px;
  transition: transform .16s var(--ease), border-color .16s var(--ease), box-shadow .16s var(--ease);
}
#nr-root .cap-tile:hover,
#nr-root .cap-tile:focus-visible {
  transform: translateY(-3px);
  border-color: var(--line-2);
  box-shadow: 0 16px 36px -18px rgba(var(--ink-rgb), 0.45);
}
#nr-root .cap-tile:focus-visible {
  outline: 2px solid var(--a1);
  outline-offset: 2px;
}
#nr-root .cap-tile:hover .cap-arrow,
#nr-root .cap-tile:focus-visible .cap-arrow {
  opacity: 1;
  transform: translate(0, 0);
  color: var(--fg);
}
#nr-root[data-theme="light"] .cap-tile:hover,
#nr-root[data-theme="light"] .cap-tile:focus-visible {
  box-shadow: 0 16px 30px -18px rgba(var(--ink-rgb), 0.16);
}

/* Pins the text block to the tile's bottom edge (consistent 20px gap to the
   border, via .cap-tile's own padding) regardless of how many flow siblings
   precede it — see the justify-content comment above. */
#nr-root .cap-body { margin-top: auto; }
#nr-root .cap-body h3.t-h3 { margin: 0 0 4px; }
#nr-root .cap-body p.t-small {
  margin: 0; color: var(--fg-dim); text-wrap: pretty;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
  /* Keep the clamped text clear of .cap-arrow's 28px corner button (bottom/
     right: 18px) so a long last line never runs under it on hover. */
  padding-right: 4px;
}
#nr-root .cap-tile--1x1 .cap-body p.t-small,
#nr-root .cap-tile--video .cap-body p.t-small { max-width: calc(100% - 30px); }

#nr-root .cap-arrow {
  position: absolute; bottom: 18px; right: 18px;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; background: rgba(var(--scrim-rgb), 0.05);
  border: 1px solid var(--line); color: var(--fg-dim);
  opacity: 0; transform: translate(-2px, -2px);
  transition: opacity .2s var(--ease), transform .2s var(--ease), color .2s;
}

/* ---- Illustration: glyph (1x1) vs background motif (2x1 / 4x1) ------ */
#nr-root .cap-icon {
  display: block;
  color: var(--fg-dim);
  transition: color .2s var(--ease);
}
#nr-root .cap-tile:hover .cap-icon,
#nr-root .cap-tile:focus-visible .cap-icon { color: var(--fg); }
#nr-root .cap-icon svg { display: block; }

/* 1x1 / 2x2 (video excluded) — compact glyph, top-aligned. Sized down from an
   earlier 52px: at the 1x1 row height, icon + title + a 3-line description
   left near-zero margin before the tile's own overflow:hidden clipped the
   last line without an ellipsis (looked like abruptly cut-off text). */
#nr-root .cap-tile--1x1 .cap-icon svg { width: 44px; height: 44px; }

/* 2x1 / 4x1 — the illustration becomes a muted full-bleed background motif
   behind the text, masked out toward the text side. -webkit-mask-image is
   required alongside mask-image or Safari/iOS silently drops the mask.
   Fully transparent through 60% (matches .cap-body's max-width below one to
   one, not just "roughly faded") so no shape edge can ever land inside the
   text column and read as a misaligned block under/behind the copy — it was
   a long, gradual fade before (92%→40%) that left the motif partially
   visible well inside the text zone. Now there's a clean text-only zone,
   then the motif ramps in only past it. */
#nr-root .cap-tile--2x1,
#nr-root .cap-tile--4x1 { padding: 24px; }
#nr-root .cap-tile--2x1 .cap-icon,
#nr-root .cap-tile--4x1 .cap-icon {
  position: absolute;
  inset: 0;
  opacity: .85;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, transparent 60%, black 82%, black 100%);
          mask-image: linear-gradient(to right, transparent 0%, transparent 60%, black 82%, black 100%);
}
#nr-root[data-theme="light"] .cap-tile--2x1 .cap-icon,
#nr-root[data-theme="light"] .cap-tile--4x1 .cap-icon { opacity: .7; }
#nr-root .cap-tile--2x1 .cap-icon svg,
#nr-root .cap-tile--4x1 .cap-icon svg { width: 100%; height: 100%; }
#nr-root .cap-tile--2x1 .cap-body,
#nr-root .cap-tile--4x1 .cap-body { position: relative; z-index: 1; max-width: 60%; }

/* ---- Beacon motif — static dot, single pulse on hover/focus only ---- */
#nr-root .cap-beacon-core,
#nr-root .cap-beacon-glow { opacity: .85; }
#nr-root .cap-tile:hover .cap-beacon-core,
#nr-root .cap-tile:focus-visible .cap-beacon-core,
#nr-root .cap-tile:hover .cap-beacon-glow,
#nr-root .cap-tile:focus-visible .cap-beacon-glow {
  animation: cap-beacon-pulse .9s var(--ease) 1;
}
@keyframes cap-beacon-pulse {
  0%   { transform: scale(1);   opacity: .85; }
  45%  { transform: scale(1.6); opacity: .35; }
  100% { transform: scale(1);   opacity: .85; }
}

/* ---- Video card (video_generation, flagship 2x2) --------------------- */
#nr-root .cap-tile--video { padding: 0; }
#nr-root .cap-tile--video .cap-body,
#nr-root .cap-tile--video .cap-arrow {
  position: relative; z-index: 1;
}
#nr-root .cap-tile--video .cap-body {
  padding: 18px 20px;
  background: linear-gradient(to top, rgba(var(--ink-rgb), 0.55), transparent 70%);
  /* margin-top:auto now lives on the shared #nr-root .cap-body rule. */
}
#nr-root .cap-tile--video .cap-body h3.t-h3,
#nr-root .cap-tile--video .cap-body p.t-small { color: #fff; }
#nr-root .cap-video-frame {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: var(--r-lg);
  aspect-ratio: 1 / 1; /* CLS-safety net if ever rendered outside a fixed-height grid cell */
  background: var(--bg-3);
}
/* Blurred, scaled-up copy of the poster fills the frame behind the video —
   a cheap static-image letterbox (no second video decode) so the 9:16 clip
   can render in full via object-fit:contain instead of being cropped down
   to whatever landscape-ish slice fits a `cover` box. scale(1.15) pushes the
   blur's own soft edge outside the visible frame (overflow:hidden clips it),
   so there's no lighter halo ring at the boundary. */
#nr-root .cap-video-backdrop {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: blur(28px) brightness(.55) saturate(1.15);
  transform: scale(1.15);
}
#nr-root .cap-video {
  position: relative;
  z-index: 1;
  width: 100%; height: 100%;
  object-fit: contain; object-position: center;
  display: block;
  background: transparent;
}
/* Viewfinder motif, CSS-only (keeps the flagship card in the same
   capture/generation family as the SVG viewfinder corners, without an SVG). */
#nr-root .cap-video-frame::before,
#nr-root .cap-video-frame::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  border-color: var(--fg-mute);
  border-style: solid;
  border-width: 0;
  opacity: .5;
  pointer-events: none;
  z-index: 2;
}
#nr-root .cap-video-frame::before {
  top: 12px; left: 12px;
  border-top-width: 1.4px; border-left-width: 1.4px;
}
#nr-root .cap-video-frame::after {
  bottom: 12px; right: 12px;
  border-bottom-width: 1.4px; border-right-width: 1.4px;
}
#nr-root .cap-video-caption {
  position: absolute; top: 14px; left: 14px; z-index: 2;
  font-size: 11px; letter-spacing: 0.04em; color: rgba(255,255,255,.85);
  padding: 5px 9px; background: rgba(0,0,0,0.35);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 6px; border: 1px solid rgba(255,255,255,0.14);
}

/* ---- Reduced motion — no beacon pulse, video never plays ----------- */
@media (prefers-reduced-motion: reduce) {
  #nr-root .cap-tile:hover .cap-beacon-core,
  #nr-root .cap-tile:focus-visible .cap-beacon-core,
  #nr-root .cap-tile:hover .cap-beacon-glow,
  #nr-root .cap-tile:focus-visible .cap-beacon-glow {
    animation: none;
  }
  #nr-root .cap-tile:hover,
  #nr-root .cap-tile:focus-visible { transform: none; }
}

/* ---- Responsive: 1040px / 640px breakpoints, matching the rest of the landing ---- */
@media (max-width: 1040px) {
  #nr-root .cap-grid { grid-template-columns: repeat(2, 1fr); }
  #nr-root .cap-grid--teaser { grid-template-columns: repeat(2, 1fr); }
  #nr-root .cap-tile--2x1 { grid-column: span 2; }
  #nr-root .cap-tile--4x1 { grid-column: span 2; }
  #nr-root .cap-tile--2x2 { grid-column: span 2; grid-row: span 2; }
}
@media (max-width: 640px) {
  #nr-root .cap-grid,
  #nr-root .cap-grid--teaser { grid-template-columns: 1fr; }
  #nr-root .cap-tile--1x1,
  #nr-root .cap-tile--2x1,
  #nr-root .cap-tile--4x1 { grid-column: span 1; grid-row: span 1; }
  #nr-root .cap-tile--2x2 { grid-column: span 1; grid-row: span 2; }
  #nr-root .cap-tile--2x1 .cap-body,
  #nr-root .cap-tile--4x1 .cap-body { max-width: 78%; }
}

/* =========================================================
   Page chrome for /capabilities/ (chat/templates/seo/capabilities_detail.html):
   hero, cap-grid section wrapper, interlude, how-it-works. The card/grid rules
   above this block are shared with the homepage teaser; everything below is
   specific to the full standalone page.
   ========================================================= */
/* Wider content column than the site-standard 1240px .container (hero and
   the 4-column card grid, NOT the prose sections below — interlude/how-it-
   works keep .container.narrow's 960px, a reading-width column is correct
   there). A 15-card bento grid reads as needlessly boxed-in at 1240px on a
   wide monitor; 1440 gives the grid real room without the site-wide
   .container (used everywhere else on the landing) changing at all. */
#nr-root .cap-hero > .container,
#nr-root .cap-grid-section > .container { max-width: 1440px; }

#nr-root .cap-hero { padding-top: 104px; padding-bottom: 48px; }
#nr-root .cap-hero .crumbs { margin-bottom: 24px; }
#nr-root .cap-hero h1.t-h1 { margin: 20px 0 16px; text-wrap: balance; }
#nr-root .cap-hero-stats {
  display: flex; gap: 40px; margin-top: 40px; flex-wrap: wrap;
}
#nr-root .cap-hero-stats > div { display: flex; flex-direction: column; gap: 4px; }
#nr-root .cap-hero-stats .t-h3 { font-size: 30px; }
#nr-root .cap-hero-stats .t-small { text-transform: uppercase; letter-spacing: 0.04em; }

#nr-root .cap-grid-section { padding-top: 0; padding-bottom: 56px; }

#nr-root .cap-interlude { padding: 56px 0; text-align: center; }
#nr-root .cap-interlude .t-h2 { margin: 0 0 16px; }
#nr-root .cap-interlude .t-lead { margin: 0 auto; }

#nr-root .cap-how { padding: 56px 0 120px; border-top: 1px solid var(--line); }
#nr-root .cap-how .t-h2 { text-align: center; margin: 0 0 48px; }
#nr-root .cap-how-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
#nr-root .cap-how-step { padding: 28px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-lg); }
#nr-root .cap-how-num { display: block; font-size: 32px; margin-bottom: 12px; }
#nr-root .cap-how-step h3.t-h3 { margin: 0 0 8px; }
#nr-root .cap-how-step p.t-small { margin: 0; color: var(--fg-dim); }

@media (max-width: 1040px) {
  #nr-root .cap-hero { padding-top: 88px; }
}
@media (max-width: 640px) {
  #nr-root .cap-hero { padding-top: 24px; }
  #nr-root .cap-hero-stats { gap: 24px; }
  #nr-root .cap-how-row { grid-template-columns: 1fr; }
}
