:root {
    --stage: min(30vw, 60svh);
    --text-top: clamp(1.4rem, 18svh, 14rem);
    --ease: cubic-bezier(0.65, 0, 0.35, 1);
}

body > aside {
    display: none;
}

.intro body > aside {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bgcolor);
    animation: fade-out 0.7s 3.1s var(--ease) forwards;
}

aside svg {
    height: 5.2rem;
    overflow: visible;
}

aside path {
    stroke-width: 1.2;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    fill-opacity: 0;
    animation: draw 1.1s var(--ease) forwards, fill 0.6s 0.9s forwards;
}

aside path + path {
    animation-delay: 0.25s, 1.1s;
}

aside p {
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    opacity: 0;
    font-size: 4.4rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--maincolor);
    animation: reveal 0.9s 1.5s var(--ease) forwards;
}

:is(aside, .mission, .support) em {
    font-style: normal;
    color: var(--highlightcolor);
}

.home .button + .button,
.support .button + .button {
    background-color: transparent;
    color: var(--maincolor);
    box-shadow: inset 0 0 0 2px var(--maincolor);
}

.home .button + .button:hover,
.support .button + .button:hover {
    background-color: var(--maincolor);
    color: var(--whitetextcolor);
}

.home hgroup p:has(.button),
.support > p:has(.button) {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.home hgroup p:has(.button) {
    padding-top: 2.4rem;
}

section.home.active {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 4rem;
}

.home > hgroup h1 {
    font-size: clamp(2.6rem, 4.4vw, 4.6rem);
    white-space: nowrap;
}

.home > * {
    grid-column: 1 / -1;
}

.home > hgroup {
    grid-column: 1;
    align-self: start;
    padding-top: 0;
    margin-top: var(--text-top);
}

.home > figure {
    grid-column: 2;
    grid-row: 1;
    height: min(72svh, 46rem);
    border-radius: 0;
    overflow: visible;
    background: none;
}

figure[data-step] {
    display: grid;
    place-items: center;
    pointer-events: none;
}

figure[data-step] svg {
    width: var(--stage);
    max-height: 100%;
}

.home > figure svg {
    width: auto;
    height: 100%;
}

section.mission.active {
    padding-top: var(--header-height);
}

section.mission.active,
section.support.active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--stage) minmax(0, 1fr);
    column-gap: clamp(1.5rem, 3vw, 3.5rem);
}

.mission > figure {
    grid-area: 1 / 2 / 4 / 3;
    display: block;
}

.mission > figure svg {
    position: sticky;
    top: var(--header-height);
    display: block;
    width: 100%;
    height: calc(100svh - var(--header-height));
    max-height: none;
}

.mission > article {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    align-items: start;
    min-height: calc(100svh - var(--header-height));
    padding-top: 1.4rem;
    transition: opacity 0.6s;
}

.mission > article:nth-of-type(1) { grid-row: 1; }
.mission > article:nth-of-type(2) { grid-row: 2; }
.mission > article:nth-of-type(3) { grid-row: 3; }

.mission > article:not([aria-current]) {
    opacity: 0.15;
}

.mission > article > :not(hgroup) {
    grid-column: 3;
}

.mission article > figure {
    display: none;
}

.mission > article > :not(figure),
.support > :is(hgroup, ul) {
    margin-top: var(--text-top);
}

.mission > :is(h2, dl) {
    grid-column: 1 / -1;
}

:is(.mission, .support) hgroup {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1.2rem;
}

:is(.mission, .support) small {
    color: var(--highlightcolor);
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

:is(.mission, .support) hgroup :is(h1, h2) {
    margin: 0;
    padding: 0;
    background: none;
    color: var(--maincolor);
}

:is(.mission, .support) hgroup h1 {
    font-size: clamp(2.4rem, 4.4vw, 5.2rem);
    line-height: 1;
    white-space: nowrap;
}

.mission hgroup h1 em {
    display: block;
}

.support hgroup h1,
:is(.mission, .support) hgroup h2 {
    font-size: clamp(1.7rem, 2.6vw, 2.6rem);
    line-height: 1.12;
    white-space: normal;
}

:is(.mission, .support) :is(hgroup p, li, dd) {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--maintextcolor);
}

:is(.mission, .support) :is(strong, dt) {
    color: var(--maincolor);
    font-weight: 600;
}

:is(.mission, .support) :is(ul, ol) {
    list-style: none;
    display: grid;
    gap: 1rem;
}

:is(.mission, .support) ul li {
    padding-left: 1rem;
    border-left: 3px solid var(--highlightcolor);
}

.mission ol {
    gap: 0;
    counter-reset: layer 5;
}

.mission ol li {
    counter-increment: layer -1;
    position: relative;
    height: calc(var(--stage) * 0.1583);
    padding-left: 3.2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.35;
}

.mission ol li::before {
    content: counter(layer);
    position: absolute;
    left: 0;
    top: 50%;
    translate: 0 -50%;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    background: var(--maincolor);
    color: var(--whitetextcolor);
    font-weight: 600;
    display: grid;
    place-items: center;
}

.mission dt {
    font-size: 1.8rem;
    line-height: 1.2;
}

.mission dd {
    margin: 0.2rem 0 1rem;
    font-size: 0.95rem;
}

.mission hgroup p:last-child:has(strong) {
    padding: 0.9rem 1.1rem;
    border-left: 4px solid var(--highlightcolor);
    border-radius: 0.4rem;
    background: #E6F6F6;
}

.mission hgroup p:last-child strong {
    display: block;
}

section.support.active {
    grid-template-rows: auto auto 1fr;
    align-items: start;
    row-gap: 1.6rem;
    min-height: calc(100svh - var(--header-height));
    padding-bottom: 2rem;
}

.support > hgroup { grid-area: 1 / 1; }
.support > hgroup + p { grid-area: 2 / 1; }
.support > p + p { grid-area: 3 / 1; }

.support > figure {
    grid-area: 1 / 2 / -1 / 3;
    align-self: center;
}

.support > ul {
    grid-area: 1 / 3 / -1 / 4;
}

.support > p:last-of-type {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 12rem));
    gap: 1rem;
}

.support > p:last-of-type small {
    grid-column: 1 / -1;
}

.support > p:last-of-type img {
    width: 100%;
    height: 4.5rem;
    padding: 0.6rem 1rem;
    object-fit: contain;
    border-radius: 0.6rem;
    background: #fff;
    box-shadow: 0 1px 3px rgb(1 93 103 / 0.12);
}

figure[data-step] text {
    font-size: 16px;
    font-weight: 600;
    fill: var(--maincolor);
    paint-order: stroke;
    stroke: var(--bgcolor);
    stroke-width: 6px;
    stroke-linejoin: round;
}

.leg {
    transform-box: view-box;
    transform-origin: 392px 580px;
    transition: transform 1.4s var(--ease);
}

.leg > path {
    vector-effect: non-scaling-stroke;
}

.layers > g {
    transform-box: fill-box;
    transform-origin: center;
}

.halo, .wound, .bandage, .dressing, .anklet, .layers > g {
    transition: opacity 0.7s, transform 0.9s var(--ease);
}

.bandage, .dressing, .anklet, .layers > g {
    opacity: 0;
}

.layers > g {
    transform: translateY(-60px);
}

.layers > g > circle {
    animation: blink 1.6s infinite;
}

.layers > g > circle:nth-of-type(odd) {
    animation-delay: 0.8s;
}

.signal {
    animation: blink 1.4s infinite;
}

[data-step="home"] :is(.dressing, .anklet),
[data-step="problem"] .bandage,
[data-step="patch"] .layers > g {
    opacity: 1;
    transform: none;
}

[data-step="home"] .halo {
    opacity: 0;
}

[data-step="scale"] .halo {
    animation: pulse 3s ease-in-out infinite;
}

[data-step="problem"] .wound {
    opacity: 0.3;
}

[data-step="patch"] .leg {
    transform: translate(-122px, 140px) scale(2.2);
}

[data-step="patch"] .layers > g:nth-child(1) { transition-delay: 1.2s; }
[data-step="patch"] .layers > g:nth-child(2) { transition-delay: 1.4s; }
[data-step="patch"] .layers > g:nth-child(3) { transition-delay: 1.6s; }
[data-step="patch"] .layers > g:nth-child(4) { transition-delay: 1.8s; }

@keyframes fade-out {
    to { opacity: 0; visibility: hidden; }
}

@keyframes reveal {
    to { max-width: 4.4em; opacity: 1; margin-left: 1.2rem; }
}

@keyframes draw {
    to { stroke-dashoffset: 0; }
}

@keyframes fill {
    to { fill-opacity: 1; }
}

@keyframes pulse {
    50% { opacity: 0.08; }
}

@keyframes blink {
    50% { opacity: 0.3; }
}

@media (max-width: 56rem) {
    section.home.active {
        grid-template-columns: minmax(0, 1fr);
    }

    .home > hgroup {
        padding-bottom: 2rem;
    }

    .home > hgroup h1 {
        font-size: 4.6rem;
        white-space: normal;
    }

    figure[data-step] {
        align-self: stretch;
    }

    figure[data-step] svg {
        width: auto;
        height: 100%;
    }

    .home > figure {
        grid-column: 1;
        grid-row: auto;
        height: 56svh;
    }

    section.support.active {
        display: flex;
        flex-direction: column;
        gap: 2rem;
    }

    section.mission.active {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    .mission > figure {
        display: none;
    }

    .mission article > figure {
        display: grid;
        height: 40svh;
    }

    .mission > article {
        grid-column: 1;
        display: flex;
        flex-direction: column;
        gap: 2rem;
        min-height: 0;
        padding-bottom: 3rem;
    }

    .mission > article:not([aria-current]) {
        opacity: 1;
    }

    :root {
        --text-top: 2rem;
    }

    .mission > article > :not(hgroup),
    .support > ul {
        margin-top: 0;
    }

    .mission ol li {
        height: auto;
        min-height: 2.6rem;
    }

    .support > figure {
        height: 44svh;
    }

    aside svg {
        height: 3.4rem;
    }

    aside p {
        font-size: 2.9rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .intro body > aside {
        display: none;
    }

    figure[data-step] *,
    figure[data-step] *::before {
        animation-duration: 0s !important;
        animation-delay: 0s !important;
        animation-iteration-count: 1 !important;
        transition: none !important;
    }
}
