/* Shared theme tokens and utilities for both pages */

:root {
  /* Default light theme; pages may override --bg locally */
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  /* Builder accent colors: softer tints than page backgrounds */
  --kb-accent: #f3f1ff;      /* light lavender pill */
  --guide-accent: #fff1f7;   /* light pink pill */
  --publisher-accent: #eaf6ff; /* light blue pill */
  --expert-accent: #f9fafb;  /* very light grey pill */
  --heading-font: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Liberation Sans', sans-serif;
}

html[data-theme="dark"] {
  --bg: #0b1220;
  --card: #121a30;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: #1f2937;
}

/* Base */
body {
  background: var(--bg);
  color: var(--text);
}

html.auth-check-pending body {
  visibility: hidden;
}

html.auth-check-ready body {
  visibility: visible;
}

/* Card + borders */
.bg-card { background: var(--card) !important; }

.border { border-color: var(--border) !important; }
.border-t, .border-r, .border-b, .border-l { border-color: var(--border) !important; }

input,
textarea,
select {
  background-color: var(--card);
  background: color-mix(in srgb, var(--card) 92%, var(--bg) 8%);
  color: var(--text);
  border-color: var(--border);
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
  background: var(--card);
  border-color: #4f46e5;
  box-shadow: 0 0 0 1px #4f46e5;
}

/* Global button polish (excluding the floating theme toggle) */
button:not(.theme-toggle) {
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    filter 0.15s ease;
}

button:not(.theme-toggle):hover {
  filter: brightness(1.03);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

button:not(.theme-toggle):active {
  filter: brightness(0.97);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

button:not(.theme-toggle):focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}



/* Button-like links (gems, menu pills, etc.) */
a.inline-flex.items-center {
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    filter 0.15s ease;
}

a.inline-flex.items-center:hover {
  filter: brightness(1.03);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

a.inline-flex.items-center:active {
  filter: brightness(0.97);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

a.inline-flex.items-center:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

/* Dark-mode: slightly stronger hover affordance for buttons and button-like links */
html[data-theme="dark"] button:not(.theme-toggle):hover,
html[data-theme="dark"] a.inline-flex.items-center:hover {
  filter: brightness(1.10);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.7);
}

html[data-theme="dark"] button:not(.theme-toggle):active,
html[data-theme="dark"] a.inline-flex.items-center:active {
  filter: brightness(0.92);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.7);
}


/* Expert incognito icon: invert to white in dark mode */
.expert-incognito-icon {
  display: block;
}

html[data-theme="dark"] .expert-incognito-icon {
  filter: brightness(0) invert(1);
}

/* Top navigation pills: use builder page accent colors in light mode */
html[data-theme="light"] a[href="/"].inline-flex {
  background-color: var(--kb-accent) !important;
}

html[data-theme="light"] a[href="/"].inline-flex:hover {
  background-color: var(--kb-accent) !important;
}

html[data-theme="light"] a[href="/guide-builder.html"].inline-flex {
  background-color: var(--guide-accent) !important;
}

html[data-theme="light"] a[href="/guide-builder.html"].inline-flex:hover {
  background-color: var(--guide-accent) !important;
}

html[data-theme="light"] a[href="/guide-publisher.html"].inline-flex {
  background-color: var(--publisher-accent) !important;
}

html[data-theme="light"] a[href="/guide-publisher.html"].inline-flex:hover {
  background-color: var(--publisher-accent) !important;
}

html[data-theme="light"] a[href="/expert.html"].inline-flex {
  background-color: var(--expert-accent) !important;
}

html[data-theme="light"] a[href="/expert.html"].inline-flex:hover {
  background-color: var(--expert-accent) !important;
}

/* Response area subtle tint */
#out { background: color-mix(in srgb, var(--card) 92%, var(--bg) 8%) !important; }

/* Heading and logo swap */
.title-text { font-family: var(--heading-font); letter-spacing: -0.01em; }
.logo-dark { display: none; }
html[data-theme="dark"] .logo-light { display: none; }
html[data-theme="dark"] .logo-dark { display: inline-block; }

/* Theme toggle */
.theme-toggle {
  position: fixed;
  top: 28px;
  right: 12px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}
.theme-toggle:hover { filter: brightness(1.05); }
.theme-toggle svg { width: 16px; height: 16px; }

/* Contact badge */
.contact-badge {
  position: fixed;
  right: 14px;
  bottom: 12px;
  z-index: 50;
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
  display: flex;
  align-items: center;
  gap: 10px;
}
html[data-theme="dark"] .contact-badge {
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}
.contact-badge a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}
.contact-badge a:hover { text-decoration: underline; }
.contact-badge .sep { opacity: .5; user-select: none; }
.contact-badge .gh { display: inline-flex; align-items: center; gap: 6px; border-bottom: none; }
.contact-badge .gh svg { width: 14px; height: 14px; display: block; }

/* Preview (guide builder) contrast improvements
   - In light mode, nested preview steps use a grey container. Ensure
     text inside nested blocks stays highly legible by forcing white. */
html[data-theme="light"] #previewTree .border-l { color: #ffffff; }
/* Ensure common muted utility classes used in preview become white */
html[data-theme="light"] #previewTree .border-l .text-slate-500,
html[data-theme="light"] #previewTree .border-l .text-slate-600,
html[data-theme="light"] #previewTree .border-l .text-slate-700,
html[data-theme="light"] #previewTree .border-l .font-medium,
html[data-theme="light"] #previewTree .border-l a { color: #ffffff !important; }

/* Choice blocks at depth 0 (no border-l) still use a grey card background.
   Force label + helper text to white there too, with slight opacity for labels. */
html[data-theme="light"] #previewTree .rounded-md .text-slate-500 { color: #ffffff !important; opacity: .9; }
html[data-theme="light"] #previewTree .rounded-md .text-slate-600 { color: #ffffff !important; }
html[data-theme="light"] #previewTree .rounded-md .italic { color: #ffffff !important; opacity: .9; }

/* AI Content Creator specifics */
.testing-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.2;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.testing-mode-toggle:hover {
  transform: translateY(-1px);
}

.testing-mode-toggle:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

.testing-mode-toggle .testing-mode-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.testing-mode-toggle .testing-mode-copy {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.1;
}

.testing-mode-toggle .testing-mode-title {
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text);
}

.testing-mode-toggle .testing-mode-status {
  font-size: 0.7rem;
  color: var(--muted);
}

.testing-mode-toggle.testing-on {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.45);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.25);
}

.testing-mode-toggle.testing-on .testing-mode-dot {
  background: #16a34a;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.35);
}

.testing-mode-toggle.testing-on .testing-mode-status {
  color: #16a34a;
}

html[data-theme="dark"] .testing-mode-toggle {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.8);
  box-shadow: 0 8px 20px rgba(2, 6, 23, 0.6);
}

html[data-theme="dark"] .testing-mode-toggle .testing-mode-title {
  color: #f8fafc;
}

html[data-theme="dark"] .testing-mode-toggle .testing-mode-status {
  color: #cbd5f5;
}

.testing-mode-banner {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  border-radius: 0.75rem;
  border: 1px dashed rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.1);
  color: #166534;
  font-size: 0.85rem;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

html[data-theme="dark"] .testing-mode-banner {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.12);
  color: #bbf7d0;
}

#discardBtn {
  border-color: rgba(248, 113, 113, 0.4);
  background-color: #fef2f2;
  color: #b91c1c;
}

#discardBtn:hover {
  background-color: #fee2e2;
}

html[data-theme="dark"] #discardBtn {
  background-color: rgba(239, 68, 68, 0.18);
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] #discardBtn:hover {
  background-color: rgba(239, 68, 68, 0.26);
}

.form-toggle-disabled {
  opacity: 0.55;
  cursor: not-allowed !important;
}

.form-toggle-disabled input {
  cursor: not-allowed !important;
}

textarea.prompt-locked {
  background: color-mix(in srgb, var(--card) 95%, var(--bg) 5%);
  color: color-mix(in srgb, var(--muted) 70%, var(--text) 30%);
  border-color: color-mix(in srgb, var(--border) 70%, rgba(99, 102, 241, 0.35) 30%);
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.08);
}

html[data-theme="light"] textarea.prompt-locked {
  background: color-mix(in srgb, var(--card) 80%, #e2e8f0 20%);
  color: color-mix(in srgb, #475569 70%, var(--text) 30%);
  border-color: color-mix(in srgb, #cbd5f5 50%, var(--border) 50%);
}

html[data-theme="dark"] textarea.prompt-locked {
  background: color-mix(in srgb, var(--card) 88%, rgba(99, 102, 241, 0.25) 12%);
  color: color-mix(in srgb, var(--text) 65%, var(--muted) 35%);
  border-color: color-mix(in srgb, rgba(148, 163, 184, 0.6), rgba(99, 102, 241, 0.4));
}


.guide-preview-card {
  background-color: var(--card);
  background: color-mix(in srgb, var(--card) 94%, var(--bg) 6%);
  border-color: var(--border);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

html[data-theme="dark"] .guide-preview-card {
  background-color: var(--card);
  background: color-mix(in srgb, var(--card) 85%, #030617 15%);
  border-color: #1f2937;
  box-shadow: 0 20px 35px rgba(2, 6, 23, 0.85);
}

.guide-preview-meta {
  letter-spacing: 0.12em;
  color: var(--muted);
  color: color-mix(in srgb, var(--muted) 80%, var(--text) 20%);
}

html[data-theme="dark"] .guide-preview-meta {
  color: var(--text);
  color: color-mix(in srgb, var(--text) 60%, var(--muted) 40%);
}

.guide-preview-title,
.guide-preview-step-title,
.guide-preview-choice-label {
  color: var(--text);
}

.guide-preview-step-title {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: baseline;
}

.guide-preview-step-title {
  font-size: 0.95rem;
}

.guide-preview-step-key {
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border) 80%, rgba(99, 102, 241, 0.25) 20%);
  color: color-mix(in srgb, var(--muted) 70%, var(--text) 30%);
  background: color-mix(in srgb, var(--card) 85%, rgba(99, 102, 241, 0.1) 15%);
}

html[data-theme="dark"] .guide-preview-step-key {
  border-color: rgba(148, 163, 184, 0.35);
  color: color-mix(in srgb, var(--text) 75%, var(--muted) 25%);
  background: color-mix(in srgb, rgba(99, 102, 241, 0.25), rgba(15, 23, 42, 0.8));
}

.guide-preview-summary,
.guide-preview-choice-ref,
.guide-preview-empty {
  color: var(--muted);
  color: color-mix(in srgb, var(--muted) 75%, var(--text) 25%);
}

html[data-theme="dark"] .guide-preview-summary,
html[data-theme="dark"] .guide-preview-choice-ref,
html[data-theme="dark"] .guide-preview-empty {
  color: var(--muted);
  color: color-mix(in srgb, var(--muted) 85%, var(--text) 15%);
}

.guide-preview-step.border-l {
  border-left-color: var(--border);
  border-left-color: color-mix(in srgb, var(--border) 85%, rgba(99, 102, 241, 0.15) 15%);
}

html[data-theme="dark"] .guide-preview-step.border-l {
  border-left-color: rgba(255, 255, 255, 0.08);
}

.guide-preview-choice-label {
  text-transform: none;
}

.guide-preview-choice-ref {
  font-style: italic;
}
