/* ==============================================================
   shitheads.app - Dynamic Theme Engine & CSS Custom Properties
   High-contrast, user-tunable color palette with darkmode violet default
   ============================================================== */

:root {
  color-scheme: dark;
  accent-color: var(--accent-primary);
  scrollbar-color: var(--border-subtle) transparent;
  scrollbar-width: thin;
  scroll-behavior: smooth;

  /* Default: Deep Violet Theme (High Contrast) */
  --bg-main: #0b0816;
  --bg-surface: #130e24;
  --bg-card: #1b1433;
  --bg-card-hover: #271d47;
  --bg-glass: rgba(19, 14, 36, 0.85);
  
  --border-subtle: #34255c;
  --border-focus: #a855f7;
  
  --text-main: #ffffff;
  --text-muted: #cbd5e1;
  --text-dim: #94a3b8;
  
  --accent-primary: #a855f7;
  --accent-secondary: #c084fc;
  --accent-glow: rgba(168, 85, 247, 0.35);
  
  --status-online: #10b981;
  --status-busy: #f59e0b;
  --status-offline: #ef4444;

  --terminal-bg: #07050d;
  --terminal-text: #c084fc;
}

/* ==============================================================
   Modern Web Standards: Typography, Form States & Optimization
   ============================================================== */

/* Typography: Balanced Headings & Pretty Body Copy (Eliminates Runts/Orphans) */
h1, h2, h3, h4, h5, h6, .text-balance {
  text-wrap: balance;
}

p, blockquote, li, .pretty-text {
  text-wrap: pretty;
}

/* Accessible Focus Visible Rings */
:focus-visible {
  outline: 2px solid var(--accent-primary) !important;
  outline-offset: 2px !important;
}

/* High-Contrast Interactive Form Validation Feedback */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):user-invalid,
textarea:user-invalid,
select:user-invalid {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 1px #ef4444 !important;
}

/* Off-Screen Rendering & Paint Optimization */
.service-card, .defer-render {
  content-visibility: auto;
  contain-intrinsic-size: 1px 260px;
}

/* Custom Scrollbars (Webkit Fallback) */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background-color: var(--border-subtle);
  border-radius: 9999px;
  border: 1px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background-color: var(--accent-primary);
}

/* Respect User Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Theme Preset: Deep Violet (Default) */
html[data-theme="deep-violet"] {
  --bg-main: #0b0816;
  --bg-surface: #130e24;
  --bg-card: #1b1433;
  --bg-card-hover: #271d47;
  --bg-glass: rgba(19, 14, 36, 0.85);
  --border-subtle: #34255c;
  --border-focus: #a855f7;
  --text-main: #ffffff;
  --text-muted: #cbd5e1;
  --text-dim: #94a3b8;
  --accent-primary: #a855f7;
  --accent-secondary: #c084fc;
  --accent-glow: rgba(168, 85, 247, 0.35);
  --terminal-bg: #07050d;
  --terminal-text: #c084fc;
}

/* Theme Preset: Cyberpunk Neon */
html[data-theme="cyberpunk-neon"] {
  --bg-main: #040714;
  --bg-surface: #0a1128;
  --bg-card: #101b3d;
  --bg-card-hover: #182754;
  --bg-glass: rgba(10, 17, 40, 0.85);
  --border-subtle: #1e2f60;
  --border-focus: #06b6d4;
  --text-main: #ffffff;
  --text-muted: #cbd5e1;
  --text-dim: #94a3b8;
  --accent-primary: #f43f5e;
  --accent-secondary: #06b6d4;
  --accent-glow: rgba(244, 63, 94, 0.35);
  --terminal-bg: #02050e;
  --terminal-text: #06b6d4;
}

/* Theme Preset: Emerald Matrix */
html[data-theme="emerald-matrix"] {
  --bg-main: #050e09;
  --bg-surface: #0a1c12;
  --bg-card: #112b1d;
  --bg-card-hover: #183d29;
  --bg-glass: rgba(10, 28, 18, 0.85);
  --border-subtle: #1e4a33;
  --border-focus: #10b981;
  --text-main: #ffffff;
  --text-muted: #cbd5e1;
  --text-dim: #86efac;
  --accent-primary: #10b981;
  --accent-secondary: #34d399;
  --accent-glow: rgba(16, 185, 129, 0.35);
  --terminal-bg: #020704;
  --terminal-text: #34d399;
}

/* Theme Preset: Obsidian Slate */
html[data-theme="obsidian-slate"] {
  --bg-main: #080c14;
  --bg-surface: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --bg-glass: rgba(15, 23, 42, 0.85);
  --border-subtle: #334155;
  --border-focus: #6366f1;
  --text-main: #ffffff;
  --text-muted: #cbd5e1;
  --text-dim: #94a3b8;
  --accent-primary: #6366f1;
  --accent-secondary: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.35);
  --terminal-bg: #04070d;
  --terminal-text: #cbd5e1;
}

/* Theme Preset: Ocean Abyss */
html[data-theme="ocean-abyss"] {
  --bg-main: #030d1a;
  --bg-surface: #081a33;
  --bg-card: #0e274c;
  --bg-card-hover: #143769;
  --bg-glass: rgba(8, 26, 51, 0.85);
  --border-subtle: #17427a;
  --border-focus: #0284c7;
  --text-main: #ffffff;
  --text-muted: #cbd5e1;
  --text-dim: #7dd3fc;
  --accent-primary: #0284c7;
  --accent-secondary: #38bdf8;
  --accent-glow: rgba(2, 132, 199, 0.35);
  --terminal-bg: #02070f;
  --terminal-text: #38bdf8;
}

/* Theme Preset: Crimson Red */
html[data-theme="crimson-red"] {
  --bg-main: #100508;
  --bg-surface: #1c090e;
  --bg-card: #2c0e16;
  --bg-card-hover: #3f1520;
  --bg-glass: rgba(28, 9, 14, 0.85);
  --border-subtle: #4c1624;
  --border-focus: #ef4444;
  --text-main: #ffffff;
  --text-muted: #fecdd3;
  --text-dim: #f43f5e;
  --accent-primary: #ef4444;
  --accent-secondary: #fb7185;
  --accent-glow: rgba(239, 68, 68, 0.35);
  --terminal-bg: #070204;
  --terminal-text: #fb7185;
}

/* User Custom Theme - All individual color channels dynamically bound */
html[data-theme="custom"] {
  --bg-main: var(--custom-bg-main, #0b0816);
  --bg-surface: var(--custom-bg-surface, #130e24);
  --bg-card: var(--custom-bg-card, #1b1433);
  --bg-card-hover: var(--custom-bg-card-hover, #271d47);
  --bg-glass: var(--custom-bg-surface, rgba(19, 14, 36, 0.85));
  --border-subtle: var(--custom-border-subtle, #34255c);
  --border-focus: var(--custom-border-focus, #a855f7);
  --accent-primary: var(--custom-accent-primary, #a855f7);
  --accent-secondary: var(--custom-accent-secondary, #c084fc);
  --accent-glow: var(--custom-accent-primary, rgba(168, 85, 247, 0.35));
  --text-main: var(--custom-text-main, #ffffff);
  --text-muted: var(--custom-text-muted, #cbd5e1);
  --text-dim: var(--custom-text-dim, #94a3b8);
  --terminal-bg: var(--custom-terminal-bg, #07050d);
  --terminal-text: var(--custom-terminal-text, #c084fc);
}

/* Global Reset & Base Styling */
body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Thematic Utility Classes */
.bg-theme-main { background-color: var(--bg-main) !important; }
.bg-theme-surface { background-color: var(--bg-surface) !important; }
.bg-theme-card { background-color: var(--bg-card) !important; }
.bg-theme-card:hover { background-color: var(--bg-card-hover) !important; }
.bg-theme-glass {
  background-color: var(--bg-glass) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.border-theme-subtle { border-color: var(--border-subtle) !important; }
.border-theme-accent { border-color: var(--accent-primary) !important; }

/* Text Color Utilities (High Contrast Guaranteed) */
.text-theme-main { color: var(--text-main) !important; }
.text-theme-muted { color: var(--text-muted) !important; }
.text-theme-dim { color: var(--text-dim) !important; }
.text-theme-accent { color: var(--accent-primary) !important; }
.text-theme-accent-sec { color: var(--accent-secondary) !important; }

/* Primary Accent Buttons & Badges */
.bg-theme-accent {
  background-color: var(--accent-primary) !important;
  color: #ffffff !important;
}
.bg-theme-accent:hover {
  filter: brightness(1.12);
}

.accent-glow-box {
  box-shadow: 0 0 25px var(--accent-glow);
}

.accent-glow-text {
  text-shadow: 0 0 12px var(--accent-glow);
}

/* Monospace Terminal Styling */
.terminal-window {
  background-color: var(--terminal-bg) !important;
  border: 1px solid var(--border-subtle);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: var(--terminal-text) !important;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.85), 0 0 20px var(--accent-glow);
}

.terminal-scroll::-webkit-scrollbar {
  width: 8px;
}
.terminal-scroll::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.4);
}
.terminal-scroll::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 4px;
}
.terminal-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* Button & Interactive Elements Readability */
button, a.button {
  transition: all 0.15s ease-in-out;
}

/* Form Inputs Styling */
input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
  color: #ffffff !important;
  background-color: var(--bg-card) !important;
  border: 1px solid var(--border-subtle) !important;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
  border-color: var(--border-focus) !important;
  outline: none;
}

/* Custom Toast Alerts */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--accent-primary);
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 12px 35px rgba(0,0,0,0.6);
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Markdown & Rich Forum Content Styles */
.prose-forum {
  color: var(--text-main);
  line-height: 1.7;
}
.prose-forum h1, .prose-forum h2, .prose-forum h3, .prose-forum h4 {
  color: #ffffff;
  font-weight: 700;
  margin-top: 1.2em;
  margin-bottom: 0.5em;
}
.prose-forum h1 { font-size: 1.5rem; }
.prose-forum h2 { font-size: 1.25rem; }
.prose-forum h3 { font-size: 1.1rem; }
.prose-forum p { margin-bottom: 0.85em; }
.prose-forum strong { color: #ffffff; font-weight: 700; }
.prose-forum em { color: #e2e8f0; font-style: italic; }
.prose-forum del, .prose-forum s { color: var(--text-dim); }
.prose-forum a {
  color: var(--accent-secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.prose-forum a:hover {
  color: #ffffff;
}
.prose-forum code {
  background-color: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border-subtle);
  color: var(--accent-secondary);
  padding: 0.15rem 0.4rem;
  border-radius: 0.375rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875em;
}
.prose-forum pre {
  background-color: var(--terminal-bg, #09090b);
  border: 1px solid var(--border-subtle);
  border-radius: 0.75rem;
  padding: 1rem;
  overflow-x: auto;
  margin: 1em 0;
}
.prose-forum pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--terminal-text, #f4f4f5);
  font-size: 0.85rem;
}
.prose-forum blockquote {
  border-left: 3px solid var(--accent-primary);
  padding: 0.5rem 1rem;
  margin: 1em 0;
  color: var(--text-muted);
  font-style: italic;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 0 0.5rem 0.5rem 0;
}
.prose-forum ul {
  list-style-type: disc;
  padding-left: 1.5rem;
  margin: 0.75em 0;
}
.prose-forum ol {
  list-style-type: decimal;
  padding-left: 1.5rem;
  margin: 0.75em 0;
}
.prose-forum li {
  margin-bottom: 0.35em;
}
.prose-forum hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: 1.5em 0;
}
.prose-forum table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
}
.prose-forum th, .prose-forum td {
  border: 1px solid var(--border-subtle);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.prose-forum th {
  background-color: var(--bg-card);
  font-weight: 700;
  color: #ffffff;
}

/* Discord-Style Spoiler Tags */
.forum-spoiler {
  background-color: rgba(255, 255, 255, 0.18);
  color: transparent !important;
  border-radius: 4px;
  padding: 1px 6px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  display: inline-block;
}
.forum-spoiler:hover {
  background-color: rgba(255, 255, 255, 0.28);
}
.forum-spoiler.revealed {
  color: inherit !important;
  background-color: rgba(255, 255, 255, 0.08);
  user-select: text;
}

/* ==============================================================
   Universal Code Copy Button
   ============================================================== */
.code-copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: inherit;
  color: #cbd5e1;
  background-color: rgba(24, 24, 27, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.5rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  backdrop-filter: blur(4px);
  z-index: 10;
}
pre:hover .code-copy-btn, div.highlight:hover .code-copy-btn {
  opacity: 1;
}
.code-copy-btn:hover {
  color: #ffffff;
  background-color: rgba(39, 39, 42, 0.95);
  border-color: var(--accent-primary);
}
.code-copy-btn.copied {
  opacity: 1;
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.5);
}

/* ==============================================================
   Blog Table of Contents (TOC) & Reading Enhancements
   ============================================================== */
#reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  z-index: 9999;
  transition: width 0.1s ease-out;
  width: 0%;
}

.toc-container .toc ul {
  list-style: none;
  padding-left: 0.75rem;
  margin: 0.35rem 0;
  border-left: 1px solid var(--border-subtle);
}
.toc-container .toc > ul {
  padding-left: 0;
  border-left: none;
}
.toc-container .toc li {
  margin: 0.3rem 0;
}
.toc-container .toc a {
  display: block;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: #94a3b8;
  text-decoration: none;
  transition: color 0.15s ease, transform 0.15s ease;
  padding: 0.15rem 0.5rem;
  border-radius: 0.375rem;
}
.toc-container .toc a:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.05);
}
.toc-container .toc a.active {
  color: var(--accent-secondary);
  font-weight: 700;
  background-color: var(--accent-glow);
}

/* Blog Prose Styling */
.prose-blog {
  color: #e2e8f0;
  line-height: 1.8;
  font-size: 1.0625rem;
}
.prose-blog h1, .prose-blog h2, .prose-blog h3, .prose-blog h4 {
  color: #ffffff;
  font-weight: 800;
  letter-spacing: -0.02em;
  scroll-margin-top: 5.5rem;
}
.prose-blog h1 { font-size: 2rem; margin-top: 2rem; margin-bottom: 1rem; }
.prose-blog h2 { font-size: 1.5rem; margin-top: 2.25rem; margin-bottom: 0.85rem; border-bottom: 1px solid var(--border-subtle); padding-bottom: 0.4rem; }
.prose-blog h3 { font-size: 1.25rem; margin-top: 1.75rem; margin-bottom: 0.65rem; }
.prose-blog p { margin: 1.25em 0; }
.prose-blog a { color: var(--accent-secondary); text-decoration: underline; text-underline-offset: 3px; }
.prose-blog a:hover { color: #ffffff; }
.prose-blog strong { color: #ffffff; font-weight: 700; }
.prose-blog blockquote {
  border-left: 4px solid var(--accent-primary);
  background: var(--bg-surface);
  padding: 0.85rem 1.25rem;
  margin: 1.5em 0;
  border-radius: 0 0.75rem 0.75rem 0;
  font-style: italic;
  color: #cbd5e1;
}
.prose-blog ul { list-style-type: disc; padding-left: 1.75rem; margin: 1em 0; }
.prose-blog ol { list-style-type: decimal; padding-left: 1.75rem; margin: 1em 0; }
.prose-blog li { margin-bottom: 0.4em; }
.prose-blog img {
  border-radius: 1rem;
  max-width: 100%;
  height: auto;
  margin: 1.5em auto;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}
.prose-blog pre {
  position: relative;
  background-color: var(--terminal-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 0.85rem;
  padding: 1.25rem;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 1.5em 0;
}
.prose-blog code:not(pre code) {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background-color: var(--bg-surface);
  color: var(--accent-secondary);
  border: 1px solid var(--border-subtle);
  padding: 0.15rem 0.4rem;
  border-radius: 0.375rem;
  font-size: 0.875em;
}
.prose-blog table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.95rem;
}
.prose-blog th, .prose-blog td {
  border: 1px solid var(--border-subtle);
  padding: 0.65rem 0.85rem;
  text-align: left;
}
.prose-blog th {
  background-color: var(--bg-card);
  color: #ffffff;
  font-weight: 700;
}

