/* ═══════════════════════════════════════════════════════════════════════════
   DNS Panopticon — Domain Visualizer
   Page-specific styles for the Domain Visualizer tool (public/index.html).
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── View states ──────────────────────────────────────────────────────────── */
.view { display: none; flex-direction: column; }
.view.active { display: flex; }

/* ════════════════════════════════════════════════════════════════════════════
   LANDING VIEW
   ════════════════════════════════════════════════════════════════════════════ */
/* Shared template classes now own landing geometry. */

/* The .view rule sets flex-direction: column for results/scanning views, but
   .landing-zone is designed for flex-direction: row (justify-content centers
   horizontally; align-items: flex-start pins content to the top under
   padding-top). Override here so the landing view matches recon/analyzer. */
#view-landing {
  flex-direction: row;
}

/* Landing illustration: the original Domain Visualizer eye, shown in the shared
   hero tile (page-template.css). The outer ring breathes. */
.visualizer-hero-svg .eye-ring-outer {
  transform-origin: 80px 80px;
  animation: eye-pulse 3s ease-in-out infinite;
}

@keyframes eye-pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.04); }
}

@media (prefers-reduced-motion: reduce) {
  .visualizer-hero-svg .eye-ring-outer { animation: none; }
}

/* Scan form */
.scan-form { width: 100%; }

/* The search bar chrome lives in page-template.css (.landing-search). */
#domain-input {
  font-family: var(--font-data);
}

#domain-input::placeholder { color: var(--txt-4); }

/* ════════════════════════════════════════════════════════════════════════════
   SCANNING AND ERROR VIEWS
   ════════════════════════════════════════════════════════════════════════════ */
/* The scanning layout itself is shared and lives in components.css. */
#view-scanning,
#view-error {
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}

/* ════════════════════════════════════════════════════════════════════════════
   RESULTS VIEW
   ════════════════════════════════════════════════════════════════════════════ */
#view-results {
  height: calc(100vh - var(--nav-height));
  overflow: hidden;
}

/* Score bar */
#top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
  min-height: 52px;
}

#top-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.result-domain {
  font-size: var(--text-small);
  font-weight: 700;
  font-family: var(--font-data);
  color: var(--txt);
}

.cache-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--amber) 15%, transparent);
  color: var(--amber);
  border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#top-center {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

/* The grades live in Security Posture; the bar links there. */
.posture-link {
  font-size: var(--text-compact);
  font-weight: var(--weight-action);
  color: var(--primary-ink);
  text-decoration: none;
  padding: 6px 8px;
  border-radius: var(--radius-control);
}
.posture-link:hover { text-decoration: underline; }

#top-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.scan-meta { font-size: 11px; color: var(--txt-4); }

/* Sankey / treemap switch: two icon buttons, the pressed one filled */
.view-switch {
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-control);
  overflow: hidden;
}

.view-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 10px;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  color: var(--txt-3);
  font-size: var(--text-caption);
  font-weight: 600;
  cursor: pointer;
}
.view-switch-btn + .view-switch-btn { border-left: 1.5px solid var(--border); }
.view-switch-btn:hover { background: var(--surface2); color: var(--txt-2); }
.view-switch-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.view-switch-btn[aria-pressed="true"] { background: var(--primary-fill); color: #fff; }
.view-switch-icon { width: 18px; height: 18px; flex-shrink: 0; }

/* Results body */
#results-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Sankey panel */
#sankey-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

#sankey-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

/* Groupby segmented control (sankey toolbar) */
.groupby-pills {
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.groupby-pill {
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface);
  color: var(--txt-3);
  border: none;
  border-radius: 0;
  cursor: pointer;
  line-height: 1.4;
}
.groupby-pill + .groupby-pill {
  border-left: 1.5px solid var(--border);
}
.groupby-pill:hover { background: var(--surface2); color: var(--txt-2); }
.groupby-pill.active {
  background: var(--primary-fill);
  color: #fff;
}

.variance-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--amber);
  background: color-mix(in srgb, var(--amber) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber) 25%, transparent);
  padding: 2px 8px;
  border-radius: 999px;
}

#sankey-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

#sankey-svg {
  width: 100%;
  height: 100%;
  display: block;
}

#sankey-container[hidden] { display: none; }

/* Record treemap: absolutely placed tiles, laid out by record-treemap.js */
.treemap-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  margin: 6px;
}
.treemap-container[hidden] { display: none; }

.tm-host {
  position: absolute;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface2);
}

.tm-host-name {
  display: block;
  padding: 2px 6px;
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  color: var(--txt-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tm-tile {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 1px;
  padding: 6px 8px;
  border: 1px solid color-mix(in srgb, currentColor 35%, transparent);
  border-radius: 6px;
  background: var(--surface);
  background-image: linear-gradient(var(--tm-bg), var(--tm-bg));
  color: var(--tm-fg);
  text-align: left;
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--t-fast);
}
.tm-tile:hover { border-color: currentColor; }
.tm-tile:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; z-index: 1; }

.tm-type {
  font-size: var(--text-compact);
  font-weight: 700;
  line-height: 1.2;
}
.tm-count {
  font-family: var(--font-data);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.tm-detail {
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
}
.tm-tile--small { padding: 3px 5px; }
.tm-tile--short { flex-direction: row; align-items: baseline; gap: 4px; }
.tm-tile--small .tm-type { font-size: 11px; }
.tm-tile--small .tm-count { font-size: 14px; }
.tm-tile--short .tm-count { font-size: 11px; }
.tm-tile--small .tm-detail,
.tm-tile--tiny .tm-detail,
.tm-tile--tiny .tm-count { display: none; }
.tm-tile--tiny { padding: 2px 3px; }
.tm-tile--tiny .tm-type { font-size: 9px; }

.tm-tile.type-a      { --tm-bg: var(--rtype-a-bg);      --tm-fg: var(--rtype-a-fg); }
.tm-tile.type-aaaa   { --tm-bg: var(--rtype-aaaa-bg);   --tm-fg: var(--rtype-aaaa-fg); }
.tm-tile.type-txt    { --tm-bg: var(--rtype-txt-bg);    --tm-fg: var(--rtype-txt-fg); }
.tm-tile.type-mx     { --tm-bg: var(--rtype-mx-bg);     --tm-fg: var(--rtype-mx-fg); }
.tm-tile.type-cname  { --tm-bg: var(--rtype-cname-bg);  --tm-fg: var(--rtype-cname-fg); }
.tm-tile.type-ns     { --tm-bg: var(--rtype-ns-bg);     --tm-fg: var(--rtype-ns-fg); }
.tm-tile.type-soa,
.tm-tile.type-other  { --tm-bg: var(--rtype-soa-bg);    --tm-fg: var(--rtype-soa-fg); }
.tm-tile.type-caa    { --tm-bg: var(--rtype-caa-bg);    --tm-fg: var(--rtype-caa-fg); }
.tm-tile.type-ptr    { --tm-bg: var(--rtype-ptr-bg);    --tm-fg: var(--rtype-ptr-fg); }
.tm-tile.type-srv    { --tm-bg: var(--rtype-srv-bg);    --tm-fg: var(--rtype-srv-fg); }
.tm-tile.type-dnssec { --tm-bg: var(--rtype-dnssec-bg); --tm-fg: var(--rtype-dnssec-fg); }

/* Node tooltip */
.node-tooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 13px;
  font-size: var(--text-caption);
  color: var(--txt-2);
  pointer-events: none;
  max-width: 260px;
  box-shadow: 0 4px 16px color-mix(in srgb, #000 18%, transparent);
  z-index: 100;
  line-height: 1.5;
}

.node-tooltip strong { color: var(--txt); font-weight: 700; display: block; margin-bottom: 3px; }
.node-tooltip .tt-meta { color: var(--txt-4); font-size: 11px; }
.node-tooltip .tt-mono { font-family: ui-monospace, monospace; word-break: break-all; }
.node-tooltip .tt-meta--summary { margin-top: 3px; }

/* Records panel */
#records-panel {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--border);
  background: var(--surface);
}

#records-header {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.panel-title {
  font-size: var(--text-compact);
  font-weight: 700;
  color: var(--txt);
}

.records-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--txt-3);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
}

.records-hint {
  margin: 0;
  font-size: var(--text-caption);
  line-height: 1.5;
  color: var(--txt-3);
}

/* Record types: one button per type, opening its records */
.record-types {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 6px 0;
  list-style: none;
}

.record-type-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 6px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  color: var(--txt);
  text-align: left;
  cursor: pointer;
  transition: background var(--t-fast);
}
.record-types li:last-child .record-type-btn { border-bottom: none; }
.record-type-btn:hover { background: var(--surface2); }
.record-type-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.record-type-btn .detail-type-badge { margin: 0; }

.record-type-count {
  font-family: var(--font-data);
  font-size: var(--text-caption);
  color: var(--txt-3);
  font-variant-numeric: tabular-nums;
}

/* Advanced: subdomain discovery summary */
#discovery-section {
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#discovery-section[hidden] { display: none; }

#discovery-section .panel-title-row {
  padding: 8px 12px 4px;
  margin-bottom: 0;
}

.discovery-summary {
  margin: 0;
  padding: 4px 12px 10px;
  font-size: var(--text-caption);
  line-height: 1.5;
  color: var(--txt-3);
  max-height: 120px;
  overflow-y: auto;
}

/* ── No-results message ───────────────────────────────────────────────────── */
.no-records-msg {
  padding: 16px 12px;
  font-size: var(--text-caption);
  color: var(--txt-4);
  text-align: center;
  line-height: 1.5;
}

/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  #records-panel {
    width: 100%;
    max-height: 45vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  #results-body { flex-direction: column; }
  #view-results {
    height: auto;
    min-height: calc(100vh - var(--nav-height));
    overflow: auto;
  }
  #sankey-container { min-height: 260px; }
  #top-center { gap: 6px; }
  .treemap-container { min-height: 260px; }
}

@media (max-width: 420px) {
  .view-switch-label { display: none; }
}

/* ── Sankey SVG styles ────────────────────────────────────────────────────── */
.sankey-node rect {
  cursor: pointer;
  rx: 3;
  transition: opacity 0.15s;
}
.sankey-node rect:hover { opacity: 0.85; }

.sankey-link {
  fill: none;
  transition: opacity 0.15s;
}
.sankey-link:hover { opacity: 0.75 !important; }

.sankey-label {
  font-family: var(--font-data);
  font-size: 10px;
  fill: var(--txt-3);
  pointer-events: none;
  dominant-baseline: middle;
}

.sankey-label.label-domain {
  font-size: 11px;
  font-weight: 700;
  fill: var(--txt);
}

.sankey-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: var(--text-compact);
  color: var(--txt-4);
}

/* ── Visualizer-specific footer override (compact for app pages) ────────────── */

/* ════════════════════════════════════════════════════════════════════════════
   DETAIL PANEL (Sankey node click-through)
   ════════════════════════════════════════════════════════════════════════════ */

/* Both sub-panels live inside #records-panel and flex to fill it */
#records-content,
#detail-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#records-content[hidden],
#detail-content[hidden] { display: none; }

#detail-header {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-title-text {
  font-size: var(--text-compact);
  font-weight: 700;
  color: var(--txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  margin: 0;
}

.detail-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
}

.detail-section {
  margin-bottom: 14px;
}

.detail-hostname-label {
  font-size: 11px;
  color: var(--txt-4);
  font-family: var(--font-data);
  margin-bottom: 8px;
  word-break: break-all;
}

/* Record type colour badges */
.detail-type-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  margin-bottom: 6px;
  background: var(--surface2);
  color: var(--txt-2);
  letter-spacing: 0.03em;
}
.detail-type-badge.type-a      { background: var(--rtype-a-bg);      color: var(--rtype-a-fg); }
.detail-type-badge.type-aaaa   { background: var(--rtype-aaaa-bg);   color: var(--rtype-aaaa-fg); }
.detail-type-badge.type-txt    { background: var(--rtype-txt-bg);    color: var(--rtype-txt-fg); }
.detail-type-badge.type-mx     { background: var(--rtype-mx-bg);     color: var(--rtype-mx-fg); }
.detail-type-badge.type-cname  { background: var(--rtype-cname-bg);  color: var(--rtype-cname-fg); }
.detail-type-badge.type-ns     { background: var(--rtype-ns-bg);     color: var(--rtype-ns-fg); }
.detail-type-badge.type-soa    { background: var(--rtype-soa-bg);    color: var(--rtype-soa-fg); }
.detail-type-badge.type-caa    { background: var(--rtype-caa-bg);    color: var(--rtype-caa-fg); }
.detail-type-badge.type-ds,
.detail-type-badge.type-dnskey { background: var(--rtype-dnssec-bg); color: var(--rtype-dnssec-fg); }

.detail-rawdata {
  font-size: 11px;
  font-family: var(--font-data);
  word-break: break-all;
  color: var(--txt-2);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 7px 9px;
  margin-bottom: 6px;
  line-height: 1.5;
}

.detail-ttl {
  font-size: 10px;
  color: var(--txt-4);
  margin-top: 2px;
  margin-bottom: 8px;
}

/* Policy status badge (DMARC / SPF) */
.detail-policy-badge {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 7px;
  border: 1px solid;
  margin-bottom: 10px;
  font-size: var(--text-caption);
  font-weight: 600;
  line-height: 1.35;
}
.detail-policy-badge .policy-icon { font-size: var(--text-small); flex-shrink: 0; margin-top: 1px; }
.detail-policy-badge .policy-sub  { font-size: 10px; font-weight: 400; color: inherit; opacity: 0.8; display: block; margin-top: 2px; }

.detail-policy-badge.policy-none       { color: var(--amber);   border-color: var(--amber);   background: color-mix(in srgb, var(--amber) 8%, transparent); }
.detail-policy-badge.policy-quarantine { color: var(--primary); border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); }
.detail-policy-badge.policy-reject     { color: var(--green);   border-color: var(--green);   background: color-mix(in srgb, var(--green) 8%, transparent); }
.detail-policy-badge.policy-info       { color: var(--txt-3); border-color: var(--border); background: var(--surface2); }

/* Tag key-value tables (DMARC, MX, etc.) */
.detail-tags-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin-top: 4px;
}

.detail-tags-table .tag-row + .tag-row .tag-key,
.detail-tags-table .tag-row + .tag-row .tag-val,
.detail-tags-table .tag-row + .tag-row .tag-name {
  border-top: 1px solid var(--border);
}

.tag-key {
  font-family: var(--font-data);
  color: var(--txt-3);
  white-space: nowrap;
  padding: 4px 6px 4px 0;
  vertical-align: top;
  font-size: 10px;
}
.tag-val {
  font-family: var(--font-data);
  color: var(--txt);
  font-weight: 600;
  word-break: break-all;
  padding: 4px 6px;
  vertical-align: top;
  font-size: 10px;
}
.tag-name {
  color: var(--txt-3);
  padding: 4px 0 4px 4px;
  vertical-align: top;
  font-size: 10px;
}
.tag-desc-row td {
  padding: 0 0 5px 0;
  color: var(--txt-4);
  font-size: 10px;
  line-height: 1.4;
  border-top: none !important;
}

/* Tooltip "click to explore" hint */
.node-tooltip .tt-explore {
  color: var(--primary);
  margin-top: 3px;
  font-size: 10px;
  font-weight: 600;
}

/* IP enrichment slot */
.ip-enrich-slot { margin-top: 10px; }

.ip-enrich-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--txt-4);
  font-size: 11px;
  padding: 6px 0;
}

.ip-enrich-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: ip-spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

.ip-enrich-error {
  color: var(--txt-4);
  font-size: 11px;
  padding: 6px 0;
  font-style: italic;
}

.ip-enrich-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.ip-enrich-card-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--txt-4);
  padding: 5px 9px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* "Explore domain" button */
.btn-explore-domain {
  margin-top: 10px;
  background: var(--surface2);
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background var(--t-fast), border-color var(--t-fast);
  font-family: inherit;
}
.btn-explore-domain:hover {
  background: color-mix(in srgb, var(--primary) 8%, var(--surface2));
  border-color: var(--primary);
}

/* Sankey node hover — smooth opacity transition */
.sankey-node rect { transition: opacity 0.12s ease; }
