/* ============================================================
   Design tokens
   ============================================================ */

:root {
  /* Light mode defaults */
  --bg: #f8f6f1;
  --text: #1a1a18;
  --text-muted: #6b6860;
  --border: #dbd8d0;
  --header-bg: rgba(248, 246, 241, 0.92);
  --link: #1a1a18;
  --link-hover: #6b6860;

  /* Layout */
  --max-content: 720px;
  --nav-height: 56px;
  --nav-clearance: 72px;

  /* Spacing scale */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-14: 3.5rem;
  --space-16: 4rem;

  /* Typography */
  --font-xs:   0.6875rem;
  --font-sm:   0.8125rem;
  --font-base: 0.875rem;
  --font-md:   0.9375rem;
  --font-lg:   1.25rem;
  --font-xl:   1.5rem;
  --font-2xl:  1.75rem;

  /* Border radius */
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;

  /* Transitions */
  --duration-fast: 200ms;
  --duration-base: 380ms;
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #121212;
  --text: #e8e6e1;
  --text-muted: #9a9890;
  --border: #2e2e2c;
  --header-bg: rgba(18, 18, 18, 0.92);
  --link: #e8e6e1;
  --link-hover: #9a9890;

  color-scheme: dark;
}

/* ============================================================
   Reset & base
   ============================================================ */

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

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: Georgia, "Times New Roman", Times, serif;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: var(--nav-clearance); /* clearance for fixed header */
}

/* ============================================================
   Header & nav
   ============================================================ */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  transition: transform var(--duration-base) var(--ease-standard);
}

.site-header.header--hidden {
  transform: translateY(-100%);
}

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

.nav-name {
  font-family: Georgia, serif;
  font-size: 1rem;
  font-weight: normal;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.nav-name:hover {
  color: var(--text-muted);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.nav-link {
  font-size: var(--font-base);
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.03em;
}

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

/* ============================================================
   Theme toggle
   ============================================================ */

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius-md);
  transition: color var(--duration-fast) ease;
}

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

/* In light mode: show moon (to switch to dark), hide sun */
:root[data-theme="light"] .icon-sun {
  display: none;
}

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

/* In dark mode: show sun (to switch to light), hide moon */
:root[data-theme="dark"] .icon-sun {
  display: block;
}

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

/* ============================================================
   Main content wrapper
   ============================================================ */

.main {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: var(--space-12) var(--space-6) var(--space-16);
}

/* ============================================================
   Homepage
   ============================================================ */

.home {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

.identity {
  padding-bottom: var(--space-10);
  border-bottom: 1px solid var(--border);
}

.identity h1 {
  font-size: var(--font-2xl);
  font-weight: normal;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-3);
}

.bio {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 60ch;
}

.bio p {
  margin-bottom: var(--space-3);
}

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

.socials {
  display: flex;
  gap: var(--space-5);
  margin-top: var(--space-5);
}

.social-link {
  font-size: var(--font-sm);
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border);
  letter-spacing: 0.01em;
}

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

.section-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.section-heading {
  font-size: var(--font-xs);
  font-weight: normal;
  font-variant: small-caps;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.section-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.section-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-1) 0;
}

.section-link {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border);
  font-size: 1rem;
}

.section-link:hover {
  text-decoration-color: var(--text-muted);
}

.section-meta {
  font-size: var(--font-sm);
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.section-more {
  font-size: var(--font-base);
  color: var(--text-muted);
  text-decoration: none;
  margin-top: var(--space-1);
}

.section-more:hover {
  color: var(--text);
}

/* ============================================================
   Work / experience section
   ============================================================ */

.work-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.work-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border);
}

.work-item:first-child {
  padding-top: 0;
  border-top: none;
}

.work-header {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.work-role {
  font-size: 1rem;
  font-weight: bold;
  color: var(--text);
}

.work-company {
  font-size: var(--font-sm);
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.work-projects {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.work-project {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.work-note {
  font-size: var(--font-base);
  color: var(--text-muted);
  font-style: italic;
}

.work-press {
  font-size: var(--font-sm);
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.work-press:hover {
  color: var(--text);
}

.work-bullets {
  list-style: disc;
  padding-left: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.work-bullets li {
  font-size: var(--font-md);
  color: var(--text-muted);
  line-height: 1.6;
}

/* ============================================================
   Archive / list page
   ============================================================ */

.page-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.page-title {
  font-size: var(--font-xl);
  font-weight: normal;
  letter-spacing: -0.01em;
}

.archive-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.archive-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
}

.archive-item:first-child {
  border-top: 1px solid var(--border);
}

.archive-link {
  color: var(--text);
  text-decoration: none;
  font-size: 1rem;
}

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

.archive-year {
  font-size: var(--font-sm);
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.empty-message {
  color: var(--text-muted);
  font-size: var(--font-md);
}

/* ============================================================
   Single / article page
   ============================================================ */

.article {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.article-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
}

.article-title {
  font-size: var(--font-2xl);
  font-weight: normal;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.article-date {
  font-size: var(--font-base);
  color: var(--text-muted);
}

/* ============================================================
   Prose (article body)
   ============================================================ */

.prose {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.prose h2 {
  font-size: var(--font-lg);
  font-weight: normal;
  letter-spacing: -0.005em;
  margin-top: var(--space-2);
}

.prose h3 {
  font-size: 1rem;
  font-weight: bold;
  margin-top: var(--space-1);
}

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

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

.prose blockquote {
  border-left: 2px solid var(--border);
  padding-left: var(--space-5);
  color: var(--text-muted);
  font-style: italic;
}

.prose code {
  font-family: "SF Mono", "Fira Mono", "Consolas", monospace;
  font-size: 0.85em;
  background: var(--border);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
}

.prose pre {
  background: var(--border);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  font-size: 0.85rem;
}

.prose pre code {
  background: none;
  padding: 0;
}

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

.site-footer {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--font-sm);
}

/* ============================================================
   Responsive — 640px breakpoint
   ============================================================ */

@media (max-width: 640px) {
  :root {
    --nav-height: 48px;
    --nav-clearance: 60px;
  }

  html {
    font-size: 18px;
  }

  body {
    padding-top: var(--nav-clearance);
  }

  .nav {
    padding: 0 var(--space-5);
    height: var(--nav-height);
  }

  .main {
    padding: var(--space-10) var(--space-5) var(--space-14);
  }

  .home {
    gap: var(--space-8);
  }

  .identity {
    padding-bottom: 1.75rem;
  }

  .site-footer {
    padding: var(--space-8) var(--space-5);
  }
}

/* ============================================================
   Reduced motion
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }

  html {
    scroll-behavior: auto;
  }
}
