/* ─── Reset ─────────────────────────────────────────────────────────────── */

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

/* ─── Base ──────────────────────────────────────────────────────────────── */

:root {
  --font: "ui-monospace", "SFMono-Regular", "SF Mono", "Cascadia Mono",
          "Segoe UI Mono", "Roboto Mono", "Oxygen Mono", "Ubuntu Monospace",
          "Source Code Pro", "Fira Mono", "Droid Sans Mono", "Courier New",
          monospace;
  --fg:       #111111;
  --bg:       #ffffff;
  --muted:    #666666;
  --link:     #111111;
  --link-hover: #000000;
  --border:   #e0e0e0;
  --max-width: 850px;
  --font-size: 18px;
  --line-height: 1.75;
}

[data-theme="dark"] {
  --fg:       #e0e0e0;
  --bg:       #1a1a1a;
  --muted:    #999999;
  --link:     #e0e0e0;
  --link-hover: #ffffff;
  --border:   #333333;
}

html {
  font-size: var(--font-size);
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: var(--font);
  line-height: var(--line-height);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
  -webkit-font-smoothing: antialiased;
}

/* ─── Links ─────────────────────────────────────────────────────────────── */

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
}

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

/* ─── Header / Nav ──────────────────────────────────────────────────────── */

header {
  margin-bottom: 3rem;
}

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-left > a {
  font-weight: bold;
  font-size: 1rem;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.nav-left > a:hover {
  text-decoration: underline;
  text-decoration-color: var(--fg);
}

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}

.theme-toggle:hover {
  border-color: var(--fg);
}

[data-theme="dark"] .icon-sun { display: inline; filter: invert(1); }
[data-theme="dark"] .icon-moon { display: none; }
:root:not([data-theme="dark"]) .icon-sun { display: none; }
:root:not([data-theme="dark"]) .icon-moon { display: inline; }

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
}

.nav-links a:hover {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--fg);
}

/* ─── Main content ──────────────────────────────────────────────────────── */

main {
  min-height: 60vh;
}

/* ─── About section ─────────────────────────────────────────────────────── */

.about {
  margin-bottom: 3rem;
}

.about .bio p {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.7;
}

.quote {
  margin-top: 1.5rem;
  padding: 1rem 1.5rem;
  border-left: 3px solid var(--border);
  font-style: italic;
}

.quote p {
  margin: 0;
  font-size: 1rem;
  color: var(--fg);
}

.quote cite {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: normal;
}

/* ─── Posts section ─────────────────────────────────────────────────────── */

.posts-section {
  margin-top: 2rem;
}

/* ─── Intro section ─────────────────────────────────────────────────────── */

.intro {
  margin-bottom: 3rem;
}

.intro p {
  color: var(--muted);
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

/* ─── Section headings ──────────────────────────────────────────────────── */

h2 {
  font-size: 0.75rem;
  font-weight: normal;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

/* ─── Post list ─────────────────────────────────────────────────────────── */

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

.post-list li {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.post-list li:first-child {
  border-top: 1px solid var(--border);
}

.post-date {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 7.5rem;
}

.post-list a {
  font-size: 0.9rem;
  text-decoration: none;
}

.post-list a:hover {
  text-decoration: underline;
  text-decoration-color: var(--fg);
}

/* ─── Post page ─────────────────────────────────────────────────────────── */

.post-header {
  margin-bottom: 2.5rem;
}

.post-header h1 {
  font-size: 1.25rem;
  font-weight: bold;
  line-height: 1.4;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.post-meta {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

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

.tag {
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0 0.35rem;
}

/* ─── Post body typography ──────────────────────────────────────────────── */

.post-body {
  font-size: 0.9rem;
}

.post-body p {
  margin-bottom: 1.25rem;
}

.post-body h1,
.post-body h2,
.post-body h3,
.post-body h4 {
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  font-size: 1rem;
  font-weight: bold;
  letter-spacing: -0.01em;
}

.post-body h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: normal;
}

.post-body ul,
.post-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}

.post-body li {
  margin-bottom: 0.35rem;
}

.post-body blockquote {
  border-left: 2px solid var(--border);
  padding-left: 1rem;
  color: var(--muted);
  margin: 1.5rem 0;
  font-style: italic;
}

.post-body code {
  font-family: var(--font);
  font-size: 0.85em;
  background: #f5f5f5;
  padding: 0.1em 0.3em;
  border-radius: 2px;
}

.post-body pre {
  background: #f5f5f5;
  padding: 1rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.82rem;
  line-height: 1.6;
  border-left: 2px solid var(--border);
}

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

.post-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.post-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem 0;
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 1.5rem 0;
}

.post-body th,
.post-body td {
  text-align: left;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
}

.post-body th {
  background: #f5f5f5;
  font-weight: bold;
}

/* ─── Post navigation ───────────────────────────────────────────────────── */

.post-nav {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.post-nav a {
  color: var(--muted);
  text-decoration: none;
}

.post-nav a:hover {
  color: var(--fg);
}

/* ─── Comments ──────────────────────────────────────────────────────────── */

.comments {
  margin-top: 3rem;
}

.comments h3 {
  font-size: 0.75rem;
  font-weight: normal;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

/* ─── Search ────────────────────────────────────────────────────────────── */

.search-page h2 {
  margin-bottom: 1rem;
}

#search-input {
  font-family: var(--font);
  font-size: 0.9rem;
  width: 100%;
  padding: 0.5rem 0;
  border: none;
  border-bottom: 1px solid var(--border);
  outline: none;
  background: transparent;
  color: var(--fg);
  margin-bottom: 1.5rem;
}

#search-input:focus {
  border-bottom-color: var(--fg);
}

#search-empty {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ─── Footer ────────────────────────────────────────────────────────────── */

footer {
  margin-top: 4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

footer p {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
}

.social-links {
  display: flex;
  gap: 1rem;
}

.social-links a {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
}

.social-links a:hover {
  color: var(--fg);
  text-decoration: underline;
}

/* ─── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  body {
    padding: 1.5rem 1rem 3rem;
  }

  .post-list li {
    flex-direction: column;
    gap: 0.15rem;
  }

  .post-date {
    font-size: 0.75rem;
    min-width: unset;
  }
}

/* ─── Profile Picture & About Header ───────────────────────────────────── */

.about-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.profile-pic {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  filter: grayscale(100%);
  transition: filter 0.3s ease;
}

.profile-pic:hover {
  filter: grayscale(0%);
}

.about-intro h1 {
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
}

.about-intro .tagline {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0;
}

/* ─── Photos Page ───────────────────────────────────────────────────────── */

.photos-page h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.photos-intro {
  color: var(--muted);
  margin-bottom: 2rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
}

.photo-item {
  margin: 0;
}

.photo-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 4px;
  filter: grayscale(100%);
  transition: filter 0.3s ease;
}

.photo-item img:hover {
  filter: grayscale(0%);
}

.photo-item figcaption {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.no-photos {
  grid-column: 1 / -1;
  color: var(--muted);
  font-style: italic;
}

.no-photos code {
  background: var(--border);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.85em;
}

/* ─── Contact Page ──────────────────────────────────────────────────────── */

.contact-page h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.contact-intro {
  color: var(--muted);
  margin-bottom: 2rem;
}

.contact-form {
  max-width: 500px;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--fg);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

.submit-btn {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.75rem 1.5rem;
  background: var(--fg);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.submit-btn:hover {
  opacity: 0.85;
}

.contact-alt {
  margin-top: 2rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ─── Stats Page ────────────────────────────────────────────────────────── */

.stats-page h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.stats-intro {
  color: var(--muted);
  margin-bottom: 2rem;
}

.stats-summary {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.stat-number {
  font-size: 2rem;
  font-weight: bold;
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.chart-container {
  margin-bottom: 2.5rem;
}

.chart-container h2 {
  margin-bottom: 1rem;
}

.chart-container canvas {
  max-height: 300px;
}

.tags-breakdown h2 {
  margin-bottom: 1rem;
}

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

.tag-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.tag-list li:first-child {
  border-top: 1px solid var(--border);
}

.tag-name {
  font-weight: 500;
}

.tag-count {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ─── Responsive for new pages ──────────────────────────────────────────── */

@media (max-width: 600px) {
  .about-header {
    flex-direction: column;
    text-align: center;
  }
  
  .profile-pic {
    width: 100px;
    height: 100px;
  }
  
  .photo-grid {
    grid-template-columns: 1fr;
  }
}
