/* ChemRepro theme: self-hosted Inter + dark mode.
 *
 * Dark mode is switched by the "dark" class on <html> (set before first paint
 * by the inline script in base.html, from localStorage or the OS setting).
 * The templates use Tailwind light-theme utilities; the rules below remap the
 * ones in use to the dark palette, so templates need no per-element changes.
 * Palette: design direction A ("Refined"), 2026-10-30.
 */

/* ── Inter (self-hosted, SIL OFL 1.1, see fonts/Inter-LICENSE.txt) ─────── */
@font-face { font-family: InterVariable; font-style: normal; font-weight: 100 900; font-display: swap; src: url('../fonts/InterVariable.woff2') format('woff2'); }
@font-face { font-family: InterVariable; font-style: italic; font-weight: 100 900; font-display: swap; src: url('../fonts/InterVariable-Italic.woff2') format('woff2'); }
/* Legacy name used by the Tailwind config */
@font-face { font-family: 'Inter var'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('../fonts/InterVariable.woff2') format('woff2'); }
@font-face { font-family: 'Inter var'; font-style: italic; font-weight: 100 900; font-display: swap; src: url('../fonts/InterVariable-Italic.woff2') format('woff2'); }

/* ── Theme toggle button ──────────────────────────────────────────────── */
/* Light mode shows a drawn moon (thin stroke); dark mode shows the text sun symbol ☀ */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  font-family: 'Segoe UI Symbol', 'Apple Symbols', 'Noto Sans Symbols 2', 'DejaVu Sans', system-ui, sans-serif;
  font-size: 16px; line-height: 1; color: #94a3b8;
  transition: color 150ms, background-color 150ms;
}
.theme-toggle:hover { color: #1e40af; background: #f1f5f9; }

/* Logo in dark mode: the image has a white background, so show it on a deliberate white tile */
html.dark .site-logo { background: #ffffff; border-radius: 7px; padding: 2px; box-sizing: content-box; }
.theme-toggle:focus-visible { outline: 2px solid #1e40af; outline-offset: 2px; }
.theme-toggle .icon-sun { display: none; }
html.dark .theme-toggle .icon-sun { display: block; }
html.dark .theme-toggle .icon-moon { display: none; }

/* ── Dark palette ─────────────────────────────────────────────────────── */
html.dark {
  color-scheme: dark;
  --cr-bg: #0d1117;
  --cr-surface: #151b24;
  --cr-surface-2: #1b2330;
  --cr-surface-3: #232d3b;
  --cr-surface-4: #2e3a4b;
  --cr-line-soft: #1f2833;
  --cr-line: #2a3442;
  --cr-line-strong: #3a4657;
  --cr-text: #e6eaf0;
  --cr-text-2: #d3dae3;
  --cr-text-3: #b8c1cc;
  --cr-muted: #9aa4b2;
  --cr-faint: #8a95a5;
  --cr-fainter: #5f6b7b;
  --cr-brand: #8ab0ff;
  --cr-brand-fill: #2f5bd3;
  --cr-brand-fill-hover: #284fbb;
  background: var(--cr-bg);
}

/* Page, surfaces */
html.dark body,
html.dark body.bg-white { background: var(--cr-bg); color: var(--cr-text); }
html.dark .bg-white,
html.dark .bg-white\/90 { background-color: var(--cr-surface); }
html.dark .bg-slate-50,
html.dark .bg-\[\#f2f7f5\],
html.dark .bg-\[\#f0f7ff\],
html.dark .bg-blue-50\/30 { background-color: var(--cr-surface-2); }
html.dark .bg-slate-100 { background-color: var(--cr-surface-3); }
html.dark .bg-slate-200 { background-color: var(--cr-surface-4); }
html.dark .bg-slate-300 { background-color: var(--cr-line-strong); }

html.dark .hover\:bg-slate-50:hover { background-color: var(--cr-surface-2); }
html.dark .hover\:bg-slate-100:hover { background-color: var(--cr-surface-3); }
html.dark .hover\:bg-slate-200:hover { background-color: var(--cr-surface-4); }

/* Tinted status backgrounds */
html.dark .bg-blue-50, html.dark .bg-indigo-50, html.dark .bg-brand\/5, html.dark .bg-brand\/8, html.dark .bg-brand\/10 { background-color: rgba(138, 176, 255, 0.12); }
html.dark .bg-blue-100 { background-color: rgba(138, 176, 255, 0.2); }
html.dark .bg-green-50, html.dark .bg-green-50\/40, html.dark .bg-teal-50 { background-color: rgba(74, 222, 128, 0.1); }
html.dark .bg-green-100 { background-color: rgba(74, 222, 128, 0.18); }
html.dark .bg-amber-50, html.dark .bg-yellow-50, html.dark .bg-orange-50 { background-color: rgba(245, 181, 68, 0.1); }
html.dark .bg-amber-100, html.dark .bg-yellow-100 { background-color: rgba(245, 181, 68, 0.18); }
html.dark .bg-red-50 { background-color: rgba(248, 113, 113, 0.1); }
html.dark .bg-red-100 { background-color: rgba(248, 113, 113, 0.18); }
html.dark .bg-violet-50 { background-color: rgba(167, 139, 250, 0.1); }
html.dark .bg-violet-100 { background-color: rgba(167, 139, 250, 0.18); }

html.dark .hover\:bg-blue-50:hover, html.dark .hover\:bg-brand\/5:hover, html.dark .focus\:bg-brand\/5:focus { background-color: rgba(138, 176, 255, 0.12); }
html.dark .hover\:bg-blue-100:hover { background-color: rgba(138, 176, 255, 0.2); }
html.dark .hover\:bg-green-50:hover { background-color: rgba(74, 222, 128, 0.1); }
html.dark .hover\:bg-green-100:hover { background-color: rgba(74, 222, 128, 0.18); }
html.dark .hover\:bg-amber-50:hover { background-color: rgba(245, 181, 68, 0.1); }
html.dark .hover\:bg-amber-100:hover { background-color: rgba(245, 181, 68, 0.18); }
html.dark .hover\:bg-red-50:hover { background-color: rgba(248, 113, 113, 0.1); }
html.dark .hover\:bg-red-100:hover { background-color: rgba(248, 113, 113, 0.18); }

/* Brand fills: a lighter blue so white text keeps its contrast */
html.dark .bg-brand { background-color: var(--cr-brand-fill); }
html.dark .hover\:bg-brand:hover { background-color: var(--cr-brand-fill); }
html.dark .hover\:bg-brand-dark:hover,
html.dark .hover\:bg-blue-700:hover { background-color: var(--cr-brand-fill-hover); }

/* Text */
html.dark .text-\[\#111c17\],
html.dark .text-slate-900,
html.dark .text-slate-800 { color: var(--cr-text); }
html.dark .text-slate-700 { color: var(--cr-text-2); }
html.dark .text-slate-600 { color: var(--cr-text-3); }
html.dark .text-slate-500 { color: var(--cr-muted); }
html.dark .text-slate-400 { color: var(--cr-faint); }
html.dark .text-slate-300 { color: var(--cr-fainter); }
html.dark .text-slate-200 { color: var(--cr-line-strong); }
html.dark .hover\:text-slate-600:hover,
html.dark .hover\:text-slate-700:hover,
html.dark .hover\:text-slate-900:hover,
html.dark .group:hover .group-hover\:text-slate-900 { color: var(--cr-text); }

html.dark .text-brand,
html.dark .hover\:text-brand:hover,
html.dark .group:hover .group-hover\:text-brand { color: var(--cr-brand); }
/* Buttons that turn into a brand fill on hover keep white text */
html.dark .hover\:text-white:hover { color: #fff; }

html.dark .text-green-600, html.dark .text-green-700, html.dark .text-green-800, html.dark .hover\:text-green-600:hover, html.dark .hover\:text-green-800:hover { color: #86efac; }
html.dark .text-red-600, html.dark .text-red-700, html.dark .hover\:text-red-600:hover { color: #fca5a5; }
html.dark .text-amber-600, html.dark .text-amber-700, html.dark .text-amber-800, html.dark .text-amber-900, html.dark .hover\:text-amber-900:hover { color: #fcd34d; }
html.dark .text-yellow-700, html.dark .text-yellow-800 { color: #fde68a; }
html.dark .text-blue-600, html.dark .text-blue-700, html.dark .hover\:text-blue-600:hover, html.dark .hover\:text-blue-700:hover { color: #93c5fd; }
html.dark .text-teal-700 { color: #5eead4; }
html.dark .text-orange-700 { color: #fdba74; }
html.dark .text-violet-700 { color: #c4b5fd; }
html.dark .text-indigo-600 { color: #a5b4fc; }
html.dark .text-sky-700 { color: #7dd3fc; }

/* Borders and dividers */
html.dark .border-slate-100 { border-color: var(--cr-line-soft); }
html.dark .border-slate-200 { border-color: var(--cr-line); }
html.dark .border-slate-300,
html.dark .hover\:border-slate-200:hover,
html.dark .hover\:border-slate-300:hover { border-color: var(--cr-line-strong); }
html.dark .divide-slate-50 > :not([hidden]) ~ :not([hidden]),
html.dark .divide-slate-100 > :not([hidden]) ~ :not([hidden]) { border-color: var(--cr-line-soft); }
html.dark .border-blue-200, html.dark .border-brand\/20, html.dark .border-brand\/30 { border-color: rgba(138, 176, 255, 0.3); }
html.dark .border-green-200, html.dark .border-teal-200 { border-color: rgba(74, 222, 128, 0.3); }
html.dark .border-amber-100, html.dark .border-amber-200, html.dark .border-amber-300, html.dark .border-yellow-300, html.dark .border-orange-200 { border-color: rgba(245, 181, 68, 0.3); }
html.dark .border-red-100, html.dark .border-red-200, html.dark .border-red-300 { border-color: rgba(248, 113, 113, 0.32); }
html.dark .border-violet-200 { border-color: rgba(167, 139, 250, 0.3); }
html.dark .border-brand,
html.dark .hover\:border-brand:hover { border-color: var(--cr-brand); }

/* Form fields: readable text, caret and placeholder in dark mode */
html.dark input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="submit"]):not([type="button"]),
html.dark textarea,
html.dark select,
html.dark [contenteditable="true"] {
  color: var(--cr-text);
  caret-color: var(--cr-text);
  border-color: var(--cr-line);
}
/* Fields keep a transparent background when they sit inside a styled box */
html.dark input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="submit"]):not([type="button"]):not(.bg-transparent),
html.dark textarea:not(.bg-transparent),
html.dark select:not(.bg-transparent),
html.dark [contenteditable="true"]:not(.bg-transparent) { background-color: var(--cr-surface-2); }
html.dark input::placeholder,
html.dark textarea::placeholder { color: var(--cr-faint); opacity: 1; }
html.dark [contenteditable][data-placeholder][data-empty]::before { color: var(--cr-faint); }
html.dark select option { background-color: var(--cr-surface); color: var(--cr-text); }
html.dark input:-webkit-autofill,
html.dark textarea:-webkit-autofill {
  -webkit-text-fill-color: var(--cr-text);
  box-shadow: 0 0 0 1000px var(--cr-surface-2) inset;
}

/* Components defined in base.html */
html.dark .md-content code,
html.dark .md-content pre { background: var(--cr-surface-3); }
html.dark .md-content blockquote { border-left-color: var(--cr-line-strong); color: var(--cr-muted); }
html.dark .vsw-active { background: var(--cr-surface-3); }
html.dark .paper-card:hover { border-color: rgba(138, 176, 255, 0.45); box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35); }
html.dark .theme-toggle { color: var(--cr-faint); }
html.dark .theme-toggle:hover { color: var(--cr-brand); background: var(--cr-surface-3); }
html.dark .theme-toggle:focus-visible { outline-color: var(--cr-brand); }

/* Guided tour tooltip (styles injected by static/js/tour.js) */
html.dark #cr-tour-tip { background: var(--cr-surface); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--cr-line); }
html.dark #cr-tour-tip code { background: var(--cr-surface-3); }
html.dark #cr-tour-step-label { color: var(--cr-muted); }
html.dark #cr-tour-title { color: var(--cr-text); }
html.dark #cr-tour-body { color: var(--cr-text-3); }
