/* ==========================================================================
   David Wiley — site styles
   Material-inspired palette: Google Sans Flex / Roboto Flex, Google's four
   colors as section accents. Change a token here and it updates everywhere.
   ========================================================================== */

:root {
  /* Type */
  --font-display: 'Google Sans Flex', 'Roboto Flex', system-ui, sans-serif;
  --font-body: 'Roboto Flex', 'Google Sans Flex', system-ui, sans-serif;

  /* Neutrals */
  --bg: #F8FAFD;
  --surface: #FFFFFF;
  --surface-alt: #F0F4F9;
  --ink: #1F1F1F;
  --ink-2: #444746;
  --ink-3: #5F6368;
  --rule: #DADCE0;
  --outline: #C4C7C5;

  /* Brand */
  --primary: #0B57D0;
  --navy: #041E49;
  --navy-line: #1B3A6B;
  --on-navy-muted: #A8C7FA;
  --charcoal: #1F1F1F;
  --on-charcoal-muted: #BDC1C6;

  /* Section palettes: accent / container / tint band / on-container text */
  --blue: #0B57D0;   --blue-container: #D3E3FD;   --blue-tint: #F3F7FE;   --on-blue: #041E49;
  --green: #146C2E;  --green-container: #C4EED0;  --green-tint: #F1F8F3;  --on-green: #0F5223;
  --red: #B3261E;    --red-container: #F9DEDC;    --red-tint: #FDF4F3;    --on-red: #8C1D18;
  --amber: #7D5700;  --amber-container: #FEEFC3;  --amber-tint: #FFFAEB;  --on-amber: #3F2E00;

  /* Shape & spacing */
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 8px;
  --gutter: clamp(16px, 5vw, 80px);
  --section-pad: clamp(64px, 8vw, 112px);
  --max-width: 1280px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; }
/* Safety net: one over-wide element must never make the page pan sideways on phones. */
html, body { overflow-x: clip; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: var(--primary); }
a:hover { color: var(--navy); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; margin: 0; }
p { margin: 0; }
ul { margin: 0; padding: 0; }

.container {
  width: 100%;
  max-width: calc(var(--max-width) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Shared pieces ---------- */
.eyebrow {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent, var(--ink-3));
}
.label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.section-title {
  font-size: clamp(40px, 5vw, 60px);
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.sub-title { font-size: 28px; line-height: 1.2; }
.sub-title--lg { font-size: 36px; }
.lede { font-size: 20px; color: var(--ink-2); }
.section-head { display: flex; flex-direction: column; gap: 20px; }

.placeholder { color: var(--ink-3); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 28px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 17px;
  text-decoration: none;
  white-space: nowrap;
}
.btn--filled { background: var(--accent, var(--primary)); color: #FFFFFF; }
.btn--filled:hover { color: #FFFFFF; filter: brightness(0.92); }
.btn--outline { border: 1.5px solid var(--ink); color: var(--ink); }
.btn--outline:hover { background: rgba(31, 31, 31, 0.06); color: var(--ink); }
.btn--sm { min-height: 44px; padding: 0 22px; font-size: 16px; }

.chip {
  display: inline-flex;
  align-self: flex-start;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  background: var(--container);
  color: var(--on-container);
}

.link-list { list-style: none; }
.link-list li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 0;
  border-top: 1px solid var(--rule);
}
.link-list .title { font-size: 20px; line-height: 1.45; }
/* Publications and speaking entries are plain running text with inline links, not title/meta pairs. */
.research-pubs .link-list li,
.section--speaking .link-list li { display: block; font-size: 20px; line-height: 1.45; }
.link-list .meta { font-size: 20px; color: var(--ink-3); }

.video { margin: 0; display: flex; flex-direction: column; gap: 14px; }
.video a, .video .video-placeholder { position: relative; display: block; }
.video img, .video .video-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-lg);
}
.video .video-placeholder {
  background: var(--charcoal);
  color: var(--on-charcoal-muted);
  display: flex;
  align-items: flex-end;
  padding: 20px;
  font-size: 20px;
}
.video figcaption { font-size: 20px; line-height: 1.5; color: var(--ink-2); }
.play {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72px;
  height: 72px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(31, 31, 31, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 88px;
}
.wordmark { display: flex; align-items: baseline; gap: 10px; color: var(--ink); text-decoration: none; }
.wordmark span:first-child { font-family: var(--font-display); font-size: 30px; font-weight: 500; letter-spacing: -0.01em; }
.wordmark span:last-child { font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.site-nav { display: flex; align-items: center; gap: 32px; font-size: 16px; font-weight: 500; }
.site-nav a:not(.btn) { display: flex; align-items: center; min-height: 44px; color: var(--ink); text-decoration: none; }
.site-nav a:not(.btn):hover { color: var(--primary); }
.nav-toggle { display: none; width: 44px; height: 44px; align-items: center; justify-content: center; background: none; border: 0; border-radius: 50%; color: var(--ink); cursor: pointer; }
.nav-toggle:hover { background: var(--surface-alt); }
.nav-toggle .x { display: none; }
.nav-open .nav-toggle .bars { display: none; }
.nav-open .nav-toggle .x { display: inline; }

/* ---------- Home ---------- */
.home { padding: 88px 0 96px; }
.home .bio { display: flow-root; }
.home .headshot { float: right; width: 420px; margin: 0 0 32px 64px; }
.home .headshot img { width: 100%; height: 520px; object-fit: cover; object-position: center top; border-radius: var(--radius-lg); }
.home .eyebrow { margin-bottom: 24px; }
.home h1 { margin-bottom: 32px; font-size: clamp(48px, 6vw, 84px); line-height: 1.02; letter-spacing: -0.02em; }
.home h1 span { color: var(--primary); }
.home .intro { margin-bottom: 24px; font-size: 20px; color: var(--ink-2); }
.home .bio p:not(.intro) { margin-bottom: 22px; font-size: 20px; line-height: 1.65; color: var(--ink-2); }
.home .actions { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 10px; }

/* ---------- Sections ---------- */
.section { padding: var(--section-pad) 0; }
.section > .container { display: flex; flex-direction: column; gap: 56px; }
.section { background: var(--surface); }
.section--tinted { background: var(--surface-alt); }

.section--research { --accent: var(--blue);  --container: var(--blue-container);  --tint: var(--blue-tint);  --on-container: var(--on-blue); }
.section--teaching { --accent: var(--green); --container: var(--green-container); --tint: var(--green-tint); --on-container: var(--on-green); }
.section--speaking { --accent: var(--red);   --container: var(--red-container);   --tint: var(--red-tint);   --on-container: var(--on-red); }
.section--startups { --accent: var(--blue);  --container: var(--blue-container);  --tint: var(--blue-tint);  --on-container: var(--on-blue); }

.split { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px; row-gap: 48px; align-items: start; }
.split .col { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Research ---------- */
.press {
  background: var(--navy);
  border-radius: var(--radius-lg);
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
}
.press .label { font-weight: 500; color: var(--on-navy-muted); }
.press .logos { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 26px 52px; }
.press img { height: 46px; width: auto; max-width: 200px; object-fit: contain; filter: brightness(0) invert(1); opacity: 0.7; transition: opacity 0.15s; }
.press img:hover { opacity: 1; }
.press img.prewhite { filter: none; } /* already white-on-transparent; the filter would flatten them */
.press img.wide { max-width: 240px; }

/* Each stat box gets an equal share of the row, however many there are. */
.stats { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 24px; }
.stat { display: flex; flex-direction: column; gap: 8px; padding: 32px; border-radius: var(--radius-lg); background: var(--container); color: var(--on-container); }
.stat .number { font-family: var(--font-display); font-size: 56px; line-height: 1; }
.stat--link { justify-content: space-between; gap: 16px; background: var(--accent); color: #FFFFFF; text-decoration: none; }
.stat--link:hover { color: #FFFFFF; filter: brightness(0.92); }
.stat--link .stat-title { font-family: var(--font-display); font-size: 30px; line-height: 1.2; }
.stat--link .stat-cta { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }

.research-pubs { grid-column: 1 / -1; } /* full width while grants are hidden; was span 7 */
/* Long DOI/URL link text has no break points; let it wrap instead of overflowing on phones. */
.research-pubs li,
.research-pubs a { overflow-wrap: anywhere; }
.research-grants { grid-column: 9 / span 4; }

/* ---------- Teaching ---------- */
.courses { grid-column: 1 / -1; } /* full width while the OER column is hidden; was span 6 */
.oer-col { grid-column: 8 / span 5; gap: 20px !important; }
.course-group { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 32px; row-gap: 10px; padding: 24px 0; border-top: 1px solid var(--rule); }
.course-group header { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.course-group ul { grid-column: 1; }
.course-logo { grid-column: 2; grid-row: 2; align-self: center; width: 250px; height: auto; object-fit: contain; border-radius: var(--radius-sm); }
.course-group .inst { font-size: 20px; font-weight: 600; }
.course-group .role { font-size: 20px; color: var(--accent); white-space: nowrap; }
.course-group ul { padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 20px; line-height: 1.5; }
.oer-list { display: flex; flex-direction: column; gap: 16px; }
.oer { display: flex; flex-direction: column; gap: 10px; padding: 26px; border-radius: 24px; background: var(--surface); border: 1px solid var(--rule); }
.oer .name { font-family: var(--font-display); font-size: 22px; line-height: 1.25; }
.oer .desc { font-size: 20px; line-height: 1.5; color: var(--ink-2); }

/* ---------- Speaking ---------- */
.speaking-head { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px; row-gap: 32px; align-items: end; }
.speaking-head .section-head { grid-column: 1 / -1; }
.section--speaking .stats { --container: var(--blue-container); --on-container: var(--on-blue); } /* blue like the Research stat boxes */
.media-block { display: flex; flex-direction: column; gap: 24px; }
.media-block .split { row-gap: 32px; }
.media-block .video { grid-column: span 6; }
.media-block .link-list { grid-column: 8 / span 5; }
.cta-panel {
  --accent: var(--blue); --container: var(--blue-container); --on-container: var(--on-blue);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 32px;
  padding: 36px 44px;
  border-radius: var(--radius-lg);
  background: var(--container);
}
.cta-panel .cta-title { font-family: var(--font-display); font-size: 30px; display: block; }
.cta-panel p { font-size: 20px; color: var(--ink-2); }
.cta-panel p a { color: var(--on-container); font-weight: 600; }

/* ---------- Projects ---------- */
.projects-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.project {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 36px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--rule);
  min-height: 340px;
}
.project h3 { font-size: 34px; line-height: 1.1; }
.project p { flex-grow: 1; color: var(--ink-2); }
.project .project-link { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--accent); }

/* ---------- Startups ---------- */
.startups-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.startup {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 36px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--rule);
  min-height: 340px;
}
.startup h3 { font-size: 34px; line-height: 1.1; }
.startup p { flex-grow: 1; color: var(--ink-2); }
.startup .startup-link { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--accent); }

/* ---------- About ---------- */
.about-photo { width: 100%; aspect-ratio: 2 / 1; object-fit: cover; object-position: center 30%; border-radius: var(--radius-lg); display: block; }
.about-body { display: flex; flex-direction: column; gap: 40px; }
.about-body > div { display: flex; flex-direction: column; gap: 14px; }
.about-body .likes { font-size: 20px; color: var(--ink-2); }
.about-body .likes strong { font-weight: 600; color: var(--ink); }
.about-body .video { width: 100%; max-width: 560px; margin-inline: auto; }
.about-body .video figcaption { text-align: center; }
.web-links { display: flex; flex-wrap: wrap; gap: 10px; }
.web-links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--outline);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-size: 20px;
  font-weight: 500;
}
.web-links a:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- Footer ---------- */
.site-footer { background: var(--navy); color: #FFFFFF; padding: 64px 0 48px; }
.site-footer .container { display: flex; flex-direction: column; gap: 40px; }
.footer-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 40px; flex-wrap: wrap; }
.footer-name { font-family: var(--font-display); font-size: 36px; display: block; margin-bottom: 12px; }
.footer-top p { color: var(--on-navy-muted); }
.footer-top p a { color: #FFFFFF; font-weight: 600; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 28px; }
.footer-nav a { display: flex; align-items: center; min-height: 44px; color: #FFFFFF; text-decoration: none; }
.footer-bottom { display: flex; justify-content: space-between; padding-top: 24px; border-top: 1px solid var(--navy-line); font-size: 14px; color: var(--on-navy-muted); }
.footer-bottom a { color: #FFFFFF; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .nav-toggle { display: flex; }
  .site-nav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0; padding: 8px var(--gutter) 20px; background: var(--surface); border-bottom: 1px solid var(--rule); box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08); }
  .nav-open .site-nav { display: flex; }
  .site-nav a:not(.btn) { min-height: 52px; border-bottom: 1px solid var(--rule); }
  .site-nav .btn { margin-top: 16px; justify-content: center; text-align: center; }
  .speaking-head .section-head { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .home .headshot { float: none; width: 100%; max-width: 420px; margin: 0 0 32px; }
  .home .headshot img { height: auto; aspect-ratio: 4 / 5; }
  .split > *,
  .research-pubs, .research-grants, .courses, .oer-col,
  .media-block .video, .media-block .link-list { grid-column: 1 / -1 !important; }
  .stats { grid-auto-flow: row; grid-auto-columns: auto; }
  .stats, .projects-grid, .startups-grid { grid-template-columns: 1fr; }
  .cta-panel { flex-direction: column; align-items: flex-start; padding: 28px; }
  .press { padding: 32px 24px; }
  .press img { height: 32px; }
  .course-logo { width: 140px; }
  .about-photo { aspect-ratio: 16 / 10; }
}

@media (max-width: 560px) {
  .wordmark span:first-child { font-size: 24px; }
  .stat .number { font-size: 44px; }
  .footer-bottom { flex-direction: column; gap: 8px; }
}
