/* =============================================================================
   Arccos content stylesheet — /_arccos/content.css

   The platform's styles for PAGE CONTENT, as opposed to header.css's styles for
   the preset header. Served by serve (embedded, content-hashed like header.css),
   linked by composeDocument BEFORE theme CSS, and imported raw by the admin so
   the editor canvas, the View iframe and the published page style one class list
   from one file (docs/site-style.md § Content stylesheet).

   TWO RULES ABOUT WHAT MAY GO IN HERE:

   1. Its selectors are a DOM contract a theme may write against, and everything
      it declares a theme must be able to override — hence `:where()` on every
      selector but `:root`, which gives them zero specificity.
   2. The admin scopes this sheet into its Edit canvas by rewriting `:root` to
      `:scope` inside an `@scope ([data-arccos-canvas])` block
      (main/src/lib/contentPreviewCss.ts). An `html` or `body` selector would
      have nothing to be rewritten to and would leak onto the admin chrome
      around the canvas, so THERE ARE NONE — pinned by that file's test.

   The derived tokens and the accessibility floor come first; the `.ac-btn`
   rules are at the bottom.
   ============================================================================= */

/* The derived tokens (docs/site-style.md § Derived tokens). Platform DEFAULTS,
   not decisions: each is a var() chain off the site's own slots, with the
   literal the block sheets already carried as the final fallback — so an unset
   site renders exactly what it rendered before this file existed. A theme may
   pin any of them directly; a theme link loads after this sheet.

   --arccos-color-surface is deliberately absent: the slot token IS the name the
   blocks already read, so the site emits it directly and the blocks' own
   `var(--arccos-color-surface, #ffffff)` fallback stands. */
:root {
  --arccos-color-brand: var(--arccos-color-1, #1f6feb);
  --arccos-color-text: var(--arccos-color-ink, #16191d);
  /* Mixed toward the site's own surface rather than toward white: a district
     with a warm off-white ground gets warm muted text and warm hairlines, which
     is the whole reason color_surface is a slot. */
  --arccos-color-muted: color-mix(in srgb, var(--arccos-color-ink, #16191d) 70%, var(--arccos-color-surface, #fff));
  --arccos-color-border: color-mix(in srgb, var(--arccos-color-ink, #16191d) 14%, var(--arccos-color-surface, #fff));
}

/* THE ACCESSIBILITY FLOOR — platform-owned, and deliberately NOT a knob.
   Hover is a site decision (all three hover knobs off is a legitimate site);
   keyboard visibility is not, because a keyboard or switch user never sees
   hover at all. A theme that wants a different ring overrides this at any
   specificity; a theme that sets none inherits a visible one.

   This is a visible change on every published page whose theme set no focus
   style, which is the point. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--arccos-color-3, var(--arccos-color-1, #1d4ed8));
  outline-offset: 2px;
}

/* The other half of the floor. The hover knobs are emitted as token values whose
   off state is zero, so nothing here has to branch — this only makes sure a site
   that turned motion ON does not force it on a reader who asked for less. */
@media (prefers-reduced-motion: reduce) {
  :where(a, button) {
    transition: none;
  }
}

/* =============================================================================
   BUTTONS — the link mark with three attributes (docs/site-style.md § Buttons)

   The three axes compose: one rule per fill, per width, per color, never one
   per combination — 5×2×2 buttons cost the nine rules below. That is the whole
   reason the mark carries a role and not a class list; the Finalsite model this
   replaces grew a class per combination of fill × corners × hover × width.

   `--ac-btn-bg` / `--ac-btn-ink` are the seam. The color rules are the only
   thing that sets them and everything else reads them, so appending color_6 to
   the palette registry is two more lines here and nothing else anywhere.
   ============================================================================= */

/* SOLID and HUG are the base. `data-fill="solid"` and `data-width="hug"` are
   data the mark round-trips, not selectors — there is nothing for them to
   declare that this rule has not. */
:where(.ac-btn) {
  /* The two ends of the palette, resolved once. --arccos-color-text is this
     sheet's own alias for the ink slot and so always resolves; the surface slot
     has no alias by design (§ Derived tokens) and carries its fallback on the
     consumer, exactly as the block sheets do. */
  --ac-ink: var(--arccos-color-text);
  --ac-surface: var(--arccos-color-surface, #ffffff);

  position: relative; /* the hover underline below is an absolute ::after */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55em 1.1em;
  /* Present on a SOLID button too, in its own fill color: it is invisible
     there, and it keeps the two fills exactly the same size, so switching an
     authored button from solid to outline does not reflow the paragraph. */
  border: 2px solid var(--ac-btn-bg);
  border-radius: var(--arccos-radius, 0.5rem);
  background: var(--ac-btn-bg);
  color: var(--ac-btn-ink);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

/* The five color slots. An unset brand slot degrades to --arccos-color-brand,
   which is this sheet's `var(--arccos-color-1, #1f6feb)` — so the chain always
   terminates in a real color and a button on a themeless site is never
   invisible (§ Palette: nothing ever resolves to transparent). The two neutrals
   are each other's ink, which is what makes them useful inside a callout or a
   banner already painted in a brand color. */
:where(.ac-btn[data-color="1"]) {
  --ac-btn-bg: var(--arccos-color-1, var(--arccos-color-brand));
  --ac-btn-ink: var(--arccos-color-1-ink, var(--ac-surface));
}
:where(.ac-btn[data-color="2"]) {
  --ac-btn-bg: var(--arccos-color-2, var(--arccos-color-brand));
  --ac-btn-ink: var(--arccos-color-2-ink, var(--ac-surface));
}
:where(.ac-btn[data-color="3"]) {
  --ac-btn-bg: var(--arccos-color-3, var(--arccos-color-brand));
  --ac-btn-ink: var(--arccos-color-3-ink, var(--ac-surface));
}
:where(.ac-btn[data-color="ink"]) {
  --ac-btn-bg: var(--ac-ink);
  --ac-btn-ink: var(--ac-surface);
}
:where(.ac-btn[data-color="surface"]) {
  --ac-btn-bg: var(--ac-surface);
  --ac-btn-ink: var(--ac-ink);
}

/* Outline keeps the stroke at the slot's FULL strength rather than a tint: the
   3:1 non-text contrast an outline button lives or dies by is then the
   district's own color decision, not something this sheet quietly weakened. */
:where(.ac-btn[data-fill="outline"]) {
  background: transparent;
  color: var(--ac-btn-bg);
}

/* Offered only when the link is its paragraph's sole content — the popover
   enforces that. A stretched button beside running text is a layout primitive
   pretending to be prose, and the CTA block is where that belongs. */
:where(.ac-btn[data-width="full"]) {
  display: flex;
  width: 100%;
}

/* Hover reads the SITE's three knobs, and each knob's OFF state is the token's
   own zero (§ Knobs) — so none of these rules branches, and a site with all
   three off gets a button that simply does not react. */
:where(.ac-btn):hover {
  /* The token's ON value is already negative, so no sign flip here. */
  transform: translateY(var(--arccos-hover-lift, 0px));
}
/* :not([data-fill="outline"]) rather than [data-fill="solid"], because solid is
   the base: a button written by hand or by the API with only data-color set is
   a solid one and must shade like one. */
:where(.ac-btn:not([data-fill="outline"])):hover {
  /* Toward the button's own INK, not toward black: a dark fill lightens and a
     light fill darkens, from one declaration. */
  background-color: color-mix(in srgb, var(--ac-btn-bg), var(--ac-btn-ink) var(--arccos-hover-shade, 12%));
}
:where(.ac-btn[data-fill="outline"]):hover {
  background-color: color-mix(in srgb, transparent, var(--ac-btn-bg) var(--arccos-hover-shade, 12%));
}

/* The underline knob as a bar, not `text-decoration`: on a solid button the
   text sits on its own fill, where an underline reads as a mistake, and
   text-decoration cannot sweep. scaleX(0) is both the resting state and what
   the knob emits when the district turns it off. */
:where(.ac-btn)::after {
  content: "";
  position: absolute;
  left: 1.1em;
  right: 1.1em;
  bottom: 0.4em;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.15s;
  pointer-events: none;
}
:where(.ac-btn):hover::after {
  transform: scaleX(var(--arccos-hover-underline, 0));
}
/* The floor's reduced-motion guard is declared ABOVE this section and carries
   the same zero specificity, so source order alone hands the win to the base
   rule's `transition:` — the hover lift would animate for exactly the reader
   the floor exists for. The button restates the guard here, after its own
   rules; the ::after bar needs its own line because `:where(a, button)` cannot
   reach a pseudo element at all. */
@media (prefers-reduced-motion: reduce) {
  :where(.ac-btn),
  :where(.ac-btn)::after {
    transition: none;
  }
}

/* The floor's ring is --arccos-color-3, which is invisible on a color-3 button.
   A button rings in its own color instead; the offset keeps it off the fill. */
:where(.ac-btn):focus-visible {
  outline: 2px solid var(--ac-btn-bg);
  outline-offset: 2px;
}

/* The island frame (docs/islands.md § Frame): what every `<arccos-island>`
   looks like while it is not yet drawn. The loader sets `data-state` and fills
   the frame; these rules give the placeholder its standard height from the
   first paint, before any script has run, and keep that height through a
   failure so nothing below it moves. Empty and ready take their content's
   height. `--arccos-island-height` is the one knob; a theme may set it. */
:where(arccos-island) {
  display: block;
  /* The failed state's padding must sit inside the standard height, or a
     failure grows the placeholder by it and moves the page. */
  box-sizing: border-box;
}
:where(arccos-island:not([data-state]), arccos-island[data-state="loading"], arccos-island[data-state="failed"]) {
  min-height: var(--arccos-island-height, 12rem);
  border-radius: var(--arccos-radius, 8px);
  background: color-mix(in srgb, var(--arccos-color-muted, #5b636d) 6%, transparent);
}
/* Media-shaped islands (the month grid) hold the grid's proportions instead of
   the standard height. After the rule above, which it must override. */
:where(arccos-island[shape="grid"]:not([data-state="ready"], [data-state="empty"])) {
  min-height: 0;
  aspect-ratio: 7 / 6;
}
:where(arccos-island[data-state="failed"]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  text-align: center;
}
:where(.arccos-island-note) {
  margin: 0;
  color: var(--arccos-color-muted, #5b636d);
  font-size: 0.875rem;
}
/* The Retry sits on the site's surface, not on the frame's tint: brand text is
   chosen to read on the surface, and the tint alone drops the default brand
   under WCAG AA's 4.5:1. */
:where(.arccos-island-retry) {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--arccos-color-brand, #1f6feb);
  background: var(--arccos-color-surface, #fff);
  border: 1px solid currentColor;
  border-radius: var(--arccos-radius, 8px);
  padding: 0.25rem 0.75rem;
  cursor: pointer;
}

/* =============================================================================
   RENDERER-EMITTED CONTENT — images, the banner hero, the gallery
   (docs/publish-contract.md § Banner hero, § Gallery)

   Rules identical on every page that uses them, so they live in this cached
   sheet rather than in a <style> inside each page's published_html. Values that
   are one page's own stay inline: site tokens, the layout grid, column widths,
   component custom CSS. Rule 1 holds — every selector is `:where()`, so a theme
   or a component's custom CSS wins — and rule 2: no `html` selector, hence the
   `:root:has()` form of the hero's clip.
   ============================================================================= */

/* The <img> carries width/height to reserve space, so height:auto is required
   or a width-constraining theme distorts it. object-fit is a no-op at
   height:auto; once a theme fixes the box it crops around the focal point the
   <img> carries as object-position (docs/media.md § Per-use edits). */
:where(.arccos-img img){max-width:100%;height:auto;object-fit:cover}
/* The text schema's image node: the same reserved box, inside running text. */
:where(.arccos-block-text img){max-width:100%;height:auto}
/* The video block (docs/media.md § The video block and the player). 16:9 holds the box before the
   poster loads, since `preload="none"` reads no dimensions. */
:where(.arccos-video video){display:block;width:100%;height:auto;aspect-ratio:16/9;background:#000}

/* `100vw` is the viewport INCLUDING a classic (non-overlay) vertical scrollbar,
   so the hero's breakout runs past the body's content box and adds a horizontal
   scrollbar that clips its left edge. Clipping at the root removes it; `clip`
   (not `hidden`) makes no scroll container, so the sticky header keeps
   sticking. `:has()` keeps it to pages that carry a hero. */
:where(:root:has(.arccos-hero)){overflow-x:clip}
/* `width:100vw` + the negative margin breaks the hero out of a constrained
   <main> to the viewport edges without theme cooperation. */
:where(.arccos-hero){position:relative;width:100vw;margin-inline:calc(50% - 50vw);overflow:hidden}
:where(.arccos-hero-media){display:block;width:100%;height:min(60vh,40rem);object-fit:cover}
:where(.arccos-hero-caption){position:absolute;inset-inline:0;bottom:0;padding:2rem clamp(1rem,5vw,4rem);background:linear-gradient(transparent,rgba(0,0,0,.65));color:#fff}
:where(.arccos-hero-title){margin:0;font-size:clamp(1.5rem,4vw,2.5rem);line-height:1.1}
:where(.arccos-hero-description){margin:.5rem 0 0;font-size:clamp(1rem,2vw,1.25rem);max-width:50rem}
/* Hero video pause and sound buttons (renderer hero.ts). 44px targets (WCAG
   2.5.5). scroll-margin-top keeps a focused button out from under a sticky
   header when keyboard focus scrolls it into view: the hero script overrides
   it with the preset header's measured height + 1rem. This value is the no-JS
   fallback, the tallest preset header as drawn (8.6rem, a tiered preset at
   desktop, uncondensed) + 1rem. The glyph shown follows aria-pressed, which
   the hero script keeps in step with the video. */
:where(.arccos-hero-controls){position:absolute;inset-inline-start:1rem;bottom:1rem;z-index:1;display:flex;gap:.5rem}
:where(.arccos-hero-control){width:44px;height:44px;padding:0;border:0;border-radius:50%;background:rgba(0,0,0,.6);color:#fff;display:grid;place-items:center;cursor:pointer;scroll-margin-top:9.75rem}
:where(.arccos-hero-control:focus-visible){outline:2px solid #fff;outline-offset:2px}
:where(.arccos-hero-control svg){width:20px;height:20px}
:where(.arccos-hero-control[aria-pressed=true] .arccos-hero-icon-idle,.arccos-hero-control[aria-pressed=false] .arccos-hero-icon-pressed){display:none}
/* The caption spans the hero's foot; lift its text clear of the buttons. */
:where(.arccos-hero:has(.arccos-hero-controls) .arccos-hero-caption){padding-bottom:4.75rem}

/* Structure only. Every dimension is a THEME token with a fallback, never a
   setting; --arccos-card-measure is the one the posts and events grids read
   too (docs/blocks-runtime.md § The display axis). After the base image rule,
   which it must override at equal specificity. */
:where(.arccos-gallery){display:grid;gap:var(--arccos-space,1rem)}
:where(.arccos-gallery-grid){grid-template-columns:repeat(auto-fill,minmax(var(--arccos-card-measure,16rem),1fr))}
:where(.arccos-gallery-rows){grid-template-columns:1fr}
:where(.arccos-gallery figure){margin:0}
:where(.arccos-gallery img){max-width:100%;height:auto;display:block;object-fit:cover;border-radius:var(--arccos-radius,.5rem)}

/* =============================================================================
   A READABLE VERSION'S ORIGINAL LINK (docs/accessibility.md § Readable version)

   The link is the site's own button (.ac-btn above); this only pins its
   paragraph to the corner, so it stays in reach while a parent scrolls a long
   document. It is the last child of <main>, inside the landmark. The bottom
   padding keeps the pinned button from covering the end of the content.
   ============================================================================= */
:where(.arccos-original){position:fixed;inset-inline-end:var(--arccos-space,1rem);inset-block-end:var(--arccos-space,1rem);z-index:10;margin:0}
:where(.arccos-main:has(> .arccos-original)){padding-block-end:4rem}
