/* ==========================================================================
   Angelo Mendes — personal academic website
   Palette: University of Minnesota Maroon (#7A0019) & Gold (#FFCC33)
   ========================================================================== */

:root {
  --maroon: #7a0019;
  --maroon-hover: #a4102c;
  --gold: #ffcc33;

  --accent: var(--maroon);
  --accent-hover: var(--maroon-hover);

  --bg: #ffffff;
  --bg-soft: #faf8f8;
  --text: #1c1c1c;
  --muted: #5f5f5f;
  --rule: #e6e2e2;

  /* One family for the entire site. Change this line to restyle everything.
     Sans alternative: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif —
     remember to update the Google Fonts <link> in each page if you switch. */
  --font: "Source Serif 4", Charter, "Iowan Old Style", Georgia, "Times New Roman", serif;

  --measure: 44rem;

  color-scheme: light dark;
}

/* Dark mode: UMN maroon is unreadable on a dark ground, so the accent moves to
   UMN gold — the official companion color — over a dark gray.

   Three rules, in this order:
     1. system preference, unless the visitor has explicitly chosen light
     2. explicit dark choice (wins over a light system preference)
     3. explicit light choice (pins color-scheme so form controls follow) */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #26262a;
    --bg-soft: #2f2f35;
    --text: #eceae7;
    --muted: #a8a29b;
    --rule: #3d3d43;

    --accent: var(--gold);
    --accent-hover: #ffdd6b;
  }
}

:root[data-theme="dark"] {
    --bg: #26262a;
    --bg-soft: #2f2f35;
    --text: #eceae7;
    --muted: #a8a29b;
    --rule: #3d3d43;

    --accent: var(--gold);
    --accent-hover: #ffdd6b;
  color-scheme: dark;
}

:root[data-theme="light"] { color-scheme: light; }

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
}

/* ---------- Links ---------- */

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  transition: color .15s ease, border-color .15s ease;
}

a:hover {
  color: var(--accent-hover);
  border-bottom-color: var(--accent-hover);
}

/* ---------- Layout ---------- */

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.5rem;
}

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

.masthead {
  border-bottom: 1px solid var(--rule);
  padding: 1.5rem 0;
  margin-bottom: 3rem;
}

.masthead .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem 1.5rem;
  /* Full-width header: name pinned left, nav right, independent of the
     centred body column. */
  max-width: none;
  padding: 0 1.5rem;
}

.masthead__name {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  border: 0;
}

.masthead__name:hover { color: var(--accent); }

.nav {
  display: flex;
  gap: 1.75rem;
  font-size: .9375rem;
  font-weight: 500;
}

.nav a {
  color: var(--muted);
  border: 0;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}

.nav a:hover { color: var(--accent); }

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

/* ---------- Hero / intro (home) ---------- */

/* Photo. Circle when stacked (mobile); a portrait rectangle in the sidebar
   on wider screens (overridden below). */
.hero__photo {
  display: block;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  margin: 0 0 1.5rem;
}

.hero__name {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0 0 .35rem;
  color: var(--accent);
}

.hero__title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
  margin: 0 0 .15rem;
}

.hero__affil {
  font-size: 1rem;
  color: var(--muted);
  margin: 0 0 1.75rem;
}

/* Mobile: one stacked column. The photo and contact live in .side and the
   text in .main; display: contents flattens both so everything stacks in
   reading order, and .contact is ordered last (below the intro). */
.home {
  display: flex;
  flex-direction: column;
}

.home > .side,
.home > .main {
  display: contents;
}

.contact { order: 1; margin-top: 2.5rem; }   /* contact last when stacked */

.contact .section { margin-top: 0; }
.contact .paper__notes { margin-bottom: 0; }

/* Tablet and up: two columns -- photo + contact on the left, text on the
   right, both top-aligned. */
@media (min-width: 34rem) {
  .home {
    display: grid;
    grid-template-columns: 180px 1fr;
    column-gap: 2rem;
    align-items: start;
  }

  .home > .side,
  .home > .main {
    display: block;
  }

  .hero__photo {
    width: 180px;
    height: 225px;
    border-radius: 4px;
    margin: 0;
  }

  .hero__name { font-size: 2rem; }

  /* Contact sits under the photo in the sidebar. */
  .contact { order: 0; margin-top: 2rem; }
}

/* Wide screens: bigger photo, and the whole two-column block is pulled into
   the empty left gutter so the text aligns with the body while the sidebar
   sits to its left. margin-left is clamped to the gutter so it never crosses
   the viewport edge. */
@media (min-width: 62rem) {
  .home {
    grid-template-columns: 240px 1fr;
    column-gap: 2.75rem;
    margin-left: max(-17.75rem, (44rem - 100vw) / 2);
  }

  .hero__photo { width: 240px; height: 300px; }

  .hero__name { font-size: 2.25rem; }
}

/* ---------- Link row (icons/buttons under the bio) ---------- */

.linkrow {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 1.75rem 0 0;
  padding: 0;
  list-style: none;
}

.linkrow a {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .875rem;
  font-weight: 500;
  padding: .4rem .85rem;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 999px;
  color: var(--accent);
  background: transparent;
}

.linkrow svg {
  width: 1.05em;
  height: 1.05em;
  fill: currentColor;
  flex: none;
}

.linkrow a:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* ---------- Typography ---------- */

h1.page-title {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
  margin: 0 0 2.25rem;
}

h2.section {
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 3rem 0 1.5rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--rule);
}

/* Only collapse the gap when the heading directly follows the page title. */
h1.page-title + h2.section { margin-top: 0; }

p { margin: 0 0 1.15rem; }

.lead { font-size: 1.125rem; }

/* ---------- Papers ---------- */

.paper {
  margin: 0 0 2.5rem;
}

.paper:last-child { margin-bottom: 0; }

.paper__title {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 .3rem;
  color: var(--text);
}

.paper__title a { color: var(--text); border-bottom-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.paper__title a:hover { color: var(--accent); }

.paper__meta {
  font-size: .9375rem;
  color: var(--muted);
  margin: 0 0 .7rem;
}

.paper__meta em { font-style: italic; }

.paper__abstract {
  margin: 0 0 .85rem;
  color: var(--text);
}

.paper__notes {
  font-size: .875rem;
  line-height: 1.6;
  color: var(--muted);
  margin: 0;
}

.paper__notes span { display: block; margin-bottom: .2rem; }

.paper__notes b {
  font-weight: 600;
  color: var(--text);
}

.badge {
  display: inline-block;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--accent);
  padding: .2rem .5rem;
  border-radius: 3px;
  vertical-align: 2px;
  margin-right: .5rem;
}

.paper__links,
.course__links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: .7rem 0 0;
  padding: 0;
  list-style: none;
  font-size: .875rem;
  font-weight: 500;
}

/* ---------- Teaching ---------- */

.course {
  margin: 0 0 1.75rem;
  padding-left: 1rem;
  border-left: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.course:last-child { margin-bottom: 0; }

.course__name {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 .2rem;
}

.course__meta {
  font-size: .9375rem;
  color: var(--muted);
  margin: 0;
}

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

.foot {
  margin-top: 4.5rem;
  padding: 1.5rem 0 3rem;
  border-top: 1px solid var(--rule);
  font-size: .8125rem;
  color: var(--muted);
}

.foot a { color: var(--muted); border-bottom-color: var(--rule); }
.foot a:hover { color: var(--accent); }

/* ---------- Responsive ---------- */

@media (max-width: 34rem) {
  body { font-size: 1rem; }

  .masthead { margin-bottom: 2rem; }
  .nav { gap: 1.25rem; }
}

/* ---------- Abstract disclosure ---------- */

.abstract {
  margin: 0 0 .85rem;
}

.abstract > summary {
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .15rem 0;
}

.abstract > summary::-webkit-details-marker { display: none; }

.abstract > summary::before {
  content: "";
  width: 0; height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform .15s ease;
}

.abstract[open] > summary::before { transform: rotate(90deg); }

.abstract > summary:hover { color: var(--accent-hover); }

.abstract > p {
  margin: .6rem 0 0;
  padding-left: .9rem;
  border-left: 2px solid var(--rule);
  color: var(--text);
  font-size: 1rem;
}

/* ---------- Definition-style lists (education, fields) ---------- */

.facts {
  margin: 0;
  padding: 0;
  list-style: none;
}

.facts li {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: .25rem 1rem;
  padding: .45rem 0;
  border-bottom: 1px solid var(--rule);
  font-size: .9375rem;
}

.facts li:last-child { border-bottom: 0; }

.facts .facts__year { color: var(--muted); }

@media (max-width: 34rem) {
  .facts li { grid-template-columns: 1fr; gap: .1rem; }
}

/* ---------- Theme toggle ---------- */

.themetoggle {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  margin: 0;
  padding: .2rem;
  border-radius: 6px;
  line-height: 0;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  transition: color .15s ease;
}

.themetoggle:hover { color: var(--accent); }

.themetoggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.themetoggle svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Show the icon for the theme you would switch TO. */
.themetoggle .sun  { display: none; }
.themetoggle .moon { display: block; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .themetoggle .sun  { display: block; }
  :root:not([data-theme="light"]) .themetoggle .moon { display: none; }
}

:root[data-theme="dark"]  .themetoggle .sun  { display: block; }
:root[data-theme="dark"]  .themetoggle .moon { display: none; }
:root[data-theme="light"] .themetoggle .sun  { display: none; }
:root[data-theme="light"] .themetoggle .moon { display: block; }

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

@media print {
  details:not([open]) > *:not(summary) { display: block; }

  .masthead, .foot { display: none; }
  body { color: #000; background: #fff; font-size: 11pt; }
  a { color: #000; border: 0; }
  .abstract > summary { display: none; }
  .abstract > p { display: block !important; border-left: 0; padding-left: 0; }
}
