/* ============================================================
   ROOT & RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink:    #0e0e0e;
  --ink-2:  #3a3a3a;
  --ink-3:  #888888;
  --paper:  #f5f3ef;
  --paper-2:#eeece8;
  --night:  #0e0e0e;
  --night-2:#161616;
  --accent: #c8a96e;   /* warm gold */
  --accent-soft: rgba(200, 169, 110, 0.16);
  --line:   rgba(0,0,0,0.1);
  --line-d: rgba(255,255,255,0.08);

  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;

  --max-w: 1200px;
  --max-narrow: 720px;
  --nav-h: 64px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
}

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
ol, ul { list-style: none; }

/* ============================================================
   UTILITY
   ============================================================ */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 32px;
}
.container-narrow {
  max-width: var(--max-narrow);
  margin: 0 auto;
  padding: 0 32px;
}

/* ============================================================
   REVEAL ANIMATIONS — GPU only, respects prefers-reduced-motion
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
  .reveal-up {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.7s var(--ease-out) var(--d, 0ms),
                transform 0.7s var(--ease-out) var(--d, 0ms);
  }
  .reveal-up.is-visible {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   NAV
   ============================================================ */
#navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  z-index: 100;
  transition: background 0.3s, box-shadow 0.3s;
}
#navbar.scrolled {
  background: rgba(245, 243, 239, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 var(--line);
}
.nav-logo {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.04em;
}
.nav-links {
  display: flex;
  gap: 36px;
  font-size: 0.875rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}
.nav-links a {
  position: relative;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 0; right: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform 0.25s var(--ease-out);
  transform-origin: left;
}
.nav-links a:hover,
.nav-links a.active { opacity: 1; }
.nav-links a:hover::after,
.nav-links a.active::after { transform: scaleX(1); }

/* Mobile toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 1.5px;
  background: var(--ink);
  transition: transform 0.3s, opacity 0.3s;
}
.nav-toggle.open span:first-child { transform: translateY(7.5px) rotate(45deg); }
.nav-toggle.open span:last-child  { transform: translateY(-7.5px) rotate(-45deg); }

/* Mobile menu */
.mobile-menu {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--paper);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.mobile-menu.open {
  opacity: 1;
  pointer-events: all;
}
.mobile-menu a {
  font-family: var(--font-display);
  font-size: 2.5rem;
  opacity: 0.8;
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: calc(var(--nav-h) + 48px) 32px 120px;
  position: relative;
  background:
    linear-gradient(90deg, var(--accent-soft) 0, var(--accent-soft) 1px, transparent 1px),
    var(--paper);
  background-size: 25% 100%, auto;
  overflow: hidden;
}
.hero::after {
  content: '';
  position: absolute;
  right: 32px;
  bottom: 96px;
  width: min(34vw, 420px);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(14, 14, 14, 0.28));
}
.hero-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
}
.hero-tag {
  font-size: 0.8125rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 28px;
}
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 8vw, 7.5rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
  margin-bottom: 32px;
  max-width: 980px;
}
.hero-title .line { display: block; }
.hero-title .italic-word { font-style: italic; }

.hero-sub {
  font-size: clamp(1rem, 1.5vw, 1.175rem);
  color: #2d2d2d;
  max-width: 600px;
  margin-bottom: 48px;
  line-height: 1.7;
}
.hero-cta { display: flex; gap: 16px; flex-wrap: wrap; }

/* Scroll indicator */
.hero-scroll {
  position: absolute;
  bottom: 40px;
  left: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.scroll-line {
  width: 1px;
  height: 48px;
  background: var(--ink-3);
  transform-origin: top;
  animation: scrollDrop 1.8s var(--ease-out) 1.2s infinite;
}
@keyframes scrollDrop {
  0%   { transform: scaleY(0); opacity: 1; }
  60%  { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1); opacity: 0; }
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  border-radius: 2px;
  transition: background 0.22s, color 0.22s, border-color 0.22s, transform 0.22s;
  cursor: pointer;
}
.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
}
.btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
  transform: translateY(-2px);
}
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--ink);
  transform: translateY(-2px);
}

/* ============================================================
   MARQUEE
   ============================================================ */
.marquee-wrap {
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
  background: var(--paper-2);
}
.marquee-track {
  display: flex;
  gap: 0;
  white-space: nowrap;
  will-change: transform;
  animation: marquee 28s linear infinite;
}
.marquee-track span {
  font-size: 0.8125rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 20px;
}
.marquee-track .dot { padding: 0 4px; }
@keyframes marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .marquee-track { animation: none; }
}

/* ============================================================
   SECTIONS
   ============================================================ */
.section {
  padding: 112px 0;
}
.section-dark {
  background: linear-gradient(180deg, var(--night) 0%, #111 100%);
  color: #f0ede8;
  --line: var(--line-d);
}
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 56px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.section-label {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.section-label::before {
  content: '';
  display: inline-block;
  width: 28px;
  height: 1px;
  margin-right: 12px;
  vertical-align: middle;
  background: currentColor;
  opacity: 0.58;
}
.section-label.light { color: rgba(245, 243, 239, 0.66); }
.section-link {
  font-size: 0.875rem;
  color: var(--ink-2);
  transition: color 0.2s;
}
.section-link:hover { color: var(--ink); }

/* ============================================================
   POSTS GRID
   ============================================================ */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.posts-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}
.post-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 32px;
  background: var(--paper-2);
  border: 1px solid rgba(14, 14, 14, 0.06);
  border-radius: 6px;
  transition: background 0.25s, border-color 0.25s, transform 0.25s, box-shadow 0.25s;
  cursor: pointer;
}
.post-card:hover {
  background: #e8e5e0;
  border-color: rgba(200, 169, 110, 0.42);
  box-shadow: 0 16px 40px rgba(14, 14, 14, 0.08);
  transform: translateY(-4px);
}
.post-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}
.post-tag {
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6c552b;
  border: 1px solid rgba(200, 169, 110, 0.38);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 2px;
}
.post-date {
  font-size: 0.75rem;
  color: var(--ink-3);
}
.post-title {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 1.4vw, 1.35rem);
  line-height: 1.25;
  flex: 1;
}
.post-excerpt {
  font-size: 0.875rem;
  color: var(--ink-2);
  line-height: 1.65;
}
.post-read {
  font-size: 0.8125rem;
  color: var(--ink-3);
  margin-top: auto;
  transition: color 0.2s;
}
.post-card:hover .post-read { color: var(--ink); }

/* ============================================================
   PROJECTS LIST
   ============================================================ */
.projects-list { display: flex; flex-direction: column; }

.project-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 32px;
  align-items: start;
  padding: 48px 28px;
  margin: 0 -28px;
  border-bottom: 1px solid var(--line-d);
  border-radius: 6px;
  transition: background 0.25s, border-color 0.25s, transform 0.25s;
}
.project-item:hover {
  background: rgba(245, 243, 239, 0.045);
  border-bottom-color: rgba(200, 169, 110, 0.38);
  transform: translateX(6px);
}
.project-number {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--accent);
  padding-top: 2px;
}
.project-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.project-tags span {
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(245, 243, 239, 0.82);
  border: 1px solid rgba(245, 243, 239, 0.28);
  background: rgba(245, 243, 239, 0.045);
  padding: 4px 10px;
  border-radius: 2px;
}
.project-title {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  line-height: 1.15;
  color: #f0ede8;
  margin-bottom: 14px;
}
.project-desc {
  font-size: 0.975rem;
  color: rgba(245, 243, 239, 0.78);
  max-width: 640px;
  line-height: 1.72;
}
.project-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 6px;
}
.project-link {
  font-size: 0.8125rem;
  color: rgba(245, 243, 239, 0.72);
  transition: color 0.2s;
  white-space: nowrap;
}
.project-link:hover { color: var(--accent); }

/* ============================================================
   ABOUT
   ============================================================ */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 80px;
  align-items: start;
}
.about-title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 4vw, 3.75rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-top: 16px;
}
.about-title em { font-style: italic; }
#about {
  background: #111;
  color: var(--paper);
  border-top: 1px solid rgba(245, 243, 239, 0.08);
}
#about .section-label {
  color: rgba(245, 243, 239, 0.64);
}
#about .about-title {
  color: var(--paper);
  max-width: 560px;
}
.about-right p {
  font-size: 1.075rem;
  color: var(--ink-2);
  line-height: 1.75;
  margin-bottom: 20px;
}
#about .about-right p {
  color: rgba(245, 243, 239, 0.78);
}
#about .about-right p strong {
  color: var(--paper);
  font-weight: 500;
}
.about-right p strong { color: var(--ink); font-weight: 500; }
.about-links { display: flex; gap: 16px; margin-top: 40px; flex-wrap: wrap; }
#about .btn-primary {
  background: var(--paper);
  color: var(--night);
  border-color: var(--paper);
}
#about .btn-primary:hover {
  background: var(--paper-2);
  border-color: var(--paper-2);
}
#about .btn-ghost {
  color: var(--paper);
  border-color: rgba(245, 243, 239, 0.28);
}
#about .btn-ghost:hover {
  border-color: rgba(245, 243, 239, 0.76);
}

/* ============================================================
   PAGE HEADER (writings / cv)
   ============================================================ */
.page-header {
  padding: calc(var(--nav-h) + 80px) 0 64px;
  border-bottom: 1px solid var(--line);
}
.page-title {
  font-family: var(--font-display);
  font-size: clamp(3rem, 6vw, 5.5rem);
  line-height: 1.06;
  letter-spacing: -0.02em;
  margin: 16px 0 20px;
}
.page-title em { font-style: italic; }
.page-sub {
  font-size: 1.075rem;
  color: var(--ink-2);
  max-width: 560px;
  line-height: 1.7;
  margin-bottom: 36px;
}
.page-sub a { text-decoration: underline; text-underline-offset: 3px; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  border-bottom: 1px solid var(--line);
  padding: 0;
}
.filters {
  display: flex;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filter-btn {
  padding: 16px 24px;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
}
.filter-btn:hover { color: var(--ink); }
.filter-btn.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* ============================================================
   WRITINGS LIST
   ============================================================ */
.writings-list { padding: 0 0 80px; }

.writing-row {
  display: grid;
  grid-template-columns: 200px 1fr 48px;
  gap: 32px;
  align-items: start;
  padding: 40px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: opacity 0.2s;
}
.writing-row:hover { opacity: 0.75; }
.writing-row.hidden { display: none; }
.writing-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 6px;
}
.writing-title {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2vw, 1.75rem);
  line-height: 1.2;
  margin-bottom: 12px;
}
.writing-excerpt {
  font-size: 0.9rem;
  color: var(--ink-2);
  line-height: 1.65;
}
.writing-arrow {
  font-size: 1.25rem;
  color: var(--ink-3);
  padding-top: 6px;
  transition: transform 0.2s;
}
.writing-row:hover .writing-arrow { transform: translate(4px, -4px); }

/* ============================================================
   POST PAGE
   ============================================================ */
.reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  background: var(--ink);
  width: 0%;
  z-index: 200;
  transition: width 0.1s linear;
}

.post-header {
  padding: calc(var(--nav-h) + 64px) 0 56px;
  border-bottom: 1px solid var(--line);
}
.back-link {
  display: inline-block;
  font-size: 0.875rem;
  color: var(--ink-3);
  margin-bottom: 32px;
  transition: color 0.2s;
}
.back-link:hover { color: var(--ink); }
.post-header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.post-read-time { font-size: 0.75rem; color: var(--ink-3); }
.post-heading {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4.5vw, 3.75rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}
.post-lede {
  font-size: 1.125rem;
  color: var(--ink-2);
  line-height: 1.7;
  max-width: 600px;
}

.post-content {
  padding: 72px 0;
}
.post-content h2 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 2.5vw, 2.2rem);
  line-height: 1.2;
  margin: 56px 0 20px;
}
.post-content h2:first-child { margin-top: 0; }
.post-content p {
  font-size: 1.0625rem;
  color: var(--ink-2);
  line-height: 1.8;
  margin-bottom: 20px;
}
.post-content ol {
  list-style: decimal;
  padding-left: 24px;
  margin-bottom: 20px;
}
.post-content ol li {
  font-size: 1.0625rem;
  color: var(--ink-2);
  line-height: 1.8;
  margin-bottom: 12px;
  padding-left: 8px;
}
.post-content code {
  font-family: 'SF Mono', 'Fira Mono', monospace;
  font-size: 0.875em;
  background: var(--paper-2);
  padding: 2px 6px;
  border-radius: 3px;
}
.callout {
  background: var(--paper-2);
  border-left: 3px solid var(--accent);
  padding: 20px 24px;
  margin: 32px 0;
  font-size: 0.9375rem;
  color: var(--ink-2);
  line-height: 1.7;
  border-radius: 0 4px 4px 0;
}
.callout strong { color: var(--ink); }

.related-posts { padding: 80px 0; border-top: 1px solid var(--line); }

/* ============================================================
   CV PAGE
   ============================================================ */
.cv-body { padding: 72px 0 100px; }
.cv-section { margin-bottom: 72px; }
.cv-section-title {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 32px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.cv-item {
  margin-bottom: 44px;
}
.cv-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.cv-role {
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1.3;
}
.cv-company {
  font-size: 0.875rem;
  color: var(--ink-3);
  display: block;
  margin-top: 2px;
}
.cv-period {
  font-size: 0.8125rem;
  color: var(--ink-3);
  white-space: nowrap;
}
.cv-desc {
  font-size: 0.9375rem;
  color: var(--ink-2);
  line-height: 1.7;
  margin-bottom: 12px;
}
.cv-list {
  list-style: disc;
  padding-left: 20px;
  color: var(--ink-2);
  font-size: 0.9375rem;
  line-height: 1.7;
}
.cv-list li { margin-bottom: 6px; }
.cv-list-standalone { margin-top: -8px; }
.cv-skills-inline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.cv-skills-inline span {
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: 2px;
}
.cv-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.cv-tags span {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6c552b;
  border: 1px solid rgba(200, 169, 110, 0.38);
  background: var(--accent-soft);
  padding: 5px 10px;
  border-radius: 2px;
}
.skills-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px 40px;
}
.skill-group h4 {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 8px;
}
.skill-group p {
  font-size: 0.9375rem;
  color: var(--ink-2);
  line-height: 1.65;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  border-top: 1px solid var(--line);
  padding: 40px 0;
  background: var(--paper-2);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.footer-name {
  font-family: var(--font-display);
  font-size: 1rem;
}
.footer-links {
  display: flex;
  gap: 28px;
  font-size: 0.875rem;
  color: var(--ink-3);
}
.footer-links a { transition: color 0.2s; }
.footer-links a:hover { color: var(--ink); }
.footer-copy { font-size: 0.75rem; color: var(--ink-3); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .posts-grid { grid-template-columns: 1fr 1fr; }
  .about-grid { grid-template-columns: 1fr; gap: 40px; }
  .project-item { grid-template-columns: 48px 1fr; }
  .project-links { grid-column: 2; flex-direction: row; }
  .writing-row { grid-template-columns: 160px 1fr 36px; gap: 20px; }
  .skills-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
  .container, .container-narrow { padding: 0 20px; }
  .hero { padding: calc(var(--nav-h) + 32px) 20px 100px; }
  #navbar { padding: 0 20px; }
  .nav-links { display: none; }
  .nav-toggle { display: flex; }
  .mobile-menu { display: flex; }
  .posts-grid, .posts-grid-2 { grid-template-columns: 1fr; }
  .writing-row {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 12px;
  }
  .writing-arrow { display: none; }
  .project-item {
    grid-template-columns: 1fr;
    gap: 16px;
    margin: 0;
    padding: 36px 0;
  }
  .project-item:hover { transform: none; }
  .project-number { display: none; }
  .skills-grid { grid-template-columns: 1fr; }
  .hero-scroll { display: none; }
  .section { padding: 64px 0; }
}
