/* Fixed accessibility FAB reservation. Other floating layers (journal draggable
   sections, SOS, Menu, Ask, toasts) must stay out of this box and below this z. */
:root {
  --merhav-a11y-z: 58;
  --merhav-a11y-fab-size: 3rem;
  --merhav-a11y-safe-gap: 0.75rem;
  --merhav-a11y-safe-inline-start: max(0.75rem, env(safe-area-inset-inline-start, 0px), env(safe-area-inset-left, 0px));
  --merhav-a11y-safe-block-end: max(5.75rem, calc(env(safe-area-inset-bottom, 0px) + 4.75rem), calc(var(--merhav-a11y-nav-reserve, 0px) + var(--merhav-a11y-safe-gap)));
  --merhav-chrome-block-start: calc(max(8px, env(safe-area-inset-top, 0px)) + var(--merhav-menu-reserve, var(--merhav-sos-reserve, 7.25rem)));
  --merhav-a11y-reserve-inline: calc(var(--merhav-a11y-fab-size) + 44px + 24px + var(--merhav-a11y-safe-inline-start) + var(--merhav-a11y-safe-gap));
  --merhav-a11y-reserve-block: calc(var(--merhav-a11y-fab-size) + var(--merhav-a11y-safe-block-end) + var(--merhav-a11y-safe-gap));
  --merhav-a11y-fab-left: auto;
  --merhav-a11y-fab-top: auto;
  --merhav-a11y-fab-right: auto;
  --merhav-a11y-fab-bottom: auto;
}

@media (min-width: 761px) {
  :root {
    --merhav-a11y-safe-block-end: max(0.75rem, env(safe-area-inset-bottom, 0px), calc(var(--merhav-a11y-nav-reserve, 0px) + var(--merhav-a11y-safe-gap)));
    --merhav-a11y-reserve-block: calc(var(--merhav-a11y-fab-size) + var(--merhav-a11y-safe-block-end) + var(--merhav-a11y-safe-gap));
  }
  /* Visible journal sidebar only. Injected app-nav hides .sidebar, so keep the FAB in the corner. */
  html:not(.merhav-has-app-nav) {
    --merhav-a11y-safe-inline-start: calc(min(280px, 88vw) + 0.75rem);
    --merhav-a11y-reserve-inline: calc(var(--merhav-a11y-fab-size) + 44px + 24px + var(--merhav-a11y-safe-inline-start) + var(--merhav-a11y-safe-gap));
  }
}

@media (max-height: 520px) {
  :root {
    --merhav-a11y-safe-block-end: max(0.75rem, env(safe-area-inset-bottom, 0px), calc(var(--merhav-a11y-nav-reserve, 0px) + var(--merhav-a11y-safe-gap)));
  }
}

html[data-a11y-font] {font-size: calc(16px * var(--a11y-font-scale, 1));}
html[data-a11y-leading='relaxed'] {--a11y-line: 1.7;}
html[data-a11y-leading='wide'] {--a11y-line: 2;}
html[data-a11y-leading] body, html[data-a11y-leading] p, html[data-a11y-leading] li, html[data-a11y-leading] label {
  line-height: var(--a11y-line, 1.7);
}
html[data-a11y-tracking='wide'] body {letter-spacing: 0.08em;}
html[data-a11y-readable] body, html[data-a11y-readable] button, html[data-a11y-readable] input, html[data-a11y-readable] textarea {
  font-family: Arial, Helvetica, "Segoe UI", sans-serif;
}
/* Remap ink/paper so H1, sidebar labels and the language button stay visible.
   Do not filter the html root: that creates a containing block and hides fixed chrome. */
html[data-a11y-contrast],
html[data-a11y-contrast][data-appearance] {
  --m-page: #111111 !important;
  --m-bg: #111111 !important;
  --m-paper: #161616 !important;
  --m-ink: #ffffff !important;
  --m-muted: #e8e8e8 !important;
  --m-line: #d0d0d0 !important;
  --m-primary: #8ec8ff !important;
  --m-on-primary: #111111 !important;
  --m-danger: #ff9b8a !important;
  --appearance-danger: #ff9b8a !important;
  --m-soft: #242424 !important;
  --m-accent: #ffd36a !important;
  --m-focus: #ffe08a !important;
  --m-card-1: #1c1c1c !important;
  --m-card-ink: #ffffff !important;
  --appearance-page: #111111 !important;
  --appearance-paper: #161616 !important;
  --appearance-surface: #161616 !important;
  --appearance-ink: #ffffff !important;
  --appearance-muted: #e8e8e8 !important;
  --appearance-line: #d0d0d0 !important;
  --appearance-primary: #8ec8ff !important;
  --appearance-soft: #242424 !important;
  --appearance-accent: #ffd36a !important;
  --appearance-focus: #ffe08a !important;
  --appearance-card: #1c1c1c !important;
  --appearance-card-ink: #ffffff !important;
  --appearance-on-primary: #111111 !important;
  --appearance-background: #111111 !important;
  --paper: #161616 !important;
  --ink: #ffffff !important;
  --muted: #e8e8e8 !important;
  --line: #d0d0d0 !important;
  --card: #1c1c1c !important;
  --soft: #242424 !important;
  --accent: #ffd36a !important;
  --green: #8ec8ff !important;
  --forest: #8ec8ff !important;
  --wash: #111111 !important;
}
html[data-a11y-contrast],
html[data-a11y-contrast] body {
  background: #111 !important;
  color: #fff !important;
}
html[data-a11y-contrast],
html[data-a11y-contrast] *,
html[data-a11y-contrast] *::before,
html[data-a11y-contrast] *::after {
  transition: none !important;
}
html[data-a11y-contrast] :is(h1, h2, h3, .brand, #jh-title, .jh-title, .jh-welcome h1, .sidebar, .sidebar a, .sidebar .nav, .navitem, .nav-button, .nav, .merhav-app-nav, .merhav-app-nav a, .merhav-app-nav button, .merhav-app-nav .language, .merhav-app-nav-toggle, .btn, .button, button.language, [data-page-language], [data-action="language"]) {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}
html[data-a11y-contrast] :is(.sidebar, .merhav-app-nav, .merhav-app-nav-toggle, .merhav-app-nav .language, .merhav-app-nav a, .merhav-app-nav button, .btn, .button, button.language, [data-page-language], [data-action="language"]) {
  background: #111 !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  border-color: #fff !important;
}
html[data-a11y-invert] {filter: invert(1) hue-rotate(180deg);}
html[data-a11y-mono] {filter: grayscale(1);}
html[data-a11y-contrast][data-a11y-invert],
html[data-a11y-contrast][data-a11y-mono],
html[data-a11y-invert][data-a11y-mono] {
  filter: invert(1) hue-rotate(180deg) grayscale(1) contrast(1.18);
}
html[data-a11y-links] a {
  text-decoration: underline !important;
  outline: 2px solid currentColor;
  outline-offset: 2px;
  background: #fff3a8;
  color: #000;
}
html[data-a11y-headings] h1, html[data-a11y-headings] h2, html[data-a11y-headings] h3,
html[data-a11y-headings] [role='heading'] {
  outline: 3px solid #1a5fb4;
  outline-offset: 4px;
  background: #eaf2ff;
}
html[data-a11y-contrast][data-a11y-headings] h1,
html[data-a11y-contrast][data-a11y-headings] h2,
html[data-a11y-contrast][data-a11y-headings] h3,
html[data-a11y-contrast][data-a11y-headings] [role='heading'] {
  outline-color: #ffd36a;
  background: #0b2a66 !important;
  color: #fff !important;
}
html[data-a11y-cursor], html[data-a11y-cursor] * {cursor: url("cursor.svg") 4 4, auto;}
html[data-a11y-motion='paused'], html[data-a11y-motion='paused'] *,
html[data-a11y-motion='paused'] *::before, html[data-a11y-motion='paused'] *::after {
  animation: none !important;
  animation-play-state: paused !important;
  transition: none !important;
  scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  html, html *, html *::before, html *::after {
    animation: none !important;
    animation-play-state: paused !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
.a11y-date {
  unicode-bidi: isolate;
  white-space: nowrap;
  display: inline-block;
}
/* Default FAB: start column on narrow phones, end column from 761. Keep headings
   out of that slot. !important wins over later page `margin:` shorthand
   (home .jh-welcome h1). Do not inset headings between 361 and 760: wrapping the
   home title there pushes `.jh-primary` under the bottom tabs at 430. */
@media (max-width: 360px) {
  html.merhav-has-a11y :is(h1, .lead) {
    margin-inline-start: calc(var(--merhav-a11y-fab-size) + var(--merhav-a11y-safe-gap) + 8px) !important;
  }
  /* Friends masthead stays full width at 320 (PR117). Do not !important-inset it. */
  html.merhav-has-a11y .letters-page :is(h1, .lead) {
    margin-inline-start: 0 !important;
  }
  /* Help/index/private headings keep readable width; do not also inset the FAB column.
     Leave migrate/username .keys-main > h1 on the FAB-column inset. */
  html.merhav-has-a11y :is(#app, #private-app) h1,
  html.merhav-has-a11y .keys-main .ac-brand h1 {
    margin-inline-start: 0 !important;
  }
}
html.merhav-has-a11y #account-app {
  padding-block-end: calc(var(--merhav-a11y-reserve-block) + 1.25rem);
}
@media (min-width: 761px) {
  html.merhav-has-a11y :is(h1, .lead, .jh-lead, .jh-art-caption, .landscape-label) {
    margin-inline-end: calc(var(--merhav-a11y-fab-size) + var(--merhav-a11y-safe-gap) + 8px) !important;
  }
  html.merhav-has-a11y .letters-page :is(h1, .lead, .jh-lead, .jh-art-caption, .landscape-label) {
    margin-inline-end: 0 !important;
  }
}
html.merhav-has-a11y .a11y-statement {
  box-sizing: border-box;
  /* Keep the cream card out of the FAB column so list bullets never sit under it. */
  margin-inline-start: calc(var(--merhav-a11y-reserve-inline) + 0.75rem) !important;
  padding-block-end: calc(var(--merhav-a11y-reserve-block) + env(safe-area-inset-bottom, 0px) + 3.5rem) !important;
  padding-inline: 1.15rem !important;
  scroll-padding-block-end: calc(var(--merhav-a11y-reserve-block) + env(safe-area-inset-bottom, 0px));
}
html.merhav-has-a11y .a11y-statement :is(ul, ol) {
  list-style-position: inside;
  padding-inline-start: 1.15em;
  padding-inline-end: calc(var(--merhav-a11y-fab-size) + var(--merhav-a11y-safe-gap));
  padding-block-end: 0.5rem;
  margin-inline-start: 0;
  scroll-margin-block-end: var(--merhav-a11y-reserve-block);
}
html.merhav-has-a11y .a11y-statement :is(ul, ol) li {
  scroll-margin-block-end: calc(var(--merhav-a11y-reserve-block) + env(safe-area-inset-bottom, 0px));
}
html.merhav-has-a11y .a11y-statement [data-page-language],
html.merhav-has-a11y .a11y-statement [data-page-language] bdi[data-text-paragraph] {
  white-space: nowrap;
  inline-size: auto;
  width: auto;
}
html[data-a11y-hide-decor] img[alt=''], html[data-a11y-hide-decor] img:not([alt]),
html[data-a11y-hide-decor] [aria-hidden='true'] img, html[data-a11y-hide-decor] .bg-layer,
html[data-a11y-hide-decor] [data-decorative] {display: none !important;}
html[data-a11y-guide] .merhav-a11y-guide {display: block;}
