/* Hex World shared UI foundation.
   Tokens plus a small set of prefixed components (hw-*) shared by index.html,
   admin/index.html and city-dome-review.html. Page layout and positioning stay in
   the page's own stylesheet; nothing here sets fixed positioning, overflow or HUD
   sizing, so the admin and review pages scroll normally. */

:root {
  color-scheme: dark;

  /* surfaces */
  --hw-bg: #111820;
  --hw-bg-deep: #0a1016;
  --hw-panel: #202b36;
  --hw-panel-2: #1b242d;
  --hw-raised: #2b3946;
  --hw-sunken: #141c24;

  /* lines */
  --hw-border: #526373;
  --hw-border-soft: #34424f;

  /* text */
  --hw-text: #edf2f5;
  --hw-text-2: #b2c0ca;
  --hw-text-dim: #8595a2;

  /* accents */
  --hw-amber: #eab665;
  --hw-teal: #62d8cb;
  --hw-focus: #8ad9ef;
  --hw-up: #6ad48c;
  --hw-down: #f08a8a;
  --hw-warn: #f0b357;
  --hw-danger: #e5645c;
  --hw-danger-bg: #3a1d1b;

  /* form */
  --hw-radius: 3px;
  --hw-radius-lg: 5px;
  --hw-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);

  /* 4 / 8 / 12 / 16 / 24 scale */
  --hw-s1: 4px;
  --hw-s2: 8px;
  --hw-s3: 12px;
  --hw-s4: 16px;
  --hw-s5: 24px;

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

/* ---- base ---------------------------------------------------------------- */

body.hw-page {
  margin: 0;
  padding: var(--hw-s5);
  background: var(--hw-bg);
  color: var(--hw-text);
  font-family: var(--hw-sans);
  font-size: 14px;
  line-height: 1.55;
}

.hw-mono { font-family: var(--hw-mono); }
.hw-num { font-variant-numeric: tabular-nums; text-align: right; }
.hw-muted { color: var(--hw-text-dim); }
.hw-dim { color: var(--hw-text-2); }
.hw-up { color: var(--hw-up); }
.hw-down { color: var(--hw-down); }
.hw-warn { color: var(--hw-warn); }
.hw-danger-text { color: var(--hw-danger); }

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

/* one focus treatment everywhere, on keyboard navigation only */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--hw-focus);
  outline-offset: 2px;
}

/* ---- headings ------------------------------------------------------------ */

.hw-title {
  margin: 0 0 var(--hw-s2);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--hw-text);
}

.hw-section {
  margin: var(--hw-s4) 0 var(--hw-s2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--hw-text-dim);
}

.hw-section:first-child { margin-top: 0; }

.hw-lede { color: var(--hw-text-2); max-width: 68ch; }

.hw-note {
  margin: var(--hw-s1) 0 0;
  font-size: 12px;
  color: var(--hw-text-dim);
}

/* ---- surfaces ------------------------------------------------------------ */

.hw-card,
.hw-panel {
  background: var(--hw-panel);
  border: 1px solid var(--hw-border-soft);
  border-radius: var(--hw-radius-lg);
  padding: var(--hw-s4);
}

.hw-panel-tight { padding: var(--hw-s3); }

.hw-sunken {
  background: var(--hw-sunken);
  border: 1px solid var(--hw-border-soft);
  border-radius: var(--hw-radius);
  padding: var(--hw-s2);
}

/* ---- buttons ------------------------------------------------------------- */

.hw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--hw-s1);
  min-height: 30px;
  padding: 5px 12px;
  font: inherit;
  font-size: 13px;
  line-height: 1.2;
  color: var(--hw-text);
  background: var(--hw-raised);
  border: 1px solid var(--hw-border-soft);
  border-radius: var(--hw-radius);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.hw-btn:hover:not(:disabled) { border-color: var(--hw-border); background: #33434f; }
.hw-btn:active:not(:disabled) { background: #263440; }
.hw-btn[aria-pressed="true"] { border-color: var(--hw-teal); color: var(--hw-teal); background: #1d3033; }
.hw-btn.primary { background: var(--hw-teal); border-color: var(--hw-teal); color: #08272a; font-weight: 600; }
.hw-btn.primary:hover:not(:disabled) { background: #7fe6d9; border-color: #7fe6d9; }
.hw-btn.ghost { background: transparent; border-color: transparent; color: var(--hw-text-2); }
.hw-btn.ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.06); color: var(--hw-text); }
.hw-btn.danger { color: var(--hw-danger); border-color: #7c3a34; background: var(--hw-danger-bg); }
.hw-btn.danger:hover:not(:disabled) { border-color: var(--hw-danger); }
.hw-btn.tiny { min-height: 24px; padding: 2px 8px; font-size: 12px; }

.hw-btn:disabled,
.hw-btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  color: var(--hw-text-dim);
  border-color: var(--hw-border-soft);
  background: var(--hw-panel-2);
}

/* busy / working state: a small spinner, never a colour-only cue */
.hw-btn.busy { color: var(--hw-text-dim); }
.hw-btn.busy::before {
  content: "";
  width: 10px; height: 10px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: hw-spin 700ms linear infinite;
}

@keyframes hw-spin { to { transform: rotate(360deg); } }

/* ---- badges and status --------------------------------------------------- */

.hw-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--hw-s1);
  padding: 1px 7px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--hw-text-2);
  background: var(--hw-sunken);
  border: 1px solid var(--hw-border-soft);
  border-radius: 999px;
}

.hw-badge.good { color: var(--hw-up); border-color: #35634a; }
.hw-badge.warn { color: var(--hw-warn); border-color: #6b5530; }
.hw-badge.bad { color: var(--hw-danger); border-color: #7c3a34; }
.hw-badge.info { color: var(--hw-teal); border-color: #2c5a58; }

/* a dot plus words: state is never signalled by colour alone */
.hw-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--hw-text-2);
}

.hw-status .dot {
  width: 8px; height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--hw-text-dim);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.hw-status.online .dot { background: var(--hw-up); }
.hw-status.busy .dot { background: var(--hw-warn); animation: hw-pulse 1.4s ease-in-out infinite; }
.hw-status.offline .dot { background: var(--hw-danger); }
.hw-status.online { color: var(--hw-up); }
.hw-status.busy { color: var(--hw-warn); }
.hw-status.offline { color: var(--hw-danger); }

@keyframes hw-pulse { 50% { opacity: 0.35; } }

/* ---- fields -------------------------------------------------------------- */

.hw-field {
  display: block;
  margin: 0 0 var(--hw-s3);
}

.hw-field > span {
  display: block;
  margin-bottom: var(--hw-s1);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--hw-text-dim);
}

.hw-input,
.hw-field input,
.hw-field select {
  width: 100%;
  padding: 7px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--hw-text);
  background: var(--hw-sunken);
  border: 1px solid var(--hw-border-soft);
  border-radius: var(--hw-radius);
}

.hw-input:hover,
.hw-field input:hover { border-color: var(--hw-border); }

.hw-input:disabled,
.hw-field input:disabled { opacity: 0.5; cursor: not-allowed; }

.hw-error {
  margin: var(--hw-s2) 0 0;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--hw-danger);
  background: var(--hw-danger-bg);
  border: 1px solid #7c3a34;
  border-radius: var(--hw-radius);
}

.hw-error:empty { display: none; }

/* ---- tables -------------------------------------------------------------- */

.hw-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.hw-table th {
  padding: 4px 10px 4px 0;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--hw-text-dim);
  border-bottom: 1px solid var(--hw-border-soft);
  white-space: nowrap;
}

.hw-table td {
  padding: 5px 10px 5px 0;
  color: var(--hw-text-2);
  border-bottom: 1px solid rgba(82, 99, 115, 0.18);
  vertical-align: middle;
}

.hw-table tbody tr:hover td { background: rgba(255, 255, 255, 0.035); }
.hw-table tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.018); }
.hw-table tbody tr:nth-child(even):hover td { background: rgba(255, 255, 255, 0.05); }
.hw-table .hw-num,
.hw-table th.num { text-align: right; padding-right: 12px; }
.hw-table .empty td {
  color: var(--hw-text-dim);
  font-style: italic;
  text-align: center;
  background: none;
}

.hw-scroll { overflow: auto; }

/* ---- dialogs ------------------------------------------------------------- */

.hw-dialog {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--hw-s4);
  background: rgba(4, 7, 10, 0.72);
}

.hw-dialog-box {
  width: 100%;
  max-width: 420px;
  padding: var(--hw-s4) var(--hw-s4) var(--hw-s3);
  background: var(--hw-panel);
  border: 1px solid var(--hw-border);
  border-radius: var(--hw-radius-lg);
  box-shadow: var(--hw-shadow);
}

.hw-dialog-box h2 {
  margin: 0 0 var(--hw-s2);
  font-size: 15px;
  letter-spacing: 0.04em;
}

.hw-dialog-box p {
  margin: 0;
  color: var(--hw-text-2);
  font-size: 13px;
}

.hw-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--hw-s2);
  margin-top: var(--hw-s4);
}

.hw-dialog[hidden],
.hw-dialog-box[hidden] { display: none; }

/* ---- misc --------------------------------------------------------------- */

.hw-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--hw-teal);
  border-top-color: transparent;
  border-radius: 50%;
  animation: hw-spin 800ms linear infinite;
}

.hw-divider {
  height: 1px;
  margin: var(--hw-s3) 0;
  background: var(--hw-border-soft);
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
