html.has-custom-js {
  scroll-behavior: auto;
}

body {
  background-color: #f8eed8;
}

body.modal-open {
  overflow: hidden;
}

.contact-card {
  margin-top: 2rem;
  padding: 1.5rem;
  border-radius: 1rem;
  border: 1px solid #e3e3e3;
  background-color: #f8f8f8;
}

.contact-card .contact-email {
  font-weight: 600;
}

.modal-card {
  cursor: pointer;
}

.modal-card:focus-visible {
  outline: 2px solid #d6c28f;
  outline-offset: 4px;
}

.modal-card-close {
  cursor: pointer;
}

.modal-card-close:focus-visible {
  outline: 2px solid #d6c28f;
  outline-offset: 4px;
}

/* Photo grids: remove Webflow shadow */
.photo_in_grid,
.photo_in_grid-oxford {
  box-shadow: none;
  background-color: #fff;
}

/* Main page grids: stretch thumbnails to match text height */
.publications-grid .photo_in_grid,
.item-list .photo_in_grid {
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  align-self: stretch;
}

.photo_in_grid .image-7 {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Profile photo: force square aspect for circular crop on landscape images */
.image-2 {
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: 55% 25%;
}

/* Research section intro text */
.research-intro {
  font-size: 1.5em;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 0.2em;
}

.research-intro + .text-block-3 {
  margin-top: 20px;
}

/* Override Webflow capitalize on publication text */
.text-block-5,
.link-4 {
  text-transform: none;
}

/* Publication entry wrapper (replaces <a> to allow nested links) */
.publication-entry {
  display: contents;
  color: inherit;
}

.publication-entry:hover .photo_in_grid {
  opacity: 0.85;
}

/* Stack text and pill links vertically within the grid cell */
.text_in_grid {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}

/* Paper pill links row */
.paper-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.paper-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s ease;
  line-height: 1.6;
}

/* Paper pill: warm beige */
.pill-paper {
  background-color: #e2d5c3;
  color: #4a3d2e;
}

.pill-paper:hover {
  background-color: #d4c4ad;
}

/* Code pill: green */
.pill-code {
  background-color: #c8debb;
  color: #2d4a2d;
}

.pill-code:hover {
  background-color: #b5d0a4;
}

/* Blog pill: purple */
.pill-blog {
  background-color: #d8c8eb;
  color: #462a5e;
}

.pill-blog:hover {
  background-color: #cbb8e2;
}

/* Website pill: blue */
.pill-website {
  background-color: #c3d5e6;
  color: #2d3f52;
}

.pill-website:hover {
  background-color: #b0c6db;
}

/* Inspect pill: rose */
.pill-inspect {
  background-color: #eac8cd;
  color: #7a2838;
}

.pill-inspect:hover {
  background-color: #dfb5bc;
}

/* YouTube pill: red */
.pill-youtube {
  background-color: #e8b8b8;
  color: #7a1a1a;
}

.pill-youtube:hover {
  background-color: #dca3a3;
}

/* News pill: amber/orange */
.pill-news {
  background-color: #e8d5a8;
  color: #5a4418;
}

.pill-news:hover {
  background-color: #dcc68e;
}

/* Remove excessive whitespace and horizontal lines between sections */
.main-page-section {
  min-height: auto;
  max-height: none;
}

.offset,
.offse_top {
  height: 40px;
  border: none;
  border-bottom: none;
}

.heading-2 {
  margin-top: 0;
}

/* Fix header underline to be more visible and consistent */
.main-nav {
  border-bottom: none !important;
  box-shadow: 0 2px 0 0 #c1c2c5 !important;
}

/* Nav link hover: match social icon hover colour */
.main-nav__link:hover,
.main-nav__link:hover div {
  color: #d9c4b0 !important;
  opacity: 1 !important;
}

/* Recolor social logos from green to pale cream (#f8eed8) */
.socials_logos img {
  filter: hue-rotate(-109deg) saturate(0.5) brightness(1.45);
  transition: filter 0.15s ease;
}

.socials_logos a:hover img {
  filter: hue-rotate(-109deg) saturate(1) brightness(1.2);
}

/* Body text: increase line-height to accommodate inline link boxes */
.div-block-4 .text-block-3 {
  line-height: 1.7;
}

/* Inline text links: boxed style instead of blue underline */
.div-block-4 .text-block-3 a:not(.w-inline-block) {
  color: inherit;
  text-decoration: none;
  background-color: #e2d5c3;
  padding: 2px 5px;
  border-radius: 3px;
  transition: background-color 0.15s ease;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.div-block-4 .text-block-3 a:not(.w-inline-block):hover {
  background-color: #d4c4ad;
}

/* Publication photo links */
.photo_in_grid a {
  display: flex;
  width: 100%;
  height: 100%;
}

/* Download CV: boxed link style matching inline links */
.button.w-button {
  background-color: #e2d5c3;
  color: #333;
  border-radius: 3px;
  padding: 2px 10px;
  font-size: inherit;
  font-weight: normal;
  text-transform: none;
  transition: background-color 0.15s ease;
}

.button.w-button:hover {
  background-color: #d4c4ad;
}

/* Read More links: boxed link style */
.link-block-12,
.link-block-4 {
  color: #333;
  text-decoration: none;
  background-color: #e2d5c3;
  padding: 2px 10px;
  border-radius: 3px;
  transition: background-color 0.15s ease;
  display: inline-block;
}

.link-block-12:hover,
.link-block-4:hover {
  background-color: #d4c4ad;
}

.link-block-12 .paragraph-2,
.link-block-12 .paragraph-2 strong,
.link-block-4 .text-block-2 {
  font-weight: normal;
  font-family: inherit;
  font-size: inherit;
  text-decoration: none;
  text-transform: none;
}

/* Remove excessive min-height/height on sections to avoid bottom whitespace */
.main-page-section {
  min-height: auto !important;
}

.contact {
  height: auto !important;
  padding-bottom: 4rem;
  background-color: var(--copy-bright);
}

/* Item list grid for teaching and blog sections (matches publications layout) */
.item-list {
  display: grid;
  grid-column-gap: 40px;
  grid-row-gap: 40px;
  grid-template-columns: minmax(107px, .5fr) minmax(200px, 4fr);
}

/* About section: tighter spacing within subsections */
.grid-2 {
  grid-row-gap: 16px !important;
}

/* About section: align CV button column with dates column */
.grid-3 {
  grid-template-columns: 1fr .27fr !important;
}

/* About section: equal gaps above/below subheadings */
.div-block-4 .heading-5 {
  margin-top: 28px;
  margin-bottom: 12px;
}

/* Oral highlight: muted warm red */
.oral-highlight {
  color: #7a3535;
  font-weight: 700;
}

/* Sub-pages: ensure content starts below fixed nav (90px tall) */
body > div:not(.page-wrapper) > section:first-of-type .offset {
  height: 100px;
}

/* Teaching sub-page grid images: fill squares */
.grid-5 .photo_in_grid img,
.grid-5-oxford .photo_in_grid img,
.grid-5-oxford .photo_in_grid-oxford img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== Breakpoint 1: Tablet & Mobile (≤767px) ===== */
@media screen and (max-width: 767px) {

  /* Prevent any child from causing horizontal scroll */
  .page-wrapper {
    overflow-x: hidden;
  }

  /* --- Nav: Webflow switches from fixed to absolute with 3em padding --- */
  .main-nav {
    padding-top: 1.2em;
    padding-bottom: 1.2em;
  }

  .div-block-10 {
    flex-wrap: wrap;
    height: auto;
    justify-content: center;
    margin-left: 0;
    gap: 0;
  }

  /* Hide nav name + CV link on mobile (name is in hero, CV in About section) */
  .name.w-nav-brand,
  .cv.w-nav-brand {
    display: none;
  }

  /* Reset margin that pushes menu right on desktop */
  .main-nav__menu {
    margin: 0;
    width: 100%;
    justify-content: center;
    padding-right: 0;
  }

  .main-nav__links-wrap {
    flex-wrap: wrap;
    justify-content: center;
    gap: 1em 1.5em;
  }

  .logo-text {
    padding-left: 15px;
    padding-right: 15px;
  }

  /* --- Hero: collapse 100vh, stack vertically, CENTER everything --- */
  .first-page-container {
    height: auto;
  }

  .div-block-7 {
    flex-direction: column;
    align-items: center;
    height: auto;
    padding-top: 100px;
    padding-bottom: 40px;
  }

  .first-page-div.gutter-outside-copy {
    width: 85%;
    max-width: 100%;
    padding-right: 0;
    justify-content: center;
    align-items: center;
  }

  .hero__grid-left.hero {
    align-items: center;
    text-align: center;
    width: 100%;
  }

  .intro {
    align-items: center;
    text-align: center;
    padding-right: 0;
  }

  .title4.text-regular {
    text-align: center;
  }

  .p-xs-end {
    text-align: center;
  }

  .logos_wrapper {
    display: flex;
    justify-content: center;
  }

  .socials_logos {
    justify-content: center;
  }

  .div-block-8 {
    width: 100%;
    max-width: 100%;
    padding-left: 0;
    display: flex;
    justify-content: center;
    margin-top: 24px;
  }

  .div-block-8 .hero__grid-left.hero {
    display: flex;
    justify-content: center;
    width: 100%;
  }

  .image-2 {
    max-width: 200px;
    margin: 0 auto;
    display: block;
  }

  /* --- Content sections --- */
  .div-block-4 {
    width: 88%;
    max-width: 100%;
    margin-top: 20px;
    margin-bottom: 0;
  }

  /* Reduce section headings from 3.5em to something mobile-friendly */
  .heading-2 {
    font-size: 2.2em;
    margin-bottom: -4px;
  }

  .text-block-3 {
    text-align: left;
    margin-top: 16px;
  }

  /* Reduce section spacing */
  .offset,
  .offse_top {
    height: 20px;
  }

  .main-page-section {
    padding-top: 0;
  }

  /* Remove scroller max-height so publications aren't cut off */
  .scroller {
    max-height: none;
    overflow: visible;
  }

  /* About section grids → single column */
  .grid-3 {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .grid-3 .button.w-button {
    margin-top: 4px;
  }

  .grid-2 {
    grid-template-columns: 1fr !important;
    grid-template: none !important;
  }

  .text-block-7 {
    text-align: left;
    margin-top: -4px;
  }

  /* Item-list (teaching/blog): 2-col → 1-col */
  .item-list {
    grid-column-gap: 16px;
    grid-row-gap: 28px;
    grid-template-columns: 1fr;
  }

  .item-list .photo_in_grid {
    width: 100%;
    height: 120px;
    max-width: 200px;
    margin: 0 auto;
  }

  /* --- Teaching sub-page modals → responsive --- */
  .popup,
  .popup-oxford {
    width: 90vw;
    max-width: 600px;
    height: auto;
    max-height: 80vh;
    margin-top: 10vh;
    overflow-y: auto;
    left: 50%;
    transform: translateX(-50%);
  }

  .popup-grid,
  .popup-grid-area,
  .popup-grid-d10 {
    grid-template-columns: 1fr .75fr;
    grid-template: none;
    padding: 0 20px 20px;
  }

  .popup-grid-oxford,
  .popup-grid-oxford-2,
  .popup-grid-oxford-3 {
    grid-template-columns: 1fr;
    grid-template: none;
    padding: 0 20px 20px;
  }

  /* Teaching sub-page cards */
  .grid-5 img,
  .grid-5-oxford img {
    max-width: 100%;
    height: auto;
  }

  .image-3 {
    width: 150px;
    height: 150px;
  }

  /* Sub-page nav offset: nav is now absolute, not fixed */
  body > div:not(.page-wrapper) > section:first-of-type .offset {
    height: 20px;
  }
}

/* ===== Breakpoint 2: Small Mobile (≤479px) ===== */
@media screen and (max-width: 479px) {

  /* --- Nav: compact for narrow screens --- */
  .main-nav {
    padding-top: 0.8em;
    padding-bottom: 0.8em;
  }

  .div-block-10 {
    flex-direction: column;
    align-items: center;
  }

  .main-nav__links-wrap {
    gap: 0.6em 1em;
    justify-content: center;
  }

  .main-nav__link.light {
    font-size: 0.75rem;
  }

  .logo-text {
    padding-left: 10px;
    padding-right: 10px;
    font-size: 1em;
  }

  /* --- Hero --- */
  .first-page-div.gutter-outside-copy {
    width: 90%;
  }

  .div-block-8 {
    width: 90%;
  }

  .image-2 {
    max-width: 160px;
  }

  /* --- Content width: override Webflow min-width: 300px --- */
  .div-block-4 {
    min-width: 0;
    width: 90%;
  }

  .research-intro {
    font-size: 1.15em;
    text-align: center;
  }

  .heading-5 {
    font-size: 1em;
    margin-top: 20px;
    margin-bottom: 8px;
  }

  /* Left-align headings (override Webflow centering at 479px) */
  .heading-2,
  .heading-5 {
    text-align: left;
  }

  /* Left-align publication & about text (must beat Webflow 479px centering) */
  .text-block-5,
  .text-block-8,
  .text-block-11 {
    text-align: left !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .bold-text-3 {
    text-align: left;
  }

  .text_in_grid {
    align-items: flex-start !important;
    text-align: left !important;
  }

  .paper-links {
    justify-content: flex-start;
  }

  .link-4 {
    text-align: left !important;
  }

  /* --- Publications grid: fix 23px crush, keep 2-col compact layout --- */
  .publications-grid {
    grid-auto-rows: auto !important;
    grid-auto-flow: row !important;
    grid-row-gap: 24px;
    grid-column-gap: 16px;
    grid-template-areas: none !important;
    grid-template-rows: auto !important;
    grid-template-columns: 80px 1fr !important;
    place-items: start !important;
    justify-items: stretch !important;
  }

  .publications-grid .photo_in_grid {
    width: 80px;
    height: 80px;
    max-width: none;
    margin: 0;
    border-radius: 6px;
    overflow: hidden;
    align-self: start;
  }

  .publications-grid .photo_in_grid .image-7 {
    object-fit: cover;
  }

  /* Item-list (teaching/blog): compact thumbnails */
  .item-list {
    grid-row-gap: 24px;
    grid-column-gap: 14px;
    grid-template-columns: 70px 1fr;
    place-items: start !important;
    justify-items: stretch !important;
  }

  .item-list .photo_in_grid {
    width: 70px;
    height: 70px;
    max-width: none;
    margin: 0;
    border-radius: 6px;
    overflow: hidden;
    align-self: start;
  }

  .item-list .photo_in_grid .image-7 {
    object-fit: cover;
  }

  /* --- Popups: maximize usable space --- */
  .popup,
  .popup-oxford {
    width: 95vw;
    margin-top: 5vh;
    max-height: 85vh;
  }

  .heading-7,
  .heading-7-oxford {
    font-size: 1.5em;
    margin-left: 20px;
  }
}
