/* ==========================================================================
   Mesh Pirkanmaa — main stylesheet
   All values come from tokens.css. No literal colours or sizes below.
   Mobile-first: base styles are the narrow layout, media queries add width.
   ========================================================================== */

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

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

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: var(--leading);
  overflow-x: hidden;
}

/* Atmosphere: a faint grid, two distant neon blooms, and scanlines.
   All well under 5% opacity — texture you feel rather than read through. */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
body::before {
  background:
    radial-gradient(60rem 40rem at 15% -10%, rgb(0 229 255 / .07), transparent 60%),
    radial-gradient(50rem 35rem at 95% 8%,  rgb(255 45 149 / .06), transparent 60%),
    linear-gradient(rgb(255 255 255 / .022) 1px, transparent 1px) 0 0 / 100% 44px,
    linear-gradient(90deg, rgb(255 255 255 / .022) 1px, transparent 1px) 0 0 / 44px 100%;
}
body::after {
  background: repeating-linear-gradient(
    180deg, rgb(0 0 0 / .22) 0 1px, transparent 1px 3px);
  opacity: .5;
  mix-blend-mode: multiply;
}

/* Everything real sits above the atmosphere. */
.site-header, .site-main, .site-footer { position: relative; z-index: 1; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* --- Typography ---------------------------------------------------------- */

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--leading-tight);
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: var(--step-3); letter-spacing: -0.01em; }
h2 { font-size: var(--step-2); margin-block: var(--sp-7) var(--sp-4); }
h3 { font-size: var(--step-1); margin-block: var(--sp-6) var(--sp-3); }

p, ul, ol { margin-block: 0 var(--sp-4); }
.prose { max-width: var(--measure); }
.prose :is(h2, h3) + p { margin-top: 0; }

a {
  color: var(--primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--speed) ease, text-shadow var(--speed) ease;
}
a:hover { text-shadow: var(--text-glow); }

strong { color: var(--text); font-weight: 600; }
small, .note { font-size: var(--step--1); color: var(--muted); }

/* Ligatures OFF everywhere monospace is used. JetBrains Mono renders "==" as a
   single glyph and "--" as an em dash, which would misrepresent a PSK of AQ==
   and a CLI flag of --ch-index. On this site those characters are the payload. */
code, kbd, pre, .val, .signal__value, .readout__value, .readout__unit, .tag {
  font-family: var(--font-mono);
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0, "calt" 0;
}
code {
  font-size: 0.9em;
  color: var(--primary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.1em 0.4em;
  border-radius: var(--radius);
}
pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 2px solid var(--primary-dim);
  padding: var(--sp-4);
  overflow-x: auto;              /* code scrolls, the page does not */
  font-size: var(--step--1);
  line-height: 1.55;
}
pre code { background: none; border: 0; padding: 0; color: var(--text); }

/* The eyebrow label — small, spaced, display face. Used a lot. */
.eyebrow {
  font-family: var(--font-display);
  font-size: var(--step--1);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--primary);
  margin: 0 0 var(--sp-2);
}
.eyebrow--accent { color: var(--accent); }

/* --- Chamfer: the corner cut that does most of the cyberpunk work --------- */
.chamfer {
  clip-path: polygon(
    var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)),
    calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer));
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
/* Hairline of neon under the header. */
.site-header::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg,
    transparent, var(--primary) 25%, var(--accent) 75%, transparent);
  opacity: .55;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  min-height: var(--tap);
  padding-block: var(--sp-3);
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-display);
  font-size: var(--step-0);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { color: var(--primary); }
.brand__mark {
  width: 0.7em; height: 0.7em;
  background: var(--primary);
  box-shadow: var(--glow-primary);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.brand__sub { color: var(--muted); font-size: var(--step--1); letter-spacing: .06em; }
/* Decorative coordinates — dropped on the narrowest screens, where they wrap
   onto a second line and push the menu button down. */
@media (max-width: 26em) { .brand__sub { display: none; } }

.site-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-4);
  margin: 0;
  padding: 0;
}
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);         /* comfortable on a phone */
  font-family: var(--font-display);
  font-size: var(--step--1);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}
.site-nav a:hover { color: var(--primary); }
.site-nav a[aria-current="page"] {
  color: var(--primary);
  box-shadow: inset 0 -2px 0 var(--primary);
}

/* --- Mobile navigation --------------------------------------------------- */

/* Hidden by default and revealed only below the breakpoint, and only when JS
   has run — see assets/js/nav.js. Without JS the list stays visible. */
.nav-toggle { display: none; }

.nav-toggle__bars {
  position: relative;
  width: 1.1em;
  height: 2px;
  background: currentColor;
  transition: background var(--speed) ease;
}
.nav-toggle__bars::before,
.nav-toggle__bars::after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  transition: transform var(--speed) ease, top var(--speed) ease;
}
.nav-toggle__bars::before { top: -6px; }
.nav-toggle__bars::after  { top: 6px; }

/* Bars fold into a cross when open. */
.nav-toggle[aria-expanded="true"] .nav-toggle__bars { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars::before { top: 0; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars::after  { top: 0; transform: rotate(-45deg); }

@media (max-width: 51.99em) {
  .js .nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-3);
    min-height: var(--tap);
    padding: var(--sp-2) var(--sp-4);
    background: transparent;
    border: 1px solid var(--border-lit);
    color: var(--text);
    font-family: var(--font-display);
    font-size: var(--step--1);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
  }
  .js .nav-toggle:hover,
  .js .nav-toggle[aria-expanded="true"] {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--glow-primary);
  }

  /* The panel drops below the brand row, full width. */
  .site-nav { flex-basis: 100%; order: 3; }
  .js .site-nav[data-collapsed] { display: none; }

  .site-nav ul { flex-direction: column; gap: 0; }
  .site-nav li + li { border-top: 1px solid var(--border); }
  .site-nav a {
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--step-0);
  }
  /* Left bar rather than an underline — reads better in a stacked list. */
  .site-nav a[aria-current="page"] {
    box-shadow: inset 3px 0 0 var(--primary);
    background: var(--surface);
  }
}

/* --- Section sub-navigation ---------------------------------------------- */

.subnav {
  position: relative;
  z-index: 9;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.subnav .wrap { padding-inline: 0; }
.subnav ul {
  list-style: none;
  margin: 0;
  padding-inline: var(--gutter);
  display: flex;
  gap: 0;
  /* Scrolls sideways on a phone rather than wrapping or hiding behind a second
     disclosure — the primary nav already owns the Menu button. */
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.subnav ul::-webkit-scrollbar { display: none; }
.subnav li { flex: none; }
.subnav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-4);
  font-family: var(--font-display);
  font-size: var(--step--1);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color var(--speed) ease, border-color var(--speed) ease;
}
.subnav a:hover { color: var(--text); }
.subnav a[aria-current="page"] {
  color: var(--primary);
  border-bottom-color: var(--primary);
  text-shadow: var(--text-glow);
}

/* --- Page head ----------------------------------------------------------- */

.page-head { padding-block: var(--sp-7) var(--sp-5); }
.page-head h1 { text-shadow: var(--text-glow); }
.page-head .lede {
  font-size: var(--step-1);
  color: var(--muted);
  max-width: 46ch;
  margin-top: var(--sp-4);
}

/* --- Signal strip: a compact status bar of key facts ---------------------- */

.signal {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;                        /* the gap IS the divider */
  background: var(--border);
  border: 1px solid var(--border);
  margin-block: var(--sp-5);
}
@media (min-width: 40em) { .signal { grid-template-columns: repeat(3, 1fr); } }

.signal__cell { background: var(--surface); padding: var(--sp-4); }
.signal__label {
  font-family: var(--font-display);
  font-size: var(--step--1);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: var(--sp-1);
}
.signal__value {
  font-family: var(--font-mono);
  font-size: var(--step-1);
  font-weight: 700;
  color: var(--primary);
  overflow-wrap: anywhere;
}

/* --- Panel: the general content container -------------------------------- */

.panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: var(--sp-5);
  margin-block: var(--sp-5);
}
.panel > :first-child { margin-top: 0; }
.panel > :last-child  { margin-bottom: 0; }

/* Corner brackets — HUD framing, drawn in CSS so there are no image assets.
   Do not combine .panel--bracket with .chamfer: the clip-path cuts the brackets. */
.panel--bracket::before,
.panel--bracket::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border: 2px solid var(--primary);
  opacity: .8;
}
.panel--bracket::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel--bracket::after  { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

/* --- Grids of panels ----------------------------------------------------- */

.grid {
  display: grid;
  gap: var(--sp-4);
  /* min() so a card never forces the page wider than the viewport */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  margin-block: var(--sp-5);
}
.grid--wide { grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr)); }
.grid > .panel { margin-block: 0; height: 100%; }

/* Headings sit tight inside a panel rather than carrying page-level margins. */
.panel :is(h2, h3) { margin-top: 0; margin-bottom: var(--sp-2); font-size: var(--step-1); }

/* --- Panels that are entirely one link ----------------------------------- */

.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--speed) ease, box-shadow var(--speed) ease;
}
.card-link :is(h2, h3) { color: var(--primary); }
.card-link:hover {
  border-color: var(--border-hover);
  box-shadow: 0 0 14px var(--accent-glow);
}
.card-link:hover :is(h2, h3) { text-shadow: var(--text-glow); }
.card-link .note { color: var(--muted); }

/* --- Hero readout: one number that matters ------------------------------- */

.readout {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-2) var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--border-lit);
  box-shadow: var(--glow-primary);
  padding: var(--sp-5);
  margin-block: var(--sp-6);
}
.readout__value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--step-3);
  line-height: 1;
  color: var(--primary);
  text-shadow: var(--text-glow);
  overflow-wrap: anywhere;
}
.readout__unit { font-family: var(--font-mono); font-size: var(--step-1); color: var(--muted); }
.readout__note { color: var(--muted); font-size: var(--step--1); flex-basis: 100%; }

/* --- Tables -------------------------------------------------------------- */

.table-scroll {
  overflow-x: auto;               /* wide tables scroll themselves */
  margin-block: var(--sp-4);
  border: 1px solid var(--border);
}
table { border-collapse: collapse; width: 100%; min-width: 30rem; }
caption {
  text-align: left;
  font-family: var(--font-display);
  font-size: var(--step--1);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--muted);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
th, td {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:last-child :is(th, td) { border-bottom: 0; }
tbody tr { background: var(--surface); transition: background var(--speed) ease; }
tbody tr:hover { background: var(--surface-2); }
th[scope="row"] { font-weight: 600; color: var(--text); white-space: nowrap; }
.val {
  font-family: var(--font-mono);
  color: var(--primary);
  white-space: nowrap;
}
.val--accent { color: var(--accent); }

/* Field name with a translation available on hover (title attr). Note: title
   tooltips do not appear on touch devices, so this is a desktop-only helper. */
.hint {
  text-decoration: underline dotted var(--border-lit);
  text-underline-offset: 3px;
  cursor: help;
}
td .note { display: block; margin-top: var(--sp-1); }

/* --- Callout ------------------------------------------------------------- */

.callout {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  padding: var(--sp-4);
  margin-block: var(--sp-5);
}
.callout > :first-child { margin-top: 0; }
.callout > :last-child  { margin-bottom: 0; }
.callout__title {
  font-family: var(--font-display);
  font-size: var(--step--1);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--warn);
  margin-bottom: var(--sp-2);
}
.callout--accent { border-left-color: var(--accent); }
.callout--accent .callout__title { color: var(--accent); }

/* --- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-5);
  font-family: var(--font-display);
  font-size: var(--step--1);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
  transition: background var(--speed) ease, color var(--speed) ease,
              box-shadow var(--speed) ease;
}
.btn:hover {
  background: var(--primary);
  color: var(--on-accent);         /* dark on neon — white would fail contrast */
  box-shadow: var(--glow-primary);
  text-shadow: none;
}
.btn--accent { border-color: var(--accent); color: var(--accent); }
.btn--accent:hover { background: var(--accent); color: var(--on-accent); box-shadow: var(--glow-accent); }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-block: var(--sp-5); }

/* --- Tags ---------------------------------------------------------------- */

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  padding: 0.15em 0.6em;
  border: 1px solid var(--border-lit);
  color: var(--muted);
}
.tag--on { border-color: var(--primary-dim); color: var(--primary); }
.tag-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: 0; }

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

.site-footer {
  margin-top: var(--sp-8);
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-block: var(--sp-6);
  color: var(--muted);
  font-size: var(--step--1);
}
.site-footer .wrap { display: grid; gap: var(--sp-5); }
@media (min-width: 48em) {
  .site-footer .wrap { grid-template-columns: repeat(3, 1fr); }
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--primary); }
.site-footer h2 {
  font-size: var(--step--1);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text);
  margin: 0 0 var(--sp-2);
}
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li + li { margin-top: var(--sp-1); }

/* --- On this page (in-page jump list for long articles) ------------------ */

.toc {
  border: 1px solid var(--border);
  border-left: 2px solid var(--primary-dim);
  background: var(--surface);
  padding: var(--sp-4);
  margin-block: var(--sp-5);
}
.toc p {
  font-family: var(--font-display);
  font-size: var(--step--1);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 var(--sp-2);
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li + li { margin-top: var(--sp-1); }

/* --- Definition-style spec list (device pages) --------------------------- */

.specs { margin-block: var(--sp-4); }
.specs div {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border);
}
.specs dt { flex: 0 0 10rem; color: var(--muted); margin: 0; }
.specs dd { margin: 0; font-family: var(--font-mono); color: var(--text); }

/* --- Accessibility ------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--primary);
  color: var(--on-accent);
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-display);
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Scanlines and glow are decorative; drop them when the user asks for less. */
@media (prefers-contrast: more) {
  body::after { display: none; }
  :root {
    --muted: #C3CBDA;
    --border: #4A5468;
  }
  h1, .readout__value, a:hover { text-shadow: none; }
}
