@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/inter-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/newsreader-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/newsreader-italic-latin.woff2") format("woff2");
}

:root {
  --bg: #fafaf7;
  --bg-blur: rgba(250, 250, 247, 0.8);
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --subtle: #f0f0eb;
  --border: #e5e5e0;
  --max-width: 640px;
  --gutter: 1.5rem;
  --radius: 10px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* Dark theme: applied via data-theme="dark" (set by JS based on saved
   preference or system preference) */
[data-theme="dark"] {
  --bg: #111111;
  --bg-blur: rgba(17, 17, 17, 0.8);
  --fg: #ededed;
  --muted: #9a9a9a;
  --subtle: #1c1c1c;
  --border: #2a2a2a;
}

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

html {
  font-size: 17px;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection {
  background: var(--fg);
  color: var(--bg);
}

a {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--border);
  transition: text-decoration-color 0.15s ease, color 0.15s ease;
}

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

:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Nav */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-blur);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
}

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

.nav-logo {
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

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

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

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

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

.theme-toggle svg,
.arrow {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

/* Container */
.container {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--gutter) 4rem;
}

/* Hero */
.hero {
  padding: 5rem 0 2.5rem;
}

.hero h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 3rem;
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin-bottom: 0.75rem;
}

.tagline {
  color: var(--muted);
  font-size: 1.1rem;
  text-wrap: balance;
}

.prose,
.project-desc {
  text-wrap: pretty;
}

/* Sections */
.section {
  padding: 2rem 0;
}

.section-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
  margin-bottom: 1rem;
  letter-spacing: 0.02em;
}

/* About prose */
.prose {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  line-height: 1.65;
  margin-bottom: 1rem;
}

/* Projects */
.project-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0 -0.9rem;
}

.project {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.15s ease;
}

a.project:hover {
  background: var(--subtle);
}

.project-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.project-name {
  font-weight: 500;
  font-size: 1rem;
}

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

.arrow {
  color: var(--muted);
  transition: transform 0.15s ease, color 0.15s ease;
}

a.project:hover .arrow {
  color: var(--fg);
  transform: translate(2px, -2px);
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 0.5rem;
  line-height: 1.6;
}

/* Books */
.book-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.book {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.book-cover {
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 8px 24px -12px rgba(0, 0, 0, 0.35);
  margin-bottom: 0.6rem;
}

.book-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-style: italic;
  line-height: 1.3;
}

.book-author {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Links */
.links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.links a {
  display: inline-block;
  font-size: 0.9rem;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.95rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.links a:hover {
  background: var(--subtle);
  border-color: var(--muted);
}

/* Footer */
.footer {
  display: flex;
  justify-content: space-between;
  max-width: calc(var(--max-width) - 2 * var(--gutter));
  width: calc(100% - 2 * var(--gutter));
  margin: 0 auto;
  padding: 1.5rem 0 2rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

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

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    transition: none !important;
  }
}

/* Mobile */
@media (max-width: 480px) {
  html {
    font-size: 16px;
  }
  :root {
    --gutter: 1.25rem;
  }
  .hero {
    padding: 3.5rem 0 2rem;
  }
  .hero h1 {
    font-size: 2.4rem;
  }
  .nav-links {
    gap: 0.9rem;
  }
  .book-grid {
    gap: 1rem;
  }
  .book-title {
    font-size: 0.95rem;
  }
}
