/* HeadlessDomains theme pilot: semantic roles layered after page-specific styles. */
:root {
  --surface-canvas: #0a0a0f;
  --surface: #0e0e14;
  --surface-strong: #14141c;
  --text-primary: #e8e8ee;
  --text-secondary: #a0a0ae;
  --text-muted: #858596;
  --border: #2a2a38;
  --border-strong: #606172;
  --accent-fill: #00ff9d;
  --accent-ink: #00ff9d;
  --on-accent: #032118;
  --focus: #00ff9d;
  --danger: #ff6675;
  --warn: #ffc35c;
  --bg-1: var(--surface);
  --fg-1: var(--text-primary);
  --border-color: var(--border);
  --bs-body-bg: var(--surface-canvas);
  --bs-body-color: var(--text-primary);
  --bs-border-color: var(--border);
  --bs-secondary-color: var(--text-secondary);
  --bs-tertiary-bg: var(--surface-strong);
}

html[data-theme="light"] {
  --surface-canvas: #f7f8f3;
  --surface: #ffffff;
  --surface-strong: #eff2ec;
  --text-primary: #11130f;
  --text-secondary: #3f4640;
  --text-muted: #5b625c;
  --border: #d8ded6;
  --border-strong: #879187;
  --accent-fill: #00d986;
  --accent-ink: #006b46;
  --on-accent: #032118;
  --focus: #006b46;
  --danger: #b42332;
  --warn: #9a5b00;
  --bg: var(--surface-canvas);
  --bg-2: var(--surface);
  --bg-3: var(--surface-strong);
  --line: var(--border);
  --line-2: var(--border-strong);
  --fg: var(--text-primary);
  --fg-2: var(--text-secondary);
  --fg-3: var(--text-muted);
  --accent: var(--accent-ink);
  --accent-dim: #005d3d;
  --accent-glow: rgba(0, 107, 70, 0.15);
  --scanline-opacity: 0.018;
}

body {
  background: var(--surface-canvas);
  color: var(--text-primary);
}

html[data-theme="light"] .bg-grid { opacity: .24; }
html[data-theme="light"] .bg-scanlines { mix-blend-mode: multiply; }

/* Brand assets */
.theme-logo { display: block; }
.theme-logo--light { display: none; }
html[data-theme="light"] .theme-logo--dark { display: none; }
html[data-theme="light"] .theme-logo--light {
  display: block;
  width: 180px !important;
  height: auto !important;
  margin-block: -12px;
  clip-path: inset(12px 0);
}
html[data-theme="light"] .nav { background: rgba(247, 248, 243, .92); }
.nav-links { gap: clamp(12px, 1.5vw, 28px); }
.nav-toggle i { display: none; }
.nav-toggle::before { content: '☰'; display: block; line-height: 1; }

/* Persistent, keyboard-native theme selection */
.theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  background: var(--bg-2);
  color: var(--fg-2);
}
.theme-picker legend {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.theme-picker label { position: relative; margin: 0; cursor: pointer; }
.theme-picker input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}
.theme-picker span {
  display: grid;
  place-items: center;
  min-height: 36px;
  padding: 0 9px;
  border-radius: 2px;
  font: 600 9px/1 var(--font-mono);
  letter-spacing: .05em;
  text-transform: uppercase;
}
.theme-picker input:checked + span {
  background: var(--accent-fill);
  color: var(--on-accent);
}
.theme-picker input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline-color: var(--focus);
}

/* Components that use a mint fill must not inherit the darker light-theme link ink. */
#hello-bar,
.btn-primary,
.btn-success,
.search-submit,
.sp-submit,
.sp-filter-chip.active,
.cr-btn--primary,
.about-primary,
.home-concept .button,
.namespace-option[aria-pressed="true"] {
  background: var(--accent-fill) !important;
  border-color: var(--accent-fill) !important;
  color: var(--on-accent) !important;
}
#hello-bar a { color: var(--on-accent) !important; }
.btn-primary:hover,
.btn-success:hover,
.search-submit:hover,
.sp-submit:hover,
.cr-btn--primary:hover,
.about-primary:hover,
.home-concept .button:hover {
  background: color-mix(in srgb, var(--accent-fill) 82%, white) !important;
  border-color: color-mix(in srgb, var(--accent-fill) 82%, white) !important;
  color: var(--on-accent) !important;
}

/* Bootstrap surfaces and feedback retain semantic contrast in both palettes. */
.card, .dropdown-menu, .modal-content, .list-group-item {
  background-color: var(--bg-2);
  color: var(--fg);
  border-color: var(--line);
}
.dropdown-item { color: var(--fg-2); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--bg-3); color: var(--fg); }
.table { --bs-table-color: var(--fg); --bs-table-bg: transparent; --bs-table-border-color: var(--line); }
.form-control::placeholder, textarea::placeholder { color: var(--fg-3); opacity: 1; }
.alert { background: var(--bg-2); color: var(--fg); border-color: var(--line-2); }
.alert-danger { border-color: var(--danger); color: var(--danger); }
.alert-warning { border-color: var(--warn); color: var(--warn); }
.alert-success, .alert-info { border-color: var(--accent); color: var(--fg); }
.btn-close { filter: var(--theme-close-filter, invert(1) grayscale(100%) brightness(180%)); }
html[data-theme="light"] { --theme-close-filter: none; }

/* Homepage and About: replace decorative dark-only greens with semantic surfaces. */
html[data-theme="light"] .home-concept a:focus-visible,
html[data-theme="light"] .home-concept button:focus-visible,
html[data-theme="light"] .home-concept input:focus-visible,
html[data-theme="light"] .home-concept textarea:focus-visible,
html[data-theme="light"] .home-concept summary:focus-visible,
html[data-theme="light"] .about-page a:focus-visible,
html[data-theme="light"] .about-page button:focus-visible,
html[data-theme="light"] .home-operator .home-faq summary:focus-visible,
html[data-theme="light"] .home-operator .explorer-start:focus-visible {
  outline-color: var(--focus);
}
html[data-theme="light"] .namespace-explorer,
html[data-theme="light"] .proof-record,
html[data-theme="light"] .home-concept .dialog textarea,
html[data-theme="light"] .about-email-toggle {
  background: var(--bg-2);
  border-color: var(--line-2);
  box-shadow: none;
}
html[data-theme="light"] .namespace-option,
html[data-theme="light"] .identity-connections span {
  background: var(--bg-3);
  border-color: var(--line-2);
  color: var(--fg-2);
}
html[data-theme="light"] .namespace-stage {
  border-color: var(--line);
  background: radial-gradient(ellipse at 50% 40%, rgba(0, 217, 134, .13), transparent 68%),
    linear-gradient(rgba(0, 107, 70, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 107, 70, .05) 1px, transparent 1px);
  background-size: auto, 24px 24px, 24px 24px;
}
html[data-theme="light"] .example-name,
html[data-theme="light"] .proof-record-name { color: var(--fg); }
html[data-theme="light"] .about-trust,
html[data-theme="light"] .about-principles,
html[data-theme="light"] .home-operator .home-start { background: var(--bg-3); }
html[data-theme="light"] .principle-art {
  background: radial-gradient(ellipse at 50% 100%, rgba(0, 217, 134, .12), transparent 85%), var(--bg-2);
  border-color: var(--line);
  color: var(--fg-2);
}
html[data-theme="light"] .audience-card:hover { background: var(--bg-3); border-color: var(--border-strong); }
html[data-theme="light"] .home-operator .explorer-start {
  background: linear-gradient(115deg, #e5f6ec, #eff2ec);
  border-color: var(--border-strong);
  box-shadow: none;
}
html[data-theme="light"] .home-operator .explorer-start:hover { background: #dff2e7; border-color: var(--accent); }
html[data-theme="light"] .home-operator .home-tools-list li,
html[data-theme="light"] .home-operator .explorer-start-hint span:last-child,
html[data-theme="light"] .home-operator .proof-caption a { color: var(--fg-2); }

/* Search: palette-only overrides; merged progressive-results markup and behavior stay intact. */
html[data-theme="light"] .sp-tld__menu,
html[data-theme="light"] .sp-filter-menu,
html[data-theme="light"] .cr-actions-menu { box-shadow: 0 18px 42px rgba(17, 19, 15, .16); }
html[data-theme="light"] a.cr-row--alt:hover,
html[data-theme="light"] .cr-row--available:hover { background: rgba(0, 107, 70, .07); }
html[data-theme="light"] .idle-agent-prompt { background: rgba(0, 107, 70, .06); }
html[data-theme="light"] .idle-agent-prompt--secondary { background: rgba(0, 103, 122, .06); }
html[data-theme="light"] .idle-agent-prompt--secondary .idle-agent-prompt__label,
html[data-theme="light"] .idle-agent-prompt--secondary a { color: #00677a; }
html[data-theme="light"] .idle-agent-prompt code { background: var(--bg-3); color: var(--fg); }
html[data-theme="light"] .mobile-error { background: rgba(180, 35, 50, .08); border-color: rgba(180, 35, 50, .3); }

/* Article and initial purchase-journey containment. */
html[data-theme="light"] .ap-content tbody tr:hover td { background: var(--bg-3); }
.ap-cta.primary { background: var(--accent-fill) !important; color: var(--on-accent) !important; }
html[data-theme="light"] .hero-sub[style] { color: var(--fg) !important; }
html[data-theme="light"] .bg-dark,
html[data-theme="light"] .bg-black { background-color: var(--bg-3) !important; }
html[data-theme="light"] .text-white,
html[data-theme="light"] .text-light { color: var(--fg) !important; }
html[data-theme="light"] .border-secondary { border-color: var(--line-2) !important; }
html[data-theme="light"] .nav-tabs .nav-link { color: var(--fg-2); }
html[data-theme="light"] .nav-tabs .nav-link.active { background: var(--bg-2); color: var(--fg); border-color: var(--line); }
html[data-theme="light"] .image-placeholder,
html[data-theme="light"] .upload-placeholder {
  background: var(--bg-3) !important;
  border-color: var(--line-2) !important;
  color: var(--fg-3) !important;
}
html[data-theme="light"] #ipfsSyncBanner { background: rgba(0, 107, 70, .08) !important; color: var(--fg) !important; }

/* Componentized shared-footer palette contract. */
html[data-theme="dark"] .hd-footer {
  --footer-line: #2e3a36;
  --footer-muted: #b2bebb;
  --footer-dim: #9aaea5;
  --footer-green: #28e6a0;
  color: #ecf3ef;
}
html[data-theme="light"] #site-footer { background: var(--bg-3); }
html[data-theme="light"] .hd-footer {
  --footer-line: #c8d1c7;
  --footer-muted: var(--fg-2);
  --footer-dim: var(--fg-3);
  --footer-green: var(--accent);
  color: var(--fg);
  background: radial-gradient(circle at 12% 8%, rgba(0, 217, 134, .11), transparent 34%), var(--bg-3);
}
html[data-theme="light"] .hd-footer-logo .theme-logo--light {
  width: 235px !important;
  height: auto !important;
}
html[data-theme="light"] .hd-footer a.hd-footer-button {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--on-accent);
}
html[data-theme="light"] .hd-footer a.hd-footer-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--fg);
}
html[data-theme="light"] .hd-footer a.hd-footer-ghost:hover,
html[data-theme="light"] .hd-footer a.hd-footer-ghost:focus-visible,
html[data-theme="light"] .hd-footer-namespaces a:hover { background: var(--bg-2); }
html[data-theme="light"] .hd-footer-drawer { background: var(--bg-2); border-color: var(--border-strong); }

@media (max-width: 700px) {
  html[data-theme="light"] .hd-footer-logo .theme-logo--light { width: 210px !important; }
  html[data-theme="light"] .hd-footer-actions a.hd-footer-button {
    background: none;
    border: 0;
    color: var(--footer-green);
  }
}

/* Keep contextual domain rows legible when Bootstrap's light semantic fills meet dark text utilities. */
html[data-theme="dark"] .table-warning {
  --bs-table-bg: #332a10;
  --bs-table-striped-bg: #3a3012;
  --bs-table-hover-bg: #413615;
  --bs-table-border-color: #705c20;
  color: #fff4d1;
}
html[data-theme="dark"] .table-danger {
  --bs-table-bg: #35161c;
  --bs-table-striped-bg: #3d1920;
  --bs-table-hover-bg: #461d25;
  --bs-table-border-color: #71313d;
  color: #ffe6e9;
}

@media (max-width: 1180px) {
  .nav-inner { flex-wrap: wrap; }
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding: 20px 0 10px;
    margin-top: 14px;
    border-top: 1px solid var(--line);
    background: var(--bg);
  }
  .nav-links.active { display: flex; }
  .nav-cta, .theme-picker { align-self: flex-start; }
  .theme-picker span { min-height: 44px; padding-inline: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .ticker-track, .t-cursor, .dot { animation: none !important; }
}

@media (forced-colors: active) {
  .theme-picker, .theme-picker span { forced-color-adjust: none; }
  .theme-picker { border-color: CanvasText; background: Canvas; color: CanvasText; }
  .theme-picker input:checked + span { background: Highlight; color: HighlightText; }
  .theme-picker input:focus-visible + span { outline-color: Highlight; }
}
