/* CSS Custom Properties - Light Theme (default) */
:root {
  --color-primary: #06c;
  --color-primary-dark: #004d99;
  --color-primary-light: #e6f2ff;
  --color-text: #2d3748;
  --color-text-muted: #718096;
  --color-bg: #f7fafc;
  --color-bg-dots: #d1dce6;
  --color-white: #fff;
  --color-border: #e2e8f0;
  --color-code-bg: #1e293b;
  --color-code-text: #e2e8f0;
  --font-sans: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 10%), 0 2px 4px -1px rgb(0 0 0 / 6%);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 10%), 0 4px 6px -2px rgb(0 0 0 / 5%);
}

/* Dark Theme - Colorblind friendly with high contrast */
[data-theme='dark'] {
  --color-primary: #6db3f2;
  --color-primary-dark: #a8d4ff;
  --color-primary-light: #1a3a5c;
  --color-text: #e8eaed;
  --color-text-muted: #9aa0a6;
  --color-bg: #121212;
  --color-bg-dots: #2a2a2a;
  --color-white: #1e1e1e;
  --color-border: #3c4043;
  --color-code-bg: #0d1117;
  --color-code-text: #e6edf3;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 30%), 0 2px 4px -1px rgb(0 0 0 / 20%);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 40%), 0 4px 6px -2px rgb(0 0 0 / 30%);
}

/* System preference detection */
@media (prefers-color-scheme: dark) {
  [data-theme='system'] {
    --color-primary: #6db3f2;
    --color-primary-dark: #a8d4ff;
    --color-primary-light: #1a3a5c;
    --color-text: #e8eaed;
    --color-text-muted: #9aa0a6;
    --color-bg: #121212;
    --color-bg-dots: #2a2a2a;
    --color-white: #1e1e1e;
    --color-border: #3c4043;
    --color-code-bg: #0d1117;
    --color-code-text: #e6edf3;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 30%), 0 2px 4px -1px rgb(0 0 0 / 20%);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 40%), 0 4px 6px -2px rgb(0 0 0 / 30%);
  }
}

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--color-bg);
  background-image: radial-gradient(circle, var(--color-bg-dots) 1px, transparent 1px);
  background-size: 20px 20px;
  color: var(--color-text);
  font-family: var(--font-sans);
  line-height: 1.7;
  min-height: 100vh;
}

/* Page Layout */
.page-wrapper {
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  max-width: 1200px;
  min-height: 100vh;
  padding: 2rem 1.5rem;
  width: 100%;
}

@media (width >= 768px) {
  .page-wrapper {
    padding: 2rem;
    width: 80%;
  }
}

/* Header */
.site-header {
  align-items: center;
  background: var(--color-white);
  border: 1px dashed #8d9fb0;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding: 1rem 1.5rem;
}

.logo {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
  text-decoration: none;
}

.logo:hover {
  text-decoration: none;
}

.logo-bracket {
  color: var(--color-primary);
}

.logo-text {
  color: var(--color-text);
}

.site-nav {
  align-items: center;
  display: flex;
  gap: 0.5rem;
}

.nav-link {
  background: transparent;
  border: 2px solid transparent;
  border-radius: var(--border-radius-sm);
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  text-decoration: none;
  transition:
    background-color 0.2s,
    border-color 0.2s,
    color 0.2s;
}

.nav-link:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.nav-link.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-white);
}

/* Main Content */
.content {
  flex: 1;
}

.post {
  background: var(--color-white);
  border: 1px dashed #8d9fb0;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--color-text);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 1rem;
  margin-top: 2rem;
}

h1 {
  border-bottom: 3px dashed var(--color-primary);
  font-size: 2.25rem;
  padding-bottom: 0.75rem;
}

h1:first-child {
  margin-top: 0;
}

h2 {
  font-size: 1.75rem;
}

h3 {
  font-size: 1.375rem;
}

p {
  margin-bottom: 1.25rem;
}

.site-footer p {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  margin-bottom: 0;
}

/* Links */
a {
  color: var(--color-primary);
  text-decoration: none;
  text-underline-offset: 3px;
  transition: color 0.2s;
}

a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

/* Code */
code {
  background: var(--color-primary-light);
  border-radius: 4px;
  color: var(--color-primary-dark);
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.2em 0.4em;
}

pre {
  background: var(--color-code-bg);
  border-radius: var(--border-radius-sm);
  color: var(--color-code-text);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  padding: 1.25rem;
}

pre code {
  background: none;
  color: inherit;
  padding: 0;
}

/* Blockquotes */
blockquote {
  background: var(--color-primary-light);
  border-left: 4px solid var(--color-primary);
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
  font-style: italic;
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* Lists */
ul,
ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

/* Horizontal Rule */
hr {
  border: none;
  border-top: 3px dashed var(--color-primary);
  margin: 2rem 0;
}

/* Tables */
table {
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  width: 100%;
}

th,
td {
  border: 1px dashed var(--color-border);
  padding: 0.75rem;
  text-align: left;
}

th {
  background: var(--color-primary-light);
  font-weight: 600;
}

tr:hover {
  background: var(--color-bg);
}

/* Images */
img {
  border-radius: var(--border-radius-sm);
  height: auto;
  max-width: 100%;
}

/* Footer */
.site-footer {
  border-top: 2px dashed var(--color-border);
  margin-top: 2rem;
  padding-top: 1.5rem;
  text-align: center;
}

.footer-code {
  background: var(--color-primary-light);
  border-radius: 4px;
  color: var(--color-primary);
  font-family: var(--font-mono);
  font-weight: 500;
  padding: 0.2em 0.5em;
}

/* Settings Menu */
.settings-menu {
  position: relative;
}

.settings-btn {
  align-items: center;
  background: transparent;
  border: 2px solid transparent;
  border-radius: var(--border-radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  justify-content: center;
  padding: 0.5rem;
  transition:
    background-color 0.2s,
    color 0.2s;
}

.settings-btn:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.settings-btn svg {
  height: 1.25rem;
  width: 1.25rem;
}

.settings-dropdown {
  background: var(--color-white);
  border: 1px dashed #8d9fb0;
  border-radius: var(--border-radius-sm);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  min-width: 140px;
  padding: 0.5rem;
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  z-index: 100;
}

.settings-menu.open .settings-dropdown {
  display: flex;
}

.dropdown-label {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  text-transform: uppercase;
}

.dropdown-item {
  align-items: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--color-text);
  cursor: pointer;
  display: flex;
  font-family: inherit;
  font-size: 0.875rem;
  gap: 0.5rem;
  padding: 0.5rem;
  text-align: left;
  transition:
    background-color 0.15s,
    color 0.15s;
  width: 100%;
}

.dropdown-item:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.dropdown-item.active {
  background: var(--color-primary);
  color: var(--color-white);
}

.dropdown-item svg {
  height: 1rem;
  width: 1rem;
}

/* Responsive */
@media (width <= 600px) {
  .page-wrapper {
    padding: 1rem;
  }

  .site-header {
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    text-align: center;
  }

  .logo {
    font-size: 1.1rem;
  }

  .nav-link {
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
  }

  .post {
    padding: 1.25rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  h3 {
    font-size: 1.125rem;
  }

  blockquote {
    padding: 0.75rem 1rem;
  }

  pre {
    padding: 1rem;
  }
}
