/* styles.css
   Site-wide rules first, homepage (Direction B / D13) components below. */

/* Tweak heading spacing */
h1, h2, h3 {
  margin-top: 1.4em;
  margin-bottom: 0.6em;
}

/* Make links a bit cleaner: underline-on-hover, not underline-always */
a {
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* Guide 17 / WCAG 1.4.1: a link inside running prose can't rely on color
   alone to be distinguishable from the text around it. Scoped to <main> so
   nav, TOC, and card-title links - already distinguished by position or
   weight, not embedded in a sentence - keep the clean look. */
main p a,
main li a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

/* Better list spacing */
li {
  margin-bottom: 0.3em;
}

/* Guide 16: long DOIs and titles must not overflow their container. */
.publication a,
.hp-meta {
  overflow-wrap: anywhere;
}

/* =========================================================================
   Homepage (index.qmd) — Direction B, editorial/typographic. See D13.
   Custom HTML is confined to index.qmd (guide section 21); these rules only
   ever apply there.
   ========================================================================= */

.hp-wrap {
  max-width: var(--wide-width);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.hp-masthead {
  padding: var(--space-8) 0 var(--space-6);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-6);
}
.hp-masthead .eyebrow { display: block; margin-bottom: var(--space-4); }
.hp-masthead-text { min-width: 0; }

.hp-photo {
  width: 130px;
  height: 173px;
  object-fit: cover;
  border-radius: var(--radius-small);
  flex: none;
  margin-top: var(--space-1);
}

.hp-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(3rem, 9vw, 6.5rem);
  line-height: 0.98;
  letter-spacing: -0.015em;
  margin: 0 0 var(--space-5);
  max-width: 14ch;
}

.hp-standfirst {
  font-family: var(--font-display);
  font-size: 1.375rem;
  line-height: 1.5;
  color: var(--color-text);
  max-width: 30.5rem; /* fixed: ch changes when the webfont swaps in, re-wrapping the text */
  margin: 0 0 var(--space-2);
}

.hp-block { padding: var(--space-7) 0; border-top: 1px solid var(--color-rule); }
.hp-block > .eyebrow { margin: 0 0 var(--space-5); display: block; }

.hp-research-entry { display: grid; grid-template-columns: 3ch 1fr; gap: var(--space-4); margin-bottom: var(--space-6); }
.hp-research-entry:last-child { margin-bottom: 0; }
.hp-research-entry .num { font-family: var(--font-mono); color: var(--color-muted); font-size: 0.85rem; padding-top: 0.3em; }
.hp-research-entry h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.5rem; margin: 0 0 var(--space-2); }
.hp-research-entry h3 a { color: var(--color-text); text-decoration: none; }
.hp-research-entry h3 a:hover { color: var(--color-accent); text-decoration: underline; }
.hp-meta { font-family: var(--font-mono); font-size: 0.8rem; color: var(--color-accent); margin: 0; }

/* Only entries with a cleared CC BY figure (Phase 060) carry a thumbnail -
   most entries are text-only, so this only ever applies to some. */
.hp-research-content { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.hp-research-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-small); flex: none; }

/* Homepage art teaser: same .art-tile/.art-grid the Art page uses (see
   below), just capped to a handful of tiles via markup, not CSS. */
.hp-art-grid { margin-top: var(--space-2); }

.hp-more { text-align: right; margin: var(--space-4) 0 0; }
.hp-more a { font-weight: 600; }


.hp-footer { max-width: var(--wide-width); margin: 0 auto; padding: var(--space-6) var(--space-5) var(--space-8); border-top: 1px solid var(--color-rule); }
.hp-footer .eyebrow { margin: 0; }
.hp-elsewhere { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); font-family: var(--font-mono); font-size: 0.85rem; margin-top: var(--space-4); }
.hp-elsewhere a { color: var(--color-muted); text-decoration: none; }
.hp-elsewhere a:hover { color: var(--color-accent); text-decoration: underline; }

@media (max-width: 640px) {
  .hp-masthead { padding: var(--space-6) 0 var(--space-5); flex-direction: column-reverse; }
  .hp-photo { width: 96px; height: 128px; }
  .hp-research-entry { grid-template-columns: 1fr; }
  .hp-research-entry .num { display: none; }
  .hp-research-thumb { width: 52px; height: 52px; }
}

/* =========================================================================
   Research page (research.qmd). Plain markdown + fenced divs, not raw HTML
   (guide section 21: custom HTML stays confined to the homepage). As of
   Phase 120 the page is title + Publications only - no per-project prose,
   figures, themes, or tools sections; nothing else to style here.
   ========================================================================= */

/* Publications: dense, scannable, no card. One `::: {.publications}` div
   wraps the year-grouped lists; li already reads as a list, which is the
   point (guide 11: "a publication list is a list"). */
.publications li { padding-block: var(--space-3); border-bottom: 1px solid var(--color-rule); overflow: hidden; }
.publications li:last-child { border-bottom: none; }
.publications a { overflow-wrap: anywhere; } /* guide 16: long DOIs */
.publication__type {
  font-family: var(--font-mono); font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-muted);
}

/* Only the two entries with a cleared CC BY figure (Phase 060) carry a
   thumbnail - float it so the citation text wraps beside it, `overflow:
   hidden` above keeps the li's own border-bottom clearing the float. */
.publication-thumb {
  float: left; width: 120px; height: auto;
  margin: 0 var(--space-4) var(--space-2) 0;
  border-radius: var(--radius-small);
}
@media (max-width: 480px) {
  .publication-thumb { width: 80px; }
}

/* =========================================================================
   Art page (art.qmd) and the homepage's art teaser. Phase 130: plain
   uniform grid, no captions - clicking a tile opens the overlay below.
   The grid/tile classes are shared between art.qmd (buttons, open the
   overlay) and index.qmd (plain links to art.qmd, no overlay behavior).
   ========================================================================= */

.art-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
  max-width: var(--wide-width);
  margin-bottom: var(--space-7);
}

.art-tile {
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius-small);
  border: none;
  padding: 0;
  cursor: pointer;
  background: var(--color-rule);
  display: block;
}
.art-tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.15s ease; }
.art-tile:hover img, .art-tile:focus-visible img { transform: scale(1.04); }

/* Overlay: hidden by default, shown by art-gallery.js toggling [hidden]. */
.art-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 1050; /* above Bootstrap's .fixed-top navbar (z-index: 1030) */
}
.art-overlay[hidden] { display: none; }

.art-overlay__panel {
  background: var(--color-bg);
  max-width: min(900px, 90vw);
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-5);
  border-radius: var(--radius-small);
  position: relative;
}
.art-overlay__panel h2 { margin-top: 0; font-family: var(--font-display); }
/* Capped to a fraction of viewport height, not just panel width, so the
   thumbnail strip and links stay visible without scrolling for a typical
   viewport - a tall/portrait image no longer pushes them out of view. */
.art-overlay__main {
  display: block;
  max-width: 100%;
  max-height: 50vh;
  width: auto;
  height: auto;
  margin: 0 auto;
  border-radius: var(--radius-small);
}

.art-overlay__thumbs { display: flex; gap: var(--space-2); overflow-x: auto; margin-top: var(--space-3); }
.art-overlay__thumbs[hidden] { display: none; }
.art-overlay__thumb {
  flex: none; padding: 0; border: none; cursor: pointer; border-radius: var(--radius-small);
  background: var(--color-rule);
}
.art-overlay__thumb img { width: 72px; height: 72px; object-fit: cover; display: block; border-radius: var(--radius-small); }

.art-overlay__links {
  display: flex; gap: var(--space-4); margin-top: var(--space-4);
  font-family: var(--font-mono); font-size: 0.85rem;
}
.art-overlay__links a[hidden] { display: none; }

.art-overlay__close {
  position: absolute; top: var(--space-3); right: var(--space-3);
  font-size: 1.5rem; line-height: 1; background: none; border: none; cursor: pointer;
  color: var(--color-muted);
}
.art-overlay__close:hover { color: var(--color-text); }

@media (max-width: 480px) {
  .art-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--space-2); }
  .art-overlay__panel { padding: var(--space-4); }
}
