/* ==========================================================================
   d4 tools - shared styles for the network tools section.
   Loaded after system.css; uses its design tokens throughout.
   ========================================================================== */

/* Forms */
.tl-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-top: 1.2rem; }
.tl-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }
.tl-field.grow { flex: 1 1 260px; }
.tl-input {
  font: 16px/1.4 var(--font); color: var(--ink); background: var(--bg);
  border: 1px solid var(--hairline); border-radius: 12px; padding: 10px 12px; width: 100%;
}
.tl-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.tl-input.mono { font-family: var(--font-mono); font-size: 15px; }
textarea.tl-input { min-height: 130px; resize: vertical; }
select.tl-input { width: auto; padding-right: 30px; }

/* Output panels */
.tl-panel {
  background: var(--card); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 20px 22px; margin-top: 16px;
}
.tl-panel h3 { margin: 0 0 10px; font-size: 19px; }
.tl-h { font-size: 23px; margin: 2.4em 0 0.4em; }
.tl-sub { color: var(--ink-2); font-size: 15px; margin: 0 0 0.4em; }

/* Key/value listing */
.tl-kv { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 7px 18px; margin: 0; font-size: 15px; }
.tl-kv dt { color: var(--ink-2); }
.tl-kv dd { margin: 0; min-width: 0; }
@media (max-width: 540px) { .tl-kv { grid-template-columns: 1fr; gap: 2px; } .tl-kv dt { margin-top: 8px; } }

/* Tables */
.tl-scroll { overflow-x: auto; }
.tl-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tl-table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-3); font-weight: 600; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--hairline);
}
.tl-table td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--hairline); vertical-align: top; }
.tl-table tr:last-child td { border-bottom: none; }

.tl-mono { font-family: var(--font-mono); font-size: 13.5px; word-break: break-all; }

/* Status badges */
.tl-badge {
  display: inline-block; padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.tl-good { background: rgba(52, 199, 89, 0.14); color: #1e8e3e; }
.tl-warn { background: rgba(255, 159, 10, 0.16); color: #b06000; }
.tl-bad  { background: rgba(255, 59, 48, 0.13); color: #c02b21; }
.tl-info { background: var(--bg-sunken); color: var(--ink-2); }
@media (prefers-color-scheme: dark) {
  .tl-good { color: #30d158; }
  .tl-warn { color: #ffd60a; }
  .tl-bad  { color: #ff6961; }
}

/* Grade disc for the headers tool */
.tl-grade {
  width: 84px; height: 84px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 34px; font-weight: 700; color: #fff; flex: 0 0 auto;
}
.tl-grade-a { background: #34c759; } .tl-grade-b { background: #a2c465; }
.tl-grade-c { background: #ff9f0a; } .tl-grade-d { background: #ff7043; }
.tl-grade-f { background: #ff3b30; }
.tl-gradewrap { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }

/* Messages */
.tl-err { font-size: 14.5px; padding: 10px 14px; border-radius: 10px; background: rgba(255, 59, 48, 0.1); color: #c02b21; margin-top: 14px; }
@media (prefers-color-scheme: dark) { .tl-err { color: #ff6961; } }
.tl-muted { color: var(--ink-3); font-size: 13.5px; }
.tl-footnote { color: var(--ink-3); font-size: 13.5px; margin-top: 2.2rem; line-height: 1.5; }

/* Latency bars for the DNS tool */
.tl-lat { display: flex; align-items: center; gap: 10px; }
.tl-lat .bar { height: 8px; border-radius: 4px; background: var(--accent); min-width: 3px; }
.tl-lat .ms { font-family: var(--font-mono); font-size: 13px; color: var(--ink-2); white-space: nowrap; }

/* Tool landing cards */
.tl-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; margin-top: 2.2rem; }
a.tl-card {
  display: block; background: var(--card); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 22px; color: var(--ink); text-decoration: none;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
a.tl-card:hover { transform: translateY(-4px); box-shadow: var(--card-shadow); text-decoration: none; }
a.tl-card .ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; margin-bottom: 16px; line-height: 1;
  border-radius: 13px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 11%, transparent);
  transition: background 0.15s var(--ease);
}
a.tl-card:hover .ico { background: color-mix(in srgb, var(--accent) 16%, transparent); }
a.tl-card .ico svg { width: 25px; height: 25px; display: block; }
a.tl-card h3 { margin: 0 0 6px; font-size: 20px; }
a.tl-card p { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.45; }
a.tl-card .where { display: inline-block; margin-top: 12px; font-size: 12px; color: var(--ink-3); }

/* Tools rail: the section's wayfinding spine. One fixed order, every page,
   current tool highlighted. Scrolls sideways on narrow screens. */
.tl-rail {
  position: sticky; top: var(--nav-h); z-index: 90;
  border-bottom: 1px solid color-mix(in srgb, var(--hairline) 60%, transparent);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .tl-rail {
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    backdrop-filter: saturate(180%) blur(22px);
  }
}
.tl-rail-inner {
  max-width: 760px; margin: 0 auto; padding: 10px 22px;
  display: flex; gap: 8px; align-items: center;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  /* The rail now carries every tool, so fade the right edge to signal that it
     scrolls to more beyond the fold. */
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
}
.tl-rail-inner::-webkit-scrollbar { display: none; }
.tl-rail-inner a {
  flex: 0 0 auto; padding: 5px 12px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 500; color: var(--ink-2); text-decoration: none;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.tl-rail-inner a:hover { color: var(--ink); background: var(--bg-sunken); text-decoration: none; }
.tl-rail-inner a.active { background: var(--accent); color: var(--on-accent); }
.tl-rail-inner a.tl-rail-home {
  font-weight: 600; color: var(--ink);
  padding-left: 0; padding-right: 12px; border-right: 1px solid var(--hairline);
  border-radius: 0;
}
.tl-rail-inner a.tl-rail-home:hover { background: none; color: var(--accent); }
.tl-rail-inner a.tl-rail-home.active { background: none; color: var(--accent); }

/* ==========================================================================
   ATT&CK (/tools/attack/ and the ATT&CK panel on CVE detail pages).
   ========================================================================== */

/* Kill-chain rail: all tactics in matrix order, affected ones lit. */
.atk-rail {
  display: flex; gap: 6px; margin-top: 4px; padding-bottom: 8px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
}
.atk-rail::-webkit-scrollbar { display: none; }
.atk-pill {
  flex: 0 0 auto; padding: 4px 11px; border-radius: var(--radius-pill);
  font-size: 12.5px; font-weight: 500; color: var(--ink-3);
  border: 1px solid var(--hairline); text-decoration: none; white-space: nowrap;
}
.atk-pill.atk-lit { background: var(--accent); border-color: transparent; color: var(--on-accent); font-weight: 600; }
a.atk-pill.atk-lit:hover { text-decoration: none; opacity: 0.88; }

/* Technique cards */
.atk-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-top: 14px; }
.atk-card { background: var(--bg); border: 1px solid var(--hairline); border-radius: 12px; padding: 16px 18px; min-width: 0; }
.atk-card h4 { margin: 0 0 8px; font-size: 15.5px; line-height: 1.35; }
.atk-card h4 .tl-mono { color: var(--accent); font-size: 13px; word-break: normal; }
.atk-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 9px; }
.atk-tag {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-3); border: 1px solid var(--hairline); border-radius: var(--radius-pill); padding: 2px 8px;
}
.atk-sum { margin: 0; font-size: 13.5px; color: var(--ink-2); line-height: 1.5; }
.atk-via { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); }
.atk-why { margin: 9px 0 0; font-size: 13px; color: var(--ink-2); border-left: 2px solid var(--accent); padding-left: 10px; line-height: 1.5; }
.atk-card .tl-muted { margin: 8px 0 0; }
.atk-card .atk-links { margin: 10px 0 0; font-size: 13px; }

/* The matrix: one column per tactic, horizontal scroll with snap on wide
   screens, stacked <details> accordions on small ones. */
.atk-matrix {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(170px, 1fr);
  gap: 10px; margin-top: 1.6rem; padding-bottom: 16px;
  overflow-x: auto; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.atk-col { scroll-snap-align: start; min-width: 0; }
.atk-col summary { list-style: none; cursor: pointer; }
.atk-col summary::-webkit-details-marker { display: none; }
.atk-colhead {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  font-size: 13px; font-weight: 600; padding: 8px 10px; border-radius: 10px;
  background: var(--bg-sunken); color: var(--ink);
}
.atk-colhead .n { color: var(--ink-3); font-weight: 500; font-size: 12px; }
.atk-cell {
  display: block; margin-top: 6px; padding: 7px 9px;
  border: 1px solid var(--hairline); border-radius: 9px;
  font-size: 12.5px; line-height: 1.35; color: var(--ink-2); text-decoration: none;
}
.atk-cell .tl-mono { display: block; font-size: 11px; color: var(--ink-3); word-break: normal; }
.atk-cell:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--ink); text-decoration: none; }
.atk-cell.hit { border-color: transparent; background: var(--accent); color: var(--on-accent); font-weight: 500; }
.atk-cell.hit .tl-mono { color: var(--on-accent); opacity: 0.8; }
.atk-matrix.hl .atk-cell:not(.hit) { opacity: 0.45; }
.atk-matrix.hl .atk-cell:not(.hit):hover { opacity: 1; }
.atk-matrix.hl .atk-col.lit .atk-colhead {
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent);
}
/* Wide screens: columns are always open and the summaries are inert. */
@media (min-width: 541px) {
  .atk-col summary { pointer-events: none; }
}
@media (max-width: 540px) {
  .atk-matrix { display: block; overflow: visible; }
  .atk-col { margin-top: 8px; }
  .atk-colhead::after { content: "+"; color: var(--ink-3); font-weight: 400; }
  .atk-col[open] .atk-colhead::after { content: "\2212"; }
}

/* Client-side technique filter (revealed by attack.js). */
.atk-filterrow { margin-top: 1.4rem; }

/* In-page jump links (used on the multi-section CIDR page). */
.tl-jump { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 1.4rem; }
.tl-jump a {
  padding: 4px 12px; border: 1px solid var(--hairline); border-radius: var(--radius-pill);
  font-size: 13px; color: var(--ink-2); text-decoration: none;
}
.tl-jump a:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); text-decoration: none; }
