/* ==========================================================================
   Arnau Blanco — Modern light design system
   White, minimal, single-page layout with sticky nav + smooth scrolling.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --surface: #ffffff;
  --surface-hover: #f0f2f5;
  --border: #e3e6eb;
  --border-soft: #eceef2;
  --text: #14171c;
  --text-muted: #5a6370;
  --text-faint: #8a93a0;
  --accent: #0d9488;
  --accent-strong: #0f766e;
  --accent-soft: rgba(13, 148, 136, 0.1);
  --accent-2: #0284c7;
  --shadow: 0 12px 28px -14px rgba(20, 23, 28, 0.18);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --header-h: 72px;
  --max-w: 1080px;
  --font-sans: "Inter", "Inter var", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

img { max-width: 100%; display: block; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.18s ease;
}
a:hover, a:focus-visible { color: var(--accent-strong); }

h1, h2, h3, h4, h5 {
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em;
  color: var(--text);
}

p { margin: 0 0 1em; color: var(--text-muted); }

hr {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 2.5rem 0;
}

::selection { background: var(--accent-soft); color: var(--text); }

/* ---------- layout helpers ---------- */

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

.section {
  padding: 96px 0;
  border-bottom: 1px solid var(--border-soft);
  scroll-margin-top: var(--header-h);
}

.section:last-of-type { border-bottom: none; }

.section-head {
  margin-bottom: 48px;
  max-width: 640px;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.kicker::before {
  content: "";
  width: 22px;
  height: 1px;
  background: var(--accent);
}

.section-head h2 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  margin-bottom: 0.4em;
}

.section-head .lede {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin: 0;
}

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease, background 0.25s ease;
}

.site-header.is-scrolled {
  border-bottom-color: var(--border-soft);
  background: rgba(255, 255, 255, 0.92);
}

.site-header a:hover,
.site-header a:focus {
  text-decoration: none;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 16px;
}

.site-header nav {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  min-width: 0;
}

.site-header .brand,
.site-header .nav-cta,
.site-header .nav-brand-group {
  flex: 0 0 auto;
}

.nav-brand-group {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.nav-back {
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.nav-back:hover,
.nav-back:focus-visible {
  color: var(--accent);
}

@media (max-width: 1280px) {
  .nav-back-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.brand .dot { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links > li {
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-links a {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.nav-links a:hover,
.nav-links a.is-active {
  color: var(--text);
  background: var(--bg-soft);
}

.nav-cta {
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav-cta .icon-link {
  color: var(--text-muted);
  display: inline-flex;
  padding: 6px;
  border-radius: 8px;
}
.nav-cta .icon-link:hover { color: var(--text); background: var(--bg-soft); }

.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.nav-toggle svg { width: 20px; height: 20px; }

@media (max-width: 860px) {
  .nav-links { display: none; }
  .nav-toggle { display: inline-flex; }
  .nav-cta .btn { display: none; }
  .site-header nav { flex: 0; }

  body.nav-open .nav-links {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    padding: 12px 20px 24px;
    background: rgba(255, 255, 255, 0.98);
    border-bottom: 1px solid var(--border-soft);
    gap: 2px;
  }
  body.nav-open .nav-links a { padding: 12px 14px; border-radius: 10px; }
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}
.btn-primary:hover { background: var(--accent-strong); color: #ffffff; }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-strong); }

/* ---------- hero ---------- */

.hero {
  padding: 120px 0 88px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 480px;
  background: radial-gradient(60% 60% at 30% 20%, rgba(13, 148, 136, 0.12), transparent 70%),
              radial-gradient(50% 50% at 80% 10%, rgba(2, 132, 199, 0.1), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.hero .wrap { position: relative; z-index: 1; }

.hero-top {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 48px;
  align-items: start;
  margin-bottom: 3rem;
}

.hero-photo {
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.hero-photo img {
  width: 100%;
  height: auto;
  display: block;
}

.hero-copy { min-width: 0; }

.hero h1 {
  font-size: clamp(2rem, 4.8vw, 3.2rem);
  max-width: 18ch;
  margin-bottom: 0.3em;
}

.hero h1 .grad {
  background: linear-gradient(100deg, var(--accent) 10%, var(--accent-2) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero .hero-sub {
  font-size: 1.15rem;
  max-width: 56ch;
  color: var(--text-muted);
  margin-bottom: 2.2rem;
}

.hero .hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 0;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--text-faint);
}
.hero-meta strong { color: var(--text-muted); font-weight: 500; }

@media (max-width: 720px) {
  .hero { padding: 88px 0 64px; }
  .hero-top {
    grid-template-columns: 1fr;
    gap: 28px;
    justify-items: start;
    margin-bottom: 2.2rem;
  }
  .hero-photo {
    width: 148px;
  }
}

/* ---------- about ---------- */

.about-copy {
  max-width: 720px;
}

.about-copy p { font-size: 1.02rem; }
.about-copy p:last-child { margin-bottom: 0; }

/* ---------- timeline / experience ---------- */

.timeline {
  position: relative;
  margin-top: 8px;
  padding: 0;
  list-style: none;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 4px;
  bottom: 0;
  width: 1px;
  background: var(--border);
  transform: translateX(-50%);
}

.tl-item {
  position: relative;
  width: calc(50% - 28px);
  padding-bottom: 40px;
  box-sizing: border-box;
}
.tl-item:last-child { padding-bottom: 0; }

.tl-item--left {
  margin-right: auto;
  padding-right: 28px;
  text-align: right;
}

.tl-item--right {
  margin-left: auto;
  padding-left: 28px;
  text-align: left;
}

.tl-item::before {
  content: "";
  position: absolute;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}

.tl-item--left::before {
  right: -34px;
}

.tl-item--right::before {
  left: -34px;
}

.tl-date {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.03em;
  color: var(--accent);
  margin-bottom: 6px;
  display: block;
}

.tl-item h3 {
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.tl-item p {
  font-size: 0.96rem;
  margin: 0;
}

@media (max-width: 720px) {
  .timeline {
    padding-left: 28px;
  }
  .timeline::before {
    left: 0;
    transform: none;
  }
  .tl-item,
  .tl-item--left,
  .tl-item--right {
    width: 100%;
    margin: 0;
    padding-left: 28px;
    padding-right: 0;
    text-align: left;
  }
  .tl-item--left::before,
  .tl-item--right::before {
    left: -33px;
    right: auto;
  }
}

/* ---------- project cards ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}

@media (max-width: 920px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .card-grid { grid-template-columns: 1fr; } }

.project-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.project-card:hover {
  transform: translateY(-4px);
  border-color: rgba(13, 148, 136, 0.35);
  box-shadow: var(--shadow);
}

.project-thumb {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}

.project-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.project-card:hover .project-thumb img { transform: scale(1.06); }

.project-body {
  padding: 20px 22px 22px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.project-tags {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tag {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(13, 148, 136, 0.2);
}

.tag.tag-muted {
  color: var(--text-muted);
  background: var(--surface-hover);
  border-color: var(--border);
}

.project-body h3 {
  font-size: 1.08rem;
  margin-bottom: 8px;
}

.project-body h3 a { color: var(--text); }
.project-body h3 a:hover { color: var(--accent); }

.project-body p {
  font-size: 0.94rem;
  margin-bottom: 0;
  flex: 1;
}

.project-links {
  display: flex;
  gap: 16px;
  margin-top: 16px;
  font-size: 13.5px;
  font-weight: 600;
}

/* ---------- publications ---------- */

.pub-list { display: flex; flex-direction: column; gap: 0; }

.pub-item {
  padding: 24px 0;
  border-top: 1px solid var(--border-soft);
}
.pub-item:first-child { border-top: none; padding-top: 0; }

.pub-item h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.pub-meta {
  font-size: 0.9rem;
  color: var(--text-faint);
  margin: 0;
}
.pub-meta b { color: var(--text-muted); font-weight: 600; }

/* ---------- teaching ---------- */

.teaching-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: center;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.teaching-card p:last-of-type { margin-bottom: 0; }

.stat-row {
  display: flex;
  gap: 32px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.stat-row .stat-value {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  color: var(--accent);
  font-weight: 700;
  display: block;
}

.stat-row .stat-label {
  font-size: 12.5px;
  color: var(--text-faint);
}

@media (max-width: 640px) {
  .teaching-card { grid-template-columns: 1fr; }
}

/* ---------- blog ---------- */

.blog-list {
  display: flex;
  flex-direction: column;
}

.blog-item {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: baseline;
  padding: 22px 0;
  border-top: 1px solid var(--border-soft);
}
.blog-item:first-child { border-top: none; padding-top: 0; }

.blog-item .blog-main h3 {
  font-size: 1.05rem;
  margin-bottom: 6px;
}
.blog-item .blog-main h3 a { color: var(--text); }
.blog-item .blog-main h3 a:hover { color: var(--accent); }

.blog-item p { margin: 0; font-size: 0.94rem; }

.blog-date {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-faint);
  white-space: nowrap;
  padding-top: 4px;
}

@media (max-width: 640px) {
  .blog-item { flex-direction: column; gap: 6px; }
}

/* ---------- contact ---------- */

.contact-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

@media (max-width: 720px) { .contact-grid { grid-template-columns: 1fr; } }

.contact-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--text);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.contact-card:hover {
  border-color: rgba(13, 148, 136, 0.35);
  transform: translateY(-2px);
  color: var(--text);
}

.contact-card .icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.contact-card .icon svg { width: 20px; height: 20px; }

.contact-card .label {
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.contact-card .value { font-weight: 600; font-size: 14.5px; word-break: break-word; }

/* ---------- footer ---------- */

.site-footer {
  padding: 40px 0;
}

.site-footer .wrap {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13.5px;
  color: var(--text-faint);
}

.site-footer a { color: var(--text-faint); }
.site-footer a:hover { color: var(--accent); }

.footer-links { display: flex; gap: 18px; }

.back-to-top {
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- reveal-on-scroll ---------- */

[data-reveal] {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
[data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Legacy page compatibility (about-me redirect, teaching, blog, portfolio
   detail pages) — light theme re-skin for pages still using Bootstrap-based
   markup (container/row/col-lg-*), so the whole site reads consistently.
   ========================================================================== */

body.legacy-page {
  margin-top: 0;
}

.legacy-page .container {
  max-width: var(--max-w);
  width: 100%;
  padding-left: 24px;
  padding-right: 24px;
  padding-bottom: 96px;
}

.legacy-page .page-header {
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 16px;
  margin: 32px 0 24px;
  font-size: clamp(1.5rem, 3vw, 2rem);
}
.legacy-page .page-header small {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 0.5em;
  margin-left: 10px;
}

.legacy-page .publication-item h3 a,
.legacy-page .publications h3 a { color: var(--text); }
.legacy-page .publication-item h3 a:hover,
.legacy-page .publications h3 a:hover { color: var(--accent); }

.legacy-page hr { border-top: 1px solid var(--border-soft); }

.legacy-page .label,
.legacy-page .label-default {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 500;
}

.legacy-page .timeline-content {
  background: var(--surface);
  border: 1px solid var(--border);
}
.legacy-page .timeline-content p,
.legacy-page .timeline-date { color: var(--text-muted); }
.legacy-page .timeline::before { background: var(--border); }
.legacy-page .timeline-event::after {
  background: var(--accent);
  border-color: var(--bg);
  box-shadow: 0 0 0 2px var(--border);
}
.legacy-page .timeline-content a { color: var(--accent); }

.legacy-page .teaching-average,
.legacy-page .teaching-term { background: var(--surface); border-color: var(--border); }
.legacy-page .teaching-average-label,
.legacy-page .teaching-grade-label,
.legacy-page .teaching-term-meta,
.legacy-page .teaching-overview { color: var(--text-muted); }
.legacy-page .teaching-average-value,
.legacy-page .teaching-grade-value { color: var(--accent); }
.legacy-page .teaching-course-guide { color: var(--accent); }
.legacy-page .teaching-comment { background: var(--surface-hover); border-left-color: var(--accent); color: var(--text-muted); }
.legacy-page .teaching-comments {
  display: flex;
  align-items: stretch;
  gap: 0;
}
.legacy-page .teaching-comments:hover,
.legacy-page .teaching-comments:focus-within,
.legacy-page .teaching-comments.teaching-comments--translate-active {
  background-color: var(--surface-hover);
  box-shadow: inset 0 0 0 1px var(--border);
}
.legacy-page .teaching-comments-content {
  flex: 1;
  min-width: 0;
}
.legacy-page .teaching-comments-translate {
  flex: 0 0 32px;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  max-width: 32px;
  margin-right: 4px;
  overflow: hidden;
  background: var(--surface);
  color: var(--accent);
}
.legacy-page .teaching-comments-translate:hover { background: var(--accent); color: #ffffff; }
.legacy-page .teaching-comments-translate-icon {
  width: 20px;
  height: 20px;
  max-width: 20px;
  max-height: 20px;
}

.legacy-page code, .legacy-page pre { background: var(--surface); color: var(--text); }

.legacy-page .tex { color: var(--text); }
