@layer page {
/* ============================================================
   TOOLS INDEX
   Vibrant card grid. Each card scopes its own --accent via a
   modifier class; the card, its glow, and its CTA all read
   from that single variable. Per-tool visuals live in
   `.tool-visual--*` blocks below.
   ============================================================ */

/* Tools hero: stacked two-line title with smaller lede.
   .tools-hero-lede is the small first line, em is the bigger
   second line. */
.tools-hero-title {
  line-height: 1;
  letter-spacing: -0.03em;

  .tools-hero-lede {
    display: block;
    font-size: 0.45em;
    font-weight: 200;
    color: var(--text-2);
    letter-spacing: -0.01em;
    margin-bottom: var(--space-4);
  }
  em {
    display: inline-block;
    font-style: normal;
    font-weight: 200;
    color: var(--text-0);
  }
}

.sec-tools-index {
  padding: var(--space-12) var(--gutter) var(--space-24);
  max-width: 80rem;
  margin-inline: auto;
}

/* Thin spectrum bar sitting under the hero. Purely decorative. */
.tools-spectrum {
  display: flex;
  gap: 2px;
  margin: var(--space-12) auto 0;
  width: min(320px, 60%);
  height: 3px;
  opacity: 0.9;

  > span {
    flex: 1;
    border-radius: 2px;
    background: oklch(0.72 0.22 var(--h));
    box-shadow: 0 0 12px oklch(0.72 0.22 var(--h) / 0.6);
  }
}

/* `.tools-grid` is composed with `.grid-auto` in the template;
   the knobs below override the primitive's defaults to preserve
   the original min-width and clamp-based gap. */
.tools-grid {
  --grid-min: 280px;
  --grid-gap: clamp(1.75rem, 2.5vw, 2.75rem);
}

/* ── Card media ────────────────────────────────────────── */

.tool-content-card {
  border: 0.5px solid color-mix(in oklch, var(--accent) 5%, transparent);
  transition: border-color var(--duration-fast) var(--ease-out-expo);

  &:is(:hover, :focus-within) {
    border-color: color-mix(in oklch, var(--accent) 20%, transparent);
  }

  > .media { padding: var(--space-5) var(--space-5) 0; }
  > .content { padding-block-start: var(--space-3); }
}

.tool-card-visual {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  background: radial-gradient(
    ellipse 80% 70% at 50% 100%,
    oklch(from var(--accent) l c h / 0.10) 0%,
    transparent 70%);
  position: relative;
  overflow: hidden;
}


/* ============================================================
   PER-TOOL VISUAL MODIFIERS
   Each sits inside .tool-card-visual and uses CSS primitives
   only. Everything scales to the card size. The .tv-* internals
   live in their per-tool files alongside the rest of the tool.
   ============================================================ */

.tool-visual {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Shared motion. Every visual answers the card hover with one bold
   move, never a pile of small ones. */
.tool-visual :where(span, div, b, i) {
  transition:
    transform var(--duration-normal) var(--ease-out-expo),
    opacity var(--duration-normal) var(--ease-out-expo),
    background var(--duration-normal) var(--ease-out-expo);
}

@media (prefers-reduced-motion: reduce) {
  .tool-visual :where(span, div, b, i) { transition: none; }
}

/* ── Palette: five hue bars, staggered lift ── */
.tool-visual--palette {
  padding: var(--space-4);
  gap: var(--space-2);

  > span {
    flex: 1;
    align-self: stretch;
    background: var(--c);
    border-radius: var(--radius-sm);
  }
}
.tool-content-card:hover .tool-visual--palette > span:nth-child(1) { transform: translateY(-10px); }
.tool-content-card:hover .tool-visual--palette > span:nth-child(2) { transform: translateY(-3px); }
.tool-content-card:hover .tool-visual--palette > span:nth-child(3) { transform: translateY(-14px); }
.tool-content-card:hover .tool-visual--palette > span:nth-child(4) { transform: translateY(-5px); }
.tool-content-card:hover .tool-visual--palette > span:nth-child(5) { transform: translateY(-9px); }

/* ── Wheel: a large hue ring that turns ── */
.tool-visual--wheel { padding: var(--space-2); }

.tv-ring {
  aspect-ratio: 1;
  block-size: 78%;
  border-radius: var(--radius-full);
  background: conic-gradient(
    oklch(0.70 0.22 0), oklch(0.72 0.22 60), oklch(0.74 0.22 120),
    oklch(0.72 0.22 180), oklch(0.70 0.22 240), oklch(0.68 0.24 300),
    oklch(0.70 0.22 360));
  mask: radial-gradient(circle, transparent 46%, black 47%);
}
.tool-content-card:hover .tv-ring { transform: rotate(120deg); }

/* ── Gradient: one full-bleed band that slides ── */
.tool-visual--gradient { padding: var(--space-5); }

.tv-band {
  inline-size: 100%;
  block-size: 62%;
  border-radius: var(--radius-lg);
  background: linear-gradient(
    100deg,
    oklch(0.70 0.22 260), oklch(0.80 0.22 175),
    oklch(0.78 0.20 25), oklch(0.70 0.22 260));
  background-size: 220% 100%;
  background-position: 0% 0;
}
.tool-content-card:hover .tv-band { background-position: 100% 0; }

/* ── Contrast: two big blocks, one legible one not ── */
.tool-visual--contrast {
  padding: var(--space-5);
  gap: var(--space-3);
}

.tv-pair {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  block-size: 62%;
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: var(--text-3xl);
  font-weight: 300;
  background: var(--bg);
  color: var(--fg);
}
.tool-content-card:hover .tv-pair:first-child { transform: translateY(-8px) scale(1.04); }
.tool-content-card:hover .tv-pair:last-child  { transform: translateY(8px) scale(0.96); opacity: 0.55; }

/* ── Relative: a source block and the colours derived from it ── */
.tool-visual--relative {
  padding: var(--space-5);
  gap: var(--space-3);
}

.tv-source {
  inline-size: 38%;
  block-size: 62%;
  border-radius: var(--radius-lg);
  background: var(--c);
}
.tv-derived {
  display: grid;
  flex: 1;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  block-size: 62%;

  > span {
    border-radius: var(--radius-md);
    background: var(--c);
  }
}
.tool-content-card:hover .tv-source { transform: scale(0.88); }
.tool-content-card:hover .tv-derived > span:nth-child(1) { transform: translate(-4px, -4px); }
.tool-content-card:hover .tv-derived > span:nth-child(2) { transform: translate(4px, -4px); }
.tool-content-card:hover .tv-derived > span:nth-child(3) { transform: translate(-4px, 4px); }
.tool-content-card:hover .tv-derived > span:nth-child(4) { transform: translate(4px, 4px); }

/* ── Blindness: three wide bands, the lower two shifting on hover ── */
.tool-visual--blindness {
  flex-direction: column;
  padding: var(--space-5);
  gap: var(--space-2);

  > span {
    inline-size: 100%;
    flex: 1;
    border-radius: var(--radius-md);
    background: var(--g);
  }
}
.tool-content-card:hover .tool-visual--blindness > span:nth-child(2) { transform: translateX(-6px); }
.tool-content-card:hover .tool-visual--blindness > span:nth-child(3) { transform: translateX(6px); }

/* ── Converter: one colour, three notations stacked and cycling ── */
.tool-visual--converter {
  padding: var(--space-5);
  gap: var(--space-4);
}

.tv-source-block {
  inline-size: 34%;
  block-size: 64%;
  border-radius: var(--radius-lg);
  background: var(--c);
}
.tv-notations {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-2);
  block-size: 64%;
  overflow: hidden;

  > b {
    display: flex;
    flex: 1;
    align-items: center;
    padding-inline: var(--space-3);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--text-2);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 400;
  }
}
.tool-content-card:hover .tv-source-block { transform: scale(1.06); }
.tool-content-card:hover .tv-notations > b:nth-child(1) { background: var(--accent-soft); color: var(--accent-text); }
.tool-content-card:hover .tv-notations > b:nth-child(2) { transform: translateX(6px); }
.tool-content-card:hover .tv-notations > b:nth-child(3) { transform: translateX(12px); }

/* ── Names: one large swatch, its nearest name spelled out ── */
.tool-visual--names { padding: var(--space-5); }

.tv-namer {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  inline-size: 100%;
  block-size: 64%;

  .swatch {
    aspect-ratio: 1;
    block-size: 100%;
    border-radius: var(--radius-lg);
    background: var(--c);
  }

  .label {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    font-family: var(--font-body);
    font-size: var(--text-2xl);
    font-weight: 300;
    color: var(--text-0);
    line-height: 1.1;

    i {
      font-family: var(--font-mono);
      font-size: var(--text-xs);
      font-style: normal;
      color: var(--text-3);
    }
  }
}
.tool-content-card:hover .tv-namer .swatch { transform: scale(1.1) rotate(-4deg); }
}
@layer page {
/* ============================================================
   PLAYGROUND INDEX VISUALS

   Each example card shows the snippet it runs and the value that
   snippet produces. Every colour below is a real output of the
   library, not a decorative approximation.

   Composed ON .tool-visual (tools/index.css), which supplies
   position: absolute, inset: 0 and the flex context. Applying a
   modifier to a child instead breaks that inheritance, which is
   what left the previous visuals with no dimensions at all.
   ============================================================ */

.pg-thumb {
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: var(--space-4);
  padding-inline: var(--space-6);
}

/* The snippet. Syntax colours reuse the .t-* classes already
   defined in components/code-block.css, so hand-written samples
   match the highlighter's output. */
.pg-thumb-code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.6;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The value it produces. Sized to carry the card, not to hide in
   a corner: the row is a third of the 16/9 visual area. */
.pg-thumb-out {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  block-size: 3rem;
}

/* ── Result primitives ── */

/* One resolved colour. Knob: --c */
.pg-chip {
  inline-size: 3rem;
  block-size: 3rem;
  flex: none;
  border-radius: var(--radius-md);
  background: var(--c);
}

/* A set of colours sharing the row evenly. Knob: --c per span */
.pg-ramp {
  display: flex;
  flex: 1;
  gap: var(--space-1);
  block-size: 3rem;

  > span {
    flex: 1;
    border-radius: var(--radius-sm);
    background: var(--c);
  }
}

/* A continuous band. Knob: --g */
.pg-band {
  flex: 1;
  block-size: 3rem;
  border-radius: var(--radius-md);
  background: var(--g);
}

/* Separator between an input and its result. */
.pg-arrow {
  flex: none;
  color: var(--text-3);
  font-size: var(--text-sm);
}

/* A measured value with its verdict. */
.pg-verdict {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-1);

  > .pass {
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: var(--text-xs);
  }
}

/* Emitted custom properties, one row per token. */
.pg-tokens {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-2);

  > span {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  .swatch {
    inline-size: 1rem;
    block-size: 1rem;
    flex: none;
    border-radius: var(--radius-sm);
    background: var(--c);
  }
}

@media (width <= 480px) {
  .pg-thumb {
    padding-inline: var(--space-4);
    gap: var(--space-3);
  }
  .pg-thumb-out,
  .pg-chip,
  .pg-ramp,
  .pg-band { block-size: 2.25rem; }
  .pg-chip { inline-size: 2.25rem; }
}
}
