/* CSS Custom Properties for theming */
:root {
  /* Light theme (default) */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f8f8;
  --bg-tertiary: #f2f2f2;
  --bg-code: rgba(0, 0, 0, 0.06);
  --bg-nav: rgba(255, 255, 255, 0.9);
  
  --text-primary: #000000;
  --text-secondary: #404040;
  --text-muted: #757575;
  --text-link: #0024edec;
  
  --border-color: #eee;
  --border-table: #dadadc;
  --code-border: rgba(0, 0, 0, 0.08);
  
  --table-row-odd: #fcfcfc;
  --highlight-bg: #f8f8f8;
}

[data-theme="dark"] {
  /* Dark theme */
  --bg-primary: #1a1a1a;
  --bg-secondary: #252525;
  --bg-tertiary: #2d2d2d;
  --bg-code: rgba(255, 255, 255, 0.1);
  --bg-nav: rgba(26, 26, 26, 0.95);
  
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-muted: #888888;
  --text-link: #6b8aff;
  
  --border-color: #3a3a3a;
  --border-table: #404040;
  --code-border: rgba(255, 255, 255, 0.15);
  
  --table-row-odd: #222222;
  --highlight-bg: #2d2d2d;
}

/* SA */
body {
  line-height: 1;
  font: normal 15px/1.5em 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  line-height: 1.5;
  letter-spacing: 0.008em;
  font-size: 18px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

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

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

/* markdown content styles */
blockquote {
  margin-top: 5px;
  margin-bottom: 5px;
  padding-left: 1em;
  margin-left: 0px;
  border-left: 3px solid var(--border-color);
  color: var(--text-muted);
}

hr {
  display: block;
  border: none;
  height: 2px;
  margin: 40px auto;
  background: var(--border-color);
}

table {
  width: 100%;
  margin: 40px 0;
  border-collapse: collapse;
  line-height: 1.5em;
}

th,
td {
  text-align: left;
  padding-right: 20px;
  vertical-align: top;
}

table td,
td {
  border-spacing: none;
  border-style: solid;
  padding: 10px 15px;
  border-width: 1px 0 0 0;
}
thead th,
th {
  text-align: left;
  padding: 10px 15px;
  height: 20px;
  font-size: 13px;
  font-weight: bold;
  color: var(--text-secondary);
  cursor: default;
  white-space: nowrap;
  border: 1px solid var(--border-table);
}

tr > td {
  border: 1px solid var(--border-table);
}

tr:nth-child(odd) > td {
  background: var(--table-row-odd);
}

h1,
h2,
h3 {
  font-weight: bold;
  color: var(--text-primary);
}

p {
  color: var(--text-primary);
  margin-block-start: 1.5em;
  margin-block-end: 1.5em;
  font-size: 18px;
}

p,
pre {
  word-break: normal;
  overflow-wrap: anywhere;
}

.markdown-image img {
  max-width: 100%;
}

.anchor {
  display: none;
}

h1:hover a,
h2:hover a,
h3:hover a,
h4:hover a {
  visibility: visible;
}

.highlight pre {
  padding: 7px;
  overflow-x: auto;
}

.highlight {
  max-width: 100%;
  overflow-x: auto;
}

p code {
  font-size: 16px;
  background-color: var(--bg-code);
  padding: 0 2px;
  border: 1px solid var(--code-border);
  border-radius: 2px 2px;
  line-height: inherit;
  word-wrap: break-word;
  text-indent: 0;
}

pre code {
  display: block;
  padding: 12px;
  overflow: auto;
  font-family: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  line-height: 1.5;
  font-size: 16px;
}

/* navigation */
nav.navigation {
  padding: 20px 20px 0;
  background: var(--bg-nav);
  margin: 0 auto;
  text-align: center;
  z-index: 100;
  transition: background-color 0.3s ease;
}

nav.navigation a {
  top: 8px;
  right: 6px;
  padding: 8px 12px;
  color: var(--text-link);
  font-size: 18px;
  line-height: 1.35;
  border-radius: 3px;
  font-weight: 600;
}

nav.navigation a:hover {
  color: var(--text-link);
}

nav.navigation a.button {
  background: var(--text-link);
  color: #fff;
  margin-left: 12px;
}

/* Theme toggle button */
#theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  vertical-align: middle;
  color: var(--text-link);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

#theme-toggle:hover {
  opacity: 0.8;
}

#theme-toggle .sun-icon {
  display: none;
}

#theme-toggle .moon-icon {
  display: block;
}

[data-theme="dark"] #theme-toggle .sun-icon {
  display: block;
}

[data-theme="dark"] #theme-toggle .moon-icon {
  display: none;
}

@media (max-width: 700px) {
  nav.navigation {
    padding: 20px 10px 0 0;
    background: var(--bg-nav);
    margin: 0 auto;
    text-align: center;
    z-index: 100;
  }
  nav.navigation a {
    top: 8px;
    right: 6px;
    padding: 8px 8px;
    color: var(--text-link);
    font-size: 15px;
    line-height: 1.35;
    border-radius: 3px;
  }
  #theme-toggle {
    padding: 8px 8px;
  }
}

@media (max-width: 324px) {
  nav.navigation a.button {
    display: none;
  }
}

/* toc */
.toc {
  margin: auto;
  background: var(--bg-secondary);
  border-radius: 0;
  padding: 10px 7px;
  margin-top: 36px;
}

.toc details summary {
  cursor: zoom-in;
  margin-inline-start: 14px;
  font-weight: 500;
}

.toc details[open] summary {
  cursor: zoom-out;
}

.toc #TableOfContents {
  margin-left: 10px;
}

.toc ul {
  padding-inline-start: 24px;
}

ul {
  display: block;
  padding-left: 1.2em;
}

ul li {
  margin: 0px;
  overflow-wrap: anywhere;
  word-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  min-width: 0;
}

/* comment */
#comment {
  margin-top: 64px;
}

/* footer */
#footer {
  margin-top: 100px;
  margin-bottom: 100px;
  text-align: center;
  color: var(--text-primary);
  font-size: 14px;
}

#footer .copyright {
  margin: 20px auto;
  font-size: 16.5px;
}

.powerby {
  margin: 20px auto;
  font-size: 13px;
}

#footer .split {
  cursor: pointer;
}

#footer .split:hover path {
  fill: #ff3356;
  transition: 0.7s ease-out;
  cursor: pointer;
}

#social a {
  margin: 0 4px;
}

/* main content */
.main {
  width: 100%;
  margin: 0 auto;
}

/* profile  */
.profile {
  margin: 60px auto 0 auto;
  text-align: center;
}

.profile .avatar {
  display: inline-block;
  width: 80px;
  height: 80px;
  border-radius: 50%;
}

.profile h1 {
  font-weight: 400;
  letter-spacing: 0px;
  font-size: 0px;
  color: var(--text-primary);
  margin-bottom: 0;
  margin-top: 0;
}

.profile h2 {
  font-size: 20px;
  font-weight: 300;
  color: var(--text-primary);
  margin-top: 0;
}

/* index post list - SA*/
#list-page {
  max-width: 850px;
  margin: 0 auto;
  padding: 0 24px;
}

#list-page .item {
  margin: 12px 0;
}

#list-page .title {
  display: inline-block;
  color: var(--text-secondary);
  font-size: 18px;
  font-weight: 400;
  margin: 0;
  width: 80%;
}

#list-page .title a {
  color: var(--text-primary);
  display: block;
}

#list-page .title a:hover {
  color: var(--text-link);
}

#list-page .date {
  width: 20%;
  float: right;
  text-align: right;
  position: relative;
  top: 1px;
  color: var(--text-primary);
}

#list-page .summary {
  color: var(--text-muted);
  margin-top: 12px;
  word-break: normal;
  overflow-wrap: anywhere;
  margin-bottom: 36px;
}

#list-page .cover {
  width: 100px;
  height: 100px;
  background: var(--bg-primary);
}

#list-page .cover img {
  width: 100%;
  text-align: center;
}

#list-page .pagination {
  margin: 48px 0;
  width: 100%;
  height: 32px;
  margin-top: 48px;
}

#list-page .pagination .pre {
  float: left;
}

#list-page .pagination .next {
  float: right;
}

/* single page - SA */
#single {
  max-width: 750px;
  margin: 60px auto 0 auto;
  padding: 0 64px;
  font-size: 18px;
}

#single .title {
  text-align: center;
  font-size: 32px;
  font-weight: bold;
  line-height: 48px;
  color: var(--text-primary);
}

@media (max-width: 700px) {
  code {
    font-family: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
    white-space: pre-wrap;
    line-height: 1.5;
  }
  #single {
    padding: 0 18px;
    margin: 20px auto 0 auto;
  }
  #single .title {
    font-size: 24px;
    line-height: 32px;
  }
}

/* SA */
#single .tip {
  text-align: center;
  color: var(--text-primary);
  margin-top: 18px;
  font-size: 14px;
  font-weight: 500;
}

#single .tip .split {
  margin: 0 4px;
}

#single .content {
  margin-top: 36px;
}

#single .tags {
  margin-top: 24px;
}

#single .tags a {
  background: var(--bg-tertiary);
  padding: 4px 7px;
  color: var(--text-link);
  font-size: 14px;
  margin-right: 3px;
}

#single .tags a:hover {
  color: var(--text-link);
}

#archive {
  max-width: 580px;
  margin: 0 auto;
  padding: 0 24px;
}

#archive .total {
  font-size: 15px;
}

#archive .group {
  margin: 24px auto;
}

#archive .group .key {
  font-size: 20px;
  margin-bottom: 12px;
}

#archive .group .value {
  display: block;
  font-size: 16px;
  margin-bottom: 12px;
}

#archive .group .value .date {
  display: inline-block;
  color: var(--text-primary);
  min-width: 60px;
}

#archive .group .value .title {
  display: inline;
  font-size: 17px;
  font-weight: 400;
}

#archive .group .value .title a {
  color: var(--text-primary);
}

#archive .group .value .title a:hover {
  color: var(--text-link);
}

#archive .group .value .tags {
  display: inline;
  margin-left: 7px;
}

#archive .group .value .tags a {
  display: none;
}

#archive .group .value .tags a:hover {
  color: var(--text-link);
}

/* taxonomy */
#tags {
  max-width: 700px;
  margin: 48px auto 0 auto;
  padding: 0 12px;
  text-align: center;
}

#tags .tag {
  display: inline-block;
  margin: 7px 7px;
}

@media (max-width: 700px) {
  #tags {
    margin: 0 auto 0 auto;
  }
  #tags .tag {
    display: inline-block;
    margin: 4px 5px;
  }
}

#tags .tag a {
  background: var(--bg-tertiary);
  padding: 4px 7px;
  color: var(--text-muted);
  color: var(--text-secondary);
  font-size: 14px;
  margin-right: 3px;
}

#tags .tag a:hover {
  color: var(--text-link);
}

/* section page */
#section {
  max-width: 580px;
  margin: 48px auto 0 auto;
  padding: 0 12px;
}

/* 404 page */
#page-404 {
  max-width: 580px;
  margin: 0 auto;
  padding: 0 24px;
}

#page-404 .item {
  margin: 12px 0 0 0;
}

#page-404 .title {
  display: inline-block;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 400;
  margin: 0;
  width: 80%;
}

#page-404 .text {
  text-align: center;
  margin-top: 60px;
}

#page-404 .read-more {
  font-weight: 300;
  font-size: 20px;
  margin-top: 48px;
  margin-bottom: 12px;
}

#page-404 .date {
  width: 20%;
  float: right;
  text-align: right;
  position: relative;
  top: 1px;
  color: var(--text-muted);
}

/* Ensure images don't get inverted in dark mode */
img {
  max-width: 100%;
}

/* Scroll to top button - dark mode color */
[data-theme="dark"] #myBtn {
  color: #fff !important;
}

/* Code blocks with syntax highlighting - dark mode compatible */
.highlight {
  background: var(--highlight-bg);
  border-radius: 6px;
  margin: 1.5em 0;
}

.highlight pre {
  background: var(--highlight-bg);
  margin: 0;
  padding: 16px;
  border-radius: 6px;
}

pre code {
  background: transparent;
  color: var(--text-primary);
}

/* Dark mode code block - proper syntax highlighting background */
/* Dark mode code blocks - override inline styles */
[data-theme="dark"] .highlight,
[data-theme="dark"] .highlight pre {
  background: #282c34 !important;
  background-color: #282c34 !important;
}

[data-theme="dark"] .highlight pre,
[data-theme="dark"] .highlight code,
[data-theme="dark"] pre code {
  color: #abb2bf !important;
}

/* Syntax highlighting colors for dark mode (One Dark theme) */
[data-theme="dark"] .highlight .c,
[data-theme="dark"] .highlight .c1,
[data-theme="dark"] .highlight .cm,
[data-theme="dark"] .highlight .cp,
[data-theme="dark"] .highlight .cs { color: #5c6370 !important; font-style: italic; } /* Comments */

[data-theme="dark"] .highlight .k,
[data-theme="dark"] .highlight .kd,
[data-theme="dark"] .highlight .kn,
[data-theme="dark"] .highlight .kp,
[data-theme="dark"] .highlight .kr,
[data-theme="dark"] .highlight .kt,
[data-theme="dark"] .highlight .kc { color: #c678dd !important; } /* Keywords */

[data-theme="dark"] .highlight .s,
[data-theme="dark"] .highlight .s1,
[data-theme="dark"] .highlight .s2,
[data-theme="dark"] .highlight .sb,
[data-theme="dark"] .highlight .sc,
[data-theme="dark"] .highlight .sd,
[data-theme="dark"] .highlight .se,
[data-theme="dark"] .highlight .sh,
[data-theme="dark"] .highlight .si,
[data-theme="dark"] .highlight .sx,
[data-theme="dark"] .highlight .sr,
[data-theme="dark"] .highlight .ss { color: #98c379 !important; } /* Strings */

[data-theme="dark"] .highlight .m,
[data-theme="dark"] .highlight .mf,
[data-theme="dark"] .highlight .mh,
[data-theme="dark"] .highlight .mi,
[data-theme="dark"] .highlight .mo,
[data-theme="dark"] .highlight .il,
[data-theme="dark"] .highlight .mb,
[data-theme="dark"] .highlight .mx { color: #d19a66 !important; } /* Numbers */

[data-theme="dark"] .highlight .n { color: #abb2bf !important; }
[data-theme="dark"] .highlight .na { color: #d19a66 !important; } /* Attributes */
[data-theme="dark"] .highlight .nb { color: #e5c07b !important; } /* Builtins */
[data-theme="dark"] .highlight .nc { color: #e5c07b !important; } /* Class names */
[data-theme="dark"] .highlight .nd { color: #61afef !important; } /* Decorators */
[data-theme="dark"] .highlight .ni { color: #abb2bf !important; }
[data-theme="dark"] .highlight .ne { color: #e06c75 !important; } /* Exceptions */
[data-theme="dark"] .highlight .nf { color: #61afef !important; } /* Functions */
[data-theme="dark"] .highlight .nl { color: #e06c75 !important; } /* Labels */
[data-theme="dark"] .highlight .nn { color: #abb2bf !important; } /* Namespaces */
[data-theme="dark"] .highlight .no { color: #d19a66 !important; } /* Constants */
[data-theme="dark"] .highlight .nt { color: #e06c75 !important; } /* Tags */
[data-theme="dark"] .highlight .nv,
[data-theme="dark"] .highlight .vi,
[data-theme="dark"] .highlight .vg,
[data-theme="dark"] .highlight .vm { color: #e06c75 !important; } /* Variables */

[data-theme="dark"] .highlight .o,
[data-theme="dark"] .highlight .ow { color: #56b6c2 !important; } /* Operators */

[data-theme="dark"] .highlight .p { color: #abb2bf !important; } /* Punctuation */

[data-theme="dark"] .highlight .err { color: #e06c75 !important; background: transparent !important; } /* Errors */

[data-theme="dark"] .highlight .gd { color: #e06c75 !important; } /* Diff deleted */
[data-theme="dark"] .highlight .gi { color: #98c379 !important; } /* Diff inserted */

[data-theme="dark"] .highlight .gh,
[data-theme="dark"] .highlight .gu { color: #61afef !important; font-weight: bold; } /* Headings */

[data-theme="dark"] .highlight .w { color: #abb2bf !important; } /* Whitespace */

/* Enhanced tag buttons for dark mode */
#single .tags a,
#tags .tag a {
  background: var(--bg-tertiary);
  color: var(--text-link);
  border: 1px solid transparent;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

#single .tags a:hover,
#tags .tag a:hover {
  background: var(--bg-secondary);
  border-color: var(--text-link);
}

[data-theme="dark"] #single .tags a,
[data-theme="dark"] #tags .tag a {
  background: #2d3748;
  color: #90cdf4;
  border: 1px solid #4a5568;
}

[data-theme="dark"] #single .tags a:hover,
[data-theme="dark"] #tags .tag a:hover {
  background: #4a5568;
  border-color: #90cdf4;
}

/* Share buttons dark mode */
[data-theme="dark"] .sharebuttons span {
  color: #90cdf4 !important;
}

[data-theme="dark"] .sharebuttons .will-change {
  fill: #90cdf4 !important;
}

[data-theme="dark"] nav.sharebuttons li > a:hover .will-change {
  fill: #63b3ed !important;
}

/* Comments container */
.comments-container {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 6px;
  transition: background-color 0.3s ease, color 0.3s ease;
  box-sizing: border-box;
}

.comments-container h4 {
  color: inherit;
  margin: 0 0 1rem 0;
}

.comments-container iframe {
  width: 100% !important;
  min-height: 300px;
}

[data-theme="dark"] .comments-container {
  background-color: #282c34;
  color: #abb2bf;
}

@media (max-width: 700px) {
  .comments-container {
    padding: 0;
    border-radius: 0;
  }
  
  .comments-container iframe {
    min-height: 250px;
  }
}
