/* ============================================================
   KBC Announcement Banner — Frontend Styles
   Plugin: kbc-announcement-banner  v1.0.0
   ============================================================

   bg_color and text_color are injected as inline `style`
   attributes directly on .kbc-announcement-banner from PHP,
   so no CSS custom properties are needed for those values.

   All other design tokens live here as CSS variables so
   they can be overridden in a child-theme if needed.
   ============================================================ */

/* ── Design tokens ────────────────────────────────────────── */
:root {
    --kbc-banner-z-top:        99999;     /* above Elementor sticky header (z 9999) */
    --kbc-banner-z-bottom:     99998;     /* just below top so they never collide   */
    --kbc-banner-font:         -apple-system, BlinkMacSystemFont, 'Segoe UI',
                               Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
    --kbc-banner-font-size:    0.9rem;
    --kbc-banner-line-height:  1.45;
    --kbc-banner-padding-y:    10px;
    --kbc-banner-padding-x:    52px;      /* reserve room for dismiss button */
    --kbc-banner-min-height:   42px;
    --kbc-banner-radius-cta:   3px;

    /* Transition used for both appear and dismiss */
    --kbc-banner-transition-duration: 0.3s;
    --kbc-banner-transition-ease:     ease;
    --kbc-banner-transition:
        max-height var(--kbc-banner-transition-duration) var(--kbc-banner-transition-ease),
        opacity    var(--kbc-banner-transition-duration) var(--kbc-banner-transition-ease),
        padding    var(--kbc-banner-transition-duration) var(--kbc-banner-transition-ease);
}

/* ── Banner wrapper ───────────────────────────────────────── */
.kbc-announcement-banner {
    /* Layout */
    position: relative;
    width: 100%;
    min-height: var(--kbc-banner-min-height);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;

    /* Typography */
    font-family: var(--kbc-banner-font);
    font-size:   var(--kbc-banner-font-size);
    line-height: var(--kbc-banner-line-height);

    /* bg_color / text_color come from inline style attr (PHP) */

    /* Dismiss animation — start at full height */
    overflow: hidden;
    max-height: 200px;      /* generous ceiling for multi-line messages */
    opacity: 1;
    transition: var(--kbc-banner-transition);
}

/* ── Top position — sticky, sits above viewport content ───── */
.kbc-announcement-banner.kbc-banner--top {
    position: sticky;
    top: 0;
    z-index: var(--kbc-banner-z-top);
}

/*
 * When the WP admin bar is visible it is 32 px tall on desktop
 * and 46 px on mobile (≤782 px). Push the banner down so it
 * stacks below the bar rather than overlapping it.
 */
.admin-bar .kbc-announcement-banner.kbc-banner--top {
    top: 32px;
}

@media screen and (max-width: 782px) {
    .admin-bar .kbc-announcement-banner.kbc-banner--top {
        top: 46px;
    }
}

/*
 * Elementor Pro sticky header uses z-index: 9999.
 * Our --kbc-banner-z-top (99999) is intentionally higher so the
 * announcement always renders above it — no extra rules needed.
 */

/* ── Bottom position — fixed to viewport bottom ───────────── */
.kbc-announcement-banner.kbc-banner--bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--kbc-banner-z-bottom);
}

/*
 * Plugin 2 (kbc-sticky-cta-bar) sits at z-index 9999 and is
 * approximately 64 px tall. Nudge the bottom banner up so they
 * don't overlap when both are active.
 */
.has-kbc-cta-bar .kbc-announcement-banner.kbc-banner--bottom {
    bottom: 64px;
}

/* ── Dismissed / hidden state ─────────────────────────────── */
/*
 * JS adds `.is-dismissed` on close-button click.
 * `.kbc-announcement-banner--hidden` is the BEM-modifier alias
 * referenced in the task spec — both produce the same animation.
 * PHP never adds either class; JS owns them exclusively.
 */
.kbc-announcement-banner.is-dismissed,
.kbc-announcement-banner.kbc-announcement-banner--hidden {
    max-height: 0         !important;
    opacity: 0            !important;
    padding-top: 0        !important;
    padding-bottom: 0     !important;
    pointer-events: none  !important;
    /* min-height must also collapse to zero */
    min-height: 0         !important;
}

/* ── Inner centred container ──────────────────────────────── */
.kbc-banner__inner {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--kbc-banner-padding-y) var(--kbc-banner-padding-x);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-sizing: border-box;
}

/* ── Message text ─────────────────────────────────────────── */
.kbc-banner__message {
    margin: 0;
    padding: 0;
    text-align: center;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.kbc-banner__message strong,
.kbc-banner__message b {
    font-weight: 700;
}

.kbc-banner__message em,
.kbc-banner__message i {
    font-style: italic;
}

/* ── Optional CTA link ────────────────────────────────────── */
.kbc-banner__cta {
    display: inline-block;
    margin-left: 8px;
    padding: 3px 10px;
    border: 1.5px solid currentColor;
    border-radius: var(--kbc-banner-radius-cta);
    text-decoration: none !important;
    font-weight: 600;
    font-size: 0.84em;
    white-space: nowrap;
    transition: background 0.15s ease;
    /* colour inherits from parent inline style (text_color) */
}

.kbc-banner__cta:hover,
.kbc-banner__cta:focus {
    background: rgba(255, 255, 255, 0.18);
    text-decoration: none !important;
}

/* ── Dismiss (✕) button ───────────────────────────────────── */
.kbc-banner__close {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);

    /* Reset button defaults */
    appearance: none;
    background: none;
    border: none;
    margin: 0;
    cursor: pointer;

    /* Sizing & centering */
    width: 32px;
    height: 32px;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;

    /* Colour inherits inline text_color from parent */
    color: inherit;
    opacity: 0.75;
    transition: opacity 0.15s ease, background 0.15s ease;
    line-height: 1;
}

.kbc-banner__close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.22);
}

.kbc-banner__close:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    opacity: 1;
}

/* SVG icon inside button */
.kbc-banner__close svg {
    display: block;
    flex-shrink: 0;
}

/* ── Mobile adjustments ───────────────────────────────────── */
@media (max-width: 600px) {
    :root {
        --kbc-banner-font-size: 0.82rem;
        --kbc-banner-padding-x: 44px;
        --kbc-banner-padding-y: 9px;
    }

    /* CTA link hidden on very small screens — message is enough */
    .kbc-banner__cta {
        display: none;
    }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
    .kbc-announcement-banner {
        display: none !important;
    }
}
