/* CarLAB ui-v2 — shared public header (block 1 of the block-by-block rebuild).
   Namespace: .cl2-header and its descendants only.

   Two legacy hooks are kept on purpose — NOT for styling, only so the
   existing, untouched pixel-stream script keeps working without edits:
     - the outer element also carries .global-header, the exact selector
       assets/carlab-header-stream.js queries for and injects a
       <canvas class="header-matrix"> into.
     - that canvas's class name (header-matrix) is hardcoded in that script.
   Every visual property either hook could imply from the legacy stylesheet
   is re-declared below under .cl2-header, so nothing legacy is inherited
   visually — the hooks are behavioral only. */

.cl2-header {
  position: relative;
  z-index: 100;
  display: block;
  background: var(--cl2-white);
  min-height: var(--cl2-header-h);
  isolation: isolate;   /* stacking context: matrix canvas (0) below content (2) */
  padding: 0;
}

/* Pixel-stream canvas — injected by assets/carlab-header-stream.js as the
   header's first child. Sized explicitly (a bare canvas is a "replaced
   element" and renders at an intrinsic ~300x150px without this). */
.cl2-header > canvas.header-matrix {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  display: block;
  width: 100%;
  height: 100%;
}

.cl2-header-inner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--cl2-space-lg);
  max-width: var(--cl2-container-max);
  height: var(--cl2-header-h);
  margin: 0 auto;
  padding: 0 var(--cl2-space-2xl);
}

/* ── Wordmark ──────────────────────────────────────────────────────────
   Always reads "CarLAB" left-to-right, even inside the page's RTL flow —
   direction:ltr + unicode-bidi:isolate keeps the Latin run and its badge
   from being reordered by the surrounding bidi context. */
.cl2-header-logo {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  direction: ltr;
  unicode-bidi: isolate;
  font-family: var(--cl2-font-logo);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.4px;
  line-height: 1;
  color: var(--cl2-text);
  text-shadow: 0 1px 6px rgba(255, 255, 255, .95), 0 0 2px rgba(255, 255, 255, .9);
}

.cl2-header-logo-lab {
  font-family: var(--cl2-font-logo-accent);
  font-size: 28px;
  color: var(--cl2-accent);
}

/* ── Search — static, plain: no typewriter, no shortcut badge ── */
.cl2-header-search {
  flex: 0 1 300px;
  min-width: 0;
  position: relative;   /* anchors the results dropdown */
  display: flex;
  align-items: center;
  gap: var(--cl2-space-sm);
  height: 38px;
  padding: 0 var(--cl2-space-md);
  background: var(--cl2-white);
  border: 1px solid var(--cl2-border);
  border-radius: var(--cl2-radius-md);
  box-shadow: var(--cl2-shadow-sm);
  cursor: text;
  transition: border-color var(--cl2-t-fast) var(--cl2-ease), box-shadow var(--cl2-t-fast) var(--cl2-ease);
}

.cl2-header-search:hover {
  border-color: var(--cl2-border-dark);
}

.cl2-header-search:focus-within {
  border-color: var(--cl2-accent);
  box-shadow: var(--cl2-shadow-focus-ring);
}

.cl2-header-search-icon {
  flex: 0 0 auto;
  color: var(--cl2-text-dim);
  transition: color var(--cl2-t-fast) var(--cl2-ease);
}

.cl2-header-search:focus-within .cl2-header-search-icon {
  color: var(--cl2-accent);
}

.cl2-header-search-input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  direction: rtl;
  font-family: var(--cl2-font-sans);
  font-size: var(--cl2-fs-sm);
  color: var(--cl2-text);
}

.cl2-header-search-input::placeholder {
  color: var(--cl2-text-dim);
}

/* Autocomplete dropdown — the class names below (header-search-results,
   header-search-item, etc) come from assets/carlab-header-search.js, which
   hardcodes them when it builds the dropdown. Currently only wired to the
   global header's search box (assets/ui-v2/header.js); scoped here under
   .cl2-header-search so every value is still token-driven. */
/* One flat list (no separate maker/model columns or headings) -- matches the
   box's own width; a maker match, when present, is rendered first followed by
   its models (see renderResults() in carlab-header-search.js), so a single
   narrow column stays readable without needing extra width for side-by-side
   columns. Anchored to the box's end (right:0, i.e. RTL reading-start). */
.cl2-header-search .header-search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  background: var(--cl2-white);
  border: 1px solid var(--cl2-border);
  border-radius: var(--cl2-radius-md);
  box-shadow: var(--cl2-shadow-md);
  z-index: 300;
  overflow: hidden;
  max-height: min(62vh, 420px);
  overflow-y: auto;
}

.cl2-header-search .header-search-item {
  width: 100%;
  border: none;
  background: transparent;
  display: block;
  padding: 7px 11px;
  cursor: pointer;
  text-align: right;
  font-family: var(--cl2-font-sans);
}

.cl2-header-search .header-search-item + .header-search-item {
  border-top: 1px solid var(--cl2-surface-2);
}

.cl2-header-search .header-search-item:hover,
.cl2-header-search .header-search-item.active {
  background: var(--cl2-accent-dim);
}

.cl2-header-search .header-search-item strong {
  display: block;
  font-size: var(--cl2-fs-sm);
  font-weight: 600;
  color: var(--cl2-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cl2-header-search .header-search-empty {
  font-family: var(--cl2-font-mono);
  font-size: var(--cl2-fs-2xs);
  color: var(--cl2-text-dim);
  padding: 10px 12px;
  text-align: center;
}

/* ── Navigation — plain editorial links, not boxed "SaaS" pills ── */
.cl2-header-nav {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: var(--cl2-space-xl);
  height: 100%;
}

.cl2-header-nav a {
  position: relative;
  display: flex;
  align-items: center;
  padding: var(--cl2-space-xs) var(--cl2-space-2xs);
  font-size: var(--cl2-fs-md);
  font-weight: 600;
  color: var(--cl2-text-muted);
  border-bottom: 2px solid transparent;
  transition: color var(--cl2-t-fast) var(--cl2-ease), border-color var(--cl2-t-fast) var(--cl2-ease);
}

.cl2-header-nav a:hover {
  color: var(--cl2-text);
}

.cl2-header-nav a.is-active {
  color: var(--cl2-accent);
  border-bottom-color: var(--cl2-accent);
}

/* ── Mobile nav toggle (hidden ≥769px; see responsive.css) ── */
.cl2-header-nav-toggle {
  display: none;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-direction: column;
  border-radius: var(--cl2-radius-sm);
}

.cl2-header-nav-toggle:hover {
  background: var(--cl2-surface);
}

.cl2-header-nav-toggle-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--cl2-text);
  border-radius: var(--cl2-radius-pill);
  transition: transform var(--cl2-t-medium) var(--cl2-ease), opacity var(--cl2-t-fast) var(--cl2-ease);
}

.cl2-header-nav-toggle[aria-expanded="true"] .cl2-header-nav-toggle-bar:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.cl2-header-nav-toggle[aria-expanded="true"] .cl2-header-nav-toggle-bar:nth-child(2) {
  opacity: 0;
}
.cl2-header-nav-toggle[aria-expanded="true"] .cl2-header-nav-toggle-bar:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* ── Actions slot (currently always empty on index/maker/model) ── */
.cl2-header-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--cl2-space-sm);
}

@media (prefers-reduced-motion: reduce) {
  .cl2-header-nav-toggle-bar {
    transition: none;
  }
}

/* =========================================================================
   Shared public footer (block 2 of the block-by-block rebuild).
   Namespace: .cl2-footer and its descendants.

   One legacy hook kept on purpose — NOT for styling, only so the existing,
   untouched shared pixel renderer (assets/carlab-pixel-cards.js) still finds
   it: the canvas's class name (pixel-matrix) and its data-pixel-* attributes
   are the script's exact contract (Pattern 2 in that file's own doc comment —
   an explicit canvas, no wrapper class required). Every visual property is
   declared under .cl2-footer below; nothing legacy is inherited visually.
   ========================================================================= */

.cl2-footer {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: var(--cl2-white);
  margin-top: var(--cl2-space-4xl);
}

.cl2-footer > canvas.pixel-matrix {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  display: block;
  width: 100%;
  height: 100%;
}

.cl2-footer-inner {
  position: relative;
  z-index: 1;
  max-width: var(--cl2-container-max);
  margin: 0 auto;
  padding: var(--cl2-space-3xl) var(--cl2-space-2xl) var(--cl2-space-2xl);
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr));
  gap: var(--cl2-space-2xl) var(--cl2-space-3xl);
  align-items: start;
}

/* ── Brand — same wordmark treatment as the header (LTR-isolated) ── */
.cl2-footer-brand {
  direction: rtl;
  max-width: 320px;
}

.cl2-footer-logo {
  display: inline-flex;
  align-items: center;
  direction: ltr;
  unicode-bidi: isolate;
  font-family: var(--cl2-font-logo);
  font-size: var(--cl2-fs-logo);
  font-weight: 700;
  letter-spacing: -.4px;
  color: var(--cl2-text);
  margin-bottom: var(--cl2-space-md);
}

.cl2-footer-logo-lab {
  font-family: var(--cl2-font-logo-accent);
  font-size: var(--cl2-fs-logo-accent);
  color: var(--cl2-accent);
}

.cl2-footer-desc {
  font-size: var(--cl2-fs-sm);
  color: var(--cl2-text-muted);
  line-height: 1.7;
  margin: 0 0 var(--cl2-space-md);
  max-width: 300px;
}

.cl2-footer-copy {
  font-size: var(--cl2-fs-xs);
  color: var(--cl2-text-dim);
  font-family: var(--cl2-font-mono);
  margin: 0;
}

/* ── Nav columns ── */
.cl2-footer-col {
  display: flex;
  flex-direction: column;
  gap: var(--cl2-space-sm);
  direction: rtl;
}

.cl2-footer-col-title {
  font-size: var(--cl2-fs-2xs);
  font-family: var(--cl2-font-mono);
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--cl2-text-dim);
  font-weight: 600;
  margin: 0 0 var(--cl2-space-2xs);
}

.cl2-footer-link {
  font-size: var(--cl2-fs-sm);
  color: var(--cl2-text-muted);
  transition: color var(--cl2-t-fast) var(--cl2-ease);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cl2-footer-link:hover {
  color: var(--cl2-accent);
}
