/* Interactive threat-toggle widget — landing page only.
   Layout, app grid, toggle pills, tagged-app overlays.
   ----------------------------------------------------- */

.section-threats {
  background:
    linear-gradient(180deg, rgba(239, 68, 68, 0.025) 0%, transparent 100%);
}

/* Threat-color tokens. Each toggle applies its color to matching
   apps via [data-active-threats~="X"] selectors below. */
:root {
  --tc-data-leak:    #ef4444;
  --tc-malware:      #f59e0b;
  --tc-phishing:     #eab308;
  --tc-privacy:      #7c5cff;
  --tc-exploit:      #ec4899;
  --tc-surveillance: #06b6d4;
}

.threat-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 60px;
  align-items: start;
  margin-top: 16px;
}
@media (max-width: 980px) {
  .threat-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }
}

/* ─── Toggles column ───────────────────────────────────────── */
.threat-controls {
  position: sticky;
  top: 100px;
}
@media (max-width: 980px) {
  .threat-controls { position: static; }
}
.threat-controls-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-mute);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 14px;
}
.threat-toggles {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
}
.threat-toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.threat-toggle:hover {
  border-color: var(--line-strong, #2b3450);
}
.threat-toggle.is-active {
  background: linear-gradient(110deg, rgba(239,68,68,0.06), var(--bg-card) 80%);
}

/* per-threat tint applied to the toggle when active */
.threat-toggle[data-threat="data-leak"].is-active    { border-color: rgba(239, 68, 68, 0.5); }
.threat-toggle[data-threat="malware"].is-active      { border-color: rgba(245, 158, 11, 0.5); }
.threat-toggle[data-threat="phishing"].is-active     { border-color: rgba(234, 179, 8, 0.5); }
.threat-toggle[data-threat="privacy"].is-active      { border-color: rgba(124, 92, 255, 0.5); }
.threat-toggle[data-threat="exploit"].is-active      { border-color: rgba(236, 72, 153, 0.5); }
.threat-toggle[data-threat="surveillance"].is-active { border-color: rgba(6, 182, 212, 0.5); }

.threat-toggle-switch {
  display: inline-block;
  position: relative;
  width: 32px;
  height: 18px;
  background: var(--bg-deep);
  border: 1px solid var(--line-strong, #2b3450);
  border-radius: 999px;
  flex-shrink: 0;
  transition: background 0.18s, border-color 0.18s;
}
.threat-toggle-switch span {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--fg-mute);
  transition: left 0.18s, background 0.18s;
}
.threat-toggle.is-active .threat-toggle-switch {
  background: currentColor;
  border-color: currentColor;
}
.threat-toggle.is-active .threat-toggle-switch span {
  left: 15px;
  background: #fff;
}

/* Color the switch itself per threat when active */
.threat-toggle[data-threat="data-leak"].is-active    { color: var(--tc-data-leak); }
.threat-toggle[data-threat="malware"].is-active      { color: var(--tc-malware); }
.threat-toggle[data-threat="phishing"].is-active     { color: var(--tc-phishing); }
.threat-toggle[data-threat="privacy"].is-active      { color: var(--tc-privacy); }
.threat-toggle[data-threat="exploit"].is-active      { color: var(--tc-exploit); }
.threat-toggle[data-threat="surveillance"].is-active { color: var(--tc-surveillance); }

.threat-toggle-text {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
}
.threat-toggle.is-active .threat-toggle-text { color: var(--fg-strong); }

.threat-toggle-count {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-dim);
  background: var(--bg-deep);
  border-radius: 999px;
  padding: 2px 8px;
  min-width: 24px;
  text-align: center;
}
.threat-toggle.is-active .threat-toggle-count {
  color: currentColor;
  background: rgba(255, 255, 255, 0.06);
}

.threat-controls-foot {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  color: var(--fg-mute);
  line-height: 1.55;
}
.threat-controls-foot strong {
  color: var(--fg-strong);
}

/* ─── Phone (large variant for this widget) ────────────────── */
.threat-phone-wrap {
  display: flex;
  justify-content: center;
}
.phone.phone-large {
  width: min(100%, 360px);
  border-radius: 42px;
  padding: 9px;
}
.phone-large .phone-screen { border-radius: 33px; }
.phone-large .phone-camera { width: 10px; height: 10px; top: 14px; }

/* The home screen is a column: status bar, app grid, dock */
.phone-home-screen {
  background:
    radial-gradient(ellipse at 30% 0%, rgba(124, 92, 255, 0.10) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 100%, rgba(59, 109, 255, 0.08) 0%, transparent 50%),
    linear-gradient(180deg, #0a0d14 0%, #131a26 100%);
  display: flex;
  flex-direction: column;
}

.phone-home-screen .status-bar {
  padding: 16px 22px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-strong);
}
.phone-home-screen .status-icons { color: var(--fg-strong); }

/* App grid (4 columns) */
.phone-apps {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 4px;
  padding: 14px 14px 18px;
}

.papp {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 4px 2px;
  border-radius: 10px;
  transition: filter 0.25s, opacity 0.25s, transform 0.25s;
}

.papp-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  position: relative;
  transition: filter 0.25s, transform 0.2s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.papp-name {
  font-size: 9.5px;
  font-weight: 500;
  color: var(--fg-strong);
  text-align: center;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  transition: color 0.25s;
}

/* Dock: 4 icons in a pill */
.phone-dock {
  margin: 6px 14px 18px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 22px;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.papp-icon-dock {
  width: 36px;
  height: 36px;
  font-size: 16px;
  border-radius: 10px;
}

/* ─── Tagged-app states (toggle ON) ────────────────────────── */
/*
 * The widget wrapper carries [data-active-threats="data-leak privacy ..."]
 * (set by JS). Each app has [data-threats="..."]. CSS applies a class-like
 * effect via attribute matching: when an active threat matches one of the
 * app's threats, the icon dims and a colored ring + warning glyph appear.
 */

/* Default: any toggle on → desaturate untagged apps */
.threat-grid[data-any-active="1"] .papp { filter: grayscale(0.55) brightness(0.6); }
.threat-grid[data-any-active="1"] .papp-name { color: var(--fg-mute); }

/* Tagged apps come back into focus and get a colored ring + warning */
.threat-grid .papp.is-tagged {
  filter: none;
  z-index: 1;
}
.threat-grid .papp.is-tagged .papp-name {
  color: var(--fg-strong);
  font-weight: 600;
}

.threat-grid .papp.is-tagged .papp-icon {
  outline: 2px solid var(--threat-color, #ef4444);
  outline-offset: 2px;
  box-shadow:
    0 0 0 4px rgba(0, 0, 0, 0.5),
    0 0 18px var(--threat-color-glow, rgba(239, 68, 68, 0.45));
}

/* Warning glyph */
.threat-grid .papp.is-tagged::after {
  content: "";
  position: absolute;
  top: -2px;
  right: 6px;
  width: 14px;
  height: 14px;
  background: var(--threat-color, #ef4444);
  border: 2px solid var(--bg);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--threat-color-glow, rgba(239, 68, 68, 0.55));
}
.threat-grid .papp.is-tagged::before {
  content: "!";
  position: absolute;
  top: 1px;
  right: 11px;
  width: 9px;
  height: 9px;
  z-index: 2;
  font-family: var(--font);
  font-size: 9px;
  font-weight: 800;
  color: #fff;
  text-align: center;
  line-height: 9px;
  pointer-events: none;
}

/* Legacy .papp-tags styles removed — explanations now live in
   .threat-callouts (a list anchored beside the phone). The icon's
   in-grid footprint stays fixed, so toggling threats no longer
   spreads the icons out. */

/* Numbered badge on each tagged icon. data-num is set by threats.js
   based on the position in the callout list. Replaces the previous
   "!" warning glyph for tagged apps. */
.threat-grid .papp.is-tagged::before {
  content: attr(data-num);
  position: absolute;
  top: -3px;
  right: 0;
  width: 18px;
  height: 18px;
  background: var(--threat-color, #ef4444);
  border: 2px solid var(--bg);
  border-radius: 50%;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  text-align: center;
  line-height: 14px;
  box-shadow: 0 0 10px var(--threat-color-glow, rgba(239, 68, 68, 0.55));
  z-index: 2;
  pointer-events: none;
}
/* Override the older ::after spec glyph since we now use ::before
   numbered badge as the visual anchor. */
.threat-grid .papp.is-tagged::after { content: none; }

/* ─── Callout list outside the phone ─────────────────────────
   Vertical list of cards anchored to the right of the phone (or
   below on mobile). Each card carries a numbered chip that matches
   the icon's ::before badge, plus a short "tail" line that visually
   reaches toward the phone — the line + chip pairing communicates
   "this explanation belongs to that icon" without requiring SVG-
   level precise pointers (fragile at every resize). */
.threat-callouts {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.threat-grid .threat-phone-wrap {
  display: grid;
  grid-template-columns: auto minmax(0, 360px);
  gap: 28px;
  align-items: start;
  justify-content: start;
}
@media (max-width: 980px) {
  .threat-grid .threat-phone-wrap {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .threat-callouts { max-width: 480px; width: 100%; }
}
.threat-callouts:empty {
  display: none;
}

.threat-callout {
  display: grid;
  grid-template-columns: 26px 22px 1fr;
  align-items: start;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--threat-color-line, rgba(239, 68, 68, 0.25));
  border-left: 3px solid var(--threat-color, #ef4444);
  border-radius: 8px;
  animation: callout-pop 0.28s ease both;
}
@keyframes callout-pop {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
.threat-callout-num {
  align-self: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--threat-color, #ef4444);
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  display: grid;
  place-items: center;
  box-shadow: 0 0 10px var(--threat-color-glow, rgba(239, 68, 68, 0.45));
}
.threat-callout-line {
  align-self: center;
  width: 22px;
  height: 1px;
  background: linear-gradient(90deg, var(--threat-color, #ef4444), transparent);
  position: relative;
}
.threat-callout-line::before {
  content: "";
  position: absolute;
  left: 0; top: -2px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--threat-color, #ef4444);
}
.threat-callout-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.threat-callout-body strong {
  font-size: 13px;
  color: var(--fg-strong);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.threat-callout-tag {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--threat-color, #ef4444);
}
.threat-callout-body p {
  margin: 2px 0 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--fg);
}

@media (prefers-reduced-motion: reduce) {
  .papp, .papp-icon, .papp-name { transition: none; }
  .threat-callout { animation: none; }
}
