/*
 * 5sigmas reader v3
 *
 * One contextual path, one readable prose measure and one wide visual canvas.
 * The complete catalogue remains available on demand instead of competing with
 * every paragraph, diagram and interaction on the page.
 */

body:has(.s5-reader-shell) {
  --s5-reader-frame: min(1660px, calc(100vw - 48px));
  --s5-reader-rail-width: 216px;
  --s5-reader-gap: clamp(34px, 2.35vw, 42px);
  --s5-reader-canvas: min(
    1280px,
    calc(var(--s5-reader-frame) - var(--s5-reader-rail-width) - var(--s5-reader-gap))
  );
  --s5-reader-prose: 70ch;
  --s5-reader-lead: 76ch;
  --s5-reader-visual: 1160px;
  --s5-reader-header-height: 56px;
}

body:has(.s5-reader-shell) .md-path,
body:has(.s5-reader-shell) .md-tags {
  display: none !important;
}

body:has(.s5-reader-shell) .md-content__inner {
  padding-top: clamp(1.65rem, 2.6vw, 2.35rem);
}

.s5-reader-context {
  display: flex;
  flex-wrap: wrap;
  gap: .34rem;
  align-items: center;
  max-width: var(--s5-reader-lead);
  margin: 0 0 .72rem;
  color: var(--s5-muted);
  font-size: .54rem;
  font-weight: 720;
  letter-spacing: .06em;
  line-height: 1.35;
  text-transform: uppercase;
}

.s5-reader-context button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--s5-brand-blue);
  cursor: pointer;
  font: inherit;
  text-transform: inherit;
}

.s5-reader-context button:hover,
.s5-reader-context button:focus-visible {
  text-decoration: underline;
  text-underline-offset: .22em;
}

.s5-reader-context strong {
  overflow: hidden;
  color: var(--s5-text);
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body:has(.s5-reader-shell) .md-typeset > h1 {
  display: block !important;
  max-width: 15ch !important;
  margin: 0 0 .82rem !important;
  font-size: clamp(3.15rem, 4.4vw, 4.65rem) !important;
  line-height: .95 !important;
  letter-spacing: -.064em !important;
  overflow-wrap: normal;
  text-wrap: balance;
}

.s5-reader-shell {
  width: 100%;
  max-width: var(--s5-reader-visual);
  margin: 0 0 .65rem !important;
}

.s5-reader-topbar {
  position: relative;
  top: auto;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, .76fr) minmax(0, 1fr);
  min-height: 44px;
  border: 0;
  border-top: 1px solid var(--s5-line-strong);
  border-bottom: 1px solid var(--s5-line);
  background: transparent;
  box-shadow: none;
}

.s5-reader-arrow,
.s5-reader-course {
  min-height: 44px;
}

.s5-reader-arrow {
  gap: .42rem;
  padding: .34rem .18rem;
}

.s5-reader-arrow--prev {
  border-right: 0;
}

.s5-reader-arrow--next {
  border-left: 0;
}

.s5-reader-arrow span,
.s5-reader-course > span {
  font-size: .42rem;
  letter-spacing: .075em;
}

.s5-reader-arrow strong {
  font-size: .55rem;
  font-weight: 740;
}

.s5-reader-arrow small {
  display: none;
}

.s5-reader-course {
  gap: .04rem;
  padding: .31rem .65rem .46rem;
  border-right: 1px solid var(--s5-line);
  border-left: 1px solid var(--s5-line);
}

.s5-reader-course > span {
  display: none;
}

.s5-reader-course strong {
  font-size: .56rem;
  font-weight: 760;
}

.s5-reader-course i {
  height: 2px;
}

.s5-reader-rail {
  display: none !important;
}

body:has(.s5-reader-shell) .s5-reader-shell + .sm-wrap {
  display: flex;
  width: fit-content;
  max-width: 100%;
  margin: .7rem 0 2.15rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body:has(.s5-reader-shell) .s5-reader-shell + .sm-wrap:hover {
  box-shadow: none;
}

body:has(.s5-reader-shell) .s5-reader-shell + .sm-wrap .sm-chips {
  gap: .62rem;
}

body:has(.s5-reader-shell) .s5-reader-shell + .sm-wrap .sm-chip {
  position: relative;
  gap: .28rem;
  padding: .15rem 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--s5-muted);
  font-size: .52rem;
}

body:has(.s5-reader-shell) .s5-reader-shell + .sm-wrap .sm-chip + .sm-chip::before {
  position: absolute;
  top: 50%;
  left: -.36rem;
  color: var(--s5-line-strong);
  content: '·';
  transform: translateY(-52%);
}

body:has(.s5-reader-shell) .s5-reader-shell + .sm-wrap .sm-chip--time {
  color: var(--s5-text);
}

body:has(.s5-reader-shell) .s5-reader-shell + .sm-wrap .sm-chip--count,
body:has(.s5-reader-shell) .s5-reader-shell + .sm-wrap .series-meta-row {
  display: none;
}

body:has(.s5-reader-shell) .s5-reader-shell + .sm-wrap .sm-dot {
  width: 6px;
  height: 6px;
  box-shadow: none;
}

body:has(.s5-reader-shell) .md-main__inner:not(:has(.s5-landing)) .md-typeset > :is(
  p,
  ul,
  ol,
  blockquote,
  .admonition,
  details
) {
  max-width: var(--s5-reader-prose) !important;
}

body:has(.s5-reader-shell) .md-typeset > p,
body:has(.s5-reader-shell) .md-typeset > li {
  font-size: .95rem;
  line-height: 1.72;
  text-wrap: pretty;
}

body:has(.s5-reader-shell) .md-typeset > blockquote:first-of-type {
  max-width: var(--s5-reader-lead) !important;
  margin: .3rem 0 2.75rem;
  padding: .08rem 0 .08rem .9rem;
  border-left: 2px solid var(--s5-text);
  color: var(--s5-muted);
  font-size: .91rem;
  line-height: 1.62;
  text-wrap: pretty;
}

body:has(.s5-reader-shell) .md-typeset > blockquote:first-of-type strong {
  color: var(--s5-text);
}

body:has(.s5-reader-shell) .md-typeset > h2 {
  max-width: 22ch;
  margin-top: clamp(4.2rem, 6vw, 5.5rem) !important;
  margin-bottom: 1.15rem !important;
  padding-top: 0 !important;
  border-top: 0 !important;
  font-size: clamp(1.95rem, 2.75vw, 2.45rem) !important;
  line-height: 1.05 !important;
  letter-spacing: -.048em !important;
  text-wrap: balance;
}

body:has(.s5-reader-shell) .md-typeset > h3 {
  max-width: 30ch;
  margin-top: 2.85rem !important;
  margin-bottom: .8rem !important;
  font-size: clamp(1.25rem, 1.8vw, 1.5rem) !important;
  line-height: 1.13 !important;
  letter-spacing: -.034em !important;
  text-wrap: balance;
}

body:has(.s5-reader-shell) .md-typeset > :is(pre, table, .highlight) {
  max-width: min(100%, 1000px);
}

body:has(.s5-reader-shell) .md-typeset > hr {
  max-width: var(--s5-reader-prose);
  margin: 3.6rem 0;
}

body:has(.s5-reader-shell) .s5-video-embed {
  width: min(100%, var(--s5-reader-visual));
  max-width: none;
  margin-top: 1.7rem;
  margin-bottom: 3.6rem;
}

body:has(.s5-reader-shell) .anim-brand-shell:has(.anim-brand-shell__viewport > .s5v) {
  width: min(1080px, 100%);
  margin-top: 1.7rem;
  margin-bottom: clamp(3.6rem, 5.4vw, 4.8rem);
}

body:has(.s5-reader-shell) .anim-brand-shell:has(.anim-brand-shell__viewport > .s5v--wide) {
  width: min(var(--s5-reader-visual), 100%);
}

.s5-reader-direct__browse {
  display: none;
}

@media (min-width: 1320px) {
  body:has(.s5-reader-shell) .md-header {
    min-height: var(--s5-reader-header-height);
  }

  body:has(.s5-reader-shell) .md-header__inner {
    width: var(--s5-reader-frame);
    max-width: none;
    min-height: var(--s5-reader-header-height);
    height: var(--s5-reader-header-height);
  }

  body:has(.s5-reader-shell) .md-tabs {
    position: fixed;
    top: 0;
    left: 50%;
    z-index: 3;
    width: var(--s5-reader-frame);
    height: var(--s5-reader-header-height);
    border: 0;
    background: transparent !important;
    pointer-events: none;
    transform: translateX(-50%);
  }

  body:has(.s5-reader-shell) .md-tabs__inner {
    width: 100%;
    max-width: none;
    height: 100%;
  }

  body:has(.s5-reader-shell) .md-tabs__list {
    align-items: stretch;
    height: 100%;
    margin: 0;
    padding-right: 330px;
    padding-left: calc(var(--s5-reader-rail-width) + var(--s5-reader-gap));
    pointer-events: auto;
  }

  body:has(.s5-reader-shell) .md-tabs__item {
    height: 100%;
    padding-right: .75rem;
    padding-left: 0;
  }

  body:has(.s5-reader-shell) .md-tabs__link {
    display: flex;
    align-items: center;
    height: 100%;
    margin: 0;
    font-size: .58rem;
  }

  body:has(.s5-reader-shell) .md-main__inner {
    display: block;
    width: var(--s5-reader-frame);
    max-width: none;
    margin-right: auto;
    margin-left: auto;
    padding-right: 0;
    padding-left: 0;
  }

  body:has(.s5-reader-shell) .md-main__inner > .md-sidebar {
    display: none !important;
  }

  body:has(.s5-reader-shell) .md-content {
    width: var(--s5-reader-canvas);
    max-width: none !important;
    margin-right: 0 !important;
    margin-left: calc(var(--s5-reader-rail-width) + var(--s5-reader-gap)) !important;
  }

  body:has(.s5-reader-shell) .md-content__inner,
  body:has(.s5-reader-shell) .md-typeset {
    width: 100%;
    max-width: none;
    margin-right: 0 !important;
    margin-left: 0 !important;
  }

  body:has(.s5-reader-shell) .s5-reader-direct {
    top: calc(var(--s5-reader-header-height) + 16px);
    left: calc((100vw - var(--s5-reader-frame)) / 2);
    width: var(--s5-reader-rail-width);
    max-height: calc(100dvh - var(--s5-reader-header-height) - 34px);
    grid-template-rows: auto auto minmax(0, 1fr);
    border-top: 1px solid var(--s5-line-strong);
    border-bottom: 0;
    background: transparent;
  }

  .s5-reader-direct__header {
    padding: .72rem 0 .64rem;
  }

  .s5-reader-direct__header > div {
    gap: .14rem;
  }

  .s5-reader-direct__header span {
    font-size: .44rem;
  }

  .s5-reader-direct__header strong {
    font-size: .76rem;
    line-height: 1.18;
  }

  .s5-reader-direct__header small {
    display: block;
    color: var(--s5-muted);
    font-size: .46rem;
    font-weight: 650;
  }

  .s5-reader-direct__browse {
    display: flex;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 36px;
    padding: .4rem 0;
    border: 0;
    border-top: 1px solid var(--s5-line);
    border-bottom: 1px solid var(--s5-line-strong);
    background: transparent;
    color: var(--s5-text);
    cursor: pointer;
    font-size: .53rem;
    font-weight: 740;
    text-align: left;
  }

  .s5-reader-direct__browse:hover,
  .s5-reader-direct__browse:focus-visible {
    color: var(--s5-brand-blue);
  }

  .s5-reader-direct__search {
    display: none;
  }

  .s5-reader-direct__collections {
    overflow-y: auto;
    padding-bottom: 0;
    scrollbar-width: thin;
  }

  .s5-reader-direct__collection:not(.is-current) {
    display: none !important;
  }

  .s5-reader-direct__collection.is-current > header {
    display: none;
  }

  .s5-reader-direct__collection nav a {
    grid-template-columns: 24px minmax(0, 1fr);
    gap: .08rem .48rem;
    min-height: 48px;
    padding: .5rem .08rem;
  }

  .s5-reader-direct__collection nav a > span {
    align-self: start;
    padding-top: .08rem;
    font-size: .46rem;
  }

  .s5-reader-direct__collection nav a > strong {
    display: -webkit-box;
    overflow: hidden;
    font-size: .59rem;
    line-height: 1.27;
    text-overflow: ellipsis;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .s5-reader-direct__collection nav a > small {
    display: none;
  }

  .s5-reader-direct__collection nav a[aria-current='page'] {
    background: transparent;
    box-shadow: inset 2px 0 0 var(--s5-brand-blue);
  }

  .s5-reader-direct-toggle,
  .s5-reader-direct-overlay {
    display: none !important;
  }
}

@media (min-width: 1760px) {
  body:has(.s5-reader-shell) {
    --s5-reader-frame: 1660px;
    --s5-reader-rail-width: 220px;
    --s5-reader-gap: 44px;
    --s5-reader-canvas: 1280px;
  }
}

@media (max-width: 1319px) {
  body:has(.s5-reader-shell) .s5-reader-direct,
  body:has(.s5-reader-shell) .s5-reader-direct-overlay,
  body:has(.s5-reader-shell) .s5-reader-direct-toggle {
    display: none !important;
  }

  body:has(.s5-reader-shell) .md-header__inner {
    min-height: var(--s5-reader-header-height);
    height: var(--s5-reader-header-height);
  }

  body:has(.s5-reader-shell) .md-main__inner:not(:has(.s5-landing)) .md-content {
    width: min(100%, 960px);
    max-width: none;
    margin-right: auto;
    margin-left: auto;
  }

  body:has(.s5-reader-shell) .md-content__inner {
    padding-right: clamp(1rem, 2.6vw, 1.5rem) !important;
    padding-left: clamp(1rem, 2.6vw, 1.5rem) !important;
  }

  .s5-reader-topbar {
    position: sticky;
    top: var(--s5-reader-header-height);
    z-index: 24;
    display: grid !important;
    grid-template-columns: 46px minmax(0, 1fr) 46px;
    min-height: 44px;
    border: 1px solid var(--s5-line);
    background: color-mix(in srgb, var(--s5-bg) 95%, transparent);
    box-shadow: 0 8px 18px color-mix(in srgb, #000 6%, transparent);
    backdrop-filter: blur(14px);
  }

  .s5-reader-arrow {
    display: flex;
    justify-content: center;
    min-height: 44px;
    padding: .35rem;
  }

  .s5-reader-arrow__copy {
    display: none;
  }

  .s5-reader-course {
    min-height: 44px;
    padding: .3rem .5rem .42rem;
    border-right: 1px solid var(--s5-line);
    border-left: 1px solid var(--s5-line);
  }

  .s5-reader-course strong {
    font-size: .54rem;
  }
}

@media (max-width: 800px) {
  body:has(.s5-reader-shell) {
    --s5-reader-prose: 100%;
    --s5-reader-lead: 100%;
    --s5-reader-header-height: 56px;
  }

  body:has(.s5-reader-shell) .md-main__inner {
    width: 100%;
    max-width: none;
    margin: 0;
  }

  body:has(.s5-reader-shell) .md-main__inner:not(:has(.s5-landing)) .md-content {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body:has(.s5-reader-shell) .md-content__inner {
    width: 100%;
    margin: 0 !important;
    padding-top: 1.35rem;
    padding-right: 20px !important;
    padding-left: 20px !important;
  }

  .s5-reader-context {
    flex-wrap: nowrap;
    gap: .28rem;
    margin-bottom: .62rem;
    font-size: .48rem;
  }

  .s5-reader-context strong {
    min-width: 0;
  }

  body:has(.s5-reader-shell) .md-typeset > h1 {
    max-width: 13ch !important;
    margin-bottom: .68rem !important;
    font-size: clamp(2.25rem, 10.8vw, 2.72rem) !important;
    line-height: .965 !important;
    letter-spacing: -.056em !important;
    overflow-wrap: break-word;
  }

  .s5-reader-shell {
    max-width: 100%;
    margin-bottom: .55rem !important;
  }

  .s5-reader-topbar {
    top: var(--s5-reader-header-height);
    width: 100%;
    margin: 0;
  }

  body:has(.s5-reader-shell) .s5-reader-shell + .sm-wrap {
    margin: .55rem 0 1.75rem;
  }

  body:has(.s5-reader-shell) .s5-reader-shell + .sm-wrap .sm-chips {
    gap: .5rem;
  }

  body:has(.s5-reader-shell) .s5-reader-shell + .sm-wrap .sm-chip {
    font-size: .49rem;
  }

  body:has(.s5-reader-shell) .md-typeset > p,
  body:has(.s5-reader-shell) .md-typeset > li {
    font-size: .87rem;
    line-height: 1.68;
  }

  body:has(.s5-reader-shell) .md-typeset > blockquote:first-of-type {
    margin: .35rem 0 2.2rem;
    padding-left: .72rem;
    font-size: .82rem;
    line-height: 1.58;
  }

  body:has(.s5-reader-shell) .md-typeset > h2 {
    max-width: 18ch;
    margin-top: 3.7rem !important;
    margin-bottom: .9rem !important;
    font-size: clamp(1.6rem, 7.5vw, 1.95rem) !important;
  }

  body:has(.s5-reader-shell) .md-typeset > h3 {
    margin-top: 2.45rem !important;
    font-size: 1.2rem !important;
  }

  body:has(.s5-reader-shell) .anim-brand-shell:has(.anim-brand-shell__viewport > .s5v) {
    width: 100%;
    margin-top: 1.35rem;
    margin-bottom: 3.2rem;
  }

  body:has(.s5-reader-shell) .anim-brand-shell:has(.anim-brand-shell__viewport > .s5v) .anim-brand-shell__toolbar {
    min-height: 28px;
    padding-bottom: 4px;
  }

  body:has(.s5-reader-shell) .s5-video-embed {
    width: 100%;
    margin-top: 1.35rem;
    margin-bottom: 2.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .s5-reader-topbar,
  .s5-reader-direct,
  .s5-reader-map {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
