/* Shared styles for templates.html and glossary.html */
:root {
  --blue: #007BFF;
  --blue-dark: #0056b3;
  --blue-light: #4dabff;
  --blue-soft: #e8f2ff;
  --ink: #1f2a36;
  --muted: #5b6876;
  --line: #d6dee8;
  --bg: #f4f7fa;
  --card: #ffffff;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.6; }
a { color: var(--blue-dark); }
:focus-visible { outline: 3px solid #7fb2ec; outline-offset: 2px; }

/* Header */
.site-header { background: var(--blue); color: #fff; }
.site-header .inner { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.site-header .brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15em; }
.site-header .brand img { width: 30px; height: 30px; }
.site-header nav { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.site-header nav a { color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 6px; font-size: 0.95em; }
.site-header nav a:hover, .site-header nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.18); }

/* Page hero */
.page-hero { background: linear-gradient(120deg, #031a3a 0%, #06305f 60%, #0a4a86 100%); color: #fff; }
.page-hero .inner { max-width: 1100px; margin: 0 auto; padding: 36px 16px 32px; }
.page-hero .eyebrow { margin: 0 0 6px; font-size: 0.8em; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(255, 255, 255, 0.78); }
.page-hero h1 { margin: 0 0 10px; font-size: 2.2em; line-height: 1.15; }
.page-hero h1 span { color: var(--blue-light); }
.page-hero p { margin: 0; max-width: 720px; color: rgba(255, 255, 255, 0.88); font-size: 1.05em; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }

/* Buttons */
.btn, .btn-secondary { display: inline-block; border: 0; border-radius: 8px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center; }
.btn { background: var(--blue); color: #fff; }
.btn:hover { background: var(--blue-dark); }
.btn-secondary { background: var(--blue-soft); color: var(--blue-dark); }
.btn-secondary:hover { background: #d6e7fd; }

/* Tags */
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.tags li { font-size: 0.78em; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--blue-soft); color: var(--blue-dark); }

/* ---------- Templates list ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.tpl-card { display: flex; flex-direction: column; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; transition: box-shadow 0.15s, transform 0.15s; }
.tpl-card:hover { box-shadow: 0 8px 22px rgba(0, 60, 130, 0.14); transform: translateY(-2px); }
.tpl-card .icon { font-size: 1.8em; line-height: 1; }
.tpl-card h2 { margin: 10px 0 6px; font-size: 1.2em; color: var(--ink); }
.tpl-card p { margin: 0; color: var(--muted); flex: 1; }
.tpl-card .open { margin-top: 14px; font-weight: 700; color: var(--blue-dark); }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }

/* Chips (filters) */
.chip { border: 1px solid #b9c5d3; background: #fff; color: var(--ink); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 0.92em; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip .count { opacity: 0.7; font-size: 0.85em; margin-left: 4px; }

/* ---------- Template form ---------- */
.tpl-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.tpl-toolbar .grow { flex: 1; }
.save-note { color: var(--muted); font-size: 0.88em; }
.tpl-form h2 { margin: 0 0 4px; font-size: 1.6em; }
.tpl-form .intro { color: var(--muted); margin: 0 0 8px; }
.tpl-form h3 { margin: 26px 0 8px; color: var(--blue-dark); font-size: 1.12em; border-bottom: 2px solid var(--blue-soft); padding-bottom: 4px; }
.tpl-form .hint { color: var(--muted); font-size: 0.9em; margin: -2px 0 6px; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 0.95em; }
.field { margin-bottom: 12px; }
input[type=text], input[type=date], input[type=search], textarea, select {
  width: 100%; font: inherit; color: inherit; background: #fff; border: 1px solid #b9c5d3; border-radius: 6px; padding: 8px 10px;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15); }
.table-wrap { overflow-x: auto; margin-bottom: 8px; }
table.tpl-table { width: 100%; border-collapse: collapse; min-width: 520px; }
table.tpl-table th { background: var(--blue-soft); text-align: left; padding: 8px; font-size: 0.9em; }
table.tpl-table td { padding: 4px; border-bottom: 1px solid #edf1f5; vertical-align: top; }
table.tpl-table td input, table.tpl-table td select, table.tpl-table td textarea { padding: 6px 8px; }
table.tpl-table td.rowhead { font-weight: 600; padding: 8px; min-width: 120px; }
.raci-legend { font-size: 0.88em; color: var(--muted); margin: 0 0 8px; }
.raci-legend strong { color: var(--ink); }
.prompt-box { background: #fff8e6; border: 1px solid #ffe2a8; border-radius: 8px; padding: 10px 14px; margin: 8px 0; font-style: italic; }

/* ---------- Glossary ---------- */
.gl-controls { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 0 10px; margin-bottom: 8px; }
.gl-search { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.gl-search input { font-size: 1.05em; padding: 11px 14px; }
.gl-status { color: var(--muted); font-size: 0.92em; margin: 4px 0 12px; }
.gl-section { margin-bottom: 26px; }
.gl-section > h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 4px; font-size: 1.35em; color: var(--ink); }
.gl-section > .desc { color: var(--muted); margin: 0 0 12px; }
.gl-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; align-items: start; }
.term { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--blue-light); border-radius: 10px; padding: 12px 16px; }
.term h3 { margin: 0; font-size: 1.05em; }
.term .stands { color: var(--blue-dark); font-weight: 600; font-size: 0.9em; margin: 2px 0 0; }
.term .def { margin: 6px 0 0; }
.term .ex { margin: 6px 0 0; color: var(--muted); font-size: 0.92em; font-style: italic; }
mark { background: #fff1a8; padding: 0 1px; border-radius: 2px; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }

.back-top { display: inline-block; margin-top: 8px; }

@media (max-width: 640px) {
  .page-hero h1 { font-size: 1.7em; }
  .site-header nav { margin-left: 0; width: 100%; }
  .tpl-grid, .gl-list { grid-template-columns: minmax(0, 1fr); }
  .tpl-toolbar .btn, .tpl-toolbar .btn-secondary { flex: 1 1 auto; }
  .card { padding: 16px; }
  /* Glossary on phones: one swipeable row of section filters */
  .gl-controls { padding: 10px 0 8px; }
  .gl-controls .filter-row { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 6px; scrollbar-width: none; }
  .gl-controls .filter-row::-webkit-scrollbar { display: none; }
  .gl-controls .chip { flex: 0 0 auto; white-space: nowrap; }
  .page-hero .inner { padding: 26px 16px 22px; }
  .page-hero .eyebrow { letter-spacing: 0.1em; }
}

@media print {
  .site-header, .page-hero, .tpl-toolbar, .no-print, .gl-controls { display: none !important; }
  body { background: #fff; }
  .wrap { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; }
  input, textarea, select { border: 1px solid #999; }
  table.tpl-table { min-width: 0; }
}

.tpl-form > .tags { margin-bottom: 16px; }

/* SWOT grid */
.swot-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin: 10px 0 8px; }
.swot-box { border-radius: 10px; padding: 12px 14px; border: 1px solid var(--line); }
.swot-box label { display: block; font-weight: 700; font-size: 1.1em; }
.swot-box label small { font-weight: 600; font-size: 0.72em; color: var(--muted); margin-left: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.swot-letter { display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; border-radius: 8px; color: #fff; margin-right: 8px; font-size: 0.95em; }
.swot-s { background: #eaf7ee; } .swot-s .swot-letter { background: #2e8b57; }
.swot-w { background: #fdf0ec; } .swot-w .swot-letter { background: #c0502e; }
.swot-o { background: #e8f2ff; } .swot-o .swot-letter { background: #007BFF; }
.swot-t { background: #fff6e0; } .swot-t .swot-letter { background: #c98a00; }
.swot-box textarea { background: rgba(255, 255, 255, 0.85); }

/* Accountability chart seats */
.seat-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin: 10px 0; }
.seat { border: 1px solid var(--line); border-top: 4px solid var(--blue); border-radius: 10px; padding: 8px 14px 4px; margin: 0; background: #fbfdff; min-width: 0; }
.seat legend { font-weight: 700; color: var(--blue-dark); padding: 0 6px; font-size: 1.05em; }
.seat .seat-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 10px; }
.seat textarea { min-height: 52px; }

@media (max-width: 700px) {
  .swot-grid, .seat-grid { grid-template-columns: minmax(0, 1fr); }
}
@media print {
  .swot-grid, .seat-grid { gap: 8px; }
  .seat, .swot-box { break-inside: avoid; }
}
