/* ==========================================================================
   HostCraft — Network status board (status/ page)
   Uses the site's own theme tokens (light and dark). Status colours follow
   convention; every state also has its own shape and text label.
   ========================================================================== */
.ns { --ns-up: var(--ok-fg); --ns-deg: var(--warn-fg); --ns-down: var(--err-fg); --ns-none: var(--border); --ns-r: 6px; }
.ns-body { padding: clamp(36px, 5vw, 64px) 0 clamp(56px, 7vw, 96px); background: var(--bg); color: var(--text); border-bottom: 1px solid var(--border); }
.ns-wrap { max-width: 1180px; display: grid; gap: 28px; }
.ns [hidden], .ns-tip[hidden] { display: none !important; }   /* component display rules must not override [hidden] */
.ns-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ns .mono, .ns-mono { font-family: var(--font-mono); }

/* State marks: shape + colour */
.ns-dot { display: inline-block; width: 10px; height: 10px; flex: none; }
.ns-dot[data-s="online"], .ns-dot[data-s="up"] { background: var(--ns-up); border-radius: 50%; }
.ns-dot[data-s="degraded"] { background: var(--ns-deg); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.ns-dot[data-s="down"] { background: var(--ns-down); clip-path: polygon(20% 0, 50% 30%, 80% 0, 100% 20%, 70% 50%, 100% 80%, 80% 100%, 50% 70%, 20% 100%, 0 80%, 30% 50%, 0 20%); }
.ns-dot[data-s="unknown"], .ns-dot[data-s="nodata"] { border: 2px solid var(--soft); border-radius: 50%; }

/* A. Overall */
.ns-overall {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px;
  padding: 20px 24px; border-radius: var(--ns-r); border: 1px solid var(--border); border-left-width: 4px;
  background: var(--surface);
}
.ns-overall-icon { width: 14px; height: 14px; border-radius: 50%; background: var(--soft); }
.ns-overall[data-state="operational"] { border-left-color: var(--ns-up); }
.ns-overall[data-state="operational"] .ns-overall-icon { background: var(--ns-up); box-shadow: 0 0 0 5px var(--ok-bg); }
.ns-overall[data-state="degraded"], .ns-overall[data-state="partial"] { border-left-color: var(--ns-deg); }
.ns-overall[data-state="degraded"] .ns-overall-icon, .ns-overall[data-state="partial"] .ns-overall-icon { background: var(--ns-deg); border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.ns-overall[data-state="outage"] { border-left-color: var(--ns-down); }
.ns-overall[data-state="outage"] .ns-overall-icon { background: var(--ns-down); border-radius: 3px; }
.ns-overall[data-state="unknown"], .ns-overall[data-state="monitoring_issue"], .ns-overall[data-state="loading"] { border-left-color: var(--soft); }
.ns-overall[data-state="unknown"] .ns-overall-icon, .ns-overall[data-state="monitoring_issue"] .ns-overall-icon { background: none; border: 2px solid var(--soft); }
.ns-overall-text { display: grid; gap: 2px; min-width: 0; }
.ns-overall-text strong { font-size: 18px; font-weight: 800; letter-spacing: -.02em; color: var(--ink); }
.ns-overall-text span { font-size: 14px; color: var(--muted); }
.ns-overall-meta { display: flex; gap: 22px; margin: 0; }
.ns-overall-meta div { display: grid; gap: 2px; }
.ns-overall-meta dt { font: 600 10.5px/1.2 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--soft); }
.ns-overall-meta dd { margin: 0; font: 600 13px var(--font-mono); color: var(--ink); white-space: nowrap; }

/* Toolbar */
.ns-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ns-ranges { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9999px; background: var(--surface); border: 1px solid var(--border); }
.ns-range {
  height: 34px; padding: 0 16px; border: 0; border-radius: 9999px; background: none; cursor: pointer;
  font: 600 13px var(--font-sans); color: var(--muted);
}
.ns-range:hover { color: var(--ink); }
.ns-range[aria-checked="true"] { background: var(--silver-soft); color: var(--text); border-color: var(--silver-bd); }
[data-theme="light"] .ns-range[aria-checked="true"] { background: var(--btn-2-bg); color: var(--btn-2-text); border-color: var(--btn-2-bd); }
.ns-range:focus-visible, .ns-loc:focus-visible, .ns-bar:focus-visible, .ns-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.ns-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 0; padding: 0; font-size: 12.5px; color: var(--muted); }
.ns-legend li { display: inline-flex; align-items: center; gap: 7px; }
.ns-sw { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.ns-s-up { background: var(--ns-up); }
.ns-s-degraded { background: var(--ns-deg); }
.ns-s-down { background: var(--ns-down); }
.ns-s-nodata { background: var(--ns-none); }
.ns-coverage-note { margin: -12px 0 0; font-size: 13px; color: var(--muted); }
.ns-error { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: var(--ns-r); border: 1px solid var(--err-bd); background: var(--err-bg); color: var(--err-fg); font-size: 14px; }
.ns-btn { height: 32px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); font: 600 13px var(--font-sans); cursor: pointer; }

/* Sections */
.ns-section { display: grid; gap: 14px; }
.ns-section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ns-section-head h2 { margin: 0; font-size: clamp(20px, 2.2vw, 26px); font-weight: 800; letter-spacing: -.03em; color: var(--ink); }
.ns-section-head p { margin: 0; font-size: 13.5px; color: var(--muted); }

/* B. Regional overview */
.ns-regions { display: grid; gap: 22px; }
.ns-region h3 { margin: 0 0 10px; font: 700 11px/1.2 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted); }
.ns-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.ns-loc {
  display: grid; gap: 10px; padding: 16px 16px 14px; text-align: left; cursor: pointer; font: inherit; color: inherit;
  border-radius: var(--ns-r); border: 1px solid var(--border); background: var(--surface);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.ns-loc:hover { border-color: var(--silver-bd); transform: translateY(-1px); box-shadow: 0 6px 18px color-mix(in srgb, var(--shadow-color) 18%, transparent); }
.ns-loc[aria-pressed="true"] { border-color: var(--silver-bd); box-shadow: 0 0 0 1px var(--silver-bd); background: var(--silver-soft); }
.ns-loc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ns-loc-name { display: grid; gap: 1px; min-width: 0; }
.ns-loc-name strong { font-size: 15px; font-weight: 700; color: var(--ink); }
.ns-loc-name span { font-size: 12px; color: var(--soft); }
.ns-state { display: inline-flex; align-items: center; gap: 6px; font: 700 11px var(--font-mono); letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
.ns-state[data-s="online"] { color: var(--ns-up); }
.ns-state[data-s="degraded"] { color: var(--ns-deg); }
.ns-state[data-s="down"] { color: var(--ns-down); }
.ns-state[data-s="unknown"] { color: var(--soft); }
.ns-loc-figs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ns-fig { display: grid; gap: 1px; }
.ns-fig dt, .ns-fig span:first-child { font: 600 10px/1.2 var(--font-mono); letter-spacing: .07em; text-transform: uppercase; color: var(--soft); }
.ns-fig b { font: 700 14px var(--font-mono); color: var(--ink); }
.ns-chip { justify-self: start; font: 600 10.5px var(--font-mono); padding: 2px 7px; border-radius: 4px; background: var(--silver-soft); color: var(--silver); border: 1px solid var(--silver-bd); }
.ns-loc-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 8px; font-size: 11.5px; color: var(--soft); }
.ns-loc-foot span { white-space: nowrap; }   /* wrap between the two facts, never mid-text */
.ns-chip { cursor: help; }
.ns-mini { display: flex; gap: 1px; height: 6px; }
.ns-mini i { flex: 1; border-radius: 1px; background: var(--ns-none); }

/* C. History rows */
.ns-history { display: grid; gap: 2px; border: 1px solid var(--border); border-radius: var(--ns-r); background: var(--surface); padding: 6px 16px; }
.ns-hrow { display: grid; grid-template-columns: 170px 1fr 110px; align-items: center; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); }
.ns-hrow:first-child { border-top: 0; }
.ns-hname { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.ns-hname span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ns-bars { display: flex; gap: 2px; height: 30px; align-items: stretch; min-width: 0; }
.ns-bar { flex: 1 1 0; min-width: 2px; border-radius: 2px; background: var(--ns-none); cursor: default; border: 0; padding: 0; }
.ns-bar[data-s="up"] { background: var(--ns-up); }
.ns-bar[data-s="degraded"] { background: var(--ns-deg); }
.ns-bar[data-s="down"] { background: var(--ns-down); }
.ns-bar[data-s="monitor_error"], .ns-bar[data-s="no_icmp"] { background: repeating-linear-gradient(135deg, var(--ns-none) 0 3px, transparent 3px 6px); }
.ns-bar:hover { filter: brightness(1.15); outline: 1px solid var(--ink); outline-offset: 1px; }
.ns-hup { text-align: right; font: 700 13px var(--font-mono); color: var(--ink); }
.ns-hup small { display: block; font: 500 11px var(--font-sans); color: var(--soft); }
.ns-axis { display: grid; grid-template-columns: 170px 1fr 110px; gap: 14px; font: 11px var(--font-mono); color: var(--soft); padding: 4px 0 6px; }
.ns-axis span:nth-child(2) { display: flex; justify-content: space-between; }

/* D. Detail */
.ns-select select {
  height: 38px; padding: 0 36px 0 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink); font: 600 14px var(--font-sans);
}
.ns-detail { display: grid; grid-template-columns: 320px 1fr; gap: 16px; }
.ns-panel { padding: 18px 20px; border-radius: var(--ns-r); border: 1px solid var(--border); background: var(--surface); min-width: 0; }
.ns-panel h3 { margin: 0 0 12px; font-size: 15px; font-weight: 700; color: var(--ink); }
.ns-kv { margin: 0; display: grid; }
.ns-kv div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.ns-kv div:first-child { border-top: 0; padding-top: 0; }
.ns-kv dt { color: var(--muted); }
.ns-kv dd { margin: 0; font: 600 13px var(--font-mono); color: var(--ink); text-align: right; }
.ns-charts { display: grid; gap: 16px; }
.ns-chart svg { display: block; width: 100%; overflow: visible; }
.ns-chart .grid { stroke: var(--line); }
.ns-chart .axis { stroke: var(--border); }
.ns-chart .tick { fill: var(--soft); font: 10px var(--font-mono); }
.ns-chart .lat-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.ns-chart .lat-area { fill: var(--accent-soft); }
.ns-chart .loss-bar { fill: var(--ns-deg); }
.ns-chart .hit { fill: transparent; }
.ns-chart .hit:hover { fill: var(--accent-soft); }
.ns-empty { margin: 0; font-size: 13.5px; color: var(--muted); }

/* Incidents */
.ns-incidents { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ns-incident { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; border-radius: var(--ns-r); border: 1px solid var(--border); border-left: 3px solid var(--ns-down); background: var(--surface); font-size: 13.5px; }
.ns-incident.is-ongoing { border-left-color: var(--ns-down); background: var(--err-bg); }
.ns-incident strong { color: var(--ink); }
.ns-incident small { display: block; color: var(--soft); font-size: 12px; }
.ns-incident .mono { font-size: 12px; color: var(--muted); text-align: right; }

/* Method */
.ns-method-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ns-method-grid > div { padding: 16px 18px; border-radius: var(--ns-r); border: 1px solid var(--border); background: var(--surface); }
.ns-method-grid h3 { margin: 0 0 6px; font-size: 14.5px; font-weight: 700; color: var(--ink); }
.ns-method-grid p { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.ns-footnote { margin: 0; font-size: 13px; color: var(--muted); }

/* Tooltip + loading */
.ns-tip {
  position: fixed; z-index: 60; pointer-events: none; display: grid; gap: 2px; max-width: 260px; padding: 8px 10px;
  border-radius: 6px; background: var(--ink); color: var(--bg); font-size: 12px; box-shadow: 0 8px 24px color-mix(in srgb, var(--shadow-color) 30%, transparent);
}
.ns-tip strong { font-weight: 700; }
.ns-skeleton { display: grid; gap: 10px; }
.ns-skeleton span { height: 16px; border-radius: 4px; background: linear-gradient(90deg, var(--line), var(--border), var(--line)); background-size: 200% 100%; animation: ns-shimmer 1.3s ease-in-out infinite; }
.ns-skeleton span:nth-child(2n) { width: 70%; }
@keyframes ns-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .ns-skeleton span { animation: none; } .ns-loc { transition: none; } }

/* Responsive */
@media (max-width: 900px) {
  .ns-overall { grid-template-columns: auto 1fr; }
  .ns-overall-meta { grid-column: 1 / -1; flex-wrap: wrap; }
  .ns-detail { grid-template-columns: 1fr; }
  .ns-hrow, .ns-axis { grid-template-columns: 120px 1fr 84px; gap: 10px; }
}
@media (max-width: 600px) {
  .ns-ranges { width: 100%; }
  .ns-range { flex: 1; padding: 0 6px; font-size: 12px; }
  .ns-hrow { grid-template-columns: 1fr auto; }
  .ns-hrow .ns-bars { grid-column: 1 / -1; grid-row: 2; }
  .ns-axis { display: none; }
  .ns-method-grid { grid-template-columns: 1fr; }
  .ns-loc-figs { grid-template-columns: repeat(3, 1fr); }
  .ns-incident { grid-template-columns: auto 1fr; }
  .ns-incident .mono { grid-column: 2; text-align: left; }
}
