/*
 * styles.css — JEYA Financial Foundations
 *
 * Built mobile-first, because most of this audience will do the course on a
 * phone. Tap targets are 44px minimum, the type scale starts at 16px so iOS does
 * not zoom form fields, and nothing depends on hover.
 */

:root {
  --navy: #0f3d70;
  --navy-dark: #0a2b50;
  --ink: #14213d;
  --body: #374151;
  --muted: #6b7280;
  --line: #e3e8ef;
  --bg: #f4f6f8;
  --card: #ffffff;
  --green: #0a7a46;
  --green-bg: #e8f5ee;
  --amber: #8a5a00;
  --amber-bg: #fdf4e3;
  --red: #a51f1f;
  --red-bg: #fdecec;
  --gold: #d9a321;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 33, 61, .06), 0 6px 20px rgba(20, 33, 61, .05);
}

* { box-sizing: border-box; }

/*
 * The hidden attribute must beat any display set by a class.
 *
 * The browser's own `[hidden] { display: none }` lives in the UA stylesheet,
 * which every rule in this file outranks. So `.overlay { display: flex }` quietly
 * defeated `hidden`, leaving an empty white overlay over the page from first
 * paint — and because closeOverlay() just sets `hidden = true`, the close button,
 * Escape, and tapping the backdrop all did nothing. The page was unusable.
 *
 * !important is deliberate: this has to hold no matter what any later class does,
 * since ten places in app.js toggle `hidden` and trust it to work.
 */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--body);
  background: var(--bg);
}

h1, h2, h3 { color: var(--ink); line-height: 1.25; }
h1 { font-size: 1.7rem; margin: 0 0 .5rem; }
h2 { font-size: 1.2rem; margin: 0 0 .5rem; }
h3 { font-size: 1.02rem; margin: 0; }
p { margin: .5rem 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

main { max-width: 760px; margin: 0 auto; padding: 20px 16px 72px; }

/* ------------------------------------------------------------------ top bar --- */

#top-bar { background: var(--navy); color: #fff; }
.bar-inner {
  max-width: 760px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1rem; letter-spacing: .01em; }
.brand-thin { font-weight: 400; color: #b9cde6; }
#top-bar nav { display: flex; gap: 4px; }

.link-btn {
  background: none; border: 0; color: #d6e4f4; font: inherit; font-size: .9rem;
  padding: 8px 10px; min-height: 44px; border-radius: 8px; cursor: pointer;
}
.link-btn:hover, .link-btn:focus-visible { background: rgba(255, 255, 255, .12); color: #fff; }
.link-btn[aria-current="true"] { color: #fff; font-weight: 600; }

/* --------------------------------------------------------------------- hero --- */

.hero { padding: 16px 0 26px; }
.eyebrow {
  font-size: .78rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--navy); font-weight: 700; margin: 0 0 6px;
}
.hero h1 { font-size: 2.1rem; }
.lede { font-size: 1.05rem; color: var(--body); max-width: 56ch; }
.hero-points { margin: 18px 0 0; padding: 0; list-style: none; }
.hero-points li {
  position: relative; padding-left: 26px; margin: 9px 0;
  color: var(--body); font-size: .95rem;
}
.hero-points li::before {
  content: "✓"; position: absolute; left: 0; top: 0;
  color: var(--green); font-weight: 700;
}

/* --------------------------------------------------------------------- card --- */

.card {
  background: var(--card); border-radius: var(--radius); padding: 22px 20px;
  box-shadow: var(--shadow); margin-bottom: 18px;
}
.card.celebrate { border-top: 4px solid var(--gold); }

/* -------------------------------------------------------------------- forms --- */

label { display: block; font-weight: 600; font-size: .9rem; color: var(--ink); margin: 14px 0 5px; }
input[type="text"], input[type="email"], textarea, select {
  width: 100%; padding: 12px 13px; font: inherit; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: 9px;
  min-height: 46px;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(15, 61, 112, .12);
}
textarea { min-height: 84px; resize: vertical; }

fieldset { border: 0; padding: 0; margin: 4px 0 0; }
legend { padding: 0; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }

button { font: inherit; cursor: pointer; }
.primary, .secondary, .approve, .reject {
  border: 0; border-radius: 9px; padding: 13px 20px; min-height: 48px;
  font-weight: 600; font-size: .97rem; width: 100%; margin-top: 18px;
}
.primary { background: var(--navy); color: #fff; }
.primary:hover:not(:disabled) { background: var(--navy-dark); }
.secondary { background: #eef2f7; color: var(--ink); }
.secondary:hover:not(:disabled) { background: #e2e8f0; }
.approve { background: var(--green); color: #fff; }
.reject { background: #fff; color: var(--red); box-shadow: inset 0 0 0 1.5px var(--red); }
button:disabled { opacity: .5; cursor: not-allowed; }

.btn-inline { width: auto; margin-top: 0; padding: 10px 16px; min-height: 44px; }

.icon-btn {
  background: none; border: 0; font-size: 1.9rem; line-height: 1; color: var(--muted);
  width: 44px; height: 44px; border-radius: 8px; flex: none;
}
.icon-btn:hover { background: #f1f4f8; color: var(--ink); }

.msg { font-size: .9rem; margin: 12px 0 0; min-height: 1.2em; }
.msg.ok { color: var(--green); }
.msg.error { color: var(--red); }

/* ----------------------------------------------------------------- progress --- */

.progress-wrap { display: flex; align-items: center; gap: 11px; margin: 10px 0 4px; }
.progress-track {
  flex: 1; height: 9px; background: #dfe5ec; border-radius: 99px; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0; background: var(--green); border-radius: 99px;
  transition: width .35s ease;
}
.progress-label { font-size: .84rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------------- units --- */

.unit {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 14px; overflow: hidden;
}
.unit-head {
  display: flex; align-items: center; gap: 13px; padding: 17px 18px;
  border-bottom: 1px solid var(--line);
}
.unit.is-locked .unit-head { background: #fafbfc; }
.unit-num {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: .9rem;
  background: #eef2f7; color: var(--muted);
}
.unit.is-current .unit-num { background: var(--navy); color: #fff; }
.unit.is-done .unit-num { background: var(--green-bg); color: var(--green); }
.unit-title { flex: 1; min-width: 0; }
.unit-title h3 { font-size: 1rem; }
.unit-title .unit-sub { font-size: .84rem; color: var(--muted); margin: 2px 0 0; }

.steps { list-style: none; margin: 0; padding: 6px 0; }
.step {
  display: flex; align-items: center; gap: 13px; padding: 12px 18px;
  border-top: 1px solid #f2f5f8;
}
.step:first-child { border-top: 0; }
.step-icon { flex: none; font-size: 1.15rem; width: 26px; text-align: center; }
.step-body { flex: 1; min-width: 0; }
.step-name { font-size: .95rem; color: var(--ink); font-weight: 500; }
.step-meta { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.step.is-locked .step-name, .step.is-locked .step-meta { color: #9aa3b0; }

.pill {
  flex: none; font-size: .74rem; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; padding: 4px 9px; border-radius: 99px;
}
.pill.done { background: var(--green-bg); color: var(--green); }
.pill.open { background: #e7eefb; color: var(--navy); }
.pill.wait { background: var(--amber-bg); color: var(--amber); }
.pill.locked { background: #f1f3f6; color: #98a1ae; }

/* --------------------------------------------------------------------- tabs --- */

/* Enrol / sign-in switch on the front page. 44px tall for thumbs. */
.tabs {
  display: flex; gap: 6px; margin: 0 0 18px;
  background: #eef1f5; border-radius: 10px; padding: 4px;
}
.tab {
  flex: 1; min-height: 44px; padding: 10px 8px; border: 0; border-radius: 7px;
  background: none; color: var(--muted); font: inherit; font-size: .92rem;
  font-weight: 600; cursor: pointer;
}
.tab[aria-selected="true"] {
  background: var(--card); color: var(--navy);
  box-shadow: 0 1px 3px rgba(20, 33, 61, .12);
}
/* Visible focus, since this is operable by keyboard and never by hover alone. */
.tab:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

/* ------------------------------------------------------------------ overlay --- */

.overlay {
  position: fixed; inset: 0; background: rgba(12, 22, 40, .58);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
  padding: 0;
}
.overlay-card {
  background: var(--card); width: 100%; max-width: 720px;
  max-height: 94vh; display: flex; flex-direction: column;
  border-radius: 16px 16px 0 0;
}
.overlay-head {
  display: flex; align-items: flex-start; gap: 12px; padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line); flex: none;
}
.overlay-head h2 { flex: 1; min-width: 0; font-size: 1.1rem; }
#overlay-body { padding: 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

@media (min-width: 620px) {
  .overlay { align-items: center; padding: 24px; }
  .overlay-card { border-radius: var(--radius); max-height: 90vh; }
}

/* ---------------------------------------------------------- media + gating --- */

.gate-note {
  background: #eef2f7; border-left: 3px solid var(--navy); border-radius: 0 6px 6px 0;
  padding: 11px 14px; font-size: .88rem; color: var(--body); margin: 0 0 16px;
}

audio { width: 100%; margin: 6px 0 14px; }

.pdf-stage {
  background: #eceff3; border-radius: 9px; padding: 10px;
  max-height: 58vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.pdf-stage canvas {
  display: block; width: 100%; height: auto; background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .14); border-radius: 3px; margin: 0 auto 10px;
}
.pdf-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: .86rem; color: var(--muted); margin-top: 10px;
}

/* ------------------------------------------------------------------- quizzes --- */

.question { padding: 16px 0; border-top: 1px solid var(--line); }
.question:first-of-type { border-top: 0; padding-top: 4px; }
.question .q-text { font-weight: 600; color: var(--ink); margin: 0 0 11px; }
.q-num { color: var(--navy); }

.choice {
  display: flex; align-items: flex-start; gap: 11px; padding: 12px 13px;
  border: 1.5px solid var(--line); border-radius: 9px; margin-bottom: 8px;
  cursor: pointer; background: #fff; min-height: 48px;
}
.choice:hover { border-color: #c3cede; background: #fbfcfd; }
.choice input { margin: 3px 0 0; width: 19px; height: 19px; flex: none; accent-color: var(--navy); }
.choice.chosen { border-color: var(--navy); background: #f5f8fc; }
.choice span { flex: 1; }

/* Marks a question that was answered wrongly on the last attempt. Which one was
   missed is shown; what the right answer is, never. */
.question.was-wrong {
  background: var(--red-bg); border-radius: 9px;
  padding: 14px 13px; margin: 10px 0; border-top-color: transparent;
}
.question.was-wrong .q-text::after {
  content: " — check this one again";
  font-weight: 400; color: var(--red); font-size: .87rem;
}

.quiz-result { border-radius: 9px; padding: 14px 16px; margin-bottom: 16px; }
.quiz-result.pass { background: var(--green-bg); color: var(--green); }
.quiz-result.fail { background: var(--red-bg); color: var(--red); }
.quiz-result strong { display: block; margin-bottom: 3px; }

/* ------------------------------------------------------------------- upload --- */

.criteria { margin: 0 0 16px; padding: 0; list-style: none; }
.criteria li {
  position: relative; padding-left: 25px; margin: 8px 0; font-size: .93rem;
}
.criteria li::before {
  content: "□"; position: absolute; left: 0; color: var(--navy); font-size: 1.05rem;
}
.photo-preview {
  max-width: 100%; max-height: 260px; border-radius: 9px; margin: 12px 0 0;
  display: block; box-shadow: var(--shadow);
}
input[type="file"] {
  width: 100%; padding: 14px; border: 1.5px dashed #c3cede; border-radius: 9px;
  background: #fbfcfd; font-size: .92rem;
}

/* -------------------------------------------------------------------- admin --- */

.sub-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.sub-head { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.sub-head .who { font-weight: 600; color: var(--ink); }
.sub-body { padding: 16px 18px; }
.sub-photo { width: 100%; border-radius: 9px; background: #eceff3; display: block; }

.ai-box { border-radius: 9px; padding: 13px 15px; margin: 14px 0; font-size: .9rem; }
.ai-box.pass { background: var(--green-bg); }
.ai-box.fail { background: var(--red-bg); }
.ai-box.unclear, .ai-box.none { background: var(--amber-bg); }
.ai-box .ai-label {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  font-weight: 700; color: var(--muted); margin-bottom: 6px;
}
.ai-crit { margin: 9px 0 0; padding: 0; list-style: none; }
.ai-crit li { padding: 4px 0 4px 22px; position: relative; font-size: .88rem; }
.ai-crit li.yes::before { content: "✓"; color: var(--green); position: absolute; left: 0; font-weight: 700; }
.ai-crit li.no::before { content: "✗"; color: var(--red); position: absolute; left: 0; font-weight: 700; }
.ai-crit li.cannot_tell::before { content: "?"; color: var(--amber); position: absolute; left: 0; font-weight: 700; }

.decide { display: flex; gap: 10px; margin-top: 16px; }
.decide > button { margin-top: 0; }

/* -------------------------------------------------------------------- toast --- */

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 13px 20px; border-radius: 9px;
  font-size: .92rem; max-width: calc(100vw - 32px); z-index: 90;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .22);
}

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.spinner { text-align: center; color: var(--muted); padding: 30px; }

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