/*
 * OSSignal site styles — no external fonts or CDNs.
 *
 * Dark is the default and matches the generated social cards: #0a0a0f ground,
 * #00ff88 accent. Light is a full second palette rather than an inversion,
 * because #00ff88 on white is unreadable — the accent darkens to a green that
 * holds 4.5:1 against the page. The two are kept in the same token names, so
 * every rule below is written once.
 *
 * Which one shows: `data-theme` on <html> wins (set by assets/js/theme.js from
 * what the reader chose), and with nothing chosen the system preference decides.
 *
 * The greys were also raised. --muted and --dim were used for real sentences at
 * around 3:1 against the background, which reads as switched-off rather than
 * secondary; both now clear 4.5:1 in each theme.
 */

:root {
  color-scheme: dark;
  --bg: #0a0a0f;
  --bg-raised: #14141f;
  --bg-hover: #1a1a29;
  --border: #23233a;
  --text: #f0f0f6;
  --muted: #a6a6bd;
  --dim: #83839c;
  --accent: #00ff88;
  --accent-alt: #4db8ff;
  --gold: #ffd700;
  --coral: #ff8080;
  --shadow: none;
  --shadow-hover: none;
  --radius: 10px;
  --wrap: 1120px;
}

/* Light, when the reader asked for it or their system did. Raised surfaces need
 * a shadow here: on a white page a 1px border alone does not lift a card off it,
 * where on the dark page the border is the whole separation. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --shadow: 0 1px 2px rgba(16, 18, 26, .05);
    --shadow-hover: 0 6px 20px rgba(16, 18, 26, .08);
    --bg: #f7f8fb;
    --bg-raised: #ffffff;
    --bg-hover: #eef1f6;
    --border: #dde1ea;
    --text: #131722;
    --muted: #566072;
    --dim: #646d7c;
    --accent: #047857;
    --accent-alt: #1d4ed8;
    --gold: #92400e;
    --coral: #b91c1c;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --shadow: 0 1px 2px rgba(16, 18, 26, .05);
  --shadow-hover: 0 6px 20px rgba(16, 18, 26, .08);
  --bg: #f7f8fb;
  --bg-raised: #ffffff;
  --bg-hover: #eef1f6;
  --border: #dde1ea;
  --text: #131722;
  --muted: #566072;
  --dim: #646d7c;
  --accent: #047857;
  --accent-alt: #1d4ed8;
  --gold: #92400e;
  --coral: #b91c1c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Keyboard users need to see where they are; the ring is the accent, so it is
 * visible in both themes without a second colour. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Theme switch ------------------------------------------------------------ */

.theme-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--bg-raised); color: var(--muted);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 12px; font: inherit; font-size: 14px; cursor: pointer;
  line-height: 1.2;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.theme-toggle .mark { font-size: 15px; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--bg); padding: 10px 16px; z-index: 10;
}
.skip-link:focus { left: 0; }

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

.site-header {
  border-bottom: 1px solid var(--border);
  /* Tokens, not a literal: the old #10101a top stop stayed near-black behind a
   * light page. */
  background: linear-gradient(180deg, var(--bg-hover), var(--bg));
  position: sticky; top: 0; z-index: 5;
  backdrop-filter: blur(6px);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 64px; flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); font-size: 18px; }
.brand-name { font-weight: 700; letter-spacing: 3px; font-size: 15px; }

.site-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.site-nav a {
  color: var(--muted); padding: 8px 14px; border-radius: var(--radius);
  font-size: 15px; border: 1px solid transparent;
}
.site-nav a:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--accent); border-color: var(--border); background: var(--bg-raised); }

/* Main -------------------------------------------------------------------- */

.site-main { padding: 40px 20px 64px; }

h1, h2, h3 { line-height: 1.25; font-weight: 700; }
h1 { font-size: clamp(28px, 4vw, 40px); }
h2 { font-size: clamp(22px, 3vw, 28px); margin-top: 8px; }
h3 { font-size: 20px; }

.page-title { margin-bottom: 8px; }
.page-title a { color: var(--accent); }
.page-meta { color: var(--muted); font-size: 15px; margin-bottom: 24px; }
.page-meta .dot { margin: 0 8px; color: var(--dim); }
.page-meta .stars { color: var(--gold); }
.page-meta .lang { color: var(--accent-alt); }
.page-meta .cat { color: var(--coral); }

.lede { color: var(--muted); font-size: 18px; max-width: 70ch; margin-bottom: 8px; }

.section { margin-top: 48px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 24px;
}
.section-head .kicker { color: var(--dim); font-size: 13px; letter-spacing: 2px; text-transform: uppercase; }

.post-image {
  width: 100%; height: auto; border-radius: var(--radius);
  border: 1px solid var(--border); margin: 8px 0 28px;
}

/* Stat strip -------------------------------------------------------------- */

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-top: 28px;
}
.stat {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .value { font-size: 27px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat .label { font-size: 12.5px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); }

/* Cards ------------------------------------------------------------------- */

.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px;
}
.card {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.card .name { font-size: 18.5px; font-weight: 700; }
.card .name a { color: var(--accent); }
.card .owner { color: var(--dim); font-weight: 400; }
.card .desc { color: var(--text); font-size: 15.5px; flex: 1; }
.card .meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13.5px; color: var(--muted); }
.card .meta .stars { color: var(--gold); }
.card .meta .lang { color: var(--accent-alt); }
.card .meta .cat { color: var(--coral); }
.card .bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.card .bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-alt)); }

/* Category + report lists -------------------------------------------------- */

.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.category {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.category h3 { font-size: 17px; margin-bottom: 4px; }
.category .count { color: var(--accent); font-weight: 700; }
.category .sub { color: var(--muted); font-size: 13px; }
.category ul { list-style: none; margin-top: 10px; font-size: 14px; }
.category li { padding: 2px 0; color: var(--muted); }

.report-list { list-style: none; }
.report-list li {
  padding: 14px 0; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.report-list time { color: var(--dim); font-size: 14px; font-variant-numeric: tabular-nums; }

.empty { color: var(--muted); background: var(--bg-raised); border: 1px dashed var(--border);
  border-radius: var(--radius); padding: 24px; text-align: center; }

/* Tables in generated reports --------------------------------------------- */

table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 15px; display: block; overflow-x: auto; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }

blockquote { border-left: 3px solid var(--accent); padding-left: 16px; color: var(--muted); margin: 16px 0; }
code { background: var(--bg-hover); padding: 2px 6px; border-radius: 4px; font-size: 14px; }
pre { background: var(--bg-hover); padding: 16px; border-radius: var(--radius); overflow-x: auto; }
pre code { background: none; padding: 0; }
hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

/* Prose wants a measure. Report bodies ran the full 1120px, which is roughly
 * 150 characters a line — the eye loses the next line on the way back. */
.site-main ul, .site-main ol { margin: 14px 0 14px 24px; max-width: 74ch; }
.site-main li { margin: 4px 0; }
.site-main p { margin: 14px 0; max-width: 74ch; }
.site-main h2, .site-main h3 { margin-top: 32px; }

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

.site-footer { border-top: 1px solid var(--border); padding: 28px 0; margin-top: 48px; }
.footer-inner {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  color: var(--dim); font-size: 14px;
}

/* Responsive --------------------------------------------------------------- */

@media (max-width: 640px) {
  .site-main { padding: 28px 16px 48px; }
  .cards { grid-template-columns: 1fr; }
  .header-inner { min-height: 56px; }
  .brand-name { font-size: 13px; letter-spacing: 2px; }
  .site-nav a { padding: 6px 10px; font-size: 14px; }
}

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

/* Search -------------------------------------------------------------------- */

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
#repo-search {
  width: 100%; padding: 14px 18px; font-size: 17px;
  background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
}
#repo-search:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
#search-count { display: inline-block; margin-top: 8px; color: var(--muted); font-size: 13px; }
.search-results { list-style: none; margin-top: 12px; }
.search-results li {
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.search-results li a { font-weight: 600; }
.search-results .meta { color: var(--muted); font-size: 13px; margin-left: 10px; }
.search-results p { color: var(--text); font-size: 15px; margin: 4px 0 0; }

/* Semantic map -------------------------------------------------------------- */

#map-shell { position: relative; margin-top: 24px; }
#semantic-map {
  width: 100%; height: auto; max-width: 100%;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: grab; touch-action: none;
}
#semantic-map:active { cursor: grabbing; }
#map-tooltip {
  position: absolute; pointer-events: none; z-index: 2;
  background: var(--bg); border: 1px solid var(--accent); border-radius: 6px;
  padding: 6px 10px; font-size: 13px; color: var(--text); white-space: nowrap;
}
#map-status { display: block; margin-top: 10px; color: var(--muted); }

/* Share row on a repository page, and the follow block above the footer.
   Both are quiet by default and only colour up on hover: a page that shouts
   "share me" before it has said anything is the pattern people scroll past. */
.share {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border);
}
.share-label { color: var(--dim); font-size: 14px; }
.share-link {
  padding: 4px 10px; font-size: 14px; border: 1px solid var(--border);
  border-radius: 4px; color: var(--muted);
}
.share-link:hover { color: var(--accent); background: var(--bg-hover); text-decoration: none; }

.follow {
  border-top: 1px solid var(--border); background: var(--bg-raised);
  margin-top: 48px; padding: 32px 0;
}
.follow > * { max-width: 760px; margin-inline: auto; padding-inline: 20px; }
.follow h2 { font-size: 20px; margin-bottom: 8px; }
.follow p { color: var(--muted); }
.follow-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.follow-link {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); font-size: 14px;
}
.follow-link:hover { color: var(--accent); background: var(--bg-hover); text-decoration: none; }
.nav-feed { color: var(--dim); }

/* The one link in the follow block that is the point of it. */
.follow-primary { border-color: var(--accent); color: var(--accent); }
.follow-primary:hover { background: var(--bg-hover); }
