/**
 * Peak Builder — the front-end stylesheet.
 *
 * Two jobs, and nothing else:
 *
 *  1. Give the three layout boxes what they are BORN with, as `--pkbs-*`
 *     defaults: a fresh Container is a row and a fresh Section a column before
 *     anybody touches them. What the Style rail then sets arrives as REAL
 *     properties in a rule keyed by the element's id — compiled by
 *     Peak_Builder_Style::css(), printed once per page — and that rule, two
 *     selectors deep, outranks the one-class defaults here. Nothing about an
 *     element's styling rides its markup: no inline variables, no flag
 *     classes. (This file once held sixty gated `.pkb-el.pkv-*` rules; the
 *     compiler is that table now.)
 *
 *  2. The few things a property cannot say — the background-video layer, the
 *     per-breakpoint hiding — as ordinary class rules.
 *
 * This file is loaded on the front end AND inside the editor canvas, so what you
 * are editing is styled by exactly the rules the visitor gets.
 *
 * @package Peak_Builder
 */

/* =========================================================================
 * Root + element box
 * ========================================================================= */

/*
 * The Page Content slot of a Single template. On a page it holds the entry —
 * a built one as its own `.pkb-root` — and adds nothing around it. While the
 * TEMPLATE is edited (its canvas, its thumbnail) it draws a skeleton one
 * screen tall in the entry's place, so the template is designed around the
 * space every entry will fill. Editor-only markup; the front end never
 * prints it (Peak_Builder_El_Page_Content).
 */
.peak-page-content__skeleton {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  box-sizing: border-box;
  min-height: 100vh;
  padding: clamp(32px, 8vh, 96px) clamp(24px, 8vw, 120px);
  border: 1px dashed color-mix(in srgb, currentColor 22%, transparent);
  border-radius: 8px;
  color: inherit;
  background:
    repeating-linear-gradient(-45deg, transparent 0 14px, color-mix(in srgb, currentColor 3.5%, transparent) 14px 15px);
}
.peak-page-content__line {
  display: block;
  height: 12px;
  width: 72%;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 10%, transparent);
}
.peak-page-content__line--title {
  height: 28px;
  width: 48%;
  margin-bottom: 10px;
}
.peak-page-content__line--short {
  width: 40%;
}
.peak-page-content__label {
  margin-top: 28px;
  font: 600 13px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.7;
}
.peak-page-content__hint {
  font: 400 13px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  opacity: 0.5;
}

.pkb-root {
  --pkb-gap: 24px;
}

/*
 * A built page never scrolls sideways (2026-10-07). Designs bleed on purpose —
 * a plane 130% wide, a marquee running past the edge, a line drawn off the
 * page — and `body { overflow-x: clip }` in a theme does not stop it: the
 * body's overflow is handed to the VIEWPORT, where `clip` becomes `hidden`,
 * and a hidden viewport still scrolls when told to. A reload restoring the
 * scroll position, a focus, a scrollIntoView — and the page sat ~160px to the
 * left with a gap down its right (Cargonic Homepage B). The page's own roots
 * (the page, its header and footer templates) clip instead: on an element
 * `clip` really clips, makes no scroll container (sticky and pins keep
 * working), and the document is never wider than the window. The canvas is a
 * frame of its own and keeps its chrome at the edges, so it is left out.
 */
html:not(.peak-editing) .pkb-root[data-pkb-root] {
  overflow-x: clip;
}

/*
 * A component instance is the box its parent lays out — a grid cell, a flex
 * item — but the component's own root sits two wrappers further in
 * (`.peak-component` › `.pkb-root--nested`). A root at `height: 100%` resolved
 * against those auto-height wrappers, so a card component stretched into a grid
 * row kept its content height inside a taller cell (Cargonic's partners grid,
 * 2026-09-15). The wrappers pass the instance's height straight through: a
 * percentage of a stretched or sized instance is definite, and of an auto one
 * it is still auto, so an instance in plain flow is unchanged. `:where()` so
 * anything written about them wins.
 */
:where(.pkb-el--component > .peak-component, .peak-component > .pkb-root--nested) {
  height: 100%;
}

/**
 * What every layout box starts from.
 *
 * Both numbers are the SITE's — the options panel's Layout section writes
 * `--peak-box-pad` and `--peak-box-gap`, and the builder's own Layout view
 * mirrors that section, so they can be moved from either place. The literals
 * here are only the fallback for a theme that declares neither.
 *
 * `:where()` has NO specificity, which is the whole point: a default has to
 * lose to everything above it — the Style rail, a Code rail's CSS, a theme's
 * own. A box that could not be un-padded because its own stylesheet outranked
 * the control meant to un-pad it is not a default, it is a decision.
 */
:where(.peak-box) {
  padding-inline: var(--peak-box-pad, 1rem);
  /* The gap every box starts from — the site's, from the same panel section.
     Set here on EVERY box rather than per arrangement, because a box with no
     gap of its own still lays children out with the site's rhythm. */
  --pkbs-gap: var(--peak-box-gap, var(--pkb-gap, 24px));
  /* The rest of the born-with vocabulary, at its CSS default. Custom
     properties INHERIT, and without these a Div inside a wrapping grid would
     read its parent's `--pkbs-*` as its own. */
  --pkbs-fw: nowrap;
  --pkbs-jc: flex-start;
  --pkbs-gtc: none;
}

.pkb-el {
  box-sizing: border-box;
}

.pkb-el *,
.pkb-el *::before,
.pkb-el *::after {
  box-sizing: border-box;
}

/* A box whose HTML Tag is Link. A theme styles `a` as TEXT — inline, a hover
   fade (Peak Starter: `a:hover { opacity: .75 }`), an underline — and none of
   that is what a linked card asked for. Display is a zero-specificity default
   (the box rules above set their own); the rest has to outrank the theme's
   `a:hover` (0,1,1) and still lose to the Style rail's `[data-pkb-id]` rule. */
:where(a.pkb-el) {
  display: block;
}
a.pkb-el {
  color: inherit;
  text-decoration: none;
}
a.pkb-el:hover {
  opacity: 1;
}

/* A linked box with links INSIDE it renders as its own tag plus this cover
   (see Peak_Builder_Render — a link cannot hold a link). The cover takes
   the click anywhere on the box; the links inside sit above it. Without an
   href (the editor drops it) it lets the pointer through to the canvas. */
:where(.pkb-has-cover) {
  position: relative;
}
.pkb-link-cover {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.pkb-link-cover:not([href]) {
  pointer-events: none;
}
:where(.pkb-has-cover) :where(a:not(.pkb-link-cover), button, input, select, textarea, label, summary) {
  position: relative;
  z-index: 2;
}

/* =========================================================================
 * The layout boxes
 *
 * Only a CONTAINER gets an unconditional display/gap, because only a container
 * is a layout box. A leaf element keeps whatever display its own widget CSS
 * gives it.
 *
 * The three boxes share this vocabulary completely — a Section is a Div that
 * also knows about page width, a Container a Div that knows about the site's
 * column — so all three emit `peak-box`. Only the width rules below are a
 * Section's or a Container's alone.
 * ========================================================================= */

/* What a box does before the Style rail says anything. The rail's own
   values arrive as real properties in the element's compiled rule
   (`.pkb-el[data-pkb-id="…"]`, two selectors deep), which outranks this one
   class — so there is no `--pkbx-*` fallback chain here any more. */
.pkb-el--section,
.pkb-el--container,
.pkb-el--div,
.pkb-el--popup,
.pkb-el--collection,
.pkb-el--cms-item,
.pkb-el--cms-empty {
  display: var(--pkbs-d, block);
  flex-direction: var(--pkbs-fd, row);
  flex-wrap: var(--pkbs-fw, nowrap);
  gap: var(--pkbs-gap, 0px);
  align-items: var(--pkbs-ai, stretch);
  justify-content: var(--pkbs-jc, flex-start);
  grid-template-columns: var(--pkbs-gtc, none);
}

/**
 * What each box is born as.
 *
 * A Section and a Div stack: a column with the site's gap, which is what a
 * page does on its own, with a rhythm. A Container opens as a ROW — it is what
 * you reach for when two things must sit beside each other (a logo and a menu,
 * a heading and a button), and stacking is what the Section around it already
 * does. The row folds to a column on a phone.
 *
 * All inside `:where()`: these are defaults, so the Style rail's Display (an
 * inline `--pkbx-*`), a Code rail's CSS and a theme's own all outrank them.
 * A Quick Layout does not rely on any of this — it writes the whole Display
 * document, fold-down included, so the rail shows what the box is doing.
 */
/* A Popup stacks its words and pictures like a Div. */
:where(.pkb-el--popup) {
  --pkbs-d: flex;
  --pkbs-fd: column;
  --pkbs-ai: stretch;
}

:where(.peak-section, .pkb-el--div) {
  --pkbs-d: flex;
  --pkbs-fd: column;
  --pkbs-ai: stretch;
}

/* A Collection's card and its Empty box stack like a Div. */
:where(.pkb-el--cms-item, .pkb-el--cms-empty) {
  --pkbs-d: flex;
  --pkbs-fd: column;
  --pkbs-ai: stretch;
}

/* A Collection is born a three-column grid that folds to two, then one —
   the same fold-down a Quick Layout writes, here as the born-with default
   so a Collection with no style document of its own (a hand-made one, a
   converted one) still lays its cards out. The editor seeds the same values
   into a fresh Collection's style document (default_style), so the rail
   shows them too. */
:where(.pkb-el--collection) {
  --pkbs-d: grid;
  --pkbs-gtc: repeat(3, minmax(0, 1fr));
  --pkbs-ai: stretch;
  padding-inline: 0;
}
@media (max-width: 1024px) {
  :where(.pkb-el--collection) {
    --pkbs-gtc: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 767px) {
  :where(.pkb-el--collection) {
    --pkbs-gtc: repeat(1, minmax(0, 1fr));
  }
}
/* The card and the empty box are Div-shaped: no padding of their own. */
:where(.pkb-el--cms-item, .pkb-el--cms-empty) {
  padding-inline: 0;
}

:where(.peak-container) {
  --pkbs-d: flex;
  --pkbs-fd: row;
  --pkbs-ai: center;
}

@media (max-width: 767px) {
  :where(.peak-container) {
    --pkbs-fd: column;
    --pkbs-ai: stretch;
  }
}

/**
 * Boxed content, full-bleed background.
 *
 * The padding does the constraining: half of whatever is left over after the
 * content width, but never less than the gutter. So the section still stretches
 * edge to edge — its background, its border, its shadow — while the content
 * inside it sits in a centred column. No inner wrapper element, which means the
 * children stay direct kids and flex/grid on the section still lays them out.
 */
/* A band is a positioning context: a badge in a corner, an absolute
   decoration, a pinned overlay all measure from the Section they sit in.
   Born-with, in CSS, so the rail can say Default and mean this — it used to
   be stored on every new Section, which read as "Relative" and opened the
   Offsets on a box nobody had positioned. Zero specificity: Absolute, Fixed
   or Sticky from the rail beats it. */
:where(.peak-section) {
  position: relative;
  /* Born-with room above and below, the site's box padding — CSS only, so
     the rail says Default (2026-09-25). It used to be stored on every new
     Section as pad_t / pad_b 1rem and read as a value somebody had set. */
  padding-block: var(--peak-box-pad, 1rem);
}

:where(.peak-section--boxed) {
  padding-inline: max(
    var(--pkbs-gutter, var(--peak-gutter, 20px)),
    calc((100% - var(--pkbs-cw, 1200px)) / 2)
  );
}

.peak-section--w-wide {
  --pkbs-cw: 1440px;
}
/* "Normal" is the site's own column: the panel's Container Width writes
   --peak-container, so a Section set to Normal lines up with every page the
   builder never touched. The literal is only the fallback for a theme that
   does not declare it. */
.peak-section--w-normal {
  --pkbs-cw: min(var(--peak-container, 1200px), var(--peak-container-max, 100%));
}
.peak-section--w-narrow {
  --pkbs-cw: 860px;
}

/**
 * The Container: a centred column. Its width is the whole of its opinion —
 * no padding, no background of its own — so it can sit inside a full-width
 * Section, a header, a footer, and line their contents up with the site.
 *
 * Every declaration here is inside `:where()`, which has NO specificity. That
 * is the point: these are defaults, and a default has to lose to everything —
 * the panel's own rules, a Code rail's CSS, a theme's. A container that could
 * not be un-centred because its own stylesheet outranked the control that was
 * supposed to un-centre it is not a default, it is a decision.
 */
:where(.peak-container) {
  width: 100%;
  /* 0 auto: centred, and nothing above or below it. */
  margin-block: 0;
  margin-inline: auto;
  /* The site's column, exactly as the panel's Layout draws it for a page the
     builder never touched: Container Width, capped by Container Share. */
  max-width: min(var(--peak-container, 1200px), var(--peak-container-max, 100%));
  /* 1rem on all four sides — the site's box padding, the same token every
     box takes inline. A Container is where content actually sits, so the
     block sides get it too; the Style rail overrides any side (2026-09-11). */
  padding: var(--peak-box-pad, 1rem);
}

/* Boxed — the site's own column, so a container lines up with every page the
   builder never touched. */
:where(.peak-container--w-boxed) {
  max-width: min(var(--peak-container, 1200px), var(--peak-container-max, 100%));
}

/* Custom — a width that was typed. Falls back to Boxed while it is empty, so
   switching to Custom never collapses the column to nothing. */
:where(.peak-container--w-custom) {
  max-width: var(--pkbc-w, var(--peak-container, 1200px));
}

/**
 * The Div Block: a PLAIN box.
 *
 * Full width and nothing else — no centred column, no max-width. That is the
 * whole difference between it and a Container: a Container is an opinion about
 * page width, a Div is a box you put things in. It used to inherit the
 * container's `max-width` through the shared vocabulary, which made a Div
 * inside a wide Section quietly stop at the content column.
 */
:where(.pkb-el--div) {
  width: 100%;
  max-width: none;
  /* And no spacing of its own. Every other box starts with the site's inline
     padding (`--peak-box-pad`, above), because a Section and a Container are
     opinions about how content sits on a page. A Div is not: it is the box you
     reach for when you are deciding the spacing yourself, and 1rem it never
     asked for is 1rem to take off before the first real decision. */
  padding-inline: 0;
  margin: 0;
}

/**
 * Fullwidth — as wide as what it is inside, and no wider.
 *
 * Deliberately NOT a viewport bleed. A container in a boxed Section fills that
 * section's content box; what boxed it is the SECTION, and the Section's own
 * Content Width is where that is undone. A `50% - 50vw` bleed here would take
 * the container past the theme's page wrapper as well as the section's
 * gutters, which is a different thing from "full width" and never what the
 * container was asked for.
 */
:where(.peak-container--w-full) {
  max-width: 100%;
}

/**
 * An Image is as big as its BOX.
 *
 * The Style rail sizes the wrapper — that is the element's one box — but the
 * widget inside it (`.peak-image` → frame → img) kept the picture's own shape:
 * an inline-block whose height was the file's. So a Width of 100% or a Height
 * of 100% landed on a box the picture never filled, and an absolutely placed
 * background image stayed the size of the file (2026-09-15, Cargonic's hero).
 *
 * Now the inside follows the box: the root, the frame, a link or lightbox
 * wrapper and the img all take its width and height, and the picture is FITTED
 * into it (the widget's Fit + Position, cover and centre by default). Nothing
 * stretches by accident, because the box's default width is the picture's own
 * (`fit-content`, capped at the column) — an Image nobody sized looks exactly
 * as it did. A caption keeps its line: the root is a column and the frame takes
 * what is left.
 *
 * `:where()` on the box's default so any rail value wins, and on the frame and
 * the img so the widget's own Ratio / Height rules (peak-widgets.css) do.
 * Builder only — Elementor sizes its own widget wrapper and is left alone.
 */
:where(.pkb-el--image) {
  width: fit-content;
  max-width: 100%;
}
.pkb-el--image > .peak-image {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: none;
}
.pkb-el--image > .peak-image > :where(.peak-image__frame) {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
}
.pkb-el--image > .peak-image > .peak-image__frame > :where(.peak-image__link) {
  height: 100%;
}
.pkb-el--image > .peak-image > .peak-image__frame :where(img) {
  height: 100%;
  object-fit: var(--pki-fit, cover);
  object-position: var(--pki-pos, center center);
}

/* =========================================================================
 * The Style rail
 *
 * Nothing here. Every value the rail can set — padding, display, radius, a
 * shadow, a transform — is compiled to real CSS by Peak_Builder_Style::css()
 * and printed in a rule keyed by the element's id, exactly as a stylesheet a
 * person would write. This file used to hold sixty gated `.pkb-el.pkv-*`
 * rules turning inline `--pkbx-*` variables into properties; both the
 * variables and the gates are gone from the markup.
 * ========================================================================= */

/* A background VIDEO is a layer, not a property: the engine's markup sits
   behind the element's own content and is clipped by its radius. The wrapper
   has to be positioned for that, and one class is all this needs — the
   Position control's value lands in the element's compiled rule, two
   selectors deep, so an element told to be absolute or fixed still is. */
.pkb-el--bgvideo {
  position: relative;
}
.pkb-el__bgvideo {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
  opacity: var(--pkbx-bgv-op, 1);
}
/* The engine draws `.peak-video > .peak-video__stage > …`; a background wants
   all of it filling the box, and `peak-video--cover` (which bg_args_from_doc
   always sets) does the object-fit inside. */
.pkb-el__bgvideo .peak-video,
.pkb-el__bgvideo .peak-video__stage {
  width: 100%;
  height: 100%;
}
/* bg_args_from_doc asks for ratio `auto`, and `.peak-video--auto` lets a
   native/HLS <video> flow at its own height — a 16:9 strip with black under
   it in any box taller than that, Size Cover or not. The media fills the box
   here so object-fit has something to crop to. */
.pkb-el__bgvideo .peak-video .peak-video__media {
  position: absolute;
  inset: 0;
  height: 100%;
}
/* The background's Size and Position, handed to the engine's own properties
   (peak-video.css reads them for a <video>, fitCover() for an iframe). */
.pkb-el__bgvideo {
  --peak-video-fit: var(--pkbx-bgv-fit, cover);
  --peak-video-pos: var(--pkbx-bgv-pos, 50% 50%);
}
/* The content has to come back in front of it. `> *` and not a wildcard: only
   the element's own children move, never anything deeper. The background
   layers themselves are left where they are. Zero specificity: a child's own
   Position and Z-Index (its compiled `.pkb-el[data-pkb-id]` rule) win — the
   old three-`:not()` selector weighed 0,4,0 and pulled an Absolute child
   back to relative (2026-10-06). */
:where(.pkb-el--bgvideo, .pkb-el--bgpar, .pkb-el--bgov) > :where(:not(.pkb-el__bgvideo, .pkb-el__bgpar, .pkb-el__bgov)) {
  position: relative;
  z-index: 1;
}
/* The background's OVERLAY (Peak_Builder_Style::overlay_fields): one layer,
   after the video and the parallax picture in the markup so it lies over
   both, under the content. Colour or gradient, its own opacity and blend. */
.pkb-el--bgov {
  position: relative;
}
.pkb-el__bgov {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  background-color: var(--pkbx-ov, transparent);
  background-image: var(--pkbx-ov-i, none);
  opacity: var(--pkbx-ov-op, 1);
  mix-blend-mode: var(--pkbx-ov-bl, normal);
}
/* …except the video's play / pause button, which is pinned over both. */
.pkb-el--bgvideo > .peak-video-toggle {
  position: absolute;
  z-index: 2;
  --peak-video-toggle-offset: var(--pkbx-bgv-t-off, 16px);
  --peak-video-toggle-size: var(--pkbx-bgv-t-size, 18px);
  --peak-video-toggle-color: var(--pkbx-bgv-t-color, #fff);
}

/* A background PICTURE with parallax (Peak_Builder_Style::layers). The outer
   layer is the box and clips; the inner one is the picture, larger than the
   box by the reach its Strength needs (--pkbx-bgpe, a fraction of the box on
   each side) so the drift never shows an edge. peak-parallax.js moves it. */
.pkb-el--bgpar {
  position: relative;
}
.pkb-el__bgpar {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}
.pkb-el__bgpar-img {
  position: absolute;
  inset: calc(var(--pkbx-bgpe, 0.25) * -100%) 0;
  background-image: var(--pkbx-bgpi, none);
  background-size: var(--pkbx-bgps, cover);
  background-position: var(--pkbx-bgpp, center center);
  background-repeat: no-repeat;
  will-change: transform;
}
.pkb-el__bgpar-img--x {
  inset: 0 calc(var(--pkbx-bgpe, 0.25) * -100%);
}

/* A background layer reads its box's own values, so those values must stop at
   the box: without this a nested element with a video of its own would take
   its parent's Size, and a nested picture its parent's parallax image. Zero
   specificity — an element's compiled rule (two selectors) always wins on the
   element itself. */
:where(.pkb-el) {
  --pkbx-bgv-op: initial;
  --pkbx-bgv-fit: initial;
  --pkbx-bgv-pos: initial;
  --pkbx-bgv-t-off: initial;
  --pkbx-bgv-t-size: initial;
  --pkbx-bgv-t-color: initial;
  --pkbx-bgpi: initial;
  --pkbx-bgps: initial;
  --pkbx-bgpp: initial;
  --pkbx-bgpe: initial;
}

/* =========================================================================
 * Per-device visibility
 *
 * `display: none !important` because it has to beat the element's own display,
 * which may itself arrive from an inline custom property.
 * ========================================================================= */

/* The rules themselves are generated per breakpoint by
   Peak_Builder_Prefs::hide_css() and attached inline to this stylesheet, because
   the widths belong to the site (Peak Builder → Settings), not to this file. */
