/* Forge. Colors are tokens; dark mode redefines them. JOG navy #0F3368 is the brand color. */
:root {
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #F8F9FB;
  --ink: #1F2933;
  --muted: #5B6472;
  --line: #E3E6EA;
  --brand: #0F3368;
  --brand-hover: #1A4785;
  --on-brand: #FFFFFF;
  --tint: #EEF3FB;
  --ember: #C76A12;
  --bar: #0F3368;
  --bar-track: #EEF1F5;
  --ok: #0E7A4D;
  --danger: #B42318;
  --warn-bg: #FFF7E6;
  --warn-ink: #8A4B00;
  --focus: #2F6FD6;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1116;
    --surface: #161B22;
    --surface-2: #1B212A;
    --ink: #E6E9EE;
    --muted: #9AA4B2;
    --line: #2A313C;
    --brand: #4F80D0;
    --brand-hover: #6A95DB;
    --on-brand: #0B1220;
    --tint: #1C2738;
    --ember: #F2A541;
    --bar: #7AA5F0;
    --bar-track: #222A35;
    --ok: #4CC38A;
    --danger: #F97066;
    --warn-bg: #2E2410;
    --warn-ink: #F5C46B;
    --focus: #8DB4F5;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 18px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); flex: none; }
.brand img { width: 30px; height: 30px; }
.brand b { font-size: 20px; letter-spacing: .3px; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--brand); background: var(--tint); }
.who { display: flex; align-items: center; gap: 10px; flex: none; font-size: 13px; color: var(--muted); }
.who .name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.voted { color: var(--brand); border-color: var(--brand); background: var(--tint); }

label { font-weight: 600; font-size: 14px; display: block; margin-bottom: 6px; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }
/* 16px keeps iPhones from zooming in when a field is tapped. */
input[type="text"], input[type="email"], input[type="date"], input[type="search"], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
}
textarea { resize: vertical; min-height: 96px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.check { display: flex; gap: 9px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; }

/* ---------- Layout pieces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 20px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; }
.stack > * + * { margin-top: 20px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.section-head a { font-size: 13px; font-weight: 600; text-decoration: none; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.notice { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 10px 14px; font-size: 14px; }
.error-text { color: var(--danger); font-size: 14px; }
.ok-text { color: var(--ok); font-size: 14px; }

/* ---------- Dashboard ---------- */
.hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.hero h1 { font-size: 28px; }
.hero p { margin: 4px 0 0; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile { padding: 16px 18px; }
.tile .label { font-size: 13px; color: var(--muted); }
.tile .value { font-size: 30px; font-weight: 650; line-height: 1.15; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .value.text { font-size: 20px; padding-top: 6px; white-space: normal; overflow-wrap: break-word; hyphens: auto; }
.tile .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.featured { padding: 22px 24px; border-left: 4px solid var(--ember); margin-bottom: 20px; }
.featured .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--ember); }
.featured h2 { font-size: 20px; margin: 6px 0 8px; }
.featured h2 a { color: var(--ink); text-decoration: none; }
.featured h2 a:hover { text-decoration: underline; }
.featured p { color: var(--ink); margin-bottom: 8px; }

/* Lessons by category: one series, so one hue and no legend; the count sits at each bar's tip. */
.bars { list-style: none; margin: 0; padding: 0; }
.bars a { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; align-items: center; gap: 12px; padding: 5px 6px; border-radius: 6px; text-decoration: none; color: var(--ink); }
.bars a:hover, .bars a:focus-visible { background: var(--surface-2); }
.bars .cat { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bars .bar { height: 14px; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 3px; flex: none; }
.bars a:hover .bar { background: var(--brand-hover); }
.bars .n { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li + li { border-top: 1px solid var(--line); }
.mini-list a { display: block; padding: 10px 2px; text-decoration: none; color: var(--ink); }
.mini-list a:hover .t { text-decoration: underline; }
.mini-list .t { font-weight: 600; }
.mini-list .m { font-size: 13px; color: var(--muted); }

/* ---------- Library ---------- */
.filters { display: grid; grid-template-columns: minmax(200px, 2fr) repeat(3, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 4px 11px; font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.chip .c { opacity: .7; margin-left: 3px; }
.result-count { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.lesson-card { display: flex; flex-direction: column; padding: 16px 18px; gap: 8px; text-decoration: none; color: var(--ink); }
.lesson-card h3 { font-size: 16px; }
.lesson-card h3 a { color: var(--ink); text-decoration: none; }
.lesson-card { cursor: pointer; }
.lesson-card h3 a:focus-visible { color: var(--brand); text-decoration: underline; }
@media (hover: hover) {
  .lesson-card:hover { border-color: var(--brand); }
  .lesson-card:hover h3 a { color: var(--brand); text-decoration: underline; }
}
.lesson-card .body { color: var(--ink); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; color: var(--muted); align-items: center; }
.meta .sep::before { content: "·"; margin-right: 12px; }
.tag-cat { display: inline-block; font-size: 12px; font-weight: 600; color: var(--brand); background: var(--tint); border-radius: 999px; padding: 2px 9px; }
.tag-impact { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.tag-impact i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--muted); }
.tag-impact.high i { background: var(--danger); }
.tag-impact.medium i { background: var(--ember); }
.tag-impact.low i { background: var(--ok); }
.tag-hidden { font-size: 12px; font-weight: 700; color: var(--danger); }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 6px; }

/* ---------- Lesson detail ---------- */
.detail { max-width: 820px; }
.detail .card { padding: 26px 28px; }
.detail h1 { font-size: 26px; margin: 10px 0 10px; }
.detail .block { margin-top: 22px; }
.detail .block h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 6px; }
.detail .block p { white-space: pre-wrap; margin: 0; font-size: 16px; }
.detail .lesson-text { border-left: 4px solid var(--ember); padding: 4px 0 4px 14px; }
.detail .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tags span { font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; color: var(--muted); }

/* ---------- Form ---------- */
.form { max-width: 760px; }
.form .card { padding: 24px 26px; }
.field { margin-bottom: 18px; }
.row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.impact-pick { display: flex; gap: 6px; }
.impact-pick label { flex: 1; margin: 0; }
.impact-pick input { position: absolute; opacity: 0; pointer-events: none; }
.impact-pick span { display: block; text-align: center; padding: 8px 6px; border: 1px solid var(--line); border-radius: 8px; font-weight: 600; cursor: pointer; background: var(--surface); }
.impact-pick input:checked + span { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.impact-pick input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.form-foot { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Cheat sheet ---------- */
.sheet { columns: 2 380px; column-gap: 28px; }
.sheet section { break-inside: avoid-column; margin-bottom: 22px; }
.sheet h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .6px; color: var(--brand); border-bottom: 2px solid var(--brand); padding-bottom: 4px; margin-bottom: 8px; }
.sheet ul { margin: 0; padding-left: 18px; }
.sheet li { margin: 0 0 7px; font-size: 14px; break-inside: avoid; }
.sheet li b { font-weight: 650; }
.sheet li a { color: inherit; text-decoration: none; }
.sheet li a:hover b { text-decoration: underline; }
.sheet .stars { color: var(--ember); font-size: 12px; white-space: nowrap; }
.print-head { display: none; }
.sheet-controls { display: flex; gap: 10px; align-items: center; }
.sheet-controls select { width: auto; min-width: 210px; }

/* ---------- Admin ---------- */
.table-wrap { overflow-x: auto; position: relative; } /* relative: keeps .sr-only headers inside the scroll area */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; white-space: nowrap; }
td { white-space: nowrap; }
td:first-child { white-space: normal; min-width: 140px; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.inactive td { color: var(--muted); }
.role { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 8px; background: var(--tint); color: var(--brand); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.link-row td { white-space: normal; }
.link-box { display: flex; gap: 8px; margin-top: 8px; }
.link-box input { font-size: 12px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: calc(100vw - 32px); }

/* ---------- Sign-in pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 420px; padding: 32px 30px; }
.auth .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth .logo img { width: 40px; height: 40px; }
.auth .logo b { font-size: 26px; display: block; line-height: 1.1; }
.auth .logo span { font-size: 13px; color: var(--muted); }
.auth h1 { font-size: 20px; margin-bottom: 6px; }
.auth p { color: var(--muted); }
.auth form { margin-top: 18px; }
.auth .btn { width: 100%; margin-top: 12px; padding: 11px 14px; }
.auth .msg { margin-top: 14px; }
.dev-link { word-break: break-all; font-size: 13px; margin-top: 10px; }

/* ---------- Small screens ---------- */
@media (max-width: 1000px) {
  .topbar-inner { flex-wrap: wrap; gap: 4px 12px; padding-top: 8px; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -6px; padding-bottom: 6px; }
  .who { margin-left: auto; }
}
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .search { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .topbar { position: static; } /* the two-row header would cover too much of a phone screen */
  .sheet-controls { width: 100%; flex-direction: column; align-items: stretch; }
  .sheet-controls select { width: 100%; }
  .nav { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); padding-right: 24px; }
  .nav a { padding: 8px 10px; }
  .who .name { display: none; }
  main { padding-top: 18px; }
  h1, .hero h1, .detail h1 { font-size: 23px; }
  .row-3, .row-2 { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .card.pad, .featured { padding: 16px; }
  .tiles { gap: 10px; }
  .tile { padding: 14px; }
  .tile .value { font-size: 28px; }
  .tile .value.text { font-size: 16px; }
  .detail .card, .form .card { padding: 20px 16px; }
  .detail .block p { font-size: 15px; }
  .hero { gap: 14px; }
  .hero .btn, .page-head .btn.primary { width: 100%; }
  .page-head { gap: 12px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 14px; padding: 0 16px 2px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .bars a { grid-template-columns: minmax(96px, 40%) 1fr; }
  .bars .cat { white-space: normal; line-height: 1.25; }
  .detail .actions .btn { flex: 1 1 auto; }
  .form-foot .btn { flex: 1 1 auto; }

  /* People: each person becomes a small card instead of a wide table row. */
  .people-table thead { display: none; }
  .people-table, .people-table tbody, .people-table tr, .people-table td { display: block; width: 100%; }
  .people-table tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .people-table tr:last-child { border-bottom: 0; }
  .people-table td { border: 0; padding: 2px 0; white-space: normal; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .people-table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; }
  .people-table td:first-child { font-weight: 650; font-size: 16px; text-align: left; justify-content: flex-start; gap: 6px; align-items: baseline; }
  .people-table td.email { color: var(--muted); font-size: 14px; word-break: break-all; text-align: left; }
  .people-table td.actions { display: block; }
  .people-table .row-actions { justify-content: flex-start; flex-wrap: wrap; margin-top: 8px; }
  .people-table .link-row td { display: block; text-align: left; }
  .people-table .link-box { flex-wrap: wrap; }
}

/* Touch screens: every tap target at least ~40px tall. */
@media (max-width: 640px), (pointer: coarse) {
  .nav a { min-height: 44px; display: inline-flex; align-items: center; }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 40px; padding: 8px 12px; font-size: 14px; }
  .chip { min-height: 40px; padding: 8px 14px; font-size: 14px; }
  .bars a { min-height: 40px; }
  .check { padding: 6px 0; }
  .check input { width: 20px; height: 20px; margin-top: 1px; flex: none; }
  .impact-pick span { padding: 11px 6px; }
  .back { display: inline-block; padding: 10px 0; }
  .link-box input { font-size: 16px; }
}

/* ---------- Print (the cheat sheet) ---------- */
@media print {
  :root { --ink: #000; --muted: #444; --brand: #0F3368; --ember: #9A520F; --bg: #fff; --surface: #fff; --line: #ccc; }
  body { background: #fff; font-size: 11px; }
  .topbar, .no-print, .toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .print-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #0F3368; padding-bottom: 6px; margin-bottom: 12px; }
  .print-head b { font-size: 16px; }
  .sheet { columns: 2; column-gap: 20px; }
  .sheet h2 { font-size: 12px; }
  .sheet li { font-size: 10.5px; margin-bottom: 4px; }
  a { color: inherit; text-decoration: none; }
}
