/* ==========================================================
   Learning Git — Matrix theme
   Vanilla CSS, no frameworks
   ========================================================== */

/* ---------- Theme variables ---------- */
:root {
  --bg: #000000;
  --bg-panel: rgba(0, 20, 0, 0.75);
  --green: #00ff41; /* classic Matrix green */
  --green-mid: #00c832;
  --green-dark: #008f11;
  --green-deep: #003b00;
  --text: #a8ffb8;
  --error: #ff3b3b;
  --glow: 0 0 4px var(--green), 0 0 12px rgba(0, 255, 65, 0.5);
  --font: "Courier New", Courier, "Lucida Console", monospace;
  --max-width: 900px;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---------- Page ---------- */
html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  /* faint "digital rain" columns */
  background-image:
    repeating-linear-gradient(
      90deg,
      rgba(0, 255, 65, 0.06) 0 2px,
      transparent 2px 28px
    ),
    linear-gradient(180deg, rgba(0, 59, 0, 0.45) 0%, var(--bg) 70%);
  background-size:
    28px 100%,
    100% 100%;
  animation: rain 6s linear infinite;
  position: relative;
  overflow-x: hidden;
}

/* CRT scanlines over everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.25) 0 1px,
    transparent 1px 3px
  );
  z-index: 10;
}

/* soft vignette */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    transparent 55%,
    rgba(0, 0, 0, 0.85) 100%
  );
  z-index: 9;
}

/* ---------- Title ---------- */
h1 {
  text-align: center;
  font-size: clamp(2.2rem, 6vw, 4rem);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--green);
  text-shadow: var(--glow);
  padding: 2.5rem 1rem 1rem;
  animation: flicker 4s infinite;
}

/* ---------- Header / nav ---------- */
header {
  border-top: 1px solid var(--green-dark);
  border-bottom: 1px solid var(--green-dark);
  background: rgba(0, 20, 0, 0.6);
  box-shadow: 0 0 18px rgba(0, 255, 65, 0.15);
}

header {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  padding: 0 1rem;
}

nav ul {
  list-style: none;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  padding: 0.9rem 0;
}

/* theme dropdown */
#style {
  font-family: var(--font);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--green);
  background: var(--bg);
  border: 1px solid var(--green-dark);
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

#style:hover,
#style:focus-visible {
  border-color: var(--green);
  box-shadow: var(--glow);
  outline: none;
}

#style option {
  background: var(--bg);
  color: var(--green);
}

nav a {
  position: relative;
  display: inline-block;
  padding: 0.3rem 0.9rem;
  color: var(--green-mid);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  border: 1px solid transparent;
  transition:
    color 0.2s,
    border-color 0.2s,
    box-shadow 0.2s,
    background 0.2s;
}

nav a::before {
  content: "> ";
  opacity: 0;
  transition: opacity 0.2s;
}

nav a:hover,
nav a:focus-visible {
  color: var(--bg);
  background: var(--green);
  border-color: var(--green);
  box-shadow: var(--glow);
  outline: none;
}

nav a:hover::before,
nav a:focus-visible::before {
  opacity: 1;
}

/* active page: outlined, glowing, with the prompt always shown */
nav li.active a {
  color: var(--green);
  background: rgba(0, 255, 65, 0.1);
  border-color: var(--green);
  text-shadow: var(--glow);
  box-shadow: inset 0 0 10px rgba(0, 255, 65, 0.25);
}

nav li.active a::before {
  opacity: 1;
}

nav li.active a:hover,
nav li.active a:focus-visible {
  color: var(--bg);
  background: var(--green);
  text-shadow: none;
}

/* ---------- Main content ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 3rem auto;
  padding: 2.5rem;
  background: var(--bg-panel);
  border: 1px solid var(--green-dark);
  box-shadow:
    0 0 25px rgba(0, 255, 65, 0.12),
    inset 0 0 40px rgba(0, 255, 65, 0.05);
  position: relative;
}

/* terminal-window style label */
main::before {
  content: "// terminal://learning-git";
  position: absolute;
  top: -0.8rem;
  left: 1.5rem;
  padding: 0 0.6rem;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--green-dark);
  background: var(--bg);
}

main h2 {
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  color: var(--green);
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.6);
  margin-bottom: 1.25rem;
}

main h2::before {
  content: "$ ";
  color: var(--green-dark);
}

/* blinking cursor after the heading */
main h2::after {
  content: "";
  display: inline-block;
  width: 0.6em;
  height: 1.1em;
  margin-left: 0.3em;
  vertical-align: text-bottom;
  background: var(--green);
  box-shadow: var(--glow);
  animation: blink 1s steps(1) infinite;
}

main p {
  color: var(--text);
  text-align: justify;
}

/* ---------- Contact form ---------- */
main form {
  display: grid;
  gap: 1.25rem;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px dashed var(--green-deep);
}

main form div {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* labels read like terminal prompts */
main form label {
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--green-mid);
}

main form label::before {
  content: "> ";
  color: var(--green-dark);
}

main form input,
main form textarea {
  width: 100%;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--green);
  caret-color: var(--green);
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--green-dark);
  padding: 0.65rem 0.85rem;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

main form textarea {
  min-height: 9rem;
  resize: vertical;
}

main form input:hover,
main form textarea:hover {
  border-color: var(--green-mid);
}

main form input:focus-visible,
main form textarea:focus-visible {
  border-color: var(--green);
  box-shadow:
    var(--glow),
    inset 0 0 10px rgba(0, 255, 65, 0.15);
  outline: none;
}

/* only flag errors after the visitor has interacted with the field */
main form input:user-invalid,
main form textarea:user-invalid {
  border-color: var(--error);
  box-shadow: 0 0 8px rgba(255, 59, 59, 0.5);
}

/* stop browsers painting autofilled fields white/yellow */
main form input:-webkit-autofill {
  -webkit-text-fill-color: var(--green);
  box-shadow: inset 0 0 0 1000px var(--bg);
  caret-color: var(--green);
}

/* submit button mirrors the nav links */
main form button {
  justify-self: start;
  font-family: var(--font);
  font-size: 1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--green);
  background: rgba(0, 255, 65, 0.1);
  border: 1px solid var(--green);
  padding: 0.6rem 1.6rem;
  cursor: pointer;
  text-shadow: var(--glow);
  box-shadow: inset 0 0 10px rgba(0, 255, 65, 0.25);
  transition:
    color 0.2s,
    background 0.2s,
    box-shadow 0.2s;
}

main form button::before {
  content: "> ";
}

main form button:hover,
main form button:focus-visible {
  color: var(--bg);
  background: var(--green);
  text-shadow: none;
  box-shadow: var(--glow);
  outline: none;
}

main form button:active {
  background: var(--green-mid);
}

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

/* ---------- Footer ---------- */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  border-top: 1px solid var(--green-deep);
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--green-dark);
}

footer p::before {
  content: "© ";
}

/* ---------- Animations ---------- */
@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes flicker {
  0%,
  92%,
  100% {
    opacity: 1;
  }
  93% {
    opacity: 0.6;
  }
  94% {
    opacity: 1;
  }
  96% {
    opacity: 0.75;
  }
}

@keyframes rain {
  from {
    background-position:
      0 0,
      0 0;
  }
  to {
    background-position:
      0 600px,
      0 0;
  }
}

/* ---------- Small screens ---------- */
@media (max-width: 600px) {
  h1 {
    letter-spacing: 0.15em;
    padding-top: 1.5rem;
  }
  main {
    margin: 1.5rem 1rem;
    width: auto;
    padding: 1.5rem;
  }
  main p {
    text-align: left;
  }
  main form button {
    justify-self: stretch;
  }
}

/* ---------- Respect reduced-motion users ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
