/**
 * Noir Editorial — design foundation tokens & shared patterns.
 * Source: landing-designs.html Design #2 (.d2) via issue #512.
 */

/* ==========================================================================
   Design tokens
   ========================================================================== */

/*
 * Fallback faces with size-adjust so system fonts approximate webfont metrics.
 * Paired with display=optional in BaseLayout (#729) to keep homepage CLS under
 * the 0.1 CWV budget when Instrument Sans / Playfair swap (or never load).
 */
@font-face {
  font-family: 'Instrument Sans Fallback';
  src: local('Arial'), local('Helvetica Neue'), local('Helvetica');
  size-adjust: 102%;
  ascent-override: 95%;
  descent-override: 22%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'Playfair Display Fallback';
  src: local('Times New Roman'), local('Times'), local('Georgia');
  size-adjust: 108%;
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'JetBrains Mono Fallback';
  src: local('Menlo'), local('Consolas'), local('Monaco'), local('Courier New');
  size-adjust: 100%;
  ascent-override: 92%;
  descent-override: 22%;
  line-gap-override: 0%;
}

:root {
  /* Fonts */
  --font-display: 'Playfair Display', 'Playfair Display Fallback', Georgia, serif;
  --font-body: 'Instrument Sans', 'Instrument Sans Fallback', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'JetBrains Mono Fallback', ui-monospace, monospace;

  /* Backgrounds */
  --noir-bg-base: #0a0a0b;
  --noir-bg-panel: #0e0e10;
  --noir-bg-code: #111114;

  /* Text */
  --noir-text-primary: #e8e6e3;
  --noir-text-secondary: #888;
  --noir-text-muted: #7c7c7c;
  /* AA normal text on --noir-bg-base (#0a0a0b): was #555 (~2.65:1) */
  --noir-text-muted-deep: #8a8a8a;
  --noir-text-eyebrow: #9a9a9a;
  --noir-ghost: #222;
  --noir-ghost-deep: #1a1a1c;

  /* Accent */
  --noir-accent: #cba6f7;
  --noir-accent-glow: rgba(203, 166, 247, 0.2);

  /* Borders */
  --noir-border-section: #222;
  --noir-border-row: #1a1a1c;
  --noir-border-ghost: #333;

  /* Motion */
  --noir-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --noir-duration: 250ms;
  --transition-fast: 200ms var(--noir-ease);
  --transition-normal: 250ms var(--noir-ease);
  --transition-slow: 300ms var(--noir-ease);

  /*
   * Theme gradients / radii / elevation come from site.css + turbo tokens.
   * Do not flatten them here — that fought showcase/prod glam while Noir
   * chrome remains temporarily (full Noir retirement is a separate task).
   */
}

/* ==========================================================================
   Global base (scoped to Noir design context)
   ========================================================================== */

html[data-design='noir'] body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--noir-text-primary);
  background-color: var(--noir-bg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* No color/background transition: theme swaps would otherwise animate
     through a mid-flight blend that fails WCAG AA under axe. */
}

html[data-design='noir'] h1,
html[data-design='noir'] h2,
html[data-design='noir'] h3,
html[data-design='noir'] .page-title {
  font-family: var(--font-display);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--noir-text-primary);
}

html:root h1,
html:root .page-title {
  letter-spacing: -0.04em;
}

html:root h1 em,
html:root h2 em,
html:root h3 em {
  font-style: italic;
  font-weight: 400;
  color: var(--turbo-brand-primary, var(--noir-accent));
}

html:root code,
html:root pre,
html:root kbd,
html:root samp {
  font-family: var(--font-mono);
}

/*
 * Content links follow the active theme accent (AA-normalized). Fixed
 * `--noir-accent` is only ~2:1 on light theme bases. Header/footer keep
 * their own noir ink via more-specific chrome selectors. Exclude `.btn`
 * so component button colors win (#741).
 */
html:root a:where(:not(.btn)) {
  color: var(--turbo-accent-link, var(--noir-accent));
}

html:root a:where(:not(.btn)):hover {
  color: var(--turbo-brand-primary, var(--noir-text-primary));
}

/* ==========================================================================
   Header — editorial chrome
   ========================================================================== */

html:root .header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--noir-bg-base);
  backdrop-filter: none;
  border-bottom: 1px solid var(--noir-border-section);
  transition: border-color var(--transition-slow);
}

html:root .header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.5rem;
  max-width: var(--container-wide, 1440px);
  margin: 0 auto;
}

html:root .logo {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--noir-text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

html:root .logo:hover {
  color: var(--turbo-brand-primary, var(--noir-accent));
  text-decoration: none;
}

html:root .logo-icon {
  color: var(--turbo-brand-primary, var(--noir-accent));
  font-size: 1rem;
  line-height: 1;
}

html:root .logo-text {
  text-transform: none;
}

/*
 * Phone layout: let the brand wrap to two lines again. site.css pins
 * `.logo` to `flex-shrink: 0` + `white-space: nowrap` (#742/#747) so the
 * brand and nav cannot overlap on desktop; at 375px that keeps the brand
 * on one line and pushes the theme selector off the right edge of the
 * viewport. Noir chrome loads after site.css, so relaxing it here below
 * the 768px breakpoint restores the wrapped phone brand while desktop
 * keeps the no-shrink rule.
 */
@media (max-width: 767px) {
  html:root .logo {
    flex-shrink: 1;
    white-space: normal;
  }
}

/*
 * Do not set `display` here — site.css owns desktop flex + the mobile
 * `display: none` / `.open` drawer. Noir loads after site.css; an
 * unconditional `display: flex` kept the mobile menu permanently open
 * and hid the homepage behind the drawer.
 */
html:root .nav-links {
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Higher specificity than site.css theme-token nav colors so light themes
   cannot paint dark secondary text onto the fixed noir header (#0a0a0b). */
html[data-design='noir'] .header .nav-link,
html[data-design='noir'] .header .nav-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  min-height: 44px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--noir-text-muted);
  text-decoration: none;
  background: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  /* No color/background transition — see the body rule above. */
}

html[data-design='noir'] .header .nav-link:hover,
html[data-design='noir'] .header .nav-dropdown-trigger:hover {
  color: var(--noir-text-primary);
  background: transparent;
  text-decoration: none;
}

/*
 * The Noir header is fixed dark chrome (#0a0a0b), so the active pill keeps
 * Noir ink like the sibling rules above. Light themes' --turbo-brand-primary
 * is tuned for a light page background and lands at ~3.4-3.7:1 here, which
 * fails AA (axe flags a[data-testid="nav-home"] under catppuccin-latte,
 * github-light/dark, everforest-light-soft, rose-pine-dawn, tokyo-night-light).
 */
html[data-design='noir'] .header .nav-link.active {
  color: var(--noir-accent);
  background: color-mix(in srgb, var(--noir-accent) 14%, transparent);
}

html:root .menu-toggle {
  color: var(--noir-text-primary);
}

html:root .menu-toggle:hover {
  background: var(--noir-bg-panel);
}

html:root .nav-dropdown-menu {
  background: var(--noir-bg-panel);
  border: 1px solid var(--noir-border-section);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0.25rem 0;
}

html:root .nav-dropdown-item {
  color: var(--noir-text-secondary);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
}

html:root .nav-dropdown-item:hover {
  color: var(--noir-text-primary);
  background: var(--noir-bg-code);
}

html:root .nav-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  justify-content: flex-end;
  max-width: 500px;
}

/* Theme / search chrome — muted panel, theme radii */
html[data-design='noir'] .header .theme-trigger,
html[data-design='noir'] .header .search-bar-inner {
  border-color: var(--noir-border-ghost);
  background: var(--noir-bg-panel);
  color: var(--noir-text-secondary);
}

html:root .theme-menu,
html:root .search-menu {
  border-color: var(--noir-border-section);
  background: var(--noir-bg-panel);
  box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   Footer — editorial chrome
   ========================================================================== */

html[data-design='noir'] .footer {
  padding: 0;
  background: var(--noir-bg-base);
  border-top: 1px solid var(--noir-border-section);
  margin-top: var(--space-4xl, 6rem);
}

html:root .footer-content {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 2.5rem;
  align-items: start;
  padding: 3.75rem 1.5rem;
  max-width: var(--container-wide, 1440px);
  margin: 0 auto;
}

html:root .footer-brand {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

html:root .footer-brand-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

html[data-design='noir'] .footer .footer-logo {
  color: var(--turbo-brand-primary, var(--noir-accent));
  font-size: 1rem;
  line-height: 1;
}

html[data-design='noir'] .footer .footer-title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--noir-text-primary);
}

html[data-design='noir'] .footer .footer-tagline {
  margin: 0;
  max-width: 28ch;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--noir-text-secondary);
}

html:root .footer-col {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

html[data-design='noir'] .footer .footer-col-label {
  margin: 0 0 0.25rem;
  font-family: var(--font-body);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--noir-text-eyebrow);
}

html[data-design='noir'] .footer .footer-col a,
html[data-design='noir'] .footer .footer-links a {
  color: var(--noir-text-secondary);
  font-size: 0.875rem;
  text-decoration: none;
}

html[data-design='noir'] .footer .footer-col a:hover,
html[data-design='noir'] .footer .footer-links a:hover {
  color: var(--noir-text-primary);
  text-decoration: none;
}

html[data-design='noir'] .footer .footer-bottom {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--noir-border-row);
}

html[data-design='noir'] .footer .footer-copyright {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--noir-text-muted);
}

html[data-design='noir'] .footer .footer-separator {
  color: var(--noir-text-muted-deep);
}

@media (max-width: 900px) {
  html:root .footer-content {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 2.5rem 1.25rem;
  }

  html:root .footer-brand {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  html:root .footer-content {
    grid-template-columns: 1fr;
  }
}
