/* ==========================================================================
   Alejandro Lancho — site styles
   Palette is pinned to UC3M corporate values. Do not substitute.
   ========================================================================== */

:root {
  /* Colour — the four pinned values, plus two derived neutrals and one accent */
  --blue:    #171790;  /* UC3M primary. Structural elements only.        */
  --ink:     #3a3a3a;  /* Body text. 11.4:1 on white.                    */
  --muted:   #6b6b6b;  /* Secondary text. 5.3:1 on white.                */
  --surface: #ffffff;
  --tint:    #f2f2f9;  /* Quiet section separation.                      */
  --status:  #8a5200;  /* Accent. Publication status flags ONLY. 6.4:1.  */
  --rule:    #dcdce9;  /* Hairlines. Decorative — never the sole cue.    */

  /* Type */
  --font-display: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --step--2: 0.6875rem;
  --step--1: 0.8125rem;
  --step-0:  1rem;
  --step-1:  1.125rem;
  --display: clamp(2.5rem, 6.5vw, 4rem);

  /* Layout */
  --measure: 1080px;
  --gutter: clamp(1.25rem, 5vw, 3rem);
}

/* --------------------------------------------------------------------------
   Self-hosted faces. Run ./fetch-fonts.sh once to populate assets/fonts/.
   Until then the fallback stacks above render the site correctly.
   -------------------------------------------------------------------------- */

@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader-variable.woff2") format("woff2-variations");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Public Sans";
  src: url("../fonts/public-sans-variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------------------
   Reset
   -------------------------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--blue); }

h1, h2, h3 { margin: 0; font-weight: 400; }

ul { margin: 0; padding: 0; list-style: none; }

/* Everything is square. The identity is flat: no radius, no shadow, no gradient. */

/* --------------------------------------------------------------------------
   Shared shell
   -------------------------------------------------------------------------- */

.shell {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.eyebrow {
  font-size: var(--step--2);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--blue);
  margin: 0 0 1.25rem;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10;
  background: var(--blue);
  color: #fff;
  padding: 0.75rem 1.25rem;
  font-size: var(--step--1);
  text-decoration: none;
}

.skip-link:focus { left: 0; }

/* --------------------------------------------------------------------------
   The signature: chaos → network → signal.
   32 nodes carry three sets of coordinates in CSS custom properties;
   one shared keyframe block reads them. No JavaScript.
   -------------------------------------------------------------------------- */

.field {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.field > .shell { position: relative; z-index: 1; }

.field__plot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.field__plot circle {
  fill: var(--blue);
  opacity: 0;
  animation: pass 26s ease-in-out infinite;
}

.field__plot line {
  stroke: var(--blue);
  stroke-width: 1;
  opacity: 0;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: wire 26s ease-in-out infinite;
}

@keyframes pass {
  0%        { transform: translate(var(--sx), var(--sy)); opacity: 0; }
  8%        { opacity: var(--o); }
  26%, 50%  { transform: translate(0, 0); opacity: var(--o); }
  62%, 80%  { transform: translate(var(--wx), var(--wy)); opacity: var(--o); }
  92%, 100% { transform: translate(var(--ex), var(--ey)); opacity: 0; }
}

/* Wiring exists only while the network does, and clears before the morph. */
@keyframes wire {
  0%, 24%   { stroke-dashoffset: 1; opacity: 0; }
  30%       { opacity: var(--eo); }
  36%, 44%  { stroke-dashoffset: 0; opacity: var(--eo); }
  50%, 100% { stroke-dashoffset: 1; opacity: 0; }
}

/* --------------------------------------------------------------------------
   Masthead
   -------------------------------------------------------------------------- */

.masthead {
  border-bottom: 2px solid var(--blue);
}

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: 0.875rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  color: var(--ink);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.wordmark svg { width: 21px; height: 21px; flex: none; color: var(--blue); }

.nav {
  display: flex;
  gap: clamp(1rem, 3vw, 2rem);
  font-size: var(--step--1);
}

.nav a {
  color: var(--ink);
  text-decoration: none;
  padding-bottom: 3px;
  border-bottom: 2px solid transparent;
}

.nav a:hover,
.nav a:focus-visible { border-bottom-color: var(--blue); }

.nav a[aria-current="page"] {
  border-bottom-color: var(--blue);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */

.hero__inner {
  display: grid;
  grid-template-columns: minmax(0, 230px) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 2.75rem);
  align-items: start;
  padding-block: clamp(1.75rem, 3.5vw, 2.5rem) clamp(1.25rem, 2.5vw, 1.75rem);
}

.hero__portrait {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

.hero__name {
  font-family: var(--font-display);
  font-size: var(--display);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.02em;
  margin: 0;
}

/* Headline slot. Uncomment the <p class="hero__lede"> in index.html to use. */
.hero__lede {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.4vw, 1.6rem);
  line-height: 1.34;
  font-weight: 400;
  margin: 1.5rem 0 0;
  max-width: 34ch;
}

.hero__name + .hero__role { margin-top: 1.25rem; }

.hero__role {
  font-size: var(--step-0);
  line-height: 1.7;
  margin: 0;
}

.hero__role strong { font-weight: 700; }

.hero__role a { color: var(--ink); text-decoration-color: var(--rule); }

.hero__role a:hover { text-decoration-color: var(--blue); }

.hero__role .subtle { color: var(--muted); }

/* --------------------------------------------------------------------------
   Profile links
   -------------------------------------------------------------------------- */

.profiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.125rem;
  margin-top: 1.375rem;
}

.profiles a {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  font-size: var(--step--1);
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
}

.profiles a:hover,
.profiles a:focus-visible { border-bottom-color: var(--blue); }

.profiles svg {
  width: 17px;
  height: 17px;
  flex: none;
  color: var(--blue);
}

/* --------------------------------------------------------------------------
   Short bio
   -------------------------------------------------------------------------- */

.bio__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
  padding-bottom: clamp(2rem, 4vw, 3rem);
}

/* The animation sits beside the prose, never behind it.
   Aligned to the top of the text, not centred against it. */
.bio__figure {
  position: relative;
  aspect-ratio: 4 / 3;
  width: 100%;
  margin-top: -0.75rem;
}

.bio__figure .field__plot { position: absolute; inset: 0; }

.bio p {
  margin: 0 0 0.875rem;
  max-width: 60ch;
}

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

.honors {
  display: grid;
  gap: 0.5rem;
  margin-top: 1.5rem;
  max-width: 60ch;
}

.honors li {
  display: flex;
  align-items: flex-start;
  gap: 0.5625rem;
  font-size: var(--step--1);
  line-height: 1.5;
}

.honors svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 2px;
  color: var(--blue);
}

.honors .where { color: var(--muted); }

/* --------------------------------------------------------------------------
   Research
   -------------------------------------------------------------------------- */

.research { background: var(--tint); }

.research__inner { padding-block: clamp(2.5rem, 5vw, 3.5rem); }

.research__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: clamp(1.75rem, 4vw, 2.75rem);
}

.area h3 {
  font-size: var(--step-1);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.375rem;
}

.area p {
  margin: 0;
  font-size: var(--step--1);
  color: var(--muted);
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Selected work — one line per publication, same grammar as /publications/
   -------------------------------------------------------------------------- */

.selected__inner { padding-block: clamp(2.5rem, 5vw, 3.5rem); }

.selected__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.selected__head .eyebrow { margin-bottom: 1.25rem; }

.more {
  font-size: var(--step--1);
  color: var(--blue);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.more:hover,
.more:focus-visible { border-bottom-color: var(--blue); }

.pubs { border-top: 1px solid var(--rule); }

.pub {
  display: flex;
  align-items: baseline;
  gap: 0.875rem;
  padding-block: 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.pub__year {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--muted);
  flex: none;
  width: 3.25rem;
  font-variant-numeric: tabular-nums;
}

.pub__body {
  flex: 1 1 auto;
  min-width: 0;
}

.pub__title {
  display: block;
  color: var(--ink);
  text-decoration: none;
  font-size: var(--step-0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pub__title:hover,
.pub__title:focus-visible { text-decoration: underline; text-decoration-color: var(--blue); }

.pub__meta {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex: none;
}

.pub__venue {
  font-size: var(--step--1);
  color: var(--muted);
  white-space: nowrap;
}

.pub__status {
  font-size: var(--step--2);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--status);
  white-space: nowrap;
}

.pub__links {
  display: flex;
  gap: 0.625rem;
  flex: none;
}

.pub__links a {
  display: inline-flex;
  color: var(--blue);
  padding: 2px;
}

.pub__links svg { width: 17px; height: 17px; }

.pub__links a:hover { color: var(--ink); }

/* --------------------------------------------------------------------------
   Publications page
   -------------------------------------------------------------------------- */

.page-head { padding-block: clamp(2.25rem, 5vw, 3.5rem) 0; }

.page-head h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.page-head__note {
  margin: 0;
  color: var(--muted);
  font-size: var(--step--1);
  max-width: 60ch;
}

/* Section jump links — plain anchors, no script */
.jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-top: 1.5rem;
  padding-bottom: 1.5rem;
  font-size: var(--step--1);
  border-bottom: 1px solid var(--rule);
}

.jump a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
}

.jump a:hover,
.jump a:focus-visible { border-bottom-color: var(--blue); }

.jump .count {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: var(--step--2);
  margin-left: 0.3125rem;
}

/* Icon legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--rule);
  font-size: var(--step--2);
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.legend svg { width: 15px; height: 15px; color: var(--blue); }

/* Section heading + count mark */
.pub-section { padding-top: clamp(2rem, 4vw, 3rem); }

.pub-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem 2rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding-bottom: 0.625rem;
  border-bottom: 2px solid var(--blue);
}

.pub-section h2 {
  font-family: var(--font-display);
  font-size: clamp(1.375rem, 2.6vw, 1.75rem);
  letter-spacing: -0.01em;
  scroll-margin-top: 1.5rem;
}

.pub-section__count {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Entries — two rows: title line, then authors */
.pub-list { border-top: 1px solid var(--rule); }

.pub-item {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr) auto;
  grid-template-areas:
    "year title meta"
    "year authors authors";
  column-gap: 0.875rem;
  row-gap: 0.1875rem;
  padding-block: 0.8125rem;
  border-bottom: 1px solid var(--rule);
}

.pub-item__year {
  grid-area: year;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--blue);
  font-variant-numeric: tabular-nums;
  line-height: 1.7;
}

.pub-item--same-year .pub-item__year { visibility: hidden; }

.pub-item__title {
  grid-area: title;
  font-size: var(--step-0);
  line-height: 1.45;
  color: var(--ink);
}

.pub-item__meta {
  grid-area: meta;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  white-space: nowrap;
  padding-top: 0.125rem;
}

.pub-item__venue {
  font-size: var(--step--1);
  color: var(--muted);
}

.pub-item__status {
  font-size: var(--step--2);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--status);
}

.pub-item__authors {
  grid-area: authors;
  font-size: var(--step--1);
  color: var(--muted);
  line-height: 1.5;
}

.pub-item__authors b {
  font-weight: 700;
  color: var(--ink);
}

.pub-item__links {
  display: inline-flex;
  gap: 0.5rem;
  vertical-align: -3px;
  margin-left: 0.25rem;
}

.pub-item__links a {
  display: inline-flex;
  color: var(--blue);
  padding: 1px;
}

.pub-item__links svg { width: 16px; height: 16px; }

.pub-item__links a:hover { color: var(--status); }

.pub-item__award {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  font-size: var(--step--1);
  color: var(--status);
  margin-left: 0.5rem;
}

.pub-item__award svg { width: 15px; height: 15px; }

@media (max-width: 720px) {
  .pub-item {
    grid-template-columns: 3.25rem minmax(0, 1fr);
    grid-template-areas:
      "year title"
      "year authors"
      "year meta";
    row-gap: 0.3125rem;
  }

  .pub-item__meta {
    white-space: normal;
    flex-wrap: wrap;
    padding-top: 0;
  }
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.footer {
  border-top: 2px solid var(--blue);
  margin-top: clamp(1rem, 4vw, 2rem);
}

.footer__inner {
  display: flex;
  justify-content: space-between;
  gap: 1rem 2rem;
  flex-wrap: wrap;
  padding-block: 1.75rem 2.5rem;
  font-size: var(--step--1);
  color: var(--muted);
}

.footer a { color: var(--muted); text-decoration-color: var(--rule); }

.footer a:hover { color: var(--blue); }

/* --------------------------------------------------------------------------
   Focus — always visible, never removed
   -------------------------------------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Narrow viewports
   -------------------------------------------------------------------------- */

@media (max-width: 860px) {
  .bio__inner { grid-template-columns: 1fr; }
  .bio__figure { aspect-ratio: 3 / 2; max-width: 520px; margin-top: 0.5rem; }
}

@media (max-width: 720px) {
  .hero__inner {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .hero__portrait { max-width: 200px; }

  /* The one-line rule is a desktop rule. Entries may wrap here. */
  .pub {
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
  }

  .pub__body { flex-basis: calc(100% - 4.125rem); }

  .pub__title { white-space: normal; }

  .pub__meta { margin-left: 4.125rem; }

  .pub__links { margin-left: auto; }
}

@media (max-width: 420px) {
  .pub__meta,
  .pub__links { margin-left: 4.125rem; }
}

/* --------------------------------------------------------------------------
   Motion — one orchestrated moment on load, and nothing else
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .field__plot circle {
    animation: none;
    opacity: var(--o);
    transform: translate(var(--wx), var(--wy));
  }
  .field__plot line { animation: none; opacity: 0; }
}

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */

@media print {
  .masthead, .footer, .profiles { display: none; }
  body { color: #000; }
  .research { background: none; }
}

/* Deep links from the home page honors list */
.pub-item[id] { scroll-margin-top: 1.5rem; }

.pub-item:target {
  background: var(--tint);
  box-shadow: -0.75rem 0 0 var(--tint), 0.75rem 0 0 var(--tint);
}

.bio a { color: var(--ink); text-decoration-color: var(--rule); }
.bio a:hover { text-decoration-color: var(--blue); }
.honors a { color: var(--ink); text-decoration-color: var(--rule); }
.honors a:hover { text-decoration-color: var(--blue); }
