/* ===========================================================================
   My Melior — design token contract, v1
   ---------------------------------------------------------------------------
   Contract artefact. Governed, versioned, owned by the shell team.
   Specification: DESIGN-TOKENS.md    Vocabulary extends: WebComponentExample

   HOW TO USE THIS FILE
   --------------------
   iframe / navigate apps:
       <link rel="stylesheet" href="https://melior.example/contract/v1/tokens.css">
     Custom properties do NOT cross an iframe boundary, so linking this is the
     only way an embedded app gets the defaults — and it is what covers FIRST
     PAINT, which no message can. Runtime changes then arrive as the
     `theme-changed` message (PROTOCOL.md 3.1); apply those to your own :root.

   webcomponent embeds:
       Nothing to do. Custom properties DO cross a shadow boundary, so these
       are inherited from the shell root automatically.

   DISTRIBUTION
   ------------
   Served from the shell origin on a MAJOR-versioned path, Cache-Control:
   no-cache with an ETag. Within v1 the VALUES may change (a rebrand) and every
   app picks them up on its next load with no redeploy. A breaking change to the
   VOCABULARY ships at /contract/v2/tokens.css and both stay live.

   Do NOT vendor a copy of this file. Do NOT add a cache-busting query string —
   the path already revalidates and yields a cheap 304.

   RULES (DESIGN-TOKENS.md 3)
   --------------------------
   T1  Drive every colour, radius and focus style from a token.
   T2  Never rename, add or drop a token unilaterally.
   T3  Set base tokens; never set a derived one.
   T4  Change values, never names.
   T5  Tokens are the entire shared styling surface, in both directions.
   =========================================================================== */

:root {

  /* --- Typography ------------------------------------------------------- */
  --component-font: Montserrat, ui-sans-serif, system-ui, -apple-system,
                    'Segoe UI', Roboto, sans-serif;

  /* --- Brand / chrome --------------------------------------------------- */
  /* Navy. Separate from --component-ink (which is text) even though the value
     matches today, so a rebrand can move chrome without moving body text.     */
  --component-brand: #0F2C4C;
  --component-brand-contrast: #FFFFFF;              /* 14.1:1 — AAA */

  /* --- Accent — INTERACTIVE -------------------------------------------- */
  /* Amber. Things the user ACTS ON: active state, counts, links, badges.
     White on this is 2.5:1 and FAILS AA. Prototype V2 draws it anyway, on
     purpose, and DESIGN-TOKENS.md 5 records that as a SIGNED-OFF EXCEPTION
     covering exactly two pairs. So --component-accent-contrast is a live token
     rather than a trap, and the exception does not extend to any other fill.  */
  --component-accent: #E48F3B;
  --component-accent-contrast: #FFFFFF;

  /* --- Accent secondary — IDENTITY ------------------------------------- */
  /* Red-orange. Things that ARE something: avatar, current-app chip, map pins.
     Not interchangeable with --component-accent; V1 is consistent about the
     distinction and swapping them reads as broken without being nameable.
     White on this is 4.1:1 — the second half of the same accepted exception.  */
  --component-accent-secondary: #DF492C;
  --component-accent-secondary-contrast: #FFFFFF;

  /* --- Surfaces --------------------------------------------------------- */
  --component-page: #F9FAFB;             /* page background, behind surfaces  */
  --component-surface: #FFFFFF;          /* cards, panels                     */
  --component-surface-sunken: #F1F5F9;   /* insets, wells, medallions         */
  --component-ink: #0F2C4C;              /* headings, primary text — 14.1:1   */
  --component-text: #374151;             /* body text that is NOT a heading   */
  --component-muted: #64748B;            /* secondary / meta — 4.8:1          */
  --component-faint: #9CA3AF;            /* placeholders, disabled — 2.5:1,   */
                                         /* below AA BY DESIGN: never the     */
                                         /* only place information appears    */
  --component-border: #E5E7EB;           /* hairlines                         */
  --component-border-strong: #E2E8F0;    /* control and card borders          */

  /* --- Semantic --------------------------------------------------------- */
  /* Deliberately darker than the usual defaults: each clears 4.5:1 against
     BOTH white and --component-page, so one token works as a filled badge and
     as body text. The brighter alternatives (#16A34A, #D97706) sit at ~3.2:1
     against white and fail both ways.
     --component-warning is NOT --component-accent: they look similar and mean
     opposite things, and a warning in the interactive accent is invisible AS a
     warning.                                                                  */
  --component-danger: #DC2626;           /* white on this: 4.8:1 — AA         */
  --component-danger-contrast: #FFFFFF;
  --component-success: #15803D;          /* white on this: 5.0:1 — AA         */
  --component-warning: #B45309;          /* white on this: 5.0:1 — AA         */

  /* --- Shape and focus -------------------------------------------------- */
  --component-radius: 14px;              /* cards                             */
  --component-radius-sm: 8px;            /* controls, chips, inputs           */
  --component-focus: #E48F3B;            /* focus ring                        */
  --component-focus-width: 2px;

  /* --- DERIVED — do not set these -------------------------------------- */
  /* Set the base; these follow. That is what makes a rebrand one value rather
     than four. color-mix() is in the stated browser baseline; where it is
     absent these states lose their colour and everything else still renders —
     the documented degradation, unchanged from COMPONENT-CONTRACT.md.         */
  --component-accent-hover:
      color-mix(in srgb, var(--component-accent) 86%, #000);
  --component-accent-soft:
      color-mix(in srgb, var(--component-accent) 12%, var(--component-surface));
  --component-accent-line:
      color-mix(in srgb, var(--component-accent) 40%, var(--component-surface));
  --component-accent-secondary-hover:
      color-mix(in srgb, var(--component-accent-secondary) 86%, #000);
}

/* ---------------------------------------------------------------------------
   Focus visibility is a contract requirement, not a style preference.
   Tabbing from the shell's rail into an app and having the indicator change
   shape, change colour or vanish is the clearest possible signal that this is
   not one product — and for a keyboard user it is not cosmetic.

   `outline: none` without a replacement is a CONFORMANCE FAILURE.
   --------------------------------------------------------------------------- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: var(--component-focus-width) solid var(--component-focus);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
   DARK MODE IS NOT IN v1.
   V1 is light-only and per todo C.3 the prototype governs the design, so dark
   mode arrives when a prototype version brings it.

   What IS decided is the shape it will take, because getting that wrong is
   expensive to undo: there will be NO --component-*-dark variants. A theme is
   one complete set of values for the SAME token names, and switching swaps the
   values. An app that follows T1 gets dark mode for free on the day the shell
   publishes a dark value set; an app that hard-codes #FFFFFF for its panels
   gets a white slab in a dark shell, and finds out on that day.

   Do NOT add a prefers-color-scheme block here speculatively — a half-derived
   dark palette that nobody designed is worse than none.
   --------------------------------------------------------------------------- */
