/* ============================================================
   buttons.css — buttons, text links and their icons
   ============================================================
   The clickable things. The native Bricks Button gets its hover lift
   here; icons on buttons and text links come from the element's Icon
   field (house SVG set) and get their size, gap and hover motion here.
   Conventions: _shared/bricks-builder/css-conventions.md

   Contents
     1. Button elevation — hover and press
     2. Icons on buttons and text links
     3. Text links — no underline at rest
     4. Editor notice — a component button without a link
   The hero's button behaviour (family hover, wash on a photo, full-
   width row) lives in components/hero.css.

   Last updated: 2026-10-07 (auto-stamped by the pre-commit hook)
   ============================================================ */


/* ------------------------------------------------------------
   1. Button elevation — hover and press
   ------------------------------------------------------------
   The hover lift, set once on the native `.brxe-button` and on a form's
   send button, so every button moves the same way (no class needed). In CSS because it's a two-layer shadow the Bricks Button
   field can't express — so keep that field's hover-shadow EMPTY.
   ------------------------------------------------------------ */

/* Keyboard focus lifts too, so the focus ring is not the only signal —
   the same pattern as the card, the header button and the other nine
   components that show their hover look on :focus-visible (§6.5). */
.brxe-button:is(:hover, :focus-visible),
.brxe-form .bricks-button:is(:hover, :focus-visible) {
    box-shadow: var(--elevation-button-hover);
    /* Rises with the shadow, like the card and the gallery figure
       (tokens.css §6; Katrine, 19-09-2026). The Button Theme Style's
       Transition field already animates it. */
    transform: translateY(calc(-1 * var(--lift-hover)));
}

/* Pressed: the lift drops away, so the button sinks back into the page
   while it is held down — the same press language as the card and the
   image figure, which both return to their resting shadow (Katrine's
   choice, 12-09-2026). A button has no resting shadow, so its rest is
   none.
   Must stay AFTER the :hover rule: a pressed button is hovered too, and
   the two selectors weigh the same, so source order decides. */
.brxe-button:active,
.brxe-form .bricks-button:active {
    box-shadow: none;
    transform: none;   /* pressed: settles back into the page */
}


/* ------------------------------------------------------------
   2. Icons on buttons and text links
   ------------------------------------------------------------
   An icon comes from the element's own Icon field, picked from the
   house set "UX-designer" (Icon Manager); Bricks inlines the SVG file.
   Button: …Label<svg>. Text Link: <span class="icon"><svg></span>
   <span class="text">Label</span> — its Position field (Left/Right)
   flips the order with flex-direction. The file's own root class
   (.icon--arrow-right etc.) is what the rules below key on.
   The old .cta--* classes (CSS-drawn icons) were retired 15-09-2026:
   one way to add an icon, the field. Icon standard:
   canon/architecture-decisions/ikon-standard.md
   ------------------------------------------------------------ */

/* Size: the house minimum is --icon-s (24 px), never the text's 1em —
   a 16 px arrow beside 16 px text read too small (Katrine, 14-09-2026).
   Theme Styles has no icon-size field for Button or Text Link, so this
   is the site default; an element's own Icon size field writes an
   id-scoped rule and still wins. Direct child only: the form's loading
   spinner is an <svg> inside span.loading and keeps its own size. */
.bricks-button > svg,
.brxe-text-link .icon > svg {
    block-size: var(--icon-s);
    inline-size: auto;
    flex-shrink: 0;
    transition: transform var(--transition-fast);   /* the hover nudge below */
}

/* A text link with an icon: the house gap between icon and words (not
   Bricks' per-element 5 px — keep the Gap field EMPTY, it would win),
   exactly as wide as its words and icon so the empty space beside it is
   never a link (width: fit-content — align-self would block
   .items-center), and the 24 px tap-target floor (WCAG 2.5.8) kept
   explicit even though the 24 px icon already gives it. */
.brxe-text-link:has(.icon) {
    gap: var(--icon-gap);
    width: fit-content;
    min-block-size: 1.5rem;
}

/* Icon side inside a component (a hero's third action): the Position
   field is repeated as a class by inc/text-link-icon-position.php,
   because Bricks writes the field as CSS on a selector every instance of
   the component shares. Two classes beat that shared rule either way. */
.brxe-text-link.icon-before { flex-direction: row; }
.brxe-text-link.icon-after  { flex-direction: row-reverse; }

/* The hover underline belongs under the words, never under the icon.
   The Theme Style underline runs across the whole flex link, so kill it
   on the link and put it on the .text span. */
.brxe-text-link:has(.icon):is(:hover, :focus-visible) {
    text-decoration: none;
}
.brxe-text-link:has(.icon):is(:hover, :focus-visible) .text {
    text-decoration: underline;
}

/* Hover motion — directional icons only, keyed on the file's class, on
   buttons and text links alike (the transition sits in the size rule
   above). New icon animation = one rule here; icons without a rule
   simply stay still. */
.bricks-button:hover > .icon--arrow-right,
.brxe-text-link:hover .icon--arrow-right { transform: translateX(0.15em); }
.bricks-button:hover > .icon--arrow-down,
.brxe-text-link:hover .icon--arrow-down  { transform: translateY(0.15em); }

/* Reduced motion: drop the nudge and the lift, keep the icon and the
   shadow. */
@media (prefers-reduced-motion: reduce) {
    .brxe-button:is(:hover, :focus-visible),
    .brxe-form .bricks-button:is(:hover, :focus-visible) {
        transform: none;
    }

    .bricks-button > svg,
    .brxe-text-link .icon > svg {
        transition: none;
    }

    .bricks-button:hover > .icon--arrow-right,
    .brxe-text-link:hover .icon--arrow-right,
    .bricks-button:hover > .icon--arrow-down,
    .brxe-text-link:hover .icon--arrow-down {
        transform: none;
    }
}


/* ------------------------------------------------------------
   3. Text links — no underline at rest
   ------------------------------------------------------------
   Theme Styles › Links underlines links at rest (WCAG 1.4.1), and
   functions.php adds .brxe-text-link to that list. The standalone
   links ("Læs mere →", "Se min portefølge") stand on their own line,
   so they keep the underline for hover only — Katrine, 16-09.
   ------------------------------------------------------------ */

a.brxe-text-link:not(:hover) {
    text-decoration: none;
}


/* ------------------------------------------------------------
   4. Editor notice — a component button without a link
   ------------------------------------------------------------
   inc/hide-component-parts.php adds .editor-notice + data-notice to a
   button inside a component instance that has no link target — only
   for logged-in editors (and in the builder canvas via its script).
   The button itself stays untouched; the reminder hangs below it in
   the feedback colour (--text-error flips per mode).
   ------------------------------------------------------------ */

.editor-notice {
    position: relative;
    outline: 2px dashed var(--text-error);
    outline-offset: 3px;
}

.editor-notice::after {
    content: attr(data-notice);
    position: absolute;
    top: calc(100% + var(--space-2xs));
    left: 0;
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-error);
    white-space: nowrap;
}
