/*
 * Dual CTA (view.php, script.js).
 *
 * Two sides in a row. Closed, a side shows its label and title (and a round arrow); the
 * open side (.is-open) widens and its text and links slide open under the title. With
 * neither open the sides share the row equally. Phones: stacked, both fully open.
 *
 * Each side's colours: --dc-bg and its text colour --dc-fg, both set inline (view.php: its
 * light or dark shade of a colour theme). The open arrow swaps the two.
 */

.blk--dual-cta {
    --dc-height: 380px;
    --dc-gap: 12px;
    --dc-radius: 18px;
    --dc-grow: 1.7;              /* how much wider the open side is */
    --dc-ease: cubic-bezier(.2, .7, .2, 1);
    --dc-pad: 40px;
    --dc-arrow: 48px;
}

.blk--dual-cta.dual-cta--compact { --dc-height: 320px; }
.blk--dual-cta.dual-cta--tall { --dc-height: 480px; }

/* Narrower screens: the open side grows a little less, so the closed one keeps more room */
@media (max-width: 1199px) {
    .blk--dual-cta {
        --dc-grow: 1.35;
        --dc-pad: 32px;
    }
}

.dual-cta__heading {
    margin-bottom: var(--step-9);
}

.dual-cta__panels {
    display: flex;
    gap: var(--dc-gap);
    min-height: var(--dc-height);
}

.dual-cta__panel {
    --dc-fg-base: var(--white);
    position: relative;
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    border-radius: var(--dc-radius);
    background: var(--dc-bg);
    color: var(--dc-fg, var(--dc-fg-base));
    transition: flex-grow 1.05s var(--dc-ease);
}

.dual-cta__panel--light {
    --dc-fg-base: var(--black);
}

.dual-cta__panel.has-photo {
    --dc-fg-base: var(--white);
}

.dual-cta__panel.is-open {
    flex-grow: var(--dc-grow);
}

/* The optional photo, darkened toward the text */
.dual-cta__photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.04);
    transition: transform 1.8s var(--dc-ease);
}

.dual-cta__panel.is-open .dual-cta__photo {
    transform: none;
}

.dual-cta__panel.has-photo::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, rgba(0, 0, 0, .8) 0%, rgba(0, 0, 0, .45) 55%, rgba(0, 0, 0, .15) 100%);
    pointer-events: none;
}

.dual-cta__inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    width: 100%;
    padding: var(--dc-pad);
}

/* The label + title row: the side's button (click, tap, keyboard) */
.dual-cta__toggle {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--step-6);
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-align: left;
    cursor: pointer;
}

.dual-cta__toggle:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 6px;
    border-radius: 4px;
}

.dual-cta__head {
    display: flex;
    flex-direction: column;
    gap: var(--step-4);
    min-width: 0;
}

/* Side by side, the label and title are always as wide as on a closed side next to an
   open one, so they wrap the same way whether open, closed or at rest:
   (row - gap) / (1 + grow) - the side's padding. */
@media (min-width: 768px) {
    .dual-cta__panels {
        container-type: inline-size;
    }

    .dual-cta__head {
        flex-shrink: 0;
        width: calc((100cqw - var(--dc-gap)) / (1 + var(--dc-grow)) - 2 * var(--dc-pad));
        max-width: 100%;
    }
}

.dual-cta__label {
    font-size: 18px;
    font-weight: 300;
    line-height: 1.33;
    letter-spacing: .1em;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: .9;
}

.dual-cta__title {
    display: block;
    font-family: var(--font-serif); /* the heading font, though not a heading */
    font-size: clamp(30px, 3vw, 44px);
    font-weight: 100;
    line-height: 1.11;
    letter-spacing: .01em;
}

/* The round arrow, in the bottom corner (out of the text's way); filled once open */
.dual-cta__arrow {
    position: absolute;
    right: var(--dc-pad);
    bottom: var(--dc-pad);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: var(--dc-arrow);
    height: var(--dc-arrow);
    border: 1px solid var(--dc-fg, var(--dc-fg-base));
    border-radius: 50%;
    background-color: transparent;
    color: var(--dc-fg, var(--dc-fg-base));
    opacity: .7;
    transition: opacity .3s ease, background-color .35s ease, color .35s ease;
}

.dual-cta__panel.is-open .dual-cta__arrow,
.dual-cta--static.dual-cta--whole .dual-cta__panel:hover .dual-cta__arrow {
    background-color: var(--dc-fg, var(--dc-fg-base));
    color: var(--dc-bg);
    opacity: 1;
}

/* The body opens by its grid row; its contents fade and rise in just after */
.dual-cta__body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .9s var(--dc-ease);
}

.dual-cta__panel.is-open .dual-cta__body {
    grid-template-rows: 1fr;
}

.dual-cta__body-inner {
    min-height: 0;
    overflow: hidden;
}

.dual-cta__body-inner > * {
    opacity: 0;
    translate: 0 12px;
    transition: opacity .45s ease, translate .45s ease;
}

.dual-cta__panel.is-open .dual-cta__body-inner > * {
    opacity: 1;
    translate: none;
    transition: opacity .75s ease .3s, translate .9s var(--dc-ease) .3s;
}

.dual-cta__panel.is-open .dual-cta__links {
    transition-delay: .45s;
}

.dual-cta__panel .dual-cta__text {
    max-width: 520px;
    margin-top: var(--step-6);
    color: inherit;
    font-size: 16px;
    line-height: 1.6;
}

.dual-cta__panel.is-open .dual-cta__text,
.dual-cta--static .dual-cta__text {
    opacity: .85;
}

.dual-cta__links {
    flex-wrap: wrap;
    margin-top: var(--step-7);
}

/* Both always open (Nothing opens them): equal widths, no widening */
.dual-cta--static .dual-cta__panel {
    flex-grow: 1;
}

.dual-cta--static .dual-cta__head {
    width: auto;
}

.dual-cta--static .dual-cta__toggle {
    cursor: inherit;
}

.dual-cta--static .dual-cta__body {
    grid-template-rows: 1fr;
}

.dual-cta--static .dual-cta__body-inner > * {
    opacity: 1;
    translate: none;
}

.dual-cta--static .dual-cta__links {
    padding-right: calc(var(--dc-arrow) + var(--step-5));
}

/* Touch screens (tablets, and phones turned sideways): no hover to open a side, so both
   show open, side by side and equal, as with "Nothing" opening them. Phones stack (below). */
@media (hover: none) and (pointer: coarse) {
    .dual-cta__panel,
    .dual-cta__panel.is-open {
        flex-grow: 1;
    }

    .dual-cta__head {
        width: auto;
    }

    .dual-cta__toggle {
        pointer-events: none;
    }

    .dual-cta__body {
        grid-template-rows: 1fr;
    }

    .dual-cta__body-inner > *,
    .dual-cta__panel:not(.is-open) .dual-cta__body-inner > * {
        opacity: 1;
        translate: none;
    }

    .dual-cta__panel .dual-cta__text {
        opacity: .85;
    }

    .dual-cta__links {
        padding-right: calc(var(--dc-arrow) + var(--step-5));
    }
}

/* Text links: underlined, with an arrow */
.dual-cta--text-links .dual-cta__links {
    gap: var(--step-4) var(--step-7);
}

.dual-cta__link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--dc-fg, var(--dc-fg-base));
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
}

.dual-cta__link span {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 5px;
    text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
    transition: text-decoration-color .3s ease;
}

.dual-cta__link-arrow {
    transition: translate .35s var(--dc-ease);
}

.dual-cta__link:hover span,
.dual-cta--whole .dual-cta__panel:hover .dual-cta__main span {
    text-decoration-color: currentColor;
}

.dual-cta__link:hover .dual-cta__link-arrow,
.dual-cta--whole .dual-cta__panel:hover .dual-cta__main .dual-cta__link-arrow {
    translate: 4px 0;
}

.dual-cta__link:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 4px;
    border-radius: 2px;
}

/* Whole side clickable: the first link stretches over the side; the second stays on top */
.dual-cta--whole .dual-cta__panel {
    cursor: pointer;
}

.dual-cta--whole .dual-cta__main::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
}

.dual-cta--whole .dual-cta__second {
    position: relative;
    z-index: 3;
}

@media (max-width: 860px) {
    .dual-cta__label {
        font-size: 16px;
        line-height: 1.5;
    }
}

/* Phones: stacked and fully open (no hover to rely on) */
@media (max-width: 767px) {
    .blk--dual-cta {
        --dc-pad: 28px;
    }

    .dual-cta__panels {
        flex-direction: column;
        min-height: 0;
    }

    .dual-cta__panel {
        flex: none;
    }

    .dual-cta__toggle {
        pointer-events: none;
    }

    .dual-cta__links {
        padding-right: calc(var(--dc-arrow) + var(--step-5));
    }

    .dual-cta__body {
        grid-template-rows: 1fr;
    }

    .dual-cta__body-inner > *,
    .dual-cta__panel:not(.is-open) .dual-cta__body-inner > * {
        opacity: 1;
        translate: none;
    }

    .dual-cta__panel .dual-cta__text {
        opacity: .85;
    }

    .dual-cta__links > a {
        width: 100%;
    }
}

/* Very small screens: no room for the round arrow beside the links */
@media (max-width: 349px) {
    .dual-cta__arrow {
        display: none;
    }

    .dual-cta__links {
        padding-right: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dual-cta__panel,
    .dual-cta__photo,
    .dual-cta__arrow,
    .dual-cta__body,
    .dual-cta__body-inner > * {
        transition: none !important;
    }
}

/* ---------- Entrance (script.js) ----------
   The heading comes in (up when centred, otherwise from the left), then the sides rise
   in one after the other. */

.blk--dual-cta.rv .dual-cta__heading,
.blk--dual-cta.rv .dual-cta__panel {
    opacity: 0;
}

.blk--dual-cta.rv.rv-from-left .dual-cta__heading {
    transform: translateX(calc(var(--reveal-shift) * -1));
}

.blk--dual-cta.rv.rv-from-below .dual-cta__heading {
    transform: translateY(var(--reveal-rise));
}

.blk--dual-cta.rv .dual-cta__panel {
    translate: 0 var(--reveal-rise);
}

.blk--dual-cta.rv-armed .dual-cta__heading {
    transition: opacity var(--reveal-text) ease, transform var(--reveal-text) var(--reveal-ease);
}

.blk--dual-cta.rv-armed .dual-cta__panel {
    --dc-delay: calc(var(--rv-start, 0s) + var(--rv-i, 0) * var(--reveal-stagger));
    transition:
        flex-grow 1.05s var(--dc-ease),
        opacity var(--reveal-text) ease var(--dc-delay),
        translate calc(var(--reveal-text) + .1s) var(--reveal-ease) var(--dc-delay);
}

.blk--dual-cta.rv.rv-heading-in .dual-cta__heading,
.blk--dual-cta.rv.rv-sides-in .dual-cta__panel {
    opacity: 1;
    transform: none;
    translate: none;
}
