/* GADNET update server - the whole stylesheet.
 *
 * Ported from gadnet.pl's design system so the two properties read as one.
 * There is nothing to import: gadnet.pl keeps its ~1100 lines of CSS as a
 * Python string literal in src/site_generator/template.py and inlines it into
 * every page, so what travels between the two is the token set and the
 * component idioms, not a file.
 *
 * The signature of that system is JetBrains Mono headings over Inter body
 * copy, a teal primary, and cards that lift on hover. Both families are
 * self-hosted (see deploy/fetch-fonts.py) because this server's CSP is
 * default-src 'none' and stays that way.
 *
 * Three things here are deliberately NOT what gadnet.pl ships, because its
 * live sheet is missing them and copying the gap would be a regression:
 * :focus-visible outlines, a prefers-reduced-motion block, and a skip link.
 * There is also no theme toggle - gadnet.pl's is JavaScript, and this site has
 * none by design, so the system preference is the whole mechanism.
 */

:root {
  color-scheme: light dark;

  /* --- gadnet.pl tokens, verbatim ---------------------------------------- */
  --color-primary: #0d9488;
  --color-primary-hover: #0f766e;
  --color-primary-light: rgba(13, 148, 136, 0.1);
  --color-secondary: #26b8a0;
  --color-accent: #f97316;
  --color-danger: #ef4444;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-info: #3b82f6;
  --color-light: #ffffff;
  --color-dark: #0d1117;
  --color-gray-50: #f9fafb;
  --color-gray-100: #f3f4f6;
  --color-gray-200: #e5e7eb;
  --color-gray-500: #6b7280;
  --color-gray-600: #4b5563;
  --color-gray-700: #374151;
  --color-gray-800: #1f2937;

  --color-bg: var(--color-light);
  --color-text: var(--color-gray-800);
  --color-text-secondary: var(--color-gray-600);
  --color-border: var(--color-gray-200);
  --color-surface: var(--color-gray-50);

  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
  --space-2xl: 4rem;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, ui-monospace, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;

  --header-height: 80px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
  /* gadnet.pl uses --shadow-xl and never defines it. Defined here. */
  --shadow-xl: 0 20px 60px rgba(13, 148, 136, 0.25);
  --transition: 200ms ease;

  /* --- severity ----------------------------------------------------------
   * Drawn from the same families as gadnet.pl's semantic colours, but shifted
   * darker: #ef4444 on white is about 3.7:1, under the 4.5:1 a piece of text
   * needs. Severity is never signalled by colour alone anyway - the word is
   * always next to it - but a word nobody can read is not much of a fallback.
   */
  --sev-critical: #b91c1c;
  --sev-high: #c2410c;
  --sev-medium: #a16207;
  --sev-low: #1d4ed8;
  --sev-unknown: var(--color-gray-600);

  --measure: 68ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: var(--color-dark);
    --color-text: #e2e8f0;
    --color-text-secondary: #94a3b8;
    --color-border: #334155;
    --color-surface: #1e293b;
    --color-primary: #14b8a6;
    --color-primary-hover: #2dd4bf;
    --color-primary-light: rgba(20, 184, 166, 0.15);
    --color-gray-50: #0d1117;
    --color-gray-100: #161b22;
    --color-gray-200: #21262d;

    --sev-critical: #fca5a5;
    --sev-high: #fdba74;
    --sev-medium: #facc15;
    --sev-low: #93c5fd;
    --sev-unknown: #9ca3af;

    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  }
}

/* --- base ----------------------------------------------------------------- */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

a { color: var(--color-primary); }
a:hover { color: var(--color-primary-hover); }

/* WCAG 2.4.1. Off-screen until focused, then pulled back into view. */
.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: var(--space-md);
  top: var(--space-xs);
  z-index: 200;
  padding: 0.6rem 1rem;
  background: var(--color-surface);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-sm);
}

a:focus-visible,
.btn:focus-visible,
button:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* --- header --------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
}

@media (prefers-color-scheme: dark) {
  .site-header { background: rgba(13, 17, 23, 0.9); }
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  padding-top: var(--space-xs);
  padding-bottom: var(--space-xs);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  text-decoration: none;
  color: var(--color-text);
}

/* The mark's "NET" is near-white, so it needs a dark plate under it on a light
 * background. gadnet.pl keeps this tile dark in both themes; so do we. */
.brand__tile {
  display: flex;
  align-items: center;
  background: var(--color-dark);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.brand:hover .brand__tile {
  box-shadow: 0 0 15px rgba(13, 148, 136, 0.4);
  transform: translateY(-1px);
}
.brand__logo { height: 40px; width: auto; display: block; }
.brand__suffix {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  letter-spacing: 0.02em;
}

.site-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}
.site-nav a {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  transition: var(--transition);
}
.site-nav a:hover {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.lang-switcher {
  display: flex;
  gap: 4px;
  font-size: var(--text-sm);
  font-weight: 600;
}
.lang-switcher__link {
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.lang-switcher__link:hover {
  color: var(--color-primary);
  background: var(--color-primary-light);
}
.lang-switcher__link--active { color: var(--color-primary); }

/* --- typography ----------------------------------------------------------- */

main { padding: var(--space-xl) var(--space-md) var(--space-2xl); }
section { margin-bottom: var(--space-xl); }

h1, h2, h3 {
  font-family: var(--font-mono);
  letter-spacing: -0.5px;
  color: var(--color-text);
}
h1 { font-size: var(--text-3xl); font-weight: 800; line-height: 1.2; }
h2 { font-size: var(--text-xl); font-weight: 700; margin-top: var(--space-xl); }
h3 { font-size: var(--text-lg); font-weight: 700; }

p, li { max-width: var(--measure); }
.lede { font-size: var(--text-lg); color: var(--color-text-secondary); }
.muted { color: var(--color-text-secondary); }
.eyebrow {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-secondary);
}
.breadcrumb { font-size: var(--text-sm); color: var(--color-text-secondary); }

.hero { padding: var(--space-sm) 0 var(--space-xs); }
.actions { display: flex; gap: var(--space-xs); flex-wrap: wrap; }

/* --- buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
}
.btn--primary { background: var(--color-primary); color: #ffffff; }
.btn--primary:hover {
  background: var(--color-primary-hover);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.btn--secondary {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn--secondary:hover { background: var(--color-primary); color: #ffffff; }

/* --- cards ---------------------------------------------------------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: var(--space-sm);
}
.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  transition: var(--transition);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-primary);
  border-top-color: var(--color-primary);
}
.card--security { border-top-color: var(--color-accent); }
.card h3 { margin-top: 0; }
.card p { max-width: none; }

.notice {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
}
.notice p { max-width: none; }

/* The device-gate banner. Same shape as .notice so it does not read as an
   error - the reader has not done anything wrong - but warm rather than
   neutral, because it is the first thing on the page and has to be seen
   before the release list below it. */
.notice--gate {
  border-left-color: var(--color-accent);
  background: var(--color-surface);
  /* The banner is the first child of <main>, so without this it sits on the
     header's padding alone - 2rem on a phone, which reads as the header having
     grown a coloured block rather than the page carrying a message. */
  margin-top: var(--space-md);
  margin-bottom: var(--space-lg);
}
.notice--gate h2 { margin-top: 0; font-size: var(--text-lg); }
.notice--gate p:last-child { margin-bottom: 0; }

/* --- pills ---------------------------------------------------------------- */

.tags { display: flex; gap: var(--space-xs); flex-wrap: wrap; align-items: center; }
.tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  padding: 4px 12px;
  color: var(--color-text-secondary);
}
.tag-security { border-color: var(--color-accent); color: var(--color-accent); }

/* Severity is always accompanied by its name in text; the colour is a second
 * channel, never the only one. */
.sev { font-size: var(--text-sm); margin-right: var(--space-xs); }
.sev-critical { color: var(--sev-critical); font-weight: 700; }
.sev-high { color: var(--sev-high); font-weight: 700; }
.sev-medium { color: var(--sev-medium); font-weight: 600; }
.sev-low { color: var(--sev-low); }
.sev-negligible, .sev-unknown { color: var(--sev-unknown); }

/* --- lists ---------------------------------------------------------------- */

.steps { padding-left: 1.25rem; }
.steps li { margin-bottom: var(--space-xs); }
.prose-list { list-style: none; padding-left: 0; }
.prose-list li {
  margin-bottom: var(--space-xs);
  padding-left: 1.25rem;
  position: relative;
}
/* The pseudo-marker idiom gadnet.pl uses throughout. */
.prose-list li::before {
  content: "\25B8";
  position: absolute;
  left: 0;
  color: var(--color-primary);
}

.facts {
  display: grid;
  grid-template-columns: minmax(10rem, max-content) 1fr;
  gap: var(--space-xs) var(--space-md);
  margin: 0;
}
.facts dt { color: var(--color-text-secondary); font-size: var(--text-sm); }
.facts dd { margin: 0; }

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

.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
table {
  border-collapse: collapse;
  width: 100%;
  min-width: 38rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
thead th {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  background: var(--color-surface);
}
tbody tr:last-child th, tbody tr:last-child td { border-bottom: none; }

/* --- collapsible inventory groups ---------------------------------------- */

/* <details> is the only disclosure control available without script, which is
   what the component inventory needs: over a thousand rows that a reader wants
   one surface of at a time. */
.surface {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xs) var(--space-sm);
  margin-bottom: var(--space-sm);
  background: var(--color-surface);
}
.surface > summary {
  cursor: pointer;
  padding: 0.35rem 0;
  font-size: var(--text-lg);
}
.surface > summary:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.surface[open] > summary { margin-bottom: var(--space-xs); }

/* --- surface totals, shown in place of the inventory while gated ---------- */

.surface-counts {
  list-style: none;
  margin: var(--space-md) 0;
  padding: 0;
  display: grid;
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.surface-counts li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 0.7rem 1rem;
  background: var(--color-bg);
}
.surface-counts .count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--color-text-secondary);
}

/* --- code ----------------------------------------------------------------- */

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-primary-light);
  color: var(--color-primary);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}
pre {
  font-family: var(--font-mono);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  overflow-x: auto;
  max-width: var(--measure);
  font-size: var(--text-sm);
  line-height: 1.6;
}
pre code { background: none; padding: 0; color: inherit; }
.digest { word-break: break-all; }

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

.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: var(--space-lg) 0;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}
.site-footer p { margin: 0.35rem auto; max-width: var(--measure); }

.social-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.social-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--color-text-secondary);
  font-weight: 600;
  transition: var(--transition);
}
.social-link:hover { color: var(--color-primary); }
.social-link svg { flex: none; }

/* --- narrow screens ------------------------------------------------------- */

@media (max-width: 640px) {
  :root { --header-height: 64px; }
  h1 { font-size: var(--text-2xl); }
  main { padding: var(--space-lg) var(--space-sm) var(--space-xl); }
  .wrap { padding: 0 var(--space-sm); }
  .btn { width: 100%; justify-content: center; }
  /* Polish nav labels are materially longer than the English ones; let them
   * take a line of their own rather than crushing the switcher. */
  .site-header .wrap { justify-content: center; }
  .facts { grid-template-columns: 1fr; gap: 0 0; }
  .facts dt { margin-top: var(--space-xs); }

  /* The inventory stops being a table here. `table` carries min-width: 38rem
     because three columns of package URLs genuinely need it - but on a phone
     that turns a thousand-row list into a sideways scroll, where the name you
     are looking for sits off-screen behind the version column. Each row
     becomes a card instead: name first, version beside it, the package URL
     wrapped underneath. Scoped to .inventory so the releases and comparison
     tables, which are narrow enough to survive, keep their table shape. */
  .table-scroll--inventory {
    overflow-x: visible;
    box-shadow: none;
    border-radius: 0;
  }
  .inventory {
    min-width: 0;
    border: none;
    background: none;
  }
  /* Visually hidden, not display:none - the column names stay available to a
     screen reader walking the rows. */
  .inventory thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .inventory tbody tr {
    display: block;
    margin-bottom: var(--space-xs);
    padding: 0.7rem 0.9rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
  }
  .inventory tbody th,
  .inventory tbody td {
    display: block;
    padding: 0;
    border-bottom: none;
  }
  .inventory tbody th {
    font-size: var(--text-base);
    font-weight: 700;
    overflow-wrap: anywhere;
  }
  .inventory tbody td:first-of-type {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin-top: 0.15rem;
  }
  .inventory .digest {
    display: block;
    margin-top: 0.35rem;
    font-size: var(--text-xs);
    line-height: 1.45;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .card:hover, .btn--primary:hover, .brand:hover .brand__tile { transform: none; }
}
