/* ==========================================================================
   ZENNTAC — Layout
   --------------------------------------------------------------------------
   Containers, section rhythm, surfaces and a few intrinsic layout
   primitives. Mobile first: every primitive works at the smallest width
   without media queries; they adapt to available space rather than to
   device names. Logical properties only, so layouts mirror in RTL.
   Depends on tokens.css.
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Page frame
   <body class="site"> … <main class="site-main" id="main" tabindex="-1">
   Keeps the footer at the bottom of short pages. WordPress: body_class()
   in header.php, <main> opened in each template.
   -------------------------------------------------------------------------- */
.site {
  display: flex;
  flex-direction: column;
  min-block-size: 100vh;
  min-block-size: 100dvh;
}

.site-main {
  flex: 1 0 auto;
}

/* --------------------------------------------------------------------------
   1. Container
   Centred, max-width content with a guaranteed gutter on both inline
   edges. min() keeps it from ever exceeding the viewport (no overflow).
   <div class="container">…</div>
   -------------------------------------------------------------------------- */
.container {
  --container-max: var(--container-default);
  inline-size: min(100% - 2 * var(--container-gutter), var(--container-max));
  margin-inline: auto;
}

.container--narrow {
  --container-max: var(--container-narrow);
}

.container--wide {
  --container-max: var(--container-wide);
}

/* --------------------------------------------------------------------------
   2. Section rhythm
   Vertical spacing between page sections. WordPress: maps to the wrapper
   of each template part.
   -------------------------------------------------------------------------- */
.section {
  padding-block: var(--space-section);
}

.section--compact {
  padding-block: var(--space-section-sm);
}

/* --------------------------------------------------------------------------
   3. Surfaces
   A surface sets its background and, where needed, remaps semantic colour
   tokens so everything inside (text, borders, links, focus) adapts without
   component changes. This is also the mechanism a future dark theme uses.
   -------------------------------------------------------------------------- */
.surface {
  background-color: var(--color-surface);
  color: var(--color-text-primary);
}

.surface-muted {
  background-color: var(--color-surface-muted);
  color: var(--color-text-primary);
}

/* Dark editorial band (footer, closing CTA). Ratios on --color-background:
   primary 18.9:1, secondary 13.6:1, muted 7.2:1, accent 8.1:1,
   border-strong 5.0:1, focus 8.1:1. */
.surface-inverse {
  --color-background: var(--zt-ink-950);
  --color-surface: var(--zt-ink-900);
  --color-surface-muted: var(--zt-ink-800);

  --color-text-primary: var(--zt-white);
  --color-text-secondary: var(--zt-ink-200);
  --color-text-muted: var(--zt-ink-300);

  --color-border: var(--zt-ink-800);
  --color-border-strong: var(--zt-ink-400);

  --color-accent: var(--zt-accent-300);
  --color-accent-hover: var(--zt-accent-200);
  --color-accent-soft: var(--zt-accent-950);
  --color-on-accent: var(--zt-ink-950);

  --color-focus: var(--zt-accent-300);
  --color-link: var(--color-accent);
  --color-link-hover: var(--color-accent-hover);
  --color-selection: var(--zt-accent-950);

  /* Re-declared so they resolve against the remapped colours above */
  --focus-ring: var(--focus-ring-width) solid var(--color-focus);
  --card-border: var(--border-width) solid var(--color-border);
  --input-border: var(--border-width) solid var(--color-border-strong);

  background-color: var(--color-background);
  color: var(--color-text-primary);
}

/* --------------------------------------------------------------------------
   4. Stack — vertical flow with consistent spacing between children.
   <div class="stack" style="--stack-space: var(--space-6)">…</div>
   -------------------------------------------------------------------------- */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--stack-space, var(--space-4));
}

/* --------------------------------------------------------------------------
   5. Cluster — inline group that wraps (buttons, tags, nav links).
   Follows the writing direction automatically.
   -------------------------------------------------------------------------- */
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cluster-space, var(--space-4));
}

/* --------------------------------------------------------------------------
   6. Grid — responsive columns without media queries. Columns never get
   narrower than --grid-min, and never overflow on small screens.
   <ul class="grid" role="list" style="--grid-min: 18rem">…</ul>
   -------------------------------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fit,
    minmax(min(var(--grid-min, 16rem), 100%), 1fr)
  );
  gap: var(--grid-space, var(--space-6));
}

/* --------------------------------------------------------------------------
   7. Split — a heading column beside a content column (lg and up).
   Stacks on smaller screens. Columns follow the writing direction.
   <div class="split"><div>heading</div><div>content</div></div>
   -------------------------------------------------------------------------- */
.split {
  display: grid;
  gap: var(--split-space, var(--space-7));
}

@media (min-width: 64em) {
  .split {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: var(--split-space, var(--space-9));
  }

  /* --sticky: the heading column stays in view beside a long content
     column. Clears the sticky site header. */
  .split--sticky > :first-child {
    position: sticky;
    inset-block-start: calc(var(--header-height) + var(--space-6));
    align-self: start;
  }
}
