/* I-194 Waiver Forum. One small stylesheet, no framework. */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6877;
  --border: #dde3ea;
  --accent: #1f4e79;
  --accent-hover: #163a5c;
  --accent-soft: #e6eef7;
  --link: #1a5fa6;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --notice-soft: #fff6dc;
  --mark: #ffe58a;
  --mod: #0b6e4f;
  --trusted: #9a5b00;
  --radius: 8px;
  --gap: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1b2129;
    --text: #e3e8ee;
    --muted: #9aa5b3;
    --border: #2d3640;
    --accent: #5b9bd5;
    --accent-hover: #7db0e0;
    --accent-soft: #1f2c3b;
    --link: #7db6ec;
    --danger: #f2867d;
    --danger-soft: #3a2220;
    --notice-soft: #3a3320;
    --mark: #6b5a12;
    --mod: #4cc39a;
    --trusted: #f0b44c;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4, h5, h6 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }

img { max-width: 100%; height: auto; }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 var(--gap); }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--gap); top: 8px; z-index: 10; background: var(--surface); padding: 8px 12px; border-radius: var(--radius); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Header ------------------------------------------------------------------------------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
}

.site-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 16px; font-size: .95rem; }
.signed-in { color: var(--muted); }

.search input {
  width: 220px;
  max-width: 100%;
}

/* Layout ------------------------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}
.layout.no-sidebar { grid-template-columns: minmax(0, 1fr); }

main { min-width: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
  margin-bottom: var(--gap);
}

.narrow { max-width: 480px; }

.crumbs { font-size: .9rem; margin-bottom: 4px; }
.lede, .muted { color: var(--muted); }

/* Thread list -------------------------------------------------------------------------- */

.threads {
  list-style: none;
  margin: 0 0 var(--gap);
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.thread { padding: 14px var(--gap); border-top: 1px solid var(--border); }
.thread:first-child { border-top: 0; }
.thread.sticky { background: var(--accent-soft); }
.thread:first-child.sticky { border-radius: var(--radius) var(--radius) 0 0; }

.thread-title { font-size: 1.08rem; margin: 0 0 2px; }
.thread-title a { color: var(--text); text-decoration: none; }
.thread-title a:hover { color: var(--link); text-decoration: underline; }

.meta { font-size: .875rem; color: var(--muted); margin: 0; }
.meta a { color: inherit; }
.author { font-weight: 600; color: var(--text); }

.excerpt {
  margin: 6px 0;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  vertical-align: middle;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--accent);
  color: var(--surface);
}
.badge.muted-badge { background: var(--muted); }
.badge.danger { background: var(--danger); }

.empty { color: var(--muted); }

/* Pagination --------------------------------------------------------------------------- */

.pagination { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 var(--gap); }
.pagination a, .pagination span {
  min-width: 36px;
  padding: 6px 10px;
  text-align: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
}
.pagination .current { background: var(--accent); border-color: var(--accent); color: var(--surface); font-weight: 600; }
.pagination .gap { border-color: transparent; background: none; }

/* Posts -------------------------------------------------------------------------------- */

.thread-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: .9rem; margin-bottom: var(--gap); }

.post { scroll-margin-top: 16px; }
.post:target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.post.removed { opacity: .75; }
.post.opening { border-top: 3px solid var(--accent); }

.post-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 8px; font-size: .92rem; }
.post-head .author { font-size: 1rem; }
.when { color: var(--muted); }

.body { overflow-wrap: anywhere; }
.body > :first-child { margin-top: 0; }
.body > :last-child { margin-bottom: 0; }
.body p { margin: 0 0 .8em; }
.body blockquote {
  margin: 0 0 .8em;
  padding: 6px 12px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
.body pre { overflow-x: auto; padding: 10px; background: var(--bg); border-radius: 6px; }
.body code { font-size: .9em; }
.body ul, .body ol { padding-left: 1.4em; margin: 0 0 .8em; }

.post-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 10px; font-size: .875rem; }

/* Forms -------------------------------------------------------------------------------- */

label { display: block; font-weight: 600; font-size: .92rem; margin: 12px 0 4px; }

input[type="text"], input[type="search"], input[type="password"], input:not([type]), textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}
textarea { resize: vertical; min-height: 140px; }
input:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.compose h2 { font-size: 1.15rem; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.hint { font-size: .85rem; color: var(--muted); margin: 6px 0 0; }

.button {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 18px;
  font: inherit;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--surface); }
.button:disabled { opacity: .6; cursor: progress; }

.link {
  font: inherit;
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link.danger, a.danger, .button.danger { color: var(--danger); }

.inline { display: inline-flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; }

.alert, .notice { padding: 10px 12px; border-radius: 6px; margin: 0 0 var(--gap); }
.alert { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.notice { background: var(--notice-soft); }

.recovery { border: 2px solid var(--accent); }
.recovery h2 { font-size: 1.15rem; }
.recovery .code {
  font: 600 1.5rem/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .06em;
  background: var(--accent-soft);
  padding: 10px 14px;
  border-radius: 6px;
  display: inline-block;
  margin: 0 0 10px;
  user-select: all;
}
.success { padding: 10px 12px; border-radius: 6px; margin: 0 0 var(--gap); background: var(--accent-soft); font-weight: 600; }

.profile h1 { margin-bottom: 4px; }
.stats { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 24px; padding: 0; margin: 12px 0 0; }
.stats strong { font-size: 1.3rem; }

/* Stats page */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.stat { text-align: center; }
.stat-number { display: block; font-size: 2rem; font-weight: 700; color: var(--accent); line-height: 1.1; }
.stat-label { color: var(--muted); }
.stat-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.stat-table th, .stat-table td { padding: 8px 6px; border-top: 1px solid var(--border); text-align: right; }
.stat-table th[scope="row"], .stat-table thead th:first-child { text-align: left; }
.stat-table thead th { border-top: 0; color: var(--muted); font-weight: 600; }
@media (max-width: 600px) { .stat-number { font-size: 1.5rem; } .stat-table { font-size: .85rem; } }

/* Member names link to profiles without looking like ordinary links */
a.name-link { color: inherit; text-decoration: none; }
a.name-link:hover .name, a.name-link:focus-visible .name { text-decoration: underline; }

/* Moderators and trusted members */
.name-mod { color: var(--mod); font-weight: 700; }
.name-trusted { color: var(--trusted); font-weight: 600; }
.name .mark { font-size: .85em; margin-right: 3px; }
.badge-mod { background: var(--mod); }
.badge-trusted { background: var(--trusted); }
.badge-flag { background: var(--danger); }
.post.by-mod { border-left: 4px solid var(--mod); }
.post.by-trusted { border-left: 4px solid var(--trusted); }
.legend p { margin: 0 0 .5em; font-size: .92rem; }

/* Honeypot: hidden from people, visible to naive bots. */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.search-page { display: flex; gap: 8px; align-items: center; }
.search-page .button { margin-top: 0; }
.results { list-style: none; padding: 0; margin: 0 0 var(--gap); }
.results h2 { font-size: 1.05rem; margin-bottom: 4px; }
.snippet { margin: 0 0 6px; }
mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 2px; }

/* Sidebar ------------------------------------------------------------------------------ */

.sidebar .card h2 { font-size: .95rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sidebar .welcome { font-size: .95rem; }
.sidebar .welcome h3 { font-size: 1.1rem; }
.sidebar .welcome p { margin: 0 0 .7em; }
.links { list-style: none; margin: 0; padding: 0; }
.links li { padding: 6px 0; border-top: 1px solid var(--border); font-size: .95rem; }
.links li:first-child { border-top: 0; padding-top: 0; }
.news .muted { display: block; font-size: .8rem; }
.names { margin: 0; font-size: .95rem; }

.ad { margin: 0 0 var(--gap); }
/* No gap when Google has no ad to show (for example on a test address). */
.ad:has(ins[data-ad-status="unfilled"]) { display: none; }

.page h2, .page h3 { margin-top: 1.2em; }

/* Footer ------------------------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 24px;
  padding: 20px 0 28px;
  font-size: .9rem;
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; }
.disclaimer { color: var(--muted); margin: 0; max-width: 70ch; }

/* Small screens ------------------------------------------------------------------------ */

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
  h1 { font-size: 1.35rem; }
  .site-header { margin-bottom: 16px; }
  .brand { width: 100%; margin-right: 0; }
  .search { flex: 1 1 100%; }
  .search input { width: 100%; }
  .card { padding: 12px; }
  .thread { padding: 12px; }
  .fields { grid-template-columns: 1fr; }
  .search-page { flex-direction: column; align-items: stretch; }
}
