/* ══════════════════════════════════════════
   Base Layout — theme-agnostic structure
   ══════════════════════════════════════════ */

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--body-font);
  font-size: var(--body-size, 17px);
  line-height: var(--body-lh, 1.7);
  min-height: 100vh;
  transition: background-color 0.4s ease, color 0.4s ease;
}

a {
  color: var(--link, var(--accent));
  text-decoration: none;
  transition: color 0.2s ease, opacity 0.2s ease;
}
a:hover { opacity: 0.8; }

img { max-width: 100%; height: auto; display: block; }

/* ── Header ── */
.site-header {
  padding: var(--header-pad, 28px 0);
  border-bottom: var(--header-border, 1px solid rgba(128,128,128,0.15));
}
.header-inner {
  max-width: var(--content-width, 720px);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.site-logo {
  font-family: var(--heading-font);
  font-size: var(--logo-size, 22px);
  font-weight: var(--logo-weight, 700);
  letter-spacing: var(--logo-tracking, -0.02em);
  color: var(--fg) !important;
  text-decoration: none;
}
.site-nav {
  display: flex;
  align-items: center;
  gap: var(--nav-gap, 28px);
}
.site-nav a {
  font-size: var(--nav-size, 14px);
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--fg);
  opacity: 0.6;
  text-transform: var(--nav-transform, none);
}
.site-nav a:hover { opacity: 1; }

/* Theme toggle button in navbar */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg);
  opacity: 0.5;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: opacity 0.15s ease;
  margin-left: 4px;
}
.theme-toggle:hover { opacity: 1; }

/* Show sun in dark mode, moon in light mode */
.icon-sun, .icon-moon { display: none; }
[data-theme="swiss-brut-night"] .icon-sun { display: block; }
[data-theme="swiss-brut-light"] .icon-moon { display: block; }
.site-nav a.active {
  opacity: 1;
  border-bottom: var(--nav-active-border, 2px solid var(--accent));
  padding-bottom: var(--nav-active-pb, 2px);
}

/* ── Hero ── */
.hero {
  padding: var(--hero-pad, 80px 24px 60px);
  text-align: var(--hero-align, left);
  max-width: var(--content-width, 720px);
  margin: 0 auto;
}
.hero-title {
  font-family: var(--heading-font);
  font-size: var(--hero-title-size, clamp(2.5rem, 6vw, 4.5rem));
  font-weight: var(--hero-title-weight, 900);
  line-height: var(--hero-title-lh, 1.05);
  letter-spacing: var(--hero-title-tracking, -0.03em);
  color: var(--fg);
  margin-bottom: 16px;
}
.hero-subtitle {
  font-size: var(--hero-sub-size, 1.15rem);
  opacity: 0.55;
  max-width: 520px;
  line-height: 1.6;
  font-weight: 300;
}

/* ── Section Title ── */
.section-title {
  font-family: var(--heading-font);
  font-size: var(--section-title-size, 13px);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.4;
  margin-bottom: 32px;
  padding: 0 24px;
  max-width: var(--content-width, 720px);
  margin-left: auto;
  margin-right: auto;
}

/* ── Post List ── */
.post-list {
  max-width: var(--content-width, 720px);
  margin: 0 auto;
  padding: 0 24px;
}

.post-card {
  padding: var(--card-pad, 32px 0);
  border-bottom: var(--card-border, 1px solid rgba(128,128,128,0.12));
  position: relative;
  cursor: pointer;
}
.post-card:last-child { border-bottom: none; }

/* Invisible full-card link overlay */
.card-link {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.post-card .post-title a,
.post-card .read-more,
.post-card .tag {
  position: relative;
  z-index: 2;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.post-meta time {
  font-size: var(--meta-size, 12px);
  font-family: var(--mono-font, 'JetBrains Mono', monospace);
  letter-spacing: 0.04em;
  opacity: 0.45;
  text-transform: var(--meta-transform, uppercase);
}
.post-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.tag {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: var(--tag-radius, 20px);
  background: var(--tag-bg, rgba(128,128,128,0.08));
  color: var(--tag-fg, var(--fg));
  font-weight: 500;
  letter-spacing: 0.03em;
}
.post-card .post-title {
  font-family: var(--heading-font);
  font-size: var(--card-title-size, 1.4rem);
  font-weight: var(--card-title-weight, 700);
  line-height: 1.25;
  letter-spacing: var(--card-title-tracking, -0.015em);
  margin-bottom: 8px;
}
.post-card .post-title a { color: var(--fg); }
.post-card .post-title a:hover { color: var(--accent); opacity: 1; }

.post-excerpt {
  font-size: var(--excerpt-size, 0.95rem);
  opacity: 0.6;
  line-height: 1.65;
  margin-bottom: 10px;
}
.read-more {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--accent) !important;
}

/* ── Single Post ── */
.single-post {
  max-width: var(--content-width, 720px);
  margin: 0 auto;
  padding: 0 24px;
}
.post-header {
  padding: var(--post-header-pad, 60px 0 40px);
}
.post-header .post-title {
  font-family: var(--heading-font);
  font-size: var(--post-title-size, clamp(2rem, 5vw, 3rem));
  font-weight: var(--post-title-weight, 800);
  line-height: 1.12;
  letter-spacing: var(--post-title-tracking, -0.025em);
  margin-bottom: 12px;
}
.post-subtitle {
  font-size: 1.15rem;
  opacity: 0.5;
  font-weight: 300;
  margin-bottom: 16px;
}

/* ── Prose ── */
.prose {
  line-height: var(--body-lh, 1.7);
}
.prose h2, .prose h3, .prose h4 {
  font-family: var(--heading-font);
  margin-top: 2.2em;
  margin-bottom: 0.6em;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
}
.prose h2 { font-size: 1.6rem; }
.prose h3 { font-size: 1.25rem; }
.prose p { margin-bottom: 1.4em; }
.prose ul, .prose ol {
  margin-bottom: 1.4em;
  padding-left: 1.6em;
}
.prose li { margin-bottom: 0.4em; }
.prose blockquote {
  border-left: var(--bq-border, 3px solid var(--accent));
  padding: 4px 0 4px 24px;
  margin: 1.8em 0;
  font-style: italic;
  opacity: 0.8;
}
.prose code {
  font-family: var(--mono-font, 'JetBrains Mono', monospace);
  font-size: 0.88em;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--code-bg, rgba(128,128,128,0.1));
}
.prose pre {
  margin: 1.8em 0;
  padding: 20px 24px;
  border-radius: var(--pre-radius, 8px);
  background: var(--pre-bg, #1e1e2e) !important;
  overflow-x: auto;
  font-size: 0.88em;
  line-height: 1.6;
}
.prose pre code {
  padding: 0;
  background: transparent;
}

/* Language label and copy button on code blocks */
.highlight {
  position: relative;
}
.highlight .copy-btn {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  color: #fff;
  opacity: 0;
  cursor: pointer;
  font-family: var(--mono-font, monospace);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  transition: opacity 0.15s ease;
  z-index: 2;
}
.highlight:hover .copy-btn {
  opacity: 0.4;
}
.highlight .copy-btn:hover {
  opacity: 0.8;
}
.highlight .copy-btn.copied {
  opacity: 0.6;
}
/* Hide language label when copy button exists (JS adds it) */
.highlight code[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 8px;
  right: 12px;
  font-family: var(--mono-font, monospace);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.3;
  color: #fff;
  pointer-events: none;
}
.highlight.has-copy code[data-lang]::before {
  display: none;
}
.prose hr {
  border: none;
  border-top: var(--hr-style, 1px solid rgba(128,128,128,0.15));
  margin: 2.5em 0;
}

/* ── Post Nav ── */
.post-footer {
  margin-top: 60px;
  padding: 32px 0 80px;
  border-top: 1px solid rgba(128,128,128,0.12);
}
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 24px;
}
.post-nav a {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

/* ── Footer ── */
.site-footer {
  padding: 40px 24px;
  text-align: center;
  font-size: 13px;
  opacity: 0.35;
}

/* ── Archive Header ── */
.archive-header {
  max-width: var(--content-width, 720px);
  margin: 0 auto;
  padding: 60px 24px 24px;
}
.page-title {
  font-family: var(--heading-font);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  text-transform: uppercase;
}
.archive-count {
  font-family: var(--mono-font, monospace);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.35;
  margin-top: 8px;
}

/* ── Archive List ── */
.archive-list {
  max-width: var(--content-width, 720px);
  margin: 0 auto;
  padding: 0 24px 60px;
}

.archive-year-group {
  margin-bottom: 0;
}

.archive-year-label {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 20px 0 12px;
  border-bottom: 1px solid var(--border-subtle, rgba(128,128,128,0.15));
  margin-bottom: 0;
}
.archive-year {
  font-family: var(--heading-font);
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--fg);
  opacity: 0.12;
}
.archive-year-count {
  font-family: var(--mono-font, monospace);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.3;
  font-weight: 600;
}
.archive-year-count::before {
  content: '— ';
}
.archive-year-count::after {
  content: ' posts';
}

.archive-year-posts {
  padding: 0;
}

/* ── Archive Items ── */
.archive-item {
  display: grid;
  grid-template-columns: 56px 1fr 24px;
  gap: 0 16px;
  align-items: center;
  padding: 16px 16px;
  margin: 0 -16px;
  position: relative;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle, rgba(128,128,128,0.08));
  transition: background-color 0.15s ease;
}
.archive-item:last-child {
  border-bottom: none;
}
.archive-item:hover {
  background: var(--card-bg, rgba(128,128,128,0.04));
}

.archive-item .card-link {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.archive-item .archive-item-title a,
.archive-item .tag {
  position: relative;
  z-index: 2;
}

.archive-item-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  line-height: 1;
}
.archive-month {
  font-family: var(--mono-font, monospace);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.35;
  font-weight: 600;
}
.archive-day {
  font-family: var(--heading-font);
  font-size: 22px;
  font-weight: 800;
  opacity: 0.15;
  letter-spacing: -0.02em;
}

.archive-item-content {
  min-width: 0;
}
.archive-item-title {
  font-family: var(--heading-font);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin-bottom: 2px;
}
.archive-item-title a {
  color: var(--fg);
}
.archive-item-title a:hover {
  color: var(--accent);
  opacity: 1;
}

.archive-item-subtitle {
  font-size: 0.85rem;
  opacity: 0.45;
  line-height: 1.4;
  margin-bottom: 4px;
}

.archive-item .post-tags {
  margin-top: 4px;
}
.archive-item .tag {
  font-size: 8px;
  padding: 1px 6px;
}

.archive-item-arrow {
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  color: var(--accent);
  font-weight: 700;
}
.archive-item:hover .archive-item-arrow {
  opacity: 0.6;
  transform: translateX(3px);
}

@media (max-width: 600px) {
  .archive-item {
    grid-template-columns: 44px 1fr 20px;
    gap: 0 12px;
    padding: 12px 12px;
    margin: 0 -12px;
  }
  .archive-day { font-size: 18px; }
}

/* ── Category ── */
.category {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

/* ── Page Transitions ── */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.site-main {
  animation: fade-in 0.25s ease-out both;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  /* Header: keep horizontal, shrink spacing */
  .header-inner {
    padding: 0 16px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .site-nav {
    gap: 16px;
  }
  .site-nav a {
    font-size: 10px;
  }

  /* Hero: less padding, smaller title */
  .hero {
    padding: 48px 16px 36px;
    padding-left: 36px;
  }
  .hero-title {
    font-size: clamp(2rem, 10vw, 3.5rem) !important;
  }
  .hero-subtitle {
    font-size: 0.85rem !important;
    max-width: 100%;
  }

  /* Post list */
  .post-list { padding: 0 16px; }
  .post-card { padding: 20px 16px; }

  /* Single post */
  .single-post { padding: 0 16px; }
  .post-header {
    padding-left: 16px !important;
  }
  .post-header .post-title {
    font-size: clamp(1.5rem, 7vw, 2.2rem) !important;
  }

  /* Prose */
  .prose pre {
    margin-left: -16px;
    margin-right: -16px;
    border-radius: 0 !important;
    padding: 16px;
  }
  .prose blockquote {
    padding-left: 16px;
  }

  /* Archive */
  .archive-header { padding: 40px 16px 16px; }
  .archive-list { padding: 0 16px 40px; }

  /* Footer */
  .site-footer { padding: 32px 16px; }

  /* Post nav: stack vertically */
  .post-nav {
    flex-direction: column;
    gap: 12px;
  }
}

@media (max-width: 480px) {
  /* Smaller phones: stack header */
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .hero {
    padding: 36px 16px 28px;
    padding-left: 28px;
  }
  .hero-title {
    font-size: clamp(1.8rem, 12vw, 2.8rem) !important;
  }

  /* Archive items: hide date column */
  .archive-item {
    grid-template-columns: 1fr 20px;
  }
  .archive-item-date {
    display: none;
  }

  /* Tags: smaller */
  .tag {
    font-size: 9px;
    padding: 1px 7px;
  }

  /* Card titles */
  .post-card .post-title {
    font-size: 1.15rem !important;
  }
}
