/* ========================================
   CSS Reset & Base
   ======================================== */

*, *::before, *::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

/* ========================================
   CSS Custom Properties
   ======================================== */

:root {
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Layout */
  --content-width: 768px;
  --site-padding: 1.5rem;

  /* Light mode colors */
  --color-bg: #ffffff;
  --color-bg-secondary: #f9fafb;
  --color-text: #111827;
  --color-text-secondary: #6b7280;
  --color-text-tertiary: #9ca3af;
  --color-border: #e5e7eb;
  --color-link: #2563eb;
  --color-link-hover: #1d4ed8;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
}

[data-theme="dark"] {
  --color-bg: #0a0a0a;
  --color-bg-secondary: #141414;
  --color-text: #f3f4f6;
  --color-text-secondary: #9ca3af;
  --color-text-tertiary: #6b7280;
  --color-border: #262626;
  --color-link: #60a5fa;
  --color-link-hover: #93c5fd;
}

/* ========================================
   Base Styles
   ======================================== */

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* ========================================
   Layout
   ======================================== */

.site-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  max-width: var(--content-width);
  width: 100%;
  margin: 0 auto;
  padding: var(--space-3xl) var(--site-padding);
}

@media (min-width: 768px) {
  :root {
    --site-padding: 3rem;
  }
}

/* ========================================
   Typography
   ======================================== */

h1, h2, h3 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: var(--space-lg);
}

h2 {
  font-size: 0.875rem;
  margin-top: var(--space-3xl);
  margin-bottom: var(--space-lg);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

p {
  margin-bottom: var(--space-md);
}

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

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

/* ========================================
   Header
   ======================================== */

.site-header {
  padding: var(--space-lg) var(--site-padding);
  border-bottom: 1px solid var(--color-border);
}

.header-content {
  max-width: var(--content-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
}

.site-title:hover {
  color: var(--color-text);
}

/* ========================================
   Theme Toggle
   ======================================== */

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: 8px;
  color: var(--color-text-secondary);
  transition: background-color var(--transition-fast), color var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background-color: var(--color-bg-secondary);
  color: var(--color-text);
}

/* Show/hide sun/moon based on theme */
.moon-icon,
[data-theme="dark"] .sun-icon {
  display: none;
}

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

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

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

/* ========================================
   Intro Section
   ======================================== */

.intro {
  margin-bottom: var(--space-xl);
}

.intro h1 {
  font-size: 0.875rem;
  margin-bottom: var(--space-lg);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.intro p {
  color: var(--color-text-secondary);
}

.intro p:last-child {
  margin-bottom: 0;
}

.intro a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ========================================
   Projects Section
   ======================================== */

.project-list {
  list-style: none;
}

.project-list li {
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--color-border);
}

.project-list li:first-child {
  padding-top: 0;
}

.project-list li:last-child {
  border-bottom: none;
}

.project-list a {
  font-weight: 500;
  display: inline;
}

.project-description {
  color: var(--color-text-secondary);
}

.project-description::before {
  content: " — ";
  color: var(--color-text-tertiary);
}

/* ========================================
   Posts Section
   ======================================== */

.post-list {
  list-style: none;
}

.post-list li {
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.post-list li:first-child {
  padding-top: 0;
}

@media (min-width: 640px) {
  .post-list li {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
  }
}

.post-list li:last-child {
  border-bottom: none;
}

.post-list a {
  font-weight: 500;
}

.post-list time {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* ========================================
   Footer
   ======================================== */

.site-footer {
  padding: var(--space-2xl) var(--site-padding);
  border-top: 1px solid var(--color-border);
  margin-top: auto;
}

.footer-links {
  max-width: var(--content-width);
  margin: 0 auto;
  text-align: center;
  font-size: 0.875rem;
}

.footer-links a {
  color: var(--color-text-secondary);
}

.footer-links a:hover {
  color: var(--color-text);
}

.footer-links .separator {
  color: var(--color-text-tertiary);
  margin: 0 var(--space-sm);
}

/* ========================================
   Post Page
   ======================================== */

.post-header {
  margin-bottom: var(--space-2xl);
}

.back-link {
  display: inline-block;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-lg);
}

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

.post-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
  line-height: 1.2;
}

.post-date {
  font-size: 0.875rem;
  color: var(--color-text-tertiary);
}

.post-description {
  margin-top: var(--space-md);
  font-size: 1.125rem;
  color: var(--color-text-secondary);
  font-style: italic;
}

/* ========================================
   Post Content
   ======================================== */

.post-content h2 {
  font-size: 1.5rem;
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-md);
  color: var(--color-text);
  text-transform: none;
  letter-spacing: normal;
  font-weight: 600;
}

.post-content h3 {
  font-size: 1.25rem;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-sm);
  font-weight: 600;
}

.post-content p {
  margin-bottom: var(--space-lg);
}

.post-content ul, .post-content ol {
  margin-bottom: var(--space-lg);
  padding-left: var(--space-lg);
}

.post-content li {
  margin-bottom: var(--space-sm);
}

.post-content blockquote {
  border-left: 3px solid var(--color-border);
  padding-left: var(--space-md);
  margin: var(--space-lg) 0;
  color: var(--color-text-secondary);
  font-style: italic;
}

.post-content code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.9em;
  background-color: var(--color-bg-secondary);
  padding: 0.125em 0.375em;
  border-radius: 4px;
}

.post-content pre {
  background-color: var(--color-bg-secondary);
  padding: var(--space-md);
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: var(--space-lg);
}

.post-content pre code {
  background: none;
  padding: 0;
}

.post-content strong {
  font-weight: 600;
}

.post-content em {
  font-style: italic;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-2xl) 0;
}

.post-content a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-footer {
  margin-top: var(--space-3xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--color-border);
}

/* ========================================
   Syntax Highlighting (Rouge)
   ======================================== */

:root {
  /* Light mode syntax colors */
  --syntax-comment: #6a737d;
  --syntax-keyword: #d73a49;
  --syntax-string: #032f62;
  --syntax-number: #005cc5;
  --syntax-function: #6f42c1;
  --syntax-class: #22863a;
  --syntax-variable: #e36209;
  --syntax-operator: #d73a49;
  --syntax-punctuation: #24292e;
}

[data-theme="dark"] {
  /* Dark mode syntax colors */
  --syntax-comment: #8b949e;
  --syntax-keyword: #ff7b72;
  --syntax-string: #a5d6ff;
  --syntax-number: #79c0ff;
  --syntax-function: #d2a8ff;
  --syntax-class: #7ee787;
  --syntax-variable: #ffa657;
  --syntax-operator: #ff7b72;
  --syntax-punctuation: #c9d1d9;
}

/* Rouge highlight wrapper */
.highlight {
  background-color: var(--color-bg-secondary);
  border-radius: 8px;
  margin-bottom: var(--space-lg);
  overflow-x: auto;
}

.highlight pre {
  margin: 0;
  padding: var(--space-md);
  background: none;
}

.highlight code {
  color: var(--color-text);
}

/* Comments */
.highlight .c,
.highlight .c1,
.highlight .cm,
.highlight .cs,
.highlight .cp {
  color: var(--syntax-comment);
  font-style: italic;
}

/* Keywords */
.highlight .k,
.highlight .kd,
.highlight .kn,
.highlight .kp,
.highlight .kr,
.highlight .kc,
.highlight .kt {
  color: var(--syntax-keyword);
  font-weight: 500;
}

/* Strings */
.highlight .s,
.highlight .s1,
.highlight .s2,
.highlight .sb,
.highlight .sc,
.highlight .sd,
.highlight .se,
.highlight .sh,
.highlight .si,
.highlight .sx,
.highlight .sr {
  color: var(--syntax-string);
}

/* Numbers */
.highlight .m,
.highlight .mi,
.highlight .mf,
.highlight .mh,
.highlight .mo,
.highlight .il {
  color: var(--syntax-number);
}

/* Functions and methods */
.highlight .nf,
.highlight .fm,
.highlight .nx {
  color: var(--syntax-function);
}

/* Classes and types */
.highlight .nc,
.highlight .nn,
.highlight .nd {
  color: var(--syntax-class);
}

/* Variables and names */
.highlight .na,
.highlight .nv,
.highlight .vi,
.highlight .vc,
.highlight .vg {
  color: var(--syntax-variable);
}

/* Operators */
.highlight .o,
.highlight .ow {
  color: var(--syntax-operator);
}

/* Punctuation */
.highlight .p {
  color: var(--syntax-punctuation);
}

/* Built-ins and constants */
.highlight .nb,
.highlight .bp {
  color: var(--syntax-number);
}

/* Special */
.highlight .err {
  color: var(--syntax-keyword);
}

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