/* Public pages: the only stylesheet. No web fonts, no build step.
   Colours are variables so the company's colour can replace the accent. */

:root {
    color-scheme: light;

    --paper: #ffffff;
    --band: #f2f6f7;
    --ink: #1b2428;
    --ink-soft: #4b575d;
    --line: #c9d3d7;
    --accent: #0a5c70;
    --accent-wash: #e3eef1;
    --accent-strong: #07465a;
    --error: #b42318;

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Nirmala UI", "Kohinoor Devanagari", sans-serif;
    --measure: 40rem;
    --gutter: clamp(1rem, 4vw, 2rem);
    --target: 2.75rem;
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    font-size: 1.125rem;
    line-height: 1.65;
    accent-color: var(--accent);
    caret-color: var(--accent);
}

::selection {
    background: var(--accent-wash);
    color: var(--ink);
}

a {
    color: var(--accent);
    text-underline-offset: 0.2em;
}

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

/* Header and main share one column, so the header lines up with the content on wide screens. */
.site-header,
main {
    padding-inline: max(var(--gutter), calc((100% - var(--measure)) / 2));
}

.site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    /* 0.5rem across too, so the site name and the language switch still share a row at 360 px. */
    gap: 0.5rem;
    padding-block: 0.5rem;
    background: var(--band);
    border-bottom: 1px solid var(--line);
}

/* The emergency line: its own strip at the top of every public page, ruled off from the site name,
   the whole sentence one phone link at least a target tall. */
.emergency {
    flex-basis: 100%;
    max-width: none;
    margin: 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--line);
    font-weight: 600;
}

.emergency a {
    display: flex;
    align-items: center;
    min-height: var(--target);
}

.site-name {
    display: inline-flex;
    align-items: center;
    min-height: var(--target);
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
}

.site-name:hover {
    text-decoration: underline;
}

/* Both languages side by side, the current one filled, like a two-way toggle. */
.language-switch ul {
    display: flex;
    margin: 0;
    padding: 0.125rem;
    list-style: none;
    border: 1px solid var(--accent);
    border-radius: 0.5rem;
    background: var(--paper);
}

.language-switch a,
.language-switch [aria-current] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--target);
    min-height: var(--target);
    padding: 0.25rem 0.875rem;
    border-radius: 0.375rem;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
}

.language-switch a {
    color: var(--accent);
}

.language-switch a:hover {
    background: var(--accent-wash);
}

.language-switch [aria-current] {
    background: var(--accent);
    color: var(--paper);
}

main {
    padding-block: 2rem 3rem;
}

/* Type steps of at least 1.25 between body (18 px), h2 and h1, at phone width too. */
h1 {
    margin: 0 0 1rem;
    font-size: clamp(1.875rem, 1.5rem + 1.5vw, 2.25rem);
    line-height: 1.35;
    text-wrap: balance;
}

p {
    margin: 0 0 1rem;
    max-width: 65ch;
}

h2 {
    margin: 0 0 0.75rem;
    font-size: 1.5rem;
    line-height: 1.35;
    text-wrap: balance;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* The notice: the company's own words, set apart by a quiet band, not a coloured edge. */
.notice {
    margin: 0 0 2.5rem;
    padding: 1.25rem;
    background: var(--band);
    border-radius: 0.5rem;
}

.notice h2 {
    font-size: 1.25rem;
}

.notice ul {
    margin: 0 0 1rem;
    padding-inline-start: 1.25rem;
}

.notice li + li {
    margin-top: 0.5rem;
}

/* The promise (heading and points) ruled off from what follows it. */
.notice ul + p {
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

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

/* Other ways to raise a grievance: one last section below the form, set apart like the form's own. */
.other-ways {
    margin-top: 2.5rem;
}

/* The form: one column of sections, each a short group, more room between groups than inside them. */
form[data-grievance] {
    display: grid;
    gap: 2.5rem;
}

.section {
    display: grid;
    gap: 1.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--line);
}

.section h2,
.section > .hint {
    margin: 0;
}

.section > .hint {
    margin-top: -1rem;
}

fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

legend {
    padding: 0;
}

/* A question that is also its section's heading gets a heading's room below it. */
.choices > legend h2 {
    margin-bottom: 0.75rem;
}

.field,
.choices,
.contact,
.date-parts-group {
    display: grid;
    gap: 0.5rem;
}

.contact {
    gap: 1.25rem;
    padding: 1.25rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
}

.contact > legend {
    float: left;
    width: 100%;
    font-size: 1.125rem;
}

label,
legend {
    font-weight: 600;
}

.hint {
    margin: 0;
    color: var(--ink-soft);
    font-size: 1rem;
    font-weight: 400;
}

input[type="text"],
input[type="tel"],
input[type="email"],
select,
textarea {
    width: 100%;
    min-height: var(--target);
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--ink-soft);
    border-radius: 0.375rem;
    background: var(--paper);
    color: var(--ink);
    font: inherit;
}

/* An error-summary link jumps to its field. form.js brings the question into view first, a little below the
   top; without JavaScript the field keeps room above it for the question, hint and error. Measured at 360 px:
   up to 136 px above a field, 222 px above the date's day box, more with wider fonts. */
legend,
label {
    scroll-margin-top: 1rem;
}

main :is(input, select, textarea) {
    scroll-margin-top: 10rem;
}

.date-parts select {
    scroll-margin-top: 18rem;
}

textarea {
    min-height: 10rem;
    resize: vertical;
}

/* Its own minimum width would widen the whole form past a 320 px screen. */
input[type="file"] {
    width: 100%;
    min-width: 0;
    font: inherit;
    font-size: 1rem;
}

input[type="file"]::file-selector-button {
    min-height: var(--target);
    margin-right: 0.75rem;
    padding: 0.5rem 1rem;
    border: 2px solid var(--accent);
    border-radius: 0.375rem;
    background: var(--paper);
    color: var(--accent);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

/* Choices: the whole row is the target, and the chosen one is marked by more than colour. */
.choice {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    min-height: var(--target);
    padding: 0.625rem 0.875rem;
    border: 2px solid var(--line);
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
}

.choice input {
    flex: none;
    width: 1.375rem;
    height: 1.375rem;
    margin: 0.2rem 0 0;
}

.choice .hint {
    display: block;
    margin-top: 0.25rem;
}

.choice:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-wash);
}

/* The spam trap: no one sees it or reaches it, so only scripts fill it. */
.trap {
    display: none;
}

/* Anonymous: the contact fields go away. Browsers without :has() show them, and the server drops them. */
form:has(#is_anonymous-1:checked) .contact {
    display: none;
}

.date-parts {
    display: grid;
    /* On a phone the day has a row of its own, so its longest choice ("I don't remember the day",
       "गते याद छैन") is never cut; month and year share the next row. */
    grid-template-columns: minmax(0, 1fr) max-content;
    gap: 0.5rem;
}

.date-parts .field:first-child {
    grid-column: 1 / -1;
}

@media (min-width: 40rem) {
    /* One row from 40rem: the day gets the most room, the year only what its four digits need. */
    .date-parts {
        grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) max-content;
    }

    .date-parts .field:first-child {
        grid-column: auto;
    }
}

.date-parts label {
    font-weight: 400;
    font-size: 1rem;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3rem;
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--accent);
    border-radius: 0.5rem;
    background: var(--paper);
    color: var(--accent);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.button-primary {
    background: var(--accent);
    color: var(--paper);
}

.button:hover {
    border-color: var(--accent-strong);
    background: var(--accent-wash);
    color: var(--accent-strong);
}

.button-primary:hover {
    background: var(--accent-strong);
    color: var(--paper);
}

@media (max-width: 40rem) {
    .button-primary {
        width: 100%;
    }
}

/* Errors: words first, colour second, and the summary links to each field. */
.error {
    margin: 0;
    color: var(--error);
    font-weight: 600;
}

.field-error input,
.field-error select,
.field-error textarea {
    border-color: var(--error);
}

.error-summary {
    padding: 1.25rem;
    border: 3px solid var(--error);
    border-radius: 0.5rem;
}

/* Under the page heading, so it is in view after a page sent back without JavaScript. */
main > .error-summary {
    margin-bottom: 1.5rem;
}

.error-summary h2 {
    color: var(--error);
    font-size: 1.25rem;
}

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

.error-summary ul {
    margin: 0;
    padding-left: 1.25rem;
}

.error-summary li + li {
    margin-top: 0.375rem;
}

.error-summary a {
    color: var(--error);
    font-weight: 600;
}

/* The received page: the two things to keep, large, spaced and easy to copy. */
.keep {
    margin: 0 0 2rem;
    padding: 1.25rem;
    border: 3px solid var(--accent);
    border-radius: 0.75rem;
}

.keep dl {
    margin: 0 0 1rem;
}

.keep dt {
    color: var(--ink-soft);
    font-size: 1rem;
}

.code {
    margin: 0 0 1rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: clamp(1.75rem, 1.4rem + 2vw, 2.5rem);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    letter-spacing: 0.06em;
    overflow-wrap: anywhere;
}

/* Our own advice under the company's sentence: what to do now, at label weight. */
.keep .advice {
    font-weight: 600;
}

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

.done {
    display: grid;
    gap: 0.75rem;
    justify-items: start;
    margin-top: 2rem;
}

/* The status pages. */
.stack {
    display: grid;
    gap: 1.5rem;
}

.notice-line {
    padding: 0.75rem 1rem;
    border: 2px solid var(--accent);
    border-radius: 0.5rem;
    background: var(--accent-wash);
}

.aside-link {
    margin-top: 2rem;
}

.facts {
    display: grid;
    gap: 1rem;
    margin: 0 0 2.5rem;
    padding: 1.25rem;
    background: var(--band);
    border-radius: 0.5rem;
}

.facts dt {
    color: var(--ink-soft);
    font-size: 1rem;
}

.facts dd {
    margin: 0;
    font-weight: 600;
}

.code-small {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}

.status-value {
    font-size: 1.375rem;
}

@media (min-width: 40rem) {
    .facts {
        grid-template-columns: repeat(3, auto);
        justify-content: space-between;
    }
}

/* The thread: who wrote each message is said in words; position only repeats it. */
.thread {
    display: grid;
    gap: 1rem;
    margin: 0 0 2.5rem;
    padding: 0;
    list-style: none;
}

.message {
    max-width: 90%;
    padding: 0.875rem 1rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    background: var(--band);
}

.message-mine {
    justify-self: end;
    background: var(--accent-wash);
    border-color: var(--accent);
}

.message-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    margin: 0 0 0.375rem;
    color: var(--ink-soft);
    font-size: 1rem;
}

.message-meta strong {
    color: var(--ink);
}

.message-body {
    margin: 0;
    overflow-wrap: anywhere;
}

.reply {
    margin-top: 0.5rem;
}
