/* SPDX-FileCopyrightText: The glsec Authors */
/* SPDX-License-Identifier: Apache-2.0 */

/* Colours from the glsec logo: slate #28333e and orange #ff6403. */
:root {
  --slate: #28333e;
  --slate-deep: #1f2831;
  --orange: #ff6403;
  --on-slate: #f4f6f8;
  --on-slate-muted: #c7d0d9;

  --bg: #ffffff;
  --surface: #f5f7f9;
  --text: #1e2730;
  --muted: #5b6672;
  --line: #e1e6eb;
  --link: #c24a00;
  --code-bg: #eef1f4;
  /* glsec's terminal colours: red for errors, yellow for warnings. */
  --ansi-red: #c62828;
  --ansi-yellow: #8a6100;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151b21;
    --surface: #1c242c;
    --text: #e6eaee;
    --muted: #9aa6b2;
    --line: #2c3742;
    --link: #ff8a3d;
    --code-bg: #212b34;
    --ansi-red: #ff7b72;
    --ansi-yellow: #e3b341;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--link); text-underline-offset: 3px; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; }
:not(pre) > code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 3px; overflow-wrap: anywhere; }
pre {
  background: var(--code-bg);
  border-left: 3px solid var(--orange);
  border-radius: 0 4px 4px 0;
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.5;
}

/* Header and hero share the slate of the logo. */
.top { background: var(--slate); color: var(--on-slate); border-bottom: 3px solid var(--orange); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 1.35rem; letter-spacing: -0.01em; }
.brand-mark { width: 33px; height: 40px; }
.brand .gl { color: var(--on-slate); }
.brand .sec { color: var(--orange); }
.top nav { display: flex; gap: 22px; }
.top nav a { color: var(--on-slate-muted); text-decoration: none; font-weight: 500; }
.top nav a:hover, .top nav a[aria-current="page"] { color: var(--on-slate); box-shadow: 0 2px 0 var(--orange); }

.hero { background: var(--slate); color: var(--on-slate); padding: 56px 0 64px; }
.hero h1 { font-size: clamp(2rem, 4.6vw, 3rem); line-height: 1.12; letter-spacing: -0.02em; margin: 0 0 18px; }
.hero h1 code { background: none; padding: 0; color: var(--orange); font-size: 0.86em; }
.hero .lede { font-size: 1.1rem; color: var(--on-slate-muted); margin: 0; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 40px; align-items: center; }
@media (max-width: 860px) { .hero-grid { grid-template-columns: minmax(0, 1fr); } }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.button {
  display: inline-block; padding: 11px 20px; border-radius: 4px;
  background: var(--orange); color: var(--slate); text-decoration: none; font-weight: 700;
  border: 2px solid var(--orange);
}
.button.ghost { background: transparent; color: var(--on-slate); border-color: var(--on-slate-muted); }
.stats { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 32px; color: var(--on-slate-muted); font-size: 0.95rem; }
.stats strong { display: block; color: var(--on-slate); font-size: 1.6rem; line-height: 1.2; }
.stats a { color: inherit; text-decoration: none; }
.stats a strong { color: var(--orange); }

.terminal {
  background: var(--slate-deep); color: #e6eaee; border: 1px solid #3a4652; border-left: 3px solid var(--orange);
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.78rem; margin: 0;
}
.terminal .prompt { color: #9aa6b2; }
.terminal .more { color: #9aa6b2; }
.terminal .more a { color: var(--orange); }
.terminal .line { display: inline; }

/* The command is typed, then the findings appear line by line. Without
   animation support, or with reduced motion, everything is simply shown. */
@media (prefers-reduced-motion: no-preference) {
  .terminal .cmd {
    display: inline-block; vertical-align: bottom; overflow: hidden; white-space: pre;
    box-sizing: content-box; width: 22ch; border-right: 0.6em solid transparent;
    animation: type 0.9s steps(22) 0.3s both, caret 0.5s step-end 0.3s 3;
  }
  .terminal .line { animation: appear 0.15s ease-out both; animation-delay: calc(1.4s + var(--i) * 45ms); }
}
@keyframes type { from { width: 0; } to { width: 22ch; } }
@keyframes caret { 50% { border-right-color: #9aa6b2; } }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }

main > section { padding: 8px 0 24px; }
h2 { font-size: 1.5rem; margin: 48px 0 14px; letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; margin: 0 0 8px; }
.note { color: var(--muted); }

.cards { display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--slate); border-radius: 4px; padding: 18px 20px; min-width: 0; }
.card pre { margin: 10px 0; font-size: 0.84rem; }
.card p { margin: 8px 0 0; color: var(--muted); font-size: 0.95rem; }

.doc { padding-top: 28px; padding-bottom: 56px; }
.doc > p, .doc > ul, .doc > ol { max-width: 800px; }
.doc h1 { font-size: 2.1rem; line-height: 1.2; margin: 8px 0 22px; letter-spacing: -0.01em; }
.doc h2 { font-size: 1.3rem; margin-top: 40px; padding-left: 12px; border-left: 4px solid var(--orange); }
.doc hr { display: none; }
.rule-id {
  display: inline-block; background: var(--slate); color: var(--orange);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.75em;
  padding: 2px 10px; border-radius: 4px; margin-right: 8px; vertical-align: 0.12em;
}
.crumbs { color: var(--muted); margin: 0; font-size: 0.95rem; }
.crumbs a { color: var(--muted); }
.source { color: var(--muted); font-size: 0.95rem; margin-top: 44px; border-top: 1px solid var(--line); padding-top: 16px; }

table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; font-size: 0.95rem; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: var(--slate); color: var(--on-slate); font-weight: 600; }
/* Rule IDs in the overview stay on one line; other first columns wrap. */
td:first-child a { white-space: nowrap; }
/* A code span in a table wraps as a whole, never inside a name. */
td code { white-space: nowrap; }
tbody tr:hover { background: var(--surface); }

.bottom { background: var(--slate); color: var(--on-slate-muted); font-size: 0.9rem; padding: 18px 0 22px; margin-top: 40px; }
.bottom a { color: var(--on-slate); }

@media (max-width: 480px) {
  /* The links get their own row under the logo instead of overflowing. */
  .top-inner { height: auto; flex-wrap: wrap; row-gap: 6px; padding-top: 10px; padding-bottom: 8px; }
  .top nav { width: 100%; justify-content: space-between; font-size: 0.95rem; }
  .brand { font-size: 1.2rem; }
}

.risks { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; }
.risk { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--orange); border-radius: 4px; padding: 16px 20px; }
.risk-outside { border-left-color: var(--line); }
.risk-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.doc .risk h2 { border: none; padding: 0; margin: 0; font-size: 1.15rem; flex: 1 1 260px; }
.risk h2 a { color: var(--text); text-decoration: none; }
.risk h2 a:hover { text-decoration: underline; }
.risk-id { background: var(--slate); color: var(--orange); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8rem; padding: 2px 8px; border-radius: 3px; }
.risk-count { color: var(--muted); font-size: 0.9rem; }
.risk p { margin: 8px 0; max-width: none; }
.risk-rules { list-style: none; padding: 0; margin: 10px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 4px 20px; font-size: 0.93rem; }
.risk-rules a { color: var(--text); text-decoration: none; }
.risk-rules a:hover .rid, .risk-rules a:hover { color: var(--link); }
.rid { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--link); margin-right: 4px; }

.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 8px; }
.toc a { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 4px 10px; text-decoration: none; color: var(--text); font-size: 0.93rem; }
.toc a:hover { border-color: var(--orange); }
.report h2 code { font-size: 0.75em; font-weight: 500; margin-left: 6px; }
.report .where { color: var(--muted); }
.report .where strong { color: var(--text); }
details { margin: 10px 0; }
summary { cursor: pointer; font-weight: 600; color: var(--text); }
summary:hover { color: var(--link); }
pre.output { max-height: 520px; }

.shot { margin: 16px 0; }
.shot img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.shot figcaption { color: var(--muted); font-size: 0.9rem; margin-top: 6px; }

.ansi-bold { font-weight: 700; }
.ansi-red { color: var(--ansi-red); }
.ansi-yellow { color: var(--ansi-yellow); }
.terminal .ansi-red { color: #ff7b72; }
.terminal .ansi-yellow { color: #e3b341; }

/* Line numbers for the scanned file, so findings like bad-pipeline.yml:17 can be found. */
pre.numbered code { counter-reset: ln; }
pre.numbered .ln::before {
  counter-increment: ln; content: counter(ln);
  display: inline-block; width: 2.5ch; margin-right: 1.5ch; text-align: right;
  color: var(--muted); user-select: none;
}
