/* The shell every page is in: a sidebar beside the content, the content a grid of cards.
   The palette and the pieces inside the cards are in style.css. */

/* align-content: a short page would otherwise stretch the sidebar row on a phone. */
body.shell { display: flex; flex-wrap: wrap; align-content: flex-start; }
/* The buttons below set display, which would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }

/* --- sidebar: beside the content on a wide screen, a bar with a menu above it on a narrow one --- */
.side {
  flex: 1 1 210px; max-width: 100%; padding: 24px 14px; background: var(--side);
  border-right: 1px solid var(--rule); display: flex; flex-direction: column; gap: 24px;
}
.side-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 10px; }
.side .brand { font: 600 1.25em var(--mono); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px;
  border-radius: 6px; color: #a9b0ba;
}
.side-nav a:hover { background: var(--hover); color: var(--fg); text-decoration: none; }
.side-nav a[aria-current] { background: var(--hover); color: var(--fg); box-shadow: inset 2px 0 var(--accent); }
.side-nav svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.side-note { margin: auto 0 0; padding: 0 10px; font-size: .82em; color: var(--dim); }
.menu-toggle {
  display: none; min-height: 44px; padding: 0 14px; border: 1px solid var(--rule); border-radius: var(--radius);
  background: none; color: var(--fg); font: 500 .95em var(--sans); cursor: pointer;
}
.menu-toggle:hover { border-color: var(--accent); }

/* The sidebar wraps above the content once the content's 560px no longer fit beside it.
   Then the nav folds behind the Menu button, which only shell.js shows: without a script
   the nav simply stays open. */
@media (max-width: 800px) {
  .side { flex-basis: 100%; padding: 12px 6px; border-right: 0; border-bottom: 1px solid var(--rule); gap: 8px; }
  .menu-toggle { display: inline-flex; align-items: center; }
  .side.folding:not(.open) .side-nav { display: none; }
  .side-note { display: none; }
}

/* --- content: a grid of cards --- */
.content { flex: 999 1 560px; min-width: 0; max-width: none; margin: 0; padding: 28px 16px 48px; }
.cards {
  max-width: 1040px; margin: 0 auto; display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
}
.card { min-width: 0; padding: 20px 24px; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; }
.card.wide, .card.atlas { grid-column: 1 / -1; }
.card h2 { margin: 0 0 12px; font-size: 1.05em; }
.card > :last-child { margin-bottom: 0; }

/* Buttons outside a form, as the check form draws its own. */
.button, .button-alt {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: var(--radius);
  font: 600 .95em var(--sans); cursor: pointer;
}
.button { background: var(--accent); color: var(--on-fg); border: 0; }
.button:hover { background: var(--bright); color: var(--on-fg); text-decoration: none; }
.button-alt { background: rgba(15, 17, 20, .9); color: var(--fg); border: 1px solid #333944; }
.button-alt:hover { border-color: var(--accent); color: var(--hi); text-decoration: none; }

/* --- the Atlas hero: the probe map, then the address in one line under it, so nothing is
   ever drawn over the map. On a phone the line wraps into a card. --- */
.card.atlas { position: relative; padding: 0; overflow: hidden; }
.atlas-map {
  position: relative; height: 420px; overflow: hidden; font: 14px/1.35 var(--mono);
  background: radial-gradient(ellipse at 40% 40%, #1a1712 0%, var(--surface) 75%);
}
.atlas-card { padding: 16px 20px; border-top: 1px solid var(--rule); }
.atlas-card .label { margin: 0; font-size: .9em; font-weight: 500; letter-spacing: 0; color: var(--dim); }
.atlas-card .ip {
  margin: 4px 0 10px; font: 600 clamp(1.9em, 5vw, 3.4em)/1.05 var(--mono); letter-spacing: -.02em;
  color: var(--accent); overflow-wrap: anywhere;
}
.atlas-card .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.atlas .netmap .credit { color: var(--dim); }

@media (min-width: 641px) {
  .atlas-card { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 10px 16px; }
  .atlas-card .ip { margin: 0; font-size: clamp(1.3em, 2.2vw, 1.8em); }
  .atlas-card .actions { margin: 0 0 0 auto; }
}

@media (max-width: 640px) {
  .atlas-map { height: 220px; }
}

/* --- the health card: verdict beside the heading, then /health's grid, compacted --- */
.card-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.card-head .verdict { font-size: .85em; padding: 2px 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mini-wrap { overflow-x: auto; margin: 0 0 12px; }
.grid.mini { font-size: .85em; }
/* Tight columns so nine regions fit beside the check card. */
.grid.mini th, .grid.mini td { padding: 5px 3px; text-align: center; border-top-color: var(--rule); }
.grid.mini tbody th { text-align: left; padding: 5px 8px 5px 0; }
.grid.mini thead th { background: none; }
/* Up is the quiet default; anything else stands out by brightness and weight, not hue. */
.grid.mini .s-up { color: #4d5560; }
.grid.mini .s-down { border-radius: 4px; }

/* --- inner pages: a heading over the cards --- */
.page-head { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.page-head h1 { margin: 4px 0 0; font-size: 1.6em; overflow-wrap: anywhere; }
.page-head .verdict { margin-top: 4px; font-size: .85em; padding: 2px 12px; }
.page-head .meta { margin: 4px 0 0; font-size: .92em; }
.page-head .lede { flex-basis: 100%; margin: 0; }
/* Prose pages: one column at a readable width, on the same left edge as the wider grids. */
.cards.prose { grid-template-columns: minmax(0, 760px); }
.card .error { margin: 0 0 4px; }
.cards > .notice, .cards > .error { justify-self: start; margin: 0; }
.card > .hint:last-child { margin-bottom: 0; }

/* Maps, result boxes and tables that sit in the grid on their own read as cards. */
.cards > .grid-wrap, .cards > .wide { grid-column: 1 / -1; min-width: 0; }
.card .grid-wrap { margin: 0 0 12px; background: none; }
.cards .check-form + .error:not(:empty) { margin-top: 12px; }
#links:empty { display: none; }
