/* ==========================================================================
   Arturo M. Flores Alvarez — personal research page
   Palette and type deliberately mirror the CV (charter serif, navy accent)
   so the page and the PDF read as one identity.
   ========================================================================== */

:root {
  --accent:      #1f3a5f;   /* CV \definecolor{accent}  */
  --link:        #2a5db0;   /* CV \definecolor{linkcol} */
  --ink:         #1a1a1a;
  --ink-soft:    #4a4f57;
  --ink-faint:   #767b83;
  --rule:        #dcdfe4;
  --rule-soft:   #ebedf0;
  --bg:          #ffffff;
  --bg-sunk:     #f7f8f9;

  --serif: "Source Serif 4", Charter, "Bitstream Charter", Georgia, serif;
  --sans:  "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  --measure: 860px;
  --gutter:  24px;

  /* platform chart geometry — heights are set as a % of --plot-h in JS,
     so changing these two values rescales the whole chart */
  --plot-h:   300px;
  --plot-pad: 46px;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }

a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid rgba(42, 93, 176, 0.28);
}
a:hover { border-bottom-color: var(--link); }
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 12px; top: 12px;
  z-index: 50;
  background: var(--bg);
  padding: 8px 14px;
  border: 1px solid var(--accent);
}

/* ---------- top navigation ---------- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--rule-soft);
}

.topnav-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 11px var(--gutter);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
}

.topnav-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent);
  white-space: nowrap;
}

.topnav ul {
  list-style: none;
  display: flex;
  gap: 20px;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.topnav a {
  font-size: 0.86rem;
  color: var(--ink-soft);
  border-bottom: none;
  letter-spacing: 0.01em;
}
.topnav a:hover { color: var(--accent); }

/* ---------- layout ---------- */
main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

section {
  padding: 40px 0;
  border-top: 1px solid var(--rule-soft);
}
section:first-of-type { border-top: none; }

/* section headings echo the CV's small-caps rule */
h2 {
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 700;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin: 0 0 6px;
  padding-bottom: 5px;
  border-bottom: 1.5px solid var(--accent);
}

h3 {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  margin: 26px 0 8px;
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

/* Full measure, not 62ch — the narrow cap made this read as a column sitting
   in a wide empty space rather than as ordinary prose above the chart. */
.section-note {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin: 12px 0 22px;
}

.footnote {
  font-size: 0.82rem;
  color: var(--ink-faint);
  margin: 6px 0 0;
}

.muted { color: var(--ink-faint); }

/* ---------- masthead ---------- */
.masthead {
  display: flex;
  gap: 30px;
  align-items: flex-start;
  padding: 44px 0 30px;
}

.portrait {
  width: 212px;
  height: 212px;
  flex: none;
  object-fit: cover;
  border-radius: 3px;
}

.masthead-text { min-width: 0; padding-top: 4px; }

h1 {
  font-family: var(--serif);
  font-size: 2.05rem;
  font-weight: 700;
  line-height: 1.14;
  letter-spacing: -0.012em;
  color: var(--accent);
  margin: 0 0 10px;
}

.standfirst {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 18px;
}

/* One row under the title. It wrapped badly before because the labels were
   long ("Google Scholar", "Curriculum Vitae"), not because the row was wrong;
   short labels fit on a single line and keep the masthead compact. */
.contact {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  font-size: 0.92rem;
}
.contact li { white-space: nowrap; }
.contact li:not(:last-child)::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: 0.8em;
  background: var(--rule);
  margin: 0 12px;
  vertical-align: -0.05em;
}
.contact a { border-bottom: none; }
.contact a:hover { text-decoration: underline; }


/* ---------- the platform lineup ---------- */
.lineup-wrap {
  position: relative;
  padding-left: var(--plot-pad);
  margin-bottom: 26px;
}

.lineup {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: var(--plot-h);   /* the tallest robot, 1.78 m, maps to this */
  overflow: visible;
}

/* horizontal gridlines at 1.8 m and 1 m */
.lineup::before,
.lineup::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  border-top: 1px dashed var(--rule);
  pointer-events: none;
}
.lineup::before { top: 0; }
.lineup::after  { top: calc(var(--plot-h) - (var(--plot-h) / 1.78)); }

.lineup-baseline {
  height: 0;
  border-top: 1.5px solid var(--accent);
  /* no margin-left: .lineup-wrap's padding already provides the axis gutter.
     Adding it here too shifted the baseline and labels 46px right of the
     robots — worst at the left end, nearly invisible at the right. */
}

.lineup-scale {
  position: absolute;
  left: 0; top: 0;
  width: calc(var(--plot-pad) - 4px);
  height: var(--plot-h);
  font-size: 0.68rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.lineup-scale span {
  position: absolute;
  right: 0;
  text-align: right;
  white-space: nowrap;
  transform: translateY(-50%);
}
.lineup-scale span:nth-child(1) { top: var(--plot-h); }
.lineup-scale span:nth-child(2) { top: calc(var(--plot-h) - (var(--plot-h) / 1.78)); }
.lineup-scale span:nth-child(3) { top: 0; }

/* Equal-width columns, matching .robot-label exactly, so every silhouette is
   centred over its own name. (They previously used different flex rules, which
   put each robot slightly off its label — most visible on the tiny MiNI-Q.) */
.robot {
  appearance: none;
  background: none;
  border: none;
  padding: 0 2px;
  margin: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  flex: 1 1 0;
  min-width: 38px;
  height: 100%;            /* gives the % heights below a definite basis */
  font-family: inherit;
}

/* Every robot is a flat silhouette so the row reads as one diagram rather than
   a collage of mismatched photography. Selection is tonal, not chromatic —
   the real photograph appears in the detail panel instead. */
.robot img {
  display: block;
  width: auto;
  /* max-width must stay unset: the global img{max-width:100%} capped the width
     to the column, and object-fit then letterboxed the robot — which drew the
     1.78 m H1-2 22% shorter than its true height and broke the whole premise
     of the chart. Height alone governs; widths still total less than the row. */
  max-width: none;
  object-fit: contain;
  object-position: bottom center;
  filter: brightness(0) opacity(0.3);
  transition: filter 180ms ease;
}

.robot:hover img { filter: brightness(0) opacity(0.55); }

.robot[aria-selected="true"] img { filter: brightness(0) opacity(0.92); }

.robot .tick {
  display: block;
  width: 1px;
  height: 7px;
  background: var(--rule);
  margin-top: 0;
}

.robot-labels {
  display: flex;
  gap: 4px;
  padding-top: 7px;
}

.robot-label {
  flex: 1 1 0;
  min-width: 38px;
  text-align: center;
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--ink-faint);
  cursor: pointer;
}
.robot-label b {
  display: block;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.robot-label .lh { font-variant-numeric: tabular-nums; }
.robot-label .ly::before { content: " · "; }
.robot-label[data-selected="true"] b { color: var(--accent); }
.robot-label[data-selected="true"] { color: var(--ink-soft); }

/* detail panel */
.platform-detail {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  background: var(--bg-sunk);
  padding: 18px 22px;
  min-height: 150px;
}

/* Fixed box, robot centred inside it. The photo used to be bottom-aligned,
   which left a wide, short robot (MiNI-Q is 420x298) sitting well below its
   own heading. A fixed box also stops the panel jumping as you switch robots. */
.detail-photo {
  flex: none;
  width: 116px;
  height: 136px;
  object-fit: contain;
  object-position: center;
  align-self: center;
}

.detail-body { min-width: 0; }

.platform-detail h4 {
  font-family: var(--serif);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 2px;
}

.platform-detail .prov {
  color: #8a5a00;
  font-style: italic;
}

.platform-detail .meta {
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin: 0 0 10px;
}

.platform-detail p { font-size: 0.95rem; margin: 0; }

.badges {
  display: flex;
  gap: 7px;
  margin: 0 0 10px;
  flex-wrap: wrap;
}
.badge {
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 2px 8px;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 2px;
}
.badge.award {
  border-color: #9a7b28;
  color: #7d631d;
}

.platform-fallback { padding-left: 18px; }
.platform-fallback li { margin-bottom: 10px; }

/* ---------- news ---------- */
.news, .awards {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}

.news li, .awards li {
  display: flex;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px solid var(--rule-soft);
  font-size: 0.95rem;
}
.news li:last-child, .awards li:last-child { border-bottom: none; }

.when {
  flex: none;
  width: 84px;
  color: var(--ink-faint);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}

/* the row has exactly two flex children; inline markup inside .what must not
   become a flex item of its own (that was adding stray gaps around <strong>) */
.what { flex: 1 1 auto; min-width: 0; }

.news li.extra { display: none; }
.news.open li.extra { display: flex; }

.morebtn {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(42, 93, 176, 0.3);
  color: var(--link);
  font: inherit;
  font-size: 0.88rem;
  padding: 0;
  margin-top: 14px;
  cursor: pointer;
}
.morebtn:hover { border-bottom-color: var(--link); }

/* ---------- publications ---------- */
.pubs {
  margin: 0;
  padding-left: 1.35em;
}
.pubs li {
  margin-bottom: 11px;
  font-size: 0.95rem;
  line-height: 1.55;
}
.pubs li::marker { color: var(--ink-faint); font-size: 0.85em; }

.venue {
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-style: italic;
}
/* venue + any link share one line below the title */
.pubs li .venue { display: inline; }
.pubs li .venue::before { content: "\A"; white-space: pre; }

.award {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #7d631d;
  border: 1px solid #c9ab5e;
  background: #fdf8ec;
  border-radius: 2px;
  padding: 0 6px;
  margin-right: 4px;
  vertical-align: 1px;
}

/* ---------- press ---------- */
.press {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}
.press li {
  padding: 9px 0;
  border-bottom: 1px solid var(--rule-soft);
  font-size: 0.95rem;
}
.press li:last-child { border-bottom: none; }
.press .translation {
  display: block;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.press .venue { display: block; font-size: 0.84rem; color: var(--ink-faint); }

/* ---------- bio expander ---------- */
.more[hidden] { display: none; }
.more p:first-child { margin-top: 4px; }
/* the global p:last-child{margin-bottom:0} zeroed this, so the expanded text
   collided with the closing paragraph that follows the block */
.more p:last-child { margin-bottom: 1em; }

#bio-more-btn { margin: 4px 0 14px; }

/* ---------- media ---------- */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 26px;
  margin-top: 18px;
}
.media-grid figure { margin: 0; }

.embed {
  position: relative;
  padding-top: 56.25%;
  background: var(--bg-sunk);
  border: 1px solid var(--rule);
}
.embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

figcaption {
  font-size: 0.86rem;
  color: var(--ink-soft);
  margin-top: 8px;
}

/* ---------- footer ---------- */
footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 26px var(--gutter) 52px;
  border-top: 1px solid var(--rule-soft);
  font-size: 0.88rem;
  color: var(--ink-soft);
}
footer p { margin: 0 0 4px; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  body { font-size: 16px; }

  .topnav-inner { flex-direction: column; align-items: flex-start; gap: 7px; }
  .topnav ul { gap: 14px; }

  .masthead {
    flex-direction: column;
    gap: 22px;
    padding: 30px 0 28px;
  }
  .portrait { width: 168px; height: 168px; }
  h1 { font-size: 1.68rem; }

  /* The chart shrinks to fit rather than scrolling: the whole point is seeing
     every robot against every other one at once. True scale is preserved —
     only the mapping from metres to pixels changes. */
  /* Chart must fit the viewport without scrolling — seeing every robot against
     every other one at once is the point. Total silhouette width scales with
     --plot-h, so this is the largest value that fits a 390 px screen. */
  :root { --plot-h: 146px; --plot-pad: 26px; }

  .lineup { gap: 2px; }
  .robot { min-width: 26px; padding: 0; }
  .robot-labels { gap: 2px; }
  .robot-label { min-width: 26px; font-size: 0.6rem; line-height: 1.25; }
  .robot-label b { font-size: 0.66rem; }
  .robot-label .ly { display: none; }  /* year stays available in the detail panel */
  .lineup-scale { font-size: 0.58rem; }

  .platform-detail { flex-direction: column; gap: 14px; padding: 16px; }
  .detail-photo { width: 92px; height: 104px; align-self: center; }

  .news li, .awards li { flex-direction: column; gap: 1px; }
  .when { width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  .topnav, .morebtn, .embed { display: none; }
  body { font-size: 11pt; }
  .news li.extra { display: flex; }
}
