@layer mobileHeaderPreview {
  html:root {
    --aligned-gutter-left: max(4vw, env(safe-area-inset-left));
    --aligned-gutter-right: max(4vw, env(safe-area-inset-right));
    --header-bottom-cut: min(4px, var(--masthead-bottom));
    --heading-gap-cut: 5px;
    --card-heading-gap: calc(clamp(19.6px, 5.6vw, 33.6px) - var(--heading-gap-cut));
    --top-trim: calc(3.5px + var(--header-side) - var(--aligned-gutter-left));
    --test-header-height: calc(var(--masthead-top) + var(--masthead-row) + var(--controls-gap) + var(--controls-row) + var(--masthead-bottom) - var(--header-bottom-cut) - var(--top-trim));
  }

  html:root #site-header .header-inner {
    padding-inline: calc(var(--aligned-gutter-left) + .5vw) calc(var(--aligned-gutter-right) + .5vw) !important;
    grid-template-rows: calc(var(--masthead-row) - var(--top-trim)) var(--controls-row) !important;
    padding-block-end: calc(var(--masthead-bottom) - var(--header-bottom-cut)) !important;
  }
  html:root .header-wrapper-2026, html:root #site-header {
    width: 100% !important;
    left: 0 !important;
    transform: none !important;
  }
  html:root #site-header .header-logo {
    width: 100% !important;
    justify-content: flex-start !important;
    translate: 0 calc(var(--top-trim) / -2);
  }
  html:root #site-header .header-logo-text {
    flex: none;
    font-size: 17vw !important;
    /* The transformed text extends into the controls. Its link owns the tap target. */
    pointer-events: none;
  }
  html:root #site-header :is(#header-lang-btn, #header-theme-btn) {
    width: 44px !important;
  }
  html:root #site-header #header-lang-btn {
    justify-self: start !important;
  }
  html:root #site-header #header-theme-btn {
    justify-self: end !important;
  }
  html:root:not([data-masthead-sticky]) #site-header #mobile-menu-btn {
    width: max-content !important;
    justify-self: center !important;
  }
  html:root .ribbon .ribbon-copy {
    padding-block-start: var(--card-heading-gap) !important;
  }
  html:root #site-home .ribbon[data-wheel-study=aligned] {
    --minimum-frame: calc(var(--test-header-height) + var(--top-trim) + var(--header-bottom-cut) + 77vw + 175px);
    --below-fold: max(0px, calc(var(--minimum-frame) - var(--hero-stable-height, 100svh)));
    min-height: calc(var(--minimum-frame) - var(--home-toolbar-height, 0px)) !important;
    /* Include the former 9px caption padding in the controls row so the
       carousel keeps its height and the row starts at the text itself. */
    grid-template-rows: minmax(0, 1fr) auto auto calc(44px + 9px + var(--top-trim) + var(--header-bottom-cut) + var(--heading-gap-cut)) !important;
  }
  html:root .ribbon[data-wheel-study=aligned] .ribbon-subtext {
    padding-block-end: 0 !important;
  }
  html:root .ribbon[data-wheel-study=aligned] .ribbon-controls {
    align-self: start;
    block-size: max(44px, calc(100% + var(--hero-stable-bottom, 4px) - var(--below-fold)));
    /* The buttons are centered in the row. Move them up to the 45% mark. */
    translate: 0 -5% !important;
  }
  .ribbon .hero-countdown {
    flex: none;
    inline-size: 5ch;
    padding-inline-end: 8px !important;
    text-align: end;
    font: 700 13.5px/1 'Google Sans', Arial, sans-serif;
    font-variant-numeric: tabular-nums;
    color: #000;
  }
  html[data-hero-theme=dark] .ribbon .hero-countdown { color: #fff; }
  /* All three 44px buttons keep their hit areas. Anchor the outer ink edges
     and split the remaining space equally around the active 32px pill. */
  html:root .ribbon[data-wheel-study=aligned] .ribbon-dots {
    /* Four equal ink gaps: (132px rail + two 8px side offsets - 32px pill - two dots) / 4. */
    --outer-inset: calc((132px + 16px - 32px - 2 * var(--indicator-size)) / 4 - 8px);
    --dot-offset: calc(22px - var(--outer-inset) - var(--indicator-size) / 2);
    --middle-offset: calc((32px - var(--indicator-size)) / 2);
  }
  html:root .ribbon[data-wheel-study=aligned] .ribbon-dots button:first-of-type span {
    translate: calc(-1 * var(--dot-offset)) 0 !important;
  }
  html:root .ribbon[data-wheel-study=aligned] .ribbon-dots button:last-of-type span {
    translate: var(--dot-offset) 0 !important;
  }
  html:root .ribbon-dots:has(button:first-of-type[aria-pressed=true]) button:nth-of-type(2) span {
    translate: var(--middle-offset) 0;
  }
  html:root .ribbon-dots:has(button:last-of-type[aria-pressed=true]) button:nth-of-type(2) span {
    translate: calc(-1 * var(--middle-offset)) 0;
  }
  html:root .ribbon[data-wheel-study=aligned] .ribbon-pill {
    left: var(--outer-inset) !important;
    translate: calc(var(--dot, 0) * (50px - var(--outer-inset))) -50% !important;
  }
  html:root .ribbon .ribbon-pause::after {
    justify-self: start;
    margin-inline-start: 8px;
    transform: none !important;
  }
  /* Anchor the artwork to the held size. Follow the expanding card with
     translations so its layout coordinates stay fixed during autoplay. */
  html:root .ribbon[data-wheel-study=aligned] .ribbon-face[data-artwork=portrait] > img {
    left: calc(var(--held-width) / 2) !important;
    transform: translateX(var(--art-offset-x, 0px)) !important;
  }
  html:root .ribbon[data-wheel-study=aligned] .ribbon-face[data-artwork=statue] > img {
    left: calc(var(--held-width) / 2 - var(--art-width) * var(--anchor-x)) !important;
    transform: translateX(var(--art-offset-x, 0px)) !important;
  }
  html:root .ribbon[data-wheel-study=aligned] .ribbon-papers {
    left: calc(var(--held-width) / 2 - var(--paper-width) * .415) !important;
    top: calc(var(--held-height) / 2 - var(--paper-width) * .5) !important;
    translate: calc(var(--art-offset-x, 0px) + var(--paper-width) * .055 * var(--paper-open, 0)) var(--art-offset-y, 0px);
  }
}
