@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Design Tokens ── */
:root {
  --bg:           #0E0F11;
  --surface:      #16181C;
  --surface-2:    #1C1E23;
  --border:       rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.14);
  --text:         #FFFFFF;
  --text-2:       #8A8F98;
  --text-3:       #555A63;
  --accent:       #7C3AED;
  --accent-light: #A78BFA;
  --accent-glow:  rgba(124,58,237,0.18);
  --radius:       8px;
  --radius-lg:    12px;
  --max-w:        760px;
  --nav-h:        60px;
}

/* ── Light mode ── */
[data-theme="light"] {
  --bg:           #F7F6F3;
  --surface:      #FFFFFF;
  --surface-2:    #EDEDEB;
  --border:       rgba(0,0,0,0.08);
  --border-hover: rgba(0,0,0,0.16);
  --text:         #0F0F0F;
  --text-2:       #4A4A52;
  --text-3:       #9A9AA8;
  --accent-light: #6D28D9;
  --accent-glow:  rgba(124,58,237,0.06);
}
[data-theme="light"] nav {
  background: rgba(247,246,243,0.85);
}
[data-theme="light"] .book-cover-sub { color: rgba(255,255,255,0.8); }
[data-theme="light"] .hero h1 span {
  background: linear-gradient(135deg, #0F0F0F 30%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Theme toggle button ── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  cursor: pointer;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: var(--surface-2);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ── Nav ── */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(14,15,17,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 32px;
}
.nav-inner {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  transition: opacity 0.15s;
}
.nav-logo:hover { opacity: 0.7; }
.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  margin-right: 8px;
}
.nav-links a {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover,
.nav-links a.active { color: var(--text); background: var(--surface-2); }

/* ── Mobile nav ── */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  padding: 4px;
}
.nav-mobile {
  display: none;
  flex-direction: column;
  position: fixed;
  top: var(--nav-h);
  left: 0; right: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px 16px;
  gap: 4px;
  z-index: 99;
}
.nav-mobile.open { display: flex; }
.nav-mobile a {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
  padding: 10px 12px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}
.nav-mobile a:hover,
.nav-mobile a.active { color: var(--text); background: var(--surface-2); }

/* ── Page wrapper ── */
main {
  padding-top: var(--nav-h);
}

/* ── Hero ── */
.hero {
  position: relative;
  overflow: hidden;
  padding: 120px 32px 100px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.hero-glow {
  position: absolute;
  top: -80px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}
.hero-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 24px;
}
.hero h1 {
  font-size: clamp(40px, 6vw, 64px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  max-width: 780px;
  margin-bottom: 24px;
}
.hero h1 span {
  background: linear-gradient(135deg, #fff 30%, var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub {
  font-size: 18px;
  font-weight: 400;
  color: var(--text-2);
  max-width: 520px;
  line-height: 1.6;
  margin-bottom: 40px;
}
.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #6d28d9; transform: translateY(-1px); }
.btn-ghost {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-hover); transform: translateY(-1px); }

/* ── Section ── */
.section {
  padding: 80px 32px;
  max-width: 1100px;
  margin: 0 auto;
}
.section-narrow {
  max-width: var(--max-w);
}
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 40px;
}
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0 32px;
}

/* ── Cards ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
  text-decoration: none;
  display: block;
}
.card:hover {
  border-color: var(--border-hover);
  background: var(--surface-2);
  transform: translateY(-2px);
}
.card-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 12px;
}
.card h3 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.3;
}
.card p {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
}
.card-arrow {
  margin-top: 20px;
  font-size: 18px;
  color: var(--text-3);
  transition: color 0.15s, transform 0.15s;
}
.card:hover .card-arrow { color: var(--accent-light); transform: translateX(3px); }

/* ── Prose (About, Books) ── */
.prose {
  max-width: var(--max-w);
  margin: 0 auto;
}
.prose h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin-bottom: 20px;
  color: var(--text);
}
.prose p {
  font-size: 16px;
  color: var(--text-2);
  line-height: 1.75;
  margin-bottom: 20px;
}
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--text); font-weight: 600; }

/* ── Quote block ── */
.blockquote {
  border-left: 2px solid var(--accent);
  padding: 4px 0 4px 24px;
  margin: 32px 0;
}
.blockquote p {
  font-size: 18px;
  font-style: italic;
  color: var(--text);
  line-height: 1.6;
  margin: 0;
}

/* ── Book hero ── */
.book-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 48px;
  align-items: start;
  padding: 80px 32px 60px;
  max-width: 900px;
  margin: 0 auto;
}
.book-cover {
  width: 160px;
  height: 240px;
  background: linear-gradient(135deg, var(--accent) 0%, #4c1d95 100%);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 20px 60px rgba(124,58,237,0.3);
  position: relative;
  overflow: hidden;
}
.book-cover::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 60%);
}
.book-cover-text {
  text-align: center;
  padding: 16px;
  z-index: 1;
}
.book-cover-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.book-cover-sub {
  font-size: 9px;
  color: rgba(255,255,255,0.7);
  margin-top: 8px;
  line-height: 1.4;
  letter-spacing: 0.03em;
}
.book-meta h1 {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: 8px;
}
.book-meta .subtitle {
  font-size: 16px;
  color: var(--text-2);
  margin-bottom: 24px;
  font-style: italic;
}
.book-meta .status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(124,58,237,0.15);
  border: 1px solid rgba(167,139,250,0.25);
  color: var(--accent-light);
  margin-bottom: 28px;
}
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-light);
}

/* ── Quotes list ── */
.quotes-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 40px;
}
.quotes-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 14px;
  color: var(--text-2);
  font-style: italic;
  line-height: 1.6;
}
.quotes-list li strong {
  display: block;
  font-style: normal;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-top: 6px;
  text-transform: uppercase;
}

/* ── Notify form ── */
.notify-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-top: 48px;
  text-align: center;
}
.notify-box h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.notify-box p {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 20px;
}
.notify-form {
  display: flex;
  gap: 8px;
  max-width: 400px;
  margin: 0 auto;
}
.notify-form input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.notify-form input:focus { border-color: var(--accent); }
.notify-form input::placeholder { color: var(--text-3); }

/* ── Contact page ── */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 48px;
}
.contact-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s, transform 0.2s;
  text-decoration: none;
}
.contact-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}
.contact-icon {
  width: 40px; height: 40px;
  background: rgba(124,58,237,0.12);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.contact-card h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.contact-card p {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
}
.contact-handle {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-light);
  margin-top: auto;
}

/* ── Footer ── */
footer {
  border-top: 1px solid var(--border);
  padding: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 60px auto 0;
  flex-wrap: wrap;
  gap: 16px;
}
.footer-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-3);
}
.footer-links {
  display: flex;
  gap: 20px;
}
.footer-links a {
  font-size: 13px;
  color: var(--text-3);
  transition: color 0.15s;
}
.footer-links a:hover { color: var(--text-2); }

/* ── Contact form ── */
.contact-form {
  max-width: 560px;
  margin: 48px auto 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-field label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.form-field input,
.form-field textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  resize: none;
}
.form-field input:focus,
.form-field textarea:focus {
  border-color: var(--accent);
  background: var(--surface-2);
}
.form-field input::placeholder,
.form-field textarea::placeholder { color: var(--text-3); }
.form-field textarea { min-height: 140px; line-height: 1.6; }
.form-submit { align-self: flex-start; }
#form-success {
  display: none;
  text-align: center;
  padding: 32px;
  background: var(--surface);
  border: 1px solid rgba(167,139,250,0.2);
  border-radius: var(--radius-lg);
  max-width: 560px;
  margin: 48px auto 0;
}
#form-success p { color: var(--text-2); font-size: 15px; margin: 8px 0 0; }

/* ── Responsive ── */
@media (max-width: 768px) {
  nav { padding: 0 20px; }
  .nav-links { display: none; }
  .nav-toggle { display: flex; }

  .hero { padding: 80px 20px 70px; }
  .hero h1 { font-size: 36px; }
  .hero-sub { font-size: 16px; }

  .section { padding: 60px 20px; }
  .section-divider { margin: 0 20px; }

  .book-hero {
    grid-template-columns: 1fr;
    gap: 32px;
    padding: 60px 20px 40px;
  }
  .book-cover { width: 120px; height: 180px; }

  .notify-form { flex-direction: column; }

  footer { padding: 24px 20px; }
}

/* ── Post pages ── */
.post-body { padding-top: 60px; padding-bottom: 100px; }
.post-title {
  font-size: clamp(28px, 4.5vw, 44px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--text);
  margin: 8px 0 32px;
}
.post-hero {
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  margin-bottom: 32px;
  display: block;
}
.post-video {
  position: relative;
  aspect-ratio: 16 / 9;
  margin-bottom: 32px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
.post-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; }
.post-body .cat-pill { vertical-align: middle; }

/* Markdown-rendered prose extras */
.prose h3 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
  margin: 32px 0 12px;
}
.prose ul, .prose ol { margin: 0 0 20px 24px; color: var(--text-2); line-height: 1.75; }
.prose li { margin-bottom: 6px; }
.prose blockquote {
  border-left: 2px solid var(--accent);
  padding: 4px 0 4px 20px;
  margin: 24px 0;
  color: var(--text-2);
  font-style: italic;
}
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
}
.prose pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  overflow-x: auto;
  margin: 0 0 24px;
}
.prose pre code { background: none; padding: 0; font-size: 13px; line-height: 1.6; }
.prose a { color: var(--accent-light); text-decoration: underline; text-underline-offset: 3px; }
.prose a:hover { opacity: 0.8; }
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 24px;
  font-size: 14px;
}
.prose th, .prose td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  color: var(--text-2);
}
.prose th { color: var(--text); font-weight: 600; }
.prose img { max-width: 100%; height: auto; border-radius: 8px; margin: 16px 0; }

/* Category pills (writing.html and post pages) */
.cat-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
}
.cat-science { background: rgba(14,116,144,0.15); color: #22d3ee; border: 1px solid rgba(14,116,144,0.3); }
.cat-systems { background: rgba(217,119,6,0.12); color: #fbbf24; border: 1px solid rgba(217,119,6,0.25); }
.cat-mind    { background: rgba(124,58,237,0.12); color: var(--accent-light); border: 1px solid rgba(124,58,237,0.25); }
