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

/* Threat label that appears beneath each tagged app */
.papp-tags {
  list-style: none;
  display: none;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 0;
  padding: 0;
  width: 100%;
}
.papp.is-tagged .papp-tags {
  display: flex;
  animation: tag-pop 0.3s ease;
}
@keyframes tag-pop {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}
.papp-tag {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 7.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1.5px 4px;
  border-radius: 3px;
  background: var(--threat-color-soft, rgba(239, 68, 68, 0.15));
  color: var(--threat-color, #ef4444);
  border: 1px solid var(--threat-color-line, rgba(239, 68, 68, 0.3));
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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