/* ==========================================================
   Vulnerability Demonstrations — stylesheet
   Concept: a security lab bench. The vulnerable output sits in
   a hazard-taped tray; the secured output in a clean, sealed one.
   ========================================================== */

@import url("https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,800&family=Atkinson+Hyperlegible:wght@400;700&family=JetBrains+Mono:wght@400;600&display=swap");

:root {
  --bg: #e9ecf2;          /* pale steel */
  --surface: #ffffff;
  --ink: #1a2233;
  --muted: #5b6577;
  --line: #c9cfdb;
  --vuln: #c2362f;        /* alarm red */
  --vuln-soft: #fbe9e7;
  --safe: #1f7a5a;        /* sealed green */
  --safe-soft: #e3f3ec;
  --focus: #3466d6;

  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131823;
    --surface: #1c2331;
    --ink: #e6eaf2;
    --muted: #9aa4b8;
    --line: #2f3849;
    --vuln: #ff6b5e;
    --vuln-soft: #3a1f22;
    --safe: #4cc79a;
    --safe-soft: #17312a;
    --focus: #7ea2ff;
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

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

html {
  background: var(--bg);
}

body {
  max-width: 46rem;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4.5rem) 1.25rem 5rem;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}

/* ---------- Headings ---------- */

h1 {
  margin: 0 0 2.5rem;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 7vw, 3.75rem);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.03em;
  padding-bottom: 1rem;
  border-bottom: 6px solid var(--ink);
}

h4 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 3rem 0 1rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

h4::before {
  content: "";
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  background: var(--ink);
}

/* "Vulnerable" and "Secured" headings get their status colour */
h4:nth-of-type(2)::before { background: var(--vuln); }
h4:nth-of-type(3)::before { background: var(--safe); }

h5 {
  margin: 0 0 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 400;
  color: var(--muted);
}

/* ---------- Play-along payloads ---------- */

#play-along {
  padding: 1.25rem 1.25rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

#play-along span {
  display: block;
}

#play-along pre {
  margin: 0 0 0.75rem;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  background: var(--bg);
  border: 1px dashed var(--line);
  border-left: 4px solid var(--muted);
  border-radius: 6px;
  transition: border-color 0.15s ease;
}

#play-along pre:hover {
  border-left-color: var(--vuln);
}

#play-along code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--ink);
  user-select: all;      /* one click selects the whole payload */
  cursor: copy;
}

/* ---------- Input rows ---------- */

div:has(> input) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

div:has(> input) > span {
  font-weight: 700;
}

input {
  flex: 1 1 14rem;
  min-width: 0;
  padding: 0.65rem 0.85rem;
  font: inherit;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 6px;
}

input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent);
}

button {
  padding: 0.65rem 1.25rem;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--ink);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
}

#btnv { background: var(--vuln); }
#btns { background: var(--safe); }

@media (prefers-color-scheme: dark) {
  button,
  #btnv,
  #btns { color: #10141c; }
}

button:hover  { filter: brightness(1.08); }
button:active { transform: translateY(1px); }

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

/* ---------- Response trays ---------- */

#responseVulnerable,
#responseSecured {
  min-height: 4.5rem;
  margin-top: 1rem;
  padding: 1.1rem 1.25rem;
  overflow-wrap: anywhere;
}

/* Vulnerable: hazard-taped tray */
#responseVulnerable {
  background: var(--vuln-soft);
  border: 6px solid;
  border-image: repeating-linear-gradient(
      -45deg,
      var(--vuln) 0 10px,
      var(--vuln-soft) 10px 20px
    ) 6;
}

/* Secured: clean, sealed tray */
#responseSecured {
  background: var(--safe-soft);
  border: 2px solid var(--safe);
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
}

/* Empty-state hint before anything is submitted */
#responseVulnerable:empty::before,
#responseSecured:empty::before {
  content: "Your response will appear here.";
  font-family: var(--font-body);
  font-style: italic;
  color: var(--muted);
}

/* Make injected markup in the vulnerable tray clearly visible */
#responseVulnerable a {
  color: var(--vuln);
  font-weight: 700;
}

#responseVulnerable img {
  max-width: 100%;
}

/* ---------- Small screens & motion ---------- */

@media (max-width: 480px) {
  button { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
