/*
 * Skin for the elements created by ./overlays.ts (emitted as dist/style.css).
 * Loaded by host pages alongside the IIFE bundle, so the palette is defined
 * here as self-owned `--presence-*` properties with literal values — NOT
 * `--acv-*` tokens: those live only inside the editor's shadow root and never
 * reach the host document these styles apply to.
 *
 * The custom properties double as a theming seam: the editor bundle runs in
 * the host document and knows the design system, so a future caller (CP-496)
 * can re-theme overlays by setting these properties on document.documentElement
 * — no CSS change needed.
 *
 * Class names are a cross-boundary contract: they are defined as constants in
 * src/domain/refresh/overlayNode.ts (`presence-overlay`) and
 * src/domain/refresh/flash.ts (`presence-flash-changed`) — keep in sync.
 * Imported ONLY from src/index.ts: adapters must stay CSS-import-free or the
 * IIFE build would start emitting a stylesheet.
 */
/* stylelint-disable go-transition-tokens/no-literal-transition-values */
:root {
  /* Space-separated RGB triplets, combined with per-rule alphas below.

     The selection blue is the kit's --acv-color-state-focus-primary (#008ce3)
     written out: these styles apply to the host document, and --acv-* tokens
     exist only inside the editor's shadow root (see the file header), so the
     token cannot be referenced here — only tracked. */
  --presence-color-selection: 0 140 227;
  --presence-color-working: 245 158 11;
  --presence-color-context: 107 114 128;
  --presence-color-modified: 34 197 94;

  /*
   * The factor the host has visually scaled this preview by, published by
   * editor/overlayPalette.ts on every editor-state snapshot. Editor chrome
   * renders at 1:1 whatever that factor is (CP-923), so every stroke and radius
   * below divides by it — an outline's *box* still has to track an element that
   * really is scaled, so only the stroke can be compensated, not the geometry.
   *
   * The 1 default is load-bearing: the editor bundle is optional (see
   * editor/loader.ts), and without it nothing publishes a scale — the overlays
   * then render exactly as they did before this existed, rather than collapsing
   * to a zero-width ring.
   */
  --presence-scale: 1;

  /* Stroke and corner per the design's Element selection frames: a 1px edge,
     square. One definition for every overlay family below, so the weight is a
     single edit — the agent-highlight families follow it too, having no
     weight of their own in any design.

     Every family draws it as an `outline`, never a `border`. positionEl in
     ./overlays.ts sizes each overlay to the target's own bounding rect, so a
     border paints inside that rect and covers the outermost pixel of the
     element — the top of its first line of text and the bottom of its last. An
     outline paints outside the box instead, and unlike a border it is
     unaffected by whatever `box-sizing` the host page declares on `*`.
     --presence-radius applies to an outline too. */
  --presence-stroke: calc(1px / var(--presence-scale));
  --presence-radius: 0;
}

@keyframes presence-pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.presence-overlay {
  position: fixed;
  display: none;
  border-radius: var(--presence-radius);
  pointer-events: none;
  transition:
    inset-block-start 0.15s ease,
    inset-inline-start 0.15s ease,
    inline-size 0.15s ease,
    block-size 0.15s ease;
}

#presence-overlay-selected {
  /* Editor-overlay ladder, lowest to highest: agent highlights, hover, selected,
     the toolbar (Toolbar.module.css), then kit dialogs (the portal host in
     main.tsx). These overlays live in the page's light DOM while the toolbar
     lives in the editor shadow root — both compete in the root stacking
     context, so the values must differ or DOM order decides and the outline
     paints over the toolbar. */
  z-index: 2147483645;

  /* A hairline edge over a 10% wash. The Auto-Publish design draws hover and
     selected identically — same stroke, same fill — so the two rules below
     differ only in stacking order, and which one you are looking at is told by
     the toolbar that accompanies a selection, not by the overlay. */
  background: rgb(var(--presence-color-selection) / 0.1);
  outline: var(--presence-stroke) solid rgb(var(--presence-color-selection));
}

#presence-overlay-hover {
  z-index: 2147483644;

  /* Identical to the selected rule above, per the design. The dashed stroke it
     used to carry is gone with it: the Auto-Publish frames draw one solid
     edge for both states, which also retires the unresolved question of how to
     express a dash period CSS derives from the stroke width. */
  background: rgb(var(--presence-color-selection) / 0.1);
  outline: var(--presence-stroke) solid rgb(var(--presence-color-selection));

  /* Enumerated, not `all`: the stroke width is now a scale-derived value, and
     `all` would animate it on every frame of a panel resize. */
  transition:
    inset-block-start 0.1s ease,
    inset-inline-start 0.1s ease,
    inline-size 0.1s ease,
    block-size 0.1s ease;
}

.presence-overlay-agent {
  z-index: 2147483643;
}

.presence-overlay-agent[data-highlight-state='working'] {
  animation: presence-pulse 1.5s ease-in-out infinite;
  background: rgb(var(--presence-color-working) / 0.08);
  outline: var(--presence-stroke) solid rgb(var(--presence-color-working) / 0.8);
}

.presence-overlay-agent[data-highlight-state='context'] {
  background: rgb(var(--presence-color-context) / 0.04);
  outline: var(--presence-stroke) dashed rgb(var(--presence-color-context) / 0.6);
}

.presence-overlay-agent[data-highlight-state='modified'] {
  background: rgb(var(--presence-color-modified) / 0.08);
  outline: var(--presence-stroke) solid rgb(var(--presence-color-modified) / 0.8);
}

/*
 * Transient flash applied to elements the morph changed (opt-in via
 * highlightChanges). A green ring (box-shadow — no layout shift) that fades over
 * ~1.2s; the bridge removes the class on animationend.
 */
@keyframes presence-flash-fade {
  from {
    box-shadow:
      0 0 0 var(--presence-stroke) rgb(var(--presence-color-modified) / 0.9),
      0 0 calc(10px / var(--presence-scale)) calc(3px / var(--presence-scale))
        rgb(var(--presence-color-modified) / 0.55);
  }

  to {
    box-shadow:
      0 0 0 var(--presence-stroke) rgb(var(--presence-color-modified) / 0),
      0 0 calc(10px / var(--presence-scale)) calc(3px / var(--presence-scale))
        rgb(var(--presence-color-modified) / 0);
  }
}

.presence-flash-changed {
  animation: presence-flash-fade 1.2s ease-out forwards;
}

/*
 * The block being edited in place (CP-499; attribute set by
 * src/adapters/dom/editing.ts — keep the name in sync). The selection overlay
 * already outlines it; the UA focus ring would double that ring. The text
 * cursor signals "type here" — edit mode drops the body-wide crosshair
 * (select-mode affordance), so the armed block declares its own.
 */

[data-presence-editing] {
  cursor: text;
}

[data-presence-editing]:focus {
  outline: none;
}

/*
 * A link inside a heading keeps the heading's type (CP-886). Copied sites
 * routinely declare type on every link — the mirror demo's own stylesheet
 * carries `a { font-size: 1rem; font-weight: 400 }` — and an explicit
 * declaration beats inheritance, so linking a word inside an <h1> dropped it
 * from 48px/800 to 16px/400. That happens to any anchor in a heading,
 * including one added by hand in wp-admin; the editor writes a bare anchor and
 * is not the cause.
 *
 * Plain declarations, no !important: the rule wins on specificity against a
 * bare `a { font-size }` (0,0,2 vs 0,0,1), and a site rule more specific than
 * that keeps its say — its own design decision, not ours to override. On the
 * mirror demo that means the type inherits while `.page-main a:not(.btn)`
 * (0,2,1) still sets the colour.
 */

:is(h1, h2, h3, h4, h5, h6) a {
  color: inherit;
  font: inherit;
  -webkit-text-decoration: underline;
  text-decoration: underline;
}
/*$vite$:1*/