/* ==================================================================
   assets/css/app.css: voter site theme on top of Bootstrap 5.3
   Colours come from the chaplaincy logo:
     green  #0E6334  actions, links, progress
     purple #561047  headings
     orange #E8782A  small highlights only (fails contrast as text)
   ================================================================== */

@font-face {
  font-family: "Figtree";
  src: url("../vendor/figtree/figtree-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --app-green: #0E6334;
  --app-green-dark: #09481F;
  --app-green-soft: #E3F1E8;
  --app-green-tint: #E9F5EE;
  --app-purple: #561047;
  --app-purple-soft: #EDE4EC;
  --app-orange: #E8782A;
  --app-warn-bg: #FFF4EA;
  --app-warn-ink: #4A2A0E;
  --app-ink: #17201B;
  --app-ink-2: #3F4A44;
  --app-muted: #55605A;
  --app-line: #DDE3DF;
  --app-line-strong: #B9C3BD;
  --app-ground: #F5F7F4;
  --app-radius: 16px;
  --app-radius-sm: 12px;

  --bs-body-font-family: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-body-color: var(--app-ink);
  --bs-body-bg: var(--app-ground);
  --bs-link-color: var(--app-green);
  --bs-link-color-rgb: 14, 99, 52;
  --bs-link-hover-color: var(--app-green-dark);
  --bs-link-hover-color-rgb: 9, 72, 31;
  --bs-border-color: var(--app-line);
  --bs-heading-color: var(--app-purple);
  --bs-primary: #0E6334;
  --bs-primary-rgb: 14, 99, 52;
  --bs-focus-ring-color: rgba(14, 99, 52, .3);
}

body { font-size: 16px; line-height: 1.5; }

h1, .h1 { font-weight: 800; line-height: 1.15; }
h2, .h2, h3, .h3 { font-weight: 800; }

/* ---------- Buttons ---------- */
.btn { --bs-btn-font-weight: 700; --bs-btn-border-radius: var(--app-radius-sm); min-height: 44px; }
.btn-lg { --bs-btn-padding-y: .75rem; --bs-btn-font-size: 1.0625rem; min-height: 52px; }
.btn-primary {
  --bs-btn-bg: var(--app-green); --bs-btn-border-color: var(--app-green);
  --bs-btn-hover-bg: var(--app-green-dark); --bs-btn-hover-border-color: var(--app-green-dark);
  --bs-btn-active-bg: var(--app-green-dark); --bs-btn-active-border-color: var(--app-green-dark);
  --bs-btn-disabled-bg: #C9D3CD; --bs-btn-disabled-border-color: #C9D3CD; --bs-btn-disabled-color: var(--app-ink-2);
  --bs-btn-disabled-opacity: 1;
}
.btn-outline-primary {
  --bs-btn-color: var(--app-green); --bs-btn-border-color: var(--app-green); --bs-btn-border-width: 2px;
  --bs-btn-hover-bg: var(--app-green); --bs-btn-hover-border-color: var(--app-green);
  --bs-btn-active-bg: var(--app-green-dark); --bs-btn-active-border-color: var(--app-green-dark);
}
.btn-outline-secondary {
  --bs-btn-color: var(--app-ink); --bs-btn-border-color: #CFD8D3; --bs-btn-border-width: 2px;
  --bs-btn-hover-bg: #EEF1EF; --bs-btn-hover-color: var(--app-ink); --bs-btn-hover-border-color: #B9C3BD;
  --bs-btn-active-bg: #E2E8E4; --bs-btn-active-color: var(--app-ink); --bs-btn-bg: #fff;
}
.btn-link { --bs-btn-color: var(--app-green); --bs-btn-hover-color: var(--app-green-dark); }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: .9375rem; margin-bottom: .375rem; }
.form-control, .form-select {
  min-height: 48px; border-color: var(--app-line-strong); border-radius: var(--app-radius-sm); font-size: 1rem;
}
.form-control:focus, .form-select:focus { border-color: var(--app-green); box-shadow: 0 0 0 .25rem rgba(14, 99, 52, .25); }
.form-text { color: var(--app-muted); font-size: .875rem; }
.form-check-input:checked { background-color: var(--app-green); border-color: var(--app-green); }
.form-check-input:focus { box-shadow: 0 0 0 .25rem rgba(14, 99, 52, .25); }

/* Segmented choice (year of study) built from radio inputs */
.segmented { display: grid; grid-template-columns: repeat(var(--segments, 5), minmax(0, 1fr)); gap: 6px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  min-height: 44px; display: flex; align-items: center; justify-content: center; text-align: center;
  border: 1px solid var(--app-line-strong); border-radius: 10px; font-weight: 600; cursor: pointer; background: #fff;
  font-size: .9375rem; padding: 0 4px;
}
.segmented input:checked + label { border: 2px solid var(--app-green); background: var(--app-green-soft); color: #0B4F29; font-weight: 700; }
.segmented input:focus-visible + label { outline: 3px solid #9CCFB0; outline-offset: 2px; }

/* ---------- Surfaces ---------- */
.app-card { background: #fff; border: 1px solid var(--app-line); border-radius: var(--app-radius); padding: 20px; }
.app-section-label { font-size: .8125rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--app-muted); }
fieldset.app-card > legend { float: none; width: auto; padding: 0 6px; margin: 0 0 4px -6px; }

.app-shell { max-width: 480px; margin: 0 auto; padding: 16px 16px 32px; }
.app-shell-wide { max-width: 760px; }

/* Top bar on inner pages */
.app-bar { background: #fff; border-bottom: 1px solid var(--app-line); }
.app-bar-inner { max-width: 760px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; }
.app-bar-title { font-weight: 700; font-size: .9375rem; line-height: 1.2; }
.app-bar-sub { font-size: .8125rem; color: var(--app-muted); }

/* Status pill */
.status-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  font-size: .875rem; font-weight: 600; background: #EEF1EF; color: var(--app-ink-2);
}
.status-pill::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: currentColor; }
.status-pill.is-open { background: var(--app-green-soft); color: #0B4F29; }
.status-pill.is-soon { background: var(--app-warn-bg); color: #6B3610; }

/* Alerts */
.alert { border-radius: var(--app-radius-sm); font-size: .9375rem; }
.alert ul { margin: 0; padding-left: 1.1rem; }
.app-note { display: flex; gap: 12px; padding: 14px; background: var(--app-warn-bg); color: var(--app-warn-ink); border-radius: var(--app-radius-sm); font-size: .9375rem; }

/* ---------- Ballot ---------- */
.ballot-progress { display: flex; gap: 6px; }
.ballot-progress span { flex: 1; height: 6px; border-radius: 999px; background: #D6DED9; }
.ballot-progress span.is-done { background: var(--app-green); }

.candidate { display: flex; gap: 8px; align-items: stretch; }
.candidate input { position: absolute; opacity: 0; pointer-events: none; }
.candidate-card {
  flex: 1; min-height: 76px; display: flex; align-items: center; gap: 14px; padding: 13px 15px; margin: 0;
  border: 1px solid #CFD8D3; background: #fff; border-radius: var(--app-radius); cursor: pointer;
}
.candidate-photo {
  width: 52px; height: 52px; border-radius: 999px; flex-shrink: 0; object-fit: cover;
  background: var(--app-purple-soft); color: var(--app-purple); display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.125rem;
}
.candidate-name { flex: 1; font-size: 1.0625rem; font-weight: 700; line-height: 1.25; }
.candidate-chosen { display: none; font-size: .875rem; font-weight: 600; color: #0B4F29; }
.candidate-mark {
  width: 26px; height: 26px; border-radius: 999px; border: 2px solid #8A968F; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.candidate-mark svg { display: none; }
.candidate input:checked + .candidate-card { border: 2px solid var(--app-green); background: var(--app-green-tint); padding: 12px 14px; }
.candidate input:checked + .candidate-card .candidate-mark { background: var(--app-green); border-color: var(--app-green); }
.candidate input:checked + .candidate-card .candidate-mark svg { display: block; }
.candidate input:checked + .candidate-card .candidate-chosen { display: block; }
.candidate input:focus-visible + .candidate-card { outline: 3px solid #9CCFB0; outline-offset: 2px; }
.candidate-more {
  width: 52px; border: 1px solid #CFD8D3; background: #fff; border-radius: var(--app-radius); color: var(--app-green);
  display: flex; align-items: center; justify-content: center;
}
.candidate-more:hover { background: #EEF1EF; }

/* Sticky action bar under the ballot */
.ballot-actions {
  position: sticky; bottom: 0; display: flex; gap: 12px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(245, 247, 244, 0), var(--app-ground) 24%);
}
.ballot-actions .btn { flex: 1; }
.ballot-actions .btn-primary { flex: 2; }

/* When JS runs, the ballot shows one position at a time */
.js-ballot .ballot-step { display: none; }
.js-ballot .ballot-step.is-active { display: block; }

.review-list { background: #fff; border: 1px solid var(--app-line); border-radius: var(--app-radius); }
.review-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid #EEF1EF; }
.review-row:last-child { border-bottom: 0; }

/* ---------- Results ---------- */
.stat-tile { background: #fff; border: 1px solid var(--app-line); border-radius: var(--app-radius); padding: 14px 16px; }
.stat-value { font-size: 1.875rem; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: .875rem; color: var(--app-muted); }

.result-row + .result-row { margin-top: 14px; }
.result-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.result-name { flex: 1; }
.result-figure { min-width: 80px; text-align: right; color: var(--app-ink-2); font-size: .9375rem; }
.result-bar { height: 10px; border-radius: 4px; background: #EEF1EF; }
.result-bar > span { display: block; height: 10px; border-radius: 4px; background: #5E8C70; min-width: 2px; }
.result-row.is-winner .result-name, .result-row.is-winner .result-figure { font-weight: 700; color: var(--app-ink); }
.result-row.is-winner .result-bar > span { background: var(--app-green); }
.badge-elected { background: var(--app-green); color: #fff; border-radius: 999px; font-size: .75rem; font-weight: 700; padding: 2px 8px; }

/* ---------- Footer ---------- */
.app-footer { font-size: .8125rem; color: var(--app-muted); text-align: center; padding: 24px 16px 32px; }
.app-footer a { color: var(--app-muted); }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

/* Inline field errors (assets/js/voter-validation.js toggles .visible / .has-error) */
.error-text { display: none; color: #B42318; font-size: .875rem; margin-top: 4px; }
.error-text.visible { display: block; }
.form-group.has-error .form-control, .form-group.has-error .form-select { border-color: #B42318; }
.result-photo { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; flex-shrink: 0; background: var(--app-purple-soft); display: block; }
.result-photo-btn { padding: 0; border: 0; background: none; border-radius: 14px; flex-shrink: 0; cursor: zoom-in; position: relative; }
.result-photo-btn::after { content: ""; position: absolute; right: -4px; bottom: -4px; width: 22px; height: 22px; border-radius: 999px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230E6334' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3M11 8v6M8 11h6'/%3E%3C/svg%3E") center/14px no-repeat; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.result-photo-btn:focus-visible { outline: 3px solid #9CCFB0; outline-offset: 2px; }
.result-head { gap: 12px; }

/* ---------- Voting guide ---------- */
.guide-hero { background: var(--app-green); color: #fff; border-radius: 20px; padding: 28px 24px; }
.guide-hero h1 { color: #fff; font-size: clamp(1.75rem, 5vw, 2.5rem); }
.guide-hero p { color: #E3F1E8; font-size: 1.0625rem; }
.guide-kicker { font-size: .8125rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #CDE6D6; }
.guide-hero .status-pill { background: rgba(255,255,255,.14); color: #fff; }
.guide-hero .btn-outline-light { --bs-btn-border-width: 2px; --bs-btn-hover-color: var(--app-green); }

.guide-timeline { position: relative; display: flex; flex-direction: column; gap: 18px; padding-left: 4px; }
.guide-timeline li { position: relative; display: flex; gap: 14px; align-items: flex-start; }
.guide-timeline li:not(:last-child)::after { content: ""; position: absolute; left: 13px; top: 30px; bottom: -18px; width: 2px; background: var(--app-line); }
.guide-timeline-dot { width: 28px; height: 28px; border-radius: 999px; border: 2px dashed #8A968F; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--app-ground); position: relative; z-index: 1; }
.guide-timeline .is-done .guide-timeline-dot { border: 0; background: var(--app-green); color: #fff; }
.guide-timeline .is-now .guide-timeline-dot { border: 3px solid var(--app-green); background: #fff; box-shadow: 0 0 0 4px var(--app-green-soft); }

.guide-steps { display: flex; flex-direction: column; gap: 0; }
.guide-step { position: relative; display: flex; gap: 16px; padding-bottom: 28px; }
.guide-step:not(:last-child)::after { content: ""; position: absolute; left: 23px; top: 52px; bottom: 4px; width: 2px; background: var(--app-line); }
.guide-step-icon { width: 48px; height: 48px; border-radius: 14px; background: var(--app-purple-soft); color: var(--app-purple); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.guide-step-body { flex: 1; min-width: 0; }
.guide-step-body p { color: var(--app-ink-2); }
.guide-step-num { font-size: .8125rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--app-muted); }
.guide-preview { background: #fff; border: 1px solid var(--app-line); border-radius: var(--app-radius); padding: 14px; max-width: 380px; box-shadow: 0 6px 20px rgba(16, 41, 27, .06); }

.guide-faq { --bs-accordion-border-radius: var(--app-radius); --bs-accordion-inner-border-radius: calc(var(--app-radius) - 1px); --bs-accordion-active-bg: var(--app-green-tint); --bs-accordion-active-color: var(--app-ink); --bs-accordion-btn-focus-box-shadow: 0 0 0 .25rem rgba(14, 99, 52, .25); }
.guide-faq .accordion-button { min-height: 56px; }

.guide-contact { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 16px; background: #fff; border: 1px solid var(--app-line); border-radius: var(--app-radius); text-decoration: none; color: var(--app-ink); }
.guide-contact svg { color: var(--app-green); flex-shrink: 0; }
.guide-contact:hover { border-color: var(--app-green); color: var(--app-ink); }

/* Member search suggestions (assets/js/member-search.js) */
.member-suggestions { position: absolute; z-index: 1050; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; background: #fff; border: 1px solid #DDE3DF; border-radius: 12px; box-shadow: 0 10px 30px rgba(16, 41, 27, .15); max-height: 320px; overflow-y: auto; }
.member-suggestions li[role=option] { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.member-suggestions li[role=option]:hover, .member-suggestions li.is-active { background: #E9F5EE; }
.member-suggestions small { color: #55605A; }
.member-suggestion-empty { padding: 10px 12px; color: #55605A; font-size: 14px; }
.view-choice { display: flex; align-items: center; gap: 16px; text-decoration: none; color: var(--app-ink); min-height: 88px; }
.view-choice:hover, .view-choice:focus { border-color: var(--app-green); color: var(--app-ink); }
.view-switch { font-size: .875rem; font-weight: 700; border-radius: 999px; padding: 6px 12px; background: #10291B; color: #fff; text-decoration: none; white-space: nowrap; }
.view-switch:hover, .view-switch:focus { background: var(--app-green); color: #fff; }
/* Profile */
.profile-photo { width: 72px; height: 72px; border-radius: 18px; object-fit: cover; flex-shrink: 0; font-size: 1.5rem; }
.profile-list { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px 12px; }
.profile-list dt { font-weight: 600; color: var(--app-muted); font-size: .9375rem; }
.profile-list dd { margin: 0; font-weight: 600; word-break: break-word; }

/* ---------- Inbox: notifications and messages ---------- */
.bell-link { color: var(--app-ink); display: inline-flex; align-items: center; }
.bell-badge {
  position: absolute; top: 4px; right: 0; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--app-orange); color: #fff; font-size: 11px; font-weight: 700;
  line-height: 18px; text-align: center;
}
.inbox-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--app-line); }
.inbox-tabs a {
  padding: 10px 14px; font-weight: 700; color: var(--app-muted); text-decoration: none;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.inbox-tabs a.is-active { color: var(--app-green); border-bottom-color: var(--app-green); }
.count-badge {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--app-orange);
  color: #fff; font-size: 12px; line-height: 20px; text-align: center;
}
.inbox-list { list-style: none; margin: 0; overflow: hidden; }
.inbox-list li + li { border-top: 1px solid var(--app-line); }
.inbox-list a { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; color: var(--app-ink); text-decoration: none; }
.inbox-list a:hover { background: var(--app-ground); }
.inbox-dot { flex: 0 0 8px; height: 8px; margin-top: 8px; border-radius: 50%; background: transparent; }
.inbox-list .is-unread .inbox-dot { background: var(--app-orange); }
.inbox-list .is-unread { background: var(--app-green-tint); }
.inbox-list li:not(.is-unread) strong { font-weight: 600; }
.inbox-when { flex: none; font-size: 13px; color: var(--app-muted); }
.inbox-preview { display: block; font-size: 14px; color: var(--app-ink-2); overflow-wrap: anywhere; }
.thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.thread-msg { max-width: 88%; }
.thread-msg.is-mine { align-self: flex-end; text-align: right; }
.thread-meta { font-size: 12.5px; color: var(--app-muted); margin-bottom: 3px; }
.thread-bubble {
  display: inline-block; text-align: left; padding: 10px 14px; border-radius: 14px 14px 14px 4px;
  background: #fff; border: 1px solid var(--app-line); overflow-wrap: anywhere;
}
.thread-msg.is-mine .thread-bubble { background: var(--app-green-soft); border-color: transparent; border-radius: 14px 14px 4px 14px; }
.min-w-0 { min-width: 0; }
.app-bar-inner > .btn-link { flex: none; }

/* ---------- Election tabs (general + group elections) ---------- */
.election-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.election-tabs::-webkit-scrollbar { display: none; }
.election-tabs a {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px;
  border: 1.5px solid var(--app-line-strong); border-radius: 999px; background: #fff;
  color: var(--app-ink); font-weight: 700; font-size: 15px; text-decoration: none; white-space: nowrap;
}
.election-tabs a.is-active { background: var(--app-green); border-color: var(--app-green); color: #fff; }
.election-tab-live { width: 8px; height: 8px; border-radius: 50%; background: var(--app-orange); }

/* Bigger candidate photos on the ballot so voters can clearly see who is who;
   tapping the photo opens it full size (the zoom badge), the rest of the card selects */
.candidate-card .candidate-photo { width: 96px; height: 96px; border-radius: 16px; font-size: 1.5rem; }
.candidate-card .result-photo-btn { border-radius: 16px; }
.candidate-card { min-height: 120px; }
@media (min-width: 576px) {
  .candidate-card .candidate-photo { width: 112px; height: 112px; }
}

/* ---------- Help (user guides) ---------- */
.help-toc { margin: 0; padding-left: 1.1rem; columns: 2; column-gap: 24px; }
.help-toc li { break-inside: avoid; margin-bottom: 4px; }
@media (max-width: 575px) { .help-toc { columns: 1; } }
.help-doc h2 { font-size: 1.4rem; margin: 1.6rem 0 .6rem; scroll-margin-top: 80px; }
.help-doc h2:first-child { margin-top: 0; }
.help-doc h3 { font-size: 1.1rem; margin-top: 1.2rem; }
.help-doc p, .help-doc li { line-height: 1.6; }
.help-doc li + li { margin-top: 4px; }
.help-doc code { background: var(--app-ground); color: var(--app-ink); padding: 1px 5px; border-radius: 4px; }
.help-doc pre { background: var(--app-ground); padding: 12px; border-radius: 8px; overflow-x: auto; }
.privacy-section h2 { font-size: 1.35rem; margin-top: 0; }
.privacy-section > :last-child { margin-bottom: 0; }
