/* ===========================================================================
   Blind Productions — accessible design system.
   Inherits the palette, type, and focus patterns from Tony's book site, then
   extends it with site components (nav, forms, flash, cards, tables, media).
   =========================================================================== */

:root {
  --bg: #0e1320;
  --surface: #161d2e;
  --surface-2: #1b2335;
  --text: #f4f6fb;
  --muted: #c2cbde;
  --accent: #f2b84b;
  --accent-bright: #ffca5f;
  --accent-ink: #0e1320;
  --border: #2c3650;
  --blue: #3a7bff;
  --danger: #ff6b6b;
  --danger-ink: #2a0d0d;
  --ok: #6ad48a;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, -apple-system, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 12px;
  --maxw: 70rem;
}

/* Light palette tokens, reused for auto (OS prefers light) and forced light. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f8fc;
    --surface: #ffffff;
    --surface-2: #eef2f9;
    --text: #131722;
    --muted: #41506a;
    --accent: #9a5b0a;
    --accent-bright: #b8791a;
    --accent-ink: #ffffff;
    --border: #d6deec;
    --blue: #1f5fe0;
    --danger: #b42318;
    --danger-ink: #ffffff;
    --ok: #1c7d3f;
  }
}
:root[data-theme="light"] {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #eef2f9;
  --text: #131722;
  --muted: #41506a;
  --accent: #9a5b0a;
  --accent-bright: #b8791a;
  --accent-ink: #ffffff;
  --border: #d6deec;
  --blue: #1f5fe0;
  --danger: #b42318;
  --danger-ink: #ffffff;
  --ok: #1c7d3f;
}

/* User text-size preference — scales every rem-based size on the page. */
:root[data-text-size="large"] { font-size: 112.5%; }
:root[data-text-size="larger"] { font-size: 131.25%; }

/* User high-contrast preference. */
:root[data-contrast="more"] { --muted: var(--text); }
:root[data-contrast="more"] .panel,
:root[data-contrast="more"] .field input,
:root[data-contrast="more"] .field textarea,
:root[data-contrast="more"] .field select,
:root[data-contrast="more"] .a11y-field select,
:root[data-contrast="more"] .a11y-bar button { border-color: var(--text); }
:root[data-contrast="more"] a { text-decoration: underline; }

/* User reduced-motion preference (in addition to the OS setting). */
:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 1.2rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 1.5rem; }
.narrow { max-width: 52rem; }

/* ---- Skip link & focus ---- */
.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--accent);
  color: var(--accent-ink); padding: 0.85rem 1.25rem; font-weight: 700;
  border-radius: 0 0 8px 0; z-index: 100;
}
.skip-link:focus { left: 0; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* visually hidden but available to screen readers */
.sr-only {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---- Header / nav ---- */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem 1.5rem; padding: 1rem 1.5rem; flex-wrap: wrap;
}
.brand {
  font-family: var(--display); font-weight: 800; font-size: 1.3rem;
  letter-spacing: 0.01em; color: var(--text); text-decoration: none;
}
.brand:hover { color: var(--accent); }
.site-nav ul {
  list-style: none; display: flex; flex-wrap: wrap; gap: 0.35rem 0.5rem;
  margin: 0; padding: 0; align-items: center;
}
.site-nav a {
  display: inline-block; color: var(--text); text-decoration: none;
  font-weight: 600; font-size: 1.05rem; padding: 0.5rem 0.85rem; border-radius: 8px;
}
.site-nav a:hover { background: var(--surface-2); color: var(--accent); }
.site-nav a[aria-current="page"] {
  color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent);
}
.nav-logout { display: inline; margin: 0; }
.nav-logout button {
  font: inherit; font-weight: 600; font-size: 1.05rem; cursor: pointer;
  color: var(--text); background: none; border: none; padding: 0.5rem 0.85rem;
  border-radius: 8px;
}
.nav-logout button:hover { background: var(--surface-2); color: var(--accent); }

/* ---- Notification bell badge ---- */
.nav-notifications { white-space: nowrap; }
.notif-badge {
  display: inline-block; min-width: 1.4em; padding: 0 0.4em;
  margin-left: 0.15em; font-size: 0.85rem; font-weight: 800; line-height: 1.4em;
  text-align: center; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
}

/* ---- Notifications list page ---- */
.notif-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.notif-toolbar p { margin: 0; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-item {
  padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); margin-bottom: 0.75rem;
}
.notif-item.notif-unread { border-left: 4px solid var(--accent); background: var(--surface-2); }
.notif-link {
  display: block; font-weight: 600; font-size: 1.1rem; color: var(--text);
  text-decoration: none;
}
a.notif-link:hover { color: var(--accent); text-decoration: underline; }
.notif-meta {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  margin: 0.4rem 0 0; font-size: 0.95rem;
}
.notif-tag {
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 0.1rem 0.5rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.notif-new {
  font-size: 0.8rem; font-weight: 800; color: var(--accent-ink);
  background: var(--accent); padding: 0.1rem 0.5rem; border-radius: 999px;
}
.pagination { display: flex; gap: 1rem; align-items: center; margin-top: 1.25rem; }

/* ---- Main / footer layout ---- */
main { display: block; flex: 1 0 auto; }
.section { padding: clamp(2rem, 5vw, 3.5rem) 0; }
.section + .section { border-top: 1px solid var(--border); }

.site-footer {
  border-top: 1px solid var(--border); padding: 2.5rem 0 3rem;
  color: var(--muted); font-size: 1rem; flex-shrink: 0;
}
.site-footer .wrap { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.site-footer a { color: var(--accent); }
.footer-nav { flex-basis: 100%; }
.footer-nav ul {
  list-style: none; margin: 0 0 0.5rem; padding: 0;
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem;
}
.footer-nav a { font-weight: 600; }

/* ---- Headings & prose ---- */
h1 {
  font-family: var(--display); font-weight: 800;
  font-size: clamp(2.2rem, 6vw, 3.6rem); line-height: 1.02;
  letter-spacing: -0.02em; margin: 0 0 1rem;
}
h2 {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.5rem, 3.5vw, 2.1rem); line-height: 1.1;
  letter-spacing: -0.01em; margin: 2rem 0 1rem;
}
h3 { font-family: var(--display); font-weight: 700; font-size: 1.3rem; margin: 1.5rem 0 0.5rem; }
p { margin: 0 0 1.1rem; }
.lead { font-size: clamp(1.25rem, 2.5vw, 1.5rem); color: var(--text); max-width: 46ch; }
.prose { max-width: 65ch; }
.prose a { color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.prose a:hover { color: var(--accent-bright); }
.muted { color: var(--muted); }
.eyebrow {
  font-family: var(--display); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.2em; font-size: 0.9rem; color: var(--accent); margin: 0 0 1rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-block; font-family: var(--display); font-weight: 700;
  font-size: 1.05rem; padding: 0.75rem 1.4rem; border-radius: 10px;
  cursor: pointer; text-decoration: none; border: 2px solid var(--accent);
  background: var(--accent); color: var(--accent-ink);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--accent-bright); border-color: var(--accent-bright); }
.btn-secondary {
  background: transparent; color: var(--text); border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.85rem; margin-top: 1.5rem; align-items: center; }

/* ---- Cards & panels ---- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: clamp(1.5rem, 4vw, 2.5rem);
}
.card-grid {
  display: grid; gap: 1.25rem; margin: 1.5rem 0 0;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  padding: 0; list-style: none;
}

/* ---- News / updates list (home page) ---- */
.news-list {
  list-style: none; margin: 1.5rem 0 0; padding: 0;
  display: grid; gap: 1.25rem;
}
.news-item .news-title { margin-top: 0; }
.news-date {
  margin: 0.15rem 0 0.75rem; color: var(--muted);
  font-size: 0.95rem; font-weight: 600;
}
.news-body p { margin: 0 0 0.75rem; }
.news-body p:last-child { margin-bottom: 0; }
.news-share {
  display: flex; flex-wrap: wrap; gap: 0.85rem; align-items: center;
  margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border);
}
.news-permalink {
  color: var(--muted); font-weight: 600; font-size: 0.95rem;
  text-decoration-thickness: 2px; text-underline-offset: 3px;
}
.news-permalink:hover { color: var(--accent); }
.btn-small { font-size: 0.95rem; padding: 0.4rem 0.9rem; }
.news-pager {
  display: flex; flex-wrap: wrap; gap: 0.85rem; align-items: center;
  margin-top: 1.5rem;
}
.news-pager-status { color: var(--muted); font-weight: 600; }

/* ---- Flash / messages ---- */
.flash-region { margin: 1.25rem 0 0; display: grid; gap: 0.75rem; }
.flash {
  font-size: 1.1rem; font-weight: 600; padding: 0.95rem 1.15rem;
  border-radius: 10px; border: 2px solid var(--border);
  background: var(--surface-2); color: var(--text);
}
.flash.success { border-color: var(--ok); }
.flash.error { border-color: var(--danger); }
.flash.warning { border-color: var(--accent); }

/* ---- Forms ---- */
.form { max-width: 34rem; margin: 1.5rem 0 0; }
.form.wide { max-width: 48rem; }
.field { margin: 0 0 1.4rem; }
.field > label,
.field-label {
  display: block; font-weight: 700; margin: 0 0 0.4rem; font-size: 1.05rem;
}
.field .req-mark { color: var(--accent); }
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="url"],
.field input[type="file"],
.field textarea,
.field select,
input.form-control,
textarea.form-control {
  width: 100%; font: inherit; font-size: 1.1rem; padding: 0.8rem 0.95rem;
  color: var(--text); background: var(--surface-2);
  border: 2px solid var(--border); border-radius: 10px;
}
.field textarea { min-height: 9rem; line-height: 1.6; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); }
.field input[aria-invalid="true"],
.field textarea[aria-invalid="true"],
.field select[aria-invalid="true"] { border-color: var(--danger); }
.field-help { font-size: 1rem; color: var(--muted); margin: 0.5rem 0 0; }
.field-errors { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.field-errors li { color: var(--danger); font-weight: 700; font-size: 1.02rem; }
.form-error-summary {
  border: 2px solid var(--danger); border-radius: 10px; padding: 1rem 1.15rem;
  margin: 0 0 1.5rem; background: var(--surface-2);
}
.form-error-summary h2 { margin: 0 0 0.5rem; font-size: 1.2rem; }
.form-error-summary ul { margin: 0; padding-left: 1.2rem; }
.form-error-summary a { color: var(--danger); font-weight: 700; }

/* ---- Tables ---- */
.data-table { width: 100%; border-collapse: collapse; margin: 1.5rem 0 0; }
.data-table caption { text-align: left; font-weight: 700; margin-bottom: 0.75rem; }
.data-table th, .data-table td {
  text-align: left; padding: 0.75rem 0.9rem; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table th[scope="col"] { font-family: var(--display); }
.data-table tr:hover td { background: var(--surface-2); }
.table-scroll { overflow-x: auto; }

/* ---- Guidelines disclosure (forum + submit) ---- */
.guidelines { margin: 0 0 1.5rem; padding: 1rem 1.25rem; }
.guidelines > summary { cursor: pointer; font-size: 1.1rem; padding: 0.25rem 0; }
.guidelines > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.guidelines-body { margin-top: 0.75rem; }
.guidelines-body ul { margin: 0.5rem 0; padding-left: 1.5rem; }
.guidelines-body li { margin: 0.4rem 0; }

/* Grouped optional fields on a form */
.field-group {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 1rem 1.25rem 0.5rem; margin: 0 0 1.25rem;
}
.field-group > legend { font-weight: 700; padding: 0 0.4rem; }

/* ---- Admin dashboard ---- */
.dash-links { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.25rem 0 2rem; }
.stat-grid {
  list-style: none; margin: 0.75rem 0 2rem; padding: 0;
  display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 1rem; display: flex; flex-direction: column; gap: 0.25rem;
}
.stat-num { font-family: var(--display); font-weight: 800; font-size: 2rem; line-height: 1; color: var(--accent); }
.stat-label { font-size: 0.95rem; color: var(--muted); }
.dash-info {
  display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.25rem;
  margin: 0.75rem 0 2rem;
}
.dash-info dt { font-weight: 700; }
.dash-info dd { margin: 0; }
.dash-list { margin: 0.5rem 0 2rem; padding-left: 1.25rem; }
.dash-list li { margin: 0.35rem 0; }
.dash-filters {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end;
  margin: 1rem 0 1.5rem;
}
.dash-filters .field { margin: 0; }
.action-grid { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.75rem 0 2rem; }
.action-grid form { margin: 0; }
.btn[disabled], .btn-secondary[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---- Media blocks (profiles) ---- */
.audio-block, .video-block { margin: 1.5rem 0; }
.audio-block audio { width: 100%; margin-top: 0.5rem; }
.video-frame {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  margin-top: 0.5rem;
}
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---- Tag / category chips ---- */
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; padding: 0; }
.chip {
  display: inline-block; font-size: 1rem; font-weight: 600; padding: 0.3rem 0.8rem;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Hero ---- */
.hero { padding: clamp(2.5rem, 7vw, 4.5rem) 0; }
.hero .lead { margin-top: 1.25rem; }
.hero-logo { display: block; width: 88px; height: 88px; margin: 0 0 1.25rem; }

/* ---- Accessibility toolbar (top of every page) ---- */
.a11y-bar { background: var(--surface-2); border-bottom: 1px solid var(--border); }
.a11y-bar-inner {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 1.25rem;
  padding: 0.45rem 1.5rem; font-size: 0.95rem;
}
.a11y-bar-label { font-family: var(--display); font-weight: 800; color: var(--muted); }
.a11y-field { display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 600; }
.a11y-field select {
  font: inherit; font-size: 0.95rem; padding: 0.3rem 0.5rem; color: var(--text);
  background: var(--surface); border: 2px solid var(--border); border-radius: 8px;
}
.a11y-textsize { display: inline-flex; align-items: center; gap: 0.3rem; }
.a11y-sublabel { font-weight: 600; }
.a11y-bar button {
  font: inherit; font-size: 0.95rem; font-weight: 700; cursor: pointer;
  color: var(--text); background: var(--surface); border: 2px solid var(--border);
  border-radius: 8px; padding: 0.35rem 0.7rem; line-height: 1;
}
.a11y-bar button:hover { border-color: var(--accent); color: var(--accent); }
.a11y-bar button[aria-pressed="true"] {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
.a11y-textsize button { min-width: 2.5rem; }

@media (prefers-contrast: more) {
  :root { --border: #6c7aa0; }
  .field input, .field textarea, .field select { border-width: 3px; }
}
