/* ─── Tokens ─────────────────────────────────────────────────────── */
:root {
  --bg:          #f5f5f5;
  --text:        #1a1a1a;
  --text-muted:  #6e6e73;
  --accent:      #0066cc;
  --border:      rgba(0, 0, 0, 0.07);
  --nav-bg:      rgba(245, 245, 245, 0.88);
}

[data-theme="dark"] {
  --bg:          #0a0a0a;
  --text:        #e0e0e0;
  --text-muted:  #888;
  --accent:      #5599ff;
  --border:      rgba(255, 255, 255, 0.07);
  --nav-bg:      rgba(10, 10, 10, 0.88);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, "SF Pro Display", "Segoe UI", Inter, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.75;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* ─── Nav ────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.nav-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 32px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  transition: opacity 0.15s ease;
}
.nav-logo:hover { opacity: 0.65; }

.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-links a {
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
  display: flex;
  align-items: center;
  min-height: 44px;
}
.nav-links a:hover,
.nav-links a.active { color: var(--text); }

/* ─── Theme toggle ───────────────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-muted);
  padding: 4px 2px;
  line-height: 1;
  display: flex;
  align-items: center;
  transition: color 0.15s ease;
}
.theme-toggle:hover { color: var(--text); }

/* ─── Main layout ────────────────────────────────────────────────── */
.main {
  max-width: 720px;
  margin: 0 auto;
  padding: 88px 32px 128px;
}

/* ─── Intro (home) ───────────────────────────────────────────────── */
.intro {
  margin-bottom: 96px;
}

.intro-eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.intro-text {
  font-size: 17px;
  line-height: 1.75;
  font-weight: 400;
  color: var(--text);
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}

/* ─── Section label ──────────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ─── Post list ──────────────────────────────────────────────────── */
.post-list {
  list-style: none;
}

.post-item {
  border-top: 1px solid var(--border);
  transition: border-color 0.25s ease;
}
.post-list > .post-item:last-child {
  border-bottom: 1px solid var(--border);
}

.post-item a {
  display: block;
  padding: 24px 0;
  text-decoration: none;
}

.post-item-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
}

.post-title {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  transition: color 0.15s ease;
}
.post-item a:hover .post-title { color: var(--accent); }

.post-date {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.post-excerpt {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}

/* ─── View all ───────────────────────────────────────────────────── */
.view-all {
  display: inline-block;
  margin-top: 36px;
  font-size: 14px;
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.15s ease;
}
.view-all:hover { opacity: 0.7; }

/* ─── Writing page header ────────────────────────────────────────── */
.page-header {
  margin-bottom: 64px;
}

.page-title {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
}

/* ─── Single post ────────────────────────────────────────────────── */
.post-back {
  display: inline-block;
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 48px;
  transition: color 0.15s ease;
}
.post-back:hover { color: var(--text); }

.post-back-bottom {
  margin-bottom: 0;
  margin-top: 56px;
}

.post-header {
  margin-bottom: 56px;
}

.post-heading {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 12px;
}

.post-meta {
  font-size: 14px;
  color: var(--text-muted);
}

.post-body {
  max-width: 600px;
}

.post-body p {
  font-size: 17px;
  line-height: 1.82;
  color: var(--text);
  margin-bottom: 28px;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.post-body p:last-child { margin-bottom: 0; }

/* ─── Contact (home bottom) ──────────────────────────────────────── */
.contact {
  margin-top: 120px;
  padding-top: 48px;
  border-top: 1px solid var(--border);
  transition: border-color 0.25s ease;
}

.contact-links {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contact-links a {
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
  width: fit-content;
  transition: color 0.15s ease;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.contact-links a:hover { color: var(--accent); }

/* ─── Tags ───────────────────────────────────────────────────────── */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 7px;
  transition: border-color 0.25s ease;
}

/* on post page, tags sit below the date */
.post-meta .tag-list {
  margin-top: 14px;
}

/* ─── Utility ────────────────────────────────────────────────────── */
.loading,
.error-msg {
  font-size: 14px;
  color: var(--text-muted);
  padding: 24px 0;
  list-style: none;
}

/* ─── Responsive: portrait mobile ───────────────────────────────── */
@media (max-width: 640px) {
  .nav-inner {
    padding: 0 20px;
  }
  .nav-links {
    gap: 16px;
  }
  .main {
    padding: 72px 20px 96px;
  }
  .intro {
    margin-bottom: 64px;
  }
  .intro-text {
    font-size: 16px;
  }

  .page-header {
    margin-bottom: 40px;
  }
  .post-item-header {
    flex-direction: column;
    gap: 3px;
  }
  .page-title {
    font-size: 26px;
  }
  .post-heading {
    font-size: 23px;
  }
  .post-body p {
    font-size: 16px;
  }
  .contact {
    margin-top: 80px;
  }
}

/* ─── Responsive: landscape mobile & small tablets ──────────────── */
@media (orientation: landscape) and (max-height: 600px) {
  .nav-inner {
    height: 48px;
    padding: 0 24px;
  }
  .main {
    padding: 64px 24px 72px;
  }
  .intro {
    margin-bottom: 56px;
  }
  .intro-text {
    font-size: 18px;
  }
  .page-header {
    margin-bottom: 40px;
  }
  .page-title {
    font-size: 24px;
  }
  .post-back {
    margin-bottom: 32px;
  }
  .post-header {
    margin-bottom: 36px;
  }
  .post-heading {
    font-size: 22px;
  }
  .contact {
    margin-top: 64px;
    padding-top: 36px;
  }
}

/* ─── Responsive: landscape mobile narrow (phones) ──────────────── */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 900px) {
  .nav-inner {
    padding: 0 20px;
  }
  .nav-links {
    gap: 16px;
  }
  .main {
    padding: 40px 20px 64px;
  }
  .post-item-header {
    flex-direction: column;
    gap: 3px;
  }
}