:root {
  --ink: #172033;
  --ink-soft: #39445A;
  --muted: #6B7280;
  --paper: #FFFFFF;
  --cloud: #F6F7F9;
  --line: #E5E7EB;
  --accent: #A0793D;
  --accent-soft: #F4EADB;
  --blue-soft: #EAF0F7;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.08);
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(160, 121, 61, 0.08), transparent 30rem),
    linear-gradient(180deg, #FFFFFF 0%, #FAFAFB 100%);
  font-size: 16.5px;
}

.navbar {
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 30px rgba(23, 32, 51, 0.04);
  backdrop-filter: blur(12px);
}

.navbar-title {
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1, h2, h3 {
  color: var(--ink);
  letter-spacing: -0.025em;
}

a {
  color: #285A8F;
}

.hero-wrap {
  background:
    linear-gradient(135deg, rgba(234, 240, 247, 0.8), rgba(244, 234, 219, 0.45)),
    #fff;
  border-bottom: 1px solid var(--line);
  margin: -1rem calc(50% - 50vw) 2.5rem calc(50% - 50vw);
  padding: 4.5rem max(2rem, calc((100vw - 1120px)/2)) 4rem;
}

.hero {
  max-width: 1120px;
  margin: auto;
  display: grid;
  grid-template-columns: 1.6fr 0.75fr;
  gap: 2.5rem;
  align-items: center;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: clamp(2.4rem, 6vw, 4.7rem);
  line-height: 0.95;
  margin-bottom: 1.25rem;
}

.hero-copy {
  font-size: 1.14rem;
  line-height: 1.75;
  color: var(--ink-soft);
}

.hero-card {
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(229, 231, 235, 0.9);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.profile-img {
  width: 100%;
  border-radius: 22px;
  border: 1px solid var(--line);
  object-fit: cover;
  aspect-ratio: 4 / 5;
  background: var(--cloud);
}

.contact-card {
  padding: 1rem 0.35rem 0.25rem;
  line-height: 1.6;
  font-size: 0.95rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    gap: 1rem;
    align-items: center;
    justify-content: flex-start;
}

.button, .small-button {
  display: inline-block;
  text-decoration: none;
  border-radius: 999px;
  font-weight: 650;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink) !important;
  box-shadow: 0 8px 22px rgba(23, 32, 51, 0.06);
  transition: transform .15s ease, box-shadow .15s ease;
}

.button {
  padding: 0.72rem 1.05rem;
  margin: 0.25rem 0.35rem 0.25rem 0;
}

.small-button {
  padding: 0.42rem 0.72rem;
  margin: 0.2rem 0.25rem 0.2rem 0;
  font-size: 0.88rem;
}

.button:hover, .small-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(23, 32, 51, 0.12);
}

.primary {
  background: var(--ink);
  color: white !important;
  border-color: var(--ink);
}

.feature-grid, .spotlight-grid, .link-grid {
  display: grid;
  gap: 1rem;
  margin: 1.25rem 0 2rem;
}

.feature-grid {
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
}

.spotlight-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.link-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.feature, .spotlight, .project-card, .publication, .research-item, .link-card, .timeline-item {
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.25rem;
  box-shadow: 0 10px 32px rgba(23, 32, 51, 0.055);
}

.feature h3, .spotlight h3, .publication h3, .research-item h3, .link-card h3 {
  margin-top: 0;
}

.spotlight {
  border-top: 4px solid var(--accent);
}

.project-card {
  background: linear-gradient(135deg, var(--blue-soft), #fff);
}

.publication {
  margin-bottom: 1.2rem;
}

.publication.muted {
  background: #FAFAFA;
}

.pub-links {
  margin-top: 0.8rem;
  margin-bottom: 0.6rem;
}

.research-list, .timeline {
  display: grid;
  gap: 1rem;
}

.tag-cloud code {
  display: inline-block;
  margin: 0.25rem;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(160, 121, 61, 0.18);
  color: var(--ink);
}

.book-hero {
  display: grid;
  grid-template-columns: 0.8fr 1.4fr;
  gap: 2rem;
  align-items: center;
  margin: 1rem 0 2.5rem;
}

.book-cover {
  min-height: 420px;
  border-radius: 28px;
  padding: 2rem;
  color: white;
  background:
    radial-gradient(circle at 20% 10%, rgba(215,168,79,.35), transparent 13rem),
    linear-gradient(145deg, #111827, #263244);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.cover-title {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 0.95;
}

.cover-subtitle {
  font-size: 1.05rem;
  color: #E5E7EB;
  line-height: 1.45;
}

.cover-authors {
  font-size: 0.95rem;
  color: #F4EADB;
  line-height: 1.55;
}

.book-description {
  background: white;
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.quarto-title-block .quarto-title-banner {
  background: transparent;
}

footer {
  border-top: 1px solid var(--line);
}

@media (max-width: 850px) {
  .hero, .book-hero {
    grid-template-columns: 1fr;
  }

  .hero-wrap {
    padding-top: 3rem;
  }

  .hero-card {
    max-width: 420px;
  }
}


/* V3 layout fixes */
.sidebar nav[role="doc-toc"] {
  max-width: 230px;
  font-size: 0.9rem;
}

#quarto-margin-sidebar {
  padding-left: 0.5rem;
}

@media (min-width: 992px) {
  .page-columns {
    column-gap: 1.6rem;
  }
}

@media (max-width: 1200px) {
  #quarto-margin-sidebar {
    display: none;
  }

  main.content {
    grid-column: body-content-start / body-content-end !important;
  }
}

.video-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  margin-top: 1rem;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 10px 32px rgba(23, 32, 51, 0.08);
  background: #111827;
}

.video-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0 2rem;
}

.toc-card {
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.2rem;
  box-shadow: 0 10px 32px rgba(23, 32, 51, 0.055);
}

.toc-card h3 {
  margin-top: 0;
}

/* Keep navbar usable on medium screens */
@media (max-width: 1100px) {
  .navbar-title {
    font-size: 1rem;
  }

  .navbar-nav .nav-link {
    padding-left: .4rem !important;
    padding-right: .4rem !important;
  }
}


/* V4: Quarto-native fenced div rendering fixes */
.hero-card figure {
  margin: 0;
}

.hero-card p {
  margin-bottom: 0;
}

.hero-card img.profile-img,
.profile-img {
  display: block;
  width: 100%;
}

.cover-authors p,
.cover-subtitle p,
.cover-title p {
  margin: 0;
}

.cover-title p {
  font-size: inherit;
  line-height: inherit;
}

.cover-subtitle p,
.cover-authors p {
  color: inherit;
}


/* V6 refinements */
.quarto-title-block:has(h1.title:empty) {
  display: none;
}

.book-cover-preview {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

.book-cover-image {
  width: 100%;
  border-radius: 24px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero h1 {
  margin-top: 0;
}

/* Slightly reduce hero title size to avoid overwhelming the page */
.hero h1 {
  font-size: clamp(2.4rem, 5.2vw, 4.25rem);
}


/* V7 PDF embed and bilingual refinements */
.pdf-embed {
  width: 100%;
  height: 78vh;
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: white;
  margin: 1rem 0 1.25rem;
}

.pdf-embed iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

@media (max-width: 760px) {
  .pdf-embed {
    height: 70vh;
    min-height: 480px;
  }
}


/* V8 Books & Notes layout */
.book-main-card {
  display: grid;
  grid-template-columns: minmax(240px, 360px) minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
  margin: 1.25rem 0 2rem;
}

.book-main-card .book-description {
  max-width: none;
  min-height: auto;
}

.book-main-card .book-cover-preview {
  align-self: start;
  position: sticky;
  top: 5.5rem;
}

.book-cover-image {
  max-height: 560px;
  object-fit: contain;
  background: #0b1320;
}

.pdf-embed-large {
  height: 92vh;
  min-height: 840px;
  max-height: 1100px;
  border-radius: 18px;
}

.pdf-embed-large iframe {
  display: block;
  transform-origin: top left;
}

@media (max-width: 950px) {
  .book-main-card {
    grid-template-columns: 1fr;
  }

  .book-main-card .book-cover-preview {
    position: static;
    max-width: 420px;
  }

  .pdf-embed-large {
    height: 78vh;
    min-height: 560px;
  }
}


/* V10 PDF preview: object/embed viewer without clipping */
.pdf-viewer-wrap {
  width: 100%;
  height: 92vh;
  min-height: 820px;
  max-height: 1100px;
  margin: 1.25rem 0 1.5rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: var(--shadow);
  overflow: visible;
}

.pdf-viewer {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  border-radius: 18px;
  background: #ffffff;
}

@media (max-width: 760px) {
  .pdf-viewer-wrap {
    height: 78vh;
    min-height: 560px;
  }
}


/* V11: wider layout + mobile scaling */
:root {
  --content-width: 1320px;
}

/* Make ordinary Quarto pages less narrow on desktop */
.page-columns {
  max-width: var(--content-width);
  margin-left: auto;
  margin-right: auto;
}

/* Give the main content more room when the left TOC exists */
@media (min-width: 1200px) {
  body:not(.floating) .page-columns,
  body .page-columns {
    grid-template-columns:
      [screen-start] minmax(1.5rem, 1fr)
      [screen-start-inset] minmax(0, 0.5fr)
      [page-start page-start-inset] minmax(0, 70px)
      [body-start-outset] minmax(0, 70px)
      [body-start] minmax(0, 920px)
      [body-end] minmax(0, 70px)
      [body-end-outset] minmax(0, 70px)
      [page-end-inset page-end] minmax(0, 0.5fr)
      [screen-end-inset] minmax(1.5rem, 1fr)
      [screen-end] !important;
  }

  main.content {
    max-width: 1000px;
  }

  .column-page,
  .column-screen-inset,
  .column-screen {
    max-width: var(--content-width);
  }
}

/* Full-width hero should still align with the new wider grid */
.hero {
  max-width: var(--content-width);
}

.hero-wrap {
  padding-left: max(2rem, calc((100vw - var(--content-width))/2));
  padding-right: max(2rem, calc((100vw - var(--content-width))/2));
}

/* Wider cards/grids on desktop */
.book-main-card {
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
}

.spotlight-grid {
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}

.toc-grid {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* PDF viewer: wider and stable */
.pdf-viewer-wrap {
  width: min(100%, 1180px);
  margin-left: auto;
  margin-right: auto;
  height: 94vh;
  min-height: 880px;
}

/* Avoid too much horizontal compression around the PDF */
main.content:has(.pdf-viewer-wrap) {
  max-width: 1180px;
}

/* Tablet */
@media (max-width: 1100px) {
  .hero-wrap {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .hero {
    gap: 1.6rem;
  }

  main.content {
    max-width: 100%;
  }

  .page-columns {
    max-width: 100%;
  }

  .book-main-card {
    grid-template-columns: 1fr;
  }

  .book-main-card .book-cover-preview {
    position: static;
    max-width: 440px;
    margin: 0 auto;
  }
}

/* Mobile */
@media (max-width: 760px) {
  body {
    font-size: 15.5px;
  }

  .hero-wrap {
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding: 2rem 1rem;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .hero h1 {
    font-size: clamp(2rem, 12vw, 3.1rem);
    line-height: 1.02;
  }

  .hero-copy {
    font-size: 1rem;
    line-height: 1.62;
  }

  .hero-card {
    max-width: 360px;
    margin: 0 auto;
    border-radius: 22px;
  }

  .profile-img {
    aspect-ratio: 4 / 5;
  }

  .button {
    display: inline-block;
    width: auto;
    margin-bottom: 0.45rem;
    padding: 0.68rem 0.9rem;
  }

  .feature-grid,
  .spotlight-grid,
  .toc-grid,
  .link-grid {
    grid-template-columns: 1fr;
  }

  .feature, .spotlight, .project-card, .publication, .research-item, .link-card, .timeline-item, .toc-card {
    border-radius: 18px;
    padding: 1rem;
  }

  .book-cover-image {
    max-height: none;
  }

  .pdf-viewer-wrap {
    width: 100%;
    height: 78vh;
    min-height: 520px;
    border-radius: 14px;
  }

  .pdf-viewer {
    border-radius: 14px;
  }
}

/* Very small phones */
@media (max-width: 420px) {
  .navbar-title {
    max-width: 230px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .hero h1 {
    font-size: 2.25rem;
  }

  .hero-wrap {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }

  .button, .small-button {
    font-size: 0.9rem;
  }
}


/* V12: true wide book layout + adaptive typography */
.wide-page {
  width: min(1500px, calc(100vw - 4rem));
  margin-left: auto;
  margin-right: auto;
}

.wide-page > h1 {
  font-size: clamp(2.4rem, 4vw, 4.2rem);
  line-height: 1;
  margin-top: 1.5rem;
  margin-bottom: 1.4rem;
}

.wide-page > h2 {
  font-size: clamp(1.55rem, 2.2vw, 2.35rem);
  margin-top: 2rem;
}

.wide-page p,
.wide-page li {
  font-size: clamp(1rem, 0.45vw + 0.9rem, 1.18rem);
  line-height: 1.72;
}

/* Override prior book grid rules */
.wide-page .book-main-card {
  display: grid !important;
  grid-template-columns: minmax(320px, 520px) minmax(520px, 1fr) !important;
  gap: clamp(1.25rem, 3vw, 3rem) !important;
  align-items: stretch !important;
  width: 100%;
  margin: 1.5rem 0 2.4rem;
}

.wide-page .book-cover-preview {
  position: static !important;
  max-width: none !important;
  width: 100%;
  display: flex;
  align-items: stretch;
}

.wide-page .book-cover-image {
  width: 100%;
  height: 100%;
  max-height: 760px;
  object-fit: contain;
  border-radius: 24px;
}

.wide-page .book-description {
  width: 100%;
  max-width: none !important;
  min-width: 0;
  padding: clamp(1.35rem, 3vw, 2.5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.wide-page .book-description h1 {
  font-size: clamp(2rem, 3vw, 3.4rem);
  line-height: 1.05;
  margin-top: 0;
}

.wide-page .book-description p {
  font-size: clamp(1rem, 0.65vw + 0.88rem, 1.28rem);
  line-height: 1.68;
}

.wide-page .toc-grid {
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)) !important;
}

.wide-page .toc-card h3,
.wide-page .feature h3 {
  font-size: clamp(1.1rem, 1vw + 0.85rem, 1.45rem);
}

.wide-page .pdf-viewer-wrap {
  width: min(100%, 1380px);
  height: 92vh;
  min-height: 820px;
  margin-left: auto;
  margin-right: auto;
}

/* Neutralize Quarto column constraints on full pages */
body:has(.wide-page) main.content {
  max-width: none !important;
  width: 100% !important;
}

body:has(.wide-page) .page-columns {
  max-width: none !important;
  display: block !important;
}

body:has(.wide-page) #quarto-content {
  padding-left: 0;
  padding-right: 0;
}

/* Tablet */
@media (max-width: 1150px) {
  .wide-page {
    width: min(1000px, calc(100vw - 2.5rem));
  }

  .wide-page .book-main-card {
    grid-template-columns: minmax(280px, 420px) minmax(0, 1fr) !important;
    gap: 1.5rem !important;
  }

  .wide-page .book-description {
    padding: 1.35rem;
  }

  .wide-page .book-description p {
    font-size: 1rem;
  }
}

/* Mobile */
@media (max-width: 850px) {
  .wide-page {
    width: calc(100vw - 1.5rem);
  }

  .wide-page .book-main-card {
    grid-template-columns: 1fr !important;
  }

  .wide-page .book-cover-preview {
    max-width: 430px !important;
    margin: 0 auto;
  }

  .wide-page .book-cover-image {
    height: auto;
    max-height: none;
  }

  .wide-page .book-description {
    padding: 1.15rem;
    border-radius: 20px;
  }

  .wide-page .pdf-viewer-wrap {
    height: 76vh;
    min-height: 520px;
  }
}

@media (max-width: 430px) {
  .wide-page {
    width: calc(100vw - 1rem);
  }

  .wide-page > h1 {
    font-size: 2.15rem;
  }

  .wide-page .book-description h1 {
    font-size: 1.8rem;
  }

  .wide-page p,
  .wide-page li,
  .wide-page .book-description p {
    font-size: 0.98rem;
  }
}


/* V13: apply modern wide layout to all pages */
.wide-page {
  width: min(1500px, calc(100vw - 4rem));
  margin-left: auto;
  margin-right: auto;
  padding-bottom: 2rem;
}

.wide-page h1:first-child {
  font-size: clamp(2.6rem, 4vw, 4.6rem);
  line-height: 1.02;
  margin-top: 1.25rem;
  margin-bottom: 1.6rem;
  letter-spacing: -0.03em;
}

.wide-page h2 {
  font-size: clamp(1.6rem, 2vw, 2.5rem);
  margin-top: 2.3rem;
  margin-bottom: 1rem;
}

.wide-page h3 {
  font-size: clamp(1.1rem, 1vw + 0.8rem, 1.5rem);
  line-height: 1.2;
}

.wide-page p,
.wide-page li {
  font-size: clamp(1rem, 0.45vw + 0.9rem, 1.16rem);
  line-height: 1.72;
}

.wide-page .feature-grid,
.wide-page .spotlight-grid,
.wide-page .toc-grid,
.wide-page .link-grid {
  gap: 1.4rem;
}

.wide-page .feature,
.wide-page .spotlight,
.wide-page .publication,
.wide-page .project-card,
.wide-page .research-item,
.wide-page .link-card,
.wide-page .timeline-item,
.wide-page .toc-card {
  padding: clamp(1.15rem, 1.2vw + 0.9rem, 2rem);
  border-radius: 24px;
}

.wide-page .timeline {
  margin-top: 1rem;
}

.wide-page .button,
.wide-page .small-button {
  font-size: clamp(0.95rem, 0.3vw + 0.85rem, 1.05rem);
}

.wide-page .publication {
  margin-bottom: 1.5rem;
}

.wide-page .publication p,
.wide-page .research-item p,
.wide-page .feature p,
.wide-page .toc-card p {
  margin-bottom: 0;
}

.wide-page .tag-cloud {
  margin-top: 1rem;
}

/* Improve content centering */
body:has(.wide-page) main.content {
  max-width: none !important;
  width: 100% !important;
}

body:has(.wide-page) .page-columns {
  display: block !important;
  max-width: none !important;
}

body:has(.wide-page) #quarto-content {
  padding-left: 0;
  padding-right: 0;
}

/* Responsive */
@media (max-width: 900px) {
  .wide-page {
    width: calc(100vw - 1.8rem);
  }

  .wide-page .feature-grid,
  .wide-page .spotlight-grid,
  .wide-page .toc-grid,
  .wide-page .link-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 430px) {
  .wide-page {
    width: calc(100vw - 1rem);
  }

  .wide-page h1:first-child {
    font-size: 2.2rem;
  }

  .wide-page p,
  .wide-page li {
    font-size: 0.98rem;
  }
}


/* V14: consistent page title alignment and adaptive typography across all pages */
body:has(.wide-page) .quarto-title-block,
body:has(.wide-page) header#title-block-header {
  display: none !important;
}

body:has(.wide-page) main.content {
  max-width: none !important;
  width: 100% !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

body:has(.wide-page) .page-columns {
  display: block !important;
  max-width: none !important;
  width: 100% !important;
}

body:has(.wide-page) #quarto-content,
body:has(.wide-page) #quarto-document-content {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.wide-page {
  width: min(1500px, calc(100vw - 4rem)) !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

.wide-page > h1:first-child {
  font-size: clamp(3.2rem, 5.6vw, 6.2rem) !important;
  line-height: 0.96 !important;
  margin-top: clamp(1.25rem, 3vw, 2.5rem) !important;
  margin-bottom: clamp(1.5rem, 3vw, 2.5rem) !important;
  letter-spacing: -0.055em !important;
  max-width: 1050px;
}

.wide-page > h2 {
  font-size: clamp(1.9rem, 2.5vw, 3rem) !important;
  line-height: 1.08 !important;
  margin-top: clamp(2rem, 4vw, 3.4rem) !important;
  margin-bottom: 1.15rem !important;
}

.wide-page > h3,
.wide-page .feature h3,
.wide-page .spotlight h3,
.wide-page .publication h3,
.wide-page .research-item h3,
.wide-page .link-card h3,
.wide-page .timeline-item h3,
.wide-page .toc-card h3 {
  font-size: clamp(1.25rem, 1.25vw + 0.9rem, 1.8rem) !important;
}

.wide-page p,
.wide-page li {
  font-size: clamp(1.08rem, 0.62vw + 0.9rem, 1.32rem) !important;
  line-height: 1.75 !important;
}

.wide-page .publication,
.wide-page .feature,
.wide-page .spotlight,
.wide-page .project-card,
.wide-page .research-item,
.wide-page .link-card,
.wide-page .timeline-item,
.wide-page .toc-card {
  padding: clamp(1.35rem, 1.8vw, 2.4rem) !important;
}

.wide-page .small-button,
.wide-page .button {
  font-size: clamp(1rem, 0.4vw + 0.88rem, 1.12rem) !important;
}

/* keep Books & Notes title from getting too huge compared with its content */
.wide-page .book-description h1 {
  font-size: clamp(2.7rem, 4.2vw, 5rem) !important;
}

.wide-page .book-description p {
  font-size: clamp(1.08rem, 0.62vw + 0.9rem, 1.34rem) !important;
}

/* publications tags: make them look like tags, not code fragments */
.wide-page code {
  font-size: 0.94em;
}

.wide-page .publication code {
  display: inline-block;
  padding: 0.3rem 0.52rem;
  margin: 0.15rem 0.1rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
  border: 1px solid rgba(160, 121, 61, 0.15);
}

/* Responsive alignment */
@media (max-width: 900px) {
  .wide-page {
    width: calc(100vw - 1.6rem) !important;
  }

  .wide-page > h1:first-child {
    font-size: clamp(2.55rem, 12vw, 4.2rem) !important;
  }

  .wide-page > h2 {
    font-size: clamp(1.65rem, 7vw, 2.4rem) !important;
  }
}

@media (max-width: 430px) {
  .wide-page {
    width: calc(100vw - 1rem) !important;
  }

  .wide-page > h1:first-child {
    font-size: 2.5rem !important;
  }

  .wide-page p,
  .wide-page li {
    font-size: 1rem !important;
  }
}


/* V15: softer spacing and typography balance */
.wide-page {
  width: min(1380px, calc(100vw - 6rem)) !important;
}

.wide-page > h1:first-child {
  font-size: clamp(2.7rem, 4.5vw, 5rem) !important;
  margin-top: clamp(1.8rem, 3vw, 3rem) !important;
  margin-bottom: clamp(1.8rem, 3vw, 3rem) !important;
  max-width: 980px;
}

.wide-page > h2 {
  font-size: clamp(1.7rem, 2vw, 2.6rem) !important;
  margin-top: clamp(2.2rem, 3vw, 3.4rem) !important;
  margin-bottom: 1.2rem !important;
}

.wide-page p,
.wide-page li {
  font-size: clamp(1rem, 0.42vw + 0.9rem, 1.2rem) !important;
  line-height: 1.78 !important;
}

.wide-page .publication,
.wide-page .feature,
.wide-page .spotlight,
.wide-page .project-card,
.wide-page .research-item,
.wide-page .link-card,
.wide-page .timeline-item,
.wide-page .toc-card {
  padding: clamp(1.5rem, 1.8vw, 2.5rem) !important;
}

.wide-page .book-description h1 {
  font-size: clamp(2.35rem, 3.8vw, 4.2rem) !important;
}

.wide-page .book-description p {
  font-size: clamp(1rem, 0.45vw + 0.9rem, 1.22rem) !important;
}

.wide-page .pdf-viewer-wrap {
  width: min(100%, 1280px);
}

/* More breathing room between sections */
.wide-page section,
.wide-page .feature-grid,
.wide-page .spotlight-grid,
.wide-page .toc-grid,
.wide-page .timeline,
.wide-page .publication {
  margin-top: 1rem;
}

/* Tablet */
@media (max-width: 900px) {
  .wide-page {
    width: calc(100vw - 2.4rem) !important;
  }

  .wide-page > h1:first-child {
    font-size: clamp(2.45rem, 9vw, 4rem) !important;
  }
}

/* Mobile */
@media (max-width: 430px) {
  .wide-page {
    width: calc(100vw - 1.2rem) !important;
  }

  .wide-page > h1:first-child {
    font-size: 2.3rem !important;
  }

  .wide-page p,
  .wide-page li {
    font-size: 0.98rem !important;
  }
}


/* V16: make Home width consistent with the rest of the website */
.hero-wrap {
  padding-left: max(3rem, calc((100vw - 1380px) / 2)) !important;
  padding-right: max(3rem, calc((100vw - 1380px) / 2)) !important;
}

.hero {
  max-width: 1380px !important;
  width: 100%;
  margin-left: auto !important;
  margin-right: auto !important;
  gap: clamp(2rem, 4vw, 4rem) !important;
}

.hero-copy {
  max-width: 880px;
}

.hero-copy h1,
.hero h1 {
  font-size: clamp(3rem, 5vw, 5.6rem) !important;
  line-height: 0.96 !important;
  letter-spacing: -0.05em;
}

.hero-copy p {
  font-size: clamp(1.04rem, 0.45vw + 0.9rem, 1.22rem);
  line-height: 1.8;
}

.hero-card {
  max-width: 430px;
}

/* Tablet */
@media (max-width: 1000px) {
  .hero-wrap {
    padding-left: 2rem !important;
    padding-right: 2rem !important;
  }

  .hero {
    gap: 2rem !important;
  }
}

/* Mobile */
@media (max-width: 760px) {
  .hero-wrap {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

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

  .hero-copy h1,
  .hero h1 {
    font-size: clamp(2.4rem, 11vw, 4rem) !important;
  }

  .hero-card {
    max-width: 360px;
    margin: 0 auto;
  }
}


/* V17: Home narrowed and aligned with the rest of the site */
.hero-wrap {
  padding-left: max(4.5rem, calc((100vw - 1180px) / 2)) !important;
  padding-right: max(4.5rem, calc((100vw - 1180px) / 2)) !important;
}

.hero {
  max-width: 1180px !important;
  width: 100%;
  margin-left: auto !important;
  margin-right: auto !important;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.62fr) !important;
  gap: clamp(1.8rem, 3vw, 3rem) !important;
}

.hero-copy {
  max-width: 760px !important;
}

.hero-copy h1,
.hero h1 {
  font-size: clamp(2.55rem, 4.25vw, 4.65rem) !important;
  line-height: 1.02 !important;
  letter-spacing: -0.045em !important;
}

.hero-copy p {
  font-size: clamp(1rem, 0.32vw + 0.92rem, 1.13rem) !important;
  line-height: 1.76 !important;
}

.hero-card {
  max-width: 360px !important;
}

/* Book copyright notice */
.book-notice {
  margin: 1.25rem 0 2rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 16px;
  background: rgba(244, 234, 219, 0.45);
  box-shadow: 0 8px 24px rgba(23, 32, 51, 0.04);
}

.book-notice p {
  margin: 0;
  font-size: clamp(0.95rem, 0.3vw + 0.88rem, 1.05rem) !important;
}

/* Footer cleanup */
.nav-footer {
  border-top: 1px solid var(--line);
}

/* Tablet */
@media (max-width: 1000px) {
  .hero-wrap {
    padding-left: 2rem !important;
    padding-right: 2rem !important;
  }

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

  .hero-copy {
    max-width: 100% !important;
  }

  .hero-card {
    max-width: 380px !important;
    margin: 0 auto;
  }
}

/* Mobile */
@media (max-width: 760px) {
  .hero-wrap {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  .hero-copy h1,
  .hero h1 {
    font-size: clamp(2.25rem, 10vw, 3.65rem) !important;
  }
}


/* V19 language switcher */
.nav-link.active-language {
  font-weight: 800 !important;
  color: var(--accent) !important;
}

/* V22: unified, viewport-centered Home layout */
:root {
  --home-max-width: 1440px;
  --home-gutter: clamp(1rem, 2.5vw, 2rem);
  --home-mobile-gutter: 0.75rem;
}

html,
body {
  max-width: 100%;
  overflow-x: clip;
}

/* The Home page uses the full viewport as its positioning context. */
body:has(.hero-wrap) .page-columns {
  display: block !important;
  max-width: none !important;
}

body:has(.hero-wrap) main.content {
  width: 100% !important;
  max-width: none !important;
  padding-inline: 0 !important;
}

body:has(.hero-wrap) #quarto-content {
  padding-inline: 0 !important;
}

/* Hero and ordinary Home content share the same centered outer width. */
.hero-wrap,
body:has(.hero-wrap) main.content > :not(.hero-wrap) {
  box-sizing: border-box;
  width: min(
    var(--home-max-width),
    calc(100vw - 2 * var(--home-gutter))
  );
  margin-inline: auto !important;
}

.hero-wrap {
  max-width: none !important;
  margin-top: 0 !important;
  margin-bottom: 2.5rem !important;
  padding: clamp(2.5rem, 5vw, 4.5rem)
           clamp(1.25rem, 4vw, 5rem)
           clamp(2.5rem, 4.5vw, 4rem) !important;
  border-radius: 0 0 26px 26px;
}

/* Keep headings and cards below the hero aligned with one another. */
body:has(.hero-wrap) main.content > h2 {
  margin-top: 2.4rem;
  margin-bottom: 1rem;
}

body:has(.hero-wrap) .feature-grid,
body:has(.hero-wrap) .spotlight-grid {
  margin-top: 1rem;
}

body:has(.hero-wrap) .feature,
body:has(.hero-wrap) .spotlight,
body:has(.hero-wrap) .project-card {
  min-width: 0;
}

@media (max-width: 760px) {
  :root {
    --home-gutter: var(--home-mobile-gutter);
  }

  .hero-wrap {
    margin-bottom: 1.75rem !important;
    padding: 2rem 1rem !important;
    border-radius: 0 0 20px 20px;
  }

  body:has(.hero-wrap) main.content > h2 {
    margin-top: 2rem;
  }
}

@supports not (overflow: clip) {
  html,
  body {
    overflow-x: hidden;
  }
}

/* Interactive Darboux laboratory */
.interactive-page {
  padding-bottom: clamp(2rem, 5vw, 5rem);
}

.interactive-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.7fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: center;
  margin: clamp(1.5rem, 4vw, 3.5rem) 0 2rem;
  padding: clamp(1.5rem, 4vw, 4rem);
  border: 1px solid var(--line);
  border-radius: 30px;
  background:
    radial-gradient(circle at 88% 10%, rgba(160,121,61,.18), transparent 20rem),
    linear-gradient(135deg, rgba(234,240,247,.95), rgba(255,255,255,.96) 58%, rgba(244,234,219,.62));
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.interactive-hero > *,
.interactive-hero-copy,
.interactive-theorem-card {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.interactive-eyebrow {
  margin-bottom: .75rem;
  color: var(--accent);
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.interactive-hero h1 {
  margin: 0 0 1rem !important;
  max-width: 920px;
  font-size: clamp(2.45rem, 5.2vw, 5.6rem) !important;
  line-height: .98 !important;
  letter-spacing: -.055em !important;
}

.interactive-hero p {
  max-width: 900px;
  margin: 0;
  color: var(--ink-soft);
  font-size: clamp(1rem, .48vw + .92rem, 1.22rem) !important;
  line-height: 1.72 !important;
}

.interactive-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  margin-top: 1.35rem;
}

.interactive-theorem-card {
  width: 100%;
  padding: clamp(1.25rem, 2.3vw, 2.25rem);
  border: 1px solid rgba(160,121,61,.26);
  border-radius: 24px;
  background: rgba(255,255,255,.82);
  box-shadow: 0 16px 44px rgba(23,32,51,.08);
  overflow: hidden;
}

.interactive-theorem-label {
  color: var(--accent);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.interactive-theorem-formula {
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  margin: .8rem 0 .35rem;
  font-size: clamp(1rem, 1.25vw, 1.35rem);
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.interactive-theorem-formula mjx-container,
.interactive-theorem-formula .math.display {
  max-width: 100%;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.interactive-theorem-card p {
  font-size: .94rem !important;
  line-height: 1.5 !important;
}

.interactive-feature-grid,
.interactive-note-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 1rem 0 2.25rem;
}

.interactive-feature-card,
.interactive-note {
  position: relative;
  min-width: 0;
  padding: clamp(1.15rem, 2vw, 1.8rem);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 10px 32px rgba(23,32,51,.055);
}

.interactive-feature-card h3,
.interactive-note h3 {
  margin: .25rem 0 .55rem;
  font-size: clamp(1.12rem, .7vw + 1rem, 1.48rem) !important;
}

.interactive-feature-card p,
.interactive-note p {
  margin: 0;
  color: var(--ink-soft);
  font-size: clamp(.94rem, .24vw + .89rem, 1.05rem) !important;
  line-height: 1.62 !important;
}

.interactive-feature-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .78rem;
  font-weight: 800;
}

.darboux-embed-shell {
  overflow: hidden;
  margin: 1rem 0 2.5rem;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 20px 65px rgba(23,32,51,.11);
}

.darboux-embed-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #fff, #f6f7f9);
}

.darboux-embed-toolbar div {
  display: grid;
  gap: .1rem;
}

.darboux-embed-toolbar strong {
  font-size: .95rem;
}

.darboux-embed-toolbar span {
  color: var(--muted);
  font-size: .78rem;
}

.darboux-embed-frame {
  display: block;
  width: 100%;
  height: min(86vh, 1040px);
  min-height: 720px;
  border: 0;
  background: #f7f8fa;
}

@media (max-width: 1050px) {
  .interactive-hero { grid-template-columns: 1fr; }
  .interactive-theorem-card { max-width: 720px; }
  .interactive-feature-grid,
  .interactive-note-grid { grid-template-columns: 1fr; }
  .darboux-embed-frame { min-height: 680px; }
}

@media (max-width: 650px) {
  .interactive-hero {
    margin-top: 1rem;
    padding: 1.25rem;
    border-radius: 22px;
    overflow: hidden;
  }
  .interactive-theorem-card { padding: 1.05rem; }
  .interactive-theorem-formula { font-size: clamp(.92rem, 4.1vw, 1.08rem); }
  .interactive-hero h1 { font-size: clamp(2.2rem, 12vw, 3.65rem) !important; }
  .interactive-actions { display: grid; grid-template-columns: 1fr; }
  .interactive-actions .button { margin: 0; text-align: center; }
  .darboux-embed-toolbar { align-items: flex-start; }
  .darboux-embed-toolbar span { display: none; }
  .darboux-embed-frame { height: 82vh; min-height: 640px; }
}

/* Quarto/Pandoc wrappers inside the interactive page */
.interactive-actions > p,
.darboux-embed-toolbar > p,
.darboux-embed-copy > p,
.interactive-feature-card > p:first-child {
  margin: 0;
}

.darboux-embed-copy > p + p {
  margin-top: 0.08rem;
}

.darboux-embed-toolbar > p {
  flex: 0 0 auto;
}
