/* Pamodzi Pass - one stylesheet, no scripts. Day by default; night when chosen with the header switch, the look of
   the Pamodzi certificates: a deep green field with the diamond lattice, an orange rule, a raised white or dark sheet.
   Readable at 375 px, visible focus, contrast kept in both themes. */
:root {
  color-scheme: light;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --field-a: #0a4a30; --field-b: #05301f; --field-ink: #ffffff; --field-muted: #b9e3cc; --field-h: 300px;
  --accent: #ef8a17;
  --bg: #eef3f0; --card: #ffffff; --card-line: transparent; --shadow: 0 14px 40px rgba(5, 48, 31, .16), 0 2px 6px rgba(5, 48, 31, .08);
  --ink: #17231d; --muted: #52635a; --line: #d5ded9; --eyebrow: #157048;
  --brand: #0b6b4f; --brand-hover: #085a42; --brand-ink: #ffffff; --link: #0b6b4f;
  --input-bg: #ffffff; --input-line: #6b7782;
  --secondary-bg: #e4ebe7; --secondary-ink: #17231d;
  --warn: #7a4f00; --warn-bg: #fff4dc; --err: #a4161a; --err-bg: #fde8e8; --ok: #0b6b4f; --ok-bg: #e3f4ec; --info: #1d5a96; --info-bg: #e8f1fa;
  --badge-bg: #e4ebe7; --focus: #ffbf47;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --field-a: #083d28; --field-b: #04251a; --field-muted: #a9d9bf;
  --bg: #121816; --card: #1b2320; --card-line: #2c3a34; --shadow: 0 18px 44px rgba(0, 0, 0, .5);
  --ink: #e8eeeb; --muted: #a3b2ab; --line: #2f3d37; --eyebrow: #7fdcaa;
  --brand: #36c27a; --brand-hover: #4fd38d; --brand-ink: #06231a; --link: #8fe3b6;
  --input-bg: #121816; --input-line: #5f716a;
  --secondary-bg: #26312d; --secondary-ink: #e8eeeb;
  --warn: #ffd27a; --warn-bg: #3a2c0a; --err: #ff9c9c; --err-bg: #3b1515; --ok: #8fe3b6; --ok-bg: #12302a; --info: #9ccbff; --info-bg: #13263a;
  --badge-bg: #26312d; --focus: #ffb347;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; font: 16px/1.5 var(--font); color: var(--ink); background: var(--bg); position: relative; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; } .skip:focus { left: 8px; top: 8px; background: var(--focus); color: #111; padding: 8px; z-index: 10; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* the green field: the certificate's lattice in a band behind the header, in day and night */
.field { position: absolute; z-index: 0; top: 0; left: 0; right: 0; height: var(--field-h); min-height: 300px; overflow: hidden; pointer-events: none;
  background: url("/assets/lattice.svg") right center / auto 100% no-repeat, linear-gradient(135deg, var(--field-a), var(--field-b)); }
.field::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--accent); }
body.wide .field { --field-h: 210px; min-height: 210px; }

.top, main, .foot { position: relative; z-index: 1; }
.top { color: var(--field-ink); padding: 14px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; }
.brand { color: var(--field-ink); font-weight: 700; font-size: 1.2rem; letter-spacing: .01em; text-decoration: none; display: inline-flex; align-items: center; gap: 10px; }
.brand .arms { width: 46px; height: auto; flex: 0 0 auto; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .35)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { font-size: .72rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--field-muted); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px 18px; } .tabs a { color: var(--field-ink); text-decoration: none; font-weight: 500; opacity: .9; } .tabs a:hover { opacity: 1; text-decoration: underline; }
.theme-switch { margin-left: auto; }
.theme-switch a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; color: var(--field-ink); text-decoration: none; font-size: .9rem; font-weight: 600;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .28); }
.theme-switch a:hover { background: rgba(255, 255, 255, .2); }
.theme-switch svg { width: 16px; height: 16px; fill: currentColor; }
.theme-switch .to-light { display: none; }
html[data-theme="dark"] .theme-switch .to-light { display: inline-flex; } html[data-theme="dark"] .theme-switch .to-dark { display: none; }

main { flex: 1 0 auto; width: 100%; margin: 28px auto 32px; padding: 0 16px; }
main.narrow { max-width: 500px; } main.wide { max-width: 1080px; }
/* the sign-in pages: one raised sheet on the field */
.sheet { background: var(--card); border: 1px solid var(--card-line); border-radius: 14px; box-shadow: var(--shadow); padding: 28px 28px 20px; }
.eyebrow { display: flex; align-items: center; gap: 12px; margin: 0 0 10px; color: var(--eyebrow); font-size: .78rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.eyebrow::before { content: ""; flex: 0 0 32px; height: 3px; border-radius: 2px; background: var(--accent); }
main.wide > .eyebrow { color: var(--field-muted); }
main.wide > h1 { color: var(--field-ink); margin-bottom: 36px; }
h1 { font-size: 1.75rem; line-height: 1.2; letter-spacing: -.01em; margin: 0 0 16px; } h2 { font-size: 1.2rem; margin: 0 0 12px; }
.lead { font-size: 1.05rem; } .lead strong { color: var(--ink); } .hint, .optional { color: var(--muted); font-size: .9rem; }
.card { background: var(--card); border: 1px solid var(--card-line); border-radius: 12px; box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }

form { margin: 0 0 12px; } form.inline { display: inline; } form.row, form.search { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
label { display: block; font-weight: 600; margin: 14px 0 6px; } form.row label, form.search label { margin: 0; }
input, select, textarea { width: 100%; max-width: 100%; padding: 11px 12px; font: inherit; color: var(--ink); border: 2px solid var(--input-line); border-radius: 8px; background: var(--input-bg); }
input:hover, select:hover, textarea:hover { border-color: var(--brand); }
form.row input, form.row select, form.search input { width: auto; flex: 1 1 160px; }
input[type=checkbox] { width: auto; margin-right: 8px; accent-color: var(--brand); } textarea { min-height: 80px; }
input[aria-invalid=true] { border-color: var(--err); } .field-error { color: var(--err); margin: 4px 0 0; font-weight: 600; }
button, .button { display: inline-block; margin-top: 18px; padding: 11px 22px; font: inherit; font-weight: 700; border: 0; border-radius: 8px; background: var(--brand); color: var(--brand-ink); cursor: pointer; text-decoration: none; }
button:hover, .button:hover { background: var(--brand-hover); }
.sheet form > button[type=submit] { width: 100%; }
button.secondary { background: var(--secondary-bg); color: var(--secondary-ink); } button.secondary:hover { background: var(--line); }
button.small { padding: 4px 10px; margin-top: 4px; font-size: .9rem; } .sheet form > button.small { width: auto; }
.alert { border-left: 6px solid var(--ok); background: var(--ok-bg); padding: 8px 12px; margin: 0 0 16px; border-radius: 6px; } .alert p { margin: 4px 0; }
.alert.error { border-color: var(--err); background: var(--err-bg); color: var(--err); } .alert.error p { color: var(--ink); }
.alert.info { border-color: var(--info); background: var(--info-bg); }
.badge { font-size: .8rem; padding: 2px 8px; border-radius: 10px; background: var(--badge-bg); } .badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
dl.kv { display: grid; grid-template-columns: minmax(120px, 30%) 1fr; gap: 6px 16px; margin: 0 0 12px; } dl.kv dt { font-weight: 600; } dl.kv dd { margin: 0; overflow-wrap: anywhere; }
table.data { width: 100%; border-collapse: collapse; background: var(--card); display: block; overflow-x: auto; }
table.data th, table.data td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
ul.codes { columns: 2; font-size: 1.1rem; } .key code { font-size: 1.05rem; word-break: break-all; }
/* an authenticator scans the code best on white, in either theme */
.qr svg { width: 220px; height: 220px; background: #fff; padding: 10px; border-radius: 8px; }
.steps li { margin-bottom: 12px; } fieldset { border: 1px solid var(--line); border-radius: 8px; } details { margin-top: 12px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
code { background: var(--badge-bg); padding: 1px 5px; border-radius: 4px; }

/* registration: the NRC for Zambian citizens, the passport for everyone else, shown once a nationality is chosen
   (a browser without :has shows both; the server applies the rule either way) */
@supports selector(:has(*)) {
  form:has(#nationality option[value=""]:checked) .if-zambian, form:has(#nationality option[value=""]:checked) .if-foreign { display: none; }
  form:has(#nationality option[value="ZM"]:checked) .if-foreign { display: none; }
  form:has(#nationality option:not([value=""]):not([value="ZM"]):checked) .if-zambian { display: none; }
}

/* gender and address (registration page 2, the sign-in step): the districts of the chosen province only, the country
   only for someone living abroad (a browser without :has shows all; the server checks either way). One rule per
   province of data/zm-geography.json. */
.details-form fieldset.choice { border: 0; padding: 0; margin: 14px 0 0; } .details-form legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
.details-form label.radio { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; margin: 0 24px 0 0; }
.details-form label.radio input { width: auto; accent-color: var(--brand); }
h2.form-section { font-size: 1.05rem; margin: 22px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
@supports selector(:has(*)) {
  .details-form .if-abroad, .details-form .if-abroad-inline { display: none; }
  .details-form:has(#address_province option[value="ABROAD"]:checked) .if-abroad { display: block; }
  .details-form:has(#address_province option[value="ABROAD"]:checked) .if-abroad-inline { display: inline; }
  .details-form:has(#address_province option[value="ABROAD"]:checked) .if-home { display: none; }
  .details-form:has(#address_province option[value="ZM-02"]:checked) #address_district optgroup:not([data-p="ZM-02"]) { display: none; }
  .details-form:has(#address_province option[value="ZM-08"]:checked) #address_district optgroup:not([data-p="ZM-08"]) { display: none; }
  .details-form:has(#address_province option[value="ZM-03"]:checked) #address_district optgroup:not([data-p="ZM-03"]) { display: none; }
  .details-form:has(#address_province option[value="ZM-04"]:checked) #address_district optgroup:not([data-p="ZM-04"]) { display: none; }
  .details-form:has(#address_province option[value="ZM-09"]:checked) #address_district optgroup:not([data-p="ZM-09"]) { display: none; }
  .details-form:has(#address_province option[value="ZM-10"]:checked) #address_district optgroup:not([data-p="ZM-10"]) { display: none; }
  .details-form:has(#address_province option[value="ZM-06"]:checked) #address_district optgroup:not([data-p="ZM-06"]) { display: none; }
  .details-form:has(#address_province option[value="ZM-05"]:checked) #address_district optgroup:not([data-p="ZM-05"]) { display: none; }
  .details-form:has(#address_province option[value="ZM-07"]:checked) #address_district optgroup:not([data-p="ZM-07"]) { display: none; }
  .details-form:has(#address_province option[value="ZM-01"]:checked) #address_district optgroup:not([data-p="ZM-01"]) { display: none; }
}

/* the footer: as on the national e-services portal - coat of arms and institution, useful links, the help desk */
.foot { background: #2a2a2a; color: #e0e0e0; padding: 28px 24px 18px; font-size: .92rem; }
.foot a { color: #f2f2f2; }
.foot-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px 32px; max-width: 1080px; margin: 0 auto; }
.foot-col { flex: 1 1 220px; min-width: 0; }
.foot-col h2 { color: #fff; font-size: 1.05rem; margin: 0 0 10px; padding-bottom: 10px; border-bottom: 1px solid #555; }
.foot-col ul { list-style: none; margin: 0; padding: 0; } .foot-col li { margin: 0 0 8px; }
.foot-col p { margin: 0 0 8px; }
.foot-arms { display: block; width: 70px; height: auto; margin-bottom: 12px; }
.foot-org { color: #bdbdbd; line-height: 1.45; } .foot-org strong { color: #fff; }
.foot-social a { color: #bdbdbd; } .foot-social a:hover { color: #fff; }
.foot-label { color: #bdbdbd; margin-bottom: 2px !important; }
.foot-short { color: #bdbdbd; }
.foot-bottom { max-width: 1080px; margin: 18px auto 0; padding-top: 14px; border-top: 1px solid #444; color: #a8a8a8; font-size: .85rem; }

@media (max-width: 600px) {
  :root { --field-h: 230px; }
  .top { padding: 12px 16px; }
  .brand .arms { width: 38px; }
  .sheet { padding: 22px 18px 14px; border-radius: 12px; }
  h1 { font-size: 1.5rem; }
  .eyebrow { letter-spacing: .08em; gap: 8px; } .eyebrow::before { flex-basis: 20px; }
  .field { min-height: 230px; background-size: auto 100%, auto; background-position: right -120px center, 0 0; }
  dl.kv { grid-template-columns: 1fr; } ul.codes { columns: 1; }
  .foot { padding: 22px 16px 14px; }
}
@media (prefers-reduced-motion: no-preference) { button, .button, input, .theme-switch a { transition: background-color .15s, border-color .15s; } }
