/* MadnessInnsmouth
 *
 * Rules this file sticks to:
 *  - Source order is reading order. With CSS off the page still reads correctly.
 *  - Nothing is conveyed by colour alone.
 *  - Focus is always visible, and never thinner than the thing it outlines.
 *  - Text scales with the visitor's browser setting (rem throughout, no px fonts).
 *  - Motion is opt-out, and there is very little of it to begin with.
 */

:root {
  --bg:        #ffffff;
  --bg-soft:   #f4f6fa;
  --surface:   #ffffff;
  --fg:        #14161c;
  --muted:     #4c5464;
  --line:      #d6dbe4;
  --accent:    #0a5aab;
  --accent-fg: #ffffff;
  --accent-soft:#e9f1fb;
  --good:      #12603a;
  --good-soft: #e3f5ea;
  --warn:      #8a5a00;
  --warn-soft: #fdf4e3;

  --radius: 12px;
  --shell: 68rem;
  --pad: clamp(1rem, 4vw, 2rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0f1116;
    --bg-soft:   #161922;
    --surface:   #171a22;
    --fg:        #eef0f5;
    --muted:     #aab2c2;
    --line:      #2b303c;
    --accent:    #7cb8f7;
    --accent-fg: #0b1220;
    --accent-soft:#17222f;
    --good:      #7ee0ac;
    --good-soft: #12241b;
    --warn:      #f0c274;
    --warn-soft: #2a2113;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 1.05rem/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

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

/* ---------- shared ---------- */

a { color: var(--accent); text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
}
.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
  padding: 0.7rem 1.1rem;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 8px;
  text-decoration: none;
}

/* ---------- header and navigation ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.bar {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0.7rem var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}
.brand-name { font-size: 1.05rem; }

/* The toggle is hidden on wide screens, where the links are always shown.
   It is display:none rather than visually hidden so it never lands in the
   tab order when it has nothing to control. */
.nav-toggle { display: none; }

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0.35rem;
}
.site-nav a {
  display: block;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  color: var(--fg);
  text-decoration: none;
  font-weight: 500;
}
.site-nav a:hover { background: var(--bg-soft); text-decoration: underline; }

/* The header rule spans the full window; its contents stay aligned with the
   page body. On wide screens the brand and the links share one row. */
.header-shell {
  max-width: var(--shell);
  margin: 0 auto;
}

@media (min-width: 45rem) {
  .header-shell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
  }
  .bar { flex: 1 1 auto; padding-right: 0; }
  .site-nav { flex: 0 0 auto; padding-right: var(--pad); }
}

/* ---------- mobile: hamburger ---------- */

@media (max-width: 44.99rem) {
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    /* Comfortably above the 44px minimum touch target on iOS. */
    min-height: 2.9rem;
    padding: 0.5rem 0.9rem;
    background: var(--surface);
    color: var(--fg);
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
  }

  .bars {
    display: grid;
    gap: 4px;
    width: 1.15rem;
  }
  .bars span {
    display: block;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.18s ease, opacity 0.18s ease;
  }
  /* Open state becomes an X, but the label text also changes, so the shape
     is never the only signal. */
  .nav-toggle[aria-expanded="true"] .bars span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] .bars span:nth-child(2) { opacity: 0; }
  .nav-toggle[aria-expanded="true"] .bars span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  /* hidden, not merely invisible: links inside are out of the tab order and
     out of the screen reader's reach until the menu is opened. */
  .site-nav[hidden] { display: none; }

  .site-nav {
    border-top: 1px solid var(--line);
    padding: 0.5rem var(--pad) 1rem;
    background: var(--bg);
  }
  .site-nav ul { flex-direction: column; gap: 0.15rem; }
  .site-nav a {
    padding: 0.8rem 0.75rem;
    border-radius: 10px;
    font-size: 1.05rem;
  }
}

/* ---------- layout ---------- */

main {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 var(--pad) 4rem;
}

section { padding: 2.75rem 0 0; }

h1, h2, h3 { line-height: 1.25; text-wrap: balance; }

h1 { font-size: clamp(1.85rem, 5vw, 2.7rem); margin: 0 0 0.6rem; letter-spacing: -0.02em; }
h2 {
  font-size: clamp(1.4rem, 3.5vw, 1.8rem);
  margin: 0 0 1rem;
  padding-bottom: 0.45rem;
  border-bottom: 2px solid var(--line);
  letter-spacing: -0.01em;
}
h3 { font-size: 1.15rem; margin: 1.6rem 0 0.4rem; }

.lead { font-size: 1.12rem; max-width: 44rem; }
.note { color: var(--muted); font-size: 0.96rem; }
.meta { color: var(--muted); font-size: 0.92rem; }

code {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.12em 0.38em;
  font-size: 0.9em;
  word-break: break-word;
}

/* ---------- hero ---------- */

.hero { padding-top: 3.25rem; }
.eyebrow {
  margin: 0 0 0.6rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.6rem 0 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  padding: 0.7rem 1.35rem;
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { text-decoration: underline; }
.btn-ghost {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--bg-soft); text-decoration: underline; }

/* ---------- cards, features, panels ---------- */

.panel {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}
.panel > :first-child { margin-top: 0; }
.panel > :last-child { margin-bottom: 0; }

ul.features, ul.cards {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}
ul.features li, ul.cards li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}
ul.features h3, ul.cards h3,
ul.features h4, ul.cards h4 { margin: 0 0 0.35rem; font-size: 1.08rem; line-height: 1.3; }
ul.features p, ul.cards p { margin: 0.3rem 0 0; }

.tag {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 600;
}
.tag-live { background: var(--good-soft); color: var(--good); border-color: currentColor; }

.steps { margin: 1rem 0 0.5rem; padding-left: 1.3rem; }
.steps li { margin: 0.35rem 0; }

/* ---------- live status ---------- */

#status-panel p, #leaderboard p { margin: 0.4rem 0; }
.badge {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  background: var(--good-soft);
  color: var(--good);
  border: 1px solid currentColor;
  font-size: 0.92rem;
  font-weight: 600;
}

/* ---------- tables ---------- */

.scroll { overflow-x: auto; margin: 0.5rem 0 1.5rem; }
table { border-collapse: collapse; width: 100%; min-width: 34rem; }
caption {
  text-align: left;
  color: var(--muted);
  font-size: 0.95rem;
  padding-bottom: 0.5rem;
}
th, td {
  text-align: left;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
thead th { background: var(--bg-soft); font-size: 0.92rem; }
tbody th { font-weight: 600; }
tbody tr:hover td, tbody tr:hover th { background: var(--bg-soft); }

/* ---------- current page ---------- */

/* Marked with a bar and weight, never with colour alone. The underline keeps
   it distinguishable for anyone who cannot pick up the tint. */
.site-nav a[aria-current="page"] {
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.25em;
  background: var(--accent-soft);
}

/* ---------- legal pages ---------- */

.legal { max-width: 46rem; }
.legal h1 { margin-top: 2.5rem; }
.legal h2 {
  font-size: 1.3rem;
  margin: 2.25rem 0 0.75rem;
  padding-bottom: 0.3rem;
}
.legal h3 { font-size: 1.08rem; }
.legal p, .legal li { max-width: 42rem; }
.legal ul { padding-left: 1.3rem; }
.legal li { margin: 0.4rem 0; }
/* The policy tables hold sentences, not figures, so they should wrap down to
   any width rather than scroll sideways the way the leaderboard does. */
.legal table { min-width: 0; }
.legal td, .legal th { white-space: normal; vertical-align: top; }
.legal tbody th { width: 32%; }
@media (max-width: 30rem) {
  .legal th, .legal td { padding: 0.5rem 0.4rem; }
  .legal tbody th { width: 38%; }
}

.updated { color: var(--muted); font-size: 0.95rem; margin-top: 0; }
.crumb { margin: 2rem 0 0; font-size: 0.95rem; }

.callout { margin: 1.5rem 0; }
.callout-h {
  font-size: 1.1rem !important;
  margin: 0 0 0.6rem !important;
  padding: 0 !important;
  border: none !important;
}
.callout ul { margin-bottom: 0; }
.callout-warn {
  background: var(--warn-soft);
  border-color: var(--warn);
}

.toc { list-style: none; padding: 0; }
.toc li {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}
.toc .meta { display: block; }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 2rem;
  padding: 1.75rem var(--pad) 3rem;
}
.footer-shell { max-width: var(--shell); margin-inline: auto; }
.footer-brand { font-weight: 700; margin: 0 0 0.6rem; }
.footer-links {
  list-style: none;
  margin: 0 0 0.9rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
}
.footer-links a { display: inline-block; padding: 0.35rem 0; }
.site-footer .note { margin: 0; }
