/* Familia upload page.
   Colour scheme: Familia navy #1d2a44 + yellow #fadb14. Flat: no shadows, gradients or animation.
   Colour roles:
     --primary  yellow : the main action on each screen (one per view)
     --tint     navy (yellow in dark mode) : links and secondary buttons
     --focus    the selected/focused field: off-white (navy edge in light mode, where off-white wouldn't show)
     --danger   red    : errors, required marks and destructive actions only
     --success  green  : confirmation only */
/* ---------- fonts (self-hosted, so no visitor data goes to a third party) ----------
   Outfit and Poppins, SIL Open Font License 1.1: see /fonts/OFL-Outfit.txt and /fonts/OFL-Poppins.txt.
   Subset to Latin, Latin Extended and common punctuation. */
@font-face { font-family: "Outfit"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/fonts/outfit-variable.woff2) format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/poppins-400.woff2) format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/poppins-500.woff2) format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/poppins-600.woff2) format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/poppins-700.woff2) format("woff2"); }

:root {
  --masthead: #1d2a44;
  --brand: #fadb14;
  --bg: #f4f2ee;
  --surface: #ffffff;
  --fill: #f1efea;
  --label: #1f2937;
  --secondary: #5f6673;
  --separator: rgba(31, 41, 55, .12);
  --tint: #1d2a44;
  --tint-soft: rgba(29, 42, 68, .08);
  --focus: #1d2a44;
  --focus-fill: #fdfaf2;
  --primary: #fadb14;
  --primary-press: #e6c700;
  --on-primary: #1d2a44;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --success: #17623a;
  --success-soft: #e7f5ec;
  --info-soft: rgba(29, 42, 68, .06);
  --border: rgba(31, 41, 55, .10);
  --r-lg: 20px;
  --r-md: 12px;
  --margin: 20px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1322;
    --surface: #182136;
    --fill: #212b43;
    --label: #eef1f7;
    --secondary: #a3abbd;
    --separator: rgba(255, 255, 255, .10);
    --tint: #fadb14;
    --tint-soft: rgba(250, 219, 20, .12);
    --focus: #f2efe6;
    --focus-fill: var(--fill);
    --danger: #ff8a7a;
    --danger-soft: rgba(255, 138, 122, .12);
    --success: #6fd49a;
    --success-soft: rgba(111, 212, 154, .12);
    --info-soft: rgba(255, 255, 255, .06);
    --border: rgba(255, 255, 255, .08);
  }
}
@media (prefers-contrast: more) {
  :root { --secondary: #3d434d; --separator: rgba(31, 41, 55, .35); --tint: #0f1626; --border: rgba(31, 41, 55, .45); }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root { --secondary: #d0d5df; --separator: rgba(255, 255, 255, .35); --tint: #ffe55c; --border: rgba(255, 255, 255, .4); }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--label);
  font: 400 16px/1.6 "Poppins", system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: "Outfit", "Poppins", system-ui, sans-serif; font-weight: 700; letter-spacing: -.01em; }
button, input, textarea { font: inherit; color: inherit; }
.wrap { max-width: 680px; margin: 0 auto; padding: 0 var(--margin); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hp { position: absolute; left: -9999px; }

/* icons: one set, 20px, 1.75 stroke, round caps */
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round; }

/* ---------- masthead ---------- */
.masthead { background: var(--masthead); color: #fff; padding: calc(16px + env(safe-area-inset-top)) 0 36px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 44px; margin-bottom: clamp(8px, 2vw, 14px); }
.kicker { margin: 0; font-size: .8125rem; color: rgba(255, 255, 255, .86); }
.kicker strong { font-weight: 600; color: #fff; }
.wordmark { display: block; width: 100%; height: auto; }
.masthead .title { margin: 0; line-height: 0; }

/* The first card straddles the line between the navy and the page colour. The band is navy
   above the card's middle and page colour below. app.js sets --split from the card's normal height,
   so a message appearing in the card grows it downward without moving the background. */
.band { background: linear-gradient(to bottom, var(--masthead) var(--split, 50%), var(--bg) var(--split, 50%)); }

.content { padding-bottom: 48px; }

/* ---------- buttons: importance by style, never by size ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px;
  padding: 0 24px; border: 1px solid transparent; /* transparent edge shows in Windows high contrast */
  border-radius: 14px; font-weight: 600; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:active { background: var(--primary-press); }
.btn-secondary { background: var(--tint-soft); color: var(--tint); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-block { width: 100%; }
.plain { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; min-width: 44px;
  padding: 0 12px; border: 0; border-radius: 10px; background: none; color: var(--tint); font-weight: 500;
  font-size: .9375rem; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.plain:active { background: var(--tint-soft); }
.plain.destructive { color: var(--danger); }
.plain.destructive:active { background: var(--danger-soft); }
.plain.on-dark { flex: none; color: #fff; margin-right: -12px; white-space: nowrap; }
.plain.on-dark:active { background: rgba(255, 255, 255, .12); }
/* square icon button: the pressed highlight sits exactly behind the icon */
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 0; border: 0;
  border-radius: 10px; background: none; color: var(--tint); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.icon-btn:active { background: var(--tint-soft); }

:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; }
.masthead :focus-visible { outline-color: #f2efe6; }
.row input:focus-visible, .stack textarea:focus-visible { outline: 0; }

/* ---------- messages ---------- */
/* The message areas always exist (empty) so screen readers announce what appears in them. */
.msg:empty { display: block; margin: 0; padding: 0; }
.msg:not(:empty) { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; padding: 12px 14px;
  border-radius: var(--r-md); font-size: .9375rem; }
.msg.err { background: var(--danger-soft); color: var(--danger); }
.msg.ok { background: var(--success-soft); color: var(--success); }
.msg.info { background: var(--info-soft); color: var(--label); }
.msg .i { margin-top: 2px; }

/* ---------- cards and grouped rows (no boxes inside boxes) ---------- */
.box { background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--border); }
.box:focus-within { border-color: var(--focus); }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 44px; padding: 0 4px 0 16px; }
.section-head h2, .section-head h3 { margin: 0; font-size: 1.0625rem; }
.req { color: var(--danger); font-weight: 600; }

.row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 16px; }
.row label { flex: 0 0 72px; font-weight: 500; }
.row input { flex: 1; min-width: 0; min-height: 44px; border: 0; background: transparent; outline: 0; padding: 0; }
.stack { padding: 14px 16px 12px; }
.stack > label { display: block; margin-bottom: 6px; font-weight: 500; }
.stack textarea { display: block; width: 100%; min-height: 168px; resize: vertical; border: 0; outline: 0;
  padding: 0; background: transparent; line-height: 1.65; }
::placeholder { color: var(--secondary); opacity: 1; } /* full strength so it meets contrast */
/* .q groups a question with its error message, so they highlight and separate together */
.box > * + :is(.q, .row, .stack, .photos) { border-top: 1px solid var(--separator); }
.box > :is(.q, .row, .stack):focus-within { background: var(--focus-fill); }
/* the focus fill of the first/last question follows the card's rounded corners */
.box > :first-child:is(.q, .row, .stack) { border-radius: calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px) 0 0; }
.box > :last-child:is(.q, .row, .stack) { border-radius: 0 0 calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px); }
.box > :only-child:is(.q, .row, .stack) { border-radius: calc(var(--r-lg) - 1px); }
.stack textarea.short { min-height: 88px; }

/* inline errors, Google Forms style: under the question, in red */
.field-err { display: flex; gap: 8px; align-items: center; margin: 0; padding: 12px 16px 0; color: var(--danger);
  font-size: .875rem; font-weight: 500; line-height: 1.4; }
.q.stack > .field-err, .q-plain > .field-err { padding: 0 0 8px; }
.add-row .field-err { padding: 8px 0 0; }
.field-err::before { content: "!" / ""; /* decorative: not read out */ display: grid; place-items: center; width: 18px; height: 18px; flex: none;
  border-radius: 50%; background: var(--danger); color: var(--surface); font: 700 .75rem/1 "Poppins", sans-serif; }
.content .box:has([aria-invalid="true"]) { border-color: var(--danger); }
.field:has([aria-invalid="true"]) { border-color: var(--danger); }
.row:has(> [aria-invalid="true"]) label, .stack:has(> [aria-invalid="true"]) > label { color: var(--danger); }

/* ---------- sign in ---------- */
#gate { padding: 28px 24px 24px; }
#gate h2 { margin: 0 0 4px; font-size: 1.625rem; }
#gate h2 + .msg:not(:empty) { margin: 12px 0 0; }
#gate form { margin-top: 18px; }
.label { display: block; font-weight: 600; }
.hint { margin: 2px 0 10px; color: var(--secondary); font-size: .9375rem; }
.field { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 4px 0 14px;
  background: var(--fill); border: 1px solid transparent; border-radius: var(--r-md); color: var(--secondary); }
.field:focus-within { border-color: var(--focus); background: var(--focus-fill); }
.field input { flex: 1; min-width: 0; min-height: 44px; border: 0; outline: 0; background: transparent; color: var(--label); }
.field .icon-btn:focus-visible { outline-offset: -2px; }
#ts:not(:empty) { margin-top: 16px; }
#gate .btn { margin-top: 20px; }

/* ---------- form header (like the top card of a Google Form) ---------- */
.who { display: flex; align-items: center; gap: 14px; padding: 16px; }
.avatar { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%;
  background: var(--masthead); color: var(--brand); font: 700 1rem/1 "Outfit", sans-serif; letter-spacing: .02em; }
.who-text { flex: 1; min-width: 0; line-height: 1.35; }
.who-text small { display: block; color: var(--secondary); font-size: .8125rem; }
.who-text strong { display: block; font-weight: 600; overflow-wrap: anywhere; }
.form-intro { padding: 16px 16px 14px; border-top: 1px solid var(--separator); }
.form-intro h2 { margin: 0 0 2px; font-size: 1.375rem; }
.form-intro p { margin: 0; color: var(--secondary); }
.form-intro .req-note { margin-top: 10px; font-size: .8125rem; }

/* ---------- articles and photos ---------- */
.add-row { display: flex; flex-direction: column; align-items: center; margin-top: 20px; }
.article.drag .box { border-color: var(--focus); background: var(--focus-fill); }

.photos { padding: 14px 16px 16px; }
.photos-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.photos-head strong { font-weight: 500; }
.photos-help { margin: 2px 0 12px; font-size: .8125rem; color: var(--secondary); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.tile { position: relative; min-width: 0; }
.tile-img { display: grid; place-items: center; aspect-ratio: 1; border-radius: var(--r-md); overflow: hidden;
  background: var(--fill); color: var(--secondary); }
.tile-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-meta { display: block; margin-top: 4px; font-size: .75rem; line-height: 1.35; color: var(--secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-warn { display: flex; gap: 6px; align-items: flex-start; margin-top: 2px; font-size: .75rem; font-weight: 600; line-height: 1.35; color: var(--label); }
.warn-icon { display: grid; place-items: center; width: 16px; height: 16px; flex: none; margin-top: 1px; border-radius: 50%;
  background: var(--label); color: var(--surface); font: 700 .6875rem/1 "Poppins", sans-serif; }
/* remove button: 44px hit area, 28px visible circle, in the tile's corner */
.tile-remove { position: absolute; top: 0; right: 0; display: grid; place-items: center; width: 44px; height: 44px;
  padding: 0; border: 0; background: none; cursor: pointer; color: #fff; -webkit-tap-highlight-color: transparent; }
.tile-remove span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: rgba(13, 19, 34, .72); border: 1px solid rgba(255, 255, 255, .5); }
.tile-remove:active span { background: rgba(13, 19, 34, .9); }
.tile-remove .i { width: 16px; height: 16px; stroke-width: 2.25; }
.tile-add { display: grid; place-content: center; justify-items: center; gap: 4px; width: 100%; aspect-ratio: 1;
  border: 1.5px dashed var(--separator); border-radius: var(--r-md); background: none; color: var(--tint);
  font-weight: 500; font-size: .875rem; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tile-add:active { background: var(--tint-soft); }
.rejects { margin: 10px 0 0; padding: 0; list-style: none; }
.rejects li { display: flex; gap: 8px; margin-top: 6px; color: var(--danger); font-size: .875rem; }
.rejects li::before { content: "!" / ""; /* decorative: not read out */ display: grid; place-items: center; width: 18px; height: 18px; flex: none; margin-top: 2px;
  border-radius: 50%; background: var(--danger); color: var(--surface); font: 700 .75rem/1 "Poppins", sans-serif; }

/* ---------- toolbar ---------- */
/* a rounded bar that floats just above the bottom edge while the form scrolls,
   and settles at the end of the form with the same rounded corners */
.toolbar { position: sticky; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 5;
  display: flex; align-items: center; gap: 8px; margin-top: 28px; padding: 10px 10px 10px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.summary { flex: 1; min-width: 0; font-size: .8125rem; color: var(--secondary); line-height: 1.3; }
@media (max-width: 440px) { .summary { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } .toolbar { justify-content: flex-end; } }

/* ---------- done ---------- */
#done { margin-top: 16px; overflow: hidden; }
#done .panel { padding: 32px 24px 24px; text-align: center; background: var(--success-soft); }
#done .next { padding: 20px 24px 24px; }
#done .next h3 { margin: 0 0 6px; font-size: 1.0625rem; }
#done .next h3:not(:first-child) { margin-top: 20px; }
#done .next p { margin: 0 0 8px; max-width: none; color: var(--label); }
#done .next .btn { margin-top: 12px; }
.tick { width: 72px; height: 72px; margin: 0 auto 16px; color: var(--success); }
.tick circle, .tick path { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
#done h2 { margin: 0 0 6px; font-size: 1.625rem; }
#done h2:focus { outline: 0; }
#done p { margin: 0 auto; max-width: 30em; color: var(--secondary); }
#done ol { margin: 0; padding-left: 1.25em; }
#done li { margin: 2px 0; }

/* ---------- Windows high contrast ---------- */
@media (forced-colors: active) {
  .band { background: Canvas; }
  .tile-remove span { border-color: ButtonText; }
  .field-err::before, .rejects li::before { forced-color-adjust: none; background: Mark; color: MarkText; }
}

/* ---------- skip link, hints and error summary ---------- */
/* skip link: hidden until it gets keyboard focus */
.skip { position: absolute; left: 12px; top: -100px; z-index: 10; padding: 10px 16px; border-radius: 10px;
  background: var(--primary); color: var(--on-primary); font-weight: 600; text-decoration: underline; }
.skip:focus { top: 12px; }
main:focus { outline: 0; }

/* section hint: sits under the section heading, before the fields */
.section-hint { margin: 0 16px 10px; font-size: .875rem; color: var(--secondary); }

/* error summary: "There is a problem", with a link to each field */
.error-summary { padding: 16px 18px; border: 2px solid var(--danger); border-radius: var(--r-md); background: var(--surface); }
.error-summary:focus { outline: 2.5px solid var(--focus); outline-offset: 3px; }
.error-summary .error-summary-title { margin: 0 0 8px; font-size: 1.125rem; color: var(--label); }
.error-summary-list { margin: 0; padding: 0; list-style: none; }
.error-summary-list li + li { margin-top: 4px; }
.error-summary-list a { color: var(--danger); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
#gsum { margin-bottom: 16px; }
#f > .error-summary { margin-top: 28px; }
