/* =============================================================
   TOOLS PAGE
   A living directory of Omar's own bookmarks — structure and
   spirit borrowed from designengineer.tools (plain-text links
   grouped under category headings, no icons/descriptions), but
   styled with this site's own tokens/type scale so it reads as
   part of the same site, not a pasted-in reference.
   ============================================================= */

.tools-hero {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 160px var(--pad-x) 60px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
}

.tools-hero-text {
  min-width: 0;
}

/* Download the whole list as a Netscape bookmark file (tools/bookmarks.php,
   generated live from data/tools.json) — every browser's bookmark manager
   can import that format directly. */
.tools-download {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 11px 18px;
  border: 1px solid var(--c-f9-10);
  border-radius: 100px;
  background: var(--c-f9-10);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--c-f9f9f9);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s var(--ease-out), border-color 0.2s var(--ease-out);
}
.tools-download:hover {
  background: rgba(249, 249, 249, 0.16);
  border-color: rgba(249, 249, 249, 0.16);
}
.tools-download-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.tools-eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c-f9-60);
  margin-bottom: 20px;
}

.tools-heading {
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  max-width: 16ch;
  margin-bottom: 24px;
}

.tools-intro {
  font-size: 16px;
  line-height: 1.6;
  color: var(--c-f9-60);
  max-width: 58ch;
}

.tools-list {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--pad-x) 160px;
}

.tools-category {
  padding: 36px 0;
  border-top: 1px solid var(--c-f9-10);
}
.tools-category:first-child {
  border-top: none;
  padding-top: 0;
}

.tools-category-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 24px;
}

.tools-category-name {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--c-f9f9f9);
}

.tools-category-count {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--c-f9-10);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--c-f9-80);
}

/* One fixed 4-column grid, every column the same width, for every category
   on the page. tools_build_columns() (tools/index.php) already caps each
   category at a max of 4 columns; whatever it produces just fills left to
   right and any unused trailing column(s) on that row stay blank. No
   stretching, no per-row math — every row's columns land on the exact same
   4 grid lines as every other row. */
.tools-subgrid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
}

/* Flat categories (no named sub-groups): tools are direct grid children,
   so the browser's own auto-flow fills all 4 tracks per row before
   wrapping — row-gap is tight (each .tools-link already has its own
   vertical padding) so wrapped rows read as one continuous list, not a
   grid of widely-spaced cards. */
.tools-subgrid--flat {
  gap: 0 32px;
}

.tools-subcolumn {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

/* A group whose subcategory needs an internal 2-column split (Web,
   Components) genuinely spans 2 of the outer grid's 4 tracks, so the next
   group lands on the real next track instead of overlapping the space
   that subcategory's tools are actually using. */
.tools-subcolumn--span-2 {
  grid-column: span 2;
}

.tools-subcategory-name {
  display: flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-f9-60);
  margin-bottom: 10px;
}

.tools-links {
  display: flex;
  flex-direction: column;
}

/* Opt-in per sub-group (data/tools.json "columns": 2, e.g. Web and
   Components) when a single list is long enough to earn a second internal
   column instead of running the full column-group height as one list. A
   real grid (not CSS multi-column) so the divider lands at a precise,
   predictable 50% of this block's own width — multi-column's balancing
   algorithm doesn't guarantee that, which is what let the second column
   drift into the neighbouring track's space. grid-auto-flow: column keeps
   the same top-to-bottom-then-next-column reading order multi-column gave,
   but needs an explicit row count telling it when to wrap into column 2 —
   --tools-links-rows (set inline per list in tools/index.php, ceil(count/
   cols)) is that count. A generic guess here (e.g. a flat 20) backfired:
   with fewer real items than guessed rows, everything fit inside column
   1's own row tracks and column 2 stayed empty the whole time. */
.tools-links--cols-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-flow: column;
  grid-template-rows: repeat(var(--tools-links-rows, 1), auto);
  column-gap: 20px;
}

.tools-link {
  display: flex;
  align-items: center;
  gap: 10px;
  break-inside: avoid;
  padding: 7px 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--c-f9-60);
  text-decoration: none;
  transition: color 0.25s var(--ease-out);
}
.tools-link:hover {
  color: var(--c-f9f9f9);
}

.tools-link-body {
  display: flex;
  align-items: center;
  min-width: 0;
}

.tools-link-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Favicon, fetched at render time (DuckDuckGo's icon proxy — no per-tool
   asset to host or keep in sync as the list changes). Sized/boxed
   uniformly so a missing or oddly-shaped icon (DDG falls back to a blank
   globe) never breaks the row's alignment. */
.tools-link-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 3px;
  background: var(--c-f9-10);
  object-fit: contain;
}

/* Favicons whose artwork is transparent *and* dark vanish against
   --c-bg, so they get an opaque white plate instead of the default 10%
   chip. Which tools qualify is measured per icon and read in PHP from
   data/tools-icons.json (see tools_icon_needs_plate in tools/index.php)
   — CSS can't inspect a remote image, and the format alone doesn't
   answer it. The small inset keeps full-bleed artwork off the plate's
   rounded corners. */
.tools-link-icon--plated {
  background: var(--c-white);
  padding: 2px;
}

/* ── TAG BADGE ([NO-CODE] / [APPS] / [PAY]) ──────────────────────
   A small pill after the tool name with a shimmering border ring —
   a thin accent-colored highlight chasing around the edge — and a
   tooltip (hover on desktop, tap on mobile via js/tools-badges.js)
   explaining what the tag means. */
@property --tools-badge-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

/* Outer wrapper stays unclipped so .tools-badge-tip (a sibling, not a
   descendant of the shape) can still float above the pill. Only
   .tools-badge-shape clips, so the shimmer/beam layers stay cropped to the
   pill instead of bleeding past its edges. */
.tools-badge {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  margin-left: 7px;
  cursor: help;
}

.tools-badge-shape {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 100px;
  background: var(--c-f9-10);
  border: 0.5px solid var(--c-f9-05);
  box-shadow: inset 0 0 6px var(--c-f9-10);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--c-f9-80);
}

.tools-badge-label {
  position: relative;
  z-index: 1;
}

/* The "snake" — a short arc of the site's gradient-accent stops (coral
   → pale yellow → cyan → purple, same palette as --gradient-accent)
   chasing around the border, masked to a 1px ring via the padding +
   double-mask trick so only the edge shows, not a filled disc. */
.tools-badge-shape::before {
  content: '';
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: conic-gradient(from var(--tools-badge-angle),
    transparent 0deg,
    transparent 295deg,
    #FE8F6D 315deg,
    #F3F3A5 330deg,
    #80FFFE 345deg,
    #B78CDE 358deg,
    transparent 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: tools-badge-spin 3s linear infinite;
  pointer-events: none;
}

/* Trailing beam — a much fainter, softer copy of the same arc, blurred
   and screen-blended so it reads as a faint glow behind the snake rather
   than a second ring. Clipped to the pill by .tools-badge-shape's
   overflow:hidden above, so it can no longer bleed past the badge edges. */
.tools-badge-shape::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: conic-gradient(from var(--tools-badge-angle),
    transparent 0deg,
    transparent 300deg,
    color-mix(in srgb, #FE8F6D 30%, transparent) 320deg,
    color-mix(in srgb, #F3F3A5 30%, transparent) 335deg,
    color-mix(in srgb, #80FFFE 30%, transparent) 348deg,
    color-mix(in srgb, #B78CDE 30%, transparent) 358deg,
    transparent 360deg);
  filter: blur(3px);
  opacity: 0.55;
  mix-blend-mode: screen;
  animation: tools-badge-spin 3s linear infinite;
  pointer-events: none;
}

@keyframes tools-badge-spin {
  to { --tools-badge-angle: 360deg; }
}

@media (prefers-reduced-motion: reduce) {
  .tools-badge-shape::before,
  .tools-badge-shape::after {
    animation: none;
  }
}

.tools-badge-tip {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  width: max-content;
  max-width: 200px;
  padding: 8px 11px;
  background: var(--c-1e);
  border: 1px solid var(--c-f9-10);
  color: var(--c-f9f9f9);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;
  text-transform: none;
  letter-spacing: normal;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 0.18s var(--ease-out), transform 0.18s var(--ease-out);
  z-index: 5;
}
.tools-badge-tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--c-1e);
}
.tools-badge:hover .tools-badge-tip,
.tools-badge.is-active .tools-badge-tip {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 809px) {
  .tools-hero { padding: 120px var(--pad-x) 40px; }
  .tools-subgrid { grid-template-columns: repeat(2, 1fr); gap: 28px 24px; }
  /* grid-auto-flow: row (not the base rule's column) so a single defined
     column just stacks every item one per row — with column-flow still
     active here, exhausting the inline --tools-links-rows count would
     spawn an unwanted implicit 2nd column instead of collapsing to 1. */
  .tools-links--cols-2 { grid-template-columns: 1fr; grid-auto-flow: row; }
}

@media (max-width: 479px) {
  .tools-subgrid { grid-template-columns: 1fr; }
}
