/* ==========================================================================
   PIXEL KINGDOM — core.css
   Design tokens, reset, typography, and shared primitives.
   ========================================================================== */

:root {
  /* —— Surfaces —— */
  --pk-bg: #171B2B;
  --pk-bg-2: #252C43;
  --pk-card: #303954;
  --pk-card-hi: #3A4566;
  --pk-ink: #0F1220;

  /* —— Text —— */
  --pk-text: #F8F4E3;
  --pk-text-dim: #B9BFD4;
  --pk-text-mute: #8A93AE;

  /* —— Accents —— */
  --pk-green: #8BD450;
  --pk-green-dk: #6BAE38;
  --pk-blue: #5DADE2;
  --pk-blue-dk: #3D87C4;
  --pk-orange: #F4A340;
  --pk-orange-dk: #D9822B;
  --pk-red: #E66B65;
  --pk-red-dk: #C24E48;
  --pk-purple: #8A6BE6;
  --pk-teal: #4EC9B0;
  --pk-pink: #E87FA8;
  --pk-yellow: #F7D64A;

  /* —— Lines & shadows (block shadows, never blur) —— */
  --pk-line: #46527A;
  --pk-line-soft: #333D5E;
  --pk-shadow: 6px 6px 0 rgba(9, 11, 21, 0.55);
  --pk-shadow-sm: 4px 4px 0 rgba(9, 11, 21, 0.5);
  --pk-shadow-inset: inset 0 0 0 2px rgba(15, 18, 32, 0.6);

  /* —— Type ——
     Pixelify Sans carries all display/UI type: it keeps the 8-bit voice while
     staying legible at heading *and* label sizes. Silkscreen is reserved for
     micro-labels at weight 400 only (its bold cut closes C/O counters). */
  --pk-font-pixel: 'Pixelify Sans', ui-monospace, monospace;
  --pk-font-display: 'Pixelify Sans', ui-monospace, monospace;
  --pk-font-micro: 'Silkscreen', 'Pixelify Sans', ui-monospace, monospace;
  --pk-font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* —— Metrics —— */
  --pk-shell: 1180px;
  /* Height available above the first ad slot. The ad's top edge must land in the
     0.40-0.45 viewport band. Measured from the rendered page: adTop =
     header + heroHeight + adMarginTop, so the hero height is 37vh minus the
     header, which puts the ad at ~0.42 of the viewport. */
  --pk-firstfold: calc(37vh - var(--pk-header-h));
  --pk-gutter: 24px;
  --pk-header-h: 76px;
  --pk-radius: 0px;      /* pixel UI is square-cornered */
  --pk-step: 4px;        /* 4px grid for pixel rhythm */

  /* —— Motion —— */
  --pk-ease: steps(3, end);
  --pk-t-fast: 120ms;
  --pk-t: 180ms;
}

/* The hero copy has a natural minimum height (roughly 300px at laptop widths).
   When the viewport is short, 42vh minus the header would be less than that, so
   the block is given the share it needs to show everything while the ad still
   lands in the 0.40-0.45 band. Values chosen per height band. */
@media (min-width: 701px) and (max-width: 1000px) {
  :root { --pk-firstfold: calc(46vh - var(--pk-header-h)); }
}
@media (max-width: 380px), (max-height: 700px) {
  :root { --pk-firstfold: calc(48vh - var(--pk-header-h)); }
}

/* —— Reset —— */
*, *::before, *::after { box-sizing: border-box; }

/* `hidden` must win over component display rules */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: clip;
  max-width: 100%;
}

body {
  margin: 0;
  font-family: var(--pk-font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--pk-text);
  background-color: var(--pk-bg);
  /* pixel grid texture */
  background-image:
    linear-gradient(rgba(93, 173, 226, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(93, 173, 226, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: center top;
  min-height: 100dvh;
  overflow-x: clip;
  max-width: 100%;
  overscroll-behavior-x: none;
  -webkit-font-smoothing: antialiased;
}

img, svg, video { display: block; max-width: 100%; height: auto; }
img { image-rendering: pixelated; }

figure { margin: 0; }

iframe {
  display: block;
  max-width: 100%;
  border: 0;
  vertical-align: bottom;
}

a { color: var(--pk-blue); text-decoration: none; }
a:hover { color: #8CC9F0; }

button, input, select, textarea { font: inherit; color: inherit; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--pk-font-pixel);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.1;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

ul, ol { margin: 0 0 12px; padding-left: 20px; }

:focus-visible {
  outline: 3px solid var(--pk-yellow);
  outline-offset: 2px;
}

::selection { background: var(--pk-green); color: var(--pk-ink); }

/* —— Shell —— */
.pk-shell {
  width: 100%;
  max-width: calc(var(--pk-shell) + var(--pk-gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--pk-gutter);
}

.pk-shell--narrow { max-width: calc(760px + var(--pk-gutter) * 2); }

/* —— Skip link —— */
.pk-skip {
  /* fixed, not absolute: an absolutely-positioned off-screen link still
     participates in the block flow at top:8px and pushes the header down. */
  position: fixed;
  left: -9999px;
  top: 8px;
  z-index: 999;
  padding: 10px 18px;
  background: var(--pk-yellow);
  color: var(--pk-ink);
  font-family: var(--pk-font-pixel);
  font-weight: 700;
  border: 3px solid var(--pk-ink);
}
.pk-skip:focus { left: 12px; }

/* —— Utility type —— */
.pk-eyebrow {
  font-family: var(--pk-font-display);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--pk-green);
  margin: 0 0 10px;
}

.pk-muted { color: var(--pk-text-mute); }

.pk-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.pk-no-scroll { overflow: hidden; overscroll-behavior: none; }

/* —— Pixel corner decoration (shared) —— */
.pk-pixel-corners {
  position: relative;
}
.pk-pixel-corners::before,
.pk-pixel-corners::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--pk-bg);
  pointer-events: none;
}
.pk-pixel-corners::before { top: -3px; left: -3px; }
.pk-pixel-corners::after { bottom: -3px; right: -3px; }

/* —— Reduced motion —— */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
