/* ============================================================
   Design tokens — all text/background and border/background pairs
   below are verified against WCAG AA (4.5:1 text, 3:1 UI components)
   in db/../design-notes; see contrast check run during development.
   ============================================================ */
:root {
  --navy-900: #142840;
  --navy-800: #1d3a5f;
  --navy-700: #2a4d78;
  --gold-700: #96591c;
  --gold-500: #c17f2a;

  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #52565c;
  --border-subtle: #dde1e8;   /* decorative dividers only */
  --border-ui: #8890a0;       /* form fields, card outlines — 3:1 verified */
  --error: #b3261e;
  --success: #1e7a34;
  --unread-bg: #eaf0f8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1.5;
  padding-bottom: 64px; /* room for mobile bottom nav */
}

.container {
  max-width: 900px;
  margin: 0;
  padding: 24px 32px;
}

/* ============================================================
   Top header (desktop) — brand banner + full nav
   ============================================================ */
.topbar {
  background: var(--navy-900);
  color: white;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 3px solid var(--gold-700);
}

.topbar .brand {
  color: white;
  font-weight: 400;
  text-decoration: none;
  font-size: 1.3rem;
  letter-spacing: 0.02em;
  font-family: 'Special Elite', monospace;
}

.topbar nav {
  display: flex;
  gap: 18px;
  align-items: center;
}

.topbar nav a, .topbar nav .link-button {
  color: white;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
}
.topbar nav a:hover, .topbar nav .link-button:hover { text-decoration: underline; }

/* Search box in nav */
.nav-search { flex: 1 1 160px; min-width: 100px; max-width: 240px; margin: 0 8px; }
.nav-search input {
  width: 100%;
  padding: 7px 12px;
  border-radius: 16px;
  border: 1px solid transparent;
  font-size: 0.9rem;
}

/* Notification bell */
.bell-link { position: relative; font-size: 1.15rem; }
.bell-badge {
  position: absolute;
  top: -7px;
  right: -11px;
  background: var(--gold-700);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
  border: 1.5px solid var(--navy-900);
}

/* ============================================================
   Mobile bottom nav — hidden on desktop, shown under 700px
   ============================================================ */
.bottom-nav {
  display: none;
}

@media (max-width: 700px) {
  .nav-dup-mobile { display: none; }
  .nav-search { display: none; }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--navy-900);
    border-top: 3px solid var(--gold-700);
    z-index: 20;
  }
  .bottom-nav a {
    flex: 1;
    text-align: center;
    padding: 8px 4px 6px;
    color: #cdd6e3;
    text-decoration: none;
    font-size: 0.68rem;
    font-weight: 600;
  }
  .bottom-nav a.active { color: white; }
  .bottom-nav .bottom-nav-icon { display: block; font-size: 1.25rem; margin-bottom: 2px; }
  .bottom-nav .bottom-nav-badge {
    position: absolute;
    margin-left: 4px;
    background: var(--gold-700);
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    border-radius: 8px;
    padding: 0 4px;
  }
}

/* ============================================================
   Cards & general layout
   ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(20,40,64,0.06);
}

.centered {
  max-width: 420px;
  margin: 48px auto;
  text-align: center;
}

h1 { font-size: 1.5rem; margin-top: 0; color: var(--navy-900); }
h2 { font-size: 1.15rem; color: var(--navy-900); }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ============================================================
   Forms
   ============================================================ */
label {
  display: block;
  font-weight: 600;
  margin: 12px 0 4px;
  font-size: 0.9rem;
}

input[type=text], input[type=email], input[type=tel], input[type=date], input[type=time],
input[type=file], select, textarea {
  width: 100%;
  padding: 10px;
  border: 1.5px solid var(--border-ui);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy-800);
  box-shadow: 0 0 0 3px rgba(29,58,95,0.18);
}

.inline-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.inline-fields input, .inline-fields select {
  width: auto;
  flex: 1 1 140px;
}

.stacked-form { max-width: 480px; margin-bottom: 24px; }

button, .button {
  background: var(--navy-800);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  margin-top: 12px;
}
button:hover, .button:hover { background: var(--navy-700); }
.button.secondary { background: var(--gold-700); }
.button.secondary:hover { background: var(--gold-500); }

.inline-form { display: inline; margin: 0; }
.link-button {
  background: none;
  border: none;
  color: var(--navy-800);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  margin: 0;
  font-size: inherit;
  font-weight: 600;
}

.error { color: var(--error); font-weight: 700; }
.success { color: var(--success); font-weight: 700; }
.muted { color: var(--muted); }
.empty-state { color: var(--muted); font-style: italic; }

/* ============================================================
   Avatars
   ============================================================ */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  object-fit: cover;
  vertical-align: middle;
}
.avatar.avatar-sm { width: 28px; height: 28px; font-size: 0.7rem; }
.avatar.avatar-lg { width: 48px; height: 48px; font-size: 1.1rem; }

/* ============================================================
   Thread list (board index / search) — card rows with avatar
   ============================================================ */
.thread-list { list-style: none; padding: 0; }
.thread-row {
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  box-shadow: 0 1px 3px rgba(20,40,64,0.05);
}
.thread-row-body { flex: 1; min-width: 0; }
.thread-title {
  font-weight: 700;
  color: var(--navy-800);
  text-decoration: none;
  font-size: 1.05rem;
  display: block;
}
.thread-title:hover { text-decoration: underline; }
.thread-meta { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.pin { margin-right: 4px; }

/* ============================================================
   Post list (thread view)
   ============================================================ */
.post-list { list-style: none; padding: 0; }
.post {
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(20,40,64,0.05);
}
.post-body-wrap { flex: 1; min-width: 0; }
.post-meta { color: var(--muted); font-size: 0.85rem; margin-bottom: 6px; }
.post-body { white-space: pre-wrap; }

/* ============================================================
   Tables
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  font-size: 0.9rem;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.data-table th { background: var(--navy-900); color: white; }
.captain-entry { margin-bottom: 8px; display: flex; gap: 8px; align-items: flex-start; }
.captain-entry:last-child { margin-bottom: 0; }
.sortable-col:hover { background: var(--navy-700); }

.stat-cards { display: flex; gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 16px 24px;
  text-align: center;
}
.stat-number { font-size: 1.8rem; font-weight: 700; color: var(--navy-800); }
.stat-label { color: var(--muted); font-size: 0.85rem; }

.admin-links { list-style: none; padding: 0; }
.admin-links li { margin-bottom: 8px; }

/* ============================================================
   Mentions styling within post bodies
   ============================================================ */
.mention {
  background: var(--unread-bg);
  color: var(--navy-800);
  border-radius: 4px;
  padding: 0 4px;
  font-weight: 700;
}

/* ============================================================
   Mentions page
   ============================================================ */
.mention-list { list-style: none; padding: 0; }
.mention-row {
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  margin-bottom: 8px;
}
.mention-row.unread { border-left: 4px solid var(--navy-800); background: var(--unread-bg); }
.mention-form { margin: 0; }
.mention-link {
  all: unset;
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 12px 16px;
  cursor: pointer;
}
.mention-token { display: inline-block; font-weight: 700; color: var(--navy-800); margin-bottom: 4px; }
.mention-context { display: block; font-size: 0.9rem; margin-bottom: 4px; color: var(--text); }
.mention-snippet { display: block; color: var(--muted); font-size: 0.85rem; }
.mention-meta { display: block; color: var(--muted); font-size: 0.75rem; margin-top: 4px; }

/* ============================================================
   Mention autocomplete dropdown
   ============================================================ */
.mention-wrap { position: relative; }
.mention-dropdown {
  position: absolute;
  z-index: 10;
  background: var(--card);
  border: 1.5px solid var(--border-ui);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(20,40,64,0.15);
  max-height: 220px;
  overflow-y: auto;
  width: 100%;
  top: 100%;
  left: 0;
  margin-top: 2px;
}
.mention-option {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.mention-option:hover, .mention-option.active { background: var(--unread-bg); }
.mention-option-handle { font-weight: 700; color: var(--navy-800); font-size: 0.9rem; }
.mention-option-label { color: var(--muted); font-size: 0.85rem; }

/* ============================================================
   Events / calendar
   ============================================================ */
.event-list { list-style: none; padding: 0; }
.event-row {
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 10px;
}
.event-date { font-weight: 700; color: var(--gold-700); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; }
.event-title { font-size: 1.1rem; margin: 4px 0; }
.event-title a { color: var(--navy-800); text-decoration: none; }
.event-title a:hover { text-decoration: underline; }
.event-location, .event-contact { color: var(--muted); font-size: 0.9rem; }
.event-description { margin-top: 6px; }

/* ============================================================
   Widget composer (in post/reply forms)
   ============================================================ */
.widget-composer { margin-top: 16px; padding-top: 12px; border-top: 1.5px dashed var(--border-ui); }
.widget-fields {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  margin-top: 8px;
}
.checkbox-label { display: flex; align-items: center; gap: 6px; font-weight: normal; }
.checkbox-label input { width: auto; }

/* ============================================================
   Widget display (rendered within a post)
   ============================================================ */
.widget-display {
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px 14px;
}
.widget-title { font-weight: 700; margin-bottom: 8px; color: var(--navy-900); }
.widget-closed-tag { color: var(--muted); font-weight: normal; font-size: 0.85rem; }
.widget-meta { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
.widget-close-link { font-size: 0.8rem; color: var(--muted); margin-top: 8px; display: inline-block; }

.poll-option-input { display: block; font-weight: normal; margin-bottom: 4px; }
.poll-option-input input { width: auto; margin-right: 6px; }
.poll-results { margin-top: 10px; }
.poll-result-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 0.9rem; }
.poll-result-label { flex: 0 0 40%; }
.poll-result-bar-wrap { flex: 1; background: #dde1e8; border-radius: 4px; height: 10px; overflow: hidden; }
.poll-result-bar { display: block; height: 100%; background: var(--navy-800); }
.poll-result-count { flex: 0 0 60px; text-align: right; color: var(--muted); font-size: 0.85rem; }

.scheduling-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-top: 6px; }
.scheduling-table th, .scheduling-table td { padding: 6px 8px; border-bottom: 1px solid var(--border-subtle); text-align: center; }
.scheduling-table th { background: transparent; color: var(--navy-900); }
.scheduling-table th:first-child, .scheduling-table td:first-child { text-align: left; }
.sched-response-form select { width: auto; padding: 4px; }
.sched-respondent-row td { font-size: 0.8rem; text-align: left; }

.file-list { list-style: none; padding: 0; margin: 0; }
.file-list li { padding: 4px 0; }
.file-list a { color: var(--navy-800); font-weight: 600; }

.rsvp-form { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.rsvp-form button { margin-top: 0; }
.rsvp-active { background: var(--navy-900); box-shadow: inset 0 0 0 2px white, inset 0 0 0 3px var(--navy-900); }

.widget-actions-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.your-choice-tag {
  display: inline-block;
  background: var(--gold-700);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: middle;
}

.sched-slot-row { border-bottom: 1px solid var(--border-subtle); padding: 10px 0; }
.sched-slot-row:last-of-type { border-bottom: none; }
.sched-slot-label { font-weight: 600; margin-bottom: 6px; }
.sched-slot-options { display: flex; gap: 18px; flex-wrap: wrap; font-weight: normal; }
.sched-slot-options label { display: flex; align-items: center; gap: 5px; font-weight: normal; }
.sched-slot-options input { width: auto; margin: 0; }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20,40,64,0.55);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: white;
  border-radius: 10px;
  padding: 20px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
}

@media (max-width: 480px) {
  .container { padding: 12px; }
  .card { padding: 16px; }
  .thread-row, .post { flex-direction: row; }
}
