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

/* ── Page body layout ─────────────────────────────────────────────────────── */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

/* ── Button base (page-level overrides) ───────────────────────────────────── */
button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), opacity var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  padding: 10px 20px;
}
.btn-primary:hover { background: var(--primary-dk); border-color: var(--primary-dk); }

.btn-ghost {
  background: transparent;
  color: var(--txt-2);
  border-color: var(--border);
  padding: 7px 13px;
}
.btn-ghost:hover { background: var(--surface2); color: var(--txt); }
.btn-sm { padding: 5px 11px; font-size: 12px; }

/* ════════════════════════════════════════════════════════════════════════════
   LANDING VIEW
   ════════════════════════════════════════════════════════════════════════════ */
#view-landing {
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 40px 16px 60px;
}

.landing-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: 100%;
  max-width: 520px;
  text-align: center;
}

/* Panopticon eye */
.eye-wrap { margin-bottom: 28px; }

.eye-svg {
  width: 96px;
  height: 96px;
  overflow: visible;
}

.eye-ring-outer {
  transform-origin: 60px 60px;
  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); }
}

.eye-svg.spinning .eye-ring-outer {
  animation: eye-spin 1.8s linear infinite;
}

@keyframes eye-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.landing-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--txt);
  margin-bottom: 8px;
}

.landing-sub {
  font-size: 15px;
  color: var(--txt-3);
  margin-bottom: 32px;
  line-height: 1.5;
}

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

.input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

#domain-input {
  flex: 1;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--txt);
  font-family: 'Inter', monospace;
  font-size: 15px;
  transition: border-color var(--t-fast);
  outline: none;
}

#domain-input::placeholder { color: var(--txt-4); }
#domain-input:focus { border-color: var(--primary); }
#btn-scan { flex-shrink: 0; font-size: 14px; padding: 11px 22px; }

/* Mode pills */
.mode-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 10px;
}

.mode-pill {
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--txt-3);
}
.mode-pill:hover { border-color: var(--primary); color: var(--primary); }
.mode-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.mode-desc {
  font-size: 12px;
  color: var(--txt-4);
  margin-bottom: 28px;
  min-height: 16px;
}

.privacy-note {
  font-size: 12px;
  color: var(--txt-4);
  margin-top: 4px;
}
.privacy-note a { color: var(--primary); text-decoration: none; }
.privacy-note a:hover { text-decoration: underline; }

/* ════════════════════════════════════════════════════════════════════════════
   SCANNING VIEW
   ════════════════════════════════════════════════════════════════════════════ */
#view-scanning {
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}

.scanning-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  text-align: center;
}

.scanning-eye { margin-bottom: 24px; }

.scanning-domain {
  font-size: 17px;
  font-weight: 700;
  color: var(--txt);
  margin-bottom: 28px;
  font-family: 'Inter', monospace;
}

.scan-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 240px;
  margin-bottom: 28px;
}

.scan-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--txt-4);
  text-align: left;
}

.scan-step::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--surface2);
  border: 2px solid var(--border);
}

.scan-step.active { color: var(--primary); }
.scan-step.active::before {
  background: transparent;
  border-color: var(--primary);
  border-top-color: transparent;
  animation: step-spin 0.7s linear infinite;
}

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

.scan-step.done { color: var(--txt-3); }
.scan-step.done::before {
  background: var(--green);
  border-color: var(--green);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2 6l3 3 5-5' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 10px;
  background-repeat: no-repeat;
  background-position: center;
}

/* ════════════════════════════════════════════════════════════════════════════
   ERROR VIEW
   ════════════════════════════════════════════════════════════════════════════ */
#view-error {
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}

.error-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  text-align: center;
  max-width: 380px;
}

.error-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--red) 12%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  color: var(--red);
  font-size: 22px;
}

.error-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--txt);
  margin-bottom: 8px;
}

.error-msg {
  font-size: 14px;
  color: var(--txt-3);
  line-height: 1.5;
  margin-bottom: 24px;
}

.error-actions { display: flex; gap: 8px; }

.error-debug {
  margin-top: 20px;
  text-align: left;
  width: 100%;
}

.error-debug summary {
  font-size: 12px;
  color: var(--txt-3);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.error-debug summary::-webkit-details-marker { display: none; }
.error-debug summary::before {
  content: '▶';
  font-size: 9px;
  transition: transform 0.15s;
  display: inline-block;
}
.error-debug[open] summary::before { transform: rotate(90deg); }

.error-debug pre {
  margin-top: 10px;
  padding: 12px;
  background: color-mix(in srgb, var(--txt) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--txt) 10%, transparent);
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--txt-3);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 260px;
  overflow-y: auto;
}

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

/* Score bar */
#score-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;
}

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

.result-domain {
  font-size: 14px;
  font-weight: 700;
  font-family: 'Inter', monospace;
  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;
}

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

.grade-badge {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.score-number {
  font-size: 20px;
  font-weight: 800;
  color: var(--txt);
}

.category-scores {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
}

.cat-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface2);
  color: var(--txt-3);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.cat-pill.grade-a { background: color-mix(in srgb, #0f766e 12%, transparent); color: #0f766e; border-color: color-mix(in srgb, #0f766e 25%, transparent); }
.cat-pill.grade-b { background: color-mix(in srgb, #0891b2 12%, transparent); color: #0891b2; border-color: color-mix(in srgb, #0891b2 25%, transparent); }
.cat-pill.grade-c { background: color-mix(in srgb, #b45309 12%, transparent); color: #b45309; border-color: color-mix(in srgb, #b45309 25%, transparent); }
.cat-pill.grade-d { background: color-mix(in srgb, #c2410c 12%, transparent); color: #c2410c; border-color: color-mix(in srgb, #c2410c 25%, transparent); }
.cat-pill.grade-f { background: color-mix(in srgb, #b91c1c 12%, transparent); color: #b91c1c; border-color: color-mix(in srgb, #b91c1c 25%, transparent); }

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

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

/* 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);
}

.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;
}

/* Node tooltip */
.node-tooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 13px;
  font-size: 12px;
  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; }

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

#findings-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: 13px;
  font-weight: 700;
  color: var(--txt);
}

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

.severity-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.sev-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  color: var(--txt-4);
}
.sev-pill:hover { color: var(--txt-2); border-color: var(--txt-3); }
.sev-pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.sev-pill.sev-critical.active { background: #dc2626; border-color: #dc2626; }
.sev-pill.sev-high.active    { background: #ea580c; border-color: #ea580c; }
.sev-pill.sev-medium.active  { background: #d97706; border-color: #d97706; }
.sev-pill.sev-low.active     { background: #65a30d; border-color: #65a30d; }
.sev-pill.sev-info.active    { background: #64748b; border-color: #64748b; }

/* Findings list */
.findings-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.finding-card {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--t-fast);
}
.finding-card:last-child { border-bottom: none; }
.finding-card:hover { background: var(--surface2); }
.finding-card.expanded { background: var(--surface2); }

.finding-top {
  display: flex;
  align-items: flex-start;
  gap: 7px;
}

.finding-sev-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.finding-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--txt);
  line-height: 1.4;
  flex: 1;
}

.finding-pass-icon {
  font-size: 11px;
  flex-shrink: 0;
  margin-top: 2px;
}

.finding-summary {
  font-size: 11px;
  color: var(--txt-3);
  line-height: 1.5;
  margin-top: 4px;
  padding-left: 15px;
}

.finding-detail {
  display: none;
  font-size: 11px;
  color: var(--txt-3);
  line-height: 1.5;
  margin-top: 6px;
  padding: 7px 9px;
  background: var(--bg);
  border-radius: 5px;
  border: 1px solid var(--border);
}

.finding-card.expanded .finding-detail { display: block; }

.finding-affected {
  margin-top: 5px;
  font-size: 10px;
  color: var(--txt-4);
  font-family: 'Inter', monospace;
}

/* Tools section */
#tools-section {
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  max-height: 220px;
  overflow-y: auto;
}

#tools-section .panel-title-row {
  padding: 8px 12px 4px;
  margin-bottom: 0;
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tools-list { padding: 4px 0; }

.tool-item {
  display: flex;
  flex-direction: column;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  gap: 2px;
}
.tool-item:last-child { border-bottom: none; }

.tool-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  flex: 1;
}
.tool-name:hover { text-decoration: underline; }

.tool-cat-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--surface2);
  color: var(--txt-4);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tool-desc {
  font-size: 11px;
  color: var(--txt-4);
  line-height: 1.4;
}

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

/* ════════════════════════════════════════════════════════════════════════════
   HELP MODAL
   ════════════════════════════════════════════════════════════════════════════ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.overlay[hidden] { display: none; }

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, #000 50%, transparent);
}

.overlay-panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px color-mix(in srgb, #000 25%, transparent);
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.overlay-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--txt);
}

.overlay-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--txt-3);
  padding: 0 4px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
}
.overlay-close:hover { color: var(--txt); background: var(--surface2); }

.overlay-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 13px;
  color: var(--txt-2);
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.overlay-body h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--txt-4);
  margin-bottom: -6px;
}

.overlay-body dl { display: flex; flex-direction: column; gap: 6px; }
.overlay-body dt { font-weight: 700; color: var(--txt); }
.overlay-body dd { margin-left: 12px; color: var(--txt-3); }

/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 680px) {
  #findings-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; }
  .category-scores { display: none; }
  #score-center { gap: 6px; }
}

/* ── Sankey SVG styles ────────────────────────────────────────────────────── */
.sankey-node rect {
  cursor: pointer;
  rx: 3;
  transition: opacity 0.15s;
}
.sankey-node rect:hover { opacity: 0.85; }
.sankey-node.selected rect { stroke: var(--txt); stroke-width: 2; }

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

.sankey-label {
  font-family: 'Inter', monospace;
  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: 13px;
  color: var(--txt-4);
}

/* ── Explorer-specific footer override (compact for app pages) ────────────── */
#site-footer.explorer-footer {
  padding: 10px 16px;
}
