/* SPDX-License-Identifier: LicenseRef-CMSD-1.0 */
/* Copyright (c) 2026 CyberMind — Gérald Kerma <devel@cybermind.fr> */

/* Phase 11.B (#507) — Social mapping per-client view stylesheet.
   Palette: cosmos-black / gold-hermetic / cinnabar / matrix-green /
   void-purple / cyber-cyan / text-primary / text-muted.
   Typography: Cinzel (headers) + IM Fell English (body) + JetBrains Mono (code/data). */

:root {
  --cosmos-black: #0a0a0f;
  --gold-hermetic: #c9a84c;
  --cinnabar: #e63946;
  --matrix-green: #00ff41;
  --void-purple: #6e40c9;
  --cyber-cyan: #00d4ff;
  --text-primary: #e8e6d9;
  --text-muted: #6b6b7a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--cosmos-black); color: var(--text-primary); }
html, body { height: 100%; }
body {
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 15px;
  line-height: 1.5;
  /* Full-viewport flex layout : header (sticky), main (flex 1, owns the
     graph), node-detail (slides over).  Cards live inside main as a
     compact bottom row so the graph stays hero. */
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Header — compact, sticky, doesn't steal vertical space from the graph. */
.social-header {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--gold-hermetic);
  background: linear-gradient(180deg, rgba(201,168,76,.06), transparent);
}
.brand-title {
  font-family: 'Cinzel', serif;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.05em;
  color: var(--gold-hermetic);
}
.brand-divider { color: var(--text-muted); margin: 0 8px; }
.brand-subtitle { color: var(--text-primary); font-style: italic; }
.lang {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--text-muted);
  border-radius: 3px;
  padding: 2px 6px;
}

/* Main : flex column, takes all remaining height after the header.
   Graph fills the body of main ; stats + cards float over the corners. */
.social-main {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;          /* allow children to shrink past content size */
  overflow: hidden;
}
/* Phase 11.B v2 — intro paragraph hidden in full-viewport mode ; the
   graph itself + the hover hint communicate the same thing. */
.social-intro { display: none; }

/* Stats tiles — compact horizontal strip floating top-left over the
   graph.  Glassy background so the graph stays visually dominant. */
.stats {
  position: absolute; top: 8px; left: 8px;
  display: flex; gap: 6px;
  z-index: 5;
  pointer-events: none;
}
.stat-tile {
  background: rgba(10, 10, 15, .65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 212, 255, .35);
  border-radius: 3px;
  padding: 4px 9px;
  display: flex; align-items: baseline; gap: 5px;
}
.stat-n {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  color: var(--cyber-cyan);
  line-height: 1;
}
.stat-l { font-size: 10px; color: var(--text-muted); }

/* Graph fills all remaining vertical space inside .social-main. */
.graph-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: rgba(110, 64, 201, .03);
  overflow: hidden;
}
.graph-hint {
  position: absolute; top: 8px; right: 12px;
  font-size: 10px; color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  pointer-events: none;
}
#social-graph { display: block; width: 100%; height: 100%; touch-action: none; }

/* d3 node + edge styling — colors come from the data class on each element. */
.node circle { stroke: var(--cosmos-black); stroke-width: 1.5; }
.node text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  fill: var(--text-primary);
  pointer-events: none;
}
.edge { fill: none; stroke: var(--cyber-cyan); stroke-opacity: .55; }
.edge.spoke { stroke: var(--cinnabar); stroke-opacity: .28; }
.edge.focused {
  stroke: var(--gold-hermetic);
  stroke-opacity: 1;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { stroke-opacity: .35; stroke-width: 1.2; }
  50%      { stroke-opacity: 1; stroke-width: 3; }
}

/* ── Round-Eye central hotspot (Phase 12.A) ── */
.node-eye circle { stroke: none; }
.eye-halo {
  fill: var(--cinnabar);
  opacity: .12;
  transform-origin: center;
  transform-box: fill-box;
  animation: eye-breathe 2.6s ease-in-out infinite;
}
@keyframes eye-breathe {
  0%, 100% { opacity: .08; r: 22px; }
  50%      { opacity: .22; r: 30px; }
}
.eye-sclera { fill: #e8e6d9; }
.eye-iris   { fill: var(--cyber-cyan); }
.eye-pupil  { fill: var(--cosmos-black); }

/* Node detail panel — bottom sheet on mobile, side panel on desktop */
.node-detail {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--cosmos-black);
  border-top: 2px solid var(--gold-hermetic);
  padding: 12px 16px env(safe-area-inset-bottom);
  max-height: 50vh;
  overflow-y: auto;
  z-index: 100;
}
.node-detail header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.nd-domain {
  font-family: 'JetBrains Mono', monospace;
  color: var(--gold-hermetic);
  font-size: 14px;
}
.nd-close {
  background: transparent; border: 1px solid var(--text-muted);
  color: var(--text-primary); border-radius: 3px;
  padding: 2px 10px; cursor: pointer;
  font-size: 18px; line-height: 1;
}
.node-detail dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 13px; }
.node-detail dt { color: var(--text-muted); font-style: italic; }
.node-detail dd { margin: 0; color: var(--text-primary); font-family: 'JetBrains Mono', monospace; font-size: 12px; word-break: break-word; }

/* Cards row — floats at the bottom of the viewport as a 3-cell
   horizontal strip ; each <details> opens upward as a popover so the
   graph stays visible while you interact with a card. */
.card {
  background: rgba(201, 168, 76, .04);
  border: 1px solid rgba(201, 168, 76, .25);
  border-radius: 4px;
}
.cards-row {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 6px 8px env(safe-area-inset-bottom);
  background: rgba(10, 10, 15, .85);
  border-top: 1px solid var(--gold-hermetic);
}
.cards-row .card {
  margin: 0;
  padding: 6px 8px;
  font-size: 12px;
}
.card summary {
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--gold-hermetic);
  list-style: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Open-card popover : opens upward so cards stay readable above the
   bottom strip. */
.cards-row .card[open] {
  position: absolute;
  left: 8px; right: 8px;
  bottom: calc(50px + env(safe-area-inset-bottom));
  background: rgba(10, 10, 15, .96);
  border-color: var(--gold-hermetic);
  padding: 12px 16px;
  z-index: 8;
}
.card summary::-webkit-details-marker { display: none; }
.card summary::after { content: ' ▾'; color: var(--text-muted); font-size: 12px; }
.card[open] summary::after { content: ' ▴'; }
.card-pending { color: var(--text-muted); font-style: italic; margin: 8px 0 4px; }
.card-wipe { border-color: rgba(230, 57, 70, .4); background: rgba(230, 57, 70, .03); }
.card-wipe summary { color: var(--cinnabar); }

/* Buttons */
.wipe-btn {
  display: block; width: 100%; margin-top: 8px;
  background: transparent; color: var(--cinnabar);
  border: 1px solid var(--cinnabar); border-radius: 3px;
  padding: 10px;
  font-family: 'Cinzel', serif; letter-spacing: 0.06em; cursor: pointer;
}
.wipe-btn:hover { background: rgba(230, 57, 70, .1); }

/* Phase 11.C — PDF report download button */
.pdf-btn {
  display: block; width: 100%; margin-top: 8px;
  text-align: center; text-decoration: none;
  background: transparent; color: var(--gold-hermetic);
  border: 1px solid var(--gold-hermetic); border-radius: 3px;
  padding: 10px;
  font-family: 'Cinzel', serif; letter-spacing: 0.06em;
}
.pdf-btn:hover { background: rgba(201, 168, 76, .12); }

/* Modal */
dialog#wipe-modal {
  background: var(--cosmos-black);
  color: var(--text-primary);
  border: 2px solid var(--cinnabar);
  border-radius: 4px;
  max-width: 420px;
  padding: 20px;
}
dialog::backdrop { background: rgba(10, 10, 15, .85); }
dialog h2 {
  font-family: 'Cinzel', serif;
  color: var(--cinnabar);
  font-size: 18px;
  letter-spacing: 0.05em;
  margin: 0 0 12px;
}
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.btn-secondary, .btn-danger {
  flex: 1;
  padding: 10px;
  border-radius: 3px;
  font-family: 'Cinzel', serif;
  letter-spacing: 0.06em;
  cursor: pointer;
  font-size: 13px;
}
.btn-secondary { background: transparent; color: var(--text-primary); border: 1px solid var(--text-muted); }
.btn-danger { background: var(--cinnabar); color: var(--cosmos-black); border: 1px solid var(--cinnabar); font-weight: bold; }
.btn-danger:disabled { background: rgba(230, 57, 70, .25); color: var(--text-muted); cursor: not-allowed; border-color: var(--text-muted); }
.wipe-countdown {
  color: var(--gold-hermetic);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  text-align: center;
  margin: 8px 0;
}

@media (min-width: 720px) {
  /* Desktop : node detail slides in from the right rail instead of bottom sheet */
  .node-detail { top: 70px; bottom: auto; right: 14px; left: auto; width: 320px; max-height: 60vh; border-top: 0; border-left: 2px solid var(--gold-hermetic); border-radius: 4px; }
}

/* ── Anti-bot / "prove you're human" (Phase 12.B) ── */
.antibot-ring {
  fill: none;
  stroke: var(--cinnabar);
  stroke-width: 1.5;
  stroke-dasharray: 3 2;
  opacity: .8;
  animation: antibot-spin 6s linear infinite;
  transform-origin: center;
  transform-box: fill-box;
}
@keyframes antibot-spin { to { transform: rotate(360deg); } }
.antibot-alert {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  z-index: 6;
  background: rgba(230, 57, 70, .92);
  color: #0a0a0f;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: bold;
  padding: 5px 12px;
  border-radius: 3px;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 2px 10px rgba(230,57,70,.4);
}

/* ── Round-Eye ring guides (Phase 12.A/B) ── */
.ring-guides circle { fill: none; stroke-width: 1; pointer-events: none; }
.ring-inner { stroke: var(--gold-hermetic); stroke-opacity: .18; stroke-dasharray: 2 4; }
.ring-outer { stroke: var(--cyber-cyan); stroke-opacity: .14; stroke-dasharray: 2 6; }

/* ── Operator-grade / state-adjacent (Phase 12.C) — top severity ── */
.opgrade-ring {
  fill: none;
  stroke: var(--void-purple);
  stroke-width: 2;
  opacity: .9;
  animation: opgrade-pulse 1.8s ease-in-out infinite;
  transform-origin: center;
  transform-box: fill-box;
}
@keyframes opgrade-pulse { 0%,100% { r: 13px; opacity: .5; } 50% { r: 17px; opacity: 1; } }
.opgrade-alert {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  z-index: 7;
  background: var(--void-purple);
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; font-weight: bold;
  padding: 5px 12px; border-radius: 3px;
  max-width: 90%; text-align: center;
  box-shadow: 0 2px 12px rgba(110,64,201,.5);
}
.opgrade-alert + .antibot-alert { top: 38px; }
