/**
 * Solutions pie: content panel beside an equal-slice donut.
 */

.terra-solutions-pie {
    --terra-pie-active: #001b3a;
    --terra-pie-inactive: #dbe4ef;
    --terra-pie-icon: #001b3a;
    --terra-pie-icon-active: #ffffff;
    --terra-pie-hub: #ffffff;
    --terra-pie-gap: 80px;
    --terra-pie-radius: 10px;
    --terra-pie-interval: 4000ms;
    --terra-pie-ease: cubic-bezier(0.22, 1, 0.36, 1);

    width: 100%;
    box-sizing: border-box;
}

.terra-solutions-pie *,
.terra-solutions-pie *::before,
.terra-solutions-pie *::after {
    box-sizing: border-box;
}

.terra-solutions-pie__layout {
    display: grid;
    grid-template-columns: minmax(0, 44fr) minmax(0, 56fr);
    column-gap: var(--terra-pie-gap);
    row-gap: min(var(--terra-pie-gap), 48px);
    align-items: center;
}

/* Content: every panel shares one cell, so the tallest sets the height. */

.terra-solutions-pie__panels {
    display: grid;
}

.terra-solutions-pie__panel {
    grid-area: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-14px);
    transition:
        opacity 0.3s ease,
        transform 0.5s var(--terra-pie-ease),
        visibility 0s linear 0.3s;
}

.terra-solutions-pie__panel.is-active {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition-delay: 0s;
}

/* "01 / 06" with a line that fills while the auto-rotate counts down. */

.terra-solutions-pie__eyebrow {
    display: flex;
    align-items: baseline;
    gap: 8px;
    width: 100%;
    max-width: 320px;
    margin-bottom: 22px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.08em;
}

.terra-solutions-pie__number {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--terra-pie-active);
}

.terra-solutions-pie__of {
    font-size: 0.8125rem;
    font-weight: 500;
    opacity: 0.5;
}

.terra-solutions-pie__bar {
    position: relative;
    flex: 1;
    align-self: center;
    height: 2px;
    margin-left: 8px;
    background: color-mix(in srgb, var(--terra-pie-active) 14%, transparent);
    overflow: hidden;
}

.terra-solutions-pie__bar::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--terra-pie-active);
    transform: scaleX(0);
    transform-origin: left center;
}

.terra-solutions-pie.is-running .terra-solutions-pie__panel.is-active .terra-solutions-pie__bar::after {
    animation: terra-pie-progress var(--terra-pie-interval) linear forwards;
}

@keyframes terra-pie-progress {
    to {
        transform: scaleX(1);
    }
}

.terra-solutions-pie__title {
    display: block;
    margin: 0;
    font-size: clamp(2rem, 1.3rem + 2vw, 3.25rem);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.03em;
    text-wrap: balance;
}

.terra-solutions-pie__text {
    display: block;
    max-width: 44ch;
    margin: 18px 0 0;
    font-size: 1.0625rem;
    line-height: 1.65;
    opacity: 0.8;
}

.terra-solutions-pie__link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 36px;
    padding: 13px 24px;
    border: 1.5px solid var(--terra-pie-active);
    border-radius: var(--terra-pie-radius);
    background: var(--terra-pie-active);
    color: var(--terra-pie-icon-active);
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    transition:
        background-color 0.25s ease,
        color 0.25s ease;
}

.terra-solutions-pie__link::after {
    content: "\2192";
    transition: transform 0.3s var(--terra-pie-ease);
}

.terra-solutions-pie__link:hover,
.terra-solutions-pie__link:focus-visible {
    background: transparent;
    color: var(--terra-pie-active);
}

.terra-solutions-pie__link:hover::after,
.terra-solutions-pie__link:focus-visible::after {
    transform: translateX(5px);
}

.terra-solutions-pie__link:focus-visible {
    outline: 2px solid var(--terra-pie-active);
    outline-offset: 3px;
}

/* Donut. */

.terra-solutions-pie__chart {
    display: flex;
    justify-content: center;
}

.terra-solutions-pie__dial {
    --terra-pie-label-w: 26%;
    --terra-pie-label-size: 2.7cqw;

    position: relative;
    width: min(100%, 480px);
    aspect-ratio: 1 / 1;
    container-type: inline-size;
}

/* Slow dashed orbit around the donut. */

.terra-solutions-pie__dial::before {
    content: "";
    position: absolute;
    inset: -5%;
    border: 1px dashed color-mix(in srgb, var(--terra-pie-active) 28%, transparent);
    border-radius: 50%;
    pointer-events: none;
    animation: terra-pie-orbit 90s linear infinite;
}

@keyframes terra-pie-orbit {
    to {
        transform: rotate(360deg);
    }
}

.terra-solutions-pie__svg {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.terra-solutions-pie__segment {
    fill: var(--terra-pie-inactive);
    cursor: pointer;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    transition:
        fill 0.3s ease,
        filter 0.3s ease,
        transform 0.5s var(--terra-pie-ease);
}

.terra-solutions-pie__segment:hover {
    fill: color-mix(in srgb, var(--terra-pie-active) 16%, var(--terra-pie-inactive));
}

.terra-solutions-pie__segment.is-active {
    fill: var(--terra-pie-active);
    filter: drop-shadow(0 6px 10px color-mix(in srgb, var(--terra-pie-active) 38%, transparent));
    transform: translate(calc(var(--terra-pie-dx, 0) * 1px), calc(var(--terra-pie-dy, 0) * 1px));
}

.terra-solutions-pie__segment:focus-visible {
    stroke: #4c9aff;
    stroke-width: 2.5;
    stroke-linejoin: round;
}

/* Icon over title, centred on each slice. */

.terra-solutions-pie__ring-item {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.2cqw;
    width: var(--terra-pie-label-w);
    transform: translate(-50%, -50%);
    color: var(--terra-pie-icon);
    text-align: center;
    pointer-events: none;
    transition:
        color 0.3s ease,
        translate 0.5s var(--terra-pie-ease);
}

.terra-solutions-pie__ring-item.is-active {
    color: var(--terra-pie-icon-active);
    translate: calc(var(--terra-pie-dx, 0) * 0.5cqw) calc(var(--terra-pie-dy, 0) * 0.5cqw);
}

.terra-solutions-pie__ring-icon {
    display: block;
    width: 6.5cqw;
    height: 6.5cqw;
}

.terra-solutions-pie__ring-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

.terra-solutions-pie__ring-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    max-width: 100%;
    overflow: hidden;
    font-size: var(--terra-pie-label-size);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
    text-wrap: balance;
}

/* Center circle: label, and View all underneath it on hover. */

.terra-solutions-pie__hub {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 31%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: var(--terra-pie-hub);
    color: var(--terra-pie-active);
    text-align: center;
    text-decoration: none;
    box-shadow:
        0 14px 34px -14px color-mix(in srgb, var(--terra-pie-active) 45%, transparent),
        inset 0 0 0 1.5px color-mix(in srgb, var(--terra-pie-active) 14%, transparent);
    transform: translate(-50%, -50%);
    transition:
        background-color 0.3s ease,
        color 0.3s ease,
        box-shadow 0.3s ease,
        scale 0.4s var(--terra-pie-ease);
}

.terra-solutions-pie__hub-label {
    display: block;
    font-size: 3.7cqw;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.01em;
}

.terra-solutions-pie__hub-more {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    transition:
        grid-template-rows 0.4s var(--terra-pie-ease),
        opacity 0.3s ease;
}

.terra-solutions-pie__hub-more > span {
    display: block;
    min-height: 0;
    overflow: hidden;
    padding-top: 0.8cqw;
    font-size: 2.6cqw;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.terra-solutions-pie__hub-more > span::after {
    content: " \2192";
}

.terra-solutions-pie__hub--link:hover,
.terra-solutions-pie__hub--link:focus-visible {
    background: var(--terra-pie-active);
    color: var(--terra-pie-icon-active);
    scale: 1.04;
}

.terra-solutions-pie__hub--link:hover .terra-solutions-pie__hub-more,
.terra-solutions-pie__hub--link:focus-visible .terra-solutions-pie__hub-more {
    grid-template-rows: 1fr;
    opacity: 1;
}

.terra-solutions-pie__hub--link:focus-visible {
    outline: 2px solid #4c9aff;
    outline-offset: 3px;
}

/* No hover on touch screens, so View all is always shown. */

@media (hover: none) {
    .terra-solutions-pie__hub-more {
        grid-template-rows: 1fr;
        opacity: 1;
    }
}

.terra-solutions-pie__empty {
    margin: 0;
    padding: 24px;
    text-align: center;
    opacity: 0.7;
}

/* Narrower than a desktop: content, then the donut. */

@media (max-width: 1024px) {
    .terra-solutions-pie__layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .terra-solutions-pie__dial {
        width: min(100%, 420px);
    }
}

/* Small donut: the title is in the content above, so slices keep their icon only. */

@container (max-width: 340px) {
    .terra-solutions-pie__ring-title {
        display: none;
    }

    .terra-solutions-pie__ring-icon {
        width: 8cqw;
        height: 8cqw;
    }
}

@media (max-width: 640px) {
    .terra-solutions-pie__dial {
        width: min(100%, 340px);
    }

    .terra-solutions-pie__text {
        font-size: 1rem;
    }

    .terra-solutions-pie__link {
        margin-top: 28px;
        padding: 12px 20px;
    }

    .terra-solutions-pie__hub-label {
        font-size: 4.2cqw;
    }

    .terra-solutions-pie__hub-more > span {
        font-size: 3cqw;
    }
}

@media (prefers-reduced-motion: reduce) {
    .terra-solutions-pie__dial::before {
        animation: none;
    }

    .terra-solutions-pie__panel,
    .terra-solutions-pie__segment,
    .terra-solutions-pie__ring-item,
    .terra-solutions-pie__hub,
    .terra-solutions-pie__hub-more,
    .terra-solutions-pie__link,
    .terra-solutions-pie__link::after {
        transition: none;
    }

    .terra-solutions-pie__panel {
        transform: none;
    }

    .terra-solutions-pie__bar {
        display: none;
    }
}
