/* ==========================================================================
   The languages section of a landing (front/partials/languages-section):
   the languages a course is studied in, the picture on the left and the
   words on the right.

   The section stands inside .lp and wears the shared shapes of the landing
   (css/views/landing-page.css: the two columns, the chip, the heading, the
   point rows, the arrow button, the pill under a picture), so this sheet
   holds only what is its own: the aqua tint, the national mark in the left
   corner, the picture the page draws in the place of a photograph, and the
   line that closes its words. The section shows and tells: it carries no
   link and no button, and no flag beyond those of its picture.

   The picture is one glass plate. Three rings of flags turn round a globe
   that carries the number of languages; a ring is a square laid over the
   plate, a flag stands on its rim at the end of an arm, and while the ring
   turns one way every flag turns the other, so a flag is always upright.
   Every length of the picture is a share of the plate, so it is the same
   picture at 280px and at 650px. Whatever moves in the section moves
   slowly, on transforms alone, only while it is on the screen (.is-resting,
   js/views/languages-section.js), and not at all for a reader who asked
   for less motion.
   ========================================================================== */

.lp .langsWorldSection {
    --ls-deep: #155e75;
    --ls-ink: #0e7490;
    --ls-aqua: #0891b2;
    --ls-line: rgba(14, 116, 144, 0.14);
    background:
        radial-gradient(50% 60% at 100% 0%, rgba(165, 243, 252, 0.8) 0%, rgba(165, 243, 252, 0) 70%),
        radial-gradient(50% 60% at 0% 100%, rgba(199, 210, 254, 0.55) 0%, rgba(199, 210, 254, 0) 70%),
        linear-gradient(180deg, #f0fcfd 0%, #e3f6fa 100%);
}

/* The national mark of the sections, in the left corner this time: the
   picture stands on the left. The shamrock on an Irish platform, the crown
   on a British one, nine percent, and nothing where the columns stack. */
.lp--ie .langsWorldSection::before,
.lp--uk .langsWorldSection::before {
    content: '';
    position: absolute;
    z-index: 0;
    bottom: 40px;
    left: 3%;
    width: clamp(220px, 20vw, calc(340px * var(--lp-scale)));
    height: clamp(220px, 20vw, calc(340px * var(--lp-scale)));
    opacity: 0.09;
    pointer-events: none;
}

.lp--ie .langsWorldSection::before {
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><g fill='%23169B62'><path d='M12 12C9.6 9.7 6.2 9.9 6.2 6.9 6.2 4.7 7.9 3.1 9.7 3.1c1 0 1.9.5 2.3 1.3.4-.8 1.3-1.3 2.3-1.3 1.8 0 3.5 1.6 3.5 3.8 0 3-3.4 2.8-5.8 5.1Z'/><path d='M12 12C9.6 9.7 6.2 9.9 6.2 6.9 6.2 4.7 7.9 3.1 9.7 3.1c1 0 1.9.5 2.3 1.3.4-.8 1.3-1.3 2.3-1.3 1.8 0 3.5 1.6 3.5 3.8 0 3-3.4 2.8-5.8 5.1Z' transform='rotate(120 12 12)'/><path d='M12 12C9.6 9.7 6.2 9.9 6.2 6.9 6.2 4.7 7.9 3.1 9.7 3.1c1 0 1.9.5 2.3 1.3.4-.8 1.3-1.3 2.3-1.3 1.8 0 3.5 1.6 3.5 3.8 0 3-3.4 2.8-5.8 5.1Z' transform='rotate(240 12 12)'/></g><path d='M12 12.4c.3 2.7-.2 5.1-1.8 7.9' fill='none' stroke='%23169B62' stroke-width='1.6' stroke-linecap='round'/></svg>") center / contain no-repeat;
    transform: rotate(12deg);
}

.lp--uk .langsWorldSection::before {
    background: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><g fill='%23d97706'><path d='M5 16 3.2 6.6a.5.5 0 0 1 .8-.5L8.6 9.6 11.56 4.3a.5.5 0 0 1 .88 0l2.96 5.3 4.6-3.5a.5.5 0 0 1 .8.5L19 16H5Z'/><path d='M5.2 17.6h13.6a.9.9 0 0 1 .9.9v.8a.9.9 0 0 1-.9.9H5.2a.9.9 0 0 1-.9-.9v-.8a.9.9 0 0 1 .9-.9Z'/></g></svg>") no-repeat center / contain;
    transform: rotate(8deg);
}

/* --------------------------------------------------------------------------
   The picture
   -------------------------------------------------------------------------- */

.lp .langsVisualGlow {
    background: linear-gradient(135deg, #22d3ee, #818cf8);
}

.lp .langsStage {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    width: 100%;
    max-width: calc(560px * var(--lp-scale));
    aspect-ratio: 1 / 1;
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: var(--lp-radius);
    background:
        radial-gradient(circle at 50% 50%, rgba(34, 211, 238, 0.2) 0%, rgba(34, 211, 238, 0) 40%),
        radial-gradient(58% 52% at 14% 10%, rgba(165, 243, 252, 0.6) 0%, rgba(165, 243, 252, 0) 72%),
        radial-gradient(56% 52% at 88% 92%, rgba(199, 210, 254, 0.62) 0%, rgba(199, 210, 254, 0) 72%),
        linear-gradient(160deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.78) 100%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    backdrop-filter: blur(18px) saturate(150%);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 40px 80px -36px rgba(14, 116, 144, 0.55), 0 0 0 1px var(--ls-line);
    container-type: inline-size;
    transition: transform 0.35s var(--lp-ease);
}

.lp .langsStage:hover {
    transform: translateY(-4px);
}

/* a field of fine dots that fades toward the edge of the plate: the chart the flags travel over */
.lp .langsStage::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background-image: radial-gradient(rgba(14, 116, 144, 0.34) 1px, rgba(14, 116, 144, 0) 1.6px);
    background-size: 22px 22px;
    background-position: center;
    -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 0%, rgba(0, 0, 0, 0.5) 46%, rgba(0, 0, 0, 0) 74%);
    mask-image: radial-gradient(circle at 50% 50%, #000 0%, rgba(0, 0, 0, 0.5) 46%, rgba(0, 0, 0, 0) 74%);
    pointer-events: none;
}

/* the rim of the plate: one hairline that runs from aqua through white to indigo, the two lights of the plate */
.lp .langsStage::after {
    content: '';
    position: absolute;
    inset: -1px;
    padding: 1px;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.7) 0%, rgba(255, 255, 255, 0.95) 38%, rgba(255, 255, 255, 0.95) 62%, rgba(129, 140, 248, 0.6) 100%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
    pointer-events: none;
}

.lp .langsOrbit {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

/* A ring: a square laid over the plate, its dashed rim the path of its flags.
   --ls-pin is the width of a flag as a share of the ring, so the flags of the
   three rings are one size on the plate. */
.lp .langsRing {
    position: absolute;
    border-radius: 50%;
    animation: lp-langs-turn var(--ls-time) linear infinite;
    will-change: transform;
}

.lp .langsRing::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px dashed rgba(14, 116, 144, 0.3);
}

.lp .langsRing--1 { inset: 28%; --ls-time: 110s; --ls-pin: 17.4%; }
.lp .langsRing--2 { inset: 17.5%; --ls-time: 150s; --ls-pin: 11.8%; --ls-lead: 18deg; animation-direction: reverse; }
.lp .langsRing--3 { inset: 7%; --ls-time: 190s; --ls-pin: 9.3%; --ls-lead: 6deg; }

/* The flags share the rim evenly: a ring says how many it carries, an arm which one it is */
.lp .langsRing--of1 { --ls-step: 360deg; }
.lp .langsRing--of2 { --ls-step: 180deg; }
.lp .langsRing--of3 { --ls-step: 120deg; }
.lp .langsRing--of4 { --ls-step: 90deg; }
.lp .langsRing--of5 { --ls-step: 72deg; }
.lp .langsRing--of6 { --ls-step: 60deg; }
.lp .langsRing--of7 { --ls-step: calc(360deg / 7); }
.lp .langsRing--of8 { --ls-step: 45deg; }
.lp .langsRing--of9 { --ls-step: 40deg; }
.lp .langsRing--of10 { --ls-step: 36deg; }
.lp .langsRing--of11 { --ls-step: calc(360deg / 11); }
.lp .langsRing--of12 { --ls-step: 30deg; }
.lp .langsRing--of13 { --ls-step: calc(360deg / 13); }
.lp .langsRing--of14 { --ls-step: calc(360deg / 14); }
.lp .langsRing--of15 { --ls-step: 24deg; }
.lp .langsRing--of16 { --ls-step: 22.5deg; }

.lp .langsArm:nth-child(2) { --ls-i: 1; }
.lp .langsArm:nth-child(3) { --ls-i: 2; }
.lp .langsArm:nth-child(4) { --ls-i: 3; }
.lp .langsArm:nth-child(5) { --ls-i: 4; }
.lp .langsArm:nth-child(6) { --ls-i: 5; }
.lp .langsArm:nth-child(7) { --ls-i: 6; }
.lp .langsArm:nth-child(8) { --ls-i: 7; }
.lp .langsArm:nth-child(9) { --ls-i: 8; }
.lp .langsArm:nth-child(10) { --ls-i: 9; }
.lp .langsArm:nth-child(11) { --ls-i: 10; }
.lp .langsArm:nth-child(12) { --ls-i: 11; }
.lp .langsArm:nth-child(13) { --ls-i: 12; }
.lp .langsArm:nth-child(14) { --ls-i: 13; }
.lp .langsArm:nth-child(15) { --ls-i: 14; }
.lp .langsArm:nth-child(16) { --ls-i: 15; }

/* an arm reaches from the middle of the ring to its rim; the pin at its end
   turns back by the angle of the arm, so the flag stands upright */
.lp .langsArm {
    --ls-angle: calc(var(--ls-step, 0deg) * var(--ls-i, 0) + var(--ls-lead, 0deg));
    position: absolute;
    inset: 0;
    transform: rotate(var(--ls-angle));
}

.lp .langsPin {
    position: absolute;
    top: 0;
    left: 50%;
    width: var(--ls-pin);
    aspect-ratio: 1 / 1;
    margin: calc(var(--ls-pin) / -2) 0 0 calc(var(--ls-pin) / -2);
    transform: rotate(calc(var(--ls-angle) * -1));
}

/* a flag: a disc cut from the square symbol in a white enamel rim, turning
   against its ring at the pace of the ring */
.lp .langsFlag {
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    border: 3px solid #ffffff;
    border-radius: 50%;
    overflow: hidden;
    isolation: isolate;
    background: #e8eefb;
    box-shadow: 0 0 0 1px rgba(14, 116, 144, 0.18), 0 10px 18px -9px rgba(8, 51, 68, 0.6);
    animation: lp-langs-turn var(--ls-time) linear infinite reverse;
    will-change: transform;
}

.lp .langsRing--2 .langsFlag {
    animation-direction: normal;
}

.lp .langsFlag svg,
.lp .langsTagFlag svg {
    display: block;
    width: 100%;
    height: 100%;
}

@keyframes lp-langs-turn {
    to { transform: rotate(360deg); }
}

/* The globe in the middle: the number of languages over a sphere whose
   meridians turn. The sphere is an element of its own under the figure: a
   deep aqua ball in a white enamel rim, three parallels drawn on it. A
   meridian is a circle that narrows to a line and opens again, at the pace
   of a cosine, so the three of them read as one sphere that spins. */
.lp .langsCore {
    position: absolute;
    top: 35%;
    left: 35%;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 30%;
    height: 30%;
    color: #ffffff;
}

.lp .langsCoreGlobe {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    overflow: hidden;
    isolation: isolate;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0) calc(24% - 0.5px), rgba(255, 255, 255, 0.2) calc(24% - 0.5px), rgba(255, 255, 255, 0.2) calc(24% + 0.5px), rgba(255, 255, 255, 0) calc(24% + 0.5px)),
        linear-gradient(180deg, rgba(255, 255, 255, 0) calc(50% - 0.5px), rgba(255, 255, 255, 0.2) calc(50% - 0.5px), rgba(255, 255, 255, 0.2) calc(50% + 0.5px), rgba(255, 255, 255, 0) calc(50% + 0.5px)),
        linear-gradient(180deg, rgba(255, 255, 255, 0) calc(76% - 0.5px), rgba(255, 255, 255, 0.2) calc(76% - 0.5px), rgba(255, 255, 255, 0.2) calc(76% + 0.5px), rgba(255, 255, 255, 0) calc(76% + 0.5px)),
        radial-gradient(circle at 27% 20%, #a5f3fc 0%, #22b8d4 15%, #0e7490 50%, #155e75 80%, #164e63 100%);
    box-shadow:
        0 0 0 6px rgba(255, 255, 255, 0.86),
        0 0 0 7px rgba(14, 116, 144, 0.16),
        0 30px 50px -20px rgba(8, 51, 68, 0.7),
        inset 0 -14px 26px rgba(8, 51, 68, 0.42),
        inset 0 2px 0 rgba(255, 255, 255, 0.4);
}

.lp .langsCoreGlobe i {
    position: absolute;
    inset: 0;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    animation: lp-langs-meridian 21s linear infinite;
    will-change: transform;
}

.lp .langsCoreGlobe i:nth-child(2) { animation-delay: -7s; }
.lp .langsCoreGlobe i:nth-child(3) { animation-delay: -14s; }

@keyframes lp-langs-meridian {
    0% { transform: scaleX(1); animation-timing-function: cubic-bezier(0.47, 0, 0.745, 0.715); }
    50% { transform: scaleX(0.02); animation-timing-function: cubic-bezier(0.39, 0.575, 0.565, 1); }
    100% { transform: scaleX(1); }
}

/* the figure and its word are one sentence (a translation keeps them
   together); a longer word of another language folds inside the sphere */
.lp .langsCoreText {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.22em;
    max-width: 88%;
    margin: 0;
    font-size: clamp(34px, 5.1vw, 62px);
    font-size: 11.6cqw;
    text-align: center;
    text-shadow: 0 1px 0 rgba(8, 51, 68, 0.35), 0 8px 18px rgba(8, 51, 68, 0.45);
}

.lp .langsCoreCount {
    font-family: var(--lp-font-display);
    font-size: 1em;
    font-weight: 800;
    line-height: 0.92;
    letter-spacing: -0.035em;
}

.lp .langsCoreUnit {
    max-width: 100%;
    font-family: var(--lp-font-body);
    font-size: clamp(12px, 0.215em, 15px);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    overflow-wrap: anywhere;
}

/* Three languages in their own words, on the edge of the plate: the pill of
   the language menu, afloat like the pill under a picture */
.lp .langsTag {
    position: absolute;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 6px 16px 6px 6px;
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 18px 32px -18px rgba(8, 51, 68, 0.6), 0 0 0 1px var(--ls-line);
    font-family: var(--lp-font-display);
    font-size: calc(15px * var(--lp-scale));
    font-weight: 800;
    line-height: 1.3;
    letter-spacing: -0.005em;
    color: var(--lp-ink);
    white-space: nowrap;
    animation: lp-float 5.4s ease-in-out infinite;
}

.lp .langsTag--1 { top: 9%; left: -2.6%; }
.lp .langsTag--2 { top: 30%; right: -3.2%; animation-duration: 6.2s; animation-delay: -1.7s; }
.lp .langsTag--3 { bottom: 15%; left: 1.4%; animation-duration: 5.8s; animation-delay: -3.3s; }

.lp .langsTagFlag {
    flex: 0 0 auto;
    width: calc(30px * var(--lp-scale));
    height: calc(30px * var(--lp-scale));
    border-radius: 50%;
    overflow: hidden;
    isolation: isolate;
    background: #e8eefb;
    box-shadow: 0 0 0 1px rgba(11, 18, 32, 0.12);
}

/* The pill under the picture: the shape of every section, in the deep aqua of this one */
.lp .langsFloatingBadge {
    background: linear-gradient(140deg, #0e7490 0%, #155e75 55%, #164e63 100%);
    box-shadow: 0 4px 12px rgba(14, 116, 144, 0.3), 0 14px 32px -12px rgba(14, 116, 144, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.lp .langsFloatingBadge svg {
    color: #0e7490;
    stroke: #0e7490;
}

/* --------------------------------------------------------------------------
   The words
   -------------------------------------------------------------------------- */

.lp .langsPointIcon {
    background: linear-gradient(135deg, var(--ls-aqua) 0%, var(--ls-ink) 100%);
    box-shadow: 0 10px 20px -12px rgba(8, 145, 178, 0.8);
}

/* Where a language is chosen: one line under the points, the globe beside its
   first line. It closes the column; the section carries no link, no button
   and no flag beyond those of its picture. */
.lp .langsNote {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: calc(24px * var(--lp-scale)) 0 0;
    font-family: var(--lp-font-body);
    font-size: calc(15.5px * var(--lp-scale));
    font-weight: 500;
    line-height: 1.55;
    color: var(--lp-ink-2);
}

.lp .langsNote svg {
    flex: 0 0 auto;
    width: calc(20px * var(--lp-scale));
    height: calc(20px * var(--lp-scale));
    margin-top: calc((15.5px * 1.55 - 20px) / 2 * var(--lp-scale));
    color: var(--ls-ink);
}

/* --------------------------------------------------------------------------
   Smaller screens
   -------------------------------------------------------------------------- */

/* the columns stack: the picture follows the words and keeps to the middle */
@media (max-width: 1024px) {
    .lp .langsWorldSection::before {
        display: none;
    }

    .lp .langsStage {
        max-width: 500px;
    }

    /* the names stand inside the plate, as the pills of the certificate do once it is stacked:
       nothing leaves its card on a narrow screen */
    .lp .langsTag--1 { left: 2.4%; }
    .lp .langsTag--2 { right: 2.4%; }
    .lp .langsTag--3 { left: 3.4%; }
}

@media (max-width: 640px) {
    .lp .langsTag {
        gap: 7px;
        padding: 5px 13px 5px 5px;
        font-size: 14px;
    }

    .lp .langsTagFlag {
        width: 26px;
        height: 26px;
    }
}

/* A phone: two rings of larger flags round a larger globe. The middle ring
   rests; its flags are among those the row of languages shows. */
@media (max-width: 480px) {
    .lp .langsRing--2 {
        display: none;
    }

    .lp .langsRing--1 { inset: 21%; --ls-pin: 18.2%; }
    .lp .langsRing--3 { inset: 6.5%; --ls-pin: 12.1%; }

    .lp .langsFlag {
        border-width: 2.5px;
    }

    .lp .langsCore {
        top: 31.5%;
        left: 31.5%;
        width: 37%;
        height: 37%;
    }

    .lp .langsCoreGlobe {
        box-shadow:
            0 0 0 5px rgba(255, 255, 255, 0.86),
            0 0 0 6px rgba(14, 116, 144, 0.16),
            0 24px 40px -18px rgba(8, 51, 68, 0.7),
            inset 0 -10px 20px rgba(8, 51, 68, 0.42),
            inset 0 2px 0 rgba(255, 255, 255, 0.4);
    }

    .lp .langsCoreText {
        font-size: clamp(36px, 11.4vw, 50px);
        font-size: 13.4cqw;
    }

    .lp .langsCoreUnit {
        font-size: 12px;
        letter-spacing: 0.08em;
    }

    /* two names, one in each corner of a diagonal: a third would hide the flags of so small a plate */
    .lp .langsTag--1 { top: 5%; }
    .lp .langsTag--2 { top: auto; bottom: 13%; }
    .lp .langsTag--3 { display: none; }
}

/* --------------------------------------------------------------------------
   A page read in another language (html[data-site-lang], docs/TRANSLATION.md)
   -------------------------------------------------------------------------- */

/* The pill under the picture was sized for its English words on one line. A
   longer language takes two lines in the same place, never cut by its box;
   the English page is not touched. */
html[data-site-lang] .lp .langsFloatingBadge {
    white-space: normal;
    text-wrap: balance;
}

/* --------------------------------------------------------------------------
   Rest and stillness
   -------------------------------------------------------------------------- */

/* off the screen the picture rests where it stands */
.lp .langsVisualWrapper.is-resting *,
.lp .langsVisualWrapper.is-resting *::before {
    animation-play-state: paused;
}

/* a reader who asked for less motion: nothing turns and nothing floats */
@media (prefers-reduced-motion: reduce) {
    .lp .langsRing,
    .lp .langsFlag,
    .lp .langsCoreGlobe i,
    .lp .langsTag,
    .lp .langsFloatingBadge {
        animation: none;
    }

    .lp .langsStage:hover {
        transform: none;
    }
}
