/* Variables */
:root {
  /* Primary colors */
  --accent: #ff8800;
  --background-primary: #222;
  --text-normal: #ddd;
  
  /* Complementary colors (dynamically calculated from accent) */
  /* Direct complement: rotate 180° in hue */
  --accent-complement: hsl(from var(--accent) calc(h + 180) s l);
  /* Split complements: rotate 150° and 210° */
  --accent-split-1: hsl(from var(--accent) calc(h + 150) s l);
  --accent-split-2: hsl(from var(--accent) calc(h + 210) s l);
  
  /* Derived colors using color-mix */
  --background-secondary: color-mix(in srgb, var(--text-normal) 5%, var(--background-primary));
  --text-accent: color-mix(in srgb, var(--accent) 90%, var(--text-normal));
  --text-dim-accent: color-mix(in srgb, var(--accent) 50%, var(--text-normal));
  --text-muted: color-mix(in srgb, var(--text-normal) 70%, transparent);
  --text-faint: color-mix(in srgb, var(--text-normal) 40%, transparent);
  
  /* Header colors - all same as normal text */
  --h1-color: var(--text-normal);
  --h2-color: var(--text-normal);
  --h3-color: var(--text-normal);
  --h4-color: var(--text-normal);
  --h5-color: var(--text-normal);
  --h6-color: var(--text-normal);

  /* Functional colors */
  --code-background: color-mix(in srgb, var(--text-normal) 3%, var(--background-primary));
  --table-border-color: var(--text-faint);

  /* Link colors */
  --link-color: var(--accent);
  --link-visited: color-mix(in srgb, var(--accent) 70%, var(--text-muted));

  /* Accent variations */
  --accent-subtle: color-mix(in srgb, var(--accent) 15%, transparent);
  --accent-faint: color-mix(in srgb, var(--accent) 5%, transparent);

  /* Bold color */
  --bold-color: var(--text-dim-accent);
}

body {
  background: var(--background-primary);
  color: var(--text-normal);
  line-height: 1.65;
  font-family: 'Crimson Text', 'Georgia', 'Cambria', 'Times New Roman', serif;
  margin: 0 auto;
  padding: 20px;
  max-width: 45rem;
  font-size: 1.125rem;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Header colors and sizing */
h1 { 
  color: var(--h1-color); 
  margin: 2rem 0 2rem 0; 
  font-size: 2.5rem;
  text-align: center;
  font-weight: 700;
  font-family: 'Crimson Text', 'Georgia', serif;
  letter-spacing: -0.02em;
}
h2 { 
  color: var(--h2-color); 
  margin: 2rem 0 1rem 0; 
  font-size: 1.8rem;
  padding-left: 2rem;
  font-family: 'Crimson Text', 'Georgia', serif;
  font-weight: 600;
  position: relative;
}
h2::before {
  content: '◆';
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  opacity: 0.7;
  font-size: 0.7em;
  line-height: 1;
}
h3 { 
  color: var(--h3-color); 
  margin: 1.5rem 0 0.75rem 0; 
  font-size: 1.4rem;
  padding-left: 1.5rem;
  font-family: 'Crimson Text', 'Georgia', serif;
  font-weight: 600;
  position: relative;
}
h3::before {
  content: '◆';
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  opacity: 0.6;
  font-size: 0.7em;
  line-height: 1;
}
h4 { 
  color: var(--h4-color); 
  margin: 1.25rem 0 0.5rem 0; 
  font-size: 1.2rem;
  padding-left: 1rem;
  font-family: 'Crimson Text', 'Georgia', serif;
  font-weight: 500;
  position: relative;
}
h4::before {
  content: '◆';
  position: absolute;
  left: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  opacity: 0.5;
  font-size: 0.7em;
  line-height: 1;
}
h5 { 
  color: var(--h5-color); 
  margin: 1rem 0 0.5rem 0; 
  font-size: 1.1rem;
  padding-left: 0.5rem;
  font-family: 'Crimson Text', 'Georgia', serif;
  font-weight: 500;
  position: relative;
}
h5::before {
  content: '◆';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  opacity: 0.4;
  font-size: 0.7em;
  line-height: 1;
}
h6 { 
  color: var(--h6-color); 
  margin: 1rem 0 0.5rem 0; 
  font-size: 1rem;
  font-family: 'Crimson Text', 'Georgia', serif;
  font-weight: 500;
}

/* Paragraphs and base elements */
p {
  margin: 1.2rem 0;
  hanging-punctuation: first;
}

ul, ol {
  margin: 1.2rem 0;
  padding-left: 2rem;
}

li {
  margin: 0.25rem 0;
}

/* Make italics more visible */
em, i {
  font-style: italic;
  letter-spacing: 0.01em;
}

/* Bold text styling */
strong, b {
  font-weight: 700;
  color: var(--bold-color);
}

/* Code blocks */
code {
  background: var(--code-background);
  padding: 0.1em 0.3em;
  border-radius: 3px;
  font-size: 0.8em;
  font-family: 'Source Code Pro', 'Consolas', 'DejaVu Sans Mono', 'Courier New', monospace;
  font-weight: 400;
}

pre {
  background: var(--code-background);
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
  border-radius: 3px;
  position: relative;
  line-height: 1.4;
}

pre code {
  padding: 0;
  background: none;
  font-size: 0.85em;
  font-family: 'Source Code Pro', 'Consolas', 'DejaVu Sans Mono', 'Courier New', monospace;
  font-weight: 400;
}

.copy-button {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: var(--code-background);
  color: var(--text-muted);
  border: 1px solid var(--text-faint);
  padding: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  opacity: 0.6;
}

.copy-button:hover {
  background: var(--accent);
  color: var(--background-primary);
  border-color: var(--accent);
  opacity: 1;
}

.copy-button:before {
  content: '📋';
  font-size: 12px;
}

.copy-button.copied:before {
  content: '✓';
  color: #4ade80;
}

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

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

/* Blockquotes */
blockquote {
  position: relative;
  padding-left: 1.5rem;
  color: var(--text-muted);
  margin: 1.5rem 0;
}

blockquote::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, transparent, var(--accent), transparent);
}

/* Horizontal rules */
hr {
  border: none;
  border-top: 1px solid var(--text-faint);
  margin: 2rem 0;
}

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

a:hover {
  text-decoration: underline;
}

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

/* Metadata */
.metadata {
  display: none;
}

/* Post list (index page) */
.post-list {
  list-style: none;
  padding: 0;
  margin: 2rem 0;
}

.post-list li {
  margin: 0;
}

.post-list a {
  display: block;
  padding: 0.75rem 0;
  text-decoration: none;
  color: var(--text-normal);
  transition: all 0.2s;
}

.post-list a:hover {
  color: var(--accent);
  text-decoration: none;
  padding-left: 0.5rem;
}

.post-list a:visited {
  color: var(--text-normal);
}

.post-list a:visited:hover {
  color: var(--accent);
}

.post-title {
  font-size: 1.125rem;
}

/* Light theme */
body.light-theme {
  --background-primary: #fefefe;
  --text-normal: #111;

  /* Override header colors for light theme */
  --h1-color: #111;
  --h2-color: #111;
  --h3-color: #111;
  --h4-color: #111;
  --h5-color: #111;
  --h6-color: #111;

  /* Recalculate for light theme */
  --text-muted: color-mix(in srgb, var(--text-normal) 60%, transparent);
  --text-faint: color-mix(in srgb, var(--text-normal) 35%, transparent);
  --code-background: color-mix(in srgb, var(--text-normal) 6%, var(--background-primary));
  --text-dim-accent: color-mix(in srgb, var(--accent) 70%, var(--text-normal));
  --bold-color: var(--text-dim-accent);
}


/* Color picker widget */
.color-picker {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  z-index: 1000;
  opacity: 0.15;
  transition: opacity 0.3s;
}

.color-picker:hover {
  opacity: 1;
}

/* Theme toggle button */
#theme-toggle {
  position: fixed;
  bottom: 4.5rem;
  left: 1rem;
  width: 40px;
  height: 40px;
  border: 2px solid var(--text-faint);
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  transition: transform 0.2s, border-color 0.2s, opacity 0.3s;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0.15;
}

#theme-toggle:hover {
  transform: scale(1.1);
  border-color: var(--accent);
  opacity: 1;
}

#accent-picker {
  width: 40px;
  height: 40px;
  border: 2px solid var(--text-faint);
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
  padding: 0;
  transition: transform 0.2s, border-color 0.2s;
}

#accent-picker:hover {
  transform: scale(1.1);
  border-color: var(--accent);
}

#accent-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}

#accent-picker::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

#accent-picker::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}

/* Footer */
footer {
  margin-top: 3rem;
  padding: 2rem 0 1rem 0;
  text-align: center;
  position: relative;
}

footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--text-faint), transparent);
}

footer a {
  display: inline-block;
  margin: 0 0.75rem;
  font-size: 1.5rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s ease;
}

footer a:hover {
  color: var(--accent);
  transform: scale(1.1);
}

