:root {
  --paper: #faf6f0;
  --bg: var(--paper);
  --fg: #211a15;
  --soft: #6a5e55;
  --mute: #8d8077;
  --line: rgba(70, 48, 30, 0.15);
  --panel: #efe7db;
  --link: #d2661a;
  --brown: #5a3a1f;
  --brown-hi: #6d4727;
  --wrap: 1120px;
  --pad: clamp(1.25rem, 4vw, 2.5rem);
  --display: "Syne", "Newsreader", Georgia, sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Geist", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Helvetica, Arial, sans-serif;
}

/* Dark sections: closing and footer */
.closing, footer {
  --bg: #141414;
  --fg: #f4f1ea;
  --soft: #bab6ac;
  --mute: #96938b;
  --dim: #6c695f;
  --line: rgba(255, 255, 255, 0.1);
  --panel: #2a2a2a;
  --link: #e08a4a;
  background: var(--bg);
  color: var(--fg);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 4px; border-radius: 4px; }
::selection { background: var(--brown); color: #fff; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--pad); }

/* Navigation */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  background: var(--paper);
  color: var(--fg);
  border-bottom: 1px solid var(--line);
}
.nav .wrap { display: flex; align-items: center; justify-content: space-between; height: 3.5rem; }
.nav-name { font-family: var(--serif); font-weight: 500; font-size: 1.35rem; letter-spacing: -0.01em; text-decoration: none; }
.nav ul { display: flex; gap: clamp(1rem, 2.6vw, 2rem); list-style: none; margin: 0; padding: 0; }
.nav ul a { color: var(--soft); font-size: 0.875rem; text-decoration: none; transition: color 0.2s; }
.nav ul a:hover { color: var(--fg); }

/* Hero */
.hero { padding: clamp(7rem, 13vw, 9.5rem) 0 0; }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 3rem clamp(2rem, 6vw, 5rem);
  align-items: center;
}
.hero h1 {
  margin: 0;
  max-width: 11.5em;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.9rem, 6.6vw, 5.4rem);
  line-height: 1.03;
  letter-spacing: -0.03em;
  opacity: 0;
  transform: translateY(18px);
  animation: rise 1.1s cubic-bezier(0.16, 1, 0.3, 1) 0.05s forwards;
}
.hero h1 strong { font-weight: 600; }
.hero-lede {
  margin: clamp(1.5rem, 3vw, 2.25rem) 0 0;
  max-width: 33em;
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  line-height: 1.65;
  color: var(--soft);
  opacity: 0;
  animation: fade 1s ease 0.45s forwards;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.75rem;
  margin-top: clamp(1.75rem, 3.5vw, 2.5rem);
  opacity: 0;
  animation: fade 1s ease 0.65s forwards;
}
.btn {
  display: inline-block;
  padding: 0.85rem 1.6rem;
  background: var(--brown);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 8px;
  transition: background-color 0.2s;
}
.btn:hover { background: var(--brown-hi); }
.btn-text { font-size: 0.95rem; font-weight: 500; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 0.3em; transition: text-decoration-color 0.2s; }
.btn-text:hover { text-decoration-color: var(--fg); }

.hero-card { display: flex; justify-content: flex-end; opacity: 0; animation: fade 1.2s ease 0.35s forwards; }

.btn-icon {
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  background: var(--panel);
  color: var(--fg);
  border-radius: 10px;
  transition: color 0.2s, background-color 0.2s;
}
.btn-icon svg { width: 1.3rem; height: 1.3rem; }
.btn-icon:hover { color: var(--link); }

/* Scribble underline under the highlighted phrase (progress set by script.js) */
.mark { position: relative; white-space: nowrap; color: var(--fg); font-weight: 500; }
.scribble { position: absolute; left: 0; bottom: -0.45em; width: 100%; height: 0.7em; overflow: visible; pointer-events: none; }
.scribble path { fill: none; stroke: var(--link); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.scribble-line { stroke-linecap: butt; }

/* Stats strip */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: clamp(3.5rem, 8vw, 6rem) 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.stats div { padding: 1.4rem 1.5rem 1.6rem; }
.stats div:first-child { padding-left: 0; }
.stats div + div { border-left: 1px solid var(--line); }
.stats dt { font-size: 1.1rem; font-weight: 600; letter-spacing: -0.01em; }
.stats dd { margin: 0.2rem 0 0; font-size: 0.9rem; color: var(--soft); }

@keyframes rise { to { opacity: 1; transform: translateY(0); } }
@keyframes fade { to { opacity: 1; } }

/* Sections */
section.block { padding: clamp(5rem, 10vw, 8rem) 0 0; }
.grid { display: block; border-top: 1px solid var(--line); padding-top: clamp(1.5rem, 3vw, 2.25rem); }
.grid > div:first-child h2 {
  margin: 0 0 clamp(2rem, 4vw, 3rem);
  font-family: var(--display);
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
}

/* About and interests */
.about-text, .interests-text {
  margin: 0;
  max-width: 34em;
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.3vw, 1.7rem);
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.about-text + .about-text { margin-top: 1.5rem; color: var(--soft); }

/* Portrait card: cursor tilt (--rx, --ry set by script.js) and click-to-flip */
.portrait {
  margin: 0;
  width: 100%;
  max-width: 330px;
  aspect-ratio: 4 / 5;
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
  box-shadow: 0 30px 60px -30px rgba(60, 38, 20, 0.35);
}
.portrait.is-tilting { transition: transform 0.12s ease-out; }
.portrait-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}
.portrait.is-flipped .portrait-inner { transform: rotateY(180deg); }
.face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.face-front { background: var(--panel); }
.face-front img { width: 100%; height: 100%; object-fit: cover; display: block; }
.face-back { transform: rotateY(180deg); background: var(--panel); }
.face-back img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Links */
.ulink { color: var(--link); text-decoration: none; }
.ulink:hover { text-decoration: underline; text-underline-offset: 0.2em; }

/* Projects */
.project {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
  gap: 0.5rem clamp(2rem, 5vw, 4rem);
  padding: 2.75rem 0;
}
.project:first-child { padding-top: 0; }
.project + .project { border-top: 1px solid var(--line); }
.project-head { grid-column: 1; grid-row: 1 / span 2; display: flex; flex-direction: column; align-items: flex-start; gap: 0.6rem; }
.project h3 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(1.9rem, 3.6vw, 2.6rem); line-height: 1.1; letter-spacing: -0.02em; }
.status { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--link); }
.status::before { content: ""; width: 0.4rem; height: 0.4rem; border-radius: 50%; border: 1px solid var(--link); }
.status.live::before { background: var(--link); }
.project p { grid-column: 2; grid-row: 1; margin: 0; max-width: 38em; color: var(--soft); }
.project dl { grid-column: 2; grid-row: 2; margin: 1.25rem 0 0; display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 0.4rem 1rem; font-size: 0.95rem; }
.project dt { color: var(--mute); }
.project dd { margin: 0; }
.links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }

/* Rows (experience, education, skills) */
.rows { margin: 0; padding: 0; list-style: none; }
.skills { margin: 0; }
.row, .skills div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr); gap: 0.25rem 2rem; padding: 1.6rem 0; }
.row:first-child, .skills div:first-child { padding-top: 0; }
.row + .row, .skills div + div { border-top: 1px solid var(--line); }
.row .when, .skills dt { color: var(--mute); font-size: 0.95rem; }
.row h3 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 1.55rem; line-height: 1.2; letter-spacing: -0.01em; }
.row p { margin: 0.35rem 0 0; color: var(--soft); font-size: 1rem; }
.skills dd { margin: 0; font-size: 1.05rem; color: var(--fg); }

/* Copy email button */
.copy-btn {
  font: inherit;
  font-size: 0.875rem;
  color: var(--mute);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.95rem;
  margin-top: 0.9rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.copy-btn:hover { color: var(--fg); border-color: rgba(255, 255, 255, 0.3); }

/* Closing (contact), dark with copper rings */
.closing {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  margin-top: clamp(5rem, 10vw, 8rem);
  padding: clamp(5rem, 10vw, 8rem) 0 clamp(4rem, 8vw, 6rem);
}
.closing .wrap { position: relative; z-index: 1; }
.rings {
  position: absolute;
  z-index: 0;
  right: -8%;
  bottom: -14%;
  width: min(70vw, 780px);
  aspect-ratio: 1;
  height: auto;
  color: #b4531a;
  pointer-events: none;
}
.closing-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.5rem, 6.6vw, 4.9rem);
  line-height: 1.04;
  letter-spacing: -0.03em;
  max-width: 14em;
}
.closing-title span { display: block; color: var(--dim); }
.closing-nav { display: flex; gap: 2.5rem; margin: 3rem 0 4rem; }
.closing-nav a { color: var(--mute); text-decoration: none; transition: color 0.2s; }
.closing-nav a:hover { color: var(--fg); }
.closing-block { margin-bottom: 2.75rem; }
.closing-block:last-child { margin-bottom: 0; }
.label { margin: 0 0 0.7rem; font-size: 0.95rem; color: var(--mute); }
.value { margin: 0; font-size: 1.2rem; color: var(--fg); overflow-wrap: anywhere; }
.plain { text-decoration: none; transition: color 0.2s; }
.plain:hover { color: var(--link); }
.icon-row { display: flex; gap: 0.9rem; }
.icon-btn {
  width: 3.5rem;
  height: 3.5rem;
  display: grid;
  place-items: center;
  background: var(--panel);
  color: var(--fg);
  border-radius: 14px;
  transition: background-color 0.2s, color 0.2s;
}
.icon-btn svg { width: 1.45rem; height: 1.45rem; }
.icon-btn:hover { background: #363636; color: var(--link); }

.heart { width: 0.95em; height: 0.95em; vertical-align: -0.14em; margin: 0 0.1em; color: var(--link); }
footer { padding: 1.5rem 0 2.5rem; border-top: 1px solid var(--line); color: var(--mute); font-size: 0.85rem; }
footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 2rem; }

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-card { justify-content: flex-start; }
  .portrait { max-width: 260px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats div:nth-child(3) { padding-left: 0; border-left: 0; }
  .stats div:nth-child(n+3) { border-top: 1px solid var(--line); }
}

@media (max-width: 760px) {
  .project { grid-template-columns: 1fr; }
  .project-head, .project p, .project dl { grid-column: 1; grid-row: auto; }
  .project p { margin-top: 0.75rem; }
  .row, .skills div { grid-template-columns: 1fr; }
  .nav ul li:not(:last-child) { display: none; }
  .project dl { grid-template-columns: 1fr; gap: 0; }
  .project dd { margin-bottom: 0.75rem; }
  .rings { width: 96vw; right: -26%; bottom: -8%; opacity: 0.5; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero h1, .hero-lede, .hero-actions, .hero-card { animation: none; transform: none; opacity: 1; }
  .portrait { transform: none; transition: none; }
  .portrait-inner { transition: none; }
}
