/*
 * Dark Mode CSS Variables and Styles
 * Production-ready dark mode implementation for Reaction theme
 */

/* CSS Custom Properties for Dark Mode */
:root {
  /* Light mode colors (default) */
  --bg-primary: #fdfdfd;
  --bg-secondary: rgba(246, 246, 246, 0.5);
  --bg-pattern: url("../images/theme/backgrounds/bg-pattern-light.png");
  --text-primary: #333;
  --text-secondary: #666;
  --text-muted: #999;
  --link-color: #0066cc;
  --link-hover: #004499;
  --border-color: #ddd;
  --border-light: #fff;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --shadow-light: rgba(255, 255, 255, 0.8);
  --comment-bg: #fff;
  --comment-border: #eee;
  
  /* Transition for smooth theme switching */
  --transition-duration: 0.3s;
}

/* Dark mode colors - improved for better contrast */
[data-theme="dark"], 
.dark-mode {
  --bg-primary: #333;
  --bg-secondary: rgba(55, 55, 55, 1);
  --bg-pattern: url("../images/theme/backgrounds/bg-pattern.png");
  --text-primary: #F5F5F5;
  --text-secondary: #BBB;
  --text-muted: #999;
  --link-color: #73c9ff;
  --link-hover: #5ab7ed;
  --border-color: #444;
  --border-light: #555;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --shadow-light: rgba(255, 255, 255, 0.1);
  --comment-bg: #222;
  --comment-border: #111;
}

/* Apply CSS variables to existing styles */
body {
  background: var(--bg-primary);
  background: var(--bg-secondary);
  background: var(--bg-pattern) repeat;
  color: var(--text-primary);
  transition: background var(--transition-duration) ease, color var(--transition-duration) ease;
}

/* Title spans */
h2.title span, 
h1.title span,
ul.tabs li a.active {
  background: var(--bg-primary);
  background: var(--bg-secondary);
  background: var(--bg-pattern) repeat;
  transition: background var(--transition-duration) ease;
}

/* Links */
a {
  color: var(--link-color);
  transition: color var(--transition-duration) ease;
}

a:hover {
  color: var(--link-hover);
}

/* Text colors */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  transition: color var(--transition-duration) ease;
}

/* Override dark text elements for better dark mode contrast */
.dark-mode .subheader,
.dark-mode p.lead,
.dark-mode blockquote,
.dark-mode blockquote p {
  color: var(--text-secondary) !important;
}

.dark-mode blockquote cite,
.dark-mode blockquote cite a,
.dark-mode blockquote cite a:visited {
  color: var(--text-muted) !important;
}

.dark-mode strong {
  color: #E5E5E5 !important;
}

.dark-mode .tabs li a,
.dark-mode .vcard a,
.dark-mode .grid-example .example,
.dark-mode .portfolio-nav a.button,
.dark-mode #page-links a div {
  color: #DDD !important;
}

.dark-mode .sf-menu > li:hover a strong {
  color: #E5E5E5 !important;
}

.dark-mode .sf-menu > li:hover a span {
  color: #BBB !important;
}

.dark-mode .sf-menu.light ul li:hover a {
  color: #DDD !important;
}

.dark-mode .sf-menu.light ul {
  color: #CCC !important;
}

.dark-mode abbr,
.dark-mode acronym {
  color: #CCC !important;
}

/* HR dividers */
hr {
  border-color: var(--border-color);
  border-bottom-color: var(--border-light);
  transition: border-color var(--transition-duration) ease;
}

/* Comments */
.commentlist li.comment article {
  background: var(--comment-bg);
  border-color: var(--comment-border);
  transition: background var(--transition-duration) ease, border-color var(--transition-duration) ease;
}

/* Dark mode specific text shadows - improved for better contrast */
.dark-mode h1, 
.dark-mode h2, 
.dark-mode h3, 
.dark-mode h4, 
.dark-mode h5, 
.dark-mode h6 {  
  -webkit-text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
  -moz-text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
  -o-text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.dark-mode .sf-menu.light ul li a, 
.dark-mode th, 
.dark-mode tr,
.dark-mode #portfolio-filter span, 
.dark-mode .portfolio-view span,
.dark-mode #section-tophat, 
.dark-mode .feature span,
.dark-mode .superquote,
.dark-mode .supertagline,
.dark-mode #section-footer, 
.dark-mode #section-footer h5,
.dark-mode .sf-menu.light li u {  
  -webkit-text-shadow: 1px 0 1px #000;
  -moz-text-shadow: 1px 0 1px #000;
  -o-text-shadow: 1px 0 1px #000;
  text-shadow: 1px 0 1px #000;
}

/* Light mode text shadows */
:root .sf-menu li ul,
.dark-mode .sf-menu li ul {  
  -webkit-text-shadow: 1px 0 1px var(--border-light);
  -moz-text-shadow: 1px 0 1px var(--border-light);
  -o-text-shadow: 1px 0 1px var(--border-light);
  text-shadow: 1px 0 1px var(--border-light);
}

/* Dark mode toggle button styles */
.dark-mode-toggle {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all var(--transition-duration) ease;
  box-shadow: 0 2px 10px var(--shadow-color);
}

/* Responsive positioning */
@media (max-width: 767px) {
  .dark-mode-toggle {
    top: 60px;
    right: 15px;
    width: 45px;
    height: 45px;
    font-size: 18px;
  }
}

.dark-mode-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 15px var(--shadow-color);
}

.dark-mode-toggle:focus {
  outline: 2px solid var(--link-color);
  outline-offset: 2px;
}

/* Icon content for toggle */
.dark-mode-toggle::before {
  content: "🌙";
  transition: transform var(--transition-duration) ease;
}

.dark-mode .dark-mode-toggle::before {
  content: "☀️";
  transform: rotate(180deg);
}

/* System preference detection - DISABLED: Always default to light mode
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #333;
    --bg-secondary: rgba(55, 55, 55, 1);
    --bg-pattern: url("../images/theme/backgrounds/bg-pattern.png");
    --text-primary: #ccc;
    --text-secondary: #aaa;
    --text-muted: #888;
    --link-color: #73c9ff;
    --link-hover: #5ab7ed;
    --border-color: #444;
    --border-light: #555;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-light: rgba(255, 255, 255, 0.1);
    --comment-bg: #222;
    --comment-border: #111;
  }
  
  :root:not([data-theme="light"]) .dark-mode-toggle::before {
    content: "☀️";
    transform: rotate(180deg);
  }
}
*/

/* Ensure smooth transitions for all color-related properties */
* {
  transition-property: background-color, color, border-color, box-shadow;
  transition-duration: var(--transition-duration);
  transition-timing-function: ease;
}

/* Reset transitions for elements that shouldn't animate */
img, video, iframe, canvas, svg {
  transition: none !important;
}