/* ============================================================
 * MALTA Lab — styles
 * The background network (js/network.js) is the identity: one
 * cluster per research area, in the lab's red and graphite tones,
 * on warm off-white paper.
 *
 *   Display  Archivo, expanded   (wordmark, headings)
 *   Body     Atkinson Hyperlegible Next
 *   Utility  Atkinson Hyperlegible Mono (dates, labels, venues)
 * ============================================================ */

:root {
  /* Surface scale — warm off-white */
  --paper:         #F3EFED;
  --surface:       rgb(251 249 248 / .9);   /* panels over the network */
  --surface-solid: #FBF9F8;
  --elev-1:        #EAE6E2;                 /* fills inside panels */
  --elev-2:        #E2DDD8;
  --border:        #D0CAC5;
  --border-strong: #B8B0A8;

  /* Ink scale — all hit WCAG AA on --paper */
  --ink:       #1F2328;   /* body, headings */
  --ink-soft:  #3F4750;   /* secondary copy   ~9:1 */
  --ink-mute:  #5B6470;   /* muted captions   ~5.2:1 */
  --ink-quiet: #6F7984;   /* tertiary, large text only */

  /* Brand accent */
  --accent:       #C8362A;
  --accent-hover: #A52A20;
  --accent-soft:  #F4D9D5;
  --accent-ink:   #7A1F18;
  --on-accent:    #FFFFFF;
  --accent-text:         #C8362A;   /* small red text   ~4.6:1 on paper, ~4.9:1 on surface */
  --accent-button:       #C8362A;   /* behind --on-accent ~5.2:1 */
  --accent-button-hover: #A52A20;   /* behind --on-accent ~7.1:1 */

  /* The wordmark bar: graphite into the brand red */
  --spectrum: linear-gradient(90deg, var(--ink), var(--accent));

  --font-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-body:    "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --font-mono:    "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --radius-sm: 3px;
  --radius:    6px;
  --radius-lg: 10px;
  --shadow-1: 0 1px 2px rgb(31 35 40 / .06);
  --shadow-2: 0 18px 40px -22px rgb(31 35 40 / .4);

  --gutter: 1.25rem;
  --header-h: 4.25rem;

  color-scheme: light;
}

/* Dark theme overrides — warm near-black, not pure black */
:root[data-theme="dark"] {
  --paper:         #1A1816;
  --surface:       rgb(35 32 32 / .9);
  --surface-solid: #232020;
  --elev-1:        #2C2826;
  --elev-2:        #34302D;
  --border:        #3A3633;
  --border-strong: #4D4843;

  --ink:       #F2EDE8;
  --ink-soft:  #C9C2BB;
  --ink-mute:  #9B948D;
  --ink-quiet: #7A746E;

  --accent:       #E84A3E;
  --accent-hover: #F2655A;
  --accent-soft:  #3A1A15;
  --accent-ink:   #F4D9D5;
  --on-accent:    #FFFFFF;
  --accent-text:         #F2655A;   /* ~5.3:1 on surface; --accent is only 4.3:1 */
  --accent-button:       #C8362A;   /* white on --accent would be 3.8:1 */
  --accent-button-hover: #A52A20;

  --shadow-1: 0 1px 2px rgba(0,0,0,.25), 0 1px 3px rgba(0,0,0,.35);
  --shadow-2: 0 18px 40px -20px rgb(0 0 0 / .75);

  color-scheme: dark;
}

/* -- reset ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; }
h1, h2, h3, h4, p, figure, blockquote, dl, dd { margin: 0; }
img, svg, canvas { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* -- base ----------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
body {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { color: var(--ink); }
.h-display {
  font-family: var(--font-display);
  font-stretch: 112%;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.08;
}

section { scroll-margin-top: var(--header-h); }

/* Text that sits straight on the network gets a paper-coloured halo,
   like labels on a map or annotations on a plot */
.section-header,
.about-copy,
.hero-main,
.team-group-label {
  text-shadow: 0 0 2px var(--paper), 0 0 6px var(--paper), 0 0 12px var(--paper);
}
.btn, .card, .chip, .venue-cloud span { text-shadow: none; }

.container-narrow {
  width: 100%;
  max-width: calc(1180px + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 0.5rem; left: 0.5rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  border-radius: var(--radius);
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

/* -- background network --------------------------------------- */
#bg-network {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100lvh;            /* stays put while a phone's URL bar slides */
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease;
}
#bg-network.is-ready { opacity: 1; }

/* -- error banner --------------------------------------------- */
.app-error {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--paper);
  text-align: center;
  font-size: 0.9rem;
}

/* -- header --------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
@supports not (background: color-mix(in srgb, red, blue)) {
  .site-header { background: var(--paper); border-bottom-color: var(--border); }
}
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--header-h);
}
.header-tools { display: flex; align-items: center; gap: 0.5rem; }

/* Brand: the wordmark lockup at header size */
.brand-mark {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand-lockup { display: inline-grid; gap: 4px; }
.brand-word {
  font-family: var(--font-display);
  font-stretch: 125%;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.brand-bar {
  display: block;
  height: 3px;
  background: var(--spectrum);
  border-radius: 1px;
}
.brand-mark .brand-sub {
  display: none;
  padding-left: 0.9rem;
  border-left: 1px solid var(--border);
  color: var(--ink-mute);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.01em;
}
@media (min-width: 1400px) {
  .brand-mark .brand-sub { display: inline; }
}

.nav-desktop { display: none; align-items: center; gap: 1.35rem; }
.nav-link {
  position: relative;
  padding: 0.35rem 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: color .2s ease;
}
.nav-link:hover, .nav-link[aria-current="true"] { color: var(--ink); }
.nav-link::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -3px;
  height: 2px;
  background: var(--spectrum);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s cubic-bezier(.2, .7, .2, 1);
}
.nav-link:hover::after, .nav-link[aria-current="true"]::after { transform: scaleX(1); }

/* Segmented toggles (theme, language) */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
}
.lang-toggle button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  min-height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-mute);
  transition: background-color .15s ease, color .15s ease;
}
.lang-toggle button:hover { color: var(--ink); }
.lang-toggle button.is-active { background: var(--ink); color: var(--paper); }

.mobile-menu-btn {
  display: inline-flex;
  flex-shrink: 0;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink-soft);
}
.mobile-menu-btn svg { max-width: none; }   /* the reset would let flex squeeze it to 0 */
.mobile-menu-btn:hover { color: var(--ink); }

#mobile-menu {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--paper);
}
#mobile-menu.is-open {
  display: block;
  max-height: calc(100vh - var(--header-h));
  max-height: calc(100dvh - var(--header-h));   /* reachable in landscape */
  overflow-y: auto;
}
.mobile-menu-list { padding-block: 0.5rem 1rem; }
#mobile-menu a {
  display: block;
  padding: 0.75rem 0.25rem;
  border-bottom: 1px solid var(--border);
  color: var(--ink-soft);
  font-weight: 600;
  text-decoration: none;
}
#mobile-menu a:last-child { border-bottom: 0; }
#mobile-menu a:hover, #mobile-menu a[aria-current="true"] { color: var(--ink); }

@media (min-width: 1000px) {
  .nav-desktop { display: flex; }
  .mobile-menu-btn, #mobile-menu, #mobile-menu.is-open { display: none; }
}
/* With the brand subtitle the row is full (the container stops at 1180px):
   pull the nav towards the tools so the subtitle doesn't read as a link */
@media (min-width: 1400px) {
  .nav-desktop { gap: 1.1rem; margin-left: auto; }
}
/* Narrow phones: tighten the header row so it fits without side-scrolling */
@media (max-width: 379px) {
  .header-bar { gap: 0.5rem; }
  .header-tools { gap: 0.25rem; }
  .lang-toggle button { min-width: 26px; padding: 0 5px; }
  .mobile-menu-btn { padding: 5px; }
}
@media (max-width: 339px) {
  .brand-mark .brand-word { font-size: 0.95rem; }
}

/* -- buttons -------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 46px;
  padding: 0.7rem 1.2rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
}
.btn-primary { background: var(--accent-button); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-button-hover); }
.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
}
.btn-secondary:hover { border-color: var(--ink); }
.btn .arrow { transition: transform .2s ease; }
.btn:hover .arrow { transform: translateX(3px); }

/* -- hero ----------------------------------------------------- */
.hero {
  display: flex;
  align-items: center;
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100svh - var(--header-h));
  padding-block: 4rem 3.5rem;
}
.hero-grid {
  display: grid;
  gap: 3rem;
  align-items: end;
}
@media (min-width: 980px) {
  /* Wide enough for the longest area name (PT or EN) on one line */
  .hero-grid { grid-template-columns: minmax(0, 1fr) 340px; gap: 4rem; }
}

.wordmark { display: block; font-weight: inherit; }
.wordmark-lockup { display: inline-grid; justify-items: stretch; }
.wordmark-word {
  font-family: var(--font-display);
  font-stretch: 125%;
  font-weight: 650;
  font-size: clamp(4rem, 15.5vw, 10.75rem);
  line-height: 0.8;
  letter-spacing: 0.005em;
  color: var(--ink);
}
/* Beside the 340px legend: MALTA is about 4.2em wide, so this keeps it in its column */
@media (min-width: 980px) {
  .wordmark-word { font-size: min(10.75rem, 23.5vw - 109px); }
}
.wordmark-bar {
  display: block;
  height: clamp(9px, 1.05vw, 15px);
  margin-top: clamp(0.85rem, 1.6vw, 1.4rem);
  background: var(--spectrum);
  border-radius: 1px 3px 3px 1px;
  transform-origin: left center;
}
.wordmark-name {
  display: block;
  max-width: 20ch;
  margin-top: clamp(1rem, 2vw, 1.5rem);
  font-family: var(--font-body);
  font-size: clamp(1.3rem, 2.3vw, 1.85rem);
  font-weight: 500;
  line-height: 1.22;
  letter-spacing: -0.005em;
  color: var(--ink);
}
@media (prefers-reduced-motion: no-preference) {
  .wordmark-bar { animation: bar-draw 1.1s cubic-bezier(.2, .7, .2, 1) .2s both; }
  .wordmark-name, .hero-tagline, .hero-ctas, .hero-stats, .hero-legend {
    animation: rise .8s cubic-bezier(.2, .7, .2, 1) both;
  }
  .wordmark-name { animation-delay: .45s; }
  .hero-tagline  { animation-delay: .55s; }
  .hero-ctas     { animation-delay: .65s; }
  .hero-stats    { animation-delay: .75s; }
  .hero-legend   { animation-delay: .9s; }
}
@keyframes bar-draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.hero-tagline {
  max-width: 54ch;
  margin-top: 1.5rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.55;
}
.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}
/* Phones: stacked CTAs of equal width */
@media (max-width: 479px) {
  .hero-ctas { display: grid; }
}
.hero-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 2rem;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
/* Below 980px the rule runs full width, like the legend under it */
@media (min-width: 980px) {
  .hero-stats { max-width: 640px; }
}
.hero-stat-list { display: flex; flex-wrap: wrap; gap: 0.75rem 2rem; }
.hero-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}
.hero-stat strong {
  font-family: var(--font-display);
  font-stretch: 125%;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.kunumi-mark { display: inline-flex; margin-left: auto; opacity: .85; transition: opacity .2s ease; }
.kunumi-mark:hover { opacity: 1; }
.kunumi-mark img { width: auto; height: 32px; }
/* Phones: tighter stats, and Kunumi starts at the left when it wraps */
@media (max-width: 599px) {
  .hero-stats, .hero-stat-list { column-gap: 1.25rem; }
  .kunumi-mark { margin-left: 0; }
}

/* Legend: maps each colour in the background to a research area */
.hero-legend {
  padding: 1rem 1.1rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}
.legend-title {
  margin-bottom: 0.5rem;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.legend-list { margin: 0; padding: 0; list-style: none; }
.legend-list a {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.38rem 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  transition: color .15s ease;
}
.legend-list a:hover, .legend-list a:focus-visible { color: var(--ink); }
/* Centre the swatch on the first line of a wrapped label */
.legend-list .swatch { margin-top: calc((1.3em - 10px) / 2); }
@media (max-width: 979px) {
  .legend-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); column-gap: 1.25rem; }
}
/* Only devices that can hover get the hint */
.legend-hint { display: none; }
@media (hover: hover) {
  .legend-hint {
    display: block;
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border);
    color: var(--ink-mute);
    font-family: var(--font-mono);
    font-size: 0.7rem;
  }
}

/* A cluster colour, with a soft halo like a point in the plot */
.swatch {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--swatch, var(--ink-mute));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--swatch, var(--ink-mute)) 25%, transparent);
  transition: transform .2s ease;
}
[data-cluster]:hover .swatch, [data-cluster]:focus-visible .swatch { transform: scale(1.3); }

/* -- sections ------------------------------------------------- */
.section { padding-block: clamp(4.5rem, 9vw, 7rem); }
.section-header { max-width: 760px; margin-bottom: 3rem; }
.section-header h2 {
  margin-top: 0.75rem;
  font-family: var(--font-display);
  font-stretch: 112%;
  font-size: clamp(2rem, 3.8vw, 2.85rem);
  font-weight: 650;
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.section-header p {
  max-width: 62ch;
  margin-top: 1rem;
  color: var(--ink-soft);
  font-size: 1.1rem;
  line-height: 1.6;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.eyebrow::before {
  content: "";
  width: 18px;
  height: 2px;
  background: currentColor;
}
.eyebrow:empty { display: none; }

/* Home sections are numbered in their eyebrow: "01 — Sobre". The dash
   moves to a background so the number can be the content, and the empty
   alt text (/ "") keeps the decorative number out of the accessible name. */
.hero { counter-reset: home-section; }
.hero ~ .section { counter-increment: home-section; }
.hero ~ .section .eyebrow::before {
  content: counter(home-section, decimal-leading-zero);
  content: counter(home-section, decimal-leading-zero) / "";
  width: auto;
  height: auto;
  padding-right: calc(18px + 0.6rem);
  background: linear-gradient(var(--accent), var(--accent)) right center / 18px 2px no-repeat;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}

/* Panels sit on the network; most of the page is one */
.card {
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* -- about ---------------------------------------------------- */
.about-grid {
  display: grid;
  gap: 2.5rem;
  align-items: start;
}
@media (min-width: 920px) {
  .about-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 4.5rem; }
}
.about-title {
  margin-top: 0.75rem;
  font-size: clamp(1.9rem, 3.4vw, 2.6rem);
  text-wrap: balance;
}
.about-body {
  margin-top: 1.4rem;
  color: var(--ink-soft);
  font-size: 1.1rem;
  line-height: 1.7;
}
.venue-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1.75rem;
}
.venue-cloud span {
  padding: 0.3rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.highlight-list { display: grid; gap: 0.75rem; }
.highlight-list .card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  padding: 1.35rem 1.4rem;
}
/* A neutral rule, not a dot: dots belong to the legend's clusters */
.highlight-list .card .dot {
  width: 16px;
  height: 2px;
  margin-top: 0.65rem;
  background: var(--ink-mute);
}
.highlight-list h3 { font-size: 1.05rem; font-weight: 700; line-height: 1.35; }
.highlight-list p { margin-top: 0.35rem; color: var(--ink-soft); font-size: 0.98rem; line-height: 1.55; }

/* -- research areas ------------------------------------------- */
.research-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}
@media (min-width: 960px) {
  .research-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.research-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.6rem 1.5rem 1.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  scroll-margin-top: calc(var(--header-h) + 1rem);
  transition: border-color .25s ease, box-shadow .25s ease;
}
.research-card::before {
  /* the cluster colour runs along the top edge */
  content: "";
  position: absolute;
  top: -1px; left: -1px; right: -1px;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--swatch);
  transform: scaleX(0.12);
  transform-origin: left;
  transition: transform .4s cubic-bezier(.2, .7, .2, 1);
}
.research-card:hover, .research-card:target { border-color: color-mix(in srgb, var(--swatch) 55%, var(--border)); box-shadow: var(--shadow-2); }
.research-card:hover::before, .research-card:target::before { transform: scaleX(1); }
.research-card .swatch { margin-top: 0.4rem; }
.research-card h3 {
  font-family: var(--font-display);
  font-stretch: 106%;
  font-size: 1.25rem;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.research-card p { color: var(--ink-soft); font-size: 0.97rem; line-height: 1.6; }

/* -- team ----------------------------------------------------- */
.team-group-label {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 3.5rem 0 1.25rem;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.team-group-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.team-group-label.is-first { margin-top: 0; }

.coord-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
}
/* 1, 2 or 4 columns, so 16 postgraduates and 4 undergraduates fill every row */
.student-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 600px) {
  .student-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 860px) {
  .student-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.member-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1.25rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  transition: border-color .25s ease;
}
.member-card:hover { border-color: var(--border-strong); }
.member-info { display: flex; flex-direction: column; align-items: center; flex: 1; width: 100%; }

.member-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 92px;
  height: 92px;
  margin: 6px 6px 1.1rem;
  overflow: hidden;
  border-radius: 50%;
  background: var(--elev-2);
  box-shadow: 0 0 0 1px var(--border), 0 0 0 5px var(--surface-solid), 0 0 0 6px var(--border);
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-stretch: 125%;
  font-size: 1.4rem;
  font-weight: 700;
}
.member-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.member-name { font-size: 1rem; font-weight: 700; line-height: 1.3; color: var(--ink); }
.member-role {
  margin-top: 0.3rem;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.member-topic { margin-top: 0.6rem; color: var(--ink-mute); font-size: 0.86rem; line-height: 1.5; }
.member-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1rem;
  width: 100%;
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
.member-links a {
  padding: 0.2rem 0;
  color: var(--ink-mute);
  text-decoration: none;
  transition: color .15s ease;
}
.member-links a:hover { color: var(--accent-text); text-decoration: underline; text-underline-offset: 0.2em; }

/* Coordinators: photo beside the text */
.member-card.coord {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  column-gap: 1.5rem;
  align-items: start;
  padding: 1.6rem;
  text-align: left;
}
.member-card.coord .member-photo { grid-row: 1 / span 2; width: 120px; height: 120px; margin: 6px; }
.member-card.coord .member-info { align-items: flex-start; }
.member-card.coord .member-name { font-size: 1.2rem; }
.member-card.coord .member-role { color: var(--accent-text, var(--accent)); }
.member-card.coord .member-links { justify-content: flex-start; }
@media (max-width: 479px) {
  .member-card.coord { grid-template-columns: 1fr; text-align: center; }
  .member-card.coord .member-photo { grid-row: auto; justify-self: center; margin: 6px 0 1.25rem; }
  .member-card.coord .member-info { align-items: center; }
  .member-card.coord .member-links { justify-content: center; }
}

/* Phones: students become compact rows, photo beside the text */
@media (max-width: 599px) {
  .student-grid { gap: 0.6rem; }
  .member-card.student {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 0.9rem;
    align-items: start;
    padding: 1rem;
    text-align: left;
  }
  .member-card.student .member-photo {
    grid-row: 1 / span 2;
    width: 64px;
    height: 64px;
    margin: 5px;
    box-shadow: 0 0 0 1px var(--border), 0 0 0 4px var(--surface-solid), 0 0 0 5px var(--border);
    font-size: 1.05rem;
  }
  .member-card.student .member-info { align-items: flex-start; }
  /* No links: centre the text against the photo */
  .member-card.student .member-info:last-child { grid-row: 1 / span 2; align-self: center; }
  .member-card.student .member-role { line-height: 1.4; }
  .member-card.student .member-links {
    grid-column: 2;
    justify-content: flex-start;
    gap: 0 1rem;
    margin-top: 0.6rem;
    padding-top: 0.5rem;
  }
}

/* -- publications --------------------------------------------- */
.pub-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  margin-bottom: 1rem;
  padding: 0.9rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pub-filter-group { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.chip-row { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.pub-filter-group .label {
  margin-right: 0.35rem;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.chip {
  min-height: 30px;
  padding: 0.25rem 0.65rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.chip:hover { border-color: var(--border-strong); color: var(--ink); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.pub-meta {
  color: var(--ink-mute);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

/* One sheet, rows separated by rules, like a bibliography */
.pub-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pub-row {
  position: relative;
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr) auto;
  gap: 1.25rem;
  align-items: start;
  padding: 1.15rem 1.35rem;
  border-top: 1px solid var(--border);
  transition: background-color .15s ease;
}
.pub-row:first-child { border-top: 0; }
.pub-row.is-year-start:not(:first-child) { border-top-color: var(--border-strong); }
.pub-row:hover { background: color-mix(in srgb, var(--elev-1) 70%, transparent); }
.pub-badges { display: flex; flex-direction: column; gap: 0.4rem; align-items: flex-start; }
.pub-badge {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.pub-badge.year {
  font-family: var(--font-display);
  font-stretch: 125%;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}
/* The year prints once per group; repeats stay for screen readers */
.pub-row:not(.is-year-start) .pub-badge.year {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.pub-badge.type-periodico,
.pub-badge.type-conferencia {
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pub-badge.type-periodico { background: var(--accent-soft); color: var(--accent-ink); }
.pub-badge.type-conferencia { border: 1px solid var(--border); color: var(--ink-mute); }
.pub-main h3 { font-size: 1.02rem; font-weight: 700; line-height: 1.4; color: var(--ink); }
.pub-main .authors { margin-top: 0.35rem; color: var(--ink-soft); font-size: 0.88rem; line-height: 1.5; }
.pub-main .source { margin-top: 0.2rem; color: var(--ink-mute); font-size: 0.86rem; font-style: italic; }
.pub-doi {
  align-self: center;
  padding: 0.3rem 0;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
}
.pub-doi:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 0.2em; }

@media (max-width: 720px) {
  .pub-row { grid-template-columns: 1fr; gap: 0.5rem; padding: 1rem; }
  .pub-badges { flex-direction: row; align-items: center; gap: 0.6rem; }
  .pub-doi { justify-self: start; }
}

/* Lab members among the authors */
.pub-main .authors strong { color: var(--ink); font-weight: 700; }
/* "Show all" below the sheet; focus lands on the first row it revealed */
.pub-more { display: flex; justify-content: center; margin-top: 1.25rem; }
.pub-more:empty { display: none; }
.pub-row:focus { outline: none; }
.pub-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* -- news on the home page: a chain of nodes ------------------- */
.news-layout {
  display: grid;
  grid-template-areas: "header" "list" "more";
  gap: 0 4rem;
  align-items: start;
}
@media (min-width: 920px) {
  .news-layout {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.4fr);
    grid-template-areas: "header list" "more list";
    grid-template-rows: auto 1fr;
  }
}
.news-layout .section-header { grid-area: header; }
.news-panel { grid-area: list; padding: 0.5rem 1.75rem 0.5rem 1.5rem; }
.news-list {
  --rail: 2rem;               /* room for the line of nodes */
  position: relative;
  display: grid;
  padding-left: var(--rail);
}
@media (max-width: 599px) {
  .news-panel { padding: 0.25rem 1.1rem 0.25rem 1rem; }
  .news-list { --rail: 1.6rem; }
}
.news-list::before {
  content: "";
  position: absolute;
  top: 1.75rem; bottom: 2rem; left: 5px;
  width: 1px;
  background: var(--border-strong);
}
.news-item {
  position: relative;
  padding: 1.15rem 0 1.4rem;
}
.news-item + .news-item { border-top: 1px solid var(--border); }
.news-item::before {
  content: "";
  position: absolute;
  left: calc(1px - var(--rail));
  top: 1.5rem;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--surface-solid);
  border: 2px solid var(--accent);
}
.news-item:first-child::before { background: var(--accent); }
.news-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}
.news-meta .news-tag {
  color: var(--accent-text);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.news-item h3 {
  margin: 0.4rem 0 0.35rem;
  font-family: var(--font-display);
  font-stretch: 106%;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
@media (max-width: 599px) {
  .news-item h3 { font-size: 1.15rem; }
}
.news-item p { color: var(--ink-soft); line-height: 1.6; }
.news-item .news-title-link { color: inherit; text-decoration: none; }
.news-item .news-title-link:hover { color: var(--accent-text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
.news-item a.news-link {
  display: inline-block;
  margin-top: 0.5rem;
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-decoration: none;
}
.news-item a.news-link:hover { text-decoration: underline; }
.news-more { grid-area: more; display: flex; margin-top: -1rem; }
@media (max-width: 919px) { .news-more { margin-top: 1.25rem; } }
.news-more:empty { display: none; }

/* -- contact -------------------------------------------------- */
.contact-grid { display: grid; gap: 1rem; }
@media (min-width: 820px) {
  .contact-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
}
.contact-block + .contact-block { margin-top: 2rem; }
.contact-block h3,
.contact-cta h3 {
  margin-bottom: 0.5rem;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.contact-block p { color: var(--ink-soft); line-height: 1.6; }
.contact-block a { color: var(--accent-text); font-weight: 700; text-decoration: none; }
.contact-block a:hover { text-decoration: underline; }
.social-links { display: flex; gap: 1.25rem; }

.contact-cta .stack { display: grid; gap: 1.75rem; }
.contact-cta a {
  display: inline-block;
  padding-bottom: 0.25rem;
  font-family: var(--font-display);
  font-stretch: 110%;
  font-size: clamp(1.25rem, 2.6vw, 1.7rem);
  font-weight: 650;
  line-height: 1.2;
  color: var(--ink);
  text-decoration: none;
  overflow-wrap: anywhere;
  border-bottom: 2px solid var(--border-strong);
  transition: color .2s ease, border-color .2s ease;
}
.contact-cta a:hover { color: var(--accent-text); border-bottom-color: var(--accent); }

/* -- footer --------------------------------------------------- */
.site-footer {
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  color: var(--ink-mute);
}
@supports not (background: color-mix(in srgb, red, blue)) {
  .site-footer { background: var(--paper); }
}
.footer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding-block: 2.25rem;
}
.footer-brand { display: flex; align-items: center; gap: 1rem; }
.footer-brand .brand-lockup { flex-shrink: 0; white-space: nowrap; }
.footer-brand .brand-word { font-size: 0.95rem; color: var(--ink); }
.footer-tagline { color: var(--ink-mute); font-size: 0.88rem; }
.footer-meta { font-family: var(--font-mono); font-size: 0.75rem; text-align: right; }
.footer-meta p + p { margin-top: 0.3rem; }
.footer-link {
  color: var(--ink-mute);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 0.25em;
}
.footer-link:hover { color: var(--ink); }
@media (max-width: 640px) {
  .footer-meta { text-align: left; }
}

/* -- focus + misc --------------------------------------------- */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.loading {
  padding: 2rem 1rem;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}
