/* Tool cards and category pages: the coloured tool cards (.tile), group headings (.tool-group), the category hero
   (.cat-hero) and the group filter pills (.filter-pill). Loaded by the category pages, /calculators, the home page and
   the PDF tool pages. Uses the site tokens from assets/style.css. Each group has one of six colour tones
   (ToolGroups.Tone: the group's place in its category). Icons are white on the tone; every tone keeps at least 3:1. */

/* ---------- colour tones ---------- */
/* --tone-a / --tone-b: the icon tile gradient (white icon: >= 3.2:1 at the light end); --tone-soft: light tint for bands. */
.tone-1 { --tone: #e8522d; --tone-a: #f0643c; --tone-b: #d9481f; --tone-soft: #fff1ec; }  /* coral: organize, borrowing... */
.tone-2 { --tone: #12925a; --tone-a: #1aa260; --tone-b: #0e8a52; --tone-soft: #e8f7ef; }  /* green: optimize, home... */
.tone-3 { --tone: #2b7de9; --tone-a: #3b8cf2; --tone-b: #1d6ad8; --tone-soft: #ebf3ff; }  /* azure: convert to PDF... */
.tone-4 { --tone: #0d8a86; --tone-a: #0f9c96; --tone-b: #0b7f7b; --tone-soft: #e6f6f5; }  /* teal: convert from PDF... */
.tone-5 { --tone: #7c3aed; --tone-a: #9b6bfa; --tone-b: #7c3aed; --tone-soft: #f2edff; }  /* violet: edit... */
.tone-6 { --tone: #1d43c8; --tone-a: #3550d6; --tone-b: #0b2a8f; --tone-soft: #ebf0ff; }  /* brand navy: security... */

/* ---------- category hero ---------- */
.cat-hero {
  position: relative; isolation: isolate; text-align: center;
  padding: 30px 0 34px; border-bottom: 1px solid var(--border);
  background:
    radial-gradient(38% 70% at 8% 18%, rgba(240, 100, 60, .09), transparent 70%),
    radial-gradient(34% 70% at 94% 12%, rgba(124, 58, 237, .09), transparent 70%),
    radial-gradient(60% 90% at 50% 0%, var(--accent-soft), transparent 75%),
    var(--bg);
}
/* faint dot grid that fades out towards the bottom */
.cat-hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: radial-gradient(rgba(29, 67, 200, .13) 1px, transparent 1.3px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(180deg, #000, transparent 85%); mask-image: linear-gradient(180deg, #000, transparent 85%);
}
.cat-hero .breadcrumbs { margin-bottom: 18px; }
.cat-hero-chip {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 0 16px; padding: 6px 14px 6px 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .05); font-size: .8438rem; font-weight: 600; color: var(--text-2);
}
.cat-hero-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: #f5a524; box-shadow: 0 0 0 3px rgba(245, 165, 36, .22); }
.cat-hero h1 { max-width: 19ch; margin: 0 auto 14px; font-size: clamp(2.125rem, 1.1rem + 3.6vw, 3.625rem); }
.cat-hero .lead { max-width: 58ch; margin: 0 auto; font-size: clamp(1.0625rem, 1rem + .3vw, 1.1875rem); color: var(--text-2); }
.cat-hero .tool-search { margin: 24px auto 0; text-align: left; }

/* ---------- filter pills ---------- */
.filter-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 920px; margin: 22px auto 0; }
.filter-pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text);
  font: inherit; font-size: .9375rem; font-weight: 600; line-height: 1.2; cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .05); transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.filter-pill .dot { width: 10px; height: 10px; flex: none; border-radius: 3px; background: linear-gradient(140deg, var(--tone-a), var(--tone-b)); }
.filter-pill:hover { border-color: color-mix(in srgb, var(--tone, var(--accent)) 45%, var(--border)); background: var(--tone-soft, var(--accent-soft)); }
.filter-pill:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 999px; }
.filter-pill[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: 0 8px 18px -8px rgba(11, 42, 143, .7); }
.filter-pill[aria-pressed="true"] .dot { box-shadow: 0 0 0 2px #fff; }

/* ---------- groups ---------- */
.tool-groups { display: grid; gap: 44px; margin: 36px 0 8px; }
.tool-group { min-width: 0; scroll-margin-top: 90px; }
.group-head {
  display: flex; align-items: center; gap: 4px 16px;
  margin: 0 0 18px; padding: 14px 18px 14px 14px; border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--tone) 18%, var(--border));
  background: linear-gradient(100deg, var(--tone-soft) 0%, color-mix(in srgb, var(--tone-soft) 45%, var(--surface)) 50%, var(--surface) 100%);
}
.group-icon {
  flex: none; width: 50px; height: 50px; display: grid; place-items: center; border-radius: 15px;
  background: linear-gradient(140deg, var(--tone-a), var(--tone-b));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 10px 20px -10px var(--tone-b);
}
.group-icon svg { width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.group-text { flex: 1 1 auto; min-width: 0; }
.group-count, .group-link { flex: none; }
.tool-group .group-title { margin: 0; font-family: var(--font); font-size: clamp(1.25rem, 1.1rem + .55vw, 1.5rem); font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; color: var(--text); }
.group-desc { margin: 3px 0 0; font-size: .9375rem; line-height: 1.45; color: var(--text-2); }
.group-count {
  padding: 5px 12px; border-radius: 999px; white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--tone) 24%, var(--border)); background: var(--surface);
  font-size: .8125rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums;
}
.group-link { white-space: nowrap; font-size: .9375rem; font-weight: 600; text-decoration: none; }
.group-link:hover { text-decoration: underline; }
@media (max-width: 559.98px) {
  .tool-groups { gap: 34px; margin-top: 26px; }
  .group-head { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 8px 12px; padding: 12px 14px 12px 12px; border-radius: 16px; }
  .group-icon { width: 44px; height: 44px; border-radius: 13px; }
  .group-icon svg { width: 23px; height: 23px; }
  .group-count, .group-link { grid-column: 2; justify-self: start; }
  .group-count { padding: 3px 10px; font-size: .75rem; }
  .group-desc { font-size: .875rem; }
}

/* ---------- tool cards ---------- */
.tile-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); }
.tile-grid > li { display: flex; min-width: 0; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; width: 100%; min-width: 0;
  padding: 18px 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04); color: var(--text); text-decoration: none;
  transition: transform .2s cubic-bezier(.2, .7, .2, 1), box-shadow .2s, border-color .2s;
}
/* coloured top edge, shown on hover and focus */
.tile::before {
  content: ""; position: absolute; left: 14px; right: 14px; top: -1px; height: 3px; border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, var(--tone-a), var(--tone-b)); opacity: 0; transition: opacity .2s;
}
.tile:hover, .tile:focus-visible {
  color: var(--text); transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--tone) 40%, var(--border));
  box-shadow: 0 20px 34px -18px color-mix(in srgb, var(--tone-b) 60%, transparent), 0 2px 6px rgba(15, 23, 42, .06);
}
.tile:hover::before, .tile:focus-visible::before { opacity: 1; }
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 16px; }
.tile-icon {
  width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 8px; border-radius: 13px;
  background: linear-gradient(140deg, var(--tone-a), var(--tone-b));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 8px 16px -8px var(--tone-b);
  transition: transform .2s cubic-bezier(.2, .7, .2, 1);
}
.tile:hover .tile-icon, .tile:focus-visible .tile-icon { transform: scale(1.07) rotate(-4deg); }
.tile-icon svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tile h3 { margin: 0; font-family: var(--font); font-size: 1rem; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.tile p { margin: 0; font-size: .875rem; line-height: 1.5; color: var(--text-2); }
.tile-new {
  position: absolute; top: 14px; right: 14px; padding: 3px 8px; border-radius: 999px;
  background: #f5a524; color: #2b1d00; font-size: .6875rem; font-weight: 700; line-height: 1.3; letter-spacing: .06em; text-transform: uppercase;
  box-shadow: 0 4px 10px -4px rgba(197, 124, 8, .7);
}
@media (max-width: 559.98px) {
  .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 14px 12px 15px; gap: 5px; border-radius: 14px; }
  .tile-icon { width: 40px; height: 40px; border-radius: 12px; margin-bottom: 6px; }
  .tile-icon svg { width: 22px; height: 22px; }
  .tile h3 { font-size: .9375rem; }
  .tile p { font-size: .8125rem; line-height: 1.45; }
  .tile-new { top: 12px; right: 10px; padding: 2px 7px; font-size: .625rem; }
}

/* home page "Featured calculators" panel (6 cards): 6 in a row, or 3 + 3, never 5 + 1 */
@media (min-width: 560px) and (max-width: 1099.98px) { .panel-section .tile-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .panel-section .tile-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; } }

/* the cards fade in after a filter pill is pressed */
@keyframes tile-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.tool-groups.is-filtered .tool-group:not([hidden]) { animation: tile-in .3s ease both; }

@media (prefers-reduced-motion: reduce) {
  .tile, .tile::before, .tile-icon, .filter-pill { transition: none; }
  .tile:hover, .tile:focus-visible, .tile:hover .tile-icon, .tile:focus-visible .tile-icon { transform: none; }
  .tool-groups.is-filtered .tool-group:not([hidden]) { animation: none; }
}
@media (forced-colors: active) {
  .tile-icon, .group-icon { border: 1px solid CanvasText; }
  .tile-icon svg, .group-icon svg { stroke: CanvasText; }
  .filter-pill[aria-pressed="true"] { border: 2px solid Highlight; }
}
@media print { .filter-bar, .cat-hero::before { display: none; } }
