/* =========================================================
   Pep Mateos — personal website
   Palette: "Nordic minimal"
   To change a colour everywhere, edit it once in :root below.
   ========================================================= */

/* ---------- Fonts (stored in assets/fonts, no Google tracking) ---------- */
@font-face {
  font-family: "Newsreader";
  src: url("assets/fonts/newsreader-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("assets/fonts/newsreader-latin-wght-italic.woff2") format("woff2");
  font-weight: 200 800; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("assets/fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}

/* ---------- Colours & sizes ---------- */
:root {
  --bg:          #FAFAF7;   /* page background (off-white) */
  --surface:     #F1F3EF;   /* cards */
  --text:        #1F2321;   /* main text (charcoal) */
  --muted:       #6E7672;   /* secondary text (grey-green) */
  --line:        #E1E4DF;   /* thin dividing lines */
  --accent:      #2E5E4E;   /* deep sage green */
  --accent-soft: #E3ECE7;   /* pale green tint */

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans:  "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --max: 1120px;            /* maximum content width */
  --ease: cubic-bezier(.22, .61, .36, 1);
}

/* ---------- Basics ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
::selection { background: var(--accent); color: #fff; }

.container { width: min(var(--max), 100% - 48px); margin-inline: auto; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 400; line-height: 1.1; margin: 0; }
em { font-style: italic; }

/* Links inside paragraphs: animated underline */
p a, .plain-list a {
  color: var(--accent);
  text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
  transition: background-size .35s var(--ease);
}
p a:hover, .plain-list a:hover { background-size: 0 1px; background-position: 100% 100%; }

/* ---------- Scroll progress bar ---------- */
.progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 60; }
.progress span { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }

/* ---------- Header ---------- */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  transition: border-color .4s var(--ease);
  border-bottom: 1px solid transparent;
}
/* The frosted background sits on its own layer (::before). If the blur were on the
   header itself, it would trap the full-screen mobile menu inside the header bar. */
.site-header::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  transition: background .4s var(--ease);
}
.site-header.scrolled { border-color: var(--line); }
.site-header.scrolled::before {
  background: rgba(250, 250, 247, .82);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 72px; }
.logo { font-family: var(--serif); font-size: 1.35rem; text-decoration: none; letter-spacing: -.01em; white-space: nowrap; }
.logo .dot { color: var(--accent); }

.nav { display: flex; gap: 30px; align-items: center; }
.nav a {
  font-size: .9rem; text-decoration: none; color: var(--muted);
  position: relative; transition: color .25s;
}
.nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 1px;
  background: var(--accent); transform: scaleX(0); transform-origin: right;
  transition: transform .35s var(--ease);
}
.nav a:hover, .nav a.active { color: var(--text); }
.nav a:hover::after, .nav a.active::after { transform: scaleX(1); transform-origin: left; }
.nav .nav-cv {
  color: var(--accent); border: 1px solid var(--accent); border-radius: 999px;
  padding: 6px 16px; transition: background .25s, color .25s;
}
.nav .nav-cv::after { display: none; }
.nav .nav-cv:hover { background: var(--accent); color: #fff; }

.menu-toggle { display: none; }

/* Language switcher: EN · CA · ES */
.lang { display: flex; align-items: center; gap: 2px; font-size: .8rem; letter-spacing: .06em; }
.nav .lang a { color: var(--muted); padding: 4px 6px; border-radius: 6px; }
.nav .lang a::after { display: none; }
.nav .lang a:hover { color: var(--text); background: var(--accent-soft); }
.nav .lang a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* ---------- Hero ---------- */
.hero {
  min-height: 100vh; min-height: 100svh;
  display: grid; grid-template-columns: 1.35fr 1fr; gap: 64px;
  align-items: center; padding-top: 110px; padding-bottom: 80px; position: relative;
}
.eyebrow {
  font-size: .78rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 22px; font-weight: 500;
}
.hero h1 {
  font-size: clamp(2.8rem, 6.4vw, 5.4rem);
  letter-spacing: -.025em; line-height: 1.02; margin-bottom: 28px;
}
.hero h1 em { color: var(--accent); }
.lede { font-size: 1.18rem; color: var(--muted); max-width: 33em; margin: 0 0 36px; }

.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 26px; border-radius: 999px; font-size: .95rem; font-weight: 500;
  text-decoration: none; transition: transform .3s var(--ease), background .3s, color .3s, border-color .3s;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #244c3f; }
.btn-ghost { border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--text); }

.hero-photo { margin: 0; justify-self: end; position: relative; width: min(400px, 100%); }
.hero-photo img {
  width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: cover;
  border-radius: 6px;                     /* square photo, softly rounded corners */
  position: relative; z-index: 1;
}
/* thin offset outline behind the photo */
.hero-photo::before {
  content: ""; position: absolute; inset: 18px -18px -18px 18px;
  border: 1px solid var(--accent); border-radius: 6px; opacity: .45;
}

.scroll-cue {
  position: absolute; left: 50%; bottom: 28px; translate: -50% 0;
  width: 24px; height: 38px; border: 1px solid var(--muted); border-radius: 14px; opacity: .6;
}
.scroll-cue span {
  position: absolute; left: 50%; top: 8px; width: 3px; height: 7px; margin-left: -1.5px;
  background: var(--muted); border-radius: 2px; animation: cue 2s var(--ease) infinite;
}
@keyframes cue { 0% { opacity: 0; transform: translateY(0); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(12px); } }

/* ---------- Sections ---------- */
.section { padding: 120px 0 40px; }
.section-head {
  display: flex; align-items: baseline; gap: 18px;
  padding-bottom: 22px; margin-bottom: 56px; border-bottom: 1px solid var(--line);
}
.section-num { font-size: .85rem; color: var(--accent); font-variant-numeric: tabular-nums; letter-spacing: .08em; }
.section-head h2 { font-size: clamp(2.2rem, 4.4vw, 3.4rem); letter-spacing: -.02em; }

.section-intro { color: var(--muted); margin: -24px 0 32px; font-size: 1rem; }
.big { font-family: var(--serif); font-size: clamp(1.35rem, 2.2vw, 1.7rem); line-height: 1.45; margin-top: 0; }
.col-title {
  font-family: var(--sans); font-size: .78rem; font-weight: 500; letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 28px;
}

/* ---------- About ---------- */
.about-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 80px; align-items: start; }
.about-text p:not(.big) { color: #3a403d; }

.chips { list-style: none; padding: 0; margin: 32px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.chips li {
  font-size: .85rem; padding: 6px 14px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}

.stats { margin: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.stat { padding: 22px 0; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; gap: 20px; }
.stat dt { font-family: var(--serif); font-size: 3rem; line-height: 1; color: var(--accent); min-width: 2.2ch; font-variant-numeric: tabular-nums; }
.stat dd { margin: 0; color: var(--muted); font-size: .95rem; }

/* ---------- Timeline ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 72px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 28px; position: relative; isolation: isolate; }
/* the vertical line — it "draws" itself as you scroll (see script.js) */
.timeline::before {
  content: ""; position: absolute; left: 3px; top: 8px; bottom: 8px; width: 1px;
  background: var(--accent); transform-origin: top; transform: scaleY(var(--draw, 0));
  transition: transform .15s linear;
}
.timeline::after {
  content: ""; position: absolute; left: 3px; top: 8px; bottom: 8px; width: 1px; background: var(--line); z-index: -1;
}
.timeline li { position: relative; padding-bottom: 38px; }
.timeline li::before {
  content: ""; position: absolute; left: -29px; top: 8px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--bg); border: 1px solid var(--accent);
  transition: background .5s var(--ease) .2s;
}
.timeline li.visible::before { background: var(--accent); }
.when { font-size: .8rem; color: var(--accent); letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.timeline h4 { font-size: 1.4rem; margin: 6px 0 4px; }
.where { margin: 0 0 6px; color: var(--muted); font-size: .92rem; }
.timeline p:not(.where) { margin: 0; font-size: .95rem; color: #3a403d; }

/* ---------- Publications ---------- */
.pubs { list-style: none; margin: 0 0 64px; padding: 0; border-top: 1px solid var(--line); }
.pubs li {
  display: grid; grid-template-columns: 90px 1fr; gap: 24px;
  padding: 26px 0; border-bottom: 1px solid var(--line);
  transition: background .3s, padding .4s var(--ease);
}
.pubs li:hover { background: var(--surface); padding-left: 16px; padding-right: 16px; }
.year { color: var(--accent); font-size: .9rem; font-variant-numeric: tabular-nums; padding-top: 4px; }
.pub-title { font-family: var(--serif); font-size: 1.3rem; line-height: 1.35; text-decoration: none; display: block; }
a.pub-title { background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1px no-repeat; transition: background-size .4s var(--ease); display: inline; }
a.pub-title:hover { background-size: 100% 1px; }
a.pub-title::after { content: " ↗"; color: var(--accent); font-family: var(--sans); font-size: .85em; }
.pub-meta { margin: 8px 0 0; color: var(--muted); font-size: .9rem; }

/* ---------- Press ---------- */
.press-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 80px; }
/* the first press card is wider */
.press-card.featured { grid-column: span 2; }
.press-card.featured .headline { font-size: 1.6rem; max-width: 22em; }
.press-card {
  display: flex; flex-direction: column; gap: 14px; padding: 26px 24px;
  background: var(--surface); border-radius: 14px; text-decoration: none; min-height: 230px;
  transition: transform .45s var(--ease), box-shadow .45s var(--ease), background .3s;
}
a.press-card:hover { transform: translateY(-6px); box-shadow: 0 18px 40px -22px rgba(31, 35, 33, .35); background: #fff; }
.outlet { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 500; }
.headline { font-family: var(--serif); font-size: 1.2rem; line-height: 1.3; flex: 1; }
.date { font-size: .85rem; color: var(--muted); }

.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 16px 0; border-bottom: 1px solid var(--line); }
.plain-list li:first-child { border-top: 1px solid var(--line); }
.plain-list li span { display: block; font-size: .87rem; color: var(--muted); margin-top: 2px; }
.plain-list a { background-size: 0 1px; color: var(--text); }
.plain-list a:hover { background-size: 100% 1px; background-position: 0 100%; color: var(--accent); }

/* ---------- Teaching ---------- */
.teaching-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 72px; align-items: start; }
.postcard {
  margin: 0; background: var(--accent); color: #F2F5F3; border-radius: 18px; padding: 36px 34px;
  position: sticky; top: 110px;
}
.postcard-label { font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; opacity: .7; margin: 0 0 14px; }
.hypothesis { font-family: var(--serif); font-size: 1.75rem; line-height: 1.2; margin: 0 0 26px; }
.postcard table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .95rem; }
.postcard th { text-align: left; font-weight: 500; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; opacity: .7; padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,.25); }
.postcard th:last-child, .postcard td:last-child { text-align: right; }
.postcard td { padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,.12); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .88rem; }
.postcard .footnote { font-size: .8rem; opacity: .7; margin: 10px 0 22px; }
.postcard figcaption { font-family: var(--serif); font-style: italic; font-size: 1.12rem; line-height: 1.45; }

/* rows of the table appear one by one */
.postcard tbody tr { opacity: 0; transform: translateX(-8px); transition: opacity .5s var(--ease), transform .5s var(--ease); }
.postcard.visible tbody tr { opacity: 1; transform: none; }
.postcard.visible tbody tr:nth-child(1) { transition-delay: .35s; }
.postcard.visible tbody tr:nth-child(2) { transition-delay: .5s; }
.postcard.visible tbody tr:nth-child(3) { transition-delay: .65s; }
.postcard.visible tbody tr:nth-child(4) { transition-delay: .8s; }
.postcard.visible tbody tr:nth-child(5) { transition-delay: .95s; }

/* ---------- Contact ---------- */
.contact { text-align: center; padding: 160px 0 140px; }
.contact-title { font-size: clamp(2.4rem, 6vw, 4.6rem); letter-spacing: -.025em; margin-bottom: 40px; }
.contact-title em { color: var(--accent); }
.contact-email {
  font-family: var(--serif); font-size: clamp(1.25rem, 3vw, 2rem); text-decoration: none; color: var(--accent);
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
  transition: background-size .4s var(--ease); display: inline-block; padding-bottom: 4px;
  word-break: break-word;
}
.contact-email:hover { background-size: 0 1px; background-position: 100% 100%; }
.contact-links { display: flex; justify-content: center; gap: 32px; margin-top: 36px; }
.contact-links a { color: var(--muted); text-decoration: none; font-size: .95rem; transition: color .25s; }
.contact-links a:hover { color: var(--text); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); }
.footer-inner { display: flex; justify-content: space-between; padding: 28px 0; font-size: .85rem; color: var(--muted); }
.footer-inner a { text-decoration: none; }
.footer-inner a:hover { color: var(--text); }

/* =========================================================
   Animations
   ========================================================= */
/* Hero items fade up when the page loads */
.load-in { opacity: 0; transform: translateY(18px); animation: loadIn 1s var(--ease) forwards; animation-delay: calc(var(--d, 0) * 120ms + 100ms); }
.hero-photo.load-in { transform: translateY(24px) scale(.98); }
@keyframes loadIn { to { opacity: 1; transform: none; } }
.scroll-cue.load-in { animation-name: loadInCue; }
@keyframes loadInCue { to { opacity: .6; transform: none; } }

/* Everything with class="reveal" fades up when scrolled into view.
   Only applied when JavaScript is running (html.js), so content never stays hidden. */
.js .reveal {
  opacity: 0; transform: translateY(26px);
  transition: opacity .9s var(--ease), transform .9s var(--ease);
  transition-delay: calc(var(--d, 0) * 90ms);
}
.js .reveal.visible { opacity: 1; transform: none; }

/* Respect people who turn off animations in their system settings */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .load-in, .js .reveal, .postcard tbody tr { opacity: 1 !important; transform: none !important; }
  .timeline::before { transform: scaleY(1); }
}

/* =========================================================
   Tablet & mobile
   ========================================================= */
@media (max-width: 1000px) {
  .press-grid { grid-template-columns: repeat(2, 1fr); }
  .nav { gap: 18px; }
  .about-grid, .teaching-grid { grid-template-columns: 1fr; gap: 56px; }
  .postcard { position: static; max-width: 520px; }
}

/* Menu becomes a full-screen overlay below 1120px wide */
@media (max-width: 1120px) {
  /* hamburger menu */
  .menu-toggle {
    display: block; position: relative; z-index: 70; width: 40px; height: 40px;
    background: none; border: 0; cursor: pointer; padding: 0;
  }
  .menu-toggle span {
    position: absolute; left: 9px; right: 9px; height: 1.5px; background: var(--text);
    transition: transform .35s var(--ease), top .35s var(--ease);
  }
  .menu-toggle span:first-child { top: 15px; }
  .menu-toggle span:last-child { top: 24px; }
  .menu-open .menu-toggle span:first-child { top: 19.5px; transform: rotate(45deg); }
  .menu-open .menu-toggle span:last-child { top: 19.5px; transform: rotate(-45deg); }

  .nav {
    position: fixed; inset: 0; z-index: 60; background: var(--bg);
    flex-direction: column; justify-content: center; gap: 26px;
    opacity: 0; visibility: hidden; transition: opacity .35s var(--ease), visibility .35s;
  }
  .nav a { font-family: var(--serif); font-size: 2rem; color: var(--text); }
  .nav .nav-cv { font-family: var(--sans); font-size: 1rem; margin-top: 12px; padding: 10px 26px; }
  .nav .lang { order: 10; margin-top: 8px; }
  .nav .lang a { font-family: var(--sans); font-size: 1rem; padding: 6px 12px; }
  .menu-open .nav { opacity: 1; visibility: visible; }
  .menu-open { overflow: hidden; }
}

@media (max-width: 800px) {
  body { font-size: 16px; }
  .container { width: min(var(--max), 100% - 40px); }



  .hero { grid-template-columns: 1fr; gap: 44px; padding-top: 112px; min-height: 0; padding-bottom: 24px; }
  .hero-photo { order: -1; justify-self: start; width: min(240px, 62vw); }
  .hero-photo::before { inset: 12px -12px -12px 12px; }
  .logo { font-size: 1.05rem; }
  .scroll-cue { display: none; }

  .section { padding: 88px 0 24px; }
  .section-head { margin-bottom: 40px; }
  .two-col { grid-template-columns: 1fr; gap: 48px; }
  .pubs li { grid-template-columns: 1fr; gap: 6px; }
  .pubs li:hover { padding-left: 0; padding-right: 0; background: none; }
  .press-grid { grid-template-columns: 1fr; margin-bottom: 56px; }
  .press-card.featured { grid-column: auto; }
  .press-card.featured .headline { font-size: 1.25rem; }
  .press-card { min-height: 0; }
  .postcard { padding: 28px 24px; }
  .contact { padding: 110px 0 100px; }
  .contact-links { flex-direction: column; gap: 14px; }
  .footer-inner { flex-direction: column; gap: 8px; text-align: center; }
}

/* Hide the scroll progress bar while the mobile menu is open */
.menu-open .progress { opacity: 0; }
