/* ============================================================================
   CareLink — components
   ----------------------------------------------------------------------------
   Every rule here mirrors a component override in admin/lib/theme.ts, so the
   marketing site and the portal stay visually in step. The class names are
   framework-agnostic on purpose: each block below maps 1:1 to a component when
   this site moves to React/Astro/etc.

     .btn      → MuiButton          .card     → MuiCard + MuiCardContent
     .chip     → MuiChip            .site-header → MuiAppBar + MuiToolbar
   ========================================================================== */

/* ── Button (MuiButton) ────────────────────────────────────────────────────
   Admin ramp, reproduced exactly: 8px radius, 600 weight, no text-transform,
   no elevation, 120ms transitions, 4px brand focus ring.
     sm  3px 10px / 0.8125rem      md  6px 14px / 0.875rem (default)
     lg  9px 18px / 0.9375rem
   ------------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--cl-space-2);
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: var(--cl-radius-button);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.75;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--cl-transition-control),
    border-color var(--cl-transition-control), box-shadow var(--cl-transition-control);
}

.btn:hover {
  text-decoration: none;
}

.btn--sm {
  padding: 3px 10px;
  font-size: 0.8125rem;
}

.btn--lg {
  padding: 9px 18px;
  font-size: 0.9375rem;
}

.btn--primary {
  background: var(--cl-navy);
  color: var(--cl-white);
}

.btn--primary:hover {
  background: var(--cl-navy-dark);
}

.btn--outlined {
  background: var(--cl-surface);
  border-color: var(--cl-border-strong);
  color: var(--cl-navy);
}

.btn--outlined:hover {
  border-color: var(--cl-gray-40);
  background: var(--cl-hover-tint);
}

/* On navy bands the outlined button inverts rather than punching a white hole. */
.section--brand .btn--outlined,
.btn--on-brand {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.4);
  color: var(--cl-white);
}

.section--brand .btn--outlined:hover,
.btn--on-brand:hover {
  border-color: var(--cl-white);
  background: rgba(255, 255, 255, 0.08);
}

.btn--block {
  width: 100%;
}

/* ── Card (MuiCard + MuiCardContent) ──────────────────────────────────────
   12px radius, 1px weak border, Paste shadowLow, 160ms surface transition.
   Padding is one step up from the portal's dense 16px — marketing copy needs
   the room, and 24px is the next stop on the same 8px scale.
   ------------------------------------------------------------------------ */

.card {
  background: var(--cl-surface);
  border: 1px solid var(--cl-border);
  border-radius: var(--cl-radius-card);
  box-shadow: var(--cl-shadow-low);
  padding: var(--cl-space-5);
  transition: box-shadow var(--cl-transition-surface),
    border-color var(--cl-transition-surface);
}

.card--interactive:hover {
  border-color: var(--cl-border-strong);
  box-shadow: var(--cl-shadow-high);
}

.card h3,
.card h4 {
  margin-bottom: var(--cl-space-2);
}

.card p {
  line-height: 1.7;
}

/* Card set — one grid for every card collection on the site. */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--cl-space-5);
}

/* ── Icon tile ────────────────────────────────────────────────────────────
   The rounded-square brand tile the portal uses for stat/section icons,
   replacing the old 80px gradient circles.
   ------------------------------------------------------------------------ */

.icon-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: var(--cl-space-4);
  border-radius: var(--cl-radius-card);
  background: var(--cl-cream);
  font-size: 1.5rem;
  line-height: 1;
}

/* ── Chip (MuiChip) ───────────────────────────────────────────────────────── */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--cl-space-2);
  padding: 2px 10px;
  border-radius: var(--cl-radius-pill);
  background: var(--cl-hover-tint-strong);
  color: var(--cl-navy);
  font-size: 0.8125rem;
  font-weight: 500;
}

/* ── Site header (MuiAppBar + MuiToolbar) ─────────────────────────────────
   Light surface rather than the portal's navy bar: the brand mark is the
   full-colour gradient icon, which needs a light background to read.
   Height matches the portal's compact 56px toolbar.
   ------------------------------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: block;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--cl-border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--cl-space-5);
  min-height: var(--cl-header-h);
}

.site-header__brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.site-header__brand:hover {
  text-decoration: none;
}

.site-header__logo {
  height: 32px;
  width: auto;
}

.site-header__nav {
  display: flex;
  align-items: center;
  gap: var(--cl-space-1);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-header__link {
  padding: 6px 12px;
  border-radius: var(--cl-radius-button);
  color: var(--cl-text-weak);
  font-size: 0.875rem;
  font-weight: 600;
  transition: background-color var(--cl-transition-control),
    color var(--cl-transition-control);
}

.site-header__link:hover {
  color: var(--cl-navy);
  background: var(--cl-hover-tint);
  text-decoration: none;
}

/* Active page marker — the portal's cream selected state. */
.site-header__link[aria-current='page'] {
  color: var(--cl-navy);
  background: var(--cl-cream);
}

/* ── Site footer ──────────────────────────────────────────────────────────
   Navy band, identical on every page. The year is rendered by the component
   so it can never drift out of date.
   ------------------------------------------------------------------------ */

.site-footer {
  display: block;
  background: var(--cl-navy);
  color: var(--cl-text-on-brand);
  padding-block: var(--cl-space-7);
  text-align: center;
}

.site-footer__logo {
  width: 64px;
  height: auto;
  margin: 0 auto var(--cl-space-5);
}

.site-footer__nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--cl-space-1);
  margin-bottom: var(--cl-space-5);
}

.site-footer__link {
  padding: 4px 12px;
  border-radius: var(--cl-radius-button);
  color: var(--cl-white);
  font-size: 0.875rem;
  font-weight: 600;
  transition: background-color var(--cl-transition-control);
}

.site-footer__link:hover {
  background: rgba(255, 255, 255, 0.1);
  text-decoration: none;
}

.site-footer__meta {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.72);
}

.site-footer__meta + .site-footer__meta {
  margin-top: var(--cl-space-1);
}

.site-footer__tagline {
  margin-top: var(--cl-space-5);
  font-style: italic;
  color: var(--cl-coral);
}

/* Reserve the chrome's height before the components upgrade, so the page
   doesn't jump on load. */
site-header:not(:defined) {
  display: block;
  min-height: var(--cl-header-h);
  border-bottom: 1px solid var(--cl-border);
}

site-footer:not(:defined) {
  display: block;
  min-height: 280px;
  background: var(--cl-navy);
}

/* ── Reveal-on-scroll ─────────────────────────────────────────────────────
   Opt-in via [data-reveal]; main.js adds .is-visible. Elements stay visible
   if JavaScript never runs.
   ------------------------------------------------------------------------ */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.js [data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .js [data-reveal] {
    opacity: 1;
    transform: none;
  }
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .site-header__inner {
    gap: var(--cl-space-3);
  }

  .site-header__nav {
    gap: 0;
  }

  .site-header__link {
    padding: 6px 8px;
    font-size: 0.8125rem;
  }
}

/* Keep all four links on one row down to the narrowest phones — a wrapped nav
   pushes the header past the height the layout reserves for it. */
@media (max-width: 400px) {
  .site-header__inner {
    gap: var(--cl-space-2);
  }

  .site-header__link {
    padding: 6px 5px;
    font-size: 0.75rem;
  }
}
