@import url("tokens.css");
@import url("type-unify.css");
@import url("reveal.css");
@import url("../fonts.css");

/* ═══════════════════════════════════════════════════════════════════
   Jarvis Playground v3 — Layout System
   ─────────────────────────────────────────────────────────────────
   Responsive grid, flexbox patterns, container-query patterns, and
   utility classes. Pure layout — no colors, no component chrome.
   Everything references tokens from tokens.css.

   Breakpoint scale (mobile-first, min-width):
     base  < 640px   (phones, single column)
     sm    ≥ 640px   (large phones / small tablets)
     md    ≥ 1024px  (tablets landscape / small laptops)
     lg    ≥ 1280px  (laptops / desktops)
     xl    ≥ 1536px  (large desktops)

   Grid API:
     .v3-container            page-width wrapper (gutter + max width)
     .v3-grid                 12-column grid, 16px gap (→ 24px at md)
     .v3-col-<n>              span n of 12 columns (n = 1..12)
     .v3-col-<bp>-<n>         span at a breakpoint (sm/md/lg/xl)
     .v3-grid-auto            auto-fit minmax card grid (no col math)
     .v3-stack                vertical flex stack with even gaps

   Usage examples:
     <div class="v3-container">
       <div class="v3-grid">
         <section class="v3-col-12 v3-md-8">…main…</section>
         <aside   class="v3-col-12 v3-md-4">…side…</aside>
       </div>
     </div>

     <!-- card wall that reflows by container, not viewport -->
     <div class="v3-cq-arena">
       <div class="v3-grid-auto">
         <article class="v3-card">…</article> ×N
       </div>
     </div>
   ═══════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────
   1. PAGE CONTAINER
   ───────────────────────────────────────────────────────────────── */
.v3-container {
  width: 100%;
  max-width: var(--v3-content-max);
  margin-inline: auto;
  padding-inline: var(--v3-gutter);
}

/* wider container for full-bleed app pages (gallery, video walls) */
.v3-container--wide {
  max-width: var(--v3-content-wide);
}

/* full-bleed horizontal band with contained inner content */
.v3-band {
  width: 100%;
  padding-block: var(--v3-space-12);
}
.v3-band > .v3-container {
  padding-inline: var(--v3-gutter);
}

/* ─────────────────────────────────────────────────────────────────
   2. 12-COLUMN GRID
   ─────────────────────────────────────────────────────────────────
   Base (mobile): single column. Columns span 12 until a breakpoint
   override says otherwise. Gap steps up at md. */
.v3-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--v3-space-4);
}

/* every grid child defaults to full width on mobile */
.v3-grid > * {
  grid-column: 1 / -1;
}

/* explicit spans — mobile (base) */
.v3-col-1  { grid-column: span 1; }
.v3-col-2  { grid-column: span 2; }
.v3-col-3  { grid-column: span 3; }
.v3-col-4  { grid-column: span 4; }
.v3-col-5  { grid-column: span 5; }
.v3-col-6  { grid-column: span 6; }
.v3-col-7  { grid-column: span 7; }
.v3-col-8  { grid-column: span 8; }
.v3-col-9  { grid-column: span 9; }
.v3-col-10 { grid-column: span 10; }
.v3-col-11 { grid-column: span 11; }
.v3-col-12 { grid-column: span 12; }

/* sm ≥ 640px — room for 2-up layouts */
@media (min-width: 640px) {
  .v3-sm-1  { grid-column: span 1; }
  .v3-sm-2  { grid-column: span 2; }
  .v3-sm-3  { grid-column: span 3; }
  .v3-sm-4  { grid-column: span 4; }
  .v3-sm-5  { grid-column: span 5; }
  .v3-sm-6  { grid-column: span 6; }
  .v3-sm-7  { grid-column: span 7; }
  .v3-sm-8  { grid-column: span 8; }
  .v3-sm-9  { grid-column: span 9; }
  .v3-sm-10 { grid-column: span 10; }
  .v3-sm-11 { grid-column: span 11; }
  .v3-sm-12 { grid-column: span 12; }
}

/* md ≥ 1024px — the standard desktop 3-up / 8+4 split */
@media (min-width: 1024px) {
  .v3-grid { gap: var(--v3-space-6); }
  .v3-md-1  { grid-column: span 1; }
  .v3-md-2  { grid-column: span 2; }
  .v3-md-3  { grid-column: span 3; }
  .v3-md-4  { grid-column: span 4; }
  .v3-md-5  { grid-column: span 5; }
  .v3-md-6  { grid-column: span 6; }
  .v3-md-7  { grid-column: span 7; }
  .v3-md-8  { grid-column: span 8; }
  .v3-md-9  { grid-column: span 9; }
  .v3-md-10 { grid-column: span 10; }
  .v3-md-11 { grid-column: span 11; }
  .v3-md-12 { grid-column: span 12; }
}

/* lg ≥ 1280px — fine-grained desktop spans */
@media (min-width: 1280px) {
  .v3-lg-1  { grid-column: span 1; }
  .v3-lg-2  { grid-column: span 2; }
  .v3-lg-3  { grid-column: span 3; }
  .v3-lg-4  { grid-column: span 4; }
  .v3-lg-5  { grid-column: span 5; }
  .v3-lg-6  { grid-column: span 6; }
  .v3-lg-7  { grid-column: span 7; }
  .v3-lg-8  { grid-column: span 8; }
  .v3-lg-9  { grid-column: span 9; }
  .v3-lg-10 { grid-column: span 10; }
  .v3-lg-11 { grid-column: span 11; }
  .v3-lg-12 { grid-column: span 12; }
}

/* xl ≥ 1536px — large-desktop spans */
@media (min-width: 1536px) {
  .v3-xl-1  { grid-column: span 1; }
  .v3-xl-2  { grid-column: span 2; }
  .v3-xl-3  { grid-column: span 3; }
  .v3-xl-4  { grid-column: span 4; }
  .v3-xl-5  { grid-column: span 5; }
  .v3-xl-6  { grid-column: span 6; }
  .v3-xl-7  { grid-column: span 7; }
  .v3-xl-8  { grid-column: span 8; }
  .v3-xl-9  { grid-column: span 9; }
  .v3-xl-10 { grid-column: span 10; }
  .v3-xl-11 { grid-column: span 11; }
  .v3-xl-12 { grid-column: span 12; }
}

/* ─────────────────────────────────────────────────────────────────
   3. AUTO-FIT CARD GRID (no column math)
   ─────────────────────────────────────────────────────────────────
   Cards size themselves to the available space. Mobile: 1-up.
   The minmax track minimum grows with the viewport so the grid
   settles into 2 → 3 → 4 columns without media queries. */
.v3-grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: var(--v3-space-4);
}
@media (min-width: 640px) {
  .v3-grid-auto { gap: var(--v3-space-5); }
}
@media (min-width: 1024px) {
  .v3-grid-auto { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
}

/* denser variant for icon-heavy walls (app grid, gallery) */
.v3-grid-auto--dense {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
}

/* ─────────────────────────────────────────────────────────────────
   4. FLEXBOX PATTERNS
   ───────────────────────────────────────────────────────────────── */

/* .v3-stack — vertical stack, even gap, children stretch.
   Usage: <div class="v3-stack v3-gap-6">…</div> */
.v3-stack {
  display: flex;
  flex-direction: column;
  gap: var(--v3-space-4);
}

/* .v3-stack-cards — stacked cards that fan out at md:
   vertical stack on mobile → horizontal row of equal cards.
   Usage: <div class="v3-stack-cards">
            <article>…</article> ×3
          </div> */
.v3-stack-cards {
  display: flex;
  flex-direction: column;
  gap: var(--v3-space-4);
}
@media (min-width: 640px) {
  .v3-stack-cards { gap: var(--v3-space-5); }
}
@media (min-width: 1024px) {
  .v3-stack-cards {
    flex-direction: row;
    align-items: stretch;
    gap: var(--v3-space-6);
  }
  .v3-stack-cards > * { flex: 1 1 0; min-width: 0; }
}

/* .v3-masonry — CSS columns masonry (order flows down each column;
   fine for image walls where strict reading order isn't critical).
   Usage: <div class="v3-masonry">…tiles…</div>
   Tiles must not be split across columns:
   .v3-masonry > * { break-inside: avoid; } */
.v3-masonry {
  column-count: 1;
  column-gap: var(--v3-space-4);
}
.v3-masonry > * {
  break-inside: avoid;
  margin-bottom: var(--v3-space-4);
}
@media (min-width: 640px) {
  .v3-masonry { column-count: 2; column-gap: var(--v3-space-5); }
  .v3-masonry > * { margin-bottom: var(--v3-space-5); }
}
@media (min-width: 1024px) {
  .v3-masonry { column-count: 3; }
}
@media (min-width: 1536px) {
  .v3-masonry { column-count: 4; }
}

/* .v3-hero — centered hero block.
   Usage: <header class="v3-hero">
            <p class="v3-hero-kicker">…</p>
            <h1 class="v3-hero-title">…</h1>
            <p class="v3-hero-sub">…</p>
            <div class="v3-hero-actions">…</div>
          </header> */
.v3-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--v3-space-5);
  padding-block: var(--v3-space-16) var(--v3-space-12);
}
.v3-hero-kicker {
  margin: 0;
  font-family: var(--v3-font-mono);
  font-size: var(--v3-text-sm);
  letter-spacing: var(--v3-tracking-wider);
  text-transform: uppercase;
  color: var(--v3-accent);
}
.v3-hero-title {
  margin: 0;
  font-family: var(--v3-font-display);
  font-size: var(--v3-text-5xl);
  font-weight: var(--v3-weight-bold);
  line-height: var(--v3-leading-tight);
  letter-spacing: -0.01em;
  max-width: 14ch;
}
.v3-hero-sub {
  margin: 0;
  font-size: var(--v3-text-lg);
  line-height: var(--v3-leading-base);
  color: var(--v3-text-secondary);
  max-width: 52ch;
}
.v3-hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--v3-space-3);
  margin-top: var(--v3-space-2);
}
@media (min-width: 1024px) {
  .v3-hero { padding-block: var(--v3-space-24) var(--v3-space-16); }
}

/* .v3-split — 50/50 media+text split; stacks on mobile.
   Usage: <div class="v3-split">
            <div class="v3-split-media">…</div>
            <div class="v3-split-body">…</div>
          </div> */
.v3-split {
  display: flex;
  flex-direction: column;
  gap: var(--v3-space-6);
}
.v3-split-media {
  aspect-ratio: 16 / 9;
  width: 100%;
  border-radius: var(--v3-radius-md);
  overflow: hidden;
}
@media (min-width: 1024px) {
  .v3-split {
    flex-direction: row;
    align-items: center;
    gap: var(--v3-space-10);
  }
  .v3-split-media { flex: 1 1 55%; aspect-ratio: auto; }
  .v3-split-body  { flex: 1 1 45%; }
}
/* reverse: media on the right */
.v3-split--reverse { flex-direction: column-reverse; }
@media (min-width: 1024px) {
  .v3-split--reverse { flex-direction: row-reverse; }
}

/* .v3-row — inline flex row, wraps, baseline-aligned.
   Usage: <div class="v3-row v3-gap-3">…chips…</div> */
.v3-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--v3-space-3);
}

/* .v3-between — space-between row (nav footers, card headers). */
.v3-between {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--v3-space-3);
}
/* .v3-between--stack — mobile-first: stacked on phones, becomes a
   space-between row at sm and up. */
.v3-between--stack {
  flex-direction: column;
  align-items: flex-start;
}
@media (min-width: 640px) {
  .v3-between--stack {
    flex-direction: row;
    align-items: center;
  }
}

/* ─────────────────────────────────────────────────────────────────
   5. CONTAINER QUERIES — component-level responsiveness
   ─────────────────────────────────────────────────────────────────
   The viewport grid above answers "how wide is the screen?";
   container queries answer "how wide is THIS component's parent?"
   — the right tool for embeddable widgets (a stat card rendered in
   a 320px sidebar vs. a 900px hero band).

   Pattern:
     1. Mark the sizing parent with `container-type: inline-size`
        (class .v3-cq-arena below).
     2. Style the component with @container rules keyed to cqw
        units or named container breakpoints.

   Usage:
     <div class="v3-cq-arena">          <!-- query container -->
       <div class="v3-stat-card">…</div>
     </div> */
.v3-cq-arena {
  container-type: inline-size;
  container-name: v3-arena;
}

/* named container breakpoints:
   v3-cq-sm  280px   v3-cq-md  480px   v3-cq-lg  720px */
@container v3-arena (min-width: 280px) {
  .v3-cq-sm { --v3-cq-step: 1; }
}
@container v3-arena (min-width: 480px) {
  .v3-cq-md { --v3-cq-step: 2; }
}
@container v3-arena (min-width: 720px) {
  .v3-cq-lg { --v3-cq-step: 3; }
}

/* Worked example: a component that lays out differently per
   container width. Pair with components/cards.css — the card reads
   --v3-cq-step (1/2/3) to switch its internal arrangement. */
.v3-cq-demo {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--v3-space-3);
}
@container v3-arena (min-width: 480px) {
  .v3-cq-demo { grid-template-columns: auto 1fr; }
}
@container v3-arena (min-width: 720px) {
  .v3-cq-demo { grid-template-columns: auto 1fr auto; }
}

/* fluid type inside a container (cqw units track the container,
   not the viewport): */
.v3-cq-fluid-title {
  font-size: clamp(1.25rem, 6cqw, 2.5rem);
}

/* ─────────────────────────────────────────────────────────────────
   6. UTILITY CLASSES
   ─────────────────────────────────────────────────────────────────
   Display helpers, spacing overrides, alignment. Spacing utilities
   are generated per breakpoint where layout differs; the base set
   applies at all widths. Keep this section lean — if a utility is
   used once, inline it instead. */

/* display */
.v3-d-none  { display: none; }
.v3-d-block { display: block; }
.v3-d-inline{ display: inline-block; }
.v3-d-flex  { display: flex; }
.v3-d-grid  { display: grid; }

@media (min-width: 640px) {
  .v3-sm-d-none  { display: none; }
  .v3-sm-d-block { display: block; }
  .v3-sm-d-flex  { display: flex; }
  .v3-sm-d-grid  { display: grid; }
}
@media (min-width: 1024px) {
  .v3-md-d-none  { display: none; }
  .v3-md-d-block { display: block; }
  .v3-md-d-flex  { display: flex; }
  .v3-md-d-grid  { display: grid; }
}
@media (min-width: 1280px) {
  .v3-lg-d-none  { display: none; }
  .v3-lg-d-block { display: block; }
  .v3-lg-d-flex  { display: flex; }
  .v3-lg-d-grid  { display: grid; }
}

/* flex alignment */
.v3-flex-center { display: flex; align-items: center; justify-content: center; }
.v3-flex-between { display: flex; align-items: center; justify-content: space-between; }
.v3-flex-col { flex-direction: column; }
.v3-items-center { align-items: center; }
.v3-justify-center { justify-content: center; }
.v3-flex-1 { flex: 1 1 0; min-width: 0; }
.v3-wrap { flex-wrap: wrap; }

/* gap overrides (any flex/grid parent) */
.v3-gap-1 { gap: var(--v3-space-1); }
.v3-gap-2 { gap: var(--v3-space-2); }
.v3-gap-3 { gap: var(--v3-space-3); }
.v3-gap-4 { gap: var(--v3-space-4); }
.v3-gap-5 { gap: var(--v3-space-5); }
.v3-gap-6 { gap: var(--v3-space-6); }
.v3-gap-8 { gap: var(--v3-space-8); }

/* margin / padding overrides — base (all widths) */
.v3-m-0  { margin: 0; }
.v3-mt-4 { margin-top: var(--v3-space-4); }
.v3-mt-6 { margin-top: var(--v3-space-6); }
.v3-mt-8 { margin-top: var(--v3-space-8); }
.v3-mb-4 { margin-bottom: var(--v3-space-4); }
.v3-mb-6 { margin-bottom: var(--v3-space-6); }
.v3-mb-8 { margin-bottom: var(--v3-space-8); }
.v3-ml-auto { margin-left: auto; }
.v3-mr-auto { margin-right: auto; }
.v3-mx-auto { margin-inline: auto; }

.v3-p-4  { padding: var(--v3-space-4); }
.v3-p-6  { padding: var(--v3-space-6); }
.v3-p-8  { padding: var(--v3-space-8); }
.v3-px-4 { padding-inline: var(--v3-space-4); }
.v3-px-6 { padding-inline: var(--v3-space-6); }
.v3-py-4 { padding-block: var(--v3-space-4); }
.v3-py-6 { padding-block: var(--v3-space-6); }
.v3-py-8 { padding-block: var(--v3-space-8); }

/* breakpoint-scoped spacing overrides (mobile-first) */
@media (min-width: 640px) {
  .v3-sm-mt-6 { margin-top: var(--v3-space-6); }
  .v3-sm-mt-8 { margin-top: var(--v3-space-8); }
  .v3-sm-mb-8 { margin-bottom: var(--v3-space-8); }
  .v3-sm-p-6  { padding: var(--v3-space-6); }
  .v3-sm-py-8 { padding-block: var(--v3-space-8); }
}
@media (min-width: 1024px) {
  .v3-md-mt-8  { margin-top: var(--v3-space-8); }
  .v3-md-mt-12 { margin-top: var(--v3-space-12); }
  .v3-md-mb-12 { margin-bottom: var(--v3-space-12); }
  .v3-md-p-8   { padding: var(--v3-space-8); }
  .v3-md-py-12 { padding-block: var(--v3-space-12); }
}
@media (min-width: 1280px) {
  .v3-lg-mt-12 { margin-top: var(--v3-space-12); }
  .v3-lg-p-8   { padding: var(--v3-space-8); }
  .v3-lg-py-16 { padding-block: var(--v3-space-16); }
}

/* text helpers */
.v3-text-center { text-align: center; }
.v3-text-left { text-align: left; }
.v3-text-right { text-align: right; }
.v3-text-secondary { color: var(--v3-text-secondary); }
.v3-text-muted { color: var(--v3-text-muted); }
.v3-text-accent { color: var(--v3-accent); }
.v3-text-mono { font-family: var(--v3-font-mono); }
.v3-text-display { font-family: var(--v3-font-display); }
.v3-text-nowrap { white-space: nowrap; }
.v3-text-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.v3-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.v3-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* layout helpers */
.v3-w-full { width: 100%; }
.v3-h-full { height: 100%; }
.v3-relative { position: relative; }
.v3-overflow-hidden { overflow: hidden; }
.v3-rounded { border-radius: var(--v3-radius); }
.v3-rounded-lg { border-radius: var(--v3-radius-lg); }
.v3-rounded-full { border-radius: var(--v3-radius-full); }
.v3-border { border: var(--v3-border-w) solid var(--v3-border); }
.v3-aspect-video { aspect-ratio: 16 / 9; }
.v3-aspect-square { aspect-ratio: 1 / 1; }

/* visually hidden (screen-reader only) */
.v3-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─────────────────────────────────────────────────────────────────
   7. REDUCED MOTION
   ─────────────────────────────────────────────────────────────────
   Layout is static, but any layout-driven transition (column
   reflow, grid gap changes) is covered by the global kill switch in
   tokens.css. Nothing here animates on its own. */
@media (prefers-reduced-motion: reduce) {
  .v3-hero, .v3-stack-cards, .v3-split {
    transition: none;
  }
}

/* ─────────────────────────────────────────────────────────────────
   8. ANCHOR SCROLL + BACK-TO-TOP (Phase 3/4)
   ───────────────────────────────────────────────────────────────── */
/* Smooth anchor/programmatic scroll. Gated on no-preference so the
   reduced-motion kill switch in tokens.css (scroll-behavior: auto)
   always wins for users who opt out. */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* In-page anchor targets clear the fixed header */
[id] { scroll-margin-top: 88px; }

/* Back-to-top button (injected by /js/back-to-top.js) */
.bt-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: var(--v3-z-fixed);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--v3-border);
  border-radius: var(--v3-radius-full);
  background: var(--v3-bg-surface);
  color: var(--v3-text-secondary);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition:
    opacity var(--v3-dur-2) var(--v3-ease-out),
    transform var(--v3-dur-2) var(--v3-ease-out),
    visibility 0s linear var(--v3-dur-2),
    color var(--v3-dur-2) var(--v3-ease-out),
    border-color var(--v3-dur-2) var(--v3-ease-out);
}
.bt-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity var(--v3-dur-2) var(--v3-ease-out),
    transform var(--v3-dur-2) var(--v3-ease-out),
    color var(--v3-dur-2) var(--v3-ease-out),
    border-color var(--v3-dur-2) var(--v3-ease-out);
}
.bt-top:hover {
  color: var(--v3-accent);
  border-color: var(--v3-accent);
}
.bt-top:focus-visible {
  outline: 2px solid var(--v3-accent);
  outline-offset: 2px;
}
.bt-top svg {
  width: 18px;
  height: 18px;
  display: block;
}
