/**
 * Info Box widget.
 *
 * Scoped to `.goxom-ib`, which only this widget outputs. Everything the Style
 * tab reaches is a custom property on the root, so the panel retunes every
 * card at once and the variants below only have to swap tokens.
 *
 * Colours fall back to the theme's tokens where they exist, so a fresh widget
 * already looks like the site rather than like a default.
 */

.goxom-ib {
    --ib-ink: var(--color-black, #0C2338);
    --ib-body: var(--color-body, #5A7387);
    --ib-accent: var(--color-primary, #1273C4);
    --ib-surface: var(--color-tint, #EEF4FB);
    --ib-border: transparent;
    --ib-track: rgba(12, 35, 56, 0.09);
    --ib-fill: var(--ib-accent);

    --ib-cols: 3;
    --ib-gap: 24px;
    --ib-radius: 22px;
    --ib-ibox: 56px;
    --ib-isize: 22px;
    --ib-bar: 8px;
    --ib-ring: 116px;
    --ib-dur: 1600ms;

    display: grid;
    grid-template-columns: repeat(var(--ib-cols), minmax(0, 1fr));
    gap: var(--ib-gap);
}

.goxom-ib *,
.goxom-ib *::before,
.goxom-ib *::after {
    box-sizing: border-box;
}

/* ───────────────────────────────────────── surfaces */

.goxom-ib--card {
    --ib-surface: #fff;
    --ib-border: rgba(12, 35, 56, 0.06);
}

.goxom-ib--outline {
    --ib-surface: transparent;
    --ib-border: var(--color-border, #D5E3EF);
}

.goxom-ib--dark {
    --ib-ink: #fff;
    --ib-body: rgba(255, 255, 255, 0.68);
    --ib-surface: #0C2338;
    --ib-border: rgba(255, 255, 255, 0.08);
    --ib-track: rgba(255, 255, 255, 0.12);
}

/* ───────────────────────────────────────── card */

.goxom-ib__card {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 30px 30px 32px;
    overflow: hidden;
    border: 1px solid var(--ib-border);
    border-radius: var(--ib-radius);
    background: var(--ib-surface);
    color: var(--ib-body);
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.45s ease, border-color 0.35s ease;
}

.goxom-ib--card .goxom-ib__card {
    box-shadow: 0 1px 2px rgba(6, 23, 38, 0.04), 0 18px 40px -28px rgba(6, 23, 38, 0.35);
}

/* A soft light in the corner that warms on hover, so the card responds
   before it moves. */
.goxom-ib__glow {
    position: absolute;
    top: -40%;
    right: -30%;
    width: 80%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(closest-side, var(--ib-accent), transparent);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
    z-index: -1;
}

.goxom-ib__card:hover .goxom-ib__glow {
    opacity: 0.12;
    transform: scale(1);
}

.goxom-ib--lift .goxom-ib__card:hover,
.goxom-ib--lift .goxom-ib__card.is-hold {
    transform: translateY(-6px);
    box-shadow: 0 6px 14px rgba(6, 23, 38, 0.05), 0 32px 60px -30px rgba(6, 23, 38, 0.4);
}

.goxom-ib--outline .goxom-ib__card:hover {
    border-color: var(--ib-accent);
}

/* ───────────────────────────────────────── highlighted card */

.goxom-ib__card.is-featured {
    --ib-ink: #fff;
    --ib-body: rgba(255, 255, 255, 0.8);
    --ib-track: rgba(255, 255, 255, 0.22);
    --ib-fill: #fff;
    border-color: transparent;
    background: linear-gradient(145deg, var(--ib-accent) 0%, color-mix(in srgb, var(--ib-accent) 55%, #061726) 100%);
    box-shadow: 0 24px 48px -26px color-mix(in srgb, var(--ib-accent) 80%, transparent);
}

@supports not (background: color-mix(in srgb, red 50%, blue)) {
    .goxom-ib__card.is-featured {
        background: linear-gradient(145deg, var(--ib-accent) 0%, rgba(6, 23, 38, 0.92) 100%);
        box-shadow: 0 24px 48px -26px rgba(6, 23, 38, 0.5);
    }
}

.goxom-ib__card.is-featured .goxom-ib__glow {
    background: radial-gradient(closest-side, #fff, transparent);
    opacity: 0.14;
    transform: scale(1);
}

.goxom-ib__card.is-featured:hover .goxom-ib__glow {
    opacity: 0.22;
}

/* ───────────────────────────────────────── head: icon / ring + index */

.goxom-ib__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 26px;
}

.goxom-ib__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: var(--ib-ibox);
    height: var(--ib-ibox);
    border-radius: 16px;
    background: rgba(18, 115, 196, 0.1);
    background: color-mix(in srgb, var(--ib-accent) 12%, transparent);
    color: var(--ib-accent);
    font-size: var(--ib-isize);
    line-height: 1;
    transition: background-color 0.35s ease, color 0.35s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.goxom-ib__icon svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
}

.goxom-ib__card:hover .goxom-ib__icon {
    background: var(--ib-accent);
    color: #fff;
    transform: rotate(-8deg) scale(1.06);
}

.goxom-ib__card.is-featured .goxom-ib__icon,
.goxom-ib__card.is-featured:hover .goxom-ib__icon {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.goxom-ib__index {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    padding-top: 4px;
    font-family: var(--font-title, inherit);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--ib-body);
    opacity: 0.6;
}

.goxom-ib__index::before {
    content: "";
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.goxom-ib__card:hover .goxom-ib__index::before {
    width: 30px;
}

/* ───────────────────────────────────────── figure */

.goxom-ib__value {
    display: flex;
    align-items: flex-start;
    font-family: var(--font-title, inherit);
    font-size: 54px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.03em;
    /* Fixed-width digits so the count-up does not make the line wobble. */
    font-variant-numeric: tabular-nums;
}

.goxom-ib__num {
    color: var(--ib-ink);
}

.goxom-ib__unit {
    margin: 0.08em 0 0 0.06em;
    font-size: 0.5em;
    letter-spacing: 0;
    color: var(--ib-accent);
}

.goxom-ib__card.is-featured .goxom-ib__unit {
    color: rgba(255, 255, 255, 0.75);
}

/* ───────────────────────────────────────── text */

.goxom-ib__title {
    margin: 16px 0 0;
    font-size: 21px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--ib-ink);
    text-wrap: balance;
}

.goxom-ib__text {
    margin: 10px 0 0;
    font-size: 15px;
    line-height: 1.65;
    color: var(--ib-body);
}

.goxom-ib__label {
    display: block;
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ib-body);
}

.goxom-ib__label--chip {
    align-self: flex-start;
    margin: 22px 0 0;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(12, 35, 56, 0.06);
    background: color-mix(in srgb, var(--ib-ink) 7%, transparent);
}

/* ───────────────────────────────────────── bar meter */

.goxom-ib__meter {
    /* Pinned to the bottom, so bars line up across cards whose titles wrap
       to a different number of lines. */
    margin-top: auto;
    padding-top: 28px;
}

.goxom-ib__track {
    position: relative;
    height: var(--ib-bar);
    border-radius: 999px;
    background: var(--ib-track);
}

.goxom-ib__fill {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: calc(var(--ib-pct) * 1%);
    border-radius: inherit;
    background: linear-gradient(90deg, color-mix(in srgb, var(--ib-fill) 55%, #fff), var(--ib-fill));
    transition: width var(--ib-dur) cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: var(--ib-d, 0ms);
}

@supports not (background: color-mix(in srgb, red 50%, blue)) {
    .goxom-ib__fill {
        background: var(--ib-fill);
    }
}

/* The knob marks the value; its halo breathes wider on hover. */
.goxom-ib__fill::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 0;
    width: calc(var(--ib-bar) + 8px);
    height: calc(var(--ib-bar) + 8px);
    border: 3px solid var(--ib-fill);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(18, 115, 196, 0.16);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--ib-fill) 18%, transparent);
    transform: translate(50%, -50%);
    transition: box-shadow 0.4s ease;
}

.goxom-ib__card:hover .goxom-ib__fill::after {
    box-shadow: 0 0 0 7px rgba(18, 115, 196, 0.14);
    box-shadow: 0 0 0 7px color-mix(in srgb, var(--ib-fill) 16%, transparent);
}

.goxom-ib__card.is-featured .goxom-ib__fill::after {
    background: var(--ib-accent);
}

/* ───────────────────────────────────────── ring meter */

.goxom-ib__ring {
    position: relative;
    flex: none;
    width: var(--ib-ring);
    height: var(--ib-ring);
}

.goxom-ib__ring svg {
    display: block;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    overflow: visible;
}

.goxom-ib__ring circle {
    fill: none;
    stroke-width: 7;
}

.goxom-ib__ring-track {
    stroke: var(--ib-track);
}

.goxom-ib__ring-fill {
    stroke: var(--ib-fill);
    stroke-linecap: round;
    stroke-dasharray: 100;
    stroke-dashoffset: calc(100 - var(--ib-pct));
    transition: stroke-dashoffset var(--ib-dur) cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: var(--ib-d, 0ms);
}

.goxom-ib__ring .goxom-ib__value {
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--ib-ring) * 0.27);
}

.goxom-ib--ring .goxom-ib__title {
    margin-top: 0;
}

/* ───────────────────────────────────────── entrance
   Only once the script has added `goxom-ib--js`; without it every card is
   already in its final state. */

.goxom-ib--js .goxom-ib__card:not(.is-in) {
    opacity: 0;
}

.goxom-ib--js .goxom-ib__card:not(.is-in) .goxom-ib__fill {
    width: 0;
}

.goxom-ib--js .goxom-ib__card:not(.is-in) .goxom-ib__ring-fill {
    stroke-dashoffset: 100;
}

/* A keyframe rather than a transition, and filled backwards only: the card
   holds its start pose through the delay, then hands `transform` back to the
   hover lift the moment it lands. */
.goxom-ib--js .goxom-ib__card.is-in {
    animation: goxom-ib-rise 0.8s cubic-bezier(0.22, 1, 0.36, 1) backwards;
    animation-delay: var(--ib-d, 0ms);
}

@keyframes goxom-ib-rise {
    from {
        opacity: 0;
        transform: translateY(28px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* ───────────────────────────────────────── responsive */

@media (max-width: 767px) {
    .goxom-ib__card {
        padding: 26px 22px 26px;
    }

    .goxom-ib__value {
        font-size: 46px;
    }

    .goxom-ib__title {
        font-size: 19px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .goxom-ib__card,
    .goxom-ib__card *,
    .goxom-ib__card *::before,
    .goxom-ib__card *::after {
        transition: none !important;
        animation: none !important;
    }

    .goxom-ib--lift .goxom-ib__card:hover,
    .goxom-ib__card:hover .goxom-ib__icon {
        transform: none;
    }
}
