/* ctrouille demo — the look of the-nerd-lab.fr (its nerdlab theme, over
   Olivero): a warm graph-paper page, the lab's gradient (violet, pink,
   orange), and "sticker" panels (an ink outline and an offset shadow in a
   colour of their own).  Light only, like the site. */

:root {
  --bg: #fffaf3;
  --grid-line: rgba(124, 58, 237, 0.07);
  --surface: #ffffff;
  --ink: #1b1530;
  --muted: #5f5876;
  --line: #e8e0f6;
  --brand: #7c3aed;
  --primary: #7c3aed;
  --on-primary: #ffffff;
  --primary-soft: #f5f3ff;
  --focus-ring: #7c3aed;

  --violet: #7c3aed;
  --pink: #ec4899;
  --yellow: #facc15;
  --cyan: #06b6d4;
  --gradient: linear-gradient(120deg, #7c3aed 0%, #ec4899 55%, #fb923c 100%);
  --outline: 2px solid var(--ink);

  --code-bg: #ffffff;
  --code-gutter: #f6f2ff;
  --code-ink: #1b1530;
  --code-muted: #8f88a8;

  --error: #b42318;
  --error-dot: #e0412f;
  --error-band: rgba(224, 65, 47, 0.13);
  --warning: #93370d;
  --warning-dot: #f79009;
  --warning-band: rgba(247, 144, 9, 0.16);
  --note: #475467;
  --note-dot: #98a2b3;
  --note-band: rgba(152, 162, 179, 0.18);
  --focus-band: rgba(124, 58, 237, 0.22);

  --radius: 22px;
  --code-font: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --code-size: 13px;
  --code-line: 20px;
  --code-pad: 12px;

  color-scheme: light;
}

/* A phone zooms into a textarea whose font is below 16px. */
@media (max-width: 640px), (pointer: coarse) {
  :root {
    --code-size: 16px;
    --code-line: 24px;
  }
}

* {
  box-sizing: border-box;
}

/* Metropolis, the site's font, comes from Olivero (index.html links its
   fonts.css); elsewhere the system's. */
body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--ink);
  font: 16px/1.55 metropolis, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a {
  color: var(--primary);
}

::selection {
  background: var(--yellow);
  color: var(--ink);
}

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

.wrap {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ------------------------------------------------------------ masthead */

/* The site's header ends on the gradient: the demo starts with it. */
.masthead {
  position: relative;
  overflow: hidden;
  border-top: 6px solid transparent;
  border-image: var(--gradient) 1;
  padding: 32px 0 12px;
}

.masthead::before {
  position: absolute;
  top: -12rem;
  right: -10rem;
  width: 36rem;
  height: 36rem;
  content: "";
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(236, 72, 153, 0.16) 0%, transparent 65%);
}

.masthead .wrap {
  position: relative;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0.3rem 0.85rem;
  border: var(--outline);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 3px 3px 0 var(--ink);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.eyebrow a {
  color: var(--violet);
  text-decoration: none;
}

.eyebrow a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

h1 {
  margin: 16px 0 8px;
  color: var(--ink);
  font-size: clamp(2.3rem, 1.3rem + 4vw, 3.6rem);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.025em;
}

.lede {
  max-width: 62ch;
  margin: 0 0 16px;
  color: #4a4361;
  font-size: 1.08rem;
}

.engine {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0.4rem 0.85rem;
  border: 1.5px solid #c4b5fd;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}

.engine[data-kind="wasm"],
.engine[data-kind="local"] {
  border-color: #a3e635;
  background: #f7fee7;
}

.engine[data-kind="static"] {
  border-color: #fcd34d;
  background: #fef9c3;
}

.engine::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.engine[data-kind="wasm"]::before,
.engine[data-kind="local"]::before {
  background: #4d7c0f;
}

.engine[data-kind="static"]::before {
  background: var(--warning-dot);
}

/* ------------------------------------------------------------ workspace */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  padding-top: 24px;
  padding-bottom: 32px;
}

@media (min-width: 1000px) {
  .workspace {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    align-items: start;
  }
}

/* The site's catalog cards: an ink outline, an offset shadow of a colour of
   its own.  The shadow stays inside the page's gutter (16px). */
.panel {
  min-width: 0;
  background: var(--surface);
  border: var(--outline);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 var(--violet);
  padding: 20px;
}

.results-panel {
  box-shadow: 6px 6px 0 var(--cyan);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 12px;
}

h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 800;
}

.picker {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

select {
  min-width: 0;
  max-width: 100%;
  padding: 6px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
}

/* ------------------------------------------------------------ editor */

.editor {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  height: clamp(340px, 60vh, 700px);
  border: var(--outline);
  border-radius: 14px;
  overflow: hidden;
  background: var(--code-bg);
  font-family: var(--code-font);
  font-size: var(--code-size);
  line-height: var(--code-line);
}

.editor-gutter {
  overflow: hidden;
  padding: var(--code-pad) 0;
  border-right: 1.5px dashed var(--line);
  background: var(--code-gutter);
  color: var(--code-muted);
  text-align: right;
  user-select: none;
}

.gutter-line {
  position: relative;
  height: var(--code-line);
  padding: 0 10px 0 24px;
  font-variant-numeric: tabular-nums;
}

.gutter-line[data-level]::before {
  content: "";
  position: absolute;
  left: 9px;
  top: calc(50% - 4px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.gutter-line[data-level="error"]::before { background: var(--error-dot); }
.gutter-line[data-level="warning"]::before { background: var(--warning-dot); }
.gutter-line[data-level="note"]::before,
.gutter-line[data-level="none"]::before { background: var(--note-dot); }

.editor-body {
  position: relative;
  min-width: 0;
}

.editor-backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.editor-backdrop-inner {
  position: relative;
}

.band {
  position: absolute;
  left: 0;
  right: 0;
}

.band[data-level="error"] { background: var(--error-band); }
.band[data-level="warning"] { background: var(--warning-band); }
.band[data-level="note"],
.band[data-level="none"] { background: var(--note-band); }

.band.is-focused {
  background: var(--focus-band);
  animation: fade 1.6s ease-out forwards;
}

@keyframes fade {
  0%, 60% { opacity: 1; }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .band.is-focused { animation: none; }
}

.editor-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: var(--code-pad) 16px;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--code-ink);
  caret-color: var(--primary);
  font: inherit;
  white-space: pre;
  overflow: auto;
  tab-size: 4;
}

.editor:focus-within {
  box-shadow: 3px 3px 0 var(--pink);
}

/* ------------------------------------------------------------ actions */

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-top: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 20px;
  border: var(--outline);
  border-radius: 999px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

/* The site's primary button: ink, a pink shadow, yellow when pressed on. */
.button-primary {
  background: var(--ink);
  color: #fff;
  box-shadow: 4px 4px 0 var(--pink);
}

.button-primary:not(:disabled):hover,
.button-primary:not(:disabled):focus-visible {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--yellow);
}

.button-primary:disabled {
  opacity: 0.6;
  cursor: progress;
}

.button-quiet {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}

.button-quiet:hover,
.button-quiet:focus-visible {
  color: var(--violet);
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  .button { transition: none; }
  .button:hover,
  .button:focus-visible { transform: none; }
}

.shortcut {
  font-size: 0.78rem;
  font-weight: 500;
  opacity: 0.8;
}

@media (pointer: coarse) {
  .shortcut { display: none; }
}

.status {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ------------------------------------------------------------ results */

.results-panel {
  display: flex;
  flex-direction: column;
}

@media (min-width: 1000px) {
  .results-panel {
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
  }

  .results {
    overflow-y: auto;
    min-height: 0;
  }
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.tab:hover {
  border-color: var(--violet);
}

/* The language menu's current item, on the site. */
.tab[aria-selected="true"] {
  border: var(--outline);
  background: var(--violet);
  color: #fff;
  box-shadow: 2px 2px 0 var(--ink);
  font-weight: 800;
}

.tab[aria-selected="true"] .tab-count {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.tab-count {
  min-width: 1.6em;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--code-gutter);
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  background: var(--primary-soft);
  font-size: 0.92rem;
}

.notice[data-tone="error"] {
  border-left-color: var(--error-dot);
  background: var(--error-band);
}

.results.is-stale {
  opacity: 0.55;
}

.empty {
  margin: 8px 0;
  color: var(--muted);
}

.groups,
.findings,
.steps {
  margin: 0;
  padding: 0;
  list-style: none;
}

.group {
  padding: 12px 0;
  border-top: 1.5px dashed var(--line);
}

.group:first-child {
  border-top: 0;
  padding-top: 0;
}

.group-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.group-count {
  color: var(--muted);
  font-size: 0.85rem;
}

.line-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.group-line {
  font-size: 0.95rem;
  font-weight: 600;
}

/* A small sticker, its shadow the colour of its level. */
.finding {
  --level-color: var(--note-dot);
  margin: 10px 4px 0 0;
  padding: 10px 14px;
  border: 1.5px solid var(--ink);
  border-left: 6px solid var(--level-color);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 3px 3px 0 var(--level-color);
}

.finding[data-level="error"] { --level-color: var(--error-dot); }
.finding[data-level="warning"] { --level-color: var(--warning-dot); }

.finding-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.level {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--note);
}

.finding[data-level="error"] .level { color: var(--error); }
.finding[data-level="warning"] .level { color: var(--warning); }

.rule {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--code-gutter);
  font-family: var(--code-font);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.cwes {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cwe {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  padding: 1px 9px;
  border: 1.5px solid #c4b5fd;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #5b21b6;
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.cwe:hover {
  text-decoration: underline;
}

.cwe-name {
  color: var(--ink);
  font-weight: 400;
}

.message {
  margin: 6px 0 0;
  font-size: 0.93rem;
  overflow-wrap: anywhere;
}

.steps {
  margin-top: 8px;
  padding-left: 12px;
  border-left: 2px dashed var(--line);
  font-size: 0.88rem;
}

.steps li {
  padding: 2px 0;
}

.steps li > * + * {
  margin-left: 8px;
}

.step-kind {
  color: var(--muted);
  font-weight: 600;
}

.step-text {
  overflow-wrap: anywhere;
}

.step-state {
  color: var(--muted);
  font-family: var(--code-font);
  font-size: 0.8rem;
}

/* ------------------------------------------------------------ footer */

.footer {
  padding-bottom: 28px;
  color: var(--muted);
  font-size: 0.88rem;
}

.footer p {
  max-width: 80ch;
  margin: 4px 0;
}
