/* yqs theme — yourqasucks.com — "The Glitch"
 * Mobile-first. Dark default. Light via prefers-color-scheme or manual toggle.
 * Single accent: #FF003C (matrix green #00FF41 reserved for the escape link hover).
 * Brutalist: 0px radius everywhere. Fira Code (headings/buttons) + IBM Plex Mono (body).
 */

/* ---- Fonts (self-hosted, latin subset) ---- */
@font-face {
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/FiraCode-Bold.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/IBMPlexMono-Regular.woff2') format('woff2');
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
img, svg, video { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
button, input, label, select, textarea { font: inherit; }

/* ---- Theme variables ---- */
:root {
  color-scheme: dark;
  --bg: #0A0A0A;
  --fg: #F5F5F5;
  --muted: #808080;
  --muted-rgb: 128, 128, 128;
  --text-soft: #f4f8fb;
  --rule: #808080;
  --rule-strong: var(--fg);
  --code-bg: #171717;
  --accent: #FF003C;
  --accent-fg: #0A0A0A;
  --accent-2: #00FF41;
  --accent-blue: #3B82F6;
  --accent-rgb: 255, 0, 60;
  --accent-2-rgb: 0, 255, 65;

  --font-heading: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --glitch-shadow: -1px 0 rgba(var(--accent-rgb), 0.65), 1px 0 rgba(0, 255, 255, 0.5);

  --container: 68ch;
  --leading: 1.6;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2rem;
  --space-6: 3rem;
  --space-7: 4rem;
}

/* System light preference */
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #F0F0F0;
    --fg: #0F0F0F;
    --muted: #686868;
    --muted-rgb: 104, 104, 104;
    --text-soft: #130f4f;
    --rule: #686868;
    --code-bg: #FFFFFF;
    --accent: #D9002B;
    --accent-fg: #F0F0F0;
    --accent-2: #00C234;
    --accent-blue: #2563EB;
    --accent-rgb: 217, 0, 43;
    --accent-2-rgb: 0, 194, 52;
  }
}

/* Manual toggle: invert whatever the current default is */
html:has(#theme-toggle:checked) {
  color-scheme: light;
  --bg: #F0F0F0;
  --fg: #0F0F0F;
  --muted: #686868;
  --muted-rgb: 104, 104, 104;
  --text-soft: #130f4f;
  --rule: #686868;
  --code-bg: #FFFFFF;
  --accent: #D9002B;
  --accent-fg: #F0F0F0;
  --accent-2: #00C234;
  --accent-blue: #2563EB;
  --accent-rgb: 217, 0, 43;
  --accent-2-rgb: 0, 194, 52;
}
@media (prefers-color-scheme: light) {
  html:has(#theme-toggle:checked) {
    color-scheme: dark;
    --bg: #0A0A0A;
    --fg: #F5F5F5;
    --muted: #808080;
    --muted-rgb: 128, 128, 128;
    --text-soft: #f4f8fb;
    --rule: #808080;
    --code-bg: #171717;
    --accent: #FF003C;
    --accent-fg: #0A0A0A;
    --accent-2: #00FF41;
    --accent-rgb: 255, 0, 60;
    --accent-2-rgb: 0, 255, 65;
  }
}

/* ---- Body / typography ---- */
body {
  font-family: var(--font-mono);
  font-size: 1.0625rem;
  line-height: var(--leading);
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent); color: var(--accent-fg); }

/* ---- Brutalist structure: zero radius, everywhere, no exceptions ---- */
* { border-radius: 0 !important; }

/* ---- A11y helpers ---- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  padding: var(--space-2) var(--space-3);
  background: var(--accent);
  color: var(--accent-fg);
  text-decoration: none;
  z-index: 100;
  font-family: var(--font-mono);
}
.skip-link:focus { top: 0; }

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

/* ---- Theme toggle ---- */
.theme-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
  margin: -1px;
}
.theme-toggle-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--rule);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 1.125rem;
  user-select: none;
  transition: border-color 0.15s ease, color 0.15s ease;
  flex: 0 0 auto;
  order: 3;
}
.theme-toggle-label:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle:focus-visible + * .theme-toggle-label,
.theme-toggle:focus-visible ~ * .theme-toggle-label,
.theme-toggle-label:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Neural/constellation background ---- */
.neural-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.5;
}

/* ---- Glitch exit overlay (click-transition to yourQArocks) ---- */
.glitch-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  pointer-events: none;
  opacity: 0;
}
.glitch-overlay.is-active {
  opacity: 1;
  animation: glitch-tear 0.5s steps(8) forwards;
}
@keyframes glitch-tear {
  0% { clip-path: inset(0 0 100% 0); background: var(--accent); }
  20% { clip-path: inset(20% 0 10% 0); background: var(--bg); transform: translateX(-2%); }
  40% { clip-path: inset(60% 0 5% 0); background: var(--accent-2); transform: translateX(2%); }
  60% { clip-path: inset(10% 0 70% 0); background: var(--bg); transform: translateX(-1%); }
  80% { clip-path: inset(0 0 0 0); background: var(--accent); transform: translateX(1%); }
  100% { clip-path: inset(0 0 0 0); background: var(--bg); transform: translateX(0); }
}

/* ---- Container ---- */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-3);
}

/* ---- Header ---- */
.site-header {
  border-bottom: 1px solid var(--rule);
  padding: var(--space-3) 0;
}
.site-header .container { max-width: 88ch; }
.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: inherit;
  font-family: var(--font-heading);
  line-height: 1.2;
  flex: 0 0 100%;
}
.brand-mark {
  flex-shrink: 0;
}
.brand-text {
  display: flex;
  flex-direction: column;
}
.brand-name {
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 1rem;
  text-transform: uppercase;
}
.brand-name::before { content: "› "; color: var(--accent); }
.brand-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

.site-nav {
  flex: 1 1 auto;
  order: 2;
}
.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}
.site-nav a {
  text-decoration: none;
  text-transform: uppercase;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  color: var(--muted);
}
.site-nav a:hover, .site-nav a:focus-visible {
  border-bottom-color: var(--accent);
  color: var(--accent);
  text-shadow: var(--glitch-shadow);
}
.site-nav a[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--accent);
  text-shadow: var(--glitch-shadow);
}

/* ---- Main ---- */
.site-main { padding: var(--space-5) 0 var(--space-7); }

/* ---- Headings ---- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  text-transform: uppercase;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: var(--space-5) 0 var(--space-3);
  font-weight: 700;
}
h1 { font-size: 2rem; margin-top: 0; letter-spacing: -2px; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }

/* ---- Links ---- */
.entry-content a,
.lede a,
p a {
  color: var(--fg);
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.entry-content a:hover,
.entry-content a:focus-visible,
.lede a:hover,
p a:hover { color: var(--accent); }

/* ---- Hero ---- */
.hero {
  padding: var(--space-5) 0 var(--space-4);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--rule);
}
.hero h1 {
  font-size: clamp(2rem, 4vw + 1rem, 2.75rem);
  margin: 0 0 var(--space-2);
}
.hero .lede {
  color: var(--text-soft);
  font-size: 1.1rem;
  margin: 0;
}

.section-heading {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: var(--space-5) 0 var(--space-3);
}

/* ---- Entry list ---- */
.entry-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-4);
}
.entry-list .entry {
  border-bottom: 1px solid var(--rule);
  padding-bottom: var(--space-4);
}
.entry-list .entry:last-child { border-bottom: 0; }
.entry-title {
  margin: 0 0 var(--space-2);
  font-size: 1.25rem;
}
.entry-title a {
  text-decoration: none;
  color: var(--fg);
}
.entry-title a:hover { color: var(--accent); text-shadow: var(--glitch-shadow); }
.entry-summary { color: var(--muted); }
.entry-summary p { margin: var(--space-2) 0 0; }

/* ---- Entry meta ---- */
.entry-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: var(--space-1);
}
.entry-meta a {
  color: var(--muted);
  text-decoration: none;
}
.entry-meta a:hover { color: var(--accent); }

/* ---- Article body ---- */
.entry-content > * + * { margin-top: var(--space-3); }
.entry-content h2, .entry-content h3 { margin-top: var(--space-6); }
.entry-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0 var(--space-3);
  margin: var(--space-4) 0;
  color: var(--muted);
  font-style: italic;
}
.entry-content code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  font-size: 0.9em;
}
.entry-content pre {
  background: var(--code-bg);
  padding: var(--space-3);
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.5;
}
.entry-content pre code { background: transparent; padding: 0; font-size: 1em; }
.entry-content hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--space-5) 0;
}
.entry-content ul, .entry-content ol { padding-left: var(--space-4); }
.entry-content li + li { margin-top: var(--space-2); }
.entry-content table {
  border-collapse: collapse;
  width: 100%;
  margin: var(--space-4) 0;
  font-size: 0.95rem;
  border: 3px solid var(--rule-strong);
}
.entry-content th, .entry-content td {
  border: 1px solid var(--rule);
  padding: var(--space-2) var(--space-3);
  text-align: left;
}
.entry-content th {
  background: var(--accent);
  color: var(--accent-fg);
  font-family: var(--font-heading);
  text-transform: uppercase;
}

/* ---- Why grid (homepage) ---- */
.why-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: 1fr;
  list-style: none;
  padding: 0;
  margin: var(--space-5) 0 0;
}
.why-card {
  position: relative;
  padding: var(--space-4);
  border: 2px solid var(--rule-strong);
  background: transparent;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.why-card:has(a:hover),
.why-card:has(a:focus-visible) {
  border-color: var(--accent);
}
.why-card:has(a:hover) .why-num,
.why-card:has(a:focus-visible) .why-num {
  color: var(--accent);
}
.why-card:has(a:hover) .why-title a,
.why-card:has(a:focus-visible) .why-title a {
  color: var(--accent);
  text-shadow: var(--glitch-shadow);
}
.why-num {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.15em;
  margin-bottom: var(--space-3);
  transition: color 0.15s ease;
}
.why-title {
  font-family: var(--font-heading);
  text-transform: uppercase;
  font-size: 1.15rem;
  margin: 0 0 var(--space-2);
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.why-title a {
  color: var(--fg);
  text-decoration: none;
  transition: color 0.15s ease, text-shadow 0.15s ease;
}
.why-title a:focus-visible { outline: none; }
.why-teaser {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.95rem;
  line-height: 1.55;
}

/* /why/ uses 90% on mobile (5% each side), 70% on wider screens (15% each side).
   Scoped to site-main so the header and footer containers keep their own widths. */
.page-why .site-main .container {
  max-width: 90%;
}
@media (min-width: 640px) {
  .page-why .site-main .container {
    max-width: 70%;
  }
}

/* Wide card (spans full grid width — used for card 09) */
@media (min-width: 640px) {
  .why-card--wide {
    grid-column: span 2;
  }
}

/* Punchline below the grid — hidden until selected */
.why-punchline {
  margin: var(--space-6) 0 var(--space-5);
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: var(--bg); /* matches page background — invisible in both themes */
  border-top: 1px solid var(--rule);
  padding-top: var(--space-5);
  font-style: italic;
  cursor: text;
  user-select: text;
}

.home-cta {
  margin-top: var(--space-6);
  padding: var(--space-4);
  border-left: 3px solid var(--accent);
  font-family: var(--font-mono);
  font-size: 0.95rem;
}
.home-cta p { margin: 0; }
.home-cta a {
  color: var(--fg);
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.home-cta a:hover { color: var(--accent); }

/* ---- Home hero + pitch ---- */
.hero-home {
  border-bottom: 0;
  padding: var(--space-7) 0 var(--space-3);
  margin-bottom: 0;
}
.hero-home h1 {
  font-size: clamp(2.5rem, 8vw + 1rem, 4.5rem);
  line-height: 0.95;
  letter-spacing: -2px;
  margin: 0 0 var(--space-2);
}
.hero-home .lede {
  font-size: 1.15rem;
}

.home-pitch {
  margin-top: var(--space-4);
  max-width: 62ch;
}
.home-pitch p {
  margin: var(--space-4) 0;
  font-size: 1.05rem;
}

.cta-primary {
  display: inline-block;
  margin: var(--space-3) 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-heading);
  text-transform: uppercase;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  background: var(--accent);
  color: var(--accent-fg);
  border: 1px solid var(--accent);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.cta-primary:hover,
.cta-primary:focus-visible {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
  text-decoration: none;
  text-shadow: var(--glitch-shadow);
}
/* ---- Split-pill CTA (homepage) ---- */
/* Two halves of one pill: unfilled by default, red/blue on hover.
   border-right on the first half creates the centre divider. */
.cta-pill-group {
  display: flex;
  margin: var(--space-5) 0 var(--space-5);
  border: 2px solid var(--fg);
  border-radius: 9999px;
  overflow: hidden;
  box-shadow: 4px 4px 0 var(--fg);
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
}
.cta-pill {
  flex: 1 1 0;
  padding: var(--space-3) var(--space-4);
  text-align: center;
  text-decoration: none;
  color: var(--fg);
  background: transparent;
  transition: background 0.18s ease, color 0.18s ease;
  line-height: 1.3;
}
.cta-pill--red {
  border-right: 2px solid var(--fg);
}
.cta-pill--red:hover,
.cta-pill--red:focus-visible {
  background: var(--accent);
  color: var(--accent-fg);
}
.cta-pill--blue:hover,
.cta-pill--blue:focus-visible {
  background: var(--accent-blue);
  color: #fff;
}

/* Secondary CTA used standalone (not in pill group) */
.cta-secondary {
  display: inline-block;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-heading);
  text-transform: uppercase;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--rule-strong);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.cta-secondary:hover,
.cta-secondary:focus-visible {
  background: transparent;
  border-color: var(--accent-2);
  color: var(--accent-2);
  text-decoration: none;
  text-shadow: -1px 0 rgba(var(--accent-2-rgb), 0.65), 1px 0 rgba(0, 255, 255, 0.5);
}

/* Section sub-headings (h4 used for Autonomy, Influence etc.) */
.entry-content h4 {
  font-size: 1rem;
  margin-top: var(--space-4);
  margin-bottom: var(--space-1);
  color: var(--accent);
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 0.85rem;
}

/* ---- Tag list ---- */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  padding: 0;
  margin: var(--space-4) 0 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
}
.tag-list a {
  text-decoration: none;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--rule);
  color: var(--muted);
}
.tag-list a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- Archive ---- */
.archive-year {
  margin: var(--space-5) 0 var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0.1em;
}
.archive-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.archive-list li {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--rule);
  align-items: baseline;
}
.archive-list time {
  flex: 0 0 4rem;
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}
.archive-list a {
  text-decoration: none;
  color: var(--fg);
}
.archive-list a:hover { color: var(--accent); }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-6);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}
.pagination a {
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--rule);
  color: var(--muted);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Contact icons ---- */
.contact-links {
  display: flex;
  gap: var(--space-3);
  margin: var(--space-5) 0;
}
.contact-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  color: var(--muted);
  border: 1px solid var(--rule);
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.contact-link:hover,
.contact-link:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}
.contact-link svg {
  width: 1.4rem;
  height: 1.4rem;
  display: block;
}

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: var(--space-4) 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}
.site-footer a {
  color: var(--muted);
  text-decoration: none;
}
.site-footer a:hover { color: var(--accent); }
.footer-row p { margin: 0; }

/* ---- Mobile spacing overrides ---- */
@media (max-width: 639px) {
  .site-main { padding-top: var(--space-3); }
  .site-main .container { max-width: 90%; }
  .hero { padding-top: var(--space-3); }
  .hero-home { padding-top: var(--space-4); }
  /* Punchline is a text-select Easter egg — not usable on touch; hide it to
     avoid the dead space it creates between the card grid and the CTA. */
  .why-punchline { display: none; }
  .home-cta { margin-top: var(--space-3); }
}

/* ---- Tablet ---- */
@media (min-width: 640px) {
  body { font-size: 1.125rem; }
  .brand { flex: 1 1 auto; }
  .site-nav { flex: 0 0 auto; order: 0; margin-left: auto; }
  .theme-toggle-label { order: 0; }
  .header-row { flex-wrap: nowrap; }
  .hero { padding: var(--space-7) 0 var(--space-5); }
  h1 { font-size: 2.5rem; }
  h2 { font-size: 1.75rem; }
  h3 { font-size: 1.3rem; }
  .entry-title { font-size: 1.4rem; }
  .why-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
  .why-title { font-size: 1.25rem; }
}

/* ---- Desktop ---- */
@media (min-width: 1024px) {
  :root { --container: 72ch; }
  .site-header .container { max-width: 96ch; }
  h1 { font-size: 3rem; }
  .hero h1 { font-size: clamp(2.5rem, 4vw + 1rem, 3.25rem); }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .neural-bg { display: none !important; }
  .glitch-overlay.is-active { animation: none !important; opacity: 0 !important; }
}

/* ---- Print ---- */
@media print {
  .site-header, .site-footer, .pagination, .skip-link, .theme-toggle-label,
  .neural-bg, .glitch-overlay { display: none; }
  body { color: #000; background: #fff; }
  a { color: #000; text-decoration: underline; }
  .entry-content pre, .entry-content code { background: #f4f4f4; color: #000; }
}
