/* ==========================================================================
   Layout overrides — fixes overlap & responsive issues across pages.
   Loaded after the compiled main.css via head/custom.html.
   ========================================================================== */

/* Make sure the main content can never sit under the fixed masthead. */
html { scroll-padding-top: 80px; }

/* Avoid edge clipping on small screens. */
img, video, canvas { max-width: 100%; height: auto; }

/* ─── Hero ────────────────────────────────────────────────────── */
.hero__title {
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
}

.hero__subtitle {
  overflow-wrap: break-word;
}

/* Keep meta-grid cells from clipping their values on tablet widths. */
.hero__meta {
  min-width: 0;
}

.hero__meta-value {
  overflow-wrap: break-word;
}

/* ─── Home sections ─────────────────────────────────────────── */
.home-aerospace { min-width: 0; }

.home-aerospace__section {
  min-width: 0;
}

.home-brief {
  align-items: start;
}

.home-brief__content,
.home-profile {
  min-width: 0;
}

.home-profile__meta li {
  min-width: 0;
}

.home-profile__meta strong {
  overflow-wrap: anywhere;
  word-break: normal;
}

.home-profile__links a {
  overflow-wrap: anywhere;
}

/* Cards in grids: prevent hover lift from overlapping siblings. */
.systems-card,
.program-card,
.control-room__card,
.mission-timeline .timeline-item {
  min-width: 0;
}

.systems-overview__grid,
.program-grid,
.control-room__grid,
.mission-timeline .timeline-list {
  align-items: stretch;
}

/* Control-room layout: equal-height cards, no clipping. */
.control-room__card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 0;
}

.control-room__card h3,
.control-room__card p {
  min-width: 0;
  overflow-wrap: break-word;
}

/* Mission timeline: align items, prevent vertical creep. */
.mission-timeline .timeline-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Program filters: don't push past container at small widths. */
.programs__header {
  row-gap: 0.75rem;
}

/* Make hover transforms safe (so they don't overlap neighbors). */
.systems-card,
.program-card,
.control-room__card,
.pub-card,
.modern-project-card,
.archive__item {
  isolation: isolate;
}

/* ─── Mission page (publications, projects, cv) ──────────────── */
.mission-page-intro__grid {
  align-items: start;
}

.mission-page-intro__copy,
.mission-page-intro__meta-value {
  overflow-wrap: break-word;
}

/* Tablet & mobile: ensure the archive's left padding doesn't get
   pushed by any leftover floats from the desktop sidebar layout. */
@media (max-width: 1023px) {
  #main > .archive,
  #main > .page {
    margin-left: 0;
    padding-left: clamp(1rem, 3.5vw, 1.5rem);
    padding-right: clamp(1rem, 3.5vw, 1.5rem);
  }
}

/* ─── Publications page ─────────────────────────────────────── */
.pub-card {
  min-width: 0;
}

.pub-content,
.pub-text {
  min-width: 0;
}

.pub-title,
.pub-venue,
.pub-authors,
.pub-excerpt {
  overflow-wrap: break-word;
  word-break: normal;
}

.pub-footer { row-gap: 0.5rem; }

@media (max-width: 820px) {
  .pub-content--featured {
    flex-direction: column !important;
    gap: 14px !important;
  }
  .pub-content--featured .pub-actions {
    flex-direction: row !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    flex-wrap: wrap;
  }
}

@media (max-width: 600px) {
  .pub-toolbar { gap: 0.5rem; }
  .pub-search-wrap { flex: 1 1 100%; }
  .pub-filter-tabs { width: 100%; }
  .pub-filter-tab { flex: 1 1 auto; text-align: center; }
}

/* ─── Projects page ─────────────────────────────────────────── */
.modern-project-card { min-width: 0; }
.project-body { min-width: 0; }
.project-title,
.project-subtitle,
.project-desc,
.extra-details { overflow-wrap: break-word; }

@media (max-width: 600px) {
  .project-footer {
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }
}

/* ─── CV page ───────────────────────────────────────────────── */
.archive.cv-page--pro .edu-card {
  min-width: 0;
  flex-wrap: wrap;
}
.archive.cv-page--pro .edu-content {
  min-width: 0;
  flex: 1 1 220px;
}
.archive.cv-page--pro .timeline-item {
  overflow-wrap: break-word;
}

/* ─── Sidebar (author profile) ──────────────────────────────────
   The `.mission-page` class lives on `.archive`, not on an ancestor
   of `.sidebar`, so the styles in `_mission-pages.scss` that target
   `.mission-page .sidebar ...` never matched. We replicate them at
   `.sidebar` scope so the profile card renders correctly on every
   page and wraps long affiliations cleanly.
   ─────────────────────────────────────────────────────────────── */

.sidebar {
  box-sizing: border-box;
  min-width: 0;
}

/* The base sidebar is `position: fixed; height: 100vh` on desktop, so
   when you scroll to the end of the page it covers the footer.
   Switch to `position: sticky` so it scrolls with the content once the
   bottom of #main is reached — and cap its height so a long sidebar
   never extends past the viewport. */
@media (min-width: 1024px) {
  .sidebar {
    position: sticky !important;
    top: 90px !important;
    height: auto !important;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    align-self: start;
    padding-top: 0 !important;
  }

  /* The archive layout floats children with Susy. Make #main a flex row
     instead so .sidebar and .archive sit side by side and the sticky
     sidebar can resolve its containing block correctly. */
  #main {
    display: flex;
    align-items: flex-start;
    gap: clamp(1rem, 2vw, 1.75rem);
  }

  #main > .archive,
  #main > .page {
    flex: 1 1 0;
    min-width: 0;
    margin-left: 0;
  }

  #main > .sidebar {
    flex: 0 0 clamp(240px, 22vw, 320px);
    float: none;
    width: auto;
  }
}

.sidebar > div[itemscope] {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Force the avatar + content + urls stack to occupy the whole card. */
.sidebar .author__avatar,
.sidebar .author__content,
.sidebar .author__urls-wrapper {
  display: block !important;
  width: 100% !important;
  padding: 0 !important;
  min-width: 0;
}

.sidebar .author__avatar img {
  display: block;
  width: 80%;
  max-width: 200px;
  height: auto;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--border-muted);
}

.sidebar .author__name {
  margin: 0;
  font-size: clamp(1.35rem, 1.6vw, 1.6rem);
  line-height: 1.15;
  text-align: left;
}

.sidebar .author__bio,
.sidebar .author__pronouns {
  margin: 0.15rem 0 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

/* The mobile dropdown wrapper had absolute positioning; pin it down. */
.sidebar .author__urls-wrapper { cursor: default; }
.sidebar .author__urls-wrapper button { display: none !important; }

.sidebar .author__urls {
  display: grid !important;
  position: relative !important;
  right: auto !important;
  left: auto !important;
  top: auto !important;
  margin: 0.6rem 0 0 !important;
  padding: 0 !important;
  gap: 0.2rem !important;
  list-style: none;
  border: 0;
  background: transparent;
  box-shadow: none !important;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  z-index: 1;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Kill the speech-bubble arrows from the mobile dropdown variant. */
.sidebar .author__urls::before,
.sidebar .author__urls::after { display: none !important; }

/* Each row: icon + wrapping text. */
.sidebar .author__urls li {
  margin: 0 !important;
  padding: 0;
  list-style: none;
  white-space: normal !important;   /* base SCSS set nowrap — undo it */
  overflow-wrap: anywhere;
  word-break: normal;
  min-width: 0;
}

.sidebar .author__urls a,
.sidebar .author__desktop {
  display: grid !important;
  grid-template-columns: 1.15rem minmax(0, 1fr);
  align-items: start;
  column-gap: 0.6rem;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0.35rem 0.1rem;
  border-radius: 0;
  background: transparent;
  font-size: 0.88rem;
  line-height: 1.4;
  white-space: normal !important;
  overflow-wrap: anywhere;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 0;
  box-sizing: border-box;
}

.sidebar .author__urls a:hover {
  text-decoration: none;
  color: var(--link-color);
  background: transparent;
}

.sidebar .author__urls i {
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  width: 1.15rem;
  text-align: center;
  line-height: 1.4;
  font-size: 0.95rem;
}

.sidebar .author__urls .icon-pad-right {
  margin-right: 0 !important;
  padding-right: 0 !important;
}

.sidebar .author__urls span {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Location and affiliation rows are shown on desktop only (keeps the
   mobile sidebar compact). Override the base SCSS's `display: block`
   so the icon + text grid takes effect. */
.sidebar .author__desktop { display: none; }

@media (min-width: 1024px) {
  .sidebar .author__desktop {
    display: grid !important;
  }
}

/* On narrow screens (<1024px) the sidebar stacks above the content,
   so keep it full-width and don't fix it. */
@media (max-width: 1023px) {
  .sidebar {
    position: static !important;
    height: auto !important;
    width: 100% !important;
    max-width: 720px;
    margin: 0 auto 1.5rem;
    padding-top: 0 !important;
    overflow: visible !important;
  }
  .sidebar > div[itemscope] {
    padding: 1rem;
  }
}

/* ─── Tiny screens (≤ 380px) ────────────────────────────────── */
@media (max-width: 380px) {
  .home-section-title { font-size: 1.4rem; }
  .systems-overview__statement { font-size: 1.2rem; }
  .home-profile__image-wrap { width: 132px; }
  .pub-stats { gap: 0.6rem; }
  .pub-stat { flex: 1 1 calc(50% - 0.6rem); padding: 0.8rem; }
  .pub-stat__num { font-size: 1.6rem; }
  .archive .page__title,
  .page .page__title { font-size: 1.55rem; line-height: 1.15; }
}

/* Prevent horizontal overflow at the document level. */
html, body { overflow-x: hidden; }

/* Footer breathing room — was being crowded by hover lifts above. */
.page__footer { position: relative; z-index: 1; }
