/*
  [CORE CONCEPT]: "Phosphor terminal" theme.
  One palette shared by every page (page CSS files only use these variables).
  Body text uses the system monospace stack = zero font downloads; only the
  One self-hosted VT323 (~12 KB) for the ASCII logo only; titles use system mono so ąęł render cleanly.
*/
@font-face {
  font-family: "VT323";
  src: url("fonts/vt323.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  /* Pixel glyphs only for basic Latin; Polish letters fall back to --mono if VT323 is ever picked. */
  unicode-range: U+0020-007E, U+00A9, U+2014;
}

:root {
  --bg: #0b0f0c;
  --bg-2: #121813;
  --bg-code: #070a08;
  --line: #2b362d;
  --fg: #c9d3c9;
  --fg-soft: #a9b5aa;
  /* Dim text still passes WCAG AA (~5.3:1 on --bg). */
  --dim: #7b8b7d;
  --amber: hsl(39, 98%, 49%);
  --amber-deep: hsl(39, 90%, 22%);
  --green: #1bfe02;
  --green-soft: #4ade80;
  --green-deep: #1d6b12;
  --green-unlit: #187a0a;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo,
    Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
  --pixel: "VT323", var(--mono);
  /* Titles and UI headings: mono with weight, not VT323 (Polish diacritics). */
  --title: var(--mono);

  color-scheme: dark;
  scrollbar-color: var(--green-deep) var(--bg);
}

@keyframes blink {
  0%, 13%, 50% { opacity: 1; }
  51%, 78%, 100% { opacity: 0; }
}

/*
  [CORE CONCEPT]: Power flicker effect (przerwa w prądzie)
  Lit letters glow #1bfe02 and briefly go dark (opacity → 0) like a failing bulb.
  15s loop with 4 short blinks (~100ms each); different animation-delay per letter.
  Only opacity is animated, so the browser runs it on the compositor (no repaints).
*/
@keyframes glitch {
  0%, 100% { opacity: 1; }
  /* Blink 1: power cut ~0.1s */
  12.00% { opacity: 1; }
  12.33% { opacity: 0; }
  12.66% { opacity: 1; }

  /* Blink 2: power cut ~0.08s */
  34.50% { opacity: 1; }
  34.70% { opacity: 0; }
  34.90% { opacity: 1; }

  /* Blink 3: double (power jerks twice) */
  58.00% { opacity: 1; }
  58.20% { opacity: 0; }
  58.35% { opacity: 1; }
  58.50% { opacity: 0; }
  58.70% { opacity: 1; }

  /* Blink 4: single */
  79.00% { opacity: 1; }
  79.25% { opacity: 0; }
  79.50% { opacity: 1; }
}

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

html {
  /* Fluid base size: 15px on phones up to 18px on wide screens, no breakpoints needed. */
  font-size: clamp(15px, 13.5px + 0.35vw, 18px);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/*
  CRT overlay: scanlines + soft vignette in ONE fixed layer.
  It is painted once and only composited on scroll; pointer-events: none keeps
  it from blocking clicks.
*/
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgb(0 0 0 / 0.16) 0 1px,
      transparent 1px 3px
    ),
    radial-gradient(ellipse at center, transparent 55%, rgb(0 0 0 / 0.45) 100%);
}

::selection {
  background: var(--green);
  color: var(--bg);
}

h2, h3 {
  scroll-margin-top: 2rem;
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible {
  outline: 2px dashed var(--amber);
  outline-offset: 3px;
}

.container {
  width: min(100% - 2.5rem, 820px);
  margin-inline: auto;
}

          /*  header  */
/*
  The two wrapper divs from the template are flattened with display: contents,
  so logo, language switch, nav and intro can be placed on one grid.
*/
header {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "logo  lang"
    "nav   nav"
    "intro intro";
  align-items: center;
  gap: 0.9rem 1.5rem;
  padding-block: 2rem 1.5rem;
  border-bottom: 1px dashed var(--line);
}

header > div {
  display: contents;
}

header > div > a {
  grid-area: logo;
  justify-self: start;
}

header h1 {
  margin: 0;
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(2.4rem, 1.6rem + 3vw, 3.4rem);
  line-height: 1;
  color: var(--green-unlit);
  letter-spacing: 0.02em;
}

  /*  h1 glitch effect - different delays = each letter "goes dark" at another moment  */
#glitch-heading1,
#glitch-heading2,
#glitch-heading3,
#glitch-heading4 {
  color: var(--green);
  text-shadow: 0 0 8px rgb(27 254 2 / 0.55);
}

#glitch-heading1 { animation: glitch 15s infinite; animation-delay: 0.5s; }
#glitch-heading2 { animation: glitch 15s infinite; animation-delay: 4.2s; }
#glitch-heading3 { animation: glitch 15s infinite; animation-delay: 8.7s; }
#glitch-heading4 { animation: glitch 15s infinite; animation-delay: 2.1s; }

/* Block cursor instead of "_": the underscore stays in the DOM (screen readers), but is hidden. */
.cursor {
  display: inline-block;
  width: 0.5em;
  height: 0.8em;
  margin-left: 0.08em;
  background: var(--green);
  color: transparent;
  box-shadow: 0 0 8px rgb(27 254 2 / 0.55);
  animation: blink 1s step-end infinite;
}

header nav {
  grid-area: nav;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  font-size: 0.9rem;
}

/* Nav items look like paths: ~/home ~/contact ~/blogroll */
nav a {
  padding: 0.05rem 0.35rem;
  margin-left: -0.35rem;
  text-transform: lowercase;
}

nav a::before {
  content: "~/";
  color: var(--dim);
}

/* Classic "inverse video" hover from old terminals. */
nav a:hover,
nav a:focus-visible {
  background: var(--amber);
  color: var(--bg);
}

nav a:hover::before,
nav a:focus-visible::before {
  color: inherit;
}

  /*  language switch (the class is on both the wrapper div and the ul)  */
div.languages {
  grid-area: lang;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--dim);
}

div.languages p {
  margin: 0;
  text-transform: lowercase;
}

ul.languages {
  display: flex;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
}

.languages li {
  list-style-type: none;
}

.languages a {
  display: block;
  padding: 0 0.4rem;
  border: 1px solid transparent;
  color: var(--fg-soft);
}

.languages a:hover {
  color: var(--amber);
}

a.active {
  /* WCAG AA compliant: #4ade80 on --bg ≈ 10:1 contrast */
  color: var(--green-soft);
}

.languages a.active {
  border-color: currentColor;
}

  /*  intro text rendered as the output of a shell command  */
header > div > p {
  grid-area: intro;
  max-width: 68ch;
  margin: 0;
  padding-left: 1rem;
  border-left: 2px solid var(--green-deep);
  color: var(--fg-soft);
  font-size: 0.88rem;
}

header > div > p::before {
  content: "$ cat ~/readme.txt";
  display: block;
  margin-bottom: 0.3rem;
  color: var(--green-soft);
}

footer {
  margin: 4rem auto 2rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--line);
  text-align: center;
  font-size: 0.8rem;
  color: var(--dim);
}

footer::before {
  content: "-- EOF --";
  display: block;
  margin-bottom: 0.3rem;
  letter-spacing: 0.2em;
  color: var(--green-deep);
}

@media (max-width: 600px) {
  /* Phones: logo on top, language switch below it, then nav and intro. */
  header {
    grid-template-columns: 1fr;
    grid-template-areas:
      "logo"
      "lang"
      "nav"
      "intro";
    padding-top: 1.5rem;
  }
  div.languages {
    justify-self: start;
  }
}

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

@media print {
  body::after {
    display: none;
  }
}
