/* "Atrium" theme chrome for non-CMS patient pages (booking, prescription
   request, intake): a quiet sheet bar over a faintly tinted page, letterspaced
   brand, hairline footer. Same single-token rule as theme.css — every colour is
   derived from --c-accent, which the per-practice override replaces.

   The form itself is an island (@conjunto/ui/island.css) and reads these
   tokens through its own fallback chain: --c-ink becomes the body text,
   --c-surface the card, --c-border the edge of every field. So the same
   pinning theme.css does has to happen here, or the page a patient actually
   fills in is the one place the accent is left free to wreck the contrast. */

:root {
  --c-accent: #1d5c56;

  /* Hue and a share of the chroma follow the accent; the lightness is the
     theme's. A plain mix carries the accent's lightness through instead: at
     14 % of a white accent the footer line came out at 3.83 : 1, and a black
     accent darkened the page until the island's own muted grey failed on it
     (3.98 : 1). The mixes above each are the fallback for browsers without
     relative colour syntax. */
  --c-ink: color-mix(in oklab, var(--c-accent) 18%, #0e1112);
  --c-ink: oklch(from var(--c-accent) 0.22 calc(c * 0.35) h);
  --c-body: color-mix(in oklab, var(--c-accent) 16%, #55595c);
  --c-body: oklch(from var(--c-accent) 0.44 calc(c * 0.22) h);
  --c-soft: color-mix(in oklab, var(--c-accent) 14%, #6b7074);
  --c-soft: oklch(from var(--c-accent) 0.5 calc(c * 0.2) h);

  /* The island's second mandatory token (it names --c-accent and --c-muted as
     the two every theme has). Atrium never set it, so the lead paragraph, the
     hints and the small print on the request form fell back to the island's
     own literal grey — which knows nothing about this page and slipped under
     AA (4.45 : 1) as soon as the accent tinted the paper. */
  --c-muted: var(--c-soft);
  --c-page: color-mix(in oklab, var(--c-accent) 4%, #f6f6f5);
  --c-page: oklch(from var(--c-accent) 0.973 min(c, 0.012) h);
  --c-surface: color-mix(in oklab, var(--c-accent) 2%, #ffffff);
  --c-surface: oklch(from var(--c-accent) 0.995 min(c, 0.006) h);
  --c-line: color-mix(in oklab, var(--c-accent) 12%, #e2e4e5);
  --c-line: oklch(from var(--c-accent) 0.905 min(c, 0.02) h);

  /* Links never rise above the lightness that still passes AA on the card. */
  --c-link: color-mix(in oklab, var(--c-accent) 78%, #12181a);
  --c-link: oklch(from var(--c-accent) min(l, 0.42) c h);

  /* The island reads --c-border *before* --c-line for the edge of a field, so
     the two jobs can be told apart: --c-line stays the faint rule under the
     chrome bar, --c-border is the boundary of a control and has to clear
     3 : 1 (it was 1.24 : 1, an input with no findable edge). */
  --c-border: color-mix(in oklab, var(--c-accent) 22%, #6f7477);
  --c-border: oklch(from var(--c-accent) 0.58 min(c, 0.03) h);

  /* The accent itself, but never lighter than the card can carry — the outline
     of the shapes that *are* the accent. Same token, same cap as theme.css. */
  --c-edge: color-mix(in oklab, var(--c-accent) 74%, #43494b);
  --c-edge: oklch(from var(--c-accent) min(l, 0.55) max(c, 0.02) h);
}

body {
  background: var(--c-page);
  color: var(--c-body);
}

/* Two corrections to the island contract, both anchored on `body` so they
   outweigh it: declared on :root they would lose to inheritance, and at equal
   specificity the island stylesheet loads last and wins. (The same anchor the
   other themes use for their island overrides.)
 *
 * 1. The island paints a link in the raw accent, which is the one colour a
 *    practice may set to anything — a white accent made the privacy link
 *    white on white, 1.00 : 1. The theme's own clamped link tone instead.
 * 2. The label on the primary button flips black/white on the accent's
 *    luminance, but over a ramp 0.001 wide; an accent landing inside it gets
 *    neither (see theme.css). Same rule, steep enough to be a step. */
body .i-page a:not(.i-btn),
body [data-island] a:not(.i-btn) {
  color: var(--c-link);
}

/* The fill stays the practice's colour; only the outline is capped, so a
   near-white accent leaves a button-shaped button instead of a label floating
   on the card (1.00 : 1). Below the cap the outline is the accent, unchanged. */
body .i-page .i-btn--primary,
body [data-island] .i-btn--primary {
  border-color: var(--c-edge);
}

@supports (color: rgb(from red r g b)) and (width: calc(pow(2, 2) * 1px)) {
  body .i-page,
  body [data-island] {
    --i-accent-fg-channel: calc(
      255 * clamp(0, (0.1775 - calc(
        0.2126 * pow((r / 255 + 0.055) / 1.055, 2.4) +
        0.7152 * pow((g / 255 + 0.055) / 1.055, 2.4) +
        0.0722 * pow((b / 255 + 0.055) / 1.055, 2.4)
      )) * 1000000, 1)
    );
    --i-accent-fg: rgb(
      from var(--c-accent) var(--i-accent-fg-channel)
        var(--i-accent-fg-channel) var(--i-accent-fg-channel)
    );
  }
}

.theme-chrome--atrium {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-line);
}

.theme-chrome--atrium .theme-chrome__bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  max-width: 72rem;
  margin-inline: auto;
  padding: 0.75rem 1.5rem;
}

.theme-chrome__logo {
  height: 2.75rem;
  width: auto;
}

.theme-chrome--atrium .theme-chrome__name {
  color: var(--c-ink);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.theme-chrome__footer {
  background: var(--c-surface);
  border-top: 1px solid var(--c-line);
  margin-top: 3rem;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--c-soft);
}
