/* User Menu dropdown + preferences overrides */

.user-menu-dropdown {
  background-color: rgba(0, 29, 53, 0.85);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.375rem; /* compact like standard menus */
}
.user-menu-dropdown.hidden { display: none; }
.user-menu-dropdown button,
.user-menu-dropdown label,
.user-menu-dropdown select {
  font-size: 0.875rem;
}

/* Themed segmented control for theme options */
.theme-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
.menu-group { padding: 0.25rem; border-radius: 0.5rem; }
.menu-group:hover { background: rgba(255,255,255,0.04); }
.menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.5rem;
  border-radius: 0.375rem;
  color: #e5e7eb;
  background: transparent;
  border: 0;
  text-align: left;
}
.menu-item:hover { background: rgba(255,255,255,0.06); }
.menu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.menu-danger { color: #fecaca; }
.menu-danger:hover { background: rgba(239,68,68,0.15); }
.theme-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0, 29, 53, 0.35);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  color: #fff;
  transition: background-color .2s ease, border-color .2s ease;
  position: relative;
  overflow: hidden;
}
.theme-opt:hover { background: rgba(0, 29, 53, 0.5); }
.theme-opt.active {
  border-color: var(--accent);
  background: rgba(0, 67, 70, 0.55);
  box-shadow: 0 0 12px rgba(0, 180, 216, 0.25);
}
.theme-opt::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  transform: translateX(-150%);
  will-change: transform;
}
.theme-opt:hover::after { transform: translateX(150%); transition: transform 0.6s ease-in-out; }
.theme-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 9999px;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.25) inset;
}
.dot-cosmic { background: linear-gradient(135deg, var(--primary), var(--accent)); }
.dot-black { background: #0b0b0b; box-shadow: 0 0 0 2px #111827 inset; }
.dot-white { background: #f7fafc; box-shadow: 0 0 0 2px #d1d5db inset; }
.dot-system {
  background: linear-gradient(90deg, #0b0b0b 0 50%, #f7fafc 50% 100%);
  box-shadow: 0 0 0 2px #9ca3af inset;
}
/* In reduced motion, remove glint on theme options */
html.reduced-motion .theme-opt::after { display: none !important; content: none !important; }

/* Reduced motion: keep gradients and small element animations, but stop whole-card morphing */
html.reduced-motion .card { transition-property: background-color, border-color, color, opacity !important; }
html.reduced-motion .card:hover,
html.reduced-motion .card:focus-within {
  transform: none !important; /* prevent lift/translate/scale */
}
/* Also neutralize module card hover lifts */
html.reduced-motion .module-card { transition-property: background-color, border-color, color, opacity !important; transform: none !important; }
html.reduced-motion .module-card:hover,
html.reduced-motion .module-card:focus-within { transform: none !important; }
/* Remove button shine/glint in reduced motion */
html.reduced-motion .button::after,
html.reduced-motion .message-type-switcher::after { display: none !important; content: none !important; }

/* Ensure toggle switches don't visually overflow their bounds */
.toggle-switch-sm, .toggle-switch { overflow: hidden; }
/* Keep the knob visible and contained */
.toggle-switch-sm .toggle-slider, .toggle-switch .toggle-slider { overflow: hidden; position: absolute; inset: 0; }
.toggle-switch-sm .toggle-slider:before, .toggle-switch .toggle-slider:before { z-index: 1; display: block; }
/* Use left for travel to avoid transform clipping on some browsers */
.toggle-switch-sm .toggle-slider:before { left: 0.25rem !important; transform: none !important; transition: left 0.2s ease-in-out !important; }
.toggle-switch-sm input:checked + .toggle-slider:before { left: 1.5rem !important; transform: none !important; }

/* Theme hooks via data-theme on <html> */
html[data-theme="white"] {
  /* Light mode with blue-tinted scheme (Coolors palette reference) */
  --bg: #eaf6fb;  /* near CAF0F8 */
  --bg3: #d9eef7; /* near 90E0EF */
  --bg2: rgba(255, 255, 255, 0.70); /* frosted base for panels/dropdowns */
  --secondary: #0077b6; /* heading/accent text */
  --primary: #00b4d8;   /* accent */
  /* subtle tint accents for frosted glass */
  --glass-magenta: rgba(236, 72, 153, 0.10); /* tailwind rose-500 ~ec4899 */
  --glass-orange: rgba(249, 115, 22, 0.08);  /* tailwind orange-500 ~f97316 */
}
html[data-theme="black"] {
  --bg: #0b0b0b;
  --bg3: #0f172a;
  --secondary: #e5e7eb;
  --primary: #ff7b00;
}
/* cosmic/system use existing defaults from Tailwind source */

/* High contrast theme: strong separation and vivid accents */
html[data-theme="high-contrast"] {
  --bg: #000000;
  --bg3: #0a0a0a;
  --secondary: #ffffff;
  --primary: #00e5ff; /* brighter accent */
}

/* Card overrides to better fit themes (since base uses fixed rgba) */
html[data-theme="white"] .card {
  /* Frosted glass with gentle magenta/orange tint glows */
  background-image:
    radial-gradient(120% 120% at 0% 0%, var(--glass-magenta), transparent 60%),
    radial-gradient(120% 120% at 100% 0%, var(--glass-orange), transparent 60%),
    linear-gradient(180deg, rgba(255,255,255,0.78), rgba(255,255,255,0.72));
  background-color: transparent !important;
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  backdrop-filter: saturate(1.2) blur(10px);
  color: #0f172a;
  border-color: rgba(0, 0, 0, 0.10) !important;
  box-shadow: 0 18px 40px -18px rgba(0,0,0,0.18);
}
/* Module cards in light mode: clearer contrast */
html[data-theme="white"] .module-card {
  background-color: rgba(255, 255, 255, 0.8) !important;
  border-color: rgba(0,0,0,0.08) !important;
  color: #0f172a !important;
}
html[data-theme="white"] .module-card:hover { border-color: var(--accent) !important; }
html[data-theme="white"] .module-card-content h3 { color: #0f172a !important; }
html[data-theme="white"] .module-card-content p { color: #374151 !important; }
/* Legacy light background override no longer needed */
html[data-theme="white"] .post-card { background-color: transparent; }

html[data-theme="black"] .card {
  background-color: rgba(0, 10, 20, 0.85) !important;
  color: #e5e7eb;
  border-color: rgba(255,255,255,0.12) !important;
}

html[data-theme="high-contrast"] .card {
  background-color: #000 !important;
  color: #fff !important;
  border-color: #fff !important;
}

/* Menu adjusts with theme for readability */
html[data-theme="white"] .user-menu-dropdown { background-color: rgba(255,255,255,0.98); border-color: rgba(0,0,0,0.12); }
html[data-theme="white"] .menu-item { color: #111827; }
html[data-theme="white"] .menu-item:hover { background: rgba(0,0,0,0.06); }

html[data-theme="high-contrast"] .user-menu-dropdown { background-color: #000; border-color: #fff; }
html[data-theme="high-contrast"] .menu-item { color: #fff; }
html[data-theme="high-contrast"] .menu-item:hover { background: #111; }

/* -------- Global background + overlay tuning per theme -------- */
/* Default body fallback */
body { background-color: var(--bg3); }

/* Common overlay class */
.overlay { background-color: rgba(0, 29, 53, 0.55); }

/* Tailwind utility override for bg-black/50 so overlays adapt per theme */
/* Note: slash must be escaped in CSS selectors */
html[data-theme="white"] .bg-black\/50 { 
  background-color: rgba(255,255,255,0.65) !important; 
  background-image: linear-gradient(135deg, rgba(202,240,248,0.85), rgba(144,224,239,0.75) 40%, rgba(216,180,254,0.45) 75%, rgba(236,72,153,0.35));
}
html[data-theme="white"] .overlay { 
  background-color: rgba(255,255,255,0.65) !important; 
  background-image: linear-gradient(135deg, rgba(202,240,248,0.85), rgba(144,224,239,0.75) 40%, rgba(216,180,254,0.45) 75%, rgba(236,72,153,0.35));
}

/* Post/updates cards contrast in light mode */
html[data-theme="white"] .post-card {
  /* Match frosted card but slightly lighter for feed items */
  background-image:
    radial-gradient(120% 120% at 0% 0%, var(--glass-magenta), transparent 60%),
    radial-gradient(120% 120% at 100% 0%, var(--glass-orange), transparent 60%),
    linear-gradient(180deg, rgba(255,255,255,0.82), rgba(255,255,255,0.74));
  background-color: transparent !important;
  -webkit-backdrop-filter: saturate(1.15) blur(10px);
  backdrop-filter: saturate(1.15) blur(10px);
  border-color: rgba(0,0,0,0.08) !important;
}
html[data-theme="white"] .post-card h4 { color: #0f172a !important; }
html[data-theme="white"] .post-card p { color: #374151 !important; }

/* Channel dropdowns (selects) frosted in light theme */
html[data-theme="white"] .form-input {
  background-image: linear-gradient(180deg, rgba(255,255,255,0.78), rgba(255,255,255,0.72));
  background-color: transparent !important;
  -webkit-backdrop-filter: saturate(1.1) blur(8px);
  backdrop-filter: saturate(1.1) blur(8px);
  border-color: rgba(0,0,0,0.12) !important;
  color: #0f172a !important;
}
html[data-theme="white"] .form-input::placeholder { color: #6b7280 !important; }
/* Make native select arrow more visible against frosted bg in Windows */
html[data-theme="white"] select.form-input { color: #0f172a !important; }
html[data-theme="white"] select.form-input option { color: #0f172a; background: #ffffff; }

/* Markdown (developer feed) readability in light mode */
html[data-theme="white"] .markdown-body { color: #111827; }
html[data-theme="white"] .markdown-body h1,
html[data-theme="white"] .markdown-body h2,
html[data-theme="white"] .markdown-body h3,
html[data-theme="white"] .markdown-body h4,
html[data-theme="white"] .markdown-body h5,
html[data-theme="white"] .markdown-body h6 { color: #0f172a; }
html[data-theme="white"] .markdown-body a { color: #0077b6; }
html[data-theme="white"] .markdown-body p, 
html[data-theme="white"] .markdown-body li { color: #1f2937; }

html[data-theme="black"] .bg-black\/50 { background-color: rgba(0,0,0,0.5) !important; }
html[data-theme="black"] .overlay { background-color: rgba(0,0,0,0.5) !important; }

html[data-theme="high-contrast"] .bg-black\/50 { background-color: rgba(0,0,0,0.85) !important; }
html[data-theme="high-contrast"] .overlay { background-color: rgba(0,0,0,0.85) !important; }

/* -------- Light theme typography adjustments -------- */
/* Use dark greys for text on light backgrounds and tame overly-light grays */
html[data-theme="white"] body { color: #111827; }
html[data-theme="white"] .text-white { color: #111827 !important; }
html[data-theme="white"] .text-gray-300 { color: #374151 !important; }
html[data-theme="white"] .text-gray-400 { color: #4b5563 !important; }
html[data-theme="white"] .text-gray-500 { color: #6b7280 !important; }
/* Ensure headings that rely on white are readable */
html[data-theme="white"] h1,
html[data-theme="white"] h2,
html[data-theme="white"] h3,
html[data-theme="white"] h4,
html[data-theme="white"] h5,
html[data-theme="white"] h6 { color: #0f172a; }
