/* Global goals section: 3D goal cabinets with pull-out drawers and paper models, over a meadow backdrop. */

/* Global goals: each card is a small cabinet turned 45° in 3D. Its front is a drawer that pulls
   out towards the viewer on hover, revealing the goal's aim written on the drawer's side. */
.goal-cell {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 20px;
    container-type: inline-size;
}

.goal-stage {
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 1;
    perspective: 900px;
    color: #fff;
}

/* the goal's name under its cabinet: a one-word name that swaps to the full title on hover */
.goal-caption {
    position: relative;
    z-index: 2;
    display: grid;
    justify-items: center;
    max-width: 90%;
    margin-top: 2cqw;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    text-align: center;
    text-transform: lowercase;
    color: var(--color-navy);
}

.goal-caption > span {
    grid-area: 1 / 1;
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.goal-caption-short {
    font-size: 16px;
}

.goal-caption-full {
    opacity: 0;
    transform: translateY(6px);
    text-decoration: underline 2px var(--goal);
    text-underline-offset: 4px;
}

.goal-cell:hover .goal-caption-short,
.goal-cell:focus-visible .goal-caption-short {
    opacity: 0;
    transform: translateY(-6px);
}

.goal-cell:hover .goal-caption-full,
.goal-cell:focus-visible .goal-caption-full {
    opacity: 1;
    transform: translateY(0);
}

.goal-cell:hover,
.goal-cell:focus-visible {
    z-index: 30;
    outline: none;
}

.goal-cube {
    --s: 50cqw;
    --pull: calc(var(--s) * 0.92);
    position: relative;
    width: var(--s);
    height: var(--s);
    transform-style: preserve-3d;
    transform-origin: 50% 50% calc(var(--s) * -0.5);
    transform: translate(5cqw, 12cqw) rotateX(-20deg) rotateY(-45deg);
}

.goal-cube span {
    display: block;
}

.goal-cube-top,
.goal-cube-right,
.goal-topper,
.goal-drawer,
.goal-drawer-top,
.goal-drawer-side,
.goal-drawer-front {
    position: absolute;
}

/* cabinet walls: top and right, extending back from the front */
.goal-cube-top {
    left: 0;
    top: 0;
    width: var(--s);
    height: var(--s);
    background:
        radial-gradient(ellipse 30% 30% at 50% 50%, rgb(0 0 0 / 0.28), transparent 75%),
        color-mix(in srgb, var(--goal) 82%, #fff);
    transform-origin: top;
    transform: rotateX(-90deg);
}

.goal-cube-right {
    left: var(--s);
    top: 0;
    width: var(--s);
    height: var(--s);
    background: color-mix(in srgb, var(--goal) 70%, #12151d);
    transform-origin: left;
    transform: rotateY(90deg);
}

/* paper model standing in the middle of the cabinet top, turned to face the viewer */
.goal-topper {
    left: calc(var(--s) * 0.15);
    top: calc(var(--s) * -0.7);
    width: calc(var(--s) * 0.7);
    height: calc(var(--s) * 0.7);
    transform-style: preserve-3d;
    transform-origin: 50% 100%;
    transform: translateZ(calc(var(--s) * -0.5)) rotateY(45deg);
}

.goal-topper-spin {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    transform-origin: 50% 100%;
}

.goal-topper svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* back copies, each a little further back and darker, read as the paper's thickness */
.goal-topper svg:nth-child(2) { transform: translateZ(-1.5px); filter: brightness(0.82); }
.goal-topper svg:nth-child(3) { transform: translateZ(-3px); filter: brightness(0.72); }
.goal-topper svg:nth-child(4) { transform: translateZ(-4.5px); filter: brightness(0.62); }

.goal-cell:hover .goal-topper-spin,
.goal-cell:focus-visible .goal-topper-spin {
    animation: topper-spin 1s cubic-bezier(0.3, 0.7, 0.3, 1);
}


@keyframes topper-spin {
    from { transform: rotateY(0) translateY(-8%); }
    to { transform: rotateY(360deg) translateY(0); }
}

/* the goal's icon, large and faint on the cabinet side */
.goal-cube-right svg {
    position: absolute;
    left: 18%;
    top: 18%;
    width: 64%;
    height: 64%;
    color: rgb(255 255 255 / 0.22);
}

/* the drawer: front face plus a body that stays hidden inside the cabinet until pulled */
.goal-drawer {
    inset: 0;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.goal-cell:hover .goal-drawer,
.goal-cell:focus-visible .goal-drawer {
    transform: translateZ(var(--pull));
}

.goal-drawer-front {
    inset: 0;
    display: flex !important;
    flex-direction: column;
    justify-content: space-between;
    padding: calc(var(--s) * 0.1);
    background: var(--goal);
    box-shadow: inset 0 0 0 calc(var(--s) * 0.025) rgb(255 255 255 / 0.18);
}

.goal-drawer-number {
    font-family: var(--font-serif);
    font-size: calc(var(--s) * 0.3);
    font-weight: 900;
    line-height: 1;
}

.goal-drawer-icon {
    align-self: flex-end;
    width: calc(var(--s) * 0.42);
    height: calc(var(--s) * 0.42);
    margin-bottom: calc(var(--s) * 0.06);
    flex: none;
}


.goal-drawer-handle {
    position: absolute;
    bottom: calc(var(--s) * 0.07);
    left: 50%;
    width: calc(var(--s) * 0.26);
    height: calc(var(--s) * 0.035);
    border-radius: 99px;
    background: rgb(255 255 255 / 0.55);
    transform: translateX(-50%);
}

.goal-drawer-side {
    left: calc(var(--s) - 3px);
    top: 3px;
    width: var(--s);
    height: calc(var(--s) - 3px);
    padding: calc(var(--s) * 0.08) calc(var(--s) * 0.14) 0 calc(var(--s) * 0.08);
    overflow: hidden;
    background: #fbfaf6;
    border-top: calc(var(--s) * 0.04) solid var(--goal);
    color: var(--color-navy);
    transform-origin: left;
    transform: rotateY(90deg);
}

.goal-drawer-aim {
    font-size: calc(var(--s) * 0.08);
    line-height: 1.3;
}

.goal-drawer-link {
    margin-top: calc(var(--s) * 0.06);
    font-size: calc(var(--s) * 0.07);
    font-weight: 700;
    color: color-mix(in srgb, var(--goal) 80%, #12151d);
    text-transform: lowercase;
}

.goal-drawer-top {
    left: 0;
    top: 3px;
    width: calc(var(--s) - 3px);
    height: var(--s);
    background: #ece5d6;
    transform-origin: top;
    transform: rotateX(-90deg);
}

/* the files in the drawer: folders standing upright, one behind the other, each with a tab in the goal's colour
   and a few ruled lines; hidden in the closed drawer, they rise up as it opens */
.goal-drawer-files {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    pointer-events: none;
}

.goal-file {
    position: absolute;
    left: 9%;
    width: 82%;
    height: calc(var(--s) * 0.34);
    top: calc(var(--s) * -0.16);
    border-radius: calc(var(--s) * 0.02) calc(var(--s) * 0.02) 0 0;
    background: #fffdf7;
    box-shadow: inset 0 0 0 1px rgb(49 54 70 / 0.12), 0 -1px 4px rgb(49 54 70 / 0.1);
    opacity: 0;
    transform: translateZ(var(--z)) translateY(calc(var(--s) * 0.2));
    transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease;
}

/* the folder's tab, in the goal's colour, a little to one side */
.goal-file::before {
    content: '';
    position: absolute;
    top: calc(var(--s) * -0.05);
    left: var(--tab, 12%);
    width: 32%;
    height: calc(var(--s) * 0.06);
    border-radius: calc(var(--s) * 0.02) calc(var(--s) * 0.02) 0 0;
    background: var(--goal);
}

/* a few ruled lines on the sheet */
.goal-file-lines {
    position: absolute;
    left: 12%;
    right: 12%;
    top: 22%;
    height: 40%;
    background: repeating-linear-gradient(180deg, rgb(49 54 70 / 0.18) 0 1px, transparent 1px calc(var(--s) * 0.05));
}

.goal-file.is-1 { --z: calc(var(--s) * -0.62); --tab: 58%; background: color-mix(in srgb, var(--goal) 18%, #fffdf7); }
.goal-file.is-2 { --z: calc(var(--s) * -0.42); --tab: 34%; background: #f4ecd8; }
.goal-file.is-3 { --z: calc(var(--s) * -0.22); --tab: 10%; }

.goal-cell:hover .goal-file,
.goal-cell:focus-visible .goal-file {
    opacity: 1;
    transform: translateZ(var(--z)) translateY(0);
}

.goal-cell:hover .goal-file.is-2,
.goal-cell:focus-visible .goal-file.is-2 { transition-delay: 0.06s; }

.goal-cell:hover .goal-file.is-3,
.goal-cell:focus-visible .goal-file.is-3 { transition-delay: 0.12s; }

@media (prefers-reduced-motion: reduce) {
    .goal-file { transition: none; }
    .goal-drawer,
    .goal-caption > span {
        transition: none;
    }

    .goal-topper-spin,
    .goal-cell:hover .goal-topper-spin {
        animation: none;
    }
}

/* Global goals backdrop: pale sky fading into the meadow; clouds bob gently in place */
.goals-scene {
    background: linear-gradient(180deg, #dcedf8 0%, #eaf6f6 45%, #f1f9ef 100%);
}

/* what a goal holds, under its cabinet (and in the goals list): small chips in the goal's colour, wrapping as needed */
.goal-count {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    max-width: 92%;
}

/* in the /goals list the chips line up under the goal's aim */
.goal-count.is-start {
    justify-content: flex-start;
    max-width: none;
}

.goal-count-chip {
    padding: 1px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--goal) 14%, #fff);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.7;
    white-space: nowrap;
    color: color-mix(in srgb, var(--goal) 80%, #1b1f2a);
}

.goal-count-chip b {
    font-weight: 800;
}

.goal-count.is-empty .goal-count-chip {
    background: rgb(49 54 70 / 0.06);
    color: rgb(49 54 70 / 0.45);
}

/* under a cabinet the chips sit at the foot of the cell, so every row lines up whatever the length of the name */
.goal-cell > .goal-count {
    margin-top: auto;
    translate: 0 8px;
}

/* the torn foot of the goals section takes the colour of what follows: the reports corner on the home page */
.goals-tear { color: #fdf2e6; }
section:has(+ #reports) .goals-tear { color: var(--color-mint-light); }
