/* ====================================================================
   NYC Election Platform — stylesheet
   Design language from the NYC Platform mockup: Archivo display + Public
   Sans body, warm cream canvas, white rounded cards, Kenyan-flag accents.
   ==================================================================== */

:root {
  --bg:        #f1efe9;
  --surface:   #ffffff;
  --surface-2: #faf9f5;
  --ink:       #0d0d0d;
  --muted:     #6b6b62;
  --line:      #e2dfd7;
  --line-2:    #ece9e1;
  --green:     #0a6b2f;
  --green-dk:  #06511f;
  --green-tint:#e6f1e9;
  --red:       #d82028;
  --red-dk:    #b3181f;
  --amber:     #c99a2e;
  --focus:     #1348d4;
  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 1px 2px rgba(13,13,13,.04), 0 10px 30px rgba(13,13,13,.06);
  --shadow-sm: 0 1px 2px rgba(13,13,13,.05);
  --maxw:      1040px;
  --font:      'Public Sans', system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display:   'Archivo', var(--font);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; }
h1 { font-size: 1.9rem; margin: 0 0 .3rem; }
h2 { font-size: 1.2rem; margin: 0 0 .6rem; }
h3 { font-size: 1.02rem; margin: 0 0 .4rem; }

a { color: var(--green); text-underline-offset: 2px; }
a:hover { color: var(--green-dk); }

p { margin: 0 0 .8rem; }

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

/* ---- Skip link ----------------------------------------------------- */
.skip-link { position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--green); color: #fff; padding: .6rem 1rem; border-radius: 0 0 8px 0; text-decoration: none; }
.skip-link:focus { left: 0; }

/* ---- Top bar ------------------------------------------------------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.portal-admin .topbar { border-top: 3px solid var(--green); }
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: .7rem 1.25rem;
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; }
.brand img { height: 42px; width: auto; display: block; }
.brand-mark { display: none; }
.brand-text { display: flex; align-items: center; padding-left: .75rem; margin-left: .1rem;
  border-left: 1px solid var(--line); }
.brand-text strong { display: none; }
.brand-text small { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }

.mainnav { display: flex; gap: .25rem; flex-wrap: wrap; margin-left: auto; }
.mainnav a {
  color: var(--ink); text-decoration: none; font-weight: 500; font-size: .9rem;
  padding: .45rem .7rem; border-radius: 8px; position: relative;
}
.mainnav a:hover { background: var(--surface-2); color: var(--green-dk); }
.mainnav a.active { color: var(--green-dk); }
.mainnav a.active::after {
  content: ""; position: absolute; left: .7rem; right: .7rem; bottom: .12rem; height: 2px;
  background: var(--green); border-radius: 2px;
}

.langswitch { display: flex; gap: .5rem; align-items: center; font-size: .8rem; }
.langswitch a { color: var(--muted); text-decoration: underline; }
.langswitch a:hover { color: var(--green); }
.langswitch [aria-current="true"] { font-weight: 700; color: var(--ink); }

/* ---- Layout -------------------------------------------------------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 1.6rem 1.25rem 3rem; width: 100%; box-sizing: border-box; flex: 1 0 auto; }
main:focus { outline: none; }

.page-head { margin: .2rem 0 1.4rem; }
.page-head h1 { margin-bottom: .25rem; }
.page-head p { color: var(--muted); max-width: 60ch; margin: 0; }

/* ---- Cards --------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem 1.5rem; margin-bottom: 1.2rem; box-shadow: var(--shadow-sm);
  animation: fadeUp .3s ease both;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
@media (max-width: 620px) { .grid-2 { grid-template-columns: 1fr; } }

.divider { border: 0; border-top: 1px solid var(--line); margin: 1.1rem 0; }
.muted { color: var(--muted); }
.meta { color: var(--muted); font-size: .86rem; }
.empty { color: var(--muted); font-style: italic; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* ---- Forms --------------------------------------------------------- */
.field { margin-bottom: 1rem; }
.field > label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.hint { color: var(--muted); font-size: .82rem; margin: .35rem 0 0; }

input:not([type]), input[type=text], input[type=password], input[type=tel], input[type=date],
input[type=number], input[type=email], input[type=search], select, textarea {
  width: 100%; padding: .6rem .7rem; font-size: .95rem;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--green); box-shadow: 0 0 0 3px rgba(10,107,47,.14); outline: none;
}
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
textarea { min-height: 90px; resize: vertical; }
::placeholder { color: #9a9a92; }

/* ---- Searchable select (custom dropdown with a search box) --------- */
.ss { position: relative; }
.ss-native { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.ss-trigger {
  width: 100%; text-align: left; padding: .6rem .7rem; font-size: .95rem;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius-sm); cursor: pointer; display: flex; align-items: center;
  justify-content: space-between; gap: .5rem; font-family: inherit;
}
.ss-trigger:hover { border-color: #cfcec6; }
.ss.open .ss-trigger, .ss-trigger:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(10,107,47,.14); outline: none; }
.ss-trigger .ss-val.placeholder { color: #9a9a92; }
.ss-trigger .ss-caret { flex: none; color: var(--muted); }
.ss-trigger[aria-disabled="true"] { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.ss-panel {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0,0,0,.12); padding: .5rem; max-height: 280px;
  display: flex; flex-direction: column;
}
.ss-panel[hidden] { display: none; }
.ss-search { width: 100%; margin-bottom: .4rem; }
.ss-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.ss-list li {
  padding: .5rem .55rem; border-radius: 8px; cursor: pointer; font-size: .93rem;
}
.ss-list li:hover, .ss-list li.active { background: var(--green-tint); }
.ss-list li[aria-selected="true"] { font-weight: 600; color: var(--green-dk); }
.ss-list li.online { font-weight: 600; }
.ss-empty { padding: .5rem .55rem; color: var(--muted); font-size: .9rem; }
.ss-trigger.err { border-color: var(--red); box-shadow: 0 0 0 3px rgba(200,30,30,.12); }

.choice { display: flex; gap: .55rem; align-items: center; margin: .35rem 0; font-size: .92rem; }
.choice input { width: auto; }

/* ---- Buttons ------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--green); color: #fff; border: 1px solid var(--green);
  padding: .62rem 1.1rem; border-radius: var(--radius-sm); font-weight: 600; font-size: .92rem;
  text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--green-dk); border-color: var(--green-dk); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: .38rem .7rem; font-size: .82rem; border-radius: 8px; }
.btn-ghost { background: var(--surface); color: var(--green-dk); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); color: var(--green-dk); border-color: var(--green); }
.btn-outline { background: transparent; color: var(--green-dk); border-color: var(--green); }
.btn-outline:hover { background: var(--green-tint); color: var(--green-dk); border-color: var(--green-dk); }
.btn-danger { background: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red-dk); border-color: var(--red-dk); }

.row-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline; }
.auth-alt { margin-top: 1rem; font-size: .9rem; }

/* ---- Alerts -------------------------------------------------------- */
.alert { padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid transparent; font-size: .92rem; }
.alert-ok { background: var(--green-tint); border-color: #bfe0c9; color: var(--green-dk); }
.alert-error { background: #fbe9ea; border-color: #f2c4c7; color: var(--red-dk); }

/* ---- Badges -------------------------------------------------------- */
.badge {
  display: inline-block; padding: .16rem .55rem; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .02em; line-height: 1.5;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}
.badge-active, .badge-approved, .badge-open { background: var(--green-tint); border-color: #bfe0c9; color: var(--green-dk); }
.badge-pending, .badge-draft { background: #fbf1dc; border-color: #ecd9a8; color: #8a6a17; }
.badge-rejected, .badge-closed, .badge-retired { background: #fbe9ea; border-color: #f2c4c7; color: var(--red-dk); }

/* ---- Stats --------------------------------------------------------- */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow-sm); }
.stat .num { font-family: var(--display); font-size: 1.8rem; font-weight: 800; letter-spacing: -.02em; }
.stat .lbl { color: var(--muted); font-size: .82rem; margin-top: .1rem; }

/* ---- Tables -------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--line-2); vertical-align: top; font-size: .92rem; }
thead th { background: var(--surface-2); font-family: var(--display); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

/* ---- Landing ------------------------------------------------------- */
.hero { text-align: center; padding: 2rem 1rem 1.4rem; }
.hero img.hero-logo { height: 96px; width: auto; max-width: 90%; margin: 0 auto 1.4rem; display: block; }
.hero h1 { font-size: 2.3rem; }
.hero p { color: var(--muted); max-width: 60ch; margin: .4rem auto 0; font-size: 1rem; line-height: 1.6; }
.hero p.hero-intro { color: var(--ink); }
.hero p.hero-intro a { color: var(--green); font-weight: 600; }
.portals { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; align-items: start; }
@media (max-width: 720px) { .portals { grid-template-columns: 1fr; } }
.portal-card { text-align: left; }
.portal-card .icn { font-size: 1.6rem; margin-bottom: .3rem; }
.cta-stack { display: grid; gap: .6rem; margin-top: 1rem; }
.hint-card { background: var(--surface-2); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 1rem 1.2rem; margin-top: 1.1rem; color: var(--muted); font-size: .9rem; text-align: center; }
.hint-card strong { color: var(--ink); }

/* ---- Footer -------------------------------------------------------- */
.footer { border-top: 1px solid var(--line); background: var(--surface); flex-shrink: 0; }
.footer-inner { max-width: var(--maxw); margin: 0 auto; padding: 1.1rem 1.25rem;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; color: var(--muted); font-size: .84rem; }

/* ---- Misc used across pages --------------------------------------- */
.sub { color: var(--muted); }
.head { margin-bottom: .6rem; }
.sign { color: var(--muted); }
.tag { display: inline-block; border: 1px solid var(--line); border-radius: 6px; padding: .05rem .4rem; font-size: .78rem; }
.who { font-weight: 600; }
.pick { margin: .3rem 0; }
.noprint {}
.area-ward, .area-constituency, .area-county { font-size: .78rem; }

/* ---- Registration wizard (mobile-first) ---------------------------- */
.wizard { max-width: 560px; margin: 0 auto; }
.wiz-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .1rem; }
.wiz-step { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: .8rem; }
.wiz-progress { height: 4px; background: var(--line); border-radius: 3px; overflow: hidden; margin: .5rem 0 1.3rem; }
.wiz-progress > span { display: block; height: 100%; background: var(--green); transition: width .3s; }
.wizard h1 { font-size: 1.7rem; }

.tabs { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px; margin: .3rem 0 1rem; }
.tab { flex: 1; text-align: center; padding: .5rem; border-radius: 8px; border: 0; background: transparent; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.choice-card { display: block; width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: .9rem 1rem; margin: .5rem 0; background: var(--surface); text-align: left; }
.choice-card:hover { border-color: var(--green); }
.choice-card.selected { border-color: var(--green); background: var(--green-tint); }
.choice-card .cc-title { font-weight: 700; }
.choice-card .cc-sub { color: var(--muted); font-size: .86rem; margin-top: .1rem; }
.choice-card .cc-tags { margin-top: .5rem; display: flex; gap: .4rem; flex-wrap: wrap; }
.cc-tag { font-size: .74rem; border: 1px solid #bfe0c9; background: var(--green-tint); color: var(--green-dk); border-radius: 999px; padding: .1rem .5rem; }

.note { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1.1rem; color: var(--muted); font-size: .9rem; margin: .8rem 0; }
.note-green { background: var(--green-tint); border-color: #bfe0c9; color: var(--green-dk); }
.note-amber { background: #fbf1dc; border-color: #ecd9a8; color: #8a6a17; }

.dropzone { border: 2px dashed var(--line); border-radius: 14px; padding: 2.2rem 1rem; text-align: center; color: var(--muted); background: var(--surface); }
.btn-black { background: #0d0d0d; border-color: #0d0d0d; color: #fff; }
.btn-black:hover { background: #000; border-color: #000; color: #fff; }

.check-list label { display: flex; gap: .6rem; align-items: flex-start; border: 1px solid var(--line);
  border-radius: 12px; padding: .8rem 1rem; margin: .5rem 0; background: var(--surface); cursor: pointer; }
.check-list label:has(input:checked) { border-color: var(--green); background: var(--green-tint); }
.check-list input { margin-top: .15rem; }

.review-row { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start;
  padding: .8rem 0; border-bottom: 1px solid var(--line-2); }
.review-row:last-child { border-bottom: 0; }
.review-row .rk { color: var(--muted); font-size: .86rem; max-width: 40%; }
.review-row .rv { font-weight: 600; text-align: right; }

/* Registration status timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 1.3rem 1.7rem; border-left: 2px solid var(--line); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -8px; top: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--line); }
.timeline li.done { border-left-color: var(--green); }
.timeline li.done::before { background: var(--green); border-color: var(--green); }
.timeline li .t-title { font-weight: 700; }
.timeline li .t-sub { color: var(--muted); font-size: .86rem; }

/* Voter certificate card */
.cert { background: var(--green); color: #fff; border-radius: var(--radius); padding: 1.4rem 1.5rem; }
.cert .cert-kicker { text-transform: uppercase; letter-spacing: .12em; font-size: .74rem; opacity: .85; }
.cert h2 { color: #fff; font-size: 1.6rem; margin: .1rem 0 1rem; }
.cert .cert-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1.2rem; }
.cert .cert-grid .k { opacity: .8; font-size: .78rem; }
.cert .cert-grid .v { font-weight: 700; }
.cert .cert-logo { background: #fff; border-radius: 8px; padding: .4rem .6rem; display: inline-block; margin-top: 1rem; }
.cert .cert-logo img { height: 30px; display: block; }

/* ---- Registration status / track page ----------------------------- */
.track { max-width: 520px; margin: 0 auto; }
.track-hero { text-align: center; padding: 1.4rem 0 1rem; }
.track-icon { width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center;
  margin: 0 auto .9rem; font-size: 2rem; font-weight: 700; }
.track-icon-green { background: var(--green-tint); color: var(--green-dk); }
.track-icon-amber { background: #fbf1dc; color: #8a6a17; }
.track-icon-red { background: #fbe9ea; color: var(--red-dk); }
.track-hero h1 { font-size: 1.7rem; margin: 0 0 .3rem; }
.track-hero p { color: var(--muted); max-width: 42ch; margin: 0 auto; line-height: 1.55; }
.track-form { margin-top: 1rem; }
.track-steps { display: flex; align-items: center; justify-content: center; margin: 1.2rem 0 1.4rem; }
.track-steps .tstep { display: flex; flex-direction: column; align-items: center; gap: .35rem; width: 84px; }
.track-steps .dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted); border: 2px solid var(--line); font-size: .95rem; font-weight: 700; }
.track-steps .lbl { font-size: .74rem; color: var(--muted); text-align: center; }
.track-steps .tstep.done .dot { background: var(--green); color: #fff; border-color: var(--green); }
.track-steps .tstep.done .lbl { color: var(--green-dk); font-weight: 600; }
.track-steps .tstep.active .dot { background: #fbf1dc; color: #8a6a17; border-color: #ecd9a8; }
.track-steps .tstep.active .lbl { color: #8a6a17; font-weight: 600; }
.track-steps .tstep.fail .dot { background: #fbe9ea; color: var(--red-dk); border-color: #f2c4c7; }
.track-steps .tbar { height: 3px; flex: 1; max-width: 46px; background: var(--line); border-radius: 2px; margin: 0 -6px 18px; }
.track-steps .tbar.on { background: var(--green); }
.track-details { margin-bottom: 1rem; }
.track-cta { margin-top: .4rem; }
.track-home { text-align: center; margin-top: 1.2rem; }
.track-home a { color: var(--muted); text-decoration: none; font-size: .88rem; }

/* ---- Help / contact ----------------------------------------------- */
.footer-help a { color: var(--green); font-weight: 600; text-decoration: none; white-space: nowrap; }
.footer-help a:hover { text-decoration: underline; }
.help-card .icn { font-size: 1.7rem; }
.help-card h2 { margin: .2rem 0 .3rem; }
.help-card p { color: var(--muted); margin: 0 0 .9rem; }

/* ---- Date-of-birth day/month/year selects ------------------------- */
.dob-row { display: flex; gap: .5rem; }
.dob-row select { flex: 1 1 0; width: 100%; min-width: 0; }
.dob-row select#dob_m { flex: 1.4 1 0; }

/* ---- Accessibility: visible keyboard focus ------------------------ */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, summary:focus-visible,
.tab:focus-within, [tabindex]:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Ensure error alerts read clearly for assistive tech and low vision. */
.alert-error { border-left: 4px solid var(--red); }
