/* =============================================================
   Jorge Parraga-Alava — researcher profile
   Premium minimalist · Aberdeen palette (navy / sea green / mint) · Avenir
   Publications live from ORCID · dynamic post generation
   ============================================================= */

:root {
  --white: #ffffff;
  --bg: #ffffff;
  --panel: #ffffff;
  /* Aberdeen palette: deep navy-slate chrome, sea/forest green accent,
     mint highlight, on a near-white grey body. Variable names kept from
     the old blue theme so the whole site reskins from this block. */
  --sky-1: #edf4ef;
  --sky-2: #dcebe1;
  --sky-line: #cde2d5;
  /* three greens: title, subtitle, links (hovers reuse these) */
  --blue: #43795f;       /* subtitle / secondary accent (sea green) */
  --blue-600: #38664f;   /* links (deeper green) */
  --blue-700: #305744;   /* title (darkest green) */
  /* accent used on card left borders and small decorations */
  --sky: #43795f;
  --mint: #8fd3a6;       /* mint highlight: underlines, active markers */
  --green-900: #21402d;  /* deep forest green: publication/post/card titles, metric values */
  --navy: #16302a;
  --navy-2: #0f2820;
  --navy-line: #2c4a40;
  --navy-ink: #e9f2ec;
  --navy-ink-2: #9bb8a9;
  --ink: #1c2a24;
  --ink-2: #45564e;
  --ink-3: #7c8d84;
  --line: #e5ece8;
  --line-2: #d5e2db;

  /* type scale — one consistent set of sizes for the whole site.
     fs-nav sits one step above fs-base so the menu reads slightly
     larger than body copy, as requested. */
  --fs-2xs: .66rem;  /* tiny uppercase labels: eyebrow, badges, chips */
  --fs-xs:  .78rem;  /* buttons, filters, pagination, meta rows, links */
  --fs-sm:  .85rem;  /* secondary text: authors, venue, CV rows */
  --fs-base: .93rem; /* body copy default */
  --fs-nav: .98rem;  /* menu / nav links, slightly larger than body */
  --fs-md:  .98rem;  /* intro paragraphs, prose, article body */
  --fs-lg:  1.03rem; /* card / publication titles */
  --fs-xl:  1.08rem; /* site name in the top bar */

  --font: "Avenir Next", "Avenir", "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.4, 0, .2, 1);
  /* a bit of textural variety: buttons get a small spring overshoot,
     frequent small controls (filters, pagination, tabs) react faster */
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-quick: cubic-bezier(.2, 0, 0, 1);
  --wrap: 940px;
  --radius: 12px;
  --shadow: 0 1px 1px rgba(16,36,31,.04), 0 3px 8px rgba(16,36,31,.06), 0 24px 46px -16px rgba(16,36,31,.22);
  --shadow-sm: 0 1px 1px rgba(16,36,31,.03), 0 7px 18px -8px rgba(16,36,31,.11);
  --shadow-lift: 0 3px 6px rgba(16,36,31,.07), 0 34px 60px -18px rgba(16,36,31,.28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-base);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }

/* per-page card left-border accent (--edge): each content type gets its own
   intense/dark green so publications, posts and portfolio tools are easy to
   tell apart. Metric pills keep their own --blue edge (set separately). */
body { --edge: var(--blue); }
body[data-page="publications"], body[data-page="home"] { --edge: #1f7a5c; }  /* teal-green */
body[data-page="news"], body[data-page="post"]        { --edge: #2f7d3a; }  /* grass green */
body[data-page="cv"]                                   { --edge: #14584c; }  /* dark teal */

::selection { background: var(--navy); color: var(--navy-ink); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 3px; }

svg { display: inline-block; vertical-align: middle; }

img, svg, video, iframe, canvas {
  max-width: 100%;
  height: auto;
}

/* ---------- Top bar: navy social strip + navy main row ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(115deg, var(--navy) 0%, #1f3a34 55%, #305749 100%);
  border-bottom: 2px solid var(--mint);
  box-shadow: 0 8px 22px -14px rgba(16,36,31,.18);
}
/* upper utility strip with academic-profile links (icon+text on desktop,
   icon-only on mobile), on the navy background of the old top bar */
.topbar-social {
  background: linear-gradient(115deg, var(--navy-2) 0%, var(--navy) 55%, #1f3a34 100%);
  border-bottom: 1px solid var(--navy-line);
}
.topbar-social-in {
  max-width: var(--wrap); margin: 0 auto;
  padding: .4rem clamp(1.1rem, 3vw, 2.2rem);
  display: flex; align-items: center; justify-content: flex-end; gap: .2rem;
}
/* language switch, sitting in the top strip to the right of the social icons,
   styled to match them: white, subtle, with a small globe */
.lang-top {
  display: inline-flex; align-items: center; gap: .35rem;
  color: #fff; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .05em;
  padding: .35rem .6rem; border-radius: 8px;
  border: 1px solid transparent;
  margin-left: .3rem; transition: background .14s var(--ease-quick), border-color .14s var(--ease-quick), transform .14s var(--ease-quick);
}
.lang-top:hover { background: rgba(255,255,255,.1); border-color: var(--navy-line); transform: translateY(-1px); }
.lang-top svg { width: 14px; height: 14px; flex: none; }
.topbar-social .socials { gap: .15rem; }
.topbar-social .socials a { color: #fff; padding: .35rem .6rem; }
.topbar-social .socials a:hover { color: #fff; background: rgba(255,255,255,.1); border-color: var(--navy-line); transform: translateY(-1px); }
@media (max-width: 640px) {
  .topbar-social .socials a span { display: none; }
  .topbar-social .socials a { padding: .35rem .45rem; }
}
.topbar-in {
  max-width: var(--wrap); margin: 0 auto;
  padding: 1.15rem clamp(1.1rem, 3vw, 2.2rem);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .6rem; line-height: 1.15; }
.brand .logo { height: 70px; width: auto; display: block; flex: none; }
/* the visible mark is the logo; the name stays in the DOM for
   screen readers and SEO but isn't shown on screen */
.brand .bname {
  font-family: "Montserrat", var(--font);
  font-weight: 700; font-size: var(--fs-xl);
  letter-spacing: .015em; color: #fff;
}
.brand .bname.visually-hidden,
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.brand .brole { display: none; }

.nav { display: flex; align-items: center; gap: .2rem; flex-wrap: wrap; justify-content: flex-end; }
.nav a {
  font-size: var(--fs-nav); font-weight: 600; color: var(--navy-ink-2);
  padding: .45rem .7rem; border-radius: 8px; display: inline-block;
  transition: background .14s var(--ease-quick), color .14s var(--ease-quick), transform .14s var(--ease-quick);
}
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; transform: translateY(-1px); }
.nav a.active { color: #fff; background: rgba(255,255,255,.14); }
.nav a.lang {
  border: 1px solid var(--navy-line); color: var(--navy-ink-2); font-weight: 700; letter-spacing: .05em;
  padding: .34rem .6rem; margin-left: .45rem;
  display: inline-flex; align-items: center; gap: .38rem;
}
.nav a.lang::before {
  content: "";
  width: 20px; height: 14px; flex: none;
  background-size: contain; background-position: center; background-repeat: no-repeat;
}
/* target-language flag, line style (no color): ES link → Ecuador, EN link → USA */
.nav a.lang[hreflang="es"]::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 16' fill='none' stroke='%239bb8a9' stroke-width='1.3' stroke-linejoin='round'%3E%3Crect x='1' y='1.5' width='22' height='13' rx='1.5'/%3E%3Cline x1='1' y1='8' x2='23' y2='8'/%3E%3Cline x1='1' y1='11.5' x2='23' y2='11.5'/%3E%3C/svg%3E");
}
.nav a.lang[hreflang="en"]::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 16' fill='none' stroke='%239bb8a9' stroke-width='1.2' stroke-linejoin='round'%3E%3Crect x='1' y='1.5' width='22' height='13' rx='1.5'/%3E%3Crect x='1' y='1.5' width='10' height='7'/%3E%3Cline x1='11.5' y1='4.5' x2='23' y2='4.5'/%3E%3Cline x1='1' y1='11.3' x2='23' y2='11.3'/%3E%3C/svg%3E");
}
.nav a.lang:hover { border-color: var(--mint); color: #fff; background: rgba(255,255,255,.1); }

/* active nav item is marked only by the subtle background pill above —
   no colored underline. */

/* ---------- Mobile menu toggle (hamburger + "Menú" label, top-right) ---------- */
/* Pure-CSS toggle: pair with this markup inside .topbar-in, after .brand —
   <input type="checkbox" id="nav-toggle" class="nav-toggle-input" hidden>
   <label for="nav-toggle" class="nav-toggle" aria-label="Abrir menú">
     <span class="nav-toggle-bars"><span></span><span></span><span></span></span>
     <span class="nav-toggle-txt">Menú</span>
   </label>
   ...then the existing <nav class="nav"> as the next sibling. */
.nav-toggle-input { display: none; }
.nav-toggle {
  display: none; flex: none; align-items: center; justify-content: center;
  flex-direction: row; gap: .4rem;
  width: auto; height: 38px; margin-left: .4rem; padding: 0 .55rem;
  border-radius: 8px; cursor: pointer;
  transition: background .18s var(--ease);
}
.nav-toggle-txt {
  font-size: var(--fs-sm); font-weight: 600; color: var(--navy-ink-2); white-space: nowrap;
}
.nav-toggle-bars { display: flex; flex-direction: column; gap: 5px; flex: none; }
.nav-toggle-bars span {
  display: block; width: 19px; height: 2px; border-radius: 2px;
  background: var(--navy-ink); transition: transform .28s var(--ease), opacity .18s var(--ease), width .18s var(--ease);
}
.nav-toggle:hover { background: rgba(255,255,255,.1); }
.nav-toggle:hover .nav-toggle-bars span { width: 22px; }

/* ---------- Page banner (third strip: teal-green band with the page title,
   echoing the University of Aberdeen profile hero) ---------- */
.page-banner {
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.page-banner-t {
  margin: 0; padding: .86rem 0; color: var(--green-900); font-weight: 700;
  font-size: clamp(.95rem, 1.5vw, 1.16rem); letter-spacing: -.015em; text-wrap: balance;
}

/* ---------- Content ---------- */
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 clamp(1.1rem, 3vw, 2rem); }
.content { padding-top: clamp(1rem, 2.4vw, 1.6rem); padding-bottom: 1.5rem; min-width: 0; }

/* ---------- home hero decoration (abstract data/network motif, no photo) ---------- */
.hero-wrap { position: relative; }
.hero-deco {
  position: absolute; top: -2.2rem; right: -1.4rem; z-index: 0;
  width: min(40vw, 460px); height: auto; opacity: .8; pointer-events: none;
}
.hero-deco .n { animation: heroPulse 3.6s ease-in-out infinite; }
.hero-deco .n2 { animation-delay: .6s; }
.hero-deco .n3 { animation-delay: 1.2s; }
@keyframes heroPulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@media (max-width: 900px) { .hero-deco { display: none; } }
@media (prefers-reduced-motion: reduce) { .hero-deco .n { animation: none; } }

.page-head { position: relative; z-index: 1; margin-bottom: 2.2rem; }
.eyebrow {
  display: flex; align-items: center; gap: .55rem;
  font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
  color: var(--blue); margin: 0 0 1rem;
}
.eyebrow::before { content: ""; width: 22px; height: 1px; background: var(--sky); flex: none; }
h1.title {
  font-weight: 700; font-size: clamp(1.3rem, 2.1vw, 1.6rem); line-height: 1.22;
  letter-spacing: -.015em; margin: 0 0 .9rem; color: var(--green-900); text-wrap: balance;
}
/* .big only constrains the line length of the homepage headline now —
   it no longer renders larger than the h1 on every other page. */
h1.title.big { max-width: 34ch; }
h1.title em { font-style: normal; color: var(--blue-700); }
.page-head .say { font-size: var(--fs-base); font-weight: 400; color: var(--ink-2); max-width: 56ch; margin: 0; line-height: 1.65; }
.page-head .btn { margin-top: 1.2rem; }

/* interests */
.tags { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.6rem 0 0; }
.tag {
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: .01em; color: var(--ink-2);
  background: transparent; border: 1px solid var(--line-2);
  padding: .3rem .78rem; border-radius: 100px; transition: border-color .16s var(--ease), color .16s var(--ease);
}
.tag:hover { border-color: var(--blue); color: var(--blue-600); }

/* ---------- Metrics System (Hero Grid, Advanced Grid, and Trajectory Chart) ---------- */
.metrics-section { margin-top: 1.8rem; margin-bottom: 2.2rem; }

/* 4-column Hero Cards for primary metrics */
.stat-hero-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .85rem;
}
@media (max-width: 860px) { .stat-hero-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 460px) { .stat-hero-grid { grid-template-columns: 1fr; } }

/* Base stat card */
.stat {
  position: relative; cursor: help;
  background: linear-gradient(160deg, #fefffe 0%, #fbfdfc 100%);
  border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: var(--radius); padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: .55rem;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease);
}
.stat:hover, .stat.open { border-color: var(--line-2); border-left-color: var(--blue-700); box-shadow: var(--shadow-lift); }

/* Hero Cards: larger typography and elevated appearance */
.stat-hero {
  background: linear-gradient(145deg, #ffffff 0%, #f6faf7 100%);
  border: 1px solid var(--sky-line); border-left: 4px solid var(--blue);
  padding: 1.35rem 1.45rem;
  box-shadow: 0 2px 10px rgba(22,48,42,.06);
}
.stat-hero:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(22,48,42,.11); border-left-color: var(--blue-700); }
.stat-hero .stat-hd .ic {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--sky-1); color: var(--blue-700);
}
.stat-hero .stat-hd .ic svg { width: 15px; height: 15px; }
.stat-hero .n {
  font-weight: 700; font-size: clamp(1.85rem, 2.6vw, 2.4rem); line-height: 1;
  color: var(--green-900); letter-spacing: -.03em; margin-top: auto;
}

.stat-hd { display: flex; align-items: center; gap: .5rem; }
.stat-hd .ic {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 24px; height: 24px; border-radius: 7px;
  background: #fff; color: var(--blue-600);
}
.stat-hd svg { width: 13px; height: 13px; flex: none; }
.stat .l { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .01em; color: var(--ink-3); line-height: 1.25; text-transform: none; }
.stat .l .ab { color: var(--blue-600); font-weight: 700; }
.stat .n { font-weight: 700; font-size: clamp(1.24rem, 2.1vw, 1.55rem); line-height: 1; color: var(--green-900); letter-spacing: -.02em; margin-top: auto; }
.stat .n small { color: var(--green-900); font-size: .55em; vertical-align: baseline; font-weight: 700; margin-left: 1px; }

/* Toggle button for advanced bibliometrics */
.stat-actions { display: flex; justify-content: center; margin: 1.15rem 0; }
.stat-toggle-btn {
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .55rem 1.15rem; background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 100px; font-family: inherit; font-size: var(--fs-xs); font-weight: 600;
  color: var(--ink-2); cursor: pointer; box-shadow: var(--shadow-sm);
  transition: all .2s var(--ease);
}
.stat-toggle-btn:hover { border-color: var(--blue); color: var(--blue-600); transform: translateY(-1px); box-shadow: var(--shadow); }
.stat-toggle-btn .btn-ic { display: inline-flex; align-items: center; justify-content: center; transition: transform .22s var(--ease); }
.stat-toggle-btn.on .btn-ic { transform: rotate(180deg); }
.stat-toggle-btn .btn-badge {
  background: var(--sky-1); color: var(--blue-700); font-size: var(--fs-2xs); font-weight: 700;
  padding: .12rem .48rem; border-radius: 100px;
}

/* Advanced metrics grid (collapsible) */
.stat-advanced-wrap { margin-bottom: 1.4rem; animation: fadeIn .22s var(--ease); }
.stat-advanced-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
}
@media (max-width: 860px) { .stat-advanced-grid { grid-template-columns: repeat(2, 1fr); } }

/* Contextual tooltip — absolute-positioned relative to each .stat card */
.stat .tip {
  position: absolute; z-index: 200;
  bottom: calc(100% + 7px);
  left: 50%; transform: translateX(-50%);
  width: max-content; max-width: min(78vw, 240px);
  background: var(--ink); color: #fff; font-size: var(--fs-xs); font-weight: 500; line-height: 1.4;
  padding: .55rem .7rem; border-radius: 9px; box-shadow: var(--shadow);
  opacity: 0; visibility: hidden;
  transition: opacity .18s var(--ease), visibility .18s var(--ease);
  pointer-events: none;
  white-space: normal;
}
/* Small arrow pointing down */
.stat .tip::after {
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--ink);
}
.stat.open .tip,
.stat:hover .tip,
.stat:focus-within .tip { opacity: 1; visibility: visible; }

/* ---------- Trajectory Chart Card ---------- */
.metrics-chart-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 1.35rem 1.6rem; margin-top: 1.2rem;
}
.chart-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .8rem;
  margin-bottom: .8rem; padding-bottom: .7rem; border-bottom: 1px solid var(--line);
}
.chart-title {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}
.chart-title svg { color: var(--blue-600); }
.chart-legend { display: inline-flex; align-items: center; gap: 1.1rem; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); }
.leg-item { display: inline-flex; align-items: center; gap: .4rem; }
.leg-dot { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.leg-pubs .leg-dot { background: var(--blue); }
.leg-cites .leg-dot { background: var(--mint); }
.leg-dash {
  width: 16px; height: 2px; flex: none; border-radius: 1px;
  background: repeating-linear-gradient(to right, var(--blue) 0, var(--blue) 4px, transparent 4px, transparent 7px);
  opacity: .65;
}

.chart-body { position: relative; width: 100%; min-height: 140px; }
.chart-loading { font-size: var(--fs-xs); color: var(--ink-3); padding: 2rem 0; text-align: center; }
.chart-svg-wrap { position: relative; width: 100%; }
.metrics-svg { width: 100%; height: auto; display: block; overflow: visible; }

.cbar { cursor: pointer; transition: opacity .16s var(--ease), fill .16s var(--ease); }
.cbar-pubs { fill: var(--blue); opacity: .88; }
.cbar-cites { fill: var(--mint); opacity: .9; }
.chart-group:hover .cbar-pubs, .chart-group:focus .cbar-pubs { fill: var(--blue-700); opacity: 1; }
.chart-group:hover .cbar-cites, .chart-group:focus .cbar-cites { fill: #48a66d; opacity: 1; }
.chart-yr-txt { fill: var(--ink-3); font-size: 11px; font-weight: 600; font-family: var(--font); }
.chart-axis-txt { fill: var(--ink-3); font-size: 10px; font-weight: 600; font-family: var(--font); }
.chart-trend-line {
  stroke: var(--blue); stroke-width: 1.5; stroke-dasharray: 5 3; opacity: .55;
  stroke-linecap: round;
}

.chart-tooltip {
  position: absolute; pointer-events: none; opacity: 0;
  transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .5rem .75rem; border-radius: 8px;
  font-size: var(--fs-xs); box-shadow: var(--shadow); z-index: 100;
  transition: opacity .15s var(--ease); white-space: nowrap;
}
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip .tip-yr { font-weight: 700; margin-bottom: .25rem; font-size: var(--fs-xs); color: #fff; }
.chart-tooltip .tip-row { display: flex; align-items: center; gap: .4rem; font-size: var(--fs-2xs); color: #e1ede6; margin-top: .15rem; }
.chart-tooltip .tip-row small { color: #9bb8a9; }
.dot-p { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--mint); }
.dot-c { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #ffffff; }

/* ---------- Live Sync Footer ---------- */
.metrics-footer {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .8rem;
  margin-top: .9rem; padding: .4rem .3rem 0; font-size: var(--fs-2xs); color: var(--ink-3);
}
.sync-status { display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; }
.pulse-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34,197,94,.5); animation: pulseGreen 2s infinite;
}
@keyframes pulseGreen {
  0% { box-shadow: 0 0 0 0 rgba(34,197,94,.6); }
  70% { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
.source-links { display: inline-flex; align-items: center; gap: .75rem; }
.src-link { color: var(--blue-600); font-weight: 600; text-decoration: none; transition: color .15s; }
.src-link:hover { color: var(--blue-700); text-decoration: underline; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* home extras */
.home-links { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 2rem; }
.btn { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .02em; padding: .68rem 1.25rem; border-radius: var(--radius); display: inline-flex; align-items: center; gap: .45rem; transition: all .24s var(--ease-spring); }
.btn.primary { background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%); color: #fff; box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: linear-gradient(180deg, var(--navy-2) 0%, var(--navy-2) 100%); box-shadow: var(--shadow); transform: translateY(-1px); }
.btn.primary:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.btn.ghost { background: var(--panel); color: var(--ink); border: 1px solid var(--line-2); }
.btn.ghost:hover { border-color: var(--blue); color: var(--blue-600); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:disabled { opacity: .6; cursor: default; pointer-events: none; }

.excerpt { margin-top: 2.2rem; padding-top: 1.9rem; border-top: 1px solid var(--line); max-width: 62ch; }
.excerpt p { color: var(--ink-2); margin: 0 0 .9rem; font-size: var(--fs-md); line-height: 1.7; }

/* ---------- section title ---------- */
.sec-title { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.sec-title h2 { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 0; }
.sec-title .more-link { font-size: var(--fs-xs); font-weight: 600; color: var(--blue-600); }
.sec-title .more-link:hover { color: var(--blue-700); }
/* home page tabs ("Recent publications" / "Latest classes"): plain title case,
   no small-caps eyebrow treatment */
#home-panel-pubs .sec-title h2, #home-panel-yt .sec-title h2 {
  font-size: var(--fs-md); font-weight: 700; letter-spacing: normal; text-transform: none; color: var(--ink);
}

/* ---------- Publications ---------- */
.orcid-note {
  display: flex; align-items: center; gap: .5rem;
  font-size: var(--fs-xs); font-weight: 600; color: var(--ink-3); margin-bottom: 1.2rem;
}
.orcid-note .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sky); box-shadow: 0 0 0 0 rgba(67,121,95,.5); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(67,121,95,.45); } 70% { box-shadow: 0 0 0 7px rgba(67,121,95,0); } 100% { box-shadow: 0 0 0 0 rgba(67,121,95,0); } }

/* Publication toolbar with filters, summary, and sort control */
.pub-toolbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .9rem;
  margin-bottom: 1.3rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line);
}
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 2rem; }
#home-tabs { margin-bottom: 2.5rem; }
.pub-search { padding: 0.4rem 0.8rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font-family: inherit; font-size: var(--fs-sm); width: 250px; }
@media (max-width: 640px) { .pub-search { width: 100%; margin-bottom: 1rem; } }
.filters button {
  font: inherit; font-size: var(--fs-xs); font-weight: 600; cursor: pointer;
  background: var(--panel); color: var(--ink-2);
  border: 1px solid var(--line-2); padding: .4rem .95rem; border-radius: 100px; transition: all .12s var(--ease-quick);
}
.filters button:hover { border-color: var(--blue); color: var(--blue-600); }
.filters button.on { background: var(--navy); color: #fff; border-color: var(--navy); }

.pub-controls { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-left: auto; }
.pub-summary { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-3); }
.pub-summary .sum-badge {
  display: inline-flex; align-items: center;
  background: var(--sky-1); border: 1px solid var(--sky-line); color: var(--blue-700);
  padding: .25rem .7rem; border-radius: 100px; font-size: var(--fs-2xs); font-weight: 700;
}

.pub-sort-wrap { display: inline-flex; align-items: center; gap: .45rem; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); }
.pub-sort-select {
  font-family: inherit; font-size: var(--fs-xs); font-weight: 600; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px;
  padding: .35rem .65rem; cursor: pointer; transition: all .15s var(--ease);
}
.pub-sort-select:hover, .pub-sort-select:focus { border-color: var(--blue); outline: none; box-shadow: var(--shadow-sm); }

.pubs { display: grid; gap: .75rem; }
.pub {
  position: relative; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--edge);
  border-radius: var(--radius); padding: 1.5rem 1.7rem; box-shadow: var(--shadow-sm);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease);
}
.pub:hover { border-color: var(--line-2); border-left-color: var(--edge); box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.pub h3 { font-weight: 700; font-size: var(--fs-base); line-height: 1.35; letter-spacing: -.01em; margin: 0 0 .35rem; color: var(--green-900); }
.pub h3 a:hover { color: var(--blue-600); }
.pub .auth { font-size: var(--fs-sm); color: var(--ink-2); margin: 0 0 .2rem; }
.pub .auth b { color: var(--ink); font-weight: 700; }
.pub .meta { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: .35rem; }
.pub .yrchip {
  font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .06em;
  color: var(--blue-700); background: var(--sky-1); border: 1px solid var(--sky-line);
  padding: .1rem .5rem; border-radius: 4px;
}
.pub .badge-quartile {
  font-size: var(--fs-2xs); font-weight: 800; letter-spacing: .04em;
  padding: .1rem .45rem; border-radius: 4px; text-transform: uppercase;
}
.pub .badge-quartile.badge-q1 {
  background: #dcfce7; color: #15803d; border: 1px solid #86efac;
}
.pub .badge-quartile.badge-q2 {
  background: #e0f2fe; color: #0369a1; border: 1px solid #7dd3fc;
}
.pub .badge-oa {
  display: inline-flex; align-items: center; gap: .25rem;
  background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0;
  padding: .1rem .45rem; border-radius: 4px; font-size: var(--fs-2xs); font-weight: 700;
}
.pub .badge-oa svg { width: 11px; height: 11px; flex: none; color: #16a34a; }
.pub .ven { font-size: var(--fs-sm); color: var(--ink-3); font-style: italic; }
.pub .cites-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .02em;
  color: var(--blue); background: transparent; border: 1px solid var(--line-2);
  padding: .1rem .5rem; border-radius: 4px; text-decoration: none; transition: all .14s var(--ease);
}
.pub .cites-chip:hover { border-color: var(--blue); color: var(--blue-700); background: var(--sky-1); }
.pub .cites-chip svg { width: 11px; height: 11px; flex: none; }
/* Scholar chip: filled mint tint so it reads as the primary citation source */
.pub .cites-chip.cites-scholar {
  color: var(--blue-700); background: var(--sky-1); border-color: var(--sky-line);
}
.pub .act { display: flex; flex-wrap: wrap; gap: .9rem; margin-top: .35rem; font-size: var(--fs-xs); font-weight: 600; }
.pub .act a, .pub .act button {
  background: none; border: none; padding: 0; font: inherit; font-weight: 600; cursor: pointer;
  color: var(--blue-600); display: inline-flex; align-items: center; gap: .28rem;
}
.pub .act a:hover, .pub .act button:hover { color: var(--blue-700); }
.pub .act .oa { color: #ea8a1e; }
.pub .act svg { width: 12px; height: 12px; }

/* pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.6rem; flex-wrap: wrap; }
.pagination button {
  font: inherit; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .04em;
  padding: .5rem 1.1rem; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink-2);
  border-radius: 8px; cursor: pointer; transition: all .12s var(--ease-quick);
}
.pagination button:hover:not(:disabled) { border-color: var(--blue); color: var(--blue-600); }
.pagination button:disabled { opacity: .35; cursor: default; }
.pagination .info { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-3); }
.pagination .goto { display: inline-flex; align-items: center; gap: .4rem; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-3); }
.pagination .goto select {
  font: inherit; font-weight: 600; color: var(--ink); cursor: pointer;
  border: 1px solid var(--line-2); background: var(--panel); border-radius: 7px;
  padding: .32rem 1.6rem .32rem .6rem; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2343795f' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .5rem center;
}
.pagination .goto select:hover { border-color: var(--blue); }

/* ---------- Rows (CV) ---------- */
.rows { display: grid; gap: .6rem; }
.row {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--edge); border-radius: var(--radius);
  padding: 1rem 1.3rem; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 1.1rem; align-items: baseline;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease);
}
.row:hover { border-color: var(--line-2); border-left-color: var(--edge); box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.row .when { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .03em; color: var(--blue-600); }
.row .what .t { font-weight: 700; font-size: var(--fs-sm); color: var(--green-900); }
.row .what .o { font-size: var(--fs-sm); color: var(--ink-2); margin-top: .18rem; }
.row .what .badge {
  display: inline-block; margin-left: .45rem; font-size: var(--fs-2xs); font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; color: var(--blue-700);
  background: var(--sky-1); border: 1px solid var(--sky-line); padding: .06rem .42rem; border-radius: 5px; vertical-align: middle;
}
.cv-block { margin-bottom: 2.4rem; }
.cv-block h2 { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.01em; text-transform: none; color: var(--ink); margin: 0 0 .95rem; }

/* ---------- News / posts ---------- */
.feed { display: grid; gap: .75rem; }
.card {
  position: relative; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--edge); border-radius: var(--radius);
  padding: 1.75rem 1.9rem; box-shadow: var(--shadow-sm); transition: border-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease);
}
.card:hover { border-color: var(--line-2); border-left-color: var(--edge); box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.card .meta { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; font-size: var(--fs-2xs); color: var(--ink-3); font-weight: 600; margin-bottom: .6rem; }
.meta .mi { display: inline-flex; align-items: center; gap: .32rem; }
.meta .mi svg { color: var(--blue-600); flex: none; }
.meta .mi time { color: inherit; }
.chip { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; border: 1px solid var(--line-2); color: var(--ink-2); padding: .14rem .5rem; border-radius: 6px; }
.chip.paper { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip.conference { background: var(--sky-1); border-color: var(--sky-line); color: var(--blue-700); }
.card h3 { font-weight: 700; font-size: var(--fs-base); line-height: 1.28; letter-spacing: -.01em; margin: 0 0 .45rem; color: var(--green-900); text-wrap: balance; }
.card h3 a:hover { color: var(--blue-600); }
.card p { margin: 0; color: var(--ink-2); font-size: var(--fs-base); max-width: 64ch; line-height: 1.65; }
.card .more { font-size: var(--fs-xs); font-weight: 700; color: var(--blue-600); margin-top: .8rem; display: inline-flex; align-items: center; gap: .3rem; transition: gap .18s var(--ease); }
.card .more:hover { gap: .45rem; }

/* ---------- About prose ---------- */
.prose { max-width: 64ch; font-size: var(--fs-md); color: var(--ink-2); line-height: 1.75; }
.prose p { margin: 0 0 1.1em; }
.prose em { color: var(--blue-600); font-style: normal; font-weight: 700; }

/* ---------- Contact block (About page) ---------- */
.contact-block { margin-top: 2.4rem; padding-top: 1.8rem; border-top: 1px solid var(--line); max-width: 64ch; }
.contact-block h2 { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 .9rem; }
.contact-mail {
  display: inline-flex; align-items: center; gap: .55rem;
  font-size: var(--fs-sm); font-weight: 700; color: var(--blue-600);
  padding: .7rem 1.1rem; border: 1px solid var(--sky-line); background: var(--sky-1);
  border-radius: var(--radius); transition: all .18s var(--ease);
}
.contact-mail svg { width: 16px; height: 16px; flex: none; }
.contact-mail:hover { background: var(--sky-2); border-color: var(--blue); color: var(--blue-700); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* ---------- Single post ---------- */
.post-hero { padding-bottom: 1.6rem; border-bottom: 1px solid var(--line); margin-bottom: 2rem; }
.post-hero h1 + .meta { margin-top: 1.4rem; }
.post-hero .meta { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--ink-3); font-weight: 600; margin-bottom: .2rem; }
.post-hero h1 { font-weight: 700; font-size: clamp(1.15rem, 2vw, 1.45rem); line-height: 1.22; letter-spacing: -.01em; margin: 0; max-width: 26ch; text-wrap: balance; color: var(--green-900); }
/* subtle text link (not a button), in the site blue */
.read-paper {
  display: inline-flex; align-items: center; gap: .4rem; margin-top: 1rem;
  color: var(--blue-600); font-weight: 700; font-size: var(--fs-sm);
}
.read-paper svg { width: 15px; height: 15px; }
.read-paper span:first-of-type { text-underline-offset: 3px; text-decoration-thickness: 1px; }
.read-paper:hover span:first-of-type { text-decoration: underline; }
.read-paper .oa-chip {
  font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--blue-700); background: var(--sky-1); border: 1px solid var(--sky-line);
  padding: .1rem .45rem; border-radius: 100px;
}
.post-layout { display: grid; grid-template-columns: minmax(0,1fr) 240px; gap: clamp(1.6rem, 4vw, 3rem); align-items: start; }
.related { position: sticky; top: 4.5rem; }
.related h3 { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 .9rem; }
.related .rel {
  display: flex; flex-direction: column; align-items: stretch; gap: .45rem;
  padding: .7rem 0; border-top: 1px solid var(--line);
}
.related .rel:first-child { border-top: none; }
.related .rel-main { flex: 1; min-width: 0; }
.related .rel-t { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--green-900); line-height: 1.35; }
.related .rel-main:hover .rel-t { color: var(--blue-600); }
.related .rel-m { display: block; font-size: var(--fs-2xs); color: var(--ink-3); margin-top: .25rem; }
.related .rel-doi {
  flex: none; color: var(--ink-3);
  display: inline-flex; padding: .2rem; border-radius: 6px;
}
.related .rel-doi:hover { color: var(--blue-600); background: var(--sky-1); }
.related .rel-doi svg { width: 14px; height: 14px; }

.article { max-width: 66ch; font-size: var(--fs-md); line-height: 1.75; color: var(--ink); }
.article p { margin: 0 0 1.15em; }
.article strong { font-weight: 700; }
.article h2 { font-weight: 700; font-size: 1.08rem; margin: 1.5em 0 .5em; }
.article code { font-size: .88em; background: var(--sky-1); padding: .1em .4em; border-radius: 5px; color: var(--blue-700); }
.refbox {
  background: var(--sky-1); border: 1px solid var(--sky-line); border-left: 2px solid var(--blue);
  border-radius: var(--radius); padding: 1.05rem 1.25rem; margin: 1.8rem 0; font-size: var(--fs-sm); color: var(--ink-2);
}
.refbox .lab { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--blue); display: block; margin-bottom: .45rem; }
.refbox em { font-style: italic; }
.refbox .ref-cite { margin-bottom: .2rem; }
.refbox .read-paper { margin-top: .9rem; }
.post-links { border-top: 1px solid var(--line); margin-top: 1.8rem; padding-top: 1rem; font-size: var(--fs-xs); font-weight: 600; display: flex; gap: 1.3rem; flex-wrap: wrap; }
.post-links a { color: var(--blue-600); display: inline-flex; align-items: center; gap: .3rem; }
.post-links a:hover { color: var(--blue-700); }
.post-links a.share-wa svg { color: #25d366; }
.meta a.share-wa { color: inherit; text-decoration: none; }
.meta a.share-wa svg { color: #25d366; }
.meta a.share-wa:hover { color: var(--blue-600); }
.meta a.share-wa:hover svg { color: #1ebe5b; }
.backlink {
  font-size: var(--fs-xs); font-weight: 700; color: var(--ink-2);
  margin-top: 1.6rem; display: inline-flex; align-items: center; gap: .4rem;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 100px;
  padding: .6rem 1.15rem; box-shadow: var(--shadow-sm);
  transition: all .18s var(--ease);
}
.backlink:hover { color: var(--blue-600); border-color: var(--blue); box-shadow: var(--shadow); transform: translateY(-1px); }

.loading { font-size: var(--fs-sm); color: var(--ink-3); padding: 1rem 0; }

/* ---------- Back to top (sits at the end of every page, before the footer) ---------- */
.to-top-wrap { display: flex; justify-content: center; padding: .4rem 0 1.6rem; }
.to-top {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em; color: var(--blue-600);
  padding: .55rem 1.2rem; border: 1px solid var(--line-2); border-radius: 100px;
  background: var(--panel); box-shadow: var(--shadow-sm);
  transition: color .16s var(--ease), border-color .16s var(--ease), box-shadow .16s var(--ease), transform .16s var(--ease);
}
.to-top:hover { color: var(--blue-700); border-color: var(--blue); box-shadow: var(--shadow); transform: translateY(-1px); }
.to-top svg { width: 14px; height: 14px; flex: none; }

/* ---------- Footer (teal-green band, matching the top strip and banner) ---------- */
.site-foot { border-top: 2px solid var(--mint); margin-top: 1rem; background: linear-gradient(115deg, var(--navy) 0%, #1f3a34 55%, #305749 100%); }
.site-foot-in {
  max-width: var(--wrap); margin: 0 auto; padding: 1.8rem clamp(1.1rem, 3vw, 2rem);
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .6rem;
}
.site-foot .socials { justify-content: center; }
.socials { display: flex; flex-wrap: wrap; gap: .3rem; }
.socials a {
  display: inline-flex; align-items: center; gap: .38rem;
  font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2);
  padding: .4rem .7rem; border-radius: 8px; border: 1px solid transparent; transition: all .18s var(--ease);
}
.socials a:hover { color: var(--blue-600); background: var(--sky-1); border-color: var(--sky-line); transform: translateY(-1px); }
.socials a svg { width: 15px; height: 15px; }
/* footer sits on navy: pure-white text and icons */
.site-foot .socials a { color: #fff; }
.site-foot .socials a:hover { color: #fff; background: rgba(255,255,255,.12); border-color: var(--navy-line); transform: translateY(-1px); }
.foot-meta { font-size: var(--fs-xs); color: #fff; font-weight: 500; }
.foot-meta a { color: #fff; font-weight: 600; }
.foot-meta a:hover { color: #fff; text-decoration: underline; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%) translateY(16px);
  background: var(--ink); color: #fff; font-size: var(--fs-xs); font-weight: 600;
  padding: .6rem 1.1rem; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease); z-index: 60; box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- scroll progress bar (top of viewport) ---------- */
#scroll-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: linear-gradient(90deg, var(--sky), var(--blue));
  z-index: 999; pointer-events: none;
}

/* ---------- Responsive ---------- */
/* ---------- Responsive / mobile UX ---------- */
/* top bar stays one row: brand left, hamburger top-right; the full nav
   is hidden and only appears as a dropdown panel when the toggle is opened */
@media (max-width: 760px) {
  .topbar-in { gap: .7rem; flex-wrap: nowrap; }
  .nav-toggle { display: inline-flex; }
  .nav {
    position: absolute; top: calc(100% + .55rem); left: .75rem; right: .75rem;
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    gap: .15rem; flex-wrap: nowrap;
    background: var(--white);
    border: 1px solid var(--line-2);
    border-radius: 16px;
    box-shadow: 0 22px 42px -14px rgba(16,36,31,.28), 0 4px 12px rgba(16,36,31,.12);
    padding: 0 .55rem;
    max-height: 0; overflow: hidden; opacity: 0;
    transition: max-height .32s var(--ease), opacity .22s var(--ease), padding .32s var(--ease);
  }
  .nav-toggle-input:checked ~ .nav {
    max-height: 26rem; opacity: 1; padding: .55rem;
  }
  .nav a { width: 100%; padding: .8rem .85rem; border-radius: 10px; border-bottom: none; color: var(--ink-2); }
  .nav a:hover { background: var(--sky-1); padding-left: .85rem; transform: none; color: var(--blue-600); }
  .nav a.active { border-radius: 10px; color: var(--blue-700); background: var(--sky-1); }
  .nav a.lang { margin: .3rem 0 .05rem; align-self: stretch; justify-content: center; border-color: var(--line-2); color: var(--ink-2); }
  .nav a.lang:hover { border-color: var(--blue); color: var(--blue-600); background: var(--sky-1); }
  .nav a.lang[hreflang="es"]::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 16' fill='none' stroke='%2345564e' stroke-width='1.3' stroke-linejoin='round'%3E%3Crect x='1' y='1.5' width='22' height='13' rx='1.5'/%3E%3Cline x1='1' y1='8' x2='23' y2='8'/%3E%3Cline x1='1' y1='11.5' x2='23' y2='11.5'/%3E%3C/svg%3E");
  }
  .nav a.lang[hreflang="en"]::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 16' fill='none' stroke='%2345564e' stroke-width='1.2' stroke-linejoin='round'%3E%3Crect x='1' y='1.5' width='22' height='13' rx='1.5'/%3E%3Crect x='1' y='1.5' width='10' height='7'/%3E%3Cline x1='11.5' y1='4.5' x2='23' y2='4.5'/%3E%3Cline x1='1' y1='11.3' x2='23' y2='11.3'/%3E%3C/svg%3E");
  }
  /* hamburger → close icon */
  .nav-toggle-input:checked ~ .nav-toggle .nav-toggle-bars span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle-input:checked ~ .nav-toggle .nav-toggle-bars span:nth-child(2) { opacity: 0; width: 0; }
  .nav-toggle-input:checked ~ .nav-toggle .nav-toggle-bars span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .row { grid-template-columns: 1fr; gap: .25rem; }
  .post-layout { grid-template-columns: 1fr; }
  .related { position: static; border-top: 1px solid var(--line); padding-top: 1.2rem; margin-top: 1.4rem; }
}
@media (max-width: 640px) {
  .brand .bname { font-size: var(--fs-xl); }
  .content { padding-top: 1.4rem; }
  h1.title.big { max-width: 100%; }
  .pub { grid-template-columns: 1fr; gap: .4rem; padding: .9rem 1rem; }
  .pub .yr { display: flex; align-items: baseline; gap: .55rem; }
  .pub .yr .kind { margin-top: 0; }
  .site-foot-in { gap: .7rem; }
  .socials { gap: .1rem; }
  .foot-meta { overflow-wrap: anywhere; line-height: 1.6; }
  .card, .row, .stat, .metrics-chart-card { padding: .9rem 1rem; }
}
/* guarantee a comfortable side margin on small phones, independent of viewport-width rounding */
@media (max-width: 480px) {
  .wrap,
  .topbar-in,
  .site-foot-in {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}
/* comfortable tap targets on touch devices */
@media (hover: none) and (pointer: coarse) {
  .nav a, .cv-tab, .filters button, .pagination button, .pub .act a, .pub .act button, .socials a { min-height: 40px; display: inline-flex; align-items: center; }
  .nav-toggle { min-height: 42px; }
  .stat { cursor: pointer; }
}
/* never let long titles or DOIs break the layout */
.pub h3, .card h3, .post-hero h1, .rel-t, .ven, .ref-cite,
.prose, .article, .row .what .o, .auth {
  overflow-wrap: anywhere;
}

@media print { .topbar, .site-foot, .pagination, .filters, .cv-tabs, .nav-toggle { display: none; } body { background: #fff; } }

/* ---------- CV tabs ---------- */
.cv-tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
.cv-tab {
  font: inherit; font-size: var(--fs-md); font-weight: 600; color: var(--ink-2);
  background: transparent; border: none; padding: .6rem .95rem; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 8px 8px 0 0;
  transition: background .12s var(--ease-quick), color .12s var(--ease-quick);
}
.cv-tab:hover { background: var(--sky-1); color: var(--blue-600); }
.cv-tab.on { color: var(--blue-700); border-bottom: 3px solid var(--mint); }

/* ---------- YouTube "Latest classes" tab (home page) ---------- */
.yt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .9rem; }
.yt-card {
  display: flex; flex-direction: column; min-width: 0; height: 100%; background: var(--panel);
  border: 1px solid var(--line); border-left: 3px solid var(--edge);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease);
}
.yt-card:hover { border-color: var(--line-2); border-left-color: var(--edge); box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.yt-thumb { display: block; width: 100%; aspect-ratio: 16 / 9; background: var(--sky-1); overflow: hidden; flex: none; }
.yt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* padding lives on the outer .yt-title (a plain block, never clipped); the
   2-line clamp is applied only to the inner .yt-title-t span, so the bottom
   padding can never get eaten by the clamp box's own overflow:hidden */
.yt-title {
  padding: 1rem .95rem 1.3rem; display: block; flex: none;
}
.yt-title-t {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink); line-height: 1.55;
  overflow: hidden; overflow-wrap: anywhere; word-break: break-word;
}

/* ---------- Toolbox cards (tools / software / databases) ---------- */
.toolbox { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: .75rem; }
.tool-card {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--edge);
  border-radius: var(--radius); padding: 1.15rem 1.25rem; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: .55rem;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease);
}
.tool-card:hover { border-color: var(--line-2); border-left-color: var(--edge); box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.tool-badge {
  align-self: flex-start; font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; padding: .16rem .55rem; border-radius: 6px;
}
.tool-badge.tool { background: var(--sky-1); border: 1px solid var(--sky-line); color: var(--blue-700); }
.tool-badge.software { background: var(--navy); color: #fff; }
.tool-badge.database { background: var(--blue); color: #fff; }
.tool-card .tt { font-weight: 700; font-size: var(--fs-lg); line-height: 1.3; color: var(--green-900); overflow-wrap: anywhere; }
.tool-card .tmeta { font-size: var(--fs-2xs); font-weight: 600; letter-spacing: .02em; color: var(--ink-3); }
.tool-card .td { margin: 0; font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.55; }
.tool-card .topen {
  margin-top: auto; padding-top: .2rem; font-size: var(--fs-xs); font-weight: 700;
  color: var(--blue-600); display: inline-flex; align-items: center; gap: .35rem;
}
.tool-card .topen:hover { color: var(--blue-700); }
.tool-card .topen svg { width: 13px; height: 13px; }
.tool-card.placeholder {
  border-style: dashed; border-color: var(--line-2); background: transparent; box-shadow: none;
}
.tool-card.placeholder:hover { transform: none; box-shadow: none; }
.tool-card .tt-todo { font-weight: 600; font-size: var(--fs-sm); color: var(--ink-3); }

/* ---------- CV intro note ---------- */
.cv-note { font-size: var(--fs-sm); color: var(--ink-3); font-style: italic; margin: 0 0 1.2rem; }

/* ---------- Tool card header with platform icon ---------- */
.tool-hd { display: flex; align-items: center; gap: .55rem; }
.tool-ic { flex: none; display: inline-flex; align-items: center; color: var(--blue-600); }
.tool-ic svg { width: 18px; height: 18px; }
.tool-card .tool-hd .tt { margin: 0; }

/* ---------- Dataset cards (same card design as R packages) ---------- */
.tool-card .ds-yr { margin-left: auto; flex: none; font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .04em; color: var(--blue-700); background: var(--sky-1); border: 1px solid var(--sky-line); padding: .1rem .45rem; border-radius: 5px; }
.ds-act { display: flex; align-items: center; gap: 1.1rem; margin-top: auto; padding-top: .3rem; font-size: var(--fs-xs); font-weight: 700; }
.ds-dl { color: var(--blue-600); display: inline-flex; align-items: center; gap: .35rem; }
.ds-dl:hover { color: var(--blue-700); }
.ds-cite { background: none; border: none; padding: 0; font: inherit; font-weight: 700; cursor: pointer; color: var(--blue-600); display: inline-flex; align-items: center; gap: .35rem; }
.ds-cite:hover { color: var(--blue-700); }
.ds-act svg { width: 13px; height: 13px; }
/* GitHub link + "used in publications" contextual menu */
.ds-gh { color: var(--ink-2); display: inline-flex; align-items: center; }
.ds-gh:hover { color: var(--ink); }
.ds-used { position: relative; display: inline-flex; }
.ds-used-btn { background: none; border: none; padding: 0; cursor: pointer; color: var(--ink-2); display: inline-flex; align-items: center; }
.ds-used-btn:hover { color: var(--blue-600); }
.ds-used-menu {
  display: none; position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 30;
  width: max-content; max-width: min(300px, calc(100vw - 2.5rem));
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: var(--shadow); padding: .3rem;
}
.ds-used.open .ds-used-menu { display: block; }
.ds-used-hd { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .01em; text-transform: none; color: var(--ink-3); padding: .3rem .5rem .35rem; }
.ds-used-menu a { display: flex; align-items: flex-start; gap: .38rem; padding: .38rem .5rem; border-radius: 7px; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); line-height: 1.35; }
.ds-used-menu a:hover { background: var(--sky-1); color: var(--blue-700); }
.ds-used-menu a span { overflow-wrap: anywhere; }
.ds-used-menu a svg { width: 12px; height: 12px; flex: none; margin-top: .18rem; color: var(--blue-600); }
/* on phones the popover can run off the left edge, so pin it as a full-width
   sheet at the bottom of the viewport instead — it can never overflow */
@media (max-width: 560px) {
  .ds-used-menu {
    position: fixed; left: .9rem; right: .9rem; bottom: .9rem; top: auto;
    width: auto; max-width: none;
    box-shadow: 0 -6px 30px rgba(16,36,31,.22), 0 4px 14px rgba(16,36,31,.14);
  }
  .ds-used-menu a { font-size: var(--fs-sm); }
}

/* ---------- links in content are bold ---------- */
.prose a, .article a:not(.read-paper), .refbox a:not(.read-paper), .card p a, .row .what .o a, .foot-meta a, .post-links a, .say a { font-weight: 700; }
.prose a, .article a:not(.read-paper), .row .what .o a {
  color: var(--blue-600); border-radius: 5px; padding: 0 .12em;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.prose a:hover, .article a:not(.read-paper):hover, .row .what .o a:hover { background: var(--sky-1); color: var(--blue-700); }

/* ---------- consistent light-sky hover for interactive elements ---------- */
.pub .act a:hover, .pub .act button:hover,
.card .more:hover, .sec-title .more-link:hover,
.post-links a:hover,
.tool-card .topen:hover, .ds-dl:hover, .ds-cite:hover, .ds-gh:hover, .ds-used-btn:hover {
  background: var(--sky-1); border-radius: 6px;
}
.pub .act a, .pub .act button, .card .more, .sec-title .more-link, .post-links a,
.tool-card .topen, .ds-dl, .ds-cite, .ds-gh, .ds-used-btn { padding: .12rem .3rem; margin: -.12rem -.3rem; border-radius: 6px; }
.filters button:hover, .pagination button:hover:not(:disabled) { background: var(--sky-1); }
/* selected filter/tab button must stay dark+white even if :hover gets "stuck"
   after a tap on touch devices — otherwise it reads white-on-near-white */
.filters button.on:hover { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- related DOI badge ---------- */
.related .rel-doi {
  align-self: flex-start; width: fit-content; max-width: 100%;
  display: inline-flex; align-items: center; gap: .28rem;
  font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .02em; color: var(--blue-600);
  border: 1px solid var(--sky-line); background: var(--sky-1);
  padding: .3rem .5rem; border-radius: 6px; line-height: 1.3; white-space: normal;
}
.related .rel-doi:hover { border-color: var(--blue); background: var(--sky-2); }
.related .rel-doi svg { width: 11px; height: 11px; }

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


@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --panel: #1e1e1e;
    --sky-1: #1a2621;
    --sky-2: #21332a;
    --sky-line: #2b4539;
    --blue: #8fd3a6;
    --blue-600: #a7e0ba;
    --blue-700: #c2ecd1;
    --sky: #8fd3a6;
    --mint: #43795f;
    --green-900: #e5ece8;
    --ink: #e5ece8;
    --ink-2: #9bb8a9;
    --ink-3: #7c8d84;
    --line: #2b4539;
    --line-2: #385c4b;
  }
}

.skeleton {
  background: linear-gradient(90deg, var(--sky-1) 25%, var(--sky-2) 50%, var(--sky-1) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite linear;
  border-radius: var(--radius);
  color: transparent !important;
  display: inline-block;
  min-height: 1em;
}
.skeleton * {
  visibility: hidden;
}
@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}


.fade-up { opacity: 0; transform: translateY(20px); transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); }
.fade-up.visible { opacity: 1; transform: translateY(0); }
.pub-search { padding: 0.4rem 0.8rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font-family: inherit; font-size: var(--fs-sm); width: 250px; }
@media (max-width: 640px) { .pub-search { width: 100%; margin-bottom: 1rem; } }
