/* =============================================================================
   Matthew G. Perich — personal site
   Clean academic light theme. No framework; just modern CSS.
   Colors and spacing are driven by the custom properties in :root below —
   change those to re-skin the whole site.
   ========================================================================== */

:root {
  /* Palette (teal/navy pulled from the brain figure) */
  --bg:          #ffffff;
  --bg-alt:      #f4f7f7;   /* alternating section background */
  --bg-tint:     #eef3f3;   /* figure/media backdrop */
  --ink:         #1b2227;   /* primary text */
  --ink-soft:    #44505a;   /* secondary text */
  --ink-muted:   #6b7780;   /* tertiary / meta text */
  --accent:      #0e6e78;   /* deep teal */
  --accent-deep: #0a525a;   /* hover / darker teal */
  --navy:        #1b2a4a;   /* deep navy for contrast */
  --line:        #e4e9ea;   /* hairlines / borders */
  --line-soft:   #eef1f2;

  /* Type */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;

  /* Layout */
  --maxw: 1080px;
  --pad: clamp(1.1rem, 4vw, 2.5rem);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 28, .04), 0 8px 24px rgba(16, 24, 28, .06);
  --shadow-hover: 0 2px 4px rgba(16, 24, 28, .06), 0 14px 36px rgba(16, 24, 28, .10);
}

/* ------------------------------- Reset ---------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

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

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

a { color: var(--accent); text-decoration: none; transition: color .15s ease; }
a:hover, a:focus-visible { color: var(--accent-deep); }

h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 600; }

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

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--accent); color: #fff; padding: .6rem 1rem; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; color: #fff; }

/* ----------------------------- Navigation -------------------------------- */
.site-nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-nav__inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad);
  height: 62px; display: flex; align-items: center; justify-content: space-between;
}
.site-nav__brand {
  font-weight: 700; font-size: 1.02rem; letter-spacing: .01em; color: var(--ink);
}
.site-nav__brand:hover { color: var(--accent); }

.site-nav__menu { display: flex; align-items: center; gap: clamp(1rem, 2.4vw, 1.9rem); }
.site-nav__menu > a {
  color: var(--ink-soft); font-weight: 500; font-size: .95rem; position: relative; padding: .2rem 0;
}
.site-nav__menu > a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .18s ease;
}
.site-nav__menu > a:hover, .site-nav__menu > a.is-active { color: var(--ink); }
.site-nav__menu > a:hover::after, .site-nav__menu > a.is-active::after { transform: scaleX(1); }

.site-nav__social { display: inline-flex; align-items: center; gap: .65rem; }
.site-nav__social a { display: inline-flex; color: var(--ink-muted); }
.site-nav__social a:hover { color: var(--accent); }
.site-nav__social svg { width: 19px; height: 19px; display: block; }

.site-nav__toggle {
  display: none; background: none; border: 0; cursor: pointer; padding: 8px; margin-right: -8px;
}
.site-nav__toggle span {
  display: block; width: 22px; height: 2px; background: var(--ink); border-radius: 2px;
  transition: transform .2s ease, opacity .2s ease;
}
.site-nav__toggle span + span { margin-top: 5px; }
.site-nav.is-open .site-nav__toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.site-nav.is-open .site-nav__toggle span:nth-child(2) { opacity: 0; }
.site-nav.is-open .site-nav__toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* -------------------------------- Hero ----------------------------------- */
.hero { max-width: var(--maxw); margin: 0 auto; padding: clamp(2.4rem, 6vw, 4.5rem) var(--pad) clamp(2rem, 5vw, 3.5rem); }
.hero__inner {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: clamp(1.5rem, 5vw, 3.5rem); align-items: center;
}
.hero__intro { min-width: 0; }
.hero__photo {
  width: 132px; height: 132px; border-radius: 50%; object-fit: cover;
  border: 4px solid #fff; box-shadow: var(--shadow); margin-bottom: 1.4rem;
}
.hero__name {
  font-family: var(--font-serif); font-weight: 600; letter-spacing: -.01em;
  font-size: clamp(1.65rem, 4vw, 2.45rem); color: var(--ink); margin-bottom: .9rem;
  white-space: nowrap;
}
.hero__positions { display: flex; flex-direction: column; gap: .6rem; }
.hero__position { color: var(--ink-soft); font-size: 1.06rem; line-height: 1.4; }
.hero__position b { display: block; color: var(--ink); font-weight: 600; }
.hero__position .detail { color: var(--ink-soft); }
.hero__position .detail a { color: var(--accent); font-weight: 500; }
.hero__position .detail a:hover { color: var(--accent-deep); text-decoration: underline; }
.hero__tagline {
  margin: 1.3rem 0 1.6rem; font-size: 1.18rem; line-height: 1.55; color: var(--ink);
  padding-left: 1rem; border-left: 3px solid var(--accent); max-width: 34ch;
}
.hero__links { display: flex; flex-wrap: wrap; gap: .65rem; }
.hero__links-break { flex-basis: 100%; height: 0; }

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .55rem 1rem; border-radius: 999px; font-size: .92rem; font-weight: 500;
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  transition: border-color .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover {
  color: var(--accent); border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow);
}
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: #fff; }

.hero__media { min-width: 0; }
.hero__media figure {
  margin: 0; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); background: var(--navy); aspect-ratio: 16 / 10;
}
.hero__media img { width: 100%; height: 100%; object-fit: cover; }

/* ------------------------------ Sections --------------------------------- */
.section { padding: clamp(2.6rem, 6vw, 4.4rem) 0; }
.section--alt { background: var(--bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section__inner { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad); }
.section__head { margin-bottom: clamp(1.6rem, 4vw, 2.4rem); }
.section__title {
  font-size: clamp(1.5rem, 3.4vw, 2rem); letter-spacing: -.01em; color: var(--ink);
  display: inline-block; padding-bottom: .5rem; position: relative;
}
.section__title::after {
  content: ""; position: absolute; left: 0; bottom: 0; width: 48px; height: 3px;
  background: var(--accent); border-radius: 3px;
}
.section__intro { margin: 1rem 0 0; color: var(--ink-soft); font-size: 1.06rem; max-width: 62ch; }

/* --------------------------- Research cards ------------------------------ */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: clamp(1rem, 2.6vw, 1.6rem); }
.card {
  display: flex; flex-direction: column; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: #d6dee0; }
.card__media {
  display: block; background: var(--bg-tint); padding: 1rem; height: 188px;
  display: flex; align-items: center; justify-content: center;
}
.card__media img { max-height: 100%; width: auto; object-fit: contain; }
.card__body { padding: 1.15rem 1.25rem 1.35rem; display: flex; flex-direction: column; gap: .5rem; }
.card__meta { font-size: .82rem; color: var(--ink-muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 500; }
.card__meta b { color: var(--accent); font-weight: 600; }
.card__title { font-size: 1.08rem; line-height: 1.32; font-weight: 600; }
.card__title a { color: var(--ink); }
.card__title a:hover { color: var(--accent); }
.card__blurb { margin: 0; color: var(--ink-soft); font-size: .96rem; }
.chip {
  align-self: flex-start; margin-top: .2rem; display: inline-flex; align-items: center; gap: .4rem;
  white-space: nowrap;
  font-size: .82rem; font-weight: 500; color: var(--accent);
  background: var(--bg-tint); border: 1px solid var(--line); padding: .28rem .7rem; border-radius: 999px;
}
.chip svg { width: 15px; height: 15px; flex: 0 0 auto; }
.chip:hover { background: #e4ecec; color: var(--accent-deep); }

/* Link shown after the research cards (full publication list) */
.section__cta { margin-top: 1.8rem; }

/* Small uppercase sub-label (used for the "Talks" / "Press" groups in Media) */
.cv-block__label {
  font-size: .82rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 600;
  color: var(--ink-muted); margin-bottom: 1.1rem;
}

/* ------------------------------- Media ----------------------------------- */
.media-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(1.6rem, 4vw, 3rem); align-items: start; }
.media-item { padding: .9rem 0; border-top: 1px solid var(--line); }
.media-item:first-of-type { border-top: 0; }
.media-item__head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; flex-wrap: wrap; }
.media-item__title { font-weight: 600; color: var(--ink); font-size: 1rem; line-height: 1.35; }
.media-item__date { color: var(--ink-muted); font-size: .85rem; white-space: nowrap; }
.media-item__venue { color: var(--ink-soft); font-style: italic; font-size: .92rem; margin-top: .2rem; }
.media-item__link { display: inline-block; margin-top: .35rem; font-size: .9rem; font-weight: 500; }
.media-item__link::before { content: "▶ "; font-size: .8em; }
.press-item__title { font-weight: 600; }
.press-item__meta { color: var(--ink-muted); font-size: .9rem; margin-top: .1rem; }

/* ------------------------------- Footer ---------------------------------- */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-alt); padding: 1.8rem 0; margin-top: 0; }
.site-footer__inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad);
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  color: var(--ink-muted); font-size: .9rem;
}
.site-footer__links { display: inline-flex; gap: 1.1rem; }
.site-footer__links a { color: var(--ink-soft); }
.site-footer__links a:hover { color: var(--accent); }

/* ------------------------------ Utilities -------------------------------- */
.is-loading { opacity: 0; }
[data-hero], [data-research], [data-cv], [data-media] { animation: fadein .4s ease both; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { [data-hero], [data-research], [data-cv], [data-media] { animation: none; } }

/* ============================== Responsive =============================== */
@media (max-width: 900px) {
  .hero__inner { grid-template-columns: 1fr; }
  .hero__media { order: -1; max-width: 460px; }
  .cards { grid-template-columns: 1fr; }
  .media-grid { grid-template-columns: 1fr; gap: 2.2rem; }
}

@media (max-width: 680px) {
  body { font-size: 16px; }
  .site-nav__toggle { display: block; }
  .site-nav__menu {
    position: absolute; top: 62px; left: 0; right: 0;
    flex-direction: column; align-items: flex-start; gap: 0;
    background: #fff; border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
    padding: .4rem var(--pad) 1rem;
    max-height: 0; overflow: hidden; visibility: hidden;
    transition: max-height .25s ease, visibility .25s;
  }
  .site-nav.is-open .site-nav__menu { max-height: 80vh; visibility: visible; }
  .site-nav__menu > a { width: 100%; padding: .7rem 0; border-bottom: 1px solid var(--line-soft); }
  .site-nav__menu > a::after { display: none; }
  .site-nav__social { padding-top: .8rem; gap: 1.1rem; }
  .site-nav__social svg { width: 22px; height: 22px; }

  .hero__tagline { max-width: none; }
  .hero__name { white-space: normal; }
}
