/* Mobile-first. Brand colors come from content.yaml via --color-primary / --color-accent
   (set in base.njk). Gold (accent) is decoration only; it fails contrast as text on white. */

:root {
  --color-text: #1b1f24;
  --color-muted: #5a6370;
  --color-border: #c9ced6;
  --color-surface: #f4f6f9;
  --color-error: #b3261e;
  --color-error-bg: #fdecea;
  --color-success: #1e6b35;
  --radius: 10px;
  --gap: 16px;
  color-scheme: light;
}

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

/* Components set display (e.g. .button); the hidden attribute must still win. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: #fff;
  color: var(--color-text);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--color-primary); }

/* Header / footer ------------------------------------------------------------ */

.site-header {
  background: var(--color-primary);
  color: #fff;
  padding: 12px var(--gap) 10px;
  border-bottom: 4px solid var(--color-accent);
}

.brand-center { display: flex; align-items: center; gap: 10px; }
.brand-name { font-size: var(--header-text, 1.05rem); font-weight: 700; line-height: 1.2; }   /* same size as the partnership text */
/* The center's logo is black on transparent, so it sits on a white tile to stay visible
   on the blue header (black on this blue is only about 2.8:1). */
.logo-center {
  height: 44px;
  width: auto;
  flex: none;
  padding: 5px 7px;
  border-radius: 8px;
  background: #fff;
}

.brand-partner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px var(--header-gap);
  margin-top: 6px;
  font-size: var(--header-text, 1.05rem);
  line-height: 1.2;
  opacity: 0.95;
}
/* Header content is as wide as the page content (.page and .page-wide, minus padding). */
.header-inner { --header-gap: 12px; --header-text: 1.05rem; max-width: calc(560px - 2 * var(--gap)); margin: 0 auto; }
.header-inner.page-wide { max-width: calc(1040px - 2 * var(--gap)); }

/* Wider screens: one row, the partnership right after the Ali Center name, kept
   together on the left. Phones keep two lines (one row needs about 420px). */
@media (min-width: 600px) {
  .header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px var(--header-gap);   /* same gap after the name as before the I.M.A.M. logo */
  }
  .brand-partner { margin-top: 0; }
}
/* Gold wordmark straight on the blue header (about 4:1, fine for a logo). */
.logo-partner { height: 28px; width: auto; }

/* Test site only (PREVIEW_MODE). Dark text on gold passes contrast. */
.preview-banner {
  margin: 0;
  padding: 10px var(--gap);
  background: var(--color-accent);
  color: var(--color-text);
  font-weight: 700;
  text-align: center;
}

.site-footer {
  margin-top: auto;
  padding: 20px var(--gap) calc(20px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 0.85rem;
  text-align: center;
}
.site-footer p { margin: 0; }

/* Layout ------------------------------------------------------------------------ */

.page {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 20px var(--gap) 32px;
}

h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 16px; }
h1:focus { outline: none; }
.h-small { font-size: 1.05rem; margin: 24px 0 8px; }
.muted, .help { color: var(--color-muted); }
.help { font-size: 0.9rem; margin: 0 0 6px; }
.note { background: var(--color-surface); border-radius: var(--radius); padding: 12px 14px; }

.checklist { padding-left: 1.2em; margin: 8px 0 16px; }
.checklist li { margin: 4px 0; }

/* Progress -------------------------------------------------------------------- */

/* Keeps the link's full tap height; wraps under the number on narrow screens. */
.account-bar { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; column-gap: 0.4em;
  margin: -8px 0 8px; font-size: 0.9rem; color: var(--color-muted); }
.account-bar[hidden] { display: none; }
.account-bar .button-link { font-size: inherit; }
.progress { margin-bottom: 20px; }
.progress-label { margin: 0 0 8px; font-size: 0.95rem; font-weight: 600; color: var(--color-text); }

/* One segment per step: completed = blue, current = gold with a blue edge, upcoming = empty.
   State never relies on colour alone: each segment has its state as screen-reader text, and
   the current one is taller. */
.tracker {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(var(--steps, 8), minmax(0, 1fr));
  gap: 4px;
  align-items: start;
}
.tracker li { min-width: 0; }
.tracker li::before {
  content: "";
  display: block;
  height: 8px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background: #fff;
}
.tracker li.is-done::before { background: var(--color-primary); border-color: var(--color-primary); }
.tracker li.is-current::before {
  height: 12px;
  background: var(--color-accent);
  border: 2px solid var(--color-primary);
}
/* Phones: segments only; the "Step X of Y" line above carries the name. */
.tracker-name {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
@media (min-width: 600px) {
  .tracker-name {
    position: static !important;
    width: auto; height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
    display: block;
    margin-top: 6px;
    font-size: 0.72rem;
    line-height: 1.2;
    text-align: center;
    color: var(--color-muted);
    hyphens: manual;
  }
  .tracker li.is-current .tracker-name { color: var(--color-text); font-weight: 700; }
}

.steps-intro { font-weight: 600; }

/* Forms ------------------------------------------------------------------------ */

.field { margin: 0 0 18px; border: 0; padding: 0; min-width: 0; }
.field > label, .field > legend, .label { display: block; font-weight: 600; margin: 0 0 6px; padding: 0; }

input[type="text"], input[type="tel"], input[type="email"], input[type="number"], input[type="search"], input[type="date"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 17px;            /* 16px+ stops iOS from zooming on focus */
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #fff;
  color: inherit;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--color-muted) 50%), linear-gradient(135deg, var(--color-muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input:focus, select:focus, textarea:focus, button:focus-visible, .button:focus-visible, .choice:focus-within {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--color-error); }

.row-2, .row-3 { display: grid; gap: 8px; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: 1.4fr 1fr 1.2fr; }

.choices { display: grid; gap: 8px; }
.choices-grid { grid-template-columns: 1fr; }
@media (min-width: 480px) { .choices-grid { grid-template-columns: 1fr 1fr; } }

.choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-weight: 400;
  cursor: pointer;
}
.choice input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--color-primary); }
.choice:has(input:checked) { border-color: var(--color-primary); box-shadow: inset 4px 0 0 var(--color-accent); }
.card .choice { margin-bottom: 8px; }
.choice-optional { margin-bottom: 18px; }

.card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px;
  margin: 0 0 18px;
}
.card legend { font-weight: 700; padding: 0 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: -10px 0 18px; }
.chip {
  font: inherit;
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

.field-inline { display: grid; grid-template-columns: 1fr 110px; align-items: center; gap: 8px; }
.field-inline .field-error { grid-column: 1 / -1; }

.field-error, .form-error { color: var(--color-error); font-size: 0.95rem; margin: 6px 0 0; }
.form-error { background: var(--color-error-bg); padding: 12px 14px; border-radius: var(--radius); margin: 0 0 16px; }

/* Photos ------------------------------------------------------------------------ */

.photo-field { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 14px; }
.photo-buttons { display: grid; gap: 8px; }
.photo-preview { display: block; width: 100%; max-height: 320px; object-fit: contain; background: var(--color-surface); border-radius: 6px; margin: 8px 0; }
.photo-status { margin: 6px 0; }
.is-disabled { opacity: 0.5; pointer-events: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Buttons ------------------------------------------------------------------------ */

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}
.button:disabled { opacity: 0.6; cursor: wait; }
.button-primary { background: var(--color-primary); color: #fff; }
.button-secondary { background: #fff; color: var(--color-primary); border-color: var(--color-primary); }
.button-link { background: none; color: var(--color-primary); text-decoration: underline; min-height: 44px; padding: 8px 0; }
.button-block { width: 100%; }

.actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 24px; }

.status-message { font-size: 1.15rem; }
.turnstile { margin: 0 0 16px; min-height: 0; }

/* Reviewer dashboard ------------------------------------------------------------- */

.page-wide { max-width: 1040px; }
.narrow { max-width: 480px; }
.notice { background: var(--color-surface); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 16px; }

.review-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin: 0 0 16px; padding-bottom: 8px; border-bottom: 1px solid var(--color-border); }
.review-nav > a { font-weight: 600; padding: 10px 0; }
.review-nav > a[aria-current] { text-decoration: none; box-shadow: inset 0 -3px 0 var(--color-accent); }
.review-nav-me { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; font-size: 0.9rem; }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.filters .field { margin-bottom: 12px; }
@media (min-width: 760px) { .filters { grid-template-columns: repeat(3, 1fr) 2fr; } }

.app-list, .team-list, .history { list-style: none; margin: 0 0 16px; padding: 0; }
.app-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}
.app-card:hover, .app-card:focus-visible { border-color: var(--color-primary); }
.app-card-name { font-weight: 600; }
.app-card-meta { grid-column: 1 / -1; color: var(--color-muted); font-size: 0.9rem; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.85rem;
  white-space: nowrap;
  align-self: start;
}
.badge-paid { border-color: var(--color-primary); color: var(--color-primary); }
.badge-verified { border-color: var(--color-primary); background: var(--color-primary); color: #fff; }
.badge-approved { border-color: var(--color-success); background: var(--color-success); color: #fff; }
.badge-rejected { border-color: var(--color-error); color: var(--color-error); background: var(--color-error-bg); }
.badge-standing { border-color: var(--color-success); color: var(--color-success); }
.badge-uploaded { border-color: var(--color-error); color: var(--color-error); background: var(--color-error-bg); }
.app-card .badge-standing { grid-column: 1 / -1; justify-self: start; }
.payments { margin: 12px 0 0; padding-left: 1.2em; }
.payments li { margin: 4px 0; }
.detail-badges { display: flex; flex-wrap: wrap; gap: 6px; }

.exports { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--color-border); }
.exports .button { margin-top: 8px; }

.panel { border-top: 1px solid var(--color-border); padding: 4px 0 12px; }
.panel h3 { font-size: 1rem; margin: 12px 0 6px; }
.facts { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 6px 12px; margin: 0; }
.facts dt { color: var(--color-muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }

.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo { margin: 0; border: 1px solid var(--color-border); border-radius: var(--radius); padding: 8px; min-height: 120px; }
.photo img { display: block; width: 100%; max-height: 420px; object-fit: contain; background: var(--color-surface); border-radius: 6px; cursor: zoom-in; }
.photo figcaption { font-weight: 600; margin-top: 6px; }
.photo-gone { display: flex; align-items: center; background: var(--color-surface); }
.photo.zoomed { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, 0.9); border: 0; border-radius: 0; padding: 12px; display: flex; flex-direction: column; justify-content: center; }
.photo.zoomed img { max-height: calc(100vh - 80px); background: transparent; cursor: zoom-out; }
.photo.zoomed figcaption { color: #fff; text-align: center; }
.compare { background: var(--color-surface); border-radius: var(--radius); padding: 4px 14px 12px; margin-top: 10px; }

.checks { display: grid; gap: 8px; margin-bottom: 8px; }
@media (min-width: 760px) { .checks { grid-template-columns: 1fr 1fr; } }
.check-reference { margin: 12px 0; }
.check-reference .choice { margin-bottom: 6px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form input[type="text"], .inline-form input[type="date"] { flex: 1 1 200px; width: auto; }
.inline-form select { width: auto; flex: 0 1 180px; }
.warning { color: var(--color-error); }

.action { margin: 12px 0 20px; }
.action textarea { margin-bottom: 8px; }
.action-reject { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 14px; }
.action-reject .note { margin: 0 0 12px; }
.button-danger { background: var(--color-error); color: #fff; }
.confirm-panel { border: 2px solid var(--color-primary); border-radius: var(--radius); padding: 12px 14px; }
.confirm-panel p { margin: 0 0 10px; font-weight: 600; }
.confirm-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.decision p { margin: 4px 0; }
.decision-rejected { background: var(--color-error-bg); }

.history li { padding: 8px 0; border-bottom: 1px solid var(--color-surface); }
.history p { margin: 0; overflow-wrap: anywhere; }
.history-meta { color: var(--color-muted); font-size: 0.85rem; }
.team-member { padding: 10px 0; border-bottom: 1px solid var(--color-border); }
.team-member p { margin: 0 0 4px; }

@media (min-width: 900px) {
  .photos { gap: 16px; }
}
