/*
 * One stylesheet for every guide site. sitegen/build.py copies this file to
 * sites/<domain>/assets/site.css. Edit it here, never in sites/.
 *
 * The colors are the Firezone brand palette from firezone/website
 * (src/brand/palette.mjs), and the diagram rules follow the `paper` canvas of
 * the Figure framework there: white ground, grey panels, near-white cards,
 * heavy connectors, no shadows, and no gradients.
 */

:root {
  /* night-rider: warm neutrals */
  --ink: #1b140e;
  --ink-2: #4c3e33;
  --muted: #766a60;
  --line: #dfdedd;
  --panel: #ebebea;
  --wash: #f8f7f7;
  --surface: #fcfcfc;
  --paper: #ffffff;
  --night: #050505;

  /* heat-wave: user traffic, tunnels, Resources, and the main action */
  --orange: #ff7300;
  --orange-deep: #c25700;
  --peach: #ffbc85;
  --peach-wash: #fff1e5;

  /* electric-violet: the control plane, identity, policy */
  --violet: #5e00d6;
  --violet-light: #a585ff;
  --violet-wash: #ece5ff;

  /* state */
  --green: #15803d;
  --green-wash: #dcfce7;
  --red: #dc2626;
  --red-wash: #fecaca;

  --sans: Roboto, "Helvetica Neue", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --mono: "Roboto Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --gutter: clamp(16px, 4vw, 40px);
  --page: 1120px;
  --rule: 3px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.65 var(--sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration-color: var(--orange);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--orange-deep);
}

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

code {
  font: 500 0.88em var(--mono);
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.08em 0.35em;
  overflow-wrap: anywhere;
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: var(--gutter);
  top: 8px;
  z-index: 10;
  background: var(--paper);
  padding: 8px 12px;
}

/* Masthead: the domain is the wordmark, set like an address. */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  max-width: var(--page);
  margin: 0 auto;
  padding: 18px var(--gutter);
  border-bottom: var(--rule) solid var(--ink);
}

.masthead a {
  text-decoration: none;
}

.masthead-domain {
  font: 600 1.02rem var(--mono);
  letter-spacing: -0.01em;
}

.masthead-domain::before {
  content: "";
  display: inline-block;
  width: 0.62em;
  height: 0.62em;
  margin-right: 0.6em;
  border-radius: 50%;
  background: var(--orange);
}

.masthead-by {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-2);
}

.fz-mark {
  width: 0.72em;
  height: 1.1em;
  fill: var(--orange);
  flex: none;
}

/* Hero */

main {
  display: block;
}

.hero {
  max-width: var(--page);
  margin: 0 auto;
  padding: clamp(40px, 8vw, 88px) var(--gutter) clamp(28px, 5vw, 48px);
}

h1 {
  max-width: 17ch;
  margin: 0;
  font-size: clamp(2.3rem, 6.4vw, 4.4rem);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.lede {
  max-width: 60ch;
  margin: 24px 0 0;
  font-size: clamp(1.1rem, 2vw, 1.3rem);
  line-height: 1.5;
  color: var(--ink-2);
  text-wrap: pretty;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 32px 0 0;
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 10px 22px;
  border: 2px solid var(--orange);
  border-radius: 3px;
  background: var(--orange);
  color: var(--night);
  font-weight: 700;
  text-decoration: none;
}

.button:hover {
  background: var(--peach);
  border-color: var(--peach);
  color: var(--night);
}

.button--quiet {
  background: transparent;
  border-color: var(--ink);
  color: var(--ink);
}

.button--quiet:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

/* Figure: the diagram and its steps */

.figure {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.figure-scroll {
  overflow-x: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 20px 0;
}

.dg {
  display: block;
  width: 100%;
  min-width: 620px;
  max-width: 960px;
  height: auto;
  margin: 0 auto;
  font-family: var(--sans);
}

.dg-panel rect {
  fill: var(--panel);
}

.dg-panel text {
  fill: var(--ink-2);
  font-size: 12.5px;
  font-weight: 700;
}

.dg-node rect {
  fill: var(--surface);
  stroke: var(--ink);
  stroke-width: 2;
}

.dg-node text {
  text-anchor: middle;
  fill: var(--ink);
}

.dg-label {
  font-size: 14.5px;
  font-weight: 700;
}

.dg-sub {
  font-size: 11.5px;
  font-weight: 500;
  fill: var(--ink-2);
}

.dg-node--traffic rect {
  fill: var(--peach-wash);
  stroke: var(--orange);
}

.dg-node--control rect {
  fill: var(--violet-wash);
  stroke: var(--violet);
}

.dg-node--ok rect {
  fill: var(--green-wash);
  stroke: var(--green);
}

.dg-node--blocked rect {
  fill: var(--red-wash);
  stroke: var(--red);
}

.dg-node--ghost rect {
  fill: none;
  stroke: var(--muted);
  stroke-dasharray: 5 5;
}

.dg-edge path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
}

.dg-edge-label {
  text-anchor: middle;
  font-size: 11.5px;
  font-weight: 700;
  fill: var(--ink);
}

.dg-edge-label[text-anchor="start"] {
  text-anchor: start;
}

.dg-edge-label[text-anchor="end"] {
  text-anchor: end;
}

.dg-edge--traffic path {
  stroke: var(--orange);
}

.dg-edge--control path {
  stroke: var(--violet);
  stroke-width: 2.5;
  stroke-dasharray: 7 6;
}

.dg-edge--blocked path {
  stroke: var(--red);
  stroke-dasharray: 3 6;
}

.dg-marker path {
  fill: var(--ink);
  stroke: none;
}

.dg-marker--traffic path {
  fill: var(--orange);
}

.dg-marker--control path {
  fill: var(--violet);
}

.dg-marker--blocked path {
  stroke: var(--red);
}

.dg [data-dg] {
  transition: opacity 0.2s ease;
}

.dg .is-dim {
  opacity: 0.16;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0 28px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  counter-increment: step;
  padding: 16px 0 12px;
  border-top: var(--rule) solid var(--line);
}

.steps h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  line-height: 1.3;
}

.steps h3::before,
.steps button::before {
  content: counter(step) ". ";
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.steps p {
  margin: 0;
  font-size: 0.93rem;
  line-height: 1.5;
  color: var(--ink-2);
}

/* With JavaScript, each step title is a button that lights its part. */

.steps button {
  all: unset;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

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

.is-enhanced .steps h3::before {
  content: none;
}

.is-enhanced .steps li {
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.is-enhanced .steps li:hover {
  border-top-color: var(--peach);
}

.is-enhanced .steps li.is-active {
  border-top-color: var(--orange);
}

.figure figcaption {
  margin-top: 8px;
  font-size: 0.88rem;
  color: var(--muted);
}

/* Columns: a table of contents beside the text */

.columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 56px;
  max-width: var(--page);
  margin: 0 auto;
  padding: clamp(32px, 6vw, 64px) var(--gutter);
}

.toc {
  display: none;
}

@media (min-width: 960px) {
  .columns {
    grid-template-columns: 200px minmax(0, 1fr);
  }

  .toc {
    display: block;
    position: sticky;
    top: 24px;
    align-self: start;
    font-size: 0.9rem;
  }
}

.toc-title {
  margin: 0 0 10px;
  font-weight: 700;
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  border-left: 2px solid var(--line);
}

.toc a {
  display: block;
  margin-left: -2px;
  padding: 5px 0 5px 14px;
  border-left: 2px solid transparent;
  color: var(--muted);
  line-height: 1.35;
  text-decoration: none;
}

.toc a:hover {
  color: var(--ink);
}

.toc a.is-current {
  border-left-color: var(--orange);
  color: var(--ink);
  font-weight: 600;
}

.prose {
  max-width: 720px;
}

.section + .section {
  margin-top: clamp(40px, 6vw, 64px);
}

.section h2 {
  margin: 0 0 16px;
  font-size: clamp(1.5rem, 3.2vw, 2rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.section h3 {
  margin: 28px 0 8px;
  font-size: 1.12rem;
  line-height: 1.3;
}

.section p,
.section ul,
.section ol {
  margin: 0 0 16px;
}

.section ul,
.section ol {
  padding-left: 1.3em;
}

.section li + li {
  margin-top: 6px;
}

.section li::marker {
  color: var(--orange-deep);
  font-weight: 700;
}

.fineprint {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
}

/* A short remark that the reader must not miss. */

.callout {
  margin: 20px 0;
  padding: 14px 18px;
  border-left: var(--rule) solid var(--violet);
  background: var(--violet-wash);
}

.callout > :last-child {
  margin-bottom: 0;
}

/* Tables */

.table-scroll {
  overflow-x: auto;
  margin: 20px 0 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
  line-height: 1.4;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

thead th {
  border-bottom: var(--rule) solid var(--ink);
  font-weight: 700;
  vertical-align: bottom;
}

thead td {
  border-bottom: var(--rule) solid var(--ink);
}

tbody th {
  font-weight: 600;
}

.compare {
  min-width: 560px;
}

.compare .is-us {
  background: var(--peach-wash);
}

.compare thead .is-us {
  border-bottom-color: var(--orange);
}

.cell {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}

.cell-mark {
  width: 0.72em;
  height: 0.72em;
  border-radius: 50%;
  border: 2px solid currentColor;
  flex: none;
}

.cell--yes {
  color: var(--green);
}

.cell--yes .cell-mark {
  background: currentColor;
}

.cell--no {
  color: var(--muted);
}

.cell--partial {
  color: var(--orange-deep);
}

.cell--partial .cell-mark {
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

.cell-note {
  display: block;
  margin-top: 3px;
  font-size: 0.85rem;
  color: var(--ink-2);
}

/* Widgets */

.widget {
  margin: 24px 0;
  padding: 20px;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.widget label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

.widget input[type="text"],
.widget input[type="number"],
.widget select {
  width: 100%;
  min-height: 46px;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  background: var(--paper);
  color: var(--ink);
  font: 500 1rem var(--mono);
}

.section .widget-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
}

.widget-examples li + li {
  margin-top: 0;
}

.widget-examples button,
.triage-restart {
  padding: 4px 10px;
  border: 1px solid var(--muted);
  border-radius: 3px;
  background: var(--paper);
  color: var(--ink);
  font: 500 0.85rem var(--mono);
  cursor: pointer;
}

.widget-examples button:hover,
.triage-restart:hover {
  border-color: var(--ink);
}

.widget-result {
  min-height: 3.2em;
  margin: 14px 0 6px;
  padding: 10px 14px;
  border-left: var(--rule) solid var(--muted);
  background: var(--paper);
  font-weight: 600;
}

.widget-result[data-kind="traffic"] {
  border-left-color: var(--orange);
}

.widget-result[data-kind="control"] {
  border-left-color: var(--violet);
}

.widget-result[data-kind="blocked"] {
  border-left-color: var(--red);
}

.widget-result[data-kind="ok"] {
  border-left-color: var(--green);
}

.widget-result small {
  display: block;
  font-weight: 400;
  color: var(--ink-2);
}

.matcher-rules {
  margin-top: 12px;
  background: var(--paper);
}

.matcher-rules code {
  overflow-wrap: normal;
  white-space: nowrap;
}

.matcher-rules tr.is-match td {
  background: var(--peach-wash);
  font-weight: 600;
}

.triage-node + .triage-node {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.triage.is-enhanced .triage-node {
  display: none;
  margin: 0;
  padding: 0;
  border: 0;
}

.triage.is-enhanced .triage-node.is-current {
  display: block;
}

.triage-question,
.triage-answer {
  margin: 0 0 12px;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.3;
}

.triage-answer::before {
  content: "";
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  margin-right: 0.5em;
  border-radius: 50%;
  background: var(--orange);
}

.section .triage-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.triage-options li + li {
  margin-top: 0;
}

.triage-options a {
  display: inline-block;
  padding: 9px 16px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  background: var(--paper);
  font-weight: 600;
  text-decoration: none;
}

.triage-options a:hover {
  background: var(--ink);
  color: var(--paper);
}

.triage-result > div > :last-child {
  margin-bottom: 0;
}

.triage-restart {
  margin-top: 16px;
}

.overhead-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
}

.overhead-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
  font-weight: 500;
}

.overhead-check input {
  width: 20px;
  height: 20px;
  accent-color: var(--orange);
}

.overhead-out {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin: 18px 0 0;
}

.overhead-out div {
  padding: 10px 14px;
  border-left: var(--rule) solid var(--orange);
  background: var(--paper);
}

.overhead-out dt {
  font-size: 0.85rem;
  color: var(--ink-2);
}

.overhead-out dd {
  margin: 2px 0 0;
  font: 600 1.35rem var(--mono);
}

.overhead-bar {
  display: flex;
  height: 14px;
  margin-top: 18px;
  background: var(--panel);
}

.overhead-bar span {
  background: var(--orange);
  transition: width 0.2s ease;
}

/* Questions */

.faq details {
  border-top: 1px solid var(--line);
}

.faq details:last-child {
  border-bottom: 1px solid var(--line);
}

.faq summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  font-weight: 700;
  line-height: 1.35;
  cursor: pointer;
  list-style: none;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "+";
  flex: none;
  font: 500 1.4rem/1 var(--mono);
  color: var(--orange-deep);
  transition: transform 0.2s ease;
}

.faq details[open] summary::after {
  transform: rotate(45deg);
}

.faq details > div {
  padding: 0 0 18px;
  max-width: 62ch;
}

.faq details > div > :last-child {
  margin-bottom: 0;
}

/* What to do next */

.next {
  background: var(--night);
  color: var(--surface);
}

.next-inner {
  max-width: var(--page);
  margin: 0 auto;
  padding: clamp(48px, 8vw, 88px) var(--gutter);
}

.next h2 {
  max-width: 20ch;
  margin: 0;
  font-size: clamp(1.9rem, 4.6vw, 3rem);
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.next-inner > p:not(.actions) {
  max-width: 58ch;
  margin: 18px 0 0;
  font-size: 1.1rem;
  color: var(--line);
}

.next .button--quiet {
  border-color: var(--surface);
  color: var(--surface);
}

.next .button--quiet:hover {
  background: var(--surface);
  color: var(--night);
}

.next-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0 32px;
  margin: 48px 0 0;
  padding: 0;
  list-style: none;
}

.next-links a {
  display: block;
  height: 100%;
  padding: 16px 0 20px;
  border-top: var(--rule) solid var(--ink-2);
  color: inherit;
  text-decoration: none;
}

.next-links a:hover {
  border-top-color: var(--orange);
}

.next-links strong {
  display: block;
  font-size: 1.05rem;
}

.next-links span {
  display: block;
  margin-top: 4px;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--line);
}

/* Footer */

.footer {
  max-width: var(--page);
  margin: 0 auto;
  padding: 32px var(--gutter) 48px;
  font-size: 0.9rem;
  color: var(--ink-2);
}

.footer p {
  margin: 0 0 12px;
}

.footer p:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 500;
}

.footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition: none !important;
  }
}

@media print {
  .toc,
  .actions,
  .widget-examples {
    display: none;
  }
}
