/* =============================================================
   Marc Llopart — Topographic redesign
   Design language: topographic map / trail. Dominant color: deep pine.
   ============================================================= */

/* ---------- Tokens ---------- */
:root {
  --paper:       #EDE9DF;
  --paper-2:     #E4DFD3;   /* slightly deeper panel */
  --ink:         #23261F;
  --pine:        #2F4A3C;
  --pine-deep:   #22382D;
  --contour:     #B08D57;
  --contour-soft:#cdb489;
  --blaze:       #C75B39;
  --stone:       #6E6A60;
  --line:        rgba(35, 38, 31, 0.12);

  --maxw: 1080px;
  --gutter: clamp(20px, 5vw, 56px);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --shadow: 0 1px 2px rgba(34,56,45,0.06), 0 12px 28px -12px rgba(34,56,45,0.22);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:       #1a201b;
    --paper-2:     #212823;
    --ink:         #E9E6DC;
    --pine:        #7FB79C;
    --pine-deep:   #A6D0BC;
    --contour:     #9c7c4c;
    --contour-soft:#6f5a37;
    --blaze:       #E0764F;
    --stone:       #A29C8E;
    --line:        rgba(233, 230, 220, 0.14);
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 14px 30px -12px rgba(0,0,0,0.6);
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: var(--pine); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

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

h1, h2, h3 { font-family: var(--font-display); font-weight: 500; line-height: 1.08; margin: 0; }

/* ---------- Utility ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding-inline: var(--gutter); }
.mono { font-family: var(--font-mono); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--pine);
  margin: 0 0 1rem;
}
.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--pine); color: #fff; padding: 10px 16px; z-index: 200;
}
.skip-link:focus { left: 12px; top: 12px; }

/* ---------- Contour background layer ---------- */
.contour-bg {
  position: absolute; inset: 0; z-index: 0;
  pointer-events: none; overflow: hidden;
  -webkit-mask-image: radial-gradient(120% 100% at 100% 0%, #000 20%, transparent 78%);
          mask-image: radial-gradient(120% 100% at 100% 0%, #000 20%, transparent 78%);
}
.contour-bg svg { width: 100%; height: 100%; }
.contour-bg path {
  fill: none;
  stroke: var(--contour);
  stroke-width: 1;
  opacity: 0.4;
}

/* ---------- Header / hero ---------- */
.hero {
  position: relative;
  background:
    radial-gradient(120% 90% at 80% -10%, rgba(47,74,60,0.10), transparent 60%),
    var(--paper);
  border-bottom: 1px solid var(--line);
  padding: clamp(64px, 12vh, 140px) 0 clamp(48px, 8vh, 96px);
}
.hero .container { position: relative; z-index: 1; }

.hero-top {
  display: flex; justify-content: space-between; align-items: center;
  gap: 20px; margin-bottom: clamp(40px, 8vh, 80px);
}
.avatar {
  width: 68px; height: 68px; border-radius: 50%;
  border: 2px solid var(--contour);
  box-shadow: var(--shadow);
  object-fit: cover;
}
.hero-socials { display: flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line);
  color: var(--ink); background: transparent;
  transition: color .25s var(--ease), border-color .25s var(--ease), transform .25s var(--ease);
}
.icon-btn:hover { color: var(--pine); border-color: var(--pine); transform: translateY(-2px); text-decoration: none; }
.icon-btn svg { width: 19px; height: 19px; }

.hero h1 {
  font-size: clamp(3rem, 11vw, 7rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0 0 0.4rem;
  font-optical-sizing: auto;
}
.hero .role {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--blaze);
  margin-bottom: 1.6rem;
}
.hero .thesis {
  font-size: clamp(1.15rem, 2.4vw, 1.6rem);
  line-height: 1.4;
  max-width: 30ch;
  color: var(--ink);
  margin: 0 0 2rem;
}
.hero .thesis b { color: var(--pine); font-weight: 600; }

/* coordinates strip */
.coords {
  display: flex; flex-wrap: wrap; gap: 4px 20px;
  font-family: var(--font-mono);
  font-size: 0.72rem; letter-spacing: 0.12em;
  color: var(--stone); text-transform: uppercase;
  padding: 12px 0; margin-bottom: 2rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.coords b { color: var(--ink); font-weight: 600; }

.cta-row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.82rem; letter-spacing: 0.04em;
  padding: 13px 22px; border-radius: 2px;
  border: 1px solid var(--pine);
  transition: background .25s var(--ease), color .25s var(--ease), transform .2s var(--ease);
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--pine); color: var(--paper); }
.btn-primary:hover { background: var(--pine-deep); text-decoration: none; transform: translateY(-2px); }
.btn-ghost { background: transparent; color: var(--pine); }
.btn-ghost:hover { background: rgba(47,74,60,0.08); text-decoration: none; transform: translateY(-2px); }
@media (prefers-color-scheme: dark) {
  .btn-primary { color: var(--pine-deep); }
}

/* ---------- Sticky section nav ---------- */
.pagenav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.pagenav ul {
  display: flex; gap: clamp(14px, 3vw, 34px);
  list-style: none; margin: 0; padding: 14px var(--gutter);
  max-width: var(--maxw); margin-inline: auto;
  overflow-x: auto; scrollbar-width: none;
}
.pagenav ul::-webkit-scrollbar { display: none; }
.pagenav a {
  font-family: var(--font-mono);
  font-size: 0.74rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--stone); white-space: nowrap; padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}
.pagenav a:hover { color: var(--ink); text-decoration: none; }
.pagenav a.active { color: var(--pine); border-bottom-color: var(--blaze); }

/* ---------- Sections ---------- */
.section { padding: clamp(56px, 10vh, 108px) 0; position: relative; }
.section + .section { border-top: 1px solid var(--line); }
.section-head { margin-bottom: clamp(32px, 6vh, 64px); }
.section-head h2 {
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  letter-spacing: -0.015em;
}
.section-index {
  font-family: var(--font-mono);
  font-size: 0.72rem; letter-spacing: 0.2em; color: var(--contour);
  text-transform: uppercase; display: block; margin-bottom: 0.6rem;
}

/* ---------- Elevation profile (signature) ---------- */
.elevation { background: var(--paper-2); }
.elevation-frame {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 4px;
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 20% ,
    var(--paper);
  padding: 8px;
  box-shadow: var(--shadow);
}
.elevation svg { width: 100%; height: auto; display: block; }
.elev-line {
  fill: none; stroke: var(--pine); stroke-width: 2.5;
  stroke-linejoin: round; stroke-linecap: round;
}
.elev-fill { fill: url(#elevGrad); opacity: 0.9; }
.elev-summit { fill: var(--paper); stroke: var(--pine); stroke-width: 2.5; }
.elev-summit.is-peak { fill: var(--blaze); stroke: var(--blaze); }
.elev-label {
  font-family: var(--font-mono); font-size: 10px;
  fill: var(--stone); letter-spacing: 0.02em;
}
.elev-label b { fill: var(--ink); }
.elev-axis { font-family: var(--font-mono); font-size: 10px; fill: var(--contour); letter-spacing: 0.1em; }
.elev-caption {
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--stone);
  letter-spacing: 0.08em; text-transform: uppercase; margin-top: 16px; text-align: center;
}

/* draw animation */
.elev-line, .elev-fill { transition: none; }
.reveal .elev-line {
  stroke-dasharray: var(--len, 2000);
  stroke-dashoffset: var(--len, 2000);
}
.reveal.in .elev-line {
  transition: stroke-dashoffset 2.2s var(--ease);
  stroke-dashoffset: 0;
}
.reveal .elev-fill, .reveal .elev-summit, .reveal .elev-label { opacity: 0; }
.reveal.in .elev-fill { transition: opacity 1s var(--ease) 1.1s; opacity: 0.9; }
.reveal.in .elev-summit { transition: opacity .5s var(--ease) 1.4s; opacity: 1; }
.reveal.in .elev-label { transition: opacity .6s var(--ease) 1.7s; opacity: 1; }

/* ---------- Key ascents (accomplishments) ---------- */
.ascents { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ascents li {
  position: relative; padding: 18px 0 18px 42px;
  border-bottom: 1px solid var(--line);
}
.ascents li:last-child { border-bottom: none; }
.ascents li::before {
  content: ""; position: absolute; left: 8px; top: 24px;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--pine); background: var(--paper);
}
.ascents li::after {
  content: ""; position: absolute; left: 13px; top: 36px; bottom: -1px;
  width: 2px; background: var(--line);
}
.ascents li:last-child::after { display: none; }
.ascents strong { color: var(--pine); font-weight: 600; }

/* ---------- Experience timeline ---------- */
.xp { display: grid; gap: 14px; }
.xp-item {
  border: 1px solid var(--line);
  border-left: 3px solid var(--contour);
  border-radius: 4px;
  background: var(--paper-2);
  padding: clamp(20px, 3vw, 30px);
  transition: transform .3s var(--ease), border-color .3s var(--ease), box-shadow .3s var(--ease);
}
.xp-item:hover { transform: translateY(-3px); border-left-color: var(--blaze); box-shadow: var(--shadow); }
.xp-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 20px; align-items: baseline; }
.xp-head h3 { font-size: 1.4rem; font-weight: 500; }
.xp-years { font-family: var(--font-mono); font-size: 0.8rem; color: var(--blaze); letter-spacing: 0.06em; white-space: nowrap; }
.xp-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 6px 0 14px; font-size: 0.92rem; color: var(--stone); }
.xp-meta .title-role { color: var(--pine); font-weight: 600; }
.xp-item p { margin: 0 0 12px; }
.xp-item ul { margin: 0 0 4px; padding-left: 20px; }
.xp-item li { margin-bottom: 6px; }
.xp-item .tech { font-family: var(--font-mono); font-size: 0.8rem; color: var(--stone); line-height: 1.7; }
.xp-item .tech b { color: var(--ink); font-weight: 600; }

/* ---------- Education grid ---------- */
.edu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.edu-card {
  border: 1px solid var(--line); border-radius: 4px;
  padding: 20px; background: var(--paper-2);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.edu-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.edu-card h3 { font-size: 1.05rem; font-weight: 500; margin-bottom: 8px; }
.edu-card .where { color: var(--pine); font-size: 0.92rem; }
.edu-card .when { font-family: var(--font-mono); font-size: 0.76rem; color: var(--stone); margin-top: 4px; }

/* ---------- Testimonials ---------- */
.quotes { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.quote-card {
  position: relative;
  border: 1px solid var(--line); border-radius: 4px;
  padding: 28px 26px 24px; background: var(--paper-2);
  overflow: hidden;
}
.quote-card::before {
  content: "\201C"; position: absolute; top: -18px; right: 12px;
  font-family: var(--font-display); font-size: 6rem; color: var(--contour);
  opacity: 0.25; line-height: 1;
}
.quote-card blockquote { margin: 0 0 16px; font-size: 1.02rem; line-height: 1.55; color: var(--ink); }
.quote-card .who { font-weight: 600; color: var(--pine); }
.quote-card .where2 { font-size: 0.86rem; color: var(--stone); }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--line);
  padding: 48px 0;
  text-align: center;
  color: var(--stone);
  font-family: var(--font-mono);
  font-size: 0.78rem; letter-spacing: 0.08em;
}
.footer .mark { color: var(--pine); }

/* ---------- Scroll reveal ---------- */
.reveal:not(.elevation-frame) { opacity: 0; transform: translateY(22px); }
.reveal.in:not(.elevation-frame) {
  opacity: 1; transform: none;
  transition: opacity .7s var(--ease), transform .7s var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal.in, .reveal .elev-line, .reveal .elev-fill,
  .reveal .elev-summit, .reveal .elev-label {
    opacity: 1 !important; transform: none !important;
    stroke-dashoffset: 0 !important; transition: none !important;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .hero-top { margin-bottom: 44px; }
  .cta-row .btn { flex: 1 1 auto; justify-content: center; }
  .xp-head h3 { font-size: 1.2rem; }
  .elev-label { font-size: 9px; }
}
