/*
 * Rappel Mail, public pages.
 * Idea: the form is an envelope (black outline like the logo, sand-tinted
 * flap) and the chosen send date is cancelled into a postmark. Everything
 * around it stays quiet: grey paper, plain type, one sand accent.
 */

:root {
    color-scheme: light;

    /* Legacy palette */
    --paper: #f0f0f0;
    --white: #ffffff;
    --ink: #000000;
    --brown: #8b4513;      /* saddlebrown: headings, postmark ink, primary action */
    --sand: #caa77c;       /* the logo's hourglass sand */
    --sand-tint: #ece0d1;  /* sand at 35% on white: envelope flap */
    --glass: #e3e4de;      /* the illustration's glass: ruled lines */
    --green: #008000;      /* validated addresses, completed steps */
    --green-bright: #00c000;
    --maroon: #800000;     /* warnings and errors */
    --lavender: #f0f0ff;
    --link: #0000a0;
    --rule: #c0c0c0;
    --muted: #595959;

    --serif: "Alegreya", Georgia, "Times New Roman", serif;
    --sans: "Alegreya Sans", "Trebuchet MS", Verdana, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 106.25%; /* 17px */
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    line-height: 1.5;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    color: var(--link);
}

:focus-visible {
    outline: 3px solid var(--brown);
    outline-offset: 2px;
}

b {
    font-weight: 700;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.email {
    overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- Header */

.site-header {
    max-width: 1120px;
    margin: 0 auto;
    padding: 16px 16px 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    text-decoration: none;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.35rem;
}

.brand img {
    display: block;
    width: 58px;
}

/* ---------------------------------------------------------------- Page grid */

.page {
    max-width: 1120px;
    margin: 0 auto;
    padding: 20px 16px 48px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "intro art"
        "main  main"
        "steps steps"
        "about about"
        "faq   faq";
    column-gap: 16px;
    row-gap: 28px;
}

.page-intro {
    grid-area: intro;
    align-self: center;
}

.page-art {
    grid-area: art;
    align-self: start;
}

.page-art img {
    display: block;
    width: 84px;
}

.page-main {
    grid-area: main;
    min-width: 0;
}

.steps {
    grid-area: steps;
}

.about {
    grid-area: about;
}

.faq {
    grid-area: faq;
}

h1 {
    font-family: var(--serif);
    font-weight: 700;
    font-size: clamp(1.55rem, 1.1rem + 1.8vw, 2.1rem);
    line-height: 1.1;
    margin: 0 0 12px;
    overflow-wrap: break-word;
    text-wrap: balance;
}

.lead {
    font-size: 1.125rem;
    margin: 0;
    max-width: 34em;
}

@media (max-width: 359px) {
    .page-art img {
        width: 64px;
    }
}

@media (min-width: 880px) {
    html {
        font-size: 112.5%; /* 18px */
    }

    .site-header {
        padding: 24px 32px 0;
    }

    .page {
        padding: 36px 32px 72px;
        grid-template-columns: minmax(0, 1fr) 300px;
        grid-template-areas:
            "intro art"
            "main  art"
            "main  steps"
            "about about"
            "faq   faq";
        grid-template-rows: auto auto 1fr auto auto;
        column-gap: 64px;
        row-gap: 32px;
    }

    .page-intro {
        align-self: start;
    }

    .page-art img {
        width: 300px;
    }

    .steps {
        align-self: start;
    }
}

/* ---------------------------------------------------------------- Envelope */

.envelope {
    position: relative;
    background: var(--white);
    border: 3px solid var(--ink);
    border-radius: 3px;
    box-shadow: 8px 8px 0 var(--sand);
    margin: 0 8px 8px 0;
    padding: 60px 16px 24px;
}

/* The flap: a black V (::before) under a sand-tinted triangle (::after) that
   is 3px shorter, leaving two tapering lines like the logo's diagonals. */
.envelope::before,
.envelope::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    pointer-events: none;
}

.envelope::before {
    background: var(--ink);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.envelope::after {
    background: var(--sand-tint);
    clip-path: polygon(0 0, 100% 0, 50% calc(100% - 3px));
}

.envelope-compact {
    padding-top: 56px;
}

@media (min-width: 560px) {
    .envelope {
        padding: 76px 28px 28px;
    }

    .envelope::before,
    .envelope::after {
        height: 52px;
    }

    .envelope-compact {
        padding-top: 72px;
    }
}

/* ---------------------------------------------------------------- Reminder / letter switch */

/* Two halves of one outlined control; the chosen half is inked in brown. */
.kind {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-width: 0;
    margin: 0 0 26px;
    padding: 0;
    overflow: hidden;
    border: 1.5px solid var(--ink);
    border-radius: 3px;
}

.kind-option {
    position: relative;
    display: flex;
    cursor: pointer;
}

.kind-option + .kind-option {
    border-left: 1.5px solid var(--ink);
}

.kind-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
}

.kind-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    background: var(--white);
    transition: background-color 0.12s ease, color 0.12s ease;
}

.kind-name {
    font-weight: 700;
    line-height: 1.25;
}

.kind-desc {
    font-size: 0.875rem;
    line-height: 1.3;
    color: var(--muted);
}

.kind-option:hover .kind-text {
    background: var(--lavender);
}

.kind-option input:checked + .kind-text {
    color: var(--white);
    background: var(--brown);
}

.kind-option input:checked + .kind-text .kind-desc {
    color: var(--white);
}

/* White inner ring shows on the brown half, black ring on the white one. */
.kind-option input:focus-visible + .kind-text {
    box-shadow: inset 0 0 0 3px var(--white), inset 0 0 0 5px var(--ink);
}

/* ---------------------------------------------------------------- Fields */

.field {
    margin: 0 0 26px;
}

.field-label {
    display: block;
    margin: 0 0 8px;
    font-family: var(--serif);
    font-style: italic;
    font-weight: 500;
    font-size: 1.4rem;
    line-height: 1.2;
    color: var(--brown);
}

input[type="text"],
input[type="email"],
select,
textarea {
    font: inherit;
    font-size: 1rem;
    color: var(--ink);
    background: var(--white);
    border: 1.5px solid var(--ink);
    border-radius: 3px;
    padding: 10px 12px;
    min-height: 46px;
    max-width: 100%;
}

select {
    padding-right: 6px;
    cursor: pointer;
}

input::placeholder,
textarea::placeholder {
    color: #767676;
    opacity: 1;
}

input[type="email"] {
    width: 100%;
}

/* The message reads as a letter: serif, on faint ruled lines. */
.letter-input {
    display: block;
    width: 100%;
    font-family: var(--serif);
    font-size: 1.15rem;
    line-height: 1.6;
    padding: 8px 12px;
    resize: vertical;
    background-image: linear-gradient(transparent calc(1.6em - 1px), var(--glass) calc(1.6em - 1px));
    background-size: 100% 1.6em;
    background-position: 0 8px;
    background-attachment: local;
}

.hint {
    margin: 8px 0 0;
    max-width: 40em;
    font-size: 0.9375rem;
    color: var(--muted);
}

.hint-warn,
.hint.is-error {
    color: var(--maroon);
}

.hint.is-set {
    color: var(--ink);
    font-weight: 500;
}

.field-error {
    margin: 8px 0 0;
    color: var(--maroon);
    font-weight: 500;
}

.field-error:empty {
    display: none;
}

/* ---------------------------------------------------------------- Known addresses */

.known-title {
    margin: 18px 0 8px;
    font-size: 0.9375rem;
    font-weight: 700;
}

.chips {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-flex;
    align-items: stretch;
    max-width: 100%;
    background: var(--lavender);
    border: 1.5px solid var(--green);
    border-radius: 999px;
}

.chip-pick,
.chip-remove {
    appearance: none;
    border: 0;
    background: none;
    font: inherit;
    cursor: pointer;
    min-height: 40px;
    border-radius: 999px;
}

.chip-pick {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 6px 4px 6px 12px;
    color: var(--green);
    font-weight: 500;
    text-align: left;
    overflow-wrap: anywhere;
}

.chip-pick:hover {
    text-decoration: underline;
}

.chip-check {
    flex: none;
    width: 16px;
    height: 16px;
    fill: none;
    stroke: var(--green);
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chip-remove {
    min-width: 40px;
    padding: 0 10px;
    font-size: 1.3rem;
    line-height: 1;
    color: var(--muted);
}

.chip-remove:hover {
    color: var(--maroon);
}

.chip :focus-visible {
    outline-offset: -2px;
}

.pending {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.pending-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 10px 6px 10px 12px;
    background: var(--paper);
    border-radius: 3px;
}

.pending-mail {
    flex: 1 1 12em;
    min-width: 0;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.pending-form {
    display: inline-flex;
    gap: 8px;
}

.pending-form .rm-code-input {
    width: 7.5em;
    min-height: 40px;
    padding: 6px 10px;
}

/* ---------------------------------------------------------------- Date + postmark */

/* On the narrowest phones the postmark wraps under the fields, right-aligned. */
.when {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 14px;
}

.when-inputs {
    flex: 1 1 11em;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

#ereminder-date {
    flex: 1 1 9em;
    width: 9em;
    min-width: 0;
}

.when-time {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.postmark {
    flex: none;
    width: 80px;
    height: 80px;
    margin-right: 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid currentColor;
    border-radius: 50%;
    box-shadow: inset 0 0 0 4px var(--white), inset 0 0 0 5.5px currentColor;
    color: var(--sand);
    font-family: var(--sans);
    line-height: 1.05;
    text-align: center;
    transform: rotate(-12deg);
    user-select: none;
}

.postmark-day {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.6rem;
}

.postmark-month,
.postmark-time {
    font-size: 0.8rem;
    font-weight: 700;
}

.postmark:not(.is-stamped) .postmark-month {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 500;
    font-size: 0.95rem;
}

.postmark.is-stamped {
    color: var(--brown);
}

.postmark.is-fresh {
    animation: stamp 0.22s ease-out;
}

@keyframes stamp {
    from {
        transform: rotate(-12deg) scale(1.3);
        opacity: 0.3;
    }
    to {
        transform: rotate(-12deg) scale(1);
        opacity: 1;
    }
}

@media (min-width: 560px) {
    .postmark {
        width: 104px;
        height: 104px;
    }

    .postmark-day {
        font-size: 1.9rem;
    }
}

/* ---------------------------------------------------------------- Buttons */

.form-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 8px;
}

.btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 50px;
    padding: 12px 22px;
    font: inherit;
    font-weight: 700;
    font-size: 1.125rem;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    border: 2px solid var(--ink);
    border-radius: 3px;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn-primary {
    background: var(--brown);
    color: var(--white);
    box-shadow: 4px 4px 0 var(--ink);
}

.btn-primary:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--ink);
}

.btn-primary:active {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 var(--ink);
}

.form-actions .btn-primary {
    flex: 1 1 auto;
}

@media (min-width: 560px) {
    .form-actions .btn-primary {
        flex: none;
    }
}

.btn-small {
    min-height: 40px;
    padding: 6px 14px;
    font-size: 1rem;
    color: var(--ink);
    background: var(--white);
    border-width: 1.5px;
}

.btn-small:hover {
    background: var(--lavender);
}

.spinner {
    display: inline-block;
    flex: none;
    width: 24px;
    height: 24px;
    vertical-align: middle;
    border: 3px solid var(--sand);
    border-top-color: var(--ink);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------------------------------------------------------------- Notices */

.notice {
    margin: 0 0 20px;
    padding: 12px 16px;
    background: var(--white);
    border-left: 4px solid var(--rule);
}

.notice-ok {
    border-left-color: var(--green-bright);
}

.notice-error {
    color: var(--maroon);
    border-left-color: var(--maroon);
}

/* ---------------------------------------------------------------- Steps */

.steps-title {
    margin: 0 0 16px;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.5rem;
    line-height: 1.2;
}

.steps-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.step {
    position: relative;
    padding: 0 0 22px 52px;
}

/* The sand line linking one step to the next. */
.step:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 17px;
    top: 40px;
    bottom: 4px;
    width: 2px;
    background: var(--sand);
}

.step-num {
    position: absolute;
    left: 0;
    top: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--brown);
    background: var(--paper);
    border: 2px solid var(--sand);
    border-radius: 50%;
}

.step.is-done .step-num {
    color: var(--green);
    border-color: var(--green);
}

.step.is-current .step-num {
    color: var(--white);
    background: var(--brown);
    border-color: var(--brown);
}

.step-title {
    margin: 5px 0 2px;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.15rem;
    line-height: 1.25;
    color: var(--brown);
}

.step-text {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--muted);
}

.step.is-current .step-text {
    color: var(--ink);
}

/* ---------------------------------------------------------------- FAQ */

.faq {
    max-width: 46rem;
}

.faq-title {
    margin: 0 0 12px;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.5rem;
    line-height: 1.2;
}

.faq-item {
    border-top: 1px solid var(--rule);
}

.faq-item:last-child {
    border-bottom: 1px solid var(--rule);
}

.faq-item summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    cursor: pointer;
    list-style: none;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

/* A sand-coloured chevron that turns when the answer is open. */
.faq-item summary::before {
    content: "";
    flex: none;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--brown);
    border-bottom: 2px solid var(--brown);
    transform: rotate(-45deg);
    transition: transform 0.15s;
}

.faq-item[open] summary::before {
    transform: rotate(45deg);
}

.faq-item summary:focus-visible {
    outline: 2px solid var(--brown);
    outline-offset: 2px;
}

.faq-item h3 {
    margin: 0;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1.25;
    color: var(--brown);
}

.faq-item p {
    margin: 0 0 14px 18px;
    font-size: 0.9375rem;
    color: var(--ink);
}

/* ---------------------------------------------------------------- Validation / report */

.code-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.code-input {
    width: 8em;
    font-size: 1.35rem;
    letter-spacing: 0.2em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.preview {
    margin-top: 40px;
}

.preview-title {
    margin: 0 0 12px;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.5rem;
    line-height: 1.2;
}

.letter,
.votre-message {
    max-height: 22em;
    overflow: auto;
    padding: 16px 20px;
    background: var(--white);
    border: 1.5px solid var(--rule);
    border-radius: 3px;
    font-family: var(--serif);
    font-size: 1.15rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

/* Built by /ajax/report.ajax.php from the raw message, newlines included. */
.votre-message {
    white-space: pre-wrap;
}

.report-feedback .loading {
    display: flex;
    align-items: center;
    gap: 12px;
}

.allok {
    color: var(--green);
    font-weight: 700;
    font-size: 1.125rem;
}

/* Data-use note under a form, as required where personal data is collected. */
.form-legal {
    margin-top: 16px;
}

/* ---------------------------------------------------------------- Legal pages */

.prose {
    max-width: 38em;
}

.prose h2 {
    margin: 36px 0 10px;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.4rem;
    line-height: 1.2;
}

.prose h2:first-child {
    margin-top: 0;
}

.prose h3 {
    margin: 22px 0 6px;
    font-family: var(--serif);
    font-style: italic;
    font-weight: 500;
    font-size: 1.15rem;
    color: var(--brown);
}

.prose p,
.prose ul,
.prose address {
    margin: 0 0 12px;
}

.prose ul {
    padding-left: 1.2em;
}

.prose li {
    margin-bottom: 4px;
}

.prose address {
    font-style: normal;
}

.prose code {
    font-size: 0.95em;
    overflow-wrap: anywhere;
}

/* Cookie list: name on its own line, its explanation indented under it. */
.facts {
    margin: 0 0 16px;
}

.facts dt {
    margin-top: 14px;
    font-weight: 700;
}

.facts dd {
    margin: 4px 0 0;
    padding-left: 14px;
    border-left: 2px solid var(--sand);
}

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

.prose .updated {
    margin-top: 36px;
    font-size: 0.875rem;
    color: var(--muted);
}

/* ---------------------------------------------------------------- Footer */

.site-footer {
    max-width: 1120px;
    margin: 0 auto;
    padding: 20px 16px 32px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    border-top: 1px solid var(--rule);
    font-size: 0.875rem;
    color: var(--muted);
}

.site-footer p {
    margin: 0;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
}

.footer-links a {
    color: var(--ink);
}

@media (min-width: 880px) {
    .site-footer {
        padding: 24px 32px 40px;
    }
}

/* ---------------------------------------------------------------- jQuery UI datepicker */

#ui-datepicker-div {
    z-index: 10 !important;
}

.ui-datepicker.ui-widget {
    font-family: var(--sans);
    font-size: 1rem;
}

.ui-datepicker.ui-widget-content {
    width: 17.5em;
    padding: 8px;
    color: var(--ink);
    background: var(--white);
    border: 3px solid var(--ink);
    border-radius: 3px;
    box-shadow: 6px 6px 0 var(--sand);
}

.ui-datepicker .ui-widget-header {
    background: none;
    border: 0;
    border-bottom: 1.5px solid var(--rule);
    border-radius: 0;
    color: var(--ink);
}

.ui-datepicker .ui-datepicker-title {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.15rem;
    line-height: 2em;
}

.ui-datepicker .ui-datepicker-prev,
.ui-datepicker .ui-datepicker-next {
    top: 0.5em;
    cursor: pointer;
}

.ui-datepicker .ui-datepicker-prev-hover,
.ui-datepicker .ui-datepicker-next-hover {
    background: var(--lavender);
    border: 1px solid var(--rule);
    border-radius: 3px;
}

.ui-datepicker th {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
}

.ui-datepicker td a.ui-state-default {
    padding: 0.35em 0;
    text-align: center;
    font-weight: 500;
    color: var(--ink);
    background: none;
    border: 1px solid transparent;
    border-radius: 3px;
}

.ui-datepicker td a.ui-state-highlight {
    font-weight: 700;
    color: var(--brown);
    border-color: var(--sand);
}

.ui-datepicker td a.ui-state-hover {
    background: var(--lavender);
    border-color: var(--rule);
}

.ui-datepicker td a.ui-state-active {
    color: var(--white);
    background: var(--brown);
    border-color: var(--brown);
}

/* ---------------------------------------------------------------- Motion */

@media (prefers-reduced-motion: reduce) {
    .btn,
    .kind-text {
        transition: none;
    }

    .postmark.is-fresh {
        animation: none;
    }

    .spinner {
        animation-duration: 2.4s;
    }
}
