/* ==========================================================================
   SMToolsAI, main.css
   Design tokens, reset, layout primitives, header/navigation, footer,
   buttons, cards, ad slots, accessibility and responsive rules.
   Loaded on every page. No frameworks, no external fonts.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS
   -------------------------------------------------------------------------- */
:root {
  /* Surfaces & text, light theme (default) */
  --bg: #ffffff;
  --surface-1: #f8fafc;
  --surface-2: #f1f5f9;
  --surface-3: #e9eef5;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* Accent */
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-strong: #4f46e5;
  --accent-soft: rgba(99, 102, 241, 0.1);
  --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --on-accent: #ffffff;

  /* Status */
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --warning: #b45309;
  --warning-soft: rgba(180, 83, 9, 0.12);

  /* Brand colours for social icons */
  --brand-facebook: #1877f2;
  --brand-twitter: #000000;
  --brand-instagram: linear-gradient(45deg, #f58529, #dd2a7b, #8134af, #515bd4);
  --brand-youtube: #ff0000;
  --brand-linkedin: #0a66c2;
  --brand-pinterest: #e60023;

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: clamp(1.0625rem, 0.2vw + 1rem, 1.125rem);
  --fs-xl: clamp(1.25rem, 0.5vw + 1.1rem, 1.5rem);
  --fs-2xl: clamp(1.5rem, 1vw + 1.25rem, 2rem);
  --fs-3xl: clamp(1.875rem, 2vw + 1.35rem, 2.75rem);
  --fs-4xl: clamp(2.125rem, 3vw + 1.4rem, 3.5rem);
  --lh-tight: 1.2;
  --lh-normal: 1.5;
  --lh-content: 1.7;

  /* Spacing scale (4px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-12: 48px;
  --sp-16: 64px;
  --sp-24: 96px;

  /* Radii */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* Shadows, soft, layered, never harsh */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05),
    0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 2px 6px rgba(15, 23, 42, 0.06),
    0 8px 24px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 4px 12px rgba(15, 23, 42, 0.07),
    0 20px 48px rgba(15, 23, 42, 0.1);

  /* Layout */
  --wrap: 1200px;
  --wrap-narrow: 760px;
  --header-h: 64px;
  --speed: 200ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface-1: #111827;
  --surface-2: #172033;
  --surface-3: #1f2a40;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #1e293b;
  --border-strong: #334155;

  --accent: #818cf8;
  --accent-2: #a78bfa;
  --accent-strong: #6366f1;
  --accent-soft: rgba(129, 140, 248, 0.16);
  --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.14);

  --brand-twitter: #ffffff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.45), 0 20px 48px rgba(0, 0, 0, 0.45);
}

/* Dark-mode X icon needs a dark glyph on a white pill */
[data-theme="dark"] .social-link[data-brand="twitter"]:hover svg,
[data-theme="dark"] .social-link[data-brand="twitter"]:focus-visible svg {
  fill: #0b1120;
}

/* --------------------------------------------------------------------------
   2. RESET & BASE
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--sp-4));
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color var(--speed) var(--ease),
    color var(--speed) var(--ease);
}

body.no-scroll {
  overflow: hidden;
}

img,
svg,
canvas,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 var(--sp-4);
  line-height: var(--lh-tight);
  font-weight: 700;
  letter-spacing: -0.015em;
}

h1 {
  font-size: var(--fs-4xl);
}
h2 {
  font-size: var(--fs-3xl);
}
h3 {
  font-size: var(--fs-xl);
}
h4 {
  font-size: var(--fs-lg);
}

p {
  margin: 0 0 var(--sp-4);
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

[data-theme="dark"] a {
  color: var(--accent);
}

ul,
ol {
  margin: 0 0 var(--sp-4);
  padding-left: var(--sp-6);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--sp-8) 0;
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection {
  background: var(--accent-soft);
}

/* --------------------------------------------------------------------------
   3. LAYOUT PRIMITIVES
   -------------------------------------------------------------------------- */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--sp-4);
}

.wrap-narrow {
  max-width: var(--wrap-narrow);
}

main {
  flex: 1 0 auto;
}

.section {
  padding-block: var(--sp-12);
}

.section-tight {
  padding-block: var(--sp-8);
}

.section-head {
  text-align: center;
  max-width: 680px;
  margin: 0 auto var(--sp-8);
}

.section-head p {
  color: var(--text-muted);
  font-size: var(--fs-lg);
  margin: 0;
}

.eyebrow {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-pill);
  margin-bottom: var(--sp-3);
}

[data-theme="dark"] .eyebrow {
  color: var(--accent);
}

.grid {
  display: grid;
  gap: var(--sp-4);
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -100px;
  z-index: 200;
  background: var(--accent-strong);
  color: #fff;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  font-weight: 600;
  transition: top var(--speed) var(--ease);
}

.skip-link:focus {
  top: var(--sp-3);
  text-decoration: none;
}

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

/* --------------------------------------------------------------------------
   4. BUTTONS
   -------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: var(--sp-3) var(--sp-6);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: transform var(--speed) var(--ease),
    box-shadow var(--speed) var(--ease), background-color var(--speed) var(--ease),
    opacity var(--speed) var(--ease);
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background: var(--gradient);
  color: var(--on-accent);
  border-color: transparent;
}

.btn-primary:hover {
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: var(--surface-1);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.btn-sm {
  min-height: 36px;
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-sm);
}

.btn-lg {
  min-height: 52px;
  padding: var(--sp-4) var(--sp-8);
  font-size: var(--fs-lg);
}

.btn-block {
  width: 100%;
}

/* --------------------------------------------------------------------------
   5. CARDS
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  transition: transform var(--speed) var(--ease),
    box-shadow var(--speed) var(--ease), border-color var(--speed) var(--ease);
}

a.card:hover,
.card-link:hover {
  text-decoration: none;
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.card h3 {
  margin-bottom: var(--sp-2);
  color: var(--text);
  font-size: var(--fs-lg);
}

.card p {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
}

.card-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent-strong);
  margin-bottom: var(--sp-4);
}

[data-theme="dark"] .card-icon {
  color: var(--accent);
}

.card-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.badge {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: var(--r-pill);
  padding: 2px var(--sp-2);
}

/* --------------------------------------------------------------------------
   6. HEADER & NAVIGATION
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  transition: box-shadow var(--speed) var(--ease),
    background-color var(--speed) var(--ease);
}

.site-header.is-scrolled {
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-height: var(--header-h);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 800;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-right: auto;
}

.logo:hover {
  text-decoration: none;
}

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  background: var(--gradient);
  display: grid;
  place-items: center;
  flex: none;
}

.logo-mark svg {
  width: 18px;
  height: 18px;
  stroke: #fff;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logo-text .accent {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Primary nav */
.nav {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.nav-list {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text);
  font-weight: 600;
  font-size: var(--fs-sm);
  background: none;
  border: 0;
  cursor: pointer;
  min-height: 40px;
}

.nav-link:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.nav-link[aria-current="page"] {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

[data-theme="dark"] .nav-link[aria-current="page"] {
  color: var(--accent);
}

.nav-link .chev {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--speed) var(--ease);
}

.nav-link[aria-expanded="true"] .chev {
  transform: rotate(180deg);
}

/* Mega menu */
.has-mega {
  position: relative;
}

.mega {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translate(-50%, -8px);
  width: min(720px, calc(100vw - var(--sp-8)));
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-4);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-2);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--speed) var(--ease),
    transform var(--speed) var(--ease), visibility var(--speed) var(--ease);
}

.mega.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.mega-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text);
}

.mega-item:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.mega-item .card-icon {
  width: 36px;
  height: 36px;
  margin: 0;
  flex: none;
}

.mega-item .card-icon svg {
  width: 18px;
  height: 18px;
}

.mega-item strong {
  display: block;
  font-size: var(--fs-sm);
  line-height: 1.3;
}

.mega-item span {
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.mega-foot {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  margin-top: var(--sp-2);
  padding-top: var(--sp-3);
  text-align: center;
  font-size: var(--fs-sm);
  font-weight: 600;
}

/* Theme toggle */
.theme-toggle {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text);
  cursor: pointer;
  transition: background-color var(--speed) var(--ease),
    border-color var(--speed) var(--ease);
}

.theme-toggle:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .icon-moon {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

/* Hamburger */
.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  flex: none;
  place-items: center;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text);
  cursor: pointer;
}

.nav-toggle svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

.nav-toggle .icon-close {
  display: none;
}

.nav-toggle[aria-expanded="true"] .icon-open {
  display: none;
}

.nav-toggle[aria-expanded="true"] .icon-close {
  display: block;
}

.nav-overlay {
  position: fixed;
  inset: var(--header-h) 0 0;
  background: rgba(15, 23, 42, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--speed) var(--ease),
    visibility var(--speed) var(--ease);
  z-index: 90;
}

.nav-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

/* --------------------------------------------------------------------------
   7. AD SLOTS, fixed min-heights so nothing shifts (protects CLS)
   -------------------------------------------------------------------------- */
.ad-slot {
  display: block;
  width: 100%;
  margin: var(--sp-8) auto;
  background: var(--surface-1);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}

.ad-slot-leaderboard {
  min-height: 100px;
  max-width: 970px;
}

.ad-slot-inline {
  min-height: 280px;
  max-width: 728px;
}

.ad-slot-footer {
  min-height: 250px;
  max-width: 970px;
}

@media (min-width: 768px) {
  .ad-slot-leaderboard {
    min-height: 90px;
  }
  .ad-slot-inline {
    min-height: 250px;
  }
}

/* --------------------------------------------------------------------------
   8. FOOTER
   -------------------------------------------------------------------------- */
.site-footer {
  background: var(--surface-1);
  border-top: 1px solid var(--border);
  margin-top: var(--sp-16);
  padding-top: var(--sp-12);
  font-size: var(--fs-sm);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: var(--sp-8);
  padding-bottom: var(--sp-8);
}

.footer-col h3 {
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  margin-bottom: var(--sp-4);
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sp-2);
}

.footer-col a {
  color: var(--text-muted);
}

.footer-col a:hover {
  color: var(--accent-strong);
}

[data-theme="dark"] .footer-col a:hover {
  color: var(--accent);
}

.footer-about p {
  color: var(--text-muted);
  max-width: 38ch;
  line-height: var(--lh-content);
}

.footer-about .logo {
  margin-bottom: var(--sp-4);
}

/* Social icons */
.social-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
  padding: 0;
  list-style: none;
}

.social-link {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
  transition: background var(--speed) var(--ease),
    transform 300ms var(--ease), box-shadow 300ms var(--ease),
    color 300ms var(--ease);
}

.social-link:hover {
  text-decoration: none;
}

.social-link svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  transition: fill 300ms var(--ease);
}

.social-link[data-brand="facebook"]:hover,
.social-link[data-brand="facebook"]:focus-visible {
  background: var(--brand-facebook);
  color: #fff;
  transform: translateY(-4px);
  box-shadow: 0 8px 20px #1877f266;
}

.social-link[data-brand="twitter"]:hover,
.social-link[data-brand="twitter"]:focus-visible {
  background: var(--brand-twitter);
  color: #fff;
  transform: translateY(-4px);
  box-shadow: 0 8px 20px #00000066;
}

.social-link[data-brand="instagram"]:hover,
.social-link[data-brand="instagram"]:focus-visible {
  background: var(--brand-instagram);
  color: #fff;
  transform: translateY(-4px);
  box-shadow: 0 8px 20px #dd2a7b66;
}

.social-link[data-brand="youtube"]:hover,
.social-link[data-brand="youtube"]:focus-visible {
  background: var(--brand-youtube);
  color: #fff;
  transform: translateY(-4px);
  box-shadow: 0 8px 20px #ff000066;
}

.social-link[data-brand="linkedin"]:hover,
.social-link[data-brand="linkedin"]:focus-visible {
  background: var(--brand-linkedin);
  color: #fff;
  transform: translateY(-4px);
  box-shadow: 0 8px 20px #0a66c266;
}

.social-link[data-brand="pinterest"]:hover,
.social-link[data-brand="pinterest"]:focus-visible {
  background: var(--brand-pinterest);
  color: #fff;
  transform: translateY(-4px);
  box-shadow: 0 8px 20px #e6002366;
}

.footer-bar {
  border-top: 1px solid var(--border);
  padding-block: var(--sp-6);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
}

.footer-bar p {
  margin: 0;
}

.footer-note {
  font-size: var(--fs-xs);
}

/* --------------------------------------------------------------------------
   8b. TOOL SEARCH COMBOBOX (hero + all-tools; driven by nav.js)
   -------------------------------------------------------------------------- */
.search-box {
  position: relative;
  max-width: 620px;
  margin-inline: auto;
  width: 100%;
}

.search-field {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  padding: var(--sp-2) var(--sp-4);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--speed) var(--ease),
    box-shadow var(--speed) var(--ease);
}

.search-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.search-field svg {
  width: 20px;
  height: 20px;
  flex: none;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-field input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border: 0;
  outline: none;
  background: transparent;
  font-size: var(--fs-base);
  color: var(--text);
}

.search-results {
  position: absolute;
  z-index: 60;
  left: 0;
  right: 0;
  top: calc(100% + var(--sp-2));
  max-height: 340px;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: var(--sp-2);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  text-align: left;
}

.search-results[hidden] {
  display: none;
}

.search-item a {
  display: block;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text);
}

.search-item a:hover {
  text-decoration: none;
}

.search-item.is-active a,
.search-item a:hover {
  background: var(--accent-soft);
}

.search-item strong {
  display: block;
  font-size: var(--fs-base);
}

.search-item span {
  display: block;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.search-empty {
  margin-top: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.search-empty[hidden] {
  display: none;
}

/* --------------------------------------------------------------------------
   9. TOAST NOTIFICATIONS (used by shared.js on every page)
   -------------------------------------------------------------------------- */
.toast-stack {
  position: fixed;
  right: var(--sp-4);
  bottom: var(--sp-4);
  z-index: 300;
  display: grid;
  gap: var(--sp-2);
  width: min(360px, calc(100vw - var(--sp-8)));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  animation: toast-in 260ms var(--ease);
}

.toast.is-leaving {
  animation: toast-out 220ms var(--ease) forwards;
}

.toast-success {
  border-left: 4px solid var(--success);
}
.toast-error {
  border-left: 4px solid var(--danger);
}
.toast-info {
  border-left: 4px solid var(--accent);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* --------------------------------------------------------------------------
   10. RESPONSIVE
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-8) var(--sp-6);
  }
  .footer-about {
    grid-column: 1 / -1;
  }
}

@media (max-width: 768px) {
  .section {
    padding-block: var(--sp-8);
  }

  .nav-toggle {
    display: grid;
  }

  .nav {
    position: fixed;
    top: var(--header-h);
    right: 0;
    bottom: 0;
    width: min(320px, 86vw);
    background: var(--bg);
    border-left: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    padding: var(--sp-4);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform var(--speed) var(--ease);
    z-index: 95;
  }

  .nav.is-open {
    transform: translateX(0);
  }

  .nav-list {
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-1);
    width: 100%;
  }

  .nav-link {
    width: 100%;
    justify-content: space-between;
    min-height: 48px;
    font-size: var(--fs-base);
  }

  .has-mega {
    position: static;
  }

  .mega {
    position: static;
    transform: none;
    width: 100%;
    box-shadow: none;
    border: 0;
    border-radius: 0;
    padding: var(--sp-2) 0 var(--sp-2) var(--sp-3);
    grid-template-columns: 1fr;
    display: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .mega.is-open {
    display: grid;
    transform: none;
  }

  .mega-item {
    padding: var(--sp-2) var(--sp-3);
  }
}

@media (max-width: 480px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: var(--sp-8);
  }
  .footer-bar {
    justify-content: flex-start;
  }
  .toast-stack {
    left: var(--sp-4);
    right: var(--sp-4);
    width: auto;
  }
}

/* --------------------------------------------------------------------------
   11. MOTION & PRINT PREFERENCES
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .btn:hover,
  .card:hover,
  a.card:hover,
  .social-link:hover,
  .social-link:focus-visible {
    transform: none;
  }
}

@media print {
  .site-header,
  .site-footer,
  .ad-slot,
  .toast-stack,
  .nav-overlay {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
}

/* ---- Cookie consent -------------------------------------------------- */
/* Sits above the sticky download bar (z-index 200) but below toasts (300),
   so a "copied" message is never hidden behind it. */

.consent {
  position: fixed;
  left: var(--sp-4);
  right: var(--sp-4);
  bottom: var(--sp-4);
  z-index: 250;
  margin-inline: auto;
  max-width: 720px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-6);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  /* Hidden until consent.js adds .is-open, so it animates in rather than
     appearing mid-paint. */
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.consent.is-open {
  opacity: 1;
  transform: none;
}

.consent-text {
  flex: 1 1 320px;
  min-width: 0;
}

.consent-text strong {
  display: block;
  margin-bottom: var(--sp-1);
  font-size: var(--fs-sm);
}

.consent-text p {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: 1.5;
}

.consent-text a {
  color: var(--accent);
}

.consent-actions {
  display: flex;
  gap: var(--sp-2);
  flex-shrink: 0;
}

@media (max-width: 560px) {
  .consent {
    left: var(--sp-3);
    right: var(--sp-3);
    bottom: var(--sp-3);
    padding: var(--sp-4);
  }

  .consent-actions {
    width: 100%;
  }

  /* Equal width on a phone, so neither choice is the easier target. */
  .consent-actions .btn {
    flex: 1;
  }
}

/* The banner must not animate for someone who asked for less motion. */
@media (prefers-reduced-motion: reduce) {
  .consent {
    transition: none;
  }
}

/* A sticky download bar plus a consent banner would overlap on a phone. */
body.has-sticky-download .consent {
  bottom: calc(var(--sp-4) + 72px);
}
