/*! SandboxAnalysis — global header and footer (Terminal identity).
    Tokens mirror the SandboxAnalysis design system (same names, same values).
    Everything else is scoped to .sa-header / .sa-footer, so it cannot leak into Bricks content. */

/* 1. Tokens --------------------------------------------------------------- */

/* Dark is the default theme, whatever the visitor's system setting. */
:root {
  color-scheme: dark;

  --ground: #0a0f0c;
  --surface: #111813;
  --ink: #e4efe7;
  --ink-muted: #93a89a;
  --line: #223028;
  --line-strong: #5e7466;
  --brand: #3ce089;
  --on-brand: #06130b;
  --brand-tint: #0f2a1b;
  --benign: #5cc8f0;
  --suspicious: #f2b94b;
  --malicious: #ff7a6b;

  --font-display: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-12: 3rem;
  --space-24: 6rem;

  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 8px;
}

/* Light: only when the visitor picks it with the theme button. */
:root[data-theme="light"] {
  color-scheme: light;
  --ground: #f4f7f4;
  --surface: #ffffff;
  --ink: #0c1510;
  --ink-muted: #4a5d51;
  --line: #d3ddd6;
  --line-strong: #6b7f73;
  --brand: #086f3b;
  --on-brand: #ffffff;
  --brand-tint: #d5f0df;
  --benign: #0a6a8c;
  --suspicious: #855600;
  --malicious: #b3311e;
}

/* 2. Shared base ---------------------------------------------------------- */

.sa-header,
.sa-footer {
  font-family: var(--font-sans);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.sa-header *,
.sa-header *::before,
.sa-header *::after,
.sa-footer *,
.sa-footer *::before,
.sa-footer *::after {
  box-sizing: border-box;
}

.sa-header ul,
.sa-footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sa-header p,
.sa-footer p {
  margin: 0;
}

.sa-wrap {
  width: 100%;
  max-width: 76rem;
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.sa-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Focus: solid 2px ring, 2px offset, on every interactive element. */
.sa-header :focus-visible,
.sa-footer :focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Logo: one inline SVG, coloured by two custom properties so it follows the theme:
   the brackets and first word in ink, the cursor block and second word in brand green. */
.sa-logo {
  --sa-logo-ink: var(--ink);
  --sa-logo-accent: var(--brand);
  display: inline-flex;
  align-items: center;
  width: 15.75rem;
  max-width: 100%;
  min-height: 2.75rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
}

/* Scales down beside the Menu button on narrow screens; never below the 150px minimum. */
.sa-logo__art {
  display: block;
  width: 100%;
  height: auto;
}

.sa-header .sa-logo {
  flex: 1 1 9rem;
  min-width: 9.375rem;
  max-width: 15.75rem;
}

.sa-logo__ink { fill: var(--sa-logo-ink); }
.sa-logo__accent { fill: var(--sa-logo-accent); }

.sa-icon {
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sa-icon__fill {
  fill: currentColor;
  stroke: none;
}

.sa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: 2.75rem;
  min-height: 2.75rem;
  margin: 0;
  padding: 0 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}

.sa-btn:hover { background: var(--surface); }

.sa-btn--primary {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--on-brand);
}

.sa-btn--primary:hover {
  background: var(--brand);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* 3. Header --------------------------------------------------------------- */

.sa-header {
  background: var(--ground);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  font-size: 1rem;
  line-height: 1.5;
}

.sa-header__bar {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  min-height: 4.5rem;
  padding-block: 0.75rem;
}

.sa-header__panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
}

.sa-header__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.sa-nav__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
}

.sa-nav__link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-decoration: none;
}

.sa-nav__link:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.35em;
}

/* Current page or section: weight and a brand underline, never colour alone. */
.sa-nav__link[aria-current] {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--brand);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.35em;
}

.sa-search {
  display: flex;
  gap: var(--space-2);
  min-width: 0;
}

.sa-search__input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  margin: 0;
  padding: 0 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  appearance: none;
}

.sa-search__input::placeholder {
  color: var(--ink-muted);
  opacity: 1;
}

/* The three script-driven buttons stay hidden until the script is known to run. */
.sa-header__toggle,
.sa-header__search-toggle,
.sa-theme-toggle {
  display: none;
}

.sa-js .sa-theme-toggle {
  display: inline-flex;
}

/* Small screens: navigation, search and theme sit in a panel behind the Menu button.
   Without JavaScript the panel is simply always open. */
@media (max-width: 59.9375rem) {
  .sa-js .sa-header__toggle {
    display: inline-flex;
  }

  .sa-header__panel {
    flex: 1 0 100%;
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-4);
    padding-block: var(--space-2) var(--space-4);
  }

  .sa-js .sa-header__panel {
    display: none;
  }

  .sa-js .sa-header__panel.is-open {
    display: flex;
  }

  .sa-nav__list {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .sa-nav__link {
    display: flex;
    min-height: 3rem;
    padding-inline: var(--space-2);
    border-bottom: 1px solid var(--line);
    border-radius: 0;
  }

  .sa-header__actions {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-4);
  }

  .sa-theme-toggle {
    align-self: flex-start;
  }
}

/* Large screens: everything on one bar; search opens in a panel under its button. */
@media (min-width: 60rem) {
  .sa-js .sa-header__search-toggle {
    display: inline-flex;
  }

  .sa-js .sa-header__search {
    position: absolute;
    z-index: 20;
    inset-block-start: calc(100% - var(--space-2));
    inset-inline-end: var(--space-6);
    display: none;
    width: min(26rem, calc(100% - var(--space-12)));
    padding: var(--space-4);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: var(--surface);
  }

  .sa-js .sa-header__search.is-open {
    display: block;
  }

  .sa-btn--icon {
    padding: 0;
  }

  .sa-btn--icon .sa-btn__label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
}

/* 4. Footer --------------------------------------------------------------- */

/* The footer follows the theme with the header: light in light, dark in dark. */
.sa-footer {
  background: var(--surface);
  color: var(--ink);
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
  line-height: 1.5714;
}

.sa-footer__top {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-12) var(--space-6);
  padding-block: var(--space-12);
}

.sa-footer .sa-footer__desc {
  max-width: 24rem;
  margin-block: var(--space-6) var(--space-2);
  font-size: 1.0625rem;
  line-height: 1.75rem;
}

.sa-footer__note {
  max-width: 26rem;
  color: var(--ink-muted);
}

.sa-footer__nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: var(--space-6);
  align-content: start;
}

.sa-footer__heading {
  margin: 0 0 var(--space-2);
  padding: 0;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sa-footer__list a {
  display: inline-block;
  padding-block: 0.375rem;
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
}

.sa-footer__list a:hover,
.sa-footer__list a[aria-current] {
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.sa-footer__bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2) var(--space-6);
  padding-block: var(--space-6);
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
}

.sa-footer__bottom a {
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

@media (min-width: 48rem) {
  .sa-footer__top {
    grid-template-columns: minmax(16rem, 1.25fr) minmax(0, 2fr);
    gap: var(--space-12);
  }
}

/* 5. Preferences and output ----------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .sa-btn,
  .sa-search__input {
    transition: background-color 120ms ease-out, border-color 120ms ease-out;
  }
}

/* Windows High Contrast and other forced-colour modes. */
@media (forced-colors: active) {
  .sa-logo__ink { fill: CanvasText; }
  .sa-logo__accent { fill: Highlight; }
  .sa-footer { border-top: 1px solid CanvasText; }
  .sa-nav__link[aria-current] { text-decoration-color: currentColor; }
}

@media print {
  .sa-header__toggle,
  .sa-header__panel,
  .sa-footer__nav {
    display: none !important;
  }

  .sa-header,
  .sa-footer {
    background: none;
    color: #000;
  }

  .sa-header .sa-logo,
  .sa-footer .sa-logo { --sa-logo-ink: #000; --sa-logo-accent: #000; }
  .sa-footer__note,
  .sa-footer__bottom,
  .sa-footer__bottom a { color: #000; }
}
