/* ============================================================
   HamCert.ca — Base Stylesheet
   Provides global resets, typography, and base layout.
   Page-specific styles live in each template's <style> block.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=IBM+Plex+Sans:wght@300;400;500;600&display=swap');

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  --bg:           #0f1117;
  --surface:      #181c26;
  --surface-2:    #1e2435;
  --border:       #2a3145;
  --accent:       #3b82f6;
  --accent-dim:   rgba(59, 130, 246, 0.12);
  --green:        #22c55e;
  --green-dim:    rgba(34, 197, 94, 0.12);
  --red:          #ef4444;
  --red-dim:      rgba(239, 68, 68, 0.10);
  --amber:        #f59e0b;
  --amber-dim:    rgba(245, 158, 11, 0.12);
  --text:         #e2e8f0;
  --text-muted:   #64748b;
  --mono:         'IBM Plex Mono', monospace;
  --sans:         'IBM Plex Sans', sans-serif;
  --radius:       8px;
  --radius-lg:    12px;
  /* Semantic tokens */
  --btn-text:     #0f1117;   /* text on solid green/accent buttons */
  --overlay:      rgba(0, 0, 0, 0.6);
  --overlay-deep: rgba(0, 0, 0, 0.4);
  --shadow-sm:    0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-lg:    0 24px 64px rgba(0, 0, 0, 0.4);
}

/* ── Light theme ──────────────────────────────────────────── */
[data-theme="light"] {
  --bg:           #f8fafc;
  --surface:      #ffffff;
  --surface-2:    #f1f5f9;
  --border:       #e2e8f0;
  --accent:       #2563eb;
  --accent-dim:   rgba(37, 99, 235, 0.10);
  --green:        #16a34a;
  --green-dim:    rgba(22, 163, 74, 0.10);
  --red:          #dc2626;
  --red-dim:      rgba(220, 38, 38, 0.08);
  --amber:        #d97706;
  --amber-dim:    rgba(217, 119, 6, 0.10);
  --text:         #0f172a;
  --text-muted:   #64748b;
  /* Semantic tokens */
  --btn-text:     #ffffff;
  --overlay:      rgba(0, 0, 0, 0.4);
  --overlay-deep: rgba(0, 0, 0, 0.15);
  --shadow-sm:    0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg:    0 24px 64px rgba(0, 0, 0, 0.15);
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

/* ── Font size scale ──────────────────────────────────────── */
html[data-fontsize="normal"]  { font-size: 16px; }
html[data-fontsize="large"]   { font-size: 19px; }
html[data-fontsize="xlarge"]  { font-size: 22px; }

/* ── Base ─────────────────────────────────────────────────── */
body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Typography ───────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--sans);
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
}

h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }

p {
  color: var(--text);
  line-height: 1.7;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.15s;
}

a:hover { opacity: 0.8; }

code, pre, kbd {
  font-family: var(--mono);
  font-size: 0.875em;
}

pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  color: var(--text);
}

/* ── Layout helpers ───────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.page-wrap {
  padding: 2.5rem 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

/* ── Base header (used when no sidebar layout is active) ──── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  font-family: var(--sans);
}

header h1::before {
  content: '// ';
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.85rem;
}

main {
  min-height: calc(100vh - 56px);
}

/* ── Forms (base — login and simple pages) ────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="tel"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
  font-family: var(--sans);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

/* ── Buttons (base) ───────────────────────────────────────── */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--sans);
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
}

button:hover,
.btn:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

button:active,
.btn:active {
  transform: translateY(0);
}

.btn-primary  { background: var(--accent); color: var(--btn-text); }
.btn-success  { background: var(--green);  color: var(--btn-text); }
.btn-danger   { background: var(--red-dim); color: var(--red);
                border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-ghost    { background: var(--surface-2); color: var(--text-muted);
                border: 1px solid var(--border); }
.btn-accent   { background: var(--accent); color: #fff; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-green  { background: var(--green-dim);  color: var(--green); }
.badge-blue   { background: var(--accent-dim); color: var(--accent); }
.badge-amber  { background: var(--amber-dim);  color: var(--amber); }
.badge-red    { background: var(--red-dim);    color: var(--red); }
.badge-muted  { background: var(--surface-2);  color: var(--text-muted);
                border: 1px solid var(--border); }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

/* ── Tables ───────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: 0.75rem 1.5rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover      { background: var(--surface-2); }

tbody td {
  padding: 0.85rem 1.5rem;
  font-size: 0.875rem;
  color: var(--text);
}

.mono-cell {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.empty-row td {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 2rem;
  font-family: var(--mono);
}

/* ── Flash / Alert messages ───────────────────────────────── */
.alert,
.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  line-height: 1.5;
}

.alert-error,
.flash-error {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.alert-success,
.flash-success {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.alert-info {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.alert-warning {
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* ── Dividers ─────────────────────────────────────────────── */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Selection ────────────────────────────────────────────── */
::selection {
  background: var(--accent-dim);
  color: var(--text);
}

/* ── Utility classes ──────────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-accent  { color: var(--accent); }
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-amber   { color: var(--amber); }
.text-mono    { font-family: var(--mono); }
.text-sm      { font-size: 0.875rem; }
.text-xs      { font-size: 0.75rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

.flex         { display: flex; }
.items-center { align-items: center; }
.gap-2        { gap: 0.5rem; }
.gap-3        { gap: 0.75rem; }
.gap-4        { gap: 1rem; }
.justify-end  { justify-content: flex-end; }
.w-full       { width: 100%; }

/* ── Sidebar shell layout ─────────────────────────────────────────────
   Used by all authenticated dashboard pages (examiner, admin, etc.).
   Child templates opt in by filling {% block sidebar_nav %}.
   ──────────────────────────────────────────────────────────────────── */

.shell {
  display: flex;
  align-items: flex-start;    /* required — stretch breaks position:sticky */
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 2rem 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 0 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.sidebar-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--sidebar-accent, var(--accent));
  display: block;
  margin-bottom: 0.3rem;
}

.sidebar-brand h1 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

/* ── Logo lockup ───────────────────────────────────────────────── */
.sidebar-lockup {
  margin-bottom: 0.1rem;
}

.sidebar-lockup-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.sidebar-lockup-link:hover { opacity: 0.88; }

.sidebar-lockup-leaf {
  height: 44px;
  width: auto;
  flex-shrink: 0;
}

.sidebar-lockup-wordmark {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar-lockup-name {
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.sidebar-lockup-tld {
  font-weight: 400;
  color: #c8102e;
}

.sidebar-lockup-tag {
  font-family: var(--mono);
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.sidebar-user {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.sidebar-user-name {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 0.3rem;
}

.sidebar-user-links {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.sidebar-user-links a {
  font-size: 0.68rem;
  font-family: var(--mono);
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  opacity: 0.85;
}

.sidebar-user-links a:hover { opacity: 1; }

.sidebar-user-sep {
  font-size: 0.65rem;
  color: var(--border);
}

.sidebar-signout {
  color: var(--text-muted) !important;
}

.sidebar-signout:hover {
  color: var(--red) !important;
}

.sidebar-nav {
  list-style: none;
  flex: 1;
  padding: 0 0.75rem;
  overflow-y: auto;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
  background: var(--sidebar-accent-dim, var(--accent-dim));
  color: var(--sidebar-accent, var(--accent));
  opacity: 1;
}

.sidebar-nav li a .icon { font-size: 1rem; }

.sidebar-donation {
  margin-top: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  list-style: none;
}

.sidebar-donation-text {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 0.4rem;
}

.sidebar-donation-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.sidebar-donation-links a {
  font-size: 0.68rem;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  opacity: 0.85;
}

.sidebar-donation-links a:hover { opacity: 1; }

.sidebar-footer {
  margin-top: auto;           /* pins accessibility controls to sidebar bottom */
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.shell-main {
  flex: 1;
  min-width: 0;               /* prevents flex blowout on wide content */
  padding: 2.5rem;
}

/* ── Theme toggle button ──────────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-family: var(--mono);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  margin-top: 0.5rem;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  opacity: 1;
  transform: none;
}

/* ── Font size toggle ─────────────────────────────────────── */
.font-size-toggle {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.4rem;
}

.font-size-btn {
  flex: 1;
  padding: 0.25rem 0.3rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--sans);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  line-height: 1;
}

.font-size-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  opacity: 1;
  transform: none;
}

.font-size-btn.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}
