/* ─── Custom properties ───────────────────────────────────────────── */
:root {
  --bg:          #eeeeed;
  --fg:          #1e1e1e;
  --muted:       #6e6e6e;
  --border:      #d8d8d6;
  --card-bg:     #e5e5e4;
  --header-bg:   rgba(238, 238, 237, 0.92);

  --font-body:   system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-logo:   system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --header-h:    58px;
  --max-w:       1050px;
  --gap:         88px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg:        #222222;
    --fg:        #e2e2e0;
    --muted:     #7a7a7a;
    --border:    #333333;
    --card-bg:   #2a2a2a;
    --header-bg: rgba(34, 34, 34, 0.92);
  }
}

[data-theme="dark"] {
  --bg:        #222222;
  --fg:        #e2e2e0;
  --muted:     #7a7a7a;
  --border:    #333333;
  --card-bg:   #2a2a2a;
  --header-bg: rgba(34, 34, 34, 0.92);
}

[data-theme="light"] {
  --bg:          #eeeeed;
  --fg:          #1e1e1e;
  --muted:       #6e6e6e;
  --border:      #d8d8d6;
  --card-bg:     #e5e5e4;
  --header-bg:   rgba(238, 238, 237, 0.92);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-h);
}

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--fg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.18s, color 0.18s;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ─── Header ──────────────────────────────────────────────────────── */
#site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background-color: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  transition: border-color 0.18s, background-color 0.18s;
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 0;
}

.logo {
  font-family: var(--font-logo);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg);
  flex-shrink: 0;
  text-decoration: none;
}

nav {
  display: flex;
  align-items: center;
  gap: 26px;
  margin-left: auto;
}

nav a {
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.12s;
  white-space: nowrap;
}

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

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 24px;
}

/* ─── Theme toggle ────────────────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s;
  line-height: 1;
}

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

/* Light mode (default): show moon, hide sun */
.icon-sun { display: none; }
.icon-moon { display: block; }

/* System dark, no manual override: show sun, hide moon */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .icon-sun  { display: block; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .icon-moon { display: none;  }
}

/* Manual dark: show sun, hide moon */
[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none;  }

/* Manual light: explicit (matches default) */
[data-theme="light"] .icon-sun  { display: none;  }
[data-theme="light"] .icon-moon { display: block; }

/* ─── Hamburger ───────────────────────────────────────────────────── */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  width: 26px;
  height: 26px;
}

.nav-toggle span {
  display: block;
  height: 1.5px;
  background-color: var(--fg);
  transition: transform 0.2s ease, opacity 0.2s ease;
  transform-origin: center;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

/* ─── Main layout ─────────────────────────────────────────────────── */
main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

/* ─── Hero ────────────────────────────────────────────────────────── */
.hero {
  padding: 80px 0 72px;
  border-bottom: 1px solid var(--border);
}

.tagline {
  font-size: clamp(1.2rem, 3vw, 1.55rem);
  font-weight: 400;
  line-height: 1.5;
  color: var(--fg);
  max-width: 540px;
}

/* ─── Page sections ───────────────────────────────────────────────── */
.page-section {
  padding: var(--gap) 0;
  border-bottom: 1px solid var(--border);
}

.page-section:last-of-type {
  border-bottom: none;
}

.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 14px;
}

.section-title {
  font-size: clamp(1.3rem, 3vw, 1.625rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-bottom: 14px;
}

.section-desc {
  font-size: 0.9375rem;
  color: var(--muted);
  max-width: 500px;
  line-height: 1.65;
  margin-bottom: 32px;
}

.section-link {
  display: inline-block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg);
  text-decoration: none;
  margin-top: 28px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
  transition: border-color 0.12s;
}

.section-link:hover {
  border-bottom-color: var(--fg);
}

/* ─── Blog: recent post card ──────────────────────────────────────── */
.recent-post-card {
  display: block;
  border: 1px solid var(--border);
  padding: 20px 22px;
  background-color: var(--card-bg);
  text-decoration: none;
  color: inherit;
  transition: background-color 0.12s;
}

.recent-post-card:hover {
  background-color: var(--border);
}

.post-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  gap: 7px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 500;
}

.post-meta-sep {
  opacity: 0.4;
}

.post-title {
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.35;
  margin-bottom: 8px;
  color: var(--fg);
}

.post-excerpt {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.6;
}

/* ─── Projects: featured ──────────────────────────────────────────── */
.featured-projects {
  display: flex;
  flex-direction: column;
  margin-bottom: 32px;
}

.featured-project {
  padding: 18px 0;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 5px;
}

.featured-projects > .featured-project:last-child {
  border-bottom: 1px solid var(--border);
}

.project-name {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--fg);
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  transition: opacity 0.12s;
}

.project-name:hover {
  opacity: 0.6;
}

.project-arrow {
  font-size: 0.8em;
  opacity: 0.5;
}

.project-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.tag {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 6px;
}

.project-desc {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.55;
}

/* ─── Subsection label ────────────────────────────────────────────── */
.subsection-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 0;
}

/* ─── Recent items list (projects + random stuff) ─────────────────── */
.recent-items-list {
  display: flex;
  flex-direction: column;
}

.recent-item {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 20px;
  padding: 13px 0;
  border-top: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: opacity 0.12s;
}

.recent-items-list > .recent-item:last-child {
  border-bottom: 1px solid var(--border);
}

.recent-item:hover {
  opacity: 0.55;
}

.item-date {
  font-size: 0.8125rem;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 1px;
  flex-shrink: 0;
}

.item-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.item-title {
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--fg);
}

.item-desc {
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ─── Active nav link ─────────────────────────────────────────────── */
nav a[aria-current="page"] {
  color: var(--fg);
}

/* ─── Inner pages: shared layout ─────────────────────────────────── */
.inner-main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px 96px;
}

.page-intro {
  padding: 60px 0 48px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.page-intro-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 14px;
}

.page-title {
  font-size: clamp(1.625rem, 3.5vw, 2.125rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 12px;
}

.page-subtitle {
  font-size: 0.9375rem;
  color: var(--muted);
  line-height: 1.65;
  max-width: 480px;
}

/* ─── Back link ───────────────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
  margin-top: 40px;
  transition: color 0.12s;
}

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

/* ─── Posts list (blog + random stuff index pages) ────────────────── */
.posts-list {
  display: flex;
  flex-direction: column;
  margin-top: 8px;
}

.post-list-item {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 28px;
  padding: 18px 0;
  border-top: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: opacity 0.12s;
}

.posts-list > .post-list-item:last-child {
  border-bottom: 1px solid var(--border);
}

.post-list-item:hover {
  opacity: 0.55;
}

.post-list-date {
  font-size: 0.8125rem;
  color: var(--muted);
  padding-top: 3px;
  white-space: nowrap;
}

.post-list-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.post-list-title {
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--fg);
}

.post-list-excerpt {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.55;
}

/* ─── Article page ────────────────────────────────────────────────── */
.article-header {
  padding: 60px 0 40px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 52px;
}

.article-title {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 10px;
}

.article-meta {
  font-size: 0.8125rem;
  color: var(--muted);
}

.article-body {
  max-width: 660px;
  padding-bottom: 80px;
}

.article-body p {
  font-size: 1rem;
  line-height: 1.78;
  color: var(--fg);
  margin-bottom: 1.5em;
}

.article-body h2 {
  font-size: 1.175rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 2.5em 0 0.75em;
  line-height: 1.3;
}

.article-body h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 2em 0 0.5em;
}

.article-body a {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.article-body a:hover {
  opacity: 0.65;
}

.article-body ul,
.article-body ol {
  padding-left: 1.4em;
  margin-bottom: 1.5em;
}

.article-body li {
  font-size: 1rem;
  line-height: 1.78;
  margin-bottom: 0.3em;
}

.article-body code {
  font-family: 'SF Mono', ui-monospace, 'Fira Code', Consolas, monospace;
  font-size: 0.875em;
  background: var(--card-bg);
  padding: 0.15em 0.4em;
  border: 1px solid var(--border);
}

.article-body pre {
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 20px 24px;
  overflow-x: auto;
  margin-bottom: 1.5em;
}

.article-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.875rem;
  line-height: 1.65;
}

/* ─── About page ──────────────────────────────────────────────────── */
.about-body {
  padding: 60px 0 80px;
  max-width: 640px;
}

.about-section {
  margin-bottom: 52px;
}

.about-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 18px;
}

.about-body p {
  font-size: 1rem;
  line-height: 1.78;
  color: var(--fg);
  margin-bottom: 1.25em;
}

.about-body a {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.about-body a:hover {
  opacity: 0.65;
}

/* ─── Search & tag filter ─────────────────────────────────────────── */
.filter-section {
  padding: 28px 0 0;
}

.search-input {
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  padding: 10px 0;
  outline: none;
  transition: border-color 0.15s;
}

.search-input::placeholder {
  color: var(--muted);
}

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

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 0 6px;
  min-height: 36px;
}

.tag-pill {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 3px 8px;
  background: none;
  cursor: pointer;
  font-family: var(--font-body);
  transition: color 0.12s, border-color 0.12s, background-color 0.12s;
}

.tag-pill:hover {
  color: var(--fg);
  border-color: var(--fg);
}

.tag-pill.active {
  color: var(--bg);
  background-color: var(--fg);
  border-color: var(--fg);
}

.post-list-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}

.post-list-tag {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 5px;
}

.no-results {
  padding: 40px 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

/* ─── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  :root {
    --gap: 60px;
  }

  .nav-toggle {
    display: flex;
  }

  nav {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background-color: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 20px 24px 28px;
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
    transition: background-color 0.18s;
  }

  nav.open {
    display: flex;
  }

  nav a {
    font-size: 1rem;
    color: var(--fg);
  }

  .hero {
    padding: 56px 0 52px;
  }

  .recent-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .post-list-item {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
