/* Threat Intel page. Colours come from Chirpy's own CSS variables,
   so the page follows the site's Light / Dark / System setting. */

.ti {
  --ti-accent: var(--link-color, #0056b2);
  --ti-ransom: #d93f53;
  --ti-line: var(--main-border-color, rgba(128, 128, 128, 0.25));
  --ti-muted: var(--text-muted-color, #757575);
  font-variant-numeric: tabular-nums;
}

.ti-lede {
  font-size: 1.3rem;
  line-height: 1.5;
  color: var(--heading-color, inherit);
  max-width: 40em;
  margin: 0.5rem 0 0.5rem;
}

.ti-lede strong {
  font-weight: 700;
  color: var(--heading-color, inherit);
  border-bottom: 3px solid var(--ti-accent);
}

.ti-lede strong.is-ransom {
  border-bottom-color: var(--ti-ransom);
}

.ti-meta,
.ti-note,
.ti-count,
.ti-source {
  color: var(--ti-muted);
  font-size: 0.9rem;
}

.ti-meta { margin-bottom: 1.5rem; }
.ti-note { max-width: 42em; }
.ti-source { margin-top: 2rem; }

.ti-error {
  border-left: 4px solid var(--ti-ransom);
  padding: 0.75rem 1rem;
}

/* Section headings with the range toggle beside the first one */
.ti-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.ti-head h2 { margin-bottom: 0.25rem; }

.ti-toggle {
  display: inline-flex;
  border: 1px solid var(--ti-line);
  border-radius: 999px;
  padding: 2px;
}

.ti-toggle button {
  border: 0;
  background: transparent;
  color: var(--ti-muted);
  font-size: 0.85rem;
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
}

.ti-toggle button[aria-pressed="true"] {
  background: var(--ti-accent);
  color: var(--main-bg, #fff);
}

.ti-toggle button:focus-visible,
.ti-filters input:focus-visible,
.ti-filters select:focus-visible,
.ti-table summary:focus-visible {
  outline: 2px solid var(--ti-accent);
  outline-offset: 2px;
}

/* Charts: the wrapper sets the height, Chart.js fills it */
.ti-chart {
  position: relative;
  width: 100%;
  height: 340px;
  margin: 0.75rem 0 2rem;
}

.ti-chart--wide { height: 280px; }

/* Table filters */
.ti-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1.25rem;
  margin: 0.75rem 0 0.5rem;
}

.ti-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.85rem;
  color: var(--ti-muted);
  margin: 0;
}

.ti-field input,
.ti-field select {
  min-width: 13rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.95rem;
  color: var(--text-color, inherit);
  background: var(--card-bg, transparent);
  border: 1px solid var(--ti-line);
  border-radius: 6px;
}

.ti-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
  margin: 0 0 0.4rem;
}

.ti-check input { accent-color: var(--ti-ransom); }

/* Table */
.ti-more {
  display: block;
  margin: 0.75rem auto 0;
  padding: 0.4rem 1.2rem;
  font-size: 0.9rem;
  color: var(--ti-accent);
  background: transparent;
  border: 1px solid var(--ti-line);
  border-radius: 999px;
  cursor: pointer;
}

.ti-more:hover { border-color: var(--ti-accent); }
.ti-more:focus-visible { outline: 2px solid var(--ti-accent); outline-offset: 2px; }

.ti-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--ti-line);
  border-radius: 8px;
}

.ti-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  margin: 0 !important; /* Chirpy adds margins to content tables */
  font-size: 0.9rem;
}

.ti-table th,
.ti-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--ti-line);
  text-align: left;
  vertical-align: top;
}

.ti-table thead th {
  position: sticky;
  top: 0;
  background: var(--card-header-bg, var(--card-bg, inherit));
  font-weight: 600;
  white-space: nowrap;
}

.ti-table tbody tr:last-child td { border-bottom: 0; }

.ti-table td:first-child,
.ti-table td:nth-child(2) { white-space: nowrap; }

.ti-table summary {
  cursor: pointer;
  color: var(--text-color, inherit);
}

.ti-table details p {
  margin: 0.4rem 0 0;
  color: var(--ti-muted);
  max-width: 48em;
}

.ti-sub {
  display: block;
  color: var(--ti-muted);
  font-size: 0.85rem;
}

.ti-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.45rem;
  font-size: 0.75rem;
  line-height: 1.5;
  color: #fff;
  background: var(--ti-ransom);
  border-radius: 4px;
  vertical-align: 1px;
}

.ti-empty td {
  text-align: center;
  color: var(--ti-muted);
  padding: 1.5rem;
}

/* Small screens: each table row becomes a stacked card */
@media (max-width: 640px) {
  .ti-table-wrap { border: 0; border-radius: 0; overflow: visible; }
  .ti-table { min-width: 0; }
  .ti-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .ti-table,
  .ti-table tbody,
  .ti-table tr,
  .ti-table td { display: block; width: 100%; box-sizing: border-box; }
  .ti-table tr {
    border: 1px solid var(--ti-line);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.75rem;
  }
  .ti-table td,
  .ti-table tbody tr:last-child td { border: 0; padding: 0.2rem 0; white-space: normal; }
  .ti-table td:first-child,
  .ti-table td:nth-child(2) { display: inline-block; width: auto; margin-right: 1.25rem; white-space: nowrap; }
  .ti-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.75rem;
    color: var(--ti-muted);
  }
  .ti-empty td { padding: 1rem 0; }
}

@media (max-width: 576px) {
  .ti-lede { font-size: 1.1rem; }
  .ti-chart { height: 380px; }
  .ti-chart--wide { height: 240px; }
  .ti-field input,
  .ti-field select { min-width: 0; width: 100%; }
  .ti-field { flex: 1 1 100%; }
}

/* IOC lookup */
.ti-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.ti-ioc {
  border: 1px solid var(--ti-line);
  border-radius: 8px;
  padding: 1rem 1.25rem 0.5rem;
  margin: 0 0 2rem;
}

.ti-ioc h2 { margin-top: 0; }

.ti-ioc-form {
  display: flex;
  gap: 0.5rem;
  margin: 0.75rem 0 0.5rem;
}

.ti-ioc-form input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  font-family: var(--bs-font-monospace, monospace);
  color: var(--text-color, inherit);
  background: var(--card-bg, transparent);
  border: 1px solid var(--ti-line);
  border-radius: 6px;
}

.ti-ioc-form button {
  flex: 0 0 auto;
  padding: 0.5rem 1.2rem;
  font-size: 0.95rem;
  color: var(--main-bg, #fff);
  background: var(--ti-accent);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.ti-ioc-form input:focus-visible,
.ti-ioc-form button:focus-visible {
  outline: 2px solid var(--ti-accent);
  outline-offset: 2px;
}

.ti-ioc-card {
  border-top: 1px solid var(--ti-line);
  padding: 0.85rem 0;
}

.ti-ioc-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
}

.ti-ioc-value {
  font-size: 0.9rem;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.ti-ioc-type { color: var(--ti-muted); font-size: 0.85rem; }

.ti-ioc-verdict {
  margin: 0.4rem 0;
  color: var(--ti-muted);
  font-size: 0.9rem;
}

.ti-ioc-verdict.is-hit {
  color: var(--heading-color, inherit);
  font-weight: 600;
  border-left: 3px solid var(--ti-ransom);
  padding-left: 0.6rem;
}

.ti-ioc-context {
  background: var(--card-header-bg, rgba(128, 128, 128, 0.08));
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  margin: 0.5rem 0 0.75rem;
  font-size: 0.9rem;
}

.ti-ioc-verdict.is-warn {
  color: var(--heading-color, inherit);
  font-weight: 600;
  border-left: 3px solid #d18b00;
  padding-left: 0.6rem;
}

.ti-ioc-context h3,
.ti-ioc-lists h3 { font-size: 0.95rem; margin: 0 0 0.35rem; }
.ti-ioc-context ul,
.ti-ioc-lists ul { margin: 0; padding-left: 1.1rem; }
.ti-ioc-context li + li,
.ti-ioc-lists li + li { margin-top: 0.25rem; }

.ti-ioc-lists {
  border: 1px solid var(--ti-line);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  margin: 0.5rem 0 0.75rem;
  font-size: 0.9rem;
}

.ti-ioc-matches {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ti-ioc-match {
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--ti-line);
}

.ti-ioc-match:last-child { border-bottom: 0; }

.ti-ioc-facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.9rem;
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: var(--ti-muted);
}

.ti-ioc-facts .ti-badge { margin-left: 0; }
.ti-ioc-rel { color: var(--text-color, inherit); }

.ti-ioc-tags {
  font-size: 0.8rem;
  color: var(--ti-muted);
  margin-top: 0.15rem;
  overflow-wrap: anywhere;
}

.ti-ioc-pivots {
  font-size: 0.85rem;
  color: var(--ti-muted);
  margin: 0.6rem 0 0;
}

@media (max-width: 576px) {
  .ti-ioc { padding: 0.85rem 0.9rem 0.25rem; }
  .ti-ioc-form button { padding: 0.5rem 0.9rem; }
}
