/* Presentation mode removes site chrome while retaining the article and TOC. */
body:has(.presentation-content.presentation-mode) :is(.md-header, .md-tabs, .md-sidebar--primary, .md-footer) {
  display: none;
}

/* The theme's normal anchor offset reserves space for the fixed header. */
.presentation-content.presentation-mode :is(h1, h2, h3, h4, h5, h6)[id] {
  scroll-margin-top: 0;
}

body:has(.presentation-content.presentation-mode) .md-main__inner {
  margin-top: 1rem;
}

body:has(.presentation-content.presentation-mode) .md-sidebar--secondary {
  top: 1rem;
}

/* Match the floating section controls without changing the normal docs TOC. */
body:has(.presentation-content.presentation-mode) .md-sidebar--secondary .md-sidebar__scrollwrap {
  /* Override the theme's viewport-height inline style so short menus hug content. */
  height: auto !important;
  max-height: calc(100dvh - 11rem);
  margin: 0 0.6rem;
  padding: 0.6rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.6rem;
  background: var(--md-default-bg-color);
  box-shadow: 0 0.25rem 1rem rgb(0 0 0 / 10%);
}

/* Keep the reading layout scoped to progress updates, including future pages. */
body:has(.presentation-content.presentation-mode) .md-main .md-grid {
  max-width: 90rem;
}

/* Give the article breathing room without moving the right-hand controls. */
body:has(.presentation-content.presentation-mode) .md-main .md-content > .md-content__inner {
  margin-left: clamp(1.2rem, 4vw, 3.6rem);
}

.md-typeset .presentation-content.presentation-mode {
  font-size: clamp(0.972rem, 0.81rem + 0.432vw, 1.188rem);
  line-height: 1.65;
}

/* Prose stays readable; tables and figures can use the full content width. */
.presentation-content.presentation-mode .presentation-slide > :is(p, ul, ol, blockquote) {
  max-width: 72ch;
}

.md-typeset .presentation-content.presentation-mode table:not([class]) {
  font-size: 0.9em;
}

.md-typeset .presentation-content.presentation-mode :is(h1, h2, h3) {
  line-height: 1.25;
}

/* Style the navigation target as the title without changing heading semantics. */
.md-typeset .presentation-content.presentation-mode .presentation-slide-title {
  font-size: 1.875em;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.025em;
  color: var(--md-default-fg-color);
  margin: 0 0 1.25em;
  padding: 0;
}

.presentation-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.presentation-controls:has(.presentation-toggle[hidden]):not(:has([data-md-copy-url])) {
  display: none;
}

.md-typeset .presentation-toggle {
  padding: 0.4em 0.7em;
  border: 1px solid var(--relcon-copy-border);
  border-radius: 0.25rem;
  background: var(--relcon-copy-bg);
  color: var(--relcon-copy-text);
  font-size: 0.7rem;
  line-height: 1.4;
  cursor: pointer;
}

.md-typeset .presentation-toggle:hover {
  background: var(--relcon-copy-hover);
}

.md-typeset .presentation-toggle[aria-pressed="true"] {
  border-color: var(--md-accent-fg-color);
  font-weight: 600;
}

.md-typeset .presentation-toggle:focus-visible {
  outline: 2px solid var(--md-accent-fg-color);
  outline-offset: 3px;
}

.md-typeset .presentation-controls .md-content__button {
  float: none;
  margin: 0;
}

/* Group page actions without overriding their shared typography or padding. */
.md-typeset .presentation-controls > button {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

/* Share the title row, following the theme's normal page-action placement. */
.presentation-controls {
  float: right;
  margin: 0 0 0.6rem 1rem;
}

@media (max-width: 60em) {
  .presentation-controls {
    float: none;
    margin: 0 0 0.6rem;
  }
}

/* Section breaks create a pause without constraining long material to slides. */
.md-typeset .presentation-content.presentation-mode > hr {
  margin: clamp(3rem, 12vh, 7rem) 0;
  border: 0;
  border-top: 1px solid var(--md-default-fg-color--lightest);
  clear: both;
}

.presentation-nav[hidden] {
  display: none;
}

.presentation-nav {
  position: static;
  margin: 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  max-width: calc(100vw - 2rem);
  padding: 0.4rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.6rem;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  box-shadow: 0 0.25rem 1rem rgb(0 0 0 / 10%);
}

.presentation-position {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  min-width: 0;
  font-size: 0.7rem;
  line-height: 1.4;
}

[data-section-title] {
  max-width: 24ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

[data-section-count] {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.md-typeset .presentation-nav button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.35rem;
  color: inherit;
  cursor: pointer;
}

.md-typeset .presentation-nav button:hover:not(:disabled) {
  background: var(--md-accent-fg-color--transparent);
  color: var(--md-accent-fg-color);
}

.md-typeset .presentation-nav button:disabled {
  opacity: 0.35;
  cursor: default;
}

.md-typeset .presentation-nav button:focus-visible {
  outline: 2px solid var(--md-accent-fg-color);
  outline-offset: 2px;
}

@media (max-width: 40em) {
  [data-section-title] { max-width: 14ch; }
  .presentation-position { gap: 0.5rem; }
  .presentation-nav { gap: 0.25rem; }
}

/* Use the right sidebar's footprint, never the article, on desktop. */
@media (min-width: 76.25em) {
  .presentation-nav {
    position: fixed;
    z-index: 3;
    right: max(0.6rem, calc((100vw - 90rem) / 2 + 0.6rem));
    bottom: 1rem;
    width: 10.5rem;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
  }

  .presentation-position {
    grid-column: 1 / -1;
    grid-row: 1;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.4rem 0.5rem;
  }

  .presentation-nav [data-section-title] {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .md-typeset .presentation-nav button {
    width: 100%;
  }
}

@media print {
  .presentation-controls, .presentation-nav { display: none !important; }
}

@media (min-width: 76.25em) {
  .presentation-nav {
    grid-template-columns: 1fr auto 1fr;
  }

  .presentation-position {
    display: contents;
  }

  .presentation-nav [data-section-title] {
    grid-column: 1 / -1;
    grid-row: 1;
    padding: 0.4rem 0.5rem;
  }

  .presentation-nav [data-section-count] {
    grid-column: 2;
    grid-row: 2;
    text-align: center;
    font-size: 0.7rem;
  }

  .presentation-nav [data-section-step="-1"] {
    grid-column: 1;
    grid-row: 2;
  }

  .presentation-nav [data-section-step="1"] {
    grid-column: 3;
    grid-row: 2;
  }
}

.md-typeset .presentation-toggle .md-icon svg {
  width: 1.2em;
  height: 1.2em;
  fill: currentColor;
}

.presentation-content.presentation-mode .presentation-controls [data-md-copy-url] {
  display: none;
}

/* Hidden presentation controls must not override the normal copy action. */
.md-typeset .presentation-controls > .presentation-toggle[hidden] {
  display: none;
}

@media (max-width: 76.249em) {
  .md-typeset .presentation-controls > .presentation-toggle,
  .presentation-nav {
    display: none;
  }
}

/* Normal docs retain their original flow; presentation shows one section. */
.presentation-slide { display: contents; }
.presentation-slide[hidden] { display: none; }
.presentation-content.presentation-mode .presentation-slide {
  display: block;
}
.presentation-content.presentation-mode .presentation-slide[hidden],
.presentation-content.presentation-mode > hr {
  display: none;
}
.presentation-content.presentation-mode .presentation-slide > :first-child {
  margin-top: 0;
}
body:has(.presentation-content.presentation-mode) .md-nav--secondary .md-nav__link {
  color: var(--md-default-fg-color);
}
body:has(.presentation-content.presentation-mode) .md-nav--secondary .presentation-toc-active {
  color: var(--md-accent-fg-color);
  font-weight: 600;
}
@media print {
  .presentation-content.presentation-mode .presentation-slide,
  .presentation-content.presentation-mode .presentation-slide[hidden] {
    display: contents;
  }
  .presentation-content.presentation-mode > hr { display: block; }
}

/* A modest presentation-only increase for the fixed-size interface text too. */
.presentation-content.presentation-mode .presentation-toggle,
.presentation-content.presentation-mode .presentation-position,
.presentation-content.presentation-mode .presentation-nav [data-section-count],
body:has(.presentation-content.presentation-mode) .md-nav--secondary {
  font-size: 0.756rem;
}

/* Keep heading anchors usable by the TOC without displaying permalink symbols. */
.presentation-content.presentation-mode .headerlink {
  display: none;
}
