/* ========================================
   iOS-styled primitives for the Patient Hub redesign
   Warm off-white body, cream cards, MGH-green accent
   ======================================== */

body.ios-mode {
  background: var(--ios-bg-body);
  color: var(--ios-ink);
}

/* In ios-mode: hide legacy accordion headers (the section is now a full screen)
   and force accordion-content to render regardless of its `hidden` attribute. */
.ios-mode .accordion-heading { display: none; }
.ios-mode .accordion-content[hidden] {
  display: block !important;
}
.ios-mode .accordion-content {
  padding: 0;
}
.ios-mode .home-section { background: var(--ios-bg-body); }
.ios-mode .site-footer {
  padding: 0.75rem 1rem;
  background: transparent;
  border-top: 1px solid var(--ios-border);
  font-size: 0.8125rem;
  color: var(--ios-muted);
  text-align: center;
  margin-bottom: 6rem; /* space for floating dock */
}
/* Last-reviewed date renders in the shared site footer on every tab
   (Home used to duplicate it - that block was removed from renderHome). */

.ios-mode .site-header,
.ios-mode .site-footer,
.ios-mode main#main-content {
  max-width: 402px;
  margin-left: auto;
  margin-right: auto;
}

/* -------- Top bar (ED badge + label + EN + gear) -------- */
.ios-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-xs) var(--space-xs);
  background: var(--ios-bg-body);
}

.ios-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  color: inherit;
  border-radius: var(--border-radius-sm);
  /* Left padding matches the card insets below. Cards sit at 16px from the
     viewport: 8px from `.accordion-body` padding + 8px from each card's own
     `var(--space-xs)` margin. Brand starts inside the top-bar's 8px left
     padding, so we add another 8px here to reach 16px. */
  padding: 0.25rem 0.25rem 0.25rem var(--space-xs);
}

.ios-brand:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
}

.ios-brand-label {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.ios-brand-kicker {
  font-size: var(--type-kicker);
  letter-spacing: var(--tracking-kicker);
  text-transform: uppercase;
  font-weight: 700;
  /* MGH brand green. Uses the deeper --ios-accent-strong (#4A7A28 in light
     theme) instead of --ios-accent (#76B043) so the uppercase 13px small
     text still meets WCAG AA contrast on the cream top bar. */
  color: var(--ios-accent-strong);
}

.ios-brand-subtitle {
  font-size: 0.9375rem;
  color: var(--ios-ink);
  font-weight: 500;
}

.ios-top-actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.ios-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: 36px;
  min-width: 44px;
  padding: 0 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--ios-bg-card);
  color: var(--ios-ink);
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid var(--ios-border);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.ios-pill svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.75;
}

.ios-pill:hover {
  background: var(--ios-bg-nested);
}

.ios-pill:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
}

.ios-pill--icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
}

.ios-pill--icon svg {
  width: 20px;
  height: 20px;
}

/* -------- Kicker (all-caps section label) -------- */
.ios-kicker {
  font-size: var(--type-kicker);
  font-weight: 600;
  letter-spacing: var(--tracking-kicker);
  text-transform: uppercase;
  color: var(--ios-kicker);
  margin: 0 0 0.5rem;
  padding: 0 var(--space-xs);
}

/* -------- Welcome card / hero on Home -------- */
.ios-hero {
  background: var(--ios-bg-card);
  border: 1px solid var(--ios-border);
  border-radius: var(--radius-card);
  padding: 1.75rem 1.5rem;
  margin: 0 var(--space-xs) var(--space-md);
  box-shadow: var(--shadow-card);
}

.ios-hero__kicker {
  font-size: var(--type-kicker);
  letter-spacing: var(--tracking-kicker);
  text-transform: uppercase;
  color: var(--ios-kicker);
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.ios-hero__title {
  font-size: var(--type-hero);
  line-height: 1.15;
  margin: 0 0 0.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ios-ink);
}

.ios-hero__desc {
  font-size: var(--type-body);
  line-height: 1.45;
  color: var(--ios-muted);
  margin: 0 0 1.25rem;
}

.ios-hero__ctas {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  align-items: flex-start;
}

.ios-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 48px;
  padding: 0 1.25rem;
  border-radius: var(--radius-pill);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.ios-btn:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
}

.ios-btn--primary {
  background: var(--ios-ink);
  color: #FFFFFF;
}

.ios-btn--primary:hover {
  transform: translateY(-1px);
}

.ios-btn--ghost {
  background: transparent;
  color: var(--ios-ink);
  border-color: var(--ios-border);
}

.ios-btn--ghost:hover {
  background: var(--ios-bg-nested);
}

.ios-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}

/* -------- Home tile grid -------- */
.ios-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 0 var(--space-xs);
  margin: 0 0 var(--space-md);
}

@media (max-width: 360px) {
  .ios-tiles { grid-template-columns: 1fr; }
}

.ios-tile {
  background: var(--ios-bg-card);
  border: 1px solid var(--ios-border);
  border-radius: var(--radius-tile);
  padding: 1rem 1rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 150px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
}

.ios-tile:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}

.ios-tile:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
}

.ios-tile__icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-check);
  background: var(--ios-accent-soft);
  color: var(--ios-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ios-tile__icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.75;
}

.ios-tile__title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--ios-ink);
  line-height: 1.2;
  margin: 0.25rem 0 0;
}

.ios-tile__subtitle {
  font-size: 0.9375rem;
  color: var(--ios-muted);
  margin: 0;
  flex-grow: 1;
}

.ios-tile__chev {
  position: absolute;
  right: 0.875rem;
  bottom: 0.75rem;
  color: var(--ios-muted);
  opacity: 0.6;
}

/* -------- Feedback card -------- */
.ios-feedback {
  background: var(--ios-bg-card);
  border: 1px solid var(--ios-border);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  margin: 0 var(--space-xs) var(--space-sm);
}

.ios-feedback__header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.75rem;
}

.ios-feedback__header svg {
  width: 20px;
  height: 20px;
  color: var(--ios-accent);
}

.ios-feedback__title {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
  color: var(--ios-ink);
}

.ios-feedback__desc {
  font-size: var(--type-body);
  color: var(--ios-muted);
  margin: 0 0 1rem;
  line-height: 1.45;
}

.ios-feedback__cta {
  display: flex;
  justify-content: center;
}

.ios-feedback__cta .ios-btn--primary {
  width: 100%;
  justify-content: center;
}

.ios-feedback__cta .ios-btn[aria-disabled="true"] {
  cursor: not-allowed;
  background: var(--ios-muted);
  opacity: 0.6;
}

.ios-feedback__divider {
  height: 1px;
  background: var(--ios-divider);
  margin: 1rem 0;
}

.ios-feedback__phone {
  font-size: 0.9375rem;
  color: var(--ios-muted);
  line-height: 1.5;
  margin: 0;
}

.ios-feedback__phone a {
  color: var(--ios-ink);
  font-weight: 600;
  text-decoration: none;
}

.ios-feedback__phone a:hover {
  text-decoration: underline;
}

/* "More information" link renders inline at the end of the phone paragraph. */
.ios-feedback__more-info {
  color: var(--ios-accent);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 150ms ease;
  white-space: nowrap;
}

.ios-feedback__more-info:hover,
.ios-feedback__more-info:focus-visible {
  border-bottom-color: currentColor;
}

.ios-feedback__more-info:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
  border-radius: 4px;
}

/* Screen-title headings (h1 with `data-screen-title`) are given `tabindex="-1"`
   and focused programmatically on tab switch so keyboard users resume below the
   title. They are not interactive, so suppress the generic focus-visible ring
   that would otherwise draw a green box around the title after each nav. */
.ios-mode [data-screen-title]:focus,
.ios-mode [data-screen-title]:focus-visible {
  outline: none;
}

/* -------- Bottom tab bar (dock) -------- */
.ios-dock {
  position: fixed;
  bottom: max(0.25rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  gap: 0.125rem;
  padding: 0.375rem;
  background: rgba(250, 247, 242, 0.92);
  border: 1px solid var(--ios-border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-tab);
  width: min(calc(100% - 2rem), 370px);
  justify-content: space-between;
}

@supports (backdrop-filter: blur(10px)) {
  .ios-dock {
    background: rgba(250, 247, 242, 0.7);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
  }
}

[data-theme="dark"] .ios-dock {
  background: rgba(30, 30, 30, 0.88);
}

@supports (backdrop-filter: blur(10px)) {
  [data-theme="dark"] .ios-dock {
    background: rgba(30, 30, 30, 0.55);
  }
}

.ios-dock__link {
  flex: 1 1 0;
  min-width: 0;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  padding: 0.375rem 0.25rem;
  border-radius: var(--radius-pill);
  color: var(--ios-muted);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 500;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.ios-dock__link:hover {
  color: var(--ios-ink);
}

.ios-dock__link:focus-visible {
  outline: var(--focus-outline);
  outline-offset: -3px;
}

.ios-dock__link svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.75;
}

.ios-dock__link[aria-current="page"] {
  background: var(--ios-bg-nested);
  color: var(--ios-accent);
}

[data-theme="dark"] .ios-dock__link[aria-current="page"] {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ios-accent);
}

.ios-dock__link[data-sub-page="true"]::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ios-accent);
}

.ios-dock__link {
  position: relative;
}

/* Dock clearance is handled by .site-footer margin-bottom; no extra
   padding on main (it only opens a gap before the footer). */

/* -------- In-header back affordance (non-Home tabs) -------- */
.ios-top-back {
  display: none;
  align-items: center;
  gap: 0.5rem;
}

.ios-top-back .ios-pill--icon {
  background: var(--ios-bg-card);
}

.ios-top-back__label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ios-ink);
  text-decoration: none;
}

.ios-top-back__label:hover {
  color: var(--ios-ink);
  text-decoration: underline;
}

.ios-top-back__label:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
  border-radius: var(--border-radius-sm);
}

/* Swap: brand shows on Home, back-affordance shows on every other tab.
   tab-bar.js sets body[data-current-tab] each time a tab activates. */
body:not([data-current-tab="home"]) .ios-brand { display: none; }
body:not([data-current-tab="home"]) .ios-top-back { display: flex; }

/* -------- Section hero (title + subtitle) -------- */
.ios-section-hero {
  padding: var(--space-sm) var(--space-xs) var(--space-sm);
}

.ios-section-hero__kicker {
  font-size: var(--type-kicker);
  font-weight: 600;
  letter-spacing: var(--tracking-kicker);
  text-transform: uppercase;
  color: var(--ios-kicker);
  margin: 0 0 0.375rem;
}

.ios-section-hero__title {
  font-size: var(--type-hero);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
  color: var(--ios-ink);
}

.ios-section-hero__subtitle {
  font-size: var(--type-body);
  line-height: 1.45;
  color: var(--ios-muted);
  margin: 0;
}

/* -------- Gear popover / settings sheet -------- */
.ios-gear-menu {
  position: fixed;
  top: 4.5rem;
  right: 1rem;
  z-index: 80;
  background: var(--ios-bg-card);
  border: 1px solid var(--ios-border);
  border-radius: var(--radius-tile);
  box-shadow: var(--shadow-card);
  min-width: 240px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ios-gear-menu[hidden] { display: none; }

.ios-gear-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ios-gear-title {
  font-size: var(--type-kicker);
  letter-spacing: var(--tracking-kicker);
  text-transform: uppercase;
  color: var(--ios-kicker);
  font-weight: 600;
  margin: 0;
}

.ios-gear-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--border-radius-sm);
  background: transparent;
  border: 1px solid var(--ios-border);
  color: var(--ios-ink);
  font-size: 0.9375rem;
  cursor: pointer;
  min-height: 44px;
}

.ios-gear-row:hover {
  background: var(--ios-bg-nested);
}

/* -------- Section body content inset (visual parity with cards) -------- */
.ios-mode .accordion-body {
  padding: 0 var(--space-xs);
}

/* -------- Helper for hidden but kept-in-DOM elements -------- */
.ios-hidden {
  display: none !important;
}

/* -------- Respect prefers-reduced-motion -------- */
@media (prefers-reduced-motion: reduce) {
  .ios-tile,
  .ios-btn--primary,
  .ios-pill {
    transition: none;
  }
}
