/* ========================================
   Utility Styles
   MGH ED Patient Hub
   ======================================== */

/* ========================================
   Reduced Motion Preference
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .zone-info-panel {
    transition: none;
  }
}

/* ========================================
   Visually Hidden (Screen reader only)
   ======================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ========================================
   Press feedback (2026-11-06)
   One look for every button, so a press reads the same everywhere:
   - a faint neutral shade on white or clear buttons (grey in light mode,
     soft white in dark; never a colour). 5% keeps every real text pair
     at 7.1:1 or better in both themes (computed, not eyeballed).
   - the same slight shrink, 0.97, on every button. Coloured buttons keep
     their colour and only shrink. The rules that set a press scale where
     the button is styled (ios.css, screens.css, map.css, components.css,
     ed-screen-tour.css) all use 0.97 too.
   Rows that open (FAQ questions, steps, cards) and links in the text show
   nothing: opening is the feedback (Alvin, 2026-11-06).
   Here, after components/ios/screens, so it wins without selector tricks.
   ======================================== */

:root {
  --press-shade: color-mix(in srgb, var(--text) 5%, transparent);
}

.ios-btn--ghost:active,
.ios-tile:active,
.ios-pill:active,
.ios-filter-pill:not([aria-pressed="true"]):active,
.team-tile__head:active,
.test-tile__head:active,
.ed-tab:not(.is-active):active,
.theme-choice__btn:active,
.font-size-step:active,
.scroller-arrow:active,
.map-zoom-btn:active,
.map-header-btn:active,
.map-close-btn:active,
.ed-tour__back:active,
.ed-tour__restart:active,
.ed-tour__hit:active,
.ios-settings-close:active,
.zone-info-close:active,
.emergency-banner__dismiss:active,
.translate-restore-btn:active,
.ios-top-back:active,
.language-modal-btn:active {
  background-image: linear-gradient(var(--press-shade), var(--press-shade));
}

@media (prefers-reduced-motion: no-preference) {
  .ios-btn:active,
  .ios-filter-pill:active,
  .zone-btn:active,
  .ed-tour__next:active,
  .ed-tour__back:active,
  .ed-tour__restart:active,
  .ios-settings-close:active,
  .zone-info-close:active,
  .emergency-banner__dismiss:active,
  .update-refresh-btn:active,
  .translate-restore-btn:active,
  .map-close-btn:active,
  .font-size-step:active {
    transform: scale(0.97);
  }
}

/* Controls are not reading text: a long press must not select the label or
   open the copy menu. Everything people read stays selectable. */
summary,
button:not(.inline-link),
.ios-btn,
.ios-tile,
.ios-dock__link,
.ios-pill {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ========================================
   Print Styles
   ======================================== */

/* Print-only provenance line: hidden on screen, stamped by main.js at print
   time so paper copies carry the site name, URL, and print date. */
.print-provenance {
  display: none;
}

@media print {
  /* beforeprint opens every <details> (main.js print support); the reveal
     animations that normally accompany an open must never leave a printed
     page snapshotted mid-fade. */
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .print-provenance {
    display: block !important;
    font-size: 11px;
    color: #000;
    border-bottom: 1px solid #000;
    padding-bottom: 4px;
    margin-bottom: 12px;
  }

  .site-header,
  .map-overlay,
  .skip-link,
  #map-btn,
  /* iOS-shell chrome: the fixed dock repeats over content on every printed
     page, and banners/decoration waste ink on discharge/imaging printouts. */
  .ios-dock,
  .footer-skyline,
  .ios-settings-overlay,
  .language-modal-overlay,
  .scroller-arrow,
  #app-update-banner,
  #site-status-banner,
  /* The dock's fade scrim is position: fixed, so print repeats it at the
     foot of EVERY page, greying out whatever line it lands on (measured
     2026-10-07: it faded the "Getting home" tile on the After Your Visit
     printout). */
  .dock-fade,
  .page-transition-ghost,
  /* Buttons do nothing on paper; this one is the "Print or save this page"
     button itself (render.js addPrintButton). */
  .print-page-row,
  .translate-restore-btn,
  /* Google Translate's own widgets. Already hidden on screen
     (components.css); named here so the printout never depends on that. */
  #google_translate_element,
  .skiptranslate,
  .goog-te-banner-frame,
  #goog-gt-tt {
    display: none !important;
  }

  /* Black on white. The app's grey page, tinted cards and pink warning box
     cost ink (or vanish, when "print backgrounds" is off) and can make grey
     text too faint on paper. Scoped to the page content and footer so the
     emergency banner keeps its drawn icon if it is ever printed. */
  html,
  body {
    background: #fff !important;
    color: #000 !important;
  }

  main#main-content,
  main#main-content *,
  .site-footer,
  .site-footer * {
    background-color: transparent !important;
    background-image: none !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  /* The "Return to the ED or call 911 if" box is marked by its fill on
     screen; with the fill gone, a solid border keeps it standing out. */
  .content-card--warning {
    border: 2px solid #000 !important;
  }

  /* The translation warning prints once, so the caveat travels with the translation. */
  .translate-disclaimer:not([hidden]) {
    position: static !important;
    background: #fff !important;
    color: #000 !important;
    border: 1px solid #000;
    padding: 4px 8px;
    margin-bottom: 12px;
  }

  .translate-disclaimer:not([hidden]) * {
    color: #000 !important;
  }

  /* The hero band prints as a solid color block; flatten it. */
  .ios-section-hero {
    background: none !important;
    color: #000 !important;
  }

  /* Keep each checklist row, tile and card whole across a page break. */
  .ios-checklist-item,
  .ios-tile,
  .content-card,
  .list-card,
  .feature-card,
  .dodont,
  .site-footer {
    break-inside: avoid;
  }

  h1,
  h2,
  h3,
  h4,
  .ios-kicker {
    break-after: avoid;
  }

  body {
    font-size: 12pt;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }

  /* Only web addresses are worth printing after a link. An in-page link
     prints as "(#getting-home)", which means nothing on paper; phone and
     email links already show the number or address as their own text. */
  a[href^="#"]::after,
  a[href^="tel:"]::after,
  a[href^="mailto:"]::after,
  a[href^="javascript:"]::after {
    content: none;
  }
}

/* ========================================
   High Contrast Mode
   ======================================== */

@media (forced-colors: active) {
  .zone-card,
  .test-card {
    border: 1px solid ButtonText;
  }

  /* Selected states lose their fill here; a system-colour outline carries them. */
  .ios-dock__link[aria-current="page"],
  .ed-tab[aria-selected="true"],
  .ios-filter-pill[aria-pressed="true"] {
    outline: 3px solid Highlight;
    outline-offset: -3px;
  }
}

/* ========================================
   Reduced Transparency Preference
   Fallback to opaque backgrounds when
   user prefers reduced transparency.
   ======================================== */

@media (prefers-reduced-transparency: reduce) {
  .zone-info-panel,
  .language-modal {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background-color: var(--glass-bg-opaque);
  }
}

/* ========================================
   Backdrop Filter Fallback
   For browsers that do not support
   backdrop-filter (graceful degradation).
   ======================================== */

@supports not (backdrop-filter: blur(1px)) {
  .zone-info-panel {
    background-color: var(--bg);
  }

  .language-modal {
    background-color: var(--bg);
  }

}
