/* GV Academy — styles. Mobile-first (375px), readable on desktop. */

:root {
  --navy: #1f3a5f;
  --navy-deep: #16293f;
  --orange: #e8792b;
  --orange-soft: #fdeee2;

  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #1a2230;
  --muted: #5b6675;
  --border: #d9dfe7;

  --primary: var(--navy);
  --primary-text: #ffffff;
  --accent: var(--orange);

  --ok: #1f7a3f;
  --ok-bg: #e4f4ea;
  --warn: #b26a00;
  --warn-bg: #fff3dc;
  --bad: #b3261e;
  --bad-bg: #fbe4e2;
  --info-bg: #e7eef8;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1621;
    --surface: #182233;
    --surface-2: #1f2c40;
    --text: #e8edf4;
    --muted: #9aa7b8;
    --border: #2c3a4f;
    --primary: #4c7bb8;
    --primary-text: #ffffff;
    --accent: #f08c47;
    --orange-soft: #3a2a1d;
    --ok: #5ccc85;
    --ok-bg: #16311f;
    --warn: #f2b85a;
    --warn-bg: #3a2c12;
    --bad: #f28b84;
    --bad-bg: #3f1b19;
    --info-bg: #1e2d44;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1621;
  --surface: #182233;
  --surface-2: #1f2c40;
  --text: #e8edf4;
  --muted: #9aa7b8;
  --border: #2c3a4f;
  --primary: #4c7bb8;
  --primary-text: #ffffff;
  --accent: #f08c47;
  --orange-soft: #3a2a1d;
  --ok: #5ccc85;
  --ok-bg: #16311f;
  --warn: #f2b85a;
  --warn-bg: #3a2c12;
  --bad: #f28b84;
  --bad-bg: #3f1b19;
  --info-bg: #1e2d44;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--primary); }
strong { font-weight: 700; }
small, .small { font-size: 0.875rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.mono { font-family: var(--mono); font-size: 0.9em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 0 4px; border-radius: 4px; }
pre { background: var(--surface-2); padding: 0.75rem; border-radius: var(--radius); overflow: auto; font-size: 0.85rem; }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--surface); padding: 0.5rem; z-index: 100;
}
.skip:focus { left: 8px; }

/* Layout */
.container {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}
.container.wide { max-width: 1100px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
/* The eye logo (assets/icon-192.png) as a 36px circle; no background box. */
.brand-mark {
  display: block;
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: contain; background: transparent;
  flex: 0 0 auto;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 1rem; }
.brand-sub { font-size: 0.7rem; opacity: 0.8; }
.nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.nav a, .nav button {
  color: #fff; text-decoration: none; font-size: 0.9rem; padding: 6px 10px; border-radius: 8px;
  background: transparent; border: 0; cursor: pointer; font-family: inherit;
}
.nav a.active { background: rgba(255, 255, 255, 0.18); font-weight: 600; }
.nav a:hover, .nav button:hover { background: rgba(255, 255, 255, 0.12); }
.nav .who { opacity: 0.85; font-size: 0.8rem; padding: 6px 4px; }

.mockbar {
  background: var(--warn-bg); color: var(--text);
  padding: 8px 16px; font-size: 0.85rem;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.mockbar .seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.mockbar .seg button {
  border: 0; background: var(--surface); color: var(--text); padding: 4px 10px; cursor: pointer; font-family: inherit; font-size: 0.85rem;
}
.mockbar .seg button.on { background: var(--primary); color: var(--primary-text); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card.tight { padding: 10px 12px; }
.card h2, .card h3 { margin-top: 0; }
.card.accent { border-left: 4px solid var(--accent); }
.card.bad { border-left: 4px solid var(--bad); }
.card.ok { border-left: 4px solid var(--ok); }
.card.info { background: var(--info-bg); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.card-head h2, .card-head h3 { margin: 0; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* Buttons and forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px;
  border-radius: 8px; border: 1px solid var(--primary);
  background: var(--primary); color: var(--primary-text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  touch-action: manipulation;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; filter: none; }
.btn.secondary { background: var(--surface); color: var(--primary); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn.small { min-height: 36px; padding: 4px 10px; font-size: 0.875rem; font-weight: 500; }
.btn.block { width: 100%; }
.btn.icon { min-width: 44px; padding: 0; font-size: 1.1rem; }

label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 0.8rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="tel"], select, textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  min-height: 44px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; margin: 0; accent-color: var(--primary); flex: 0 0 auto; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 8px 6px; font-weight: 400; cursor: pointer; border-radius: 8px; }
.check:hover { background: var(--surface-2); }
.check span { padding-top: 1px; }
input[type="file"] { font: inherit; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* Messages */
.msg { padding: 10px 12px; border-radius: 8px; margin: 8px 0; font-size: 0.95rem; }
.msg.error { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad); }
.msg.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok); }
.msg.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }
.msg.info { background: var(--info-bg); }
.msg:empty { display: none; }
.loading { color: var(--muted); padding: 24px 0; text-align: center; }
.spinner {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite; vertical-align: -3px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--navy-deep); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 0.9rem; z-index: 50; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* Badges and status glyphs */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.locked { background: var(--surface-2); color: var(--muted); }
.badge.available { background: var(--info-bg); color: var(--primary); }
.badge.in_progress { background: var(--warn-bg); color: var(--warn); }
.badge.knowledge_passed { background: var(--ok-bg); color: var(--ok); }
.badge.complete { background: var(--ok); color: #fff; }
.badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.approved, .badge.met, .badge.graded, .badge.strong { background: var(--ok-bg); color: var(--ok); }
.badge.rejected, .badge.missed, .badge.error, .badge.needs_work { background: var(--bad-bg); color: var(--bad); }
.badge.due, .badge.submitted, .badge.acceptable { background: var(--info-bg); color: var(--primary); }
.badge.pending_review, .badge.soon, .badge.behind { background: var(--warn-bg); color: var(--warn); }
.badge.flag { background: var(--bad); color: #fff; }
.glyph { font-weight: 700; display: inline-block; width: 1.2em; text-align: center; }
.glyph.ok { color: var(--ok); }
.glyph.bad { color: var(--bad); }
.glyph.due { color: var(--warn); }
.glyph.dim { color: var(--muted); }
.text-bad { color: var(--bad); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }

/* Progress */
.bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.3s; }
.bar.accent > span { background: var(--accent); }
.bar-label { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); margin: 2px 0 6px; }
.dayline { font-size: 1.25rem; font-weight: 700; margin-bottom: 4px; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-start; }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .meta { font-size: 0.8rem; color: var(--muted); }
.list li.missed { background: var(--bad-bg); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
.list li.amber { background: var(--warn-bg); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
.legend { font-size: 0.8rem; color: var(--muted); margin: 4px 0 8px; }
.legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.legend .swatch.amber { background: var(--warn); }
.legend .swatch.red { background: var(--bad); }

.module-card { display: block; text-decoration: none; color: inherit; }
.module-card.locked { opacity: 0.7; }
.module-card.behind { border-left: 4px solid var(--warn); }
.card.warn { border-left: 4px solid var(--warn); }

/* Lesson media placeholder ({{video: label}}) — neutral, never a broken embed. */
.video-placeholder {
  display: block; margin: 10px 0; padding: 12px 14px;
  border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface-2);
  color: var(--muted); font-size: 0.9rem;
}
.video-placeholder::before { content: "▶ "; color: var(--primary); }

/* Sign-off checklist ticks and activity field inputs */
.ticks .check { padding: 6px 4px; }
.ticks .check .stamp { color: var(--muted); font-size: 0.75rem; margin-left: auto; white-space: nowrap; }
.fields-grid { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 6px 0; }
@media (min-width: 640px) { .fields-grid { grid-template-columns: 1fr 1fr; } }
.fields-grid label { font-size: 0.8rem; }
.fields-grid input { min-height: 40px; padding: 6px 10px; }
.meta-list { margin: 2px 0 0; font-size: 0.8rem; color: var(--muted); }
.module-card .title { font-weight: 700; font-size: 1.05rem; }
.module-card .meta { color: var(--muted); font-size: 0.85rem; }

/* Accordion (lessons) */
details.lesson { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: var(--surface); }
details.lesson summary {
  cursor: pointer; padding: 12px; font-weight: 600; display: flex; gap: 8px; align-items: center; list-style: none;
}
details.lesson summary::-webkit-details-marker { display: none; }
details.lesson summary::before { content: "▸"; color: var(--muted); font-size: 0.9rem; }
details.lesson[open] summary::before { content: "▾"; }
details.lesson .lesson-body { padding: 0 12px 12px; border-top: 1px solid var(--border); }
.prose { max-width: 70ch; }
.prose img { max-width: 100%; height: auto; }
.prose table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; }
.prose blockquote { border-left: 3px solid var(--accent); margin: 0.5rem 0; padding: 4px 12px; color: var(--muted); }
.prose h1 { font-size: 1.3rem; } .prose h2 { font-size: 1.15rem; margin-top: 1rem; } .prose h3 { font-size: 1rem; margin-top: 0.8rem; }

/* Knowledge check */
.question { border-top: 1px solid var(--border); padding: 14px 0; }
.question { scroll-margin-top: 72px; }
/* The first unanswered question when the trainee taps Submit (QA-NOTES 1). */
.question.needs-answer { box-shadow: inset 4px 0 0 var(--bad); padding-left: 10px; }
.question:first-child { border-top: 0; }
.question .stem { font-weight: 600; margin-bottom: 8px; }
.question .qnum { color: var(--muted); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; }
.order-list { list-style: none; margin: 0; padding: 0; }
.order-list li {
  display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; background: var(--surface);
}
.order-list .order-num { font-weight: 700; color: var(--muted); width: 1.5em; text-align: center; flex: 0 0 auto; }
.order-list .order-text { flex: 1; min-width: 0; }
.order-list .order-btns { display: flex; gap: 4px; flex: 0 0 auto; }
.order-list .order-btns button {
  width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 1rem; cursor: pointer;
}
.order-list .order-btns button:disabled { opacity: 0.35; cursor: default; }
.result-big { font-size: 1.4rem; font-weight: 800; margin-bottom: 6px; }

/* Feedback */
.feedback { border-left: 4px solid var(--primary); }
.feedback ul { margin: 4px 0 8px 1.2rem; padding: 0; }
.feedback .verdict { font-weight: 700; }

/* Tables (admin) */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 0 14px; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 0.9rem; min-width: 560px; }
table.tbl th, table.tbl td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--border); vertical-align: top; white-space: nowrap; }
table.tbl th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
table.tbl tr.flagged td { background: var(--bad-bg); }
table.tbl td.wrap { white-space: normal; }
table.tbl a { font-weight: 600; }

/* People (admin): role / status badges, phone cards, wrapped action buttons. */
.badge.admin { background: var(--navy); color: #fff; }
.badge.trainee { background: var(--info-bg); color: var(--primary); }
.badge.active { background: var(--ok-bg); color: var(--ok); }
.badge.invited { background: var(--warn-bg); color: var(--warn); }
.badge.dropped { background: var(--bad-bg); color: var(--bad); }
.badge.deactivated { background: var(--surface-2); color: var(--muted); }
.badge.you { background: var(--accent); color: #fff; }
.people-cards li.deactivated { opacity: 0.7; }
.people-cards li.dropped { opacity: 0.85; }
.people-cards .person-name { font-size: 1.05rem; }
.people-cards .actions { margin-top: 8px; }
.people-cards .meta .badge { vertical-align: 1px; }
table.tbl td.actions { white-space: normal; min-width: 260px; }
table.tbl td.actions .btn { margin: 2px 4px 2px 0; }
.btn.small.text-bad { color: var(--bad); }

/* Admin overview on a phone: cards instead of a side-scrolling table. */
.only-desktop { display: none; }
.trainee-cards a.name {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 44px; font-weight: 700; font-size: 1.05rem; text-decoration: none; color: inherit;
}
.trainee-cards a.name span:first-child { text-decoration: underline; }
@media (min-width: 640px) {
  .only-desktop { display: block; }
  .only-mobile { display: none; }
}

.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.subnav a {
  text-decoration: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 0.9rem;
}
.subnav a.active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 0.95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.notice-text { font-family: var(--font); min-height: 260px; }
.login-wrap { max-width: 420px; margin: 24px auto; }
/* "Save GV Academy to your iPhone" box under the sign-in card: green, light and dark aware
   (the --ok tokens flip in dark mode). */
.card.home-screen-tip { background: var(--ok-bg); border-color: var(--ok); }
.card.home-screen-tip h3 { color: var(--ok); }
.card.home-screen-tip ol { margin: 0 0 8px 1.2rem; padding: 0; }
.card.home-screen-tip ol li { margin-bottom: 4px; }
.back { display: inline-block; margin-bottom: 8px; font-size: 0.9rem; }

/* Terms: the dashboard card and the one-line footer link to #/terms. */
.card.terms-card .row { align-items: center; }
.card.terms-card a { white-space: nowrap; font-weight: 600; }
.terms-link { margin: -6px 0 14px; }

@media (min-width: 640px) {
  .container { padding: 24px 24px 64px; }
  h1 { font-size: 1.75rem; }
}

@media print {
  .topbar, .mockbar, .nav, .btn, .toast { display: none !important; }
}
