/*----------------------------------------------------------------------------
  Dark Mode Theme with CSS Custom Properties
----------------------------------------------------------------------------*/

:root {
  /* Light theme (fallback) */
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-tertiary: #f0f1f2;
  --text-primary: #333333;
  --text-secondary: #222222;
  --text-muted: #777777;
  --text-light: #bbbbbb;
  --text-lighter: #aaaaaa;
  --text-lightest: #999999;
  --border-color: #dddddd;
  --border-light: #eee;
  --accent-color: #2382c8;
  --accent-hover: #00bfff;
  --code-bg: #f4faff;
  --code-color: #556270;
  --pre-bg: #ffffff;
  --pre-color: #444444;
  --pre-border: #eeeeee;
  --blockquote-border: #aaaaaa;
  --blockquote-text: #999999;
  --figure-bg: #f5f5f5;
  --figure-border: #dddddd;
  --figure-caption-bg: #dddddd;
  --figure-caption-text: #666666;
  --table-bg: #ffffff;
  --table-border: #cccccc;
  --table-odd-bg: #f0f1f2;
  --shadow-color: rgba(0, 0, 0, 0.29);
  --text-shadow: 0 1px 0 rgba(255, 255, 255, 1);
  --logo-bg: #556270;
  --logo-shadow: 0 1px 0 rgba(255, 255, 255, 1);
}

[data-theme="dark"] {
  /* Dark theme - Dark Gray */
  --bg-primary: #121212;
  --bg-secondary: #1e1e1e;
  --bg-tertiary: #2a2a2a;
  --text-primary: #d8d8d8;
  --text-secondary: #c8c8c8;
  --text-muted: #a8a8a8;
  --text-light: #989898;
  --text-lighter: #888888;
  --text-lightest: #686868;
  --border-color: #333333;
  --border-light: #222222;
  --accent-color: #4a9eff;
  --accent-hover: #66b3ff;
  --code-bg: #1e1e1e;
  --code-color: #e8e8e8;
  --pre-bg: #1e1e1e;
  --pre-color: #e8e8e8;
  --pre-border: #333333;
  --blockquote-border: #444444;
  --blockquote-text: #b8b8b8;
  --figure-bg: #1e1e1e;
  --figure-border: #333333;
  --figure-caption-bg: #333333;
  --figure-caption-text: #b8b8b8;
  --table-bg: #1e1e1e;
  --table-border: #333333;
  --table-odd-bg: #2a2a2a;
  --shadow-color: rgba(0, 0, 0, 0.8);
  --text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
  --logo-bg: #333333;
  --logo-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

/* Apply theme variables to body */
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  text-shadow: var(--text-shadow);
  font-size: 16px;
  line-height: 1.4;
}

/* Text colors */
p {
  color: var(--text-secondary);
  font-size: 1.15em; /* Bumped by ~10% from 1.05em */
}

/* Lists */
ul,
ol {
  font-size: 1.1em;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text-primary);
}

h1 {
  font-size: 2.3em; /* Bumped by ~10% from 2.1em */
  margin-top: 2em; /* Added more space above H1 */
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  -moz-hyphens: auto;
  -ms-hyphens: auto;
}

h2 {
  font-size: 1.9em; /* Bumped by ~10% from 1.7em */
}

h3 {
  font-size: 1.4em; /* Bumped by ~10% from 1.3em */
  color: var(--text-primary);
}

h4 {
  font-size: 1.2em; /* Bumped by ~10% from 1.05em */
}

/* Links */
a {
  color: var(--accent-color);
}

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

/* Navigation */
ul.nav li a {
  color: var(--text-primary);
  font-size: 1.15em; /* Slightly bumped from 1.1em */
}

ul.nav li a:hover {
  color: var(--accent-hover);
}

ul.nav li.logo a {
  background: var(--logo-bg);
}

/* Top link */
a.top-link {
  color: var(--text-primary);
}

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

/* Logo shadow */
a.top-logo img {
}

a.top-logo img:hover {
}

/* Header social links */
.header-social {
  text-align: center;
  margin: 1em 0;
}

.header-social .social-media-icons {
  display: inline-block;
  margin: 0 0.5em;
  font-size: 1.3em;
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.3s ease;
}

.header-social .social-media-icons:hover {
  color: var(--accent-color);
}

/* HR */
hr {
  color: var(--border-color);
}

/* Listing styles */
.listing .post p.date {
  color: var(--text-light);
}

.listing .post h2 a {
  color: var(--text-primary);
  font-size: 2em;
}

.listing .post .post-summary {
  color: var(--text-muted);
  font-size: 1.05em; /* Slightly bumped from 1em */
}

.listing .post.other {
  color: var(--text-muted);
}

.listing .post.other h2 a {
  color: var(--text-primary);
}

.listing .post.other h2 a:hover {
  color: var(--accent-hover);
}

.listing .post.other .icon {
  color: var(--border-color);
}

.listing .post.other .icon:hover {
  color: var(--text-light);
}

.listing blockquote {
  border-left-color: var(--border-color);
}

/* Post styles */
p.date {
  color: var(--text-lighter);
}

p.intro {
  font-size: 1.25em; /* Slightly bumped from 1.2em */
}

p.intro a {
  color: var(--accent-color);
}

h1.words {
  color: #ff6b6b; /* Keep red for emphasis in both themes */
}

h1.link .desc {
  color: var(--text-primary);
}

h2,
h2 a,
h2 a:visited {
  color: var(--text-primary);
}

h2 a:hover {
  color: var(--text-primary);
}

h3 a,
h3 a:visited {
  color: var(--text-primary);
}

h3 a:hover {
  color: var(--text-primary);
}

h4 {
  color: var(--text-primary);
}

/* Pagination */
.pagination i {
  color: var(--text-primary);
}

/* Figures */
.figure {
  border: 1px solid var(--figure-border);
  background: var(--figure-bg);
}

.figure small {
  color: var(--figure-caption-text);
  background: var(--figure-caption-bg);
}

/* Blockquotes */
blockquote {
  border-left: 2px solid var(--blockquote-border);
}

blockquote p {
  color: var(--blockquote-text);
}

/* Tables */
table {
  background: var(--table-bg);
  border-top: 1px solid var(--table-border);
  border-bottom: 2px solid var(--table-border);
  color: var(--text-primary);
}

.odd td {
  background: var(--table-odd-bg);
}

/* Keep in touch */
.keep-in-touch {
  border-top: 1px solid var(--border-color);
}

.keep-in-touch p:first-child {
  border-top: 1px solid var(--bg-primary);
}

.keep-in-touch a {
  color: var(--accent-color);
}

/* Code styles are now in code.css */

/* Social media icons */
.social-media-icons {
  color: var(--text-primary);
  margin: 0 1em;
  text-decoration: none;
}

.social-media-icons:hover {
  text-decoration: none;
  color: var(--accent-color);
}

/* Footer styling */
.social {
  padding: 2em 0 2em 0;
  text-align: center;
  border-top: 1px solid var(--border-color);
  margin-top: 3em;
}

.pagination {
  padding: 1em 0 5em 0;
  text-align: center;
}

.pagination a {
  text-decoration: none;
  color: var(--text-primary);
}

.pagination a:hover {
  text-decoration: none;
  color: var(--accent-color);
}

/* Theme toggle container */
.theme-toggle-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  text-align: center;
  margin: 0;
}

/* Theme toggle button */
.theme-toggle {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
  border-radius: 50%;
  width: 52px;
  height: 52px;
  font-size: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  outline: none;
  -webkit-appearance: none;
  box-shadow: 0 2px 8px var(--shadow-color);
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.theme-toggle:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--border-color);
  transform: scale(1.05);
  box-shadow: 0 4px 12px var(--shadow-color);
}

.theme-toggle:focus {
  outline: none;
}

.theme-toggle:active {
  transform: scale(0.95);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--border-color);
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  -webkit-tap-highlight-color: transparent;
}

/* Syntax highlighting is now in code.css */

/* Responsive adjustments */
@media only screen and (max-width: 768px) {
  .theme-toggle {
    font-size: 25px;
    width: 62px;
    height: 62px;
  }

  /* Make navigation more compact on tablets */
  .nav li {
    margin: 0 2px;
    font-size: 18px;
  }

  .nav li a {
    margin-right: 6px;
  }

  /* Adjust header elements for mobile */
  .top-link {
    font-size: 1.2em;
  }

  .top-logo img {
    width: 77px;
  }

  .header-social .social-media-icons {
    font-size: 1.2em;
    margin: 0 0.3em;
  }

  /* Footer links vertical on tablets */
  .social {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5em;
  }

  .social .social-media-icons {
    margin: 0;
  }
}

@media only screen and (max-width: 520px) {
  .theme-toggle {
    font-size: 28px;
    width: 70px;
    height: 70px;
  }

  /* Stack navigation vertically on small screens */
  .nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
  }

  .nav li {
    display: block;
    margin: 5px 0;
    font-size: 15px;
  }

  .nav li a {
    margin-right: 0;
    padding: 5px 10px;
    display: block;
  }

  /* Make header more compact */
  .top-link {
    font-size: 1.1em;
  }

  .top-logo img {
    width: 66px;
  }

  .header-social {
    margin: 0.5em 0;
  }

  .header-social .social-media-icons {
    font-size: 1.1em;
    margin: 0 0.2em;
  }
}

@media only screen and (max-width: 400px) {
  /* Extra small screens - even more compact */
  .theme-toggle {
    font-size: 32px;
    width: 79px;
    height: 79px;
  }

  .nav li {
    font-size: 14px;
  }

  .top-logo img {
    width: 55px;
  }

  .header-social .social-media-icons {
    font-size: 1em;
  }
}
