/* form.css — Message form */

/* --- 1. BACKGROUND --- */
body {
    min-height: 100vh;
    min-height: 100dvh;   /* accounts for the mobile address bar */
    background:
        radial-gradient(ellipse 62% 58% at 50% 46%,
                        rgba(var(--star-rgb), .09) 0%,
                        rgba(var(--star-rgb), .03) 45%,
                        transparent 72%),
        radial-gradient(ellipse at 50% 42%,
                        var(--night-raised) 0%,
                        var(--night) 55%,
                        var(--abyss) 100%);
}

/* --- 3. DOTS --- */
.journey__dots {
    position: fixed;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    opacity: .3;
    pointer-events: none;
}

/* Fields on the frosted card: darker background, no second blur. */
.field,
.review {
    background: rgba(9, 11, 17, .5);
}

.field:focus {
    background: rgba(13, 15, 23, .62);
}

/* --- 4. SCREEN AND CARD --- */
.screen {
    position: relative;
    z-index: 1;   /* above the background */
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;   /* accounts for the mobile address bar */
    padding: var(--gutter);
}

/* Card. */
.screen__card {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 30rem;
    margin: auto;
    padding: 2rem 1.6rem 1.75rem;
    background: rgba(13, 15, 23, .55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--rule);
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .45);

    /* One card per screen; animating the height makes them look like one. */
    transition: height .45s cubic-bezier(.3, .7, .3, 1);
}

/* Clip during the height transition. */
.screen__card.is-resizing {
    overflow: hidden;
}

/* Cards are hidden until form.js starts the entrance (section 5b). */
.screen__card {
    opacity: 0;
}

/* --- 5. SCREEN TRANSITIONS --- */
.screen__header,
.screen__body,
.screen__footer {
    opacity: 0;
}

.screen--in .screen__header,
.screen--in .screen__body,
.screen--in .screen__footer {
    animation: block-in .7s cubic-bezier(.25, .6, .3, 1) both;
}

/* Exit: the blocks fade, the card stays and resizes. */
.screen--out .screen__header,
.screen--out .screen__body,
.screen--out .screen__footer {
    animation: block-out .25s ease both;
}

@keyframes block-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* Reveal timing. */
.screen--in .screen__header { animation-delay: .08s; }
.screen--in .screen__body   { animation-delay: .28s; }
.screen--in .screen__footer { animation-delay: .50s; }

@keyframes block-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* The header does not animate. */
.journey--settled .screen__header,
.journey--settled .screen--in .screen__header,
.journey--settled .screen--out .screen__header {
    opacity: 1;
    animation: none;
}

/* Reduced motion: no animation. Must come after the rules it overrides. */
@media (prefers-reduced-motion: reduce) {
    .screen__card {
        transition: none;
    }

    .screen--out .screen__header,
    .screen--out .screen__body,
    .screen--out .screen__footer {
        animation: none;
    }

    .screen__header,
    .screen__body,
    .screen__footer,
    .screen--in .screen__header,
    .screen--in .screen__body,
    .screen--in .screen__footer {
        opacity: 1;
        animation: none;
    }
}

/* --- 5b. PAGE ENTRANCE --- */
/* Once started, every card is visible, including those of hidden screens. */
.journey--entering .screen__card {
    opacity: 1;
}

/* Only the card shown on load animates; form.js adds then removes this class. */
.screen__card.is-arriving {
    animation: block-in .8s ease .25s both;
}

/* --- 6. HEADER: logo and step number --- */
.screen__header {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    position: relative;
    margin-bottom: 2rem;
}

/* Logo, as an image. */
.screen__logo {
    display: block;
    width: 9.36rem;   /* 150px, in rem so a tablet scales it (section 14) */
    aspect-ratio: 1536 / 1024;   /* file dimensions */
    background: url("../img/icone-arbre.webp") center / contain no-repeat;
}

.screen__step {
    position: absolute;
    top: .35rem;
    right: 0;
    font-size: .72rem;
    letter-spacing: .08em;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   7. BODY: screen content
   -------------------------------------------------------------------------- */
/* No flex: 1, or the body would push the button down. */
.screen__body {
    flex: 0 0 auto;
}

/* Introduction (screen 1). */
.intro p {
    margin: 0 0 1.35rem;
    font-size: .95rem;
    font-weight: 300;
    line-height: 1.75;
}

.intro p:last-child {
    margin-bottom: 0;
}

/* Question (screen 2), styled like the page titles. */
.question {
    margin: 0 0 1.75rem;
    font-size: clamp(1.5rem, 5vw, 1.85rem);
    font-weight: 300;
    line-height: 1.25;
    letter-spacing: -.01em;
    color: var(--text-bright);
    text-shadow: 0 0 30px rgba(192, 139, 62, .25);
}

/* Review heading (screen 3). */
.section-title {
    margin: 0 0 1.25rem;
    font-size: 1.25rem;
    font-weight: 300;
    line-height: 1.35;
    color: var(--text-bright);
}

/* --- 8. MESSAGE FIELD AND COUNTER (screen 2) --- */
.message-field {
    position: relative;
}

.message-field .field--textarea {
    padding-bottom: 2.4rem;   /* room for the counter */
}

.counter {
    position: absolute;
    right: .95rem;
    bottom: .65rem;
    margin: 0;
    font-size: .78rem;
    font-variant-numeric: tabular-nums;   /* stable digit widths */
    color: var(--text-muted);
    pointer-events: none;
}

/* Counter turns cyan over the last 30 characters. */
.counter.is-near-limit {
    color: var(--glow);
}

/* --------------------------------------------------------------------------
   9. REVIEW AND SIGNATURE (screen 3)
   -------------------------------------------------------------------------- */
.review {
    margin: 0;
    padding: 1.1rem 1.15rem;
    background: var(--veil);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    font-size: .95rem;
    font-weight: 300;
    line-height: 1.7;
    white-space: pre-wrap;   /* keep the line breaks */
    overflow-wrap: break-word;
}

/* First name and initial side by side. */
.identity {
    display: flex;
    gap: .75rem;
    margin-top: 1.4rem;
}

.identity__first-name {
    flex: 1 1 auto;
    min-width: 0;
}

.identity__initial {
    flex: 0 0 5.5rem;
}

.identity__initial .field {
    text-align: center;
    text-transform: uppercase;
}

/* Country. */
.country {
    margin-top: 1.1rem;
}

/* With country-picker.js the select is replaced by a button opening the list. */
.country--enhanced select {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
}

.country-trigger {
    padding-right: 2.6rem;
    text-align: left;
    cursor: pointer;
}

.country-trigger--empty {
    color: var(--text-muted);
}

.country-trigger[aria-invalid="true"] {
    border-color: rgba(255, 155, 138, .6);
}

/* Select styled like the other fields. */
.select {
    position: relative;
}

.select select {
    padding-right: 2.6rem;
    cursor: pointer;
}

.select::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 1.1rem;
    width: .5rem;
    height: .5rem;
    border-right: 1.5px solid var(--glow);
    border-bottom: 1.5px solid var(--glow);
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}

/* Options get an explicit colour, since the open list uses the system background. */
.select option {
    background: var(--night);
    color: var(--text-bright);
}

/* --- 9b. COUNTRY LIST (country-picker.js) --- */
.picker {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
}

.picker[open] {
    display: flex;
}

.picker::backdrop {
    background: rgba(3, 4, 8, .72);
    -webkit-backdrop-filter: blur(6px);
            backdrop-filter: blur(6px);
}

.picker__panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #070a12;
}

.picker__head {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.25rem .9rem;
    border-bottom: 1px solid rgba(var(--glow-rgb), .25);
}

.picker__title {
    margin: 0;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--glow-soft);
}

.picker__close {
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    margin-right: -.5rem;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.picker__close:hover,
.picker__close:focus-visible {
    background: rgba(var(--glow-rgb), .12);
    color: var(--glow-soft);
    outline: none;
}

/* Title between the back arrow and the ×. */
.picker__title {
    flex: 1;
}

/* Back to the common countries. */
.picker__back {
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    margin-left: -.6rem;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 50%;
    color: var(--glow);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.picker__back[hidden] {
    display: none;
}

.picker__back:hover,
.picker__back:focus-visible {
    background: rgba(var(--glow-rgb), .12);
    color: var(--glow-soft);
    outline: none;
}

/* "Other…" opens the full list. */
.picker__option.picker__option--other {
    color: var(--glow-soft);
    border-bottom: 0;
}

.picker__option.picker__option--other::after {
    content: "›";
    font-size: 1.3rem;
    line-height: 1;
    color: var(--glow);
}

.picker__search {
    flex: none;
    position: relative;
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem .5rem;
}

.picker__search svg {
    position: absolute;
    left: 2.1rem;
    width: .9rem;
    height: .9rem;
    color: var(--text-muted);
    pointer-events: none;
}

.picker__search .field {
    padding-left: 2.6rem;
    border-color: rgba(var(--glow-rgb), .35);
}

/* The list scrolls; header and search stay. */
.picker__list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 .75rem 2rem;
    scrollbar-color: rgba(var(--glow-rgb), .45) transparent;
    scrollbar-width: thin;
}

/* Sticky group title. */
.picker__group-title {
    position: sticky;
    top: 0;
    z-index: 1;
    margin: 0;
    padding: 1rem .5rem .45rem;
    background: #070a12;
    font-size: .66rem;
    font-weight: 600;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* One row per country, at least 3rem tall. */
.picker__option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    min-height: 3rem;
    padding: .7rem .75rem;
    background: none;
    border: 0;
    border-bottom: 1px solid rgba(var(--star-rgb), .08);
    border-radius: 0;
    color: var(--text-bright);
    font-family: var(--sans);
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
}

.picker__option:hover,
.picker__option:focus-visible {
    background: rgba(var(--glow-rgb), .1);
    outline: none;
}

.picker__option--chosen {
    color: var(--glow-soft);
}

.picker__option--chosen::after {
    content: "✓";
    color: var(--glow);
}

.picker__none {
    margin: 2rem 1.25rem;
    color: var(--text-muted);
    text-align: center;
}

/* Wider screens: centred panel; clicking outside closes it. */
@media (min-width: 640px) {
    .picker[open] {
        align-items: center;
        justify-content: center;
        padding: 2rem;
    }

    .picker__panel {
        width: min(28rem, 100%);
        height: min(40rem, 100%);
        border: 1px solid rgba(var(--glow-rgb), .55);
        border-radius: 14px;
        box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
        overflow: hidden;
    }
}

/* Fades with allow-discrete and @starting-style where supported. */
.picker,
.picker::backdrop {
    opacity: 0;
    transition: opacity .25s ease,
                display .25s allow-discrete,
                overlay .25s allow-discrete;
}

.picker[open],
.picker[open]::backdrop {
    opacity: 1;
}

@starting-style {
    .picker[open],
    .picker[open]::backdrop {
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .picker,
    .picker::backdrop {
        transition: none;
    }
}

/* No page scroll while the list is open. */
html:has(.picker[open]) {
    overflow: hidden;
}

/* --------------------------------------------------------------------------
  10. CONFIRMATION (screen 4)
   -------------------------------------------------------------------------- */
.thanks {
    display: flex;
    flex-direction: column;
    text-align: center;
}

.thanks__check {
    width: 3.9rem;
    height: 3.9rem;
    margin: 0 auto 1.5rem;
    border: 1px solid var(--glow);
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--glow);
    box-shadow: 0 0 30px rgba(var(--glow-rgb), .18);
}

.thanks__title {
    margin: 0 0 1.25rem;
    font-size: 2rem;
    font-weight: 300;
    color: var(--text-bright);
}

.thanks p {
    margin: 0 0 1.1rem;
    font-size: .92rem;
    font-weight: 300;
    line-height: 1.7;
}

/* Site address callout */
.link-card {
    display: flex;
    gap: .7rem;
    align-items: center;
    margin-top: 1.5rem;
    padding: .9rem 1rem;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    font-size: .8rem;
    line-height: 1.5;
    text-align: left;
}

.link-card__icon {
    flex: 0 0 auto;
    width: 1.35rem;
    height: 1.35rem;
    color: var(--glow);
}

.link-card a {
    color: var(--glow);
    font-weight: 500;
    text-decoration: none;
    overflow-wrap: break-word;
}

.link-card a:hover {
    text-decoration: underline;
}

/* --------------------------------------------------------------------------
  11. BUTTONS
   -------------------------------------------------------------------------- */
.screen__footer {
    margin-top: 2rem;
}

/* Turnstile widget, when enabled. */
.cf-turnstile {
    margin-bottom: .9rem;
}

/* --- 12. WIDE SCREENS --- */
@media (min-width: 640px) {
    /* Centred card on wide screens. */
    .screen__card {
        max-width: 34rem;
        padding: 3.25rem 3rem 2.75rem;
        background: rgba(16, 18, 26, .74);
        border-radius: 24px;
        box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
    }

    .screen__logo {
        width: 13.2rem;   /* 211px */
    }

    .screen__header {
        margin-bottom: 2.6rem;
    }

    .intro p {
        margin-bottom: 1.5rem;
        font-size: 1.02rem;
    }

    .section-title {
        font-size: 1.4rem;
    }

    .button {
        padding: 1.1rem 1.25rem;
        font-size: .85rem;
    }

    .screen__footer {
        margin-top: 2.4rem;
    }
}

/* --- 13. BACKGROUND PULSE --- */ /* Each layer has a rest opacity and an amplitude. */
.journey__dots {
    --rest-opacity: .3;
    --pulse: 2.9;
}

.journey--pulse .journey__dots {
    animation: background-pulse 2.4s ease-in-out;
}

@keyframes background-pulse {
      0% { opacity: var(--rest-opacity); }
     22% { opacity: calc(var(--rest-opacity) * var(--pulse)); }   /* at 530 ms */
    100% { opacity: var(--rest-opacity); }
}

@media (prefers-reduced-motion: reduce) {
    .journey--pulse .journey__dots {
        animation: none;
    }
}

/* --- 13b. SHORT SCREENS (small phones) --- */
/* Tighter card, so each screen fits without scrolling. */
@media (max-height: 820px) {
    .screen {
        padding: 1rem;
    }

    .screen__card {
        padding: 1.4rem 1.25rem 1.25rem;
    }

    .screen__header {
        margin-bottom: 1.1rem;
    }

    .screen__logo {
        width: 6.5rem;
    }

    .intro p {
        margin-bottom: 1rem;
        font-size: .9rem;
        line-height: 1.55;
    }

    .question {
        margin-bottom: 1.1rem;
        font-size: clamp(1.3rem, 4.5vw, 1.6rem);
    }

    .message-field .field--textarea {
        min-height: 7rem;
    }

    .note {
        margin-top: .8rem;
        font-size: .75rem;
    }

    .screen__footer {
        margin-top: 1rem;
    }

    .section-title {
        margin-bottom: .9rem;
    }
}

/* Under 900px the quoted message scrolls instead of stretching the card. */
@media (max-height: 900px) {
    .screen__header {
        margin-bottom: 1.4rem;
    }

    .screen__logo {
        width: 7.5rem;
    }

    .review {
        max-height: 6rem;
        overflow: auto;
        padding: .8rem .95rem;
        line-height: 1.5;
    }

    .identity {
        margin-top: .8rem;
    }

    .country {
        margin-top: .7rem;
    }

    .consent {
        margin-top: .8rem;
    }

    .field-label {
        margin-bottom: .3rem;
    }

    .section-title {
        font-size: 1.1rem;
    }
}

@media (max-height: 740px) {
    .review {
        max-height: 4.5rem;
    }

    [data-screen="review"] .note {
        display: none;
    }
}

/* Very short screens: the message field gives up a little more. */
@media (max-height: 620px) {
    .screen__card {
        padding: 1rem .9rem .9rem;
    }

    .screen__header {
        margin-bottom: .7rem;
    }

    .message-field .field--textarea {
        min-height: 6rem;
    }

    .screen__logo {
        width: 3.5rem;
    }

    .review {
        max-height: 2.8rem;
    }

    .screen__footer {
        margin-top: .6rem;
    }

    .identity,
    .country,
    .consent {
        margin-top: .55rem;
    }

    .consent {
        font-size: .72rem;
    }
}

/* --- 14. PORTRAIT TABLETS --- */
@media (min-width: 700px) and (orientation: portrait) {
    html {
        font-size: 125%;
    }

    .screen__card {
        max-width: 36rem;
    }
}

/* --- 15. PERSONAL DATA DIALOG --- */
/* The page behind does not scroll while the dialog is open. */
body:has(.privacy[open]) {
    overflow: hidden;
}

.privacy {
    width: min(34rem, calc(100% - 2rem));
    max-height: min(80vh, 40rem);
    margin: auto;
    padding: 0;
    /* Only the body scrolls, never the dialog itself. */
    overflow: hidden;
    background: #070a12;
    color: var(--text);
    border: 1px solid rgba(var(--glow-rgb), .25);
    border-radius: 6px;
}

.privacy::backdrop {
    background: rgba(3, 4, 8, .72);
    -webkit-backdrop-filter: blur(6px);
            backdrop-filter: blur(6px);
}

.privacy__panel {
    display: flex;
    flex-direction: column;
    max-height: min(80vh, 40rem);
    min-height: 0;
}

.privacy__head {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem .8rem;
    border-bottom: 1px solid rgba(var(--glow-rgb), .25);
}

.privacy__title {
    margin: 0;
    font-size: .85rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-bright);
}

.privacy__close {
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    margin-right: -.5rem;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.privacy__close:hover,
.privacy__close:focus-visible {
    background: rgba(var(--glow-rgb), .12);
    color: var(--glow-soft);
    outline: none;
}

.privacy__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: .5rem 1.25rem 1.25rem;
}

.privacy__body h3 {
    margin: 1.2rem 0 .4rem;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--glow-soft);
}

.privacy__body p {
    margin: 0 0 .7rem;
    font-size: .85rem;
    line-height: 1.6;
}
