/* SafeGrd documentation layer.
 *
 * Loads after system.css and landing.css. It adds the two-column reading
 * layout the reference pages need and nothing else: every colour, size and
 * spacing value here resolves to a token defined in system.css, so a docs page
 * cannot quietly invent a shade the rest of the product does not have.
 */

/* --- Shell -------------------------------------------------------------- */

.docs-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding-inline: var(--gutter);
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

.docs-side {
  position: sticky;
  top: calc(var(--nav-h) + 24px);
  padding-block: 40px 24px;
  border-right: 1px solid var(--line);
  padding-right: 20px;
}

.docs-side-group { margin-bottom: 22px; }

.docs-side-group p {
  font-family: var(--mono);
  font-size: var(--fs-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin-bottom: 8px;
}

.docs-side-group a {
  display: block;
  font-size: 14.5px;
  color: var(--ink-2);
  text-decoration: none;
  padding: 5px 10px;
  margin-left: -10px;
  border-radius: var(--r-sm);
}

.docs-side-group a:hover { color: var(--ink); background: var(--panel-2); }
.docs-side-group a[aria-current="page"] { color: var(--ink); background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); font-weight: 500; }
/* A section's own pages, under it: PostgreSQL, Files and Email under Surfaces. */
.docs-side-group a.docs-sub { padding-left: 24px; font-size: var(--fs-ui); }

.docs-main { padding-block: 40px 72px; min-width: 0; }

@media (max-width: 900px) {
  .docs-shell { grid-template-columns: minmax(0, 1fr); gap: 0; }
  /* On a phone the sidebar sits above the page as two columns of links, so
     all five groups fit in a screen rather than a scroll. */
  .docs-side {
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-right: 0;
    padding-block: 24px 8px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 16px;
  }
  .docs-side-group { min-width: 0; margin-bottom: 16px; }
}

/* --- Page furniture ------------------------------------------------------ */

.docs-crumb {
  font-family: var(--mono);
  font-size: var(--fs-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin-bottom: 10px;
}

.docs-crumb a { color: var(--ink-3); text-decoration: underline; text-underline-offset: 3px; }
.docs-crumb a:hover { color: var(--ink); }

.docs-main h1 {
  font-size: clamp(30px, 3.4vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.035em;
  color: var(--ink);
  margin-bottom: 12px;
}

.docs-main h2 {
  font-size: 23px;
  line-height: 1.25;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-top: 44px;
  margin-bottom: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.docs-main h3 {
  font-size: 17px;
  color: var(--ink);
  margin-top: 26px;
  margin-bottom: 6px;
}
/* A card's title is the heading under its section's h2, set as the h4 it
   used to be so the level does not skip. */
.docs-main .card > h3:first-child { font-size: 1em; margin-top: 0; margin-bottom: 0; }

.docs-main p {
  font-size: var(--fs-body);
  line-height: 1.65;
  color: var(--ink-2);
  margin-bottom: 14px;
  max-width: 68ch;
}

.docs-main ul, .docs-main ol {
  margin: 0 0 16px 20px;
  max-width: 68ch;
}

.docs-main li {
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--ink-2);
  margin-bottom: 7px;
}

.docs-main a { color: var(--signal); }
/* In running text a link is underlined as well: colour alone does not mark it
   against body copy (WCAG 1.4.1). */
.docs-main p a, .docs-main li a, .docs-main td a { text-decoration: underline; text-underline-offset: 3px; }
.docs-main strong { color: var(--ink); }
/* A call to action inside a page keeps its button colours, not the link's. */
.docs-main a.btn { color: var(--on-signal); text-decoration: none; }
.docs-main a.btn-secondary { color: var(--ink); }

.docs-main code {
  font-size: var(--fs-data);
  color: var(--ink);
  background: var(--panel-2);
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
}

.docs-main .code-box code { background: none; border: 0; padding: 0; }

/* A multi-line example. It wraps rather than scrolls: on a phone a one-line
   `claude mcp add` pushed /docs/mcp 161px past the screen (STYLE.md §7.8). */
.docs-main pre {
  margin: 0 0 16px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: var(--fs-data);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.docs-main pre code { background: none; border: 0; padding: 0; }

/* --- Command and flag reference ------------------------------------------ */

.cmd {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  box-shadow: var(--shadow-1);
  padding: 20px 22px;
  margin-bottom: 16px;
}

.cmd > h3 { margin-top: 0; }

.cmd-sig {
  font-family: var(--mono);
  font-size: var(--fs-data);
  color: var(--brand);
  margin-bottom: 8px;
}

.flags {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.flags th {
  font-family: var(--mono);
  font-size: var(--fs-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  text-align: left;
  font-weight: 400;
  padding: 0 14px 7px 0;
  border-bottom: 1px solid var(--line);
}

.flags td {
  font-size: var(--fs-table);
  color: var(--ink-2);
  vertical-align: top;
  padding: 9px 14px 9px 0;
  border-bottom: 1px solid var(--line);
  line-height: 1.5;
}

.flags td:first-child {
  font-family: var(--mono);
  font-size: var(--fs-data);
  color: var(--ink);
  white-space: nowrap;
}

.flags tr:last-child td { border-bottom: 0; }

/* On a phone the key column may wrap and long values break anywhere: a
   nowrap config key pushed /docs/daemon 449px past a 390px screen. */
@media (max-width: 600px) {
  .flags td, .flags th { overflow-wrap: anywhere; }
  .flags td:first-child { white-space: normal; }
}

/* --- Comparison table: a feature per row, a drawn mark per product -------- */

.vs {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.vs th {
  font-family: var(--mono);
  font-size: var(--fs-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  font-weight: 400;
  text-align: center;
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--line);
}

.vs th:first-child { text-align: left; padding-left: 0; }
.vs th.us { color: var(--brand); }

.vs td {
  font-size: var(--fs-table);
  color: var(--ink);
  text-align: center;
  vertical-align: middle;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  line-height: 1.45;
}

.vs td:first-child { text-align: left; padding-left: 0; }
.vs td.us { background: var(--brand-2); }
.vs tr:last-child td { border-bottom: 0; }
.vs + p { margin-top: 18px; }

/* Drawn, not typed: the style test keeps symbol glyphs out of markup. */
.vs .yes::before {
  content: "";
  display: inline-block;
  width: 12px; height: 7px;
  margin-bottom: 3px;
  border-left: 2px solid var(--brand);
  border-bottom: 2px solid var(--brand);
  transform: rotate(-45deg);
}

.vs .no::before {
  content: "";
  display: inline-block;
  width: 11px; height: 11px;
  background:
    linear-gradient(45deg, transparent 44%, var(--ink-3) 44%, var(--ink-3) 56%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, var(--ink-3) 44%, var(--ink-3) 56%, transparent 56%);
}

.vs .part { font-size: var(--fs-label); color: var(--ink-3); }
.vs .price { font-family: var(--mono); font-size: var(--fs-data); }

/* --- Index cards ---------------------------------------------------------- */

.docs-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: 12px;
  margin-top: 24px;
}

.docs-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 20px;
  text-decoration: none;
  display: block;
  transition: border-color .15s;
}

.docs-card:hover { border-color: var(--ink-3); }

.docs-card p:last-child { margin-bottom: 0; }

.docs-card .docs-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
  display: block;
}

.docs-card:hover .docs-card-name { color: var(--ink); }

.docs-card span.tag { display: block; margin-bottom: 8px; }

/* --- Next / previous ------------------------------------------------------ */

.docs-pager {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  margin-top: 52px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.docs-pager a {
  font-size: var(--fs-ui);
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  padding: 8px 14px;
  border: 1px solid var(--line-3);
  border-radius: var(--r-md);
}

.docs-pager a:hover { border-color: var(--ink-3); background: var(--panel); }

/* A console screenshot inside a docs page (classes in landing.css). */
.docs-main .shot { margin-block: 24px 32px; }

/* --- Free tools (/tools) -------------------------------------------------- */
/* The inputs and results of the tools pages. They run in the browser, so a
   result is drawn by the page's script into these containers. */

.tool {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  box-shadow: var(--shadow-1);
  padding: 22px;
  margin-block: 20px 28px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 18px;
}

.tool-grid .form-group { margin-bottom: 14px; }
.tool-check { display: flex; align-items: center; gap: 8px; font-size: var(--fs-ui); color: var(--ink-2); margin-bottom: 14px; }

.tool-drop {
  display: block;
  border: 1px dashed var(--line-3);
  border-radius: var(--r-md);
  padding: 28px 20px;
  text-align: center;
  color: var(--ink-2);
  font-size: var(--fs-ui);
  cursor: pointer;
}

.tool-drop strong { display: block; color: var(--ink); font-size: var(--fs-body); margin-bottom: 6px; }
.tool-drop .form-input { margin: 14px auto 0; max-width: 320px; }
.tool-drop-over { border-color: var(--signal); background: var(--signal-2); }

.tool-status { font-size: var(--fs-ui); color: var(--ink-3); margin-top: 12px; min-height: 1.4em; }

.tool-result { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.tool-verdict { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 14px; }
.tool-verdict strong { color: var(--ink); }

.tool-facts {
  display: grid;
  grid-template-columns: minmax(120px, max-content) minmax(0, 1fr);
  gap: 6px 18px;
  margin-bottom: 16px;
  font-size: var(--fs-table);
}

.tool-facts dt { color: var(--ink-3); }
.tool-facts dd { color: var(--ink); font-family: var(--mono); font-size: var(--fs-data); overflow-wrap: anywhere; }

.docs-main .tool-checks { list-style: none; margin: 0 0 16px; max-width: none; }
.docs-main .tool-checks li { display: flex; align-items: baseline; gap: 12px; }
.tool-checks .state-mark { position: relative; top: -1px; }

.docs-main .tool-label {
  font-family: var(--mono);
  font-size: var(--fs-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin: 18px 0 6px;
}

.tool-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tool-head .tool-label { margin-top: 0; }

.tool-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 6px;
}

.tool-stat { border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 12px 14px; background: var(--ground); }
.tool-stat span { display: block; font-size: var(--fs-label); color: var(--ink-3); margin-bottom: 4px; }
.tool-stat b { font-family: var(--mono); font-size: var(--fs-body); font-weight: 500; color: var(--ink); }

@media (max-width: 600px) {
  .tool { padding: 16px; }
  .tool-facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .tool-facts dd { margin-bottom: 8px; }
}

/* Printing: the Evidence Pack and any docs page. The chrome, the controls
   and the links' underlines go; tables keep their rows together. */
@media print {
  .site-nav, .site-footer, .consent, .no-print, .docs-side { display: none !important; }
  body { background: var(--ground); color: var(--ink); }
  a { text-decoration: none; color: inherit; }
  .table-container { overflow: visible; }
  table { page-break-inside: auto; }
  tr { page-break-inside: avoid; }
  h2 { page-break-after: avoid; }
}
