/* ============================================================
   Design tokens
   ============================================================ */
:root {
  --bg:        #f4f2ec;
  --bg-elev:   #faf9f5;
  --text:      #16150f;
  --muted:     #6b6862;
  --faint:     #a8a49b;
  --line:      #ddd9cf;
  --accent:    #e8401f;
  --max:       1080px;
  --gutter:    clamp(20px, 5vw, 48px);
  --radius:    14px;
  --ease:      cubic-bezier(0.22, 1, 0.36, 1);

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body:    "Inter", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, monospace;
}

html[data-theme="dark"] {
  --bg:        #0d0d0c;
  --bg-elev:   #161614;
  --text:      #f2f0ea;
  --muted:     #9a968d;
  --faint:     #5e5b53;
  --line:      #26251f;
  --accent:    #ff5a36;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background 0.4s var(--ease), color 0.4s var(--ease);
}

main { flex: 1 0 auto; }

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
::selection { background: var(--accent); color: #fff; }

.wrap { width: min(100% - calc(var(--gutter) * 2), var(--max)); margin-inline: auto; }

.mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Page fade-in (cross-page navigation feel) */
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
main { animation: pageIn 0.5s var(--ease) both; }

/* Section scaffolding */
section { padding-block: clamp(56px, 9vh, 110px); position: relative; }
.section-head { margin-bottom: clamp(36px, 5vw, 60px); }
.section-head .label {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--accent);
}
.section-head .label::before {
  content: ""; width: 26px; height: 1px; background: var(--accent);
}
.section-head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.8rem, 4.4vw, 3rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-top: 14px;
  max-width: 18ch;
}
.section-head p {
  color: var(--muted); margin-top: 16px; max-width: 52ch; font-size: 1.02rem;
}

/* ============================================================
   Navbar
   ============================================================ */
header.nav {
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}
header.nav.scrolled { border-bottom-color: var(--line); }
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand {
  font-family: var(--font-mono); font-weight: 500;
  font-size: 0.95rem; letter-spacing: 0.02em;
  display: inline-flex; align-items: center; gap: 8px;
}
.brand .dot { color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  font-family: var(--font-mono); font-size: 0.8rem;
  color: var(--muted); padding: 8px 12px; border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.nav-links a.active { background: var(--bg-elev); }
.nav-links a .slash { color: var(--faint); margin-right: 4px; }

.nav-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border: 1px solid var(--line);
  background: transparent; color: var(--text); border-radius: 10px;
  display: grid; place-items: center; cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, background 0.2s;
}
.icon-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.icon-btn svg { width: 17px; height: 17px; }
.theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: block; }
html[data-theme="dark"] .theme-icon-moon { display: none; }

.nav-toggle { display: none; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-mono); font-size: 0.82rem; font-weight: 500;
  padding: 13px 22px; border-radius: 11px; cursor: pointer;
  border: 1px solid transparent; transition: all 0.2s var(--ease);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 26px -10px var(--accent); }
.btn-ghost { border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--text); transform: translateY(-2px); }
.btn svg { width: 15px; height: 15px; }

/* ============================================================
   Hero (home)
   ============================================================ */
.hero { padding-top: clamp(40px, 8vh, 90px); padding-bottom: clamp(48px, 8vh, 96px); }
.status {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-mono); font-size: 0.76rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 100px;
  padding: 6px 14px 6px 11px; margin-bottom: 30px;
}
.status .pulse {
  width: 8px; height: 8px; border-radius: 50%; background: #28c76f;
  box-shadow: 0 0 0 0 rgba(40,199,111,0.5); animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(40,199,111,0.5); }
  70% { box-shadow: 0 0 0 7px rgba(40,199,111,0); }
  100% { box-shadow: 0 0 0 0 rgba(40,199,111,0); }
}
.hero h1 {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(2.6rem, 9vw, 6rem);
  line-height: 0.98; letter-spacing: -0.045em;
  margin-bottom: 26px;
}
.hero h1 .accent { color: var(--accent); }
.hero-role {
  font-size: clamp(1.05rem, 2.4vw, 1.5rem);
  color: var(--muted); max-width: 38ch; margin-bottom: 14px;
}
.hero-role strong { color: var(--text); font-weight: 600; }
.hero-tag { color: var(--muted); max-width: 46ch; margin-bottom: 38px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.hero-socials { display: flex; gap: 22px; margin-top: 44px; flex-wrap: wrap; }
.hero-socials a {
  font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted);
  transition: color 0.2s;
}
.hero-socials a::after { content: "↗"; font-size: 0.7em; margin-left: 4px; opacity: 0.5; }
.hero-socials a:hover { color: var(--accent); }

/* ============================================================
   Page header (interior pages)
   ============================================================ */
.page-hero { padding-top: clamp(48px, 8vh, 96px); padding-bottom: clamp(28px, 4vh, 48px); }
.page-hero .label {
  display: inline-flex; align-items: center; gap: 10px; color: var(--accent);
}
.page-hero .label::before { content: ""; width: 26px; height: 1px; background: var(--accent); }
.page-hero h1 {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(2.4rem, 7vw, 4.6rem); letter-spacing: -0.04em; line-height: 1;
  margin-top: 16px;
}
.page-hero p { color: var(--muted); max-width: 56ch; margin-top: 18px; font-size: 1.1rem; }

/* ============================================================
   Marquee
   ============================================================ */
.marquee {
  border-block: 1px solid var(--line); overflow: hidden; padding-block: 16px;
  white-space: nowrap;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.marquee-track { display: inline-flex; gap: 0; animation: scroll 26s linear infinite; }
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee-track span {
  font-family: var(--font-display); font-size: 1.05rem; font-weight: 500;
  color: var(--muted); padding-inline: 26px;
}
.marquee-track span::before { content: "✱"; color: var(--accent); margin-right: 26px; }
@keyframes scroll { to { transform: translateX(-50%); } }

/* ============================================================
   About + stats
   ============================================================ */
.about-grid {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: clamp(32px, 6vw, 80px);
  align-items: start;
}
.about-text p { font-size: 1.12rem; color: var(--text); margin-bottom: 20px; }
.about-text p.lead { font-size: 1.32rem; font-family: var(--font-display); font-weight: 400; letter-spacing: -0.01em; }
.about-text .muted { color: var(--muted); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stat { background: var(--bg); padding: 26px 22px; }
.stat .value {
  font-family: var(--font-display); font-weight: 600;
  font-size: 2.4rem; letter-spacing: -0.03em; line-height: 1; color: var(--accent);
}
.stat .label { color: var(--muted); font-size: 0.86rem; margin-top: 8px; }

/* ============================================================
   Stack
   ============================================================ */
.stack-row {
  display: grid; grid-template-columns: 180px 1fr; gap: 24px;
  padding: 26px 0; border-top: 1px solid var(--line);
}
.stack-row:last-child { border-bottom: 1px solid var(--line); }
.stack-group { font-family: var(--font-display); font-weight: 500; font-size: 1.15rem; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  font-family: var(--font-mono); font-size: 0.8rem; color: var(--text);
  border: 1px solid var(--line); border-radius: 100px; padding: 7px 15px;
  background: var(--bg-elev); transition: all 0.2s var(--ease); cursor: default;
}
.chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }

/* ============================================================
   Services
   ============================================================ */
.services-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.service { background: var(--bg); padding: clamp(26px, 3.5vw, 40px); transition: background 0.25s; }
.service:hover { background: var(--bg-elev); }
.service .num { font-family: var(--font-mono); color: var(--accent); font-size: 0.82rem; }
.service h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; margin: 16px 0 12px; letter-spacing: -0.02em; }
.service p { color: var(--muted); font-size: 0.98rem; }

/* ============================================================
   Projects
   ============================================================ */
.projects-list { border-top: 1px solid var(--line); }
.project {
  display: grid; grid-template-columns: auto 1fr auto; gap: clamp(16px, 4vw, 48px);
  align-items: baseline; padding: clamp(26px, 3.5vw, 40px) 8px;
  border-bottom: 1px solid var(--line); position: relative;
  transition: padding-left 0.35s var(--ease);
}
.project::before {
  content: ""; position: absolute; inset: 0; background: var(--bg-elev);
  opacity: 0; transition: opacity 0.3s; z-index: -1; border-radius: 10px;
}
.project:hover { padding-left: 26px; }
.project:hover::before { opacity: 1; }
.project .p-num { font-family: var(--font-mono); color: var(--faint); font-size: 0.85rem; }
.project .p-main { min-width: 0; }
.project .p-title-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.project h3 {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.4rem, 3.4vw, 2.1rem); letter-spacing: -0.03em; line-height: 1.1;
  transition: color 0.2s;
}
.project:hover h3 { color: var(--accent); }
.project .p-cat { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 100px; padding: 3px 10px; }
.project .p-desc { color: var(--muted); margin: 12px 0 16px; max-width: 60ch; }
.project .p-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.project .p-tags span { font-family: var(--font-mono); font-size: 0.74rem; color: var(--faint); }
.project .p-tags span::before { content: "#"; opacity: 0.6; }
.project .p-side { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.project .p-year { font-family: var(--font-mono); font-size: 0.85rem; color: var(--muted); }
.project .p-links { display: flex; gap: 8px; }
.project .p-links a {
  width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 9px;
  display: grid; place-items: center; transition: all 0.2s;
}
.project .p-links a:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.project .p-links svg { width: 15px; height: 15px; }

/* ============================================================
   Timeline
   ============================================================ */
.timeline { border-left: 1px solid var(--line); margin-left: 6px; }
.tl-item { position: relative; padding: 0 0 44px 34px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -5px; top: 6px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 4px var(--bg);
}
.tl-period { font-family: var(--font-mono); font-size: 0.78rem; color: var(--accent); }
.tl-item h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; margin: 8px 0 2px; letter-spacing: -0.02em; }
.tl-company { color: var(--muted); font-size: 0.95rem; margin-bottom: 12px; }
.tl-item p { color: var(--muted); max-width: 58ch; }

/* ============================================================
   Writing
   ============================================================ */
.writing-list { border-top: 1px solid var(--line); }
.write-item {
  display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: baseline;
  padding: 24px 8px; border-bottom: 1px solid var(--line);
  transition: padding-left 0.3s var(--ease), background 0.25s; border-radius: 8px;
}
.write-item:hover { padding-left: 20px; background: var(--bg-elev); }
.write-item h3 { font-family: var(--font-display); font-weight: 500; font-size: 1.25rem; letter-spacing: -0.02em; transition: color 0.2s; }
.write-item:hover h3 { color: var(--accent); }
.write-item p { color: var(--muted); font-size: 0.94rem; margin-top: 6px; max-width: 60ch; }
.write-date { font-family: var(--font-mono); font-size: 0.78rem; color: var(--faint); white-space: nowrap; }

/* ============================================================
   Home teaser blocks
   ============================================================ */
.teaser-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 36px; flex-wrap: wrap; }
.teaser-head h2 { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.6rem, 4vw, 2.6rem); letter-spacing: -0.03em; }
.text-link { font-family: var(--font-mono); font-size: 0.82rem; color: var(--accent); display: inline-flex; align-items: center; gap: 7px; transition: gap 0.2s; }
.text-link:hover { gap: 11px; }
.text-link svg { width: 14px; height: 14px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(28px, 6vw, 70px); align-items: center; }
.split .lead { font-family: var(--font-display); font-size: clamp(1.3rem, 2.6vw, 1.9rem); font-weight: 400; letter-spacing: -0.02em; line-height: 1.35; }
.split .muted { color: var(--muted); margin-top: 16px; }

/* ============================================================
   Contact
   ============================================================ */
.contact { text-align: center; }
.contact .label { color: var(--accent); display:inline-flex; align-items:center; gap:10px; }
.contact .label::before { content:""; width:26px; height:1px; background:var(--accent); }
.contact h2 {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(2.2rem, 7vw, 4.6rem); letter-spacing: -0.04em; line-height: 1;
  margin: 18px 0 28px;
}
.big-mail {
  display: inline-block; font-family: var(--font-display); font-weight: 500;
  font-size: clamp(1.2rem, 4vw, 2.2rem); letter-spacing: -0.02em;
  border-bottom: 2px solid var(--line); padding-bottom: 6px; transition: border-color 0.2s, color 0.2s;
}
.big-mail:hover { color: var(--accent); border-color: var(--accent); }
.contact-socials { display: flex; gap: 18px; justify-content: center; margin-top: 40px; flex-wrap: wrap; }
.contact-socials a {
  font-family: var(--font-mono); font-size: 0.82rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 100px; padding: 9px 18px; transition: all 0.2s;
}
.contact-socials a:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }

/* Contact form */
.contact-form { max-width: 560px; margin: 0 auto; text-align: left; display: grid; gap: 18px; }
.field { display: grid; gap: 8px; }
.field label { font-family: var(--font-mono); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.field input, .field textarea {
  font-family: var(--font-body); font-size: 1rem; color: var(--text);
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 11px;
  padding: 13px 15px; transition: border-color 0.2s; resize: vertical;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.form-note { font-family: var(--font-mono); font-size: 0.76rem; color: var(--muted); text-align: center; min-height: 1.2em; }

/* ============================================================
   Footer
   ============================================================ */
footer { border-top: 1px solid var(--line); padding-block: 40px; flex-shrink: 0; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.footer-inner .mono { text-transform: none; }
.to-top { cursor: pointer; }
.to-top:hover { color: var(--accent); }

/* ============================================================
   Scroll reveal
   ============================================================ */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, main { animation: none !important; scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 860px) {
  .about-grid, .services-grid, .split { grid-template-columns: 1fr; }
  .stack-row { grid-template-columns: 1fr; gap: 14px; }
}
@media (max-width: 680px) {
  .nav-links { display: none; }
  .nav-toggle { display: grid; }
  .nav-links.open {
    display: flex; flex-direction: column; align-items: stretch;
    position: absolute; top: 64px; left: 0; right: 0;
    background: var(--bg-elev); border-bottom: 1px solid var(--line);
    padding: 12px var(--gutter) 20px; gap: 2px;
  }
  .nav-links.open a { padding: 12px 8px; font-size: 0.92rem; border-bottom: 1px solid var(--line); }
  .project { grid-template-columns: auto 1fr; }
  .project .p-side { grid-column: 2; flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
  .write-item { grid-template-columns: 1fr; }
  .write-date { order: -1; }
}
