/* ==========================================================================
   Home 04 — "Tools I Work With"
   Markup: resources/views/components/tools/*.blade.php
   Data: config/tools_section.php

   Phones: head → portrait (tighter crop, edges faded) → six accordion cards
   → callout. 768–1199: portrait, then the categories in two columns.
   1200+: three categories each side of the portrait, callout overlapping
   its faded base. Motion: the shared scroll reveal only.
   ========================================================================== */

.tl {
  --tl-pad: calc(var(--hdr-inset) + var(--hdr-pad)); /* same content edge as the header */
  position: relative;
  background: var(--warm-50);
  padding-block: clamp(32px, 3.5vw, 56px) clamp(48px, 5vw, 80px);
}

/* Section 03 ends in its own bottom padding on the same paper: pull 04 up into
   part of it so the two paddings don't stack into one big empty band. */
.svc + .tl { margin-top: calc(-1 * clamp(24px, 3.5vw, 56px)); }

.tl__wrap {
  max-width: var(--hdr-max);
  margin-inline: auto;
  padding-inline: var(--tl-pad);
}

/* ---- Head ------------------------------------------------------------------ */

.tl__head {
  max-width: 52rem;
  margin-inline: auto;
  text-align: center;
}

.tl__label {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--ink-900);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.tl__num { color: var(--color-primary); font-variant-numeric: tabular-nums; }

.tl__line {
  width: clamp(40px, 5vw, 56px);
  height: 2px;
  border-radius: 2px;
  background: var(--color-primary);
}

/* Same scale as section 03's title. */
.tl__title {
  margin: 10px 0 0;
  color: var(--ink-900);
  font-size: clamp(2.25rem, 1.3rem + 3.4vw, 4rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.tl__accent { color: var(--color-primary); }

.tl__lede {
  max-width: 52rem;
  margin: 12px auto 0;
  color: var(--slate-700);
  font-size: clamp(1.0625rem, 0.98rem + 0.3vw, 1.1875rem);
  line-height: 1.5;
  text-wrap: pretty;
}

/* ---- Filter pills (they need JS, and phones use the accordions instead) ----- */

.tl__filters {
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

@media (min-width: 768px) {
  html.js .tl__filters { display: flex; }
}

.tl__pill {
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--ink-900);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}

.tl__pill:hover { border-color: var(--slate-400); }

.tl__pill[aria-pressed="true"] {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: var(--color-on-primary);
}

/* ---- Stage: portrait + categories ----------------------------------------- */

.tl__stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "img" "seo" "ads" "automation" "dev" "design" "data" "callout";
  gap: 10px;
  margin-top: 16px;
}

.tl__figure { grid-area: img; margin: 0 0 8px; }
.tl-cat[data-cat="seo"]        { grid-area: seo; }
.tl-cat[data-cat="ads"]        { grid-area: ads; }
.tl-cat[data-cat="automation"] { grid-area: automation; }
.tl-cat[data-cat="dev"]        { grid-area: dev; }
.tl-cat[data-cat="design"]     { grid-area: design; }
.tl-cat[data-cat="data"]       { grid-area: data; }

.tl__img {
  width: 100%;
  height: auto;
  /* The cutout ends in a hard line at the knees: fade it out. */
  -webkit-mask-image: linear-gradient(to bottom, #000 80%, transparent);
  mask-image: linear-gradient(to bottom, #000 80%, transparent);
}

/* Phones: bleed to the screen edges and fade the cropped tiles at both sides. */
@media (max-width: 767.98px) {
  .tl__figure { margin-inline: calc(-1 * var(--tl-pad)); }
  .tl__img {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 9%, #000 91%, transparent), linear-gradient(to bottom, #000 80%, transparent);
    -webkit-mask-composite: source-in;
    mask-image: linear-gradient(to right, transparent, #000 9%, #000 91%, transparent), linear-gradient(to bottom, #000 80%, transparent);
    mask-composite: intersect;
  }
}

/* ---- Category: an accordion card on phones --------------------------------- */

.tl-cat {
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  background: var(--color-surface);
  transition: background-color var(--t-base) var(--ease-out), border-color var(--t-base) var(--ease-out);
}

.tl-cat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 16px;
  list-style: none;
  cursor: pointer;
}

.tl-cat__head::-webkit-details-marker { display: none; }

.tl-cat__icon { flex-shrink: 0; color: var(--color-primary); }

.tl-cat__title {
  flex: 1;
  margin: 0;
  color: var(--ink-900);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.tl-cat__chev { flex-shrink: 0; color: var(--slate-500); transition: transform var(--t-base) var(--ease-out); }
.tl-cat[open] .tl-cat__chev { transform: rotate(180deg); }

.tl-cat__list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  padding: 2px 14px 16px 16px;
  color: var(--slate-700);
  font-size: 0.875rem;
  line-height: 1.3;
}

/* One tool: its official mark on a small paper tile, then the name. */
.tl-tool {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
}

.tl-tool__mark {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid rgb(15 23 42 / 0.08);
  border-radius: 7px;
  background: var(--color-surface);
  color: var(--color-primary); /* UI icons; brand marks set their own colour */
  box-shadow: 0 1px 1px rgb(15 23 42 / 0.04), 0 4px 10px -6px rgb(15 23 42 / 0.28);
}

.tl-tool__mark svg { width: 14px; height: 14px; }

/* The Screaming Frog mark is its own square app icon: let it fill the tile. */
.tl-tool__mark--full { overflow: hidden; border: 0; }
.tl-tool__mark--full svg { width: 100%; height: 100%; }

.tl-tool__name { min-width: 0; }

@media (max-width: 359.98px) {
  .tl-cat__list { grid-template-columns: minmax(0, 1fr); }
}

/* Highlighted by a filter pill. */
.tl-cat.is-active {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}

/* ---- Callout --------------------------------------------------------------- */

.tl__callout {
  grid-area: callout;
  justify-self: center;
  width: 100%;
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 14px;
  align-items: center;
  max-width: 720px;
  margin-top: 8px;
  padding: 16px 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  background: rgb(253 253 254 / 0.88);
  box-shadow: 0 18px 40px -28px rgb(15 23 42 / 0.28);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.tl__bulb {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.tl__callout-title {
  color: var(--ink-900);
  font-size: clamp(1.0625rem, 0.95rem + 0.5vw, 1.375rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.tl__callout-title span { color: var(--color-primary); }

.tl__callout-text {
  margin-top: 4px;
  color: var(--slate-600);
  font-size: 0.875rem;
  line-height: 1.45;
}

/* ---- Tablet (768–1199): portrait on top, categories in two columns --------- */

@media (min-width: 768px) {
  .tl__stage {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "img        img"
      "seo        ads"
      "automation design"
      "dev        data"
      "callout    callout";
    gap: 28px clamp(32px, 5vw, 64px);
    margin-top: 24px;
  }

  .tl__figure { justify-self: center; width: min(100%, 720px); margin: 0 0 -8px; }

  /* A plain editorial block: blue title, list under it, hairline on the left. */
  .tl-cat {
    padding: 4px 0 4px 20px;
    border: 0;
    border-left: 1px solid var(--color-border);
    border-radius: 0 var(--r-md) var(--r-md) 0;
    background: transparent;
  }

  .tl-cat__head { min-height: 0; margin-bottom: 8px; padding: 0; cursor: default; pointer-events: none; }
  .tl-cat__chev { display: none; }
  .tl-cat__title { color: var(--color-primary); font-size: 1.125rem; }

  .tl-cat__list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    padding: 0; /* tiles line up under the category icon, names near the title text */
    font-size: 0.9375rem;
  }

  .tl-cat.is-active { border-left-color: var(--color-primary); }

  .tl__callout {
    margin-top: 4px;
    padding: 18px 28px 18px 20px;
    column-gap: 18px;
  }

  .tl__callout-text { font-size: 0.9375rem; }
}

/* ---- Desktop (1200+): categories flank the portrait ----------------------- */

@media (min-width: 1200px) {
  .tl__stage {
    grid-template-columns: minmax(224px, 0.72fr) minmax(0, 2.6fr) minmax(224px, 0.72fr);
    grid-template-areas:
      "seo        img ads"
      "automation img design"
      "dev        img data";
    --tl-gap: clamp(16px, 2vw, 32px);
    gap: 22px var(--tl-gap);
  }

  /* The cutout's edges are transparent tiles and glow, so it may bleed into the gutters. */
  .tl__figure {
    align-self: start; /* top of the portrait level with the first category */
    justify-self: center;
    width: calc(100% + 2 * var(--tl-gap));
    max-width: 940px;
    margin: 0;
  }

  .tl-cat__title { font-size: clamp(1rem, 0.6rem + 0.55vw, 1.125rem); }

  /* The callout shares the portrait's cell and starts where the portrait (3:2)
     ends, overlapping its faded base by 48px, whatever the side lists' height.
     A grid item's % margin resolves against its grid area's width. */
  .tl__callout {
    grid-area: img;
    align-self: start;
    margin-top: calc(min(100% + 2 * var(--tl-gap), 940px) * 2 / 3 - 48px);
  }
}
