/* styles.css */

/* ===========================
   1. CSS Variables
   =========================== */

/* Light Mode Variables */
:root {
  /* Colors */
  --background: #ffffff;
  --foreground: #000000;
  --toggle-bg: #e4e4e7;
  --toggle-fg: #18181b;
  --bg-color: #ffffff;
  --text-color: #000000;
  --link-color: #11AA22;
  --link-hover-color: #11AA22;
  --button-bg-color: #11AA22;
  --button-text-color: #ffffff;
  --input-bg-color: #ffffff;
  --input-text-color: #000000;
  --input-border-color: #ccc;

  /* Code Block Variables */
  --code-bg-color: #f6f8fa;
  --code-text-color: #24292e;
  --code-border-color: #e1e4e8;
  --code-lang-color: #0366d6;
  --code-header-bg: #f3f4f6;
  --code-header-text: #586069;
  --copy-button-color: #586069;
  --copy-button-hover-color: #0366d6;
  --copy-button-copied-color: #28a745;

  /* Syntax Highlighting Colors */
  --syntax-keyword: #d73a49;
  --syntax-string: #032f62;
  --syntax-built_in: #6f42c1;
  --syntax-function: #005cc5;
  --syntax-params: #6f42c1;
  --syntax-title: #6f42c1;

  /* Additional Variables */
  --spacing-small: 8px;
  --spacing-medium: 16px;
  --spacing-large: 24px;

  --border-radius-sm: 4px;
  --border-radius-md: 6px;
  --border-radius-lg: 8px;

  --shadow-sm: 0 1px 3px rgba(27,31,35,0.12), 0 1px 2px rgba(27,31,35,0.24);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);

  /* Additional Colors for Dark Mode */
  --link-color-dark-mode: #8ab4f8;
}

/* Dark Mode Variables */
body.dark-mode {
  /* Colors */
  --background: #000000;
  --foreground: #ffffff;
  --toggle-bg: #18181b;
  --toggle-fg: #e4e4e7;
  --bg-color: #121212;
  --text-color: #e0e0e0;
  --link-color: #11AA22;
  --link-hover-color: #11AA22;
  --button-bg-color: #11AA22;
  --button-text-color: #ffffff;
  --input-bg-color: #1e1e1e;
  --input-text-color: #e0e0e0;
  --input-border-color: #555;

  /* Code Block Variables */
  --code-bg-color: #1e1e1e;
  --code-text-color: #e0e0e0;
  --code-border-color: #555;
  --code-lang-color: #8ab4f8;
  --code-header-bg: #2c2c2c;
  --code-header-text: #e0e0e0;
  --copy-button-color: #e0e0e0;
  --copy-button-hover-color: #ffffff;
  --copy-button-copied-color: #28a745;

  /* Syntax Highlighting Colors */
  --syntax-keyword: #ff7b72;
  --syntax-string: #9ece6a;
  --syntax-built_in: #c678dd;
  --syntax-function: #61afef;
  --syntax-params: #56b6c2;
  --syntax-title: #61afef;
}

/* ===========================
   2. Global Styles
   =========================== */

/* Apply Variables */
body {
  font-family: 'Fira Code', 'Courier New', Courier, monospace;
  font-size: 18px;
  line-height: 1.6;
  margin: 0;
  padding: 0 20px;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background-color 0.3s ease, color 0.3s ease;
  padding-bottom: 80px; /* Prevent overlap with the toggle */
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Fira Code', 'Courier New', Courier, monospace;
  font-weight: 700;
  margin-bottom: 0.5em;
}

h1 {
  font-size: 2.5em;
  text-align: center;
  color: #11AA22
}

h2 {
  font-size: 1.75em;
}

p {
  margin-bottom: 1em;
}

/* Links */
a {
  color: var(--link-color);
  text-decoration: underline;
  transition: color 0.3s ease, text-decoration 0.3s ease;
}

a:hover, a:focus {
  color: var(--link-hover-color);
  text-decoration: none;
}

/* Container */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===========================
   3. Header and Navigation
   =========================== */

header {
  padding: 40px 0 20px;
  border-bottom: 1px solid var(--code-border-color);
}

header h1 {
  margin: 0;
  font-size: 2.5em;
  text-align: center;
  color: #11AA22;
}

header p {
  margin: 0;
  font-size: 1.2em;
   text-align: center;
  color: var(--text-color);
}

nav {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 10px;
}

nav a {
  font-size: 1em;
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  color: var(--link-color);
  text-decoration: underline;
  transition: background-color 0.3s ease, color 0.3s ease;
}

nav a:hover, nav a:focus {
  background-color: var(--toggle-bg);
  color: var(--link-hover-color);
}

/* ===========================
   4. Main Content
   =========================== */

main {
  max-width: 800px;
  margin: 40px auto;
}

article h2 {
  font-family: 'Fira Code', 'Courier New', Courier, monospace;
  font-size: 1.75em;
  margin-bottom: 0.5em;
}

article p {
  margin-bottom: 1em;
}

/* ===========================
   5. Footer
   =========================== */

footer {
  padding: 20px 0;
  border-top: 1px solid var(--code-border-color);
  text-align: center;
  font-size: 0.9em;
  color: var(--text-color);
}

/* ===========================
   Social Share Styles
   =========================== */

.social-share {
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--code-bg-color);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--code-border-color);
  text-align: center;
}

.social-share h3 {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
  color: var(--text-color);
  font-weight: 600;
}

.social-share a {
  display: inline-block;
  margin: 0.5rem 0.75rem;
  padding: 0.75rem 1.25rem;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--border-radius-md);
  transition: all 0.2s ease;
  color: var(--text-color);
  background: var(--input-bg-color);
  border: 1px solid var(--input-border-color);
}

.social-share a:hover, .social-share a:focus {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-color: var(--link-color);
  color: var(--link-color);
}

@media (max-width: 768px) {
  .social-share {
    padding: 1rem;
  }
  
  .social-share a {
    display: block;
    margin: 0.5rem 0;
    text-align: center;
  }
}

/* ===========================
   6. Buttons
   =========================== */

button {
  background-color: var(--button-bg-color);
  color: var(--button-text-color);
  border: none;
  padding: 8px 16px;
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  transition: background-color 0.3s ease, transform 0.2s ease;
  box-shadow: var(--shadow-sm);
}

button:hover, button:focus {
  background-color: #005ea6; /* Darker shade of button-bg-color */
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ===========================
   7. Inputs and Textareas
   =========================== */

input, textarea {
  background-color: var(--input-bg-color);
  color: var(--input-text-color);
  border: 1px solid var(--input-border-color);
  padding: 10px;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 10px;
  border-radius: var(--border-radius-sm);
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--link-color);
}

/* ===========================
   8. Theme Toggle
   =========================== */

/* Theme Toggle Container */
.theme-toggle {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--toggle-bg);
  border-radius: 30px;
  padding: 4px;
  width: 60px;
  height: 34px;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.3s ease;
  z-index: 1000;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* Toggle Thumb */
.toggle-thumb {
  width: 26px;
  height: 26px;
  background-color: var(--background);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.3s ease, background-color 0.3s ease;
  position: relative;
}

body.dark-mode .toggle-thumb {
  transform: translateX(26px);
}

/* Icons within Toggle */
.icon {
  width: 16px;
  height: 16px;
}

.sun-icon, .moon-icon {
  position: absolute;
  transition: opacity 0.3s ease;
}

.sun-icon {
  opacity: 1;
}

body.dark-mode .sun-icon {
  opacity: 0;
}

.moon-icon {
  opacity: 0;
}

body.dark-mode .moon-icon {
  opacity: 1;
}

/* ===========================
   9. Code Blocks
   =========================== */

/* 2. Code Block Container */
.code-block {
  position: relative;
  margin: 1.5em 0;
  border: 1px solid var(--code-border-color);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  background-color: var(--code-bg-color);
  font-size: 14px;
  max-width: 100%;
  box-shadow: var(--shadow-sm);
}

/* 3. Code Block Header */
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.2rem;
  background-color: var(--code-header-bg);
  color: var(--code-header-text);
  font-size: 0.8rem;
  font-family: 'Fira Code', 'Courier New', Courier, monospace;
  border-bottom: 1px solid var(--code-border-color);
}

/* 4. Language Label */
.code-lang {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--code-lang-color);
}

/* 5. Copy Button */
.copy-button {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  background: none;
  border: 1px solid var(--copy-button-color);
  border-radius: var(--border-radius-sm);
  color: var(--copy-button-color);
  cursor: pointer;
  font-size: 0.75rem;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.copy-button:hover,
.copy-button:focus {
  background-color: var(--copy-button-hover-color);
  color: var(--background);
}

.copy-button svg.copy-icon {
  fill: currentColor;
  margin-right: 4px;
  transition: fill 0.3s ease;
}

.copy-button.copied {
  background-color: var(--copy-button-copied-color);
  color: var(--background);
}

.copy-button.copied svg.copy-icon {
  fill: var(--background);
}

.copy-button:focus {
  outline: 2px solid var(--copy-button-hover-color);
  outline-offset: 2px;
}

/* 6. Code Styling */
.code-block pre {
  margin: 0;
  padding: 12px 16px;
  overflow-x: auto;
  background-color: var(--code-bg-color);
  font-family: 'Fira Code', 'Courier New', Courier, monospace;
  font-size: 14px;
}

/* 7. Syntax Highlighting Styles */
.hljs-keyword {
  color: var(--syntax-keyword);
  font-weight: bold;
}

.hljs-string {
  color: var(--syntax-string);
}

.hljs-built_in {
  color: var(--syntax-built_in);
}

.hljs-function_ {
  color: var(--syntax-function);
}

.hljs-params {
  color: var(--syntax-params);
}

.hljs-title {
  color: var(--syntax-title);
  font-weight: bold;
}

/* 8. Additional Syntax Highlighting (Optional) */
.hljs-comment {
  color: #6a737d;
  font-style: italic;
}

.hljs-number {
  color: #005cc5;
}

/* 9. Language-Specific Syntax Highlighting */
.language-python .hljs-keyword,
.language-javascript .hljs-keyword,
.language-json .hljs-keyword,
.language-bash .hljs-keyword,
.language-c .hljs-keyword,
.language-cpp .hljs-keyword,
.language-java .hljs-keyword,
.language-ruby .hljs-keyword,
.language-go .hljs-keyword,
.language-swift .hljs-keyword,
.language-xml .hljs-keyword,
.language-css .hljs-keyword,
.language-html .hljs-keyword,
.language-typescript .hljs-keyword {
  color: var(--syntax-keyword);
  font-weight: bold;
}

[class^="language-"] .hljs-string {
  color: var(--syntax-string);
}

[class^="language-"] .hljs-built_in {
  color: var(--syntax-built_in);
}

[class^="language-"] .hljs-function_ {
  color: var(--syntax-function);
}

[class^="language-"] .hljs-params {
  color: var(--syntax-params);
}

[class^="language-"] .hljs-title {
  color: var(--syntax-title);
  font-weight: bold;
}

/* 10. Responsive Adjustments */
@media (max-width: 768px) {
  .code-block-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .copy-button {
    margin-top: 8px;
  }

  .code-block pre {
    padding: 10px 12px;
  }
}

/* ===========================
   10. Responsive Design
   =========================== */

/* Responsive Typography */
@media (max-width: 1200px) {
  body {
    font-size: 15px;
  }

  header h1 {
    font-size: 2.2em;
    color: #11AA22
  }
  header p {
  font-size: 1.2em;
      }

  nav a {
    font-size: 0.95em;
  }
}

@media (max-width: 768px) {
  body {
    font-size: 14px;
  }

  header h1 {
    font-size: 2em;
  }

  nav {
    flex-direction: column;
    gap: 10px;
  }

  .theme-toggle {
    width: 50px;
    height: 28px;
  }

  .toggle-thumb {
    width: 22px;
    height: 22px;
  }

  .icon {
    width: 14px;
    height: 14px;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 13px;
  }

  header h1 {
    font-size: 1.8em;
  }

  nav a {
    font-size: 0.85em;
  }

  .code-block {
    font-size: 13px;
  }
}

/* Fluid Images and Media */
img, video, iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ===========================
   11. Accessibility Enhancements
   =========================== */

/* Focus States */
a:focus, button:focus, input:focus, textarea:focus {
  outline: 2px dashed var(--link-color);
  outline-offset: 4px;
}

/* ===========================
   12. Print Styles
   =========================== */

@media print {
  body {
    background-color: #fff;
    color: #000;
  }

  header, footer, .theme-toggle, .copy-button {
    display: none;
  }

  .code-block {
    border: none;
    box-shadow: none;
  }

  .code-block-header {
    display: none;
  }

  .code-block pre {
    padding-left: 0;
  }
}

/* ===========================
   13. Smooth Scrolling
   =========================== */

html {
  scroll-behavior: smooth;
}

/* ===========================
   14. Additional Transitions
   =========================== */

/* Button Transitions */
button {
  transition: background-color 0.3s ease, transform 0.2s ease;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Link Transitions */
a {
  transition: color 0.3s ease, text-decoration 0.3s ease;
}

/* ===========================
   15. Miscellaneous Styles
   =========================== */

/* Responsive Images */
img, video, iframe {
  max-width: 100%;
  height: auto;
  display: block;
}
/* ===========================
   16. pagination Styles
   =========================== */

/* Pagination Styles */
.pagination {
  text-align: center;
  margin: 2rem 0;
}

.pagination a {
  display: inline-block;
  color: #333;
  text-decoration: none;
  margin: 0 0.3rem;
}

.pagination a.active {
  font-weight: bold;
}

.pagination a:hover {
  text-decoration: underline;
}

/* ===========================
   17. 404 Error Page Styles
   =========================== */

.error-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.error-page h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  text-align: center;
}

.error-page > p {
  font-size: 1.1rem;
  text-align: center;
  margin-bottom: 2rem;
  color: var(--text-color);
  opacity: 0.8;
}

.error-page section {
  margin-bottom: 2rem;
}

.error-page section h2 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--link-color);
  padding-bottom: 0.5rem;
}

.error-page ul {
  list-style: none;
  padding: 0;
}

.error-page ul li {
  margin-bottom: 0.5rem;
  padding: 0.3rem 0;
}

.error-page ul li a {
  color: var(--link-color);
  text-decoration: none;
  transition: color 0.2s ease;
}

.error-page ul li a:hover {
  color: var(--link-hover-color);
  text-decoration: underline;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tags-list li {
  margin-bottom: 0;
  padding: 0;
}

.tags-list li a {
  display: inline-block;
  background: var(--code-bg-color);
  padding: 0.3rem 0.8rem;
  border-radius: var(--border-radius-md);
  font-size: 0.9rem;
  border: 1px solid var(--code-border-color);
  transition: all 0.2s ease;
}

.tags-list li a:hover {
  background: var(--link-color);
  color: white;
  text-decoration: none;
}

@media (max-width: 768px) {
  .error-page {
    padding: 1rem 0.5rem;
  }
  
  .error-page h1 {
    font-size: 2rem;
  }
  
  .tags-list {
    flex-direction: column;
  }
  
  .tags-list li a {
    display: block;
    text-align: center;
  }
}

/* ===========================
   18. Contact Page Styles
   =========================== */

.contact-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.contact-page h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  text-align: center;
}

.contact-page > p {
  font-size: 1.1rem;
  text-align: center;
  margin-bottom: 2rem;
  color: var(--text-color);
  opacity: 0.8;
}

.contact-simple {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}

.contact-info {
  background: var(--code-bg-color);
  padding: 2rem;
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--code-border-color);
}

.contact-info p {
  margin-bottom: 1rem;
  line-height: 1.6;
  color: var(--text-color);
}

.email-contact {
  font-size: 1.2rem;
  margin: 1.5rem 0 !important;
}

.email-contact a {
  color: var(--link-color);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border: 2px solid var(--link-color);
  border-radius: var(--border-radius-md);
  display: inline-block;
  transition: all 0.2s ease;
}

.email-contact a:hover {
  background: var(--link-color);
  color: white;
  text-decoration: none;
}

/* ===========================
   19. Search Page Styles
   =========================== */

.search-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.search-page h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  text-align: center;
}

.search-page > p {
  font-size: 1.1rem;
  text-align: center;
  margin-bottom: 2rem;
  color: var(--text-color);
  opacity: 0.8;
}

.search-container {
  margin-top: 2rem;
}

#search-input {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--input-border-color);
  border-radius: var(--border-radius-lg);
  background: var(--input-bg-color);
  color: var(--input-text-color);
  font-size: 1.1rem;
  transition: border-color 0.2s ease;
}

#search-input:focus {
  outline: none;
  border-color: var(--link-color);
}

.search-results-container {
  margin-top: 2rem;
}

#search-results {
  list-style: none;
  padding: 0;
}

#search-results li {
  background: var(--code-bg-color);
  margin-bottom: 1rem;
  padding: 1.5rem;
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--code-border-color);
  transition: box-shadow 0.2s ease;
}

#search-results li:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#search-results li a {
  color: var(--link-color);
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 600;
  display: block;
  margin-bottom: 0.5rem;
}

#search-results li a:hover {
  text-decoration: underline;
}

#search-results li p {
  color: var(--text-color);
  opacity: 0.8;
  margin: 0;
  line-height: 1.5;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .contact-page,
  .search-page {
    padding: 1rem 0.5rem;
  }
  
  .contact-page h1,
  .search-page h1 {
    font-size: 2rem;
  }
  
  .contact-info {
    padding: 1.5rem;
  }
  
  .email-contact {
    font-size: 1.1rem;
  }
  
  .email-contact a {
    padding: 0.4rem 0.8rem;
    font-size: 1rem;
  }
  
  #search-input {
    padding: 0.75rem;
    font-size: 1rem;
  }
  
  #search-results li {
    padding: 1rem;
  }
}

/* ===========================
   20. Category Page Styles
   =========================== */

.category-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.category-page h1 {
  font-size: 2rem;
  margin-bottom: 2rem;
  text-align: center;
  color: var(--text-color);
}

.category-page ul {
  list-style: none;
  padding: 0;
}

.category-page ul li {
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--code-bg-color);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--code-border-color);
  transition: box-shadow 0.2s ease;
}

.category-page ul li:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
  .category-page {
    padding: 1rem 0.5rem;
  }
  
  .category-page h1 {
    font-size: 1.5rem;
  }
  
  .category-page ul li {
    padding: 0.75rem;
  }
}
