/* === Theme tokens =========================================================== */
:root {
  --bg: #f7f3ed;
  --bg-dot: rgba(0, 0, 0, 0.06);
  --ink: #221a3a;
  --ink-soft: #6b6580;
  --ink-faint: #a39db4;
  --rule: rgba(34, 26, 58, 0.12);
  --card-bg: #ffffff;
  --chip-bg: #ffffff;
  --chip-ink: #221a3a;
  --link: #4f3fbf;

  --c-security: #6f5fbf;     /* lavender / violet */
  --c-it:       #6c8d63;     /* sage green */
  --c-other:    #d8a073;     /* peach */

  --col-applicationsecurity: #4d8767;
  --col-cloudsecurity:       #4d8a87;
  --col-itservicedeliveryandsupport: #4f7fb8;
  --col-governanceriskandcompliance: #8466b9;
  --col-networking:          #c54f7d;
  --col-networksecurity:     #b58741;
  --col-infrastructuremanagement: #c46b46;
  --col-identityandaccessmanagement: #845cba;
  --col-threatintelligence:  #b84a45;
  --col-applicationmanagement: #a06a3f;
  --col-incidentresponse:    #5d8a52;
  --col-vulnerabilitymanagement: #d76e3c;
  --col-datalossprevention:  #3a4d80;
  --col-other:               #a26a4a;
}
[data-theme='dark'] {
  --bg: #1a1626;
  --bg-dot: rgba(255, 255, 255, 0.05);
  --ink: #f1edff;
  --ink-soft: #a59ec0;
  --ink-faint: #6b6582;
  --rule: rgba(255, 255, 255, 0.1);
  --card-bg: #251f36;
  --chip-bg: #2c2640;
  --chip-ink: #f1edff;
  --link: #b8a8ff;
}

/* === Reset / base ============================================================ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: ui-serif, "Iowan Old Style", "Charter", "Georgia", serif;
  background: var(--bg);
  color: var(--ink);
  background-image:
    radial-gradient(var(--bg-dot) 1px, transparent 1px);
  background-size: 14px 14px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
a { color: var(--link); }

/* === Topbar ================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px;
  backdrop-filter: blur(10px);
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-soft); }
.brand-mark {
  width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(from 90deg, #6f5fbf, #d8a073, #6c8d63, #6f5fbf);
}
.brand-text { letter-spacing: 0.02em; }
.topbar-actions { display: flex; gap: 8px; }
.ghost {
  border: 1px solid var(--rule);
  background: var(--chip-bg);
  color: var(--chip-ink);
  padding: 6px 12px;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  font-size: 13px;
}
.ghost:hover { border-color: var(--ink-soft); }

/* === Hero ==================================================================== */
.hero {
  display: grid;
  grid-template-columns: minmax(320px, 460px) 1fr;
  gap: 40px;
  padding: 48px 28px 24px;
  align-items: start;
  max-width: 1700px; margin: 0 auto;
}
.hero h1 {
  font-size: clamp(48px, 5vw, 72px);
  line-height: 0.95;
  margin: 0 0 24px;
  font-weight: 500;
  color: #4f3fbf;
}
[data-theme='dark'] .hero h1 { color: #b8a8ff; }
.lede { color: var(--ink-soft); max-width: 460px; line-height: 1.5; font-size: 16px; }

.controls { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--chip-bg);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 8px 16px;
  color: var(--ink-soft);
  flex: 1; min-width: 180px;
}
.search input { background: none; border: 0; outline: 0; width: 100%; color: var(--ink); }
.select { position: relative; }
#categoryBtn {
  background: var(--chip-bg);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--ink);
}
#categoryBtn:hover { border-color: var(--ink-soft); }
#categoryMenu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 20;
  background: var(--chip-bg);
  border: 1px solid var(--rule);
  border-radius: 14px;
  list-style: none; margin: 0; padding: 6px;
  min-width: 240px; max-height: 360px; overflow: auto;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}
#categoryMenu li {
  padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
#categoryMenu li:hover { background: color-mix(in oklab, var(--ink) 8%, transparent); }
#categoryMenu li[aria-selected='true'] { background: color-mix(in oklab, var(--link) 14%, transparent); }
#categoryMenu li .swatch { width: 10px; height: 10px; border-radius: 50%; }
#categoryMenu li .num { color: var(--ink-faint); font-size: 12px; }

.status { color: var(--ink-soft); margin-top: 14px; font-size: 14px; }
.status .hint { color: var(--ink-faint); }
.status.sub { margin-top: 4px; }

/* === Venn ==================================================================== */
.venn-wrap { display: flex; justify-content: center; align-items: center; }
#venn { width: 100%; max-width: 560px; height: auto; }
.vcircle {
  fill-opacity: 0.45;
  stroke-width: 1.2;
  cursor: pointer;
  transition: fill-opacity 0.18s ease, transform 0.2s ease;
  transform-origin: center;
  transform-box: fill-box;
  mix-blend-mode: multiply;
}
[data-theme='dark'] .vcircle { mix-blend-mode: screen; }
.vcircle[data-team='security'] { fill: #cdc1ee; stroke: #6f5fbf; }
.vcircle[data-team='it']       { fill: #c5d6bb; stroke: #6c8d63; }
.vcircle[data-team='other']    { fill: #f1cfb1; stroke: #d8a073; }
.vcircle:hover { fill-opacity: 0.62; }
.vcircle.active { fill-opacity: 0.78; }
.vcircle.dim    { fill-opacity: 0.18; }

.vlabels { pointer-events: auto; }
.vlabel {
  font-family: ui-serif, "Iowan Old Style", serif;
  font-style: italic;
  font-size: 23px;
  font-weight: 600;
  text-anchor: middle;
  cursor: pointer;
  user-select: none;
  paint-order: stroke fill;       /* halo behind text for readability over circle fill */
  stroke: var(--bg);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.vlabel:hover { opacity: 0.78; }
.vcount {
  font-size: 11px;
  font-style: normal;
  font-weight: 500;
  paint-order: stroke fill;
  stroke: var(--bg);
  stroke-width: 3px;
}
.vlabel[data-team='security'] { fill: #4f3fbf; }
.vlabel[data-team='it']       { fill: #4d6f48; }
.vlabel[data-team='other']    { fill: #a05f3a; }
.vcount { font-size: 11px; font-style: normal; }

/* === Canvas tools ============================================================ */
.canvas-tools {
  position: sticky; bottom: 16px; z-index: 30;
  display: flex; gap: 8px; align-items: center;
  width: max-content; margin: 0 auto;
  background: var(--chip-bg); border: 1px solid var(--rule);
  border-radius: 999px; padding: 6px 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
.chip {
  border: 0; background: transparent; color: var(--ink);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 13px;
}
.chip:hover { background: color-mix(in oklab, var(--ink) 8%, transparent); }
.chip.on { background: color-mix(in oklab, var(--link) 16%, transparent); color: var(--link); }
.chip-icon {
  border: 0; background: transparent; color: var(--ink-soft); cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%; font-size: 16px;
}
.chip-icon:hover { background: color-mix(in oklab, var(--ink) 8%, transparent); color: var(--ink); }
.chip-label { color: var(--ink-soft); font-size: 12px; min-width: 36px; text-align: center; }

/* === Connections SVG overlay ================================================= */
/* Sits BEHIND the card grid so text stays readable. The cards' stacking context
   (set on .canvas below) layers above this. */
#connections {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 0;
}
#connectionsSvg { width: 100%; height: 100%; }
#connectionsSvg path { fill: none; stroke-width: 0.5; opacity: 0.16; transition: opacity 0.15s ease, stroke-width 0.15s ease; }
#connectionsSvg path.security { stroke: #6f5fbf; }
#connectionsSvg path.it       { stroke: #6c8d63; }
#connectionsSvg path.other    { stroke: #d8a073; }
#connectionsSvg path.security.it { stroke: #99a294; }
#connectionsSvg path.dim      { opacity: 0.04; }
#connectionsSvg path.hot      { opacity: 0.5; stroke-width: 0.9; }

/* === Canvas (columns) ======================================================== */
.canvas-wrap {
  /* the canvas itself takes scaling; this wrapper provides the scroll viewport */
  position: relative;
}
.canvas {
  display: grid;
  grid-template-columns: repeat(14, minmax(220px, 1fr));
  gap: 18px;
  padding: 8px 28px 80px;
  align-items: start;
  max-width: 100%;
  transform-origin: top left;
  transition: transform 0.25s ease;
  overflow-x: auto;
  position: relative;     /* establish stacking context above #connections */
  z-index: 1;
}
.canvas:focus { outline: none; }

.column { color: var(--col); display: flex; flex-direction: column; gap: 14px; }
.column-head { font-family: ui-serif, "Iowan Old Style", serif; font-style: italic; font-weight: 600; font-size: 22px; line-height: 1.05; color: var(--col); }
.column-count { color: color-mix(in oklab, var(--col) 70%, transparent); font-size: 13px; font-style: italic; margin-top: 2px; }

.subjob { display: flex; flex-direction: column; gap: 8px; }
.subjob-label { font-size: 12px; color: color-mix(in oklab, var(--col) 75%, transparent); font-style: italic; padding-left: 4px; }

.card {
  display: flex; flex-direction: column; gap: 4px;
  background: color-mix(in oklab, var(--col) 12%, var(--card-bg));
  border: 1px solid color-mix(in oklab, var(--col) 30%, transparent);
  border-radius: 6px;
  padding: 12px 14px;
  text-decoration: none;
  color: var(--ink);
  position: relative;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  min-height: 64px;
  outline: none;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
.card:hover, .card:focus-visible {
  transform: translateY(-1px);
  border-color: color-mix(in oklab, var(--col) 60%, transparent);
  box-shadow: 0 6px 14px color-mix(in oklab, var(--col) 18%, transparent);
}
.card .name { font-weight: 600; font-size: 14px; line-height: 1.3; }
.card .team { color: color-mix(in oklab, var(--ink) 65%, transparent); font-size: 12px; }
.card.built { background: color-mix(in oklab, var(--col) 22%, var(--card-bg)); }

.card .check {
  position: absolute; top: 10px; right: 10px;
  width: 18px; height: 18px;
  border-radius: 4px;
  border: 1.4px solid color-mix(in oklab, var(--col) 60%, transparent);
  background: var(--card-bg);
  cursor: pointer;
  display: grid; place-items: center;
  color: white;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.card .check.on {
  background: var(--col);
  border-color: var(--col);
}
.card .check svg { display: none; width: 11px; height: 11px; }
.card .check.on svg { display: block; }

/* Hidden state + dim */
.card[hidden] { display: none; }
.card.dim { opacity: 0.18; pointer-events: none; }
.column.dim .column-head { opacity: 0.4; }
.column[hidden] { display: none !important; }

/* === Detail panel ============================================================ */
.detail {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: min(420px, 100%);
  background: var(--card-bg);
  border-left: 1px solid var(--rule);
  z-index: 60;
  padding: 24px;
  overflow-y: auto;
  box-shadow: -16px 0 40px rgba(0, 0, 0, 0.12);
  transform: translateX(0);
  transition: transform 0.2s ease;
}
.detail[hidden] { display: block !important; transform: translateX(100%); pointer-events: none; }
.detail #detailClose {
  position: absolute; top: 12px; right: 12px; border: 0; background: transparent;
  font-size: 26px; color: var(--ink-soft); cursor: pointer; line-height: 1;
}
.detail h2 { font-family: ui-serif, "Iowan Old Style", serif; font-style: italic; font-size: 28px; line-height: 1.1; margin: 8px 0 6px; }
.detail .meta { color: var(--ink-soft); font-size: 13px; margin-bottom: 20px; display: flex; flex-direction: column; gap: 4px; }
.detail .meta strong { color: var(--ink); font-weight: 600; }
.detail .actions { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.detail .actions a, .detail .actions button {
  background: var(--chip-bg); border: 1px solid var(--rule); border-radius: 999px;
  padding: 7px 14px; font-size: 13px; text-decoration: none; color: var(--ink); cursor: pointer;
}
.detail .crosslist { font-size: 13px; color: var(--ink-soft); }
.detail .crosslist ul { padding-left: 18px; }

@media (max-width: 1100px) {
  .hero { grid-template-columns: 1fr; gap: 24px; }
  .canvas { grid-template-columns: repeat(14, 220px); }
}
