/* ===================================================================
   All-tools directory. Loaded only by tools.cshtml, after the shared
   template stylesheet, and scoped under .toolspage throughout.

   Design tokens come from a2z-tokens.css, shared with the home page -
   this is the same product, so it is the same palette, radii and
   shadows. Mobile-first: base rules are the phone layout and the media
   queries only add.

   The page no longer uses .search-block / .search-below-wrpr /
   .icon-list-hero from the template stylesheet. Those are still used by
   index-design.cshtml and category-details.cshtml and are deliberately
   left alone.
   =================================================================== */

.toolspage section {
    padding-top: 0;
    padding-bottom: 0;
    overflow: visible;
}

.tp-shell {
    width: 100%;
    max-width: 1200px;
    margin-inline: auto;
    padding-inline: clamp(1rem, 4vw, 2rem);
}

.tp-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.toolspage a:focus-visible,
.toolspage button:focus-visible,
.toolspage input:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
    border-radius: var(--h-r-sm);
}

/* -------------------------------------------------------------------
   HERO
   ------------------------------------------------------------------- */
.tp-hero {
    background: var(--h-canvas);
    border-bottom: 1px solid var(--h-line-soft);
    padding-block: clamp(1.75rem, 5vw, 3rem) clamp(1.5rem, 4vw, 2.25rem);
}

.tp-hero-inner {
    text-align: center;
}

.tp-title {
    margin: 0;
    font-size: clamp(1.75rem, 5vw, 2.75rem);
    line-height: 1.12;
    letter-spacing: -.022em;
    font-weight: 700;
    color: var(--heading-color);
    text-wrap: balance;
}

.tp-lede {
    margin: clamp(.7rem, 2vw, 1rem) auto 0;
    max-width: 58ch;
    font-size: clamp(.9375rem, 2.2vw, 1.0625rem);
    line-height: 1.6;
    color: var(--h-muted);
    text-wrap: pretty;
}

/* ---- filter field --------------------------------------------------- */
.tp-search {
    position: relative;
    width: 100%;
    max-width: 560px;
    margin: clamp(1.15rem, 3vw, 1.75rem) auto 0;
    text-align: left;
}

.tp-search-icon {
    position: absolute;
    top: 50%;
    left: 1.15rem;
    width: 19px;
    height: 19px;
    margin-top: -9.5px;
    color: var(--h-muted);
    pointer-events: none;
}

.tp-search-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.tp-search-input {
    box-sizing: border-box;
    display: block;
    width: 100%;
    /* 52px on a phone - above the 44px touch-target floor. */
    height: clamp(3.25rem, 7vw, 3.5rem);
    margin: 0;
    padding: 0 3rem 0 3.1rem;
    font-size: clamp(.9375rem, 2.4vw, 1rem);
    font-family: inherit;
    color: var(--h-ink);
    background: var(--h-paper);
    border: 1px solid var(--h-line);
    border-radius: var(--h-r-pill);
    box-shadow: var(--h-shadow-md);
    transition: box-shadow .18s ease, border-color .18s ease;
    -webkit-appearance: none;
    appearance: none;
}

.tp-search-input::placeholder {
    color: var(--h-muted);
    opacity: 1;
}

.tp-search-input:focus {
    outline: 0;
    border-color: var(--h-accent);
    box-shadow: var(--h-shadow-md), 0 0 0 4px var(--h-accent-ring);
}

/* The native cross would sit on top of the custom clear button. */
.tp-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.tp-search-clear {
    position: absolute;
    top: 50%;
    right: .6rem;
    display: grid;
    place-items: center;
    /* 40px hit area even though the glyph is 16px. */
    width: 40px;
    height: 40px;
    margin-top: -20px;
    padding: 0;
    color: var(--h-muted);
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.tp-search-clear svg {
    width: 16px;
    height: 16px;
}

.tp-search-clear:hover {
    color: var(--h-ink);
    background: var(--h-line-soft);
}

.tp-count {
    margin: .85rem 0 0;
    font-size: .875rem;
    font-weight: 500;
    color: var(--h-muted);
}

/* -------------------------------------------------------------------
   JUMP NAV
   Sticky under the fixed header the layout already offsets for.
   ------------------------------------------------------------------- */
.tp-jump {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--h-paper);
    border-bottom: 1px solid var(--h-line-soft);
}

.tp-jump-inner {
    display: flex;
    gap: .4rem;
    /* Scrolls sideways on a phone instead of wrapping into a tall block
       that would push the actual list off the screen. */
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    padding-block: .6rem;
    -webkit-overflow-scrolling: touch;
}

.tp-jump-inner::-webkit-scrollbar {
    height: 6px;
}

.tp-jump-inner::-webkit-scrollbar-thumb {
    background: var(--h-line);
    border-radius: 6px;
}

.tp-jump-link {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    flex: 0 0 auto;
    min-height: 38px;
    padding: .4rem .8rem;
    font-size: .8125rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    color: var(--h-ink-2);
    text-decoration: none;
    background: var(--h-canvas);
    border: 1px solid var(--h-line-soft);
    border-radius: var(--h-r-pill);
    transition: color .15s ease, border-color .15s ease;
}

.tp-jump-link:hover {
    color: var(--h-accent-strong);
    border-color: var(--h-accent);
    text-decoration: none;
}

.tp-jump-count {
    font-size: .6875rem;
    font-variant-numeric: tabular-nums;
    color: var(--h-muted);
}

/* -------------------------------------------------------------------
   CATEGORY SECTIONS
   ------------------------------------------------------------------- */
.tp-body {
    background: var(--h-paper);
    padding-block: clamp(1.75rem, 5vw, 3rem);
}

.tp-cat + .tp-cat {
    margin-top: clamp(2rem, 5vw, 3rem);
}

/* An anchored jump must not land the heading under the sticky bar. */
.tp-cat {
    scroll-margin-top: 4.5rem;
}

.tp-cat-head {
    display: flex;
    align-items: center;
    gap: .7rem;
    margin-bottom: 1rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--h-line-soft);
}

.tp-cat-icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    color: var(--primary-blue);
    background: var(--h-accent-soft);
    border-radius: var(--h-r-sm);
}

.tp-cat-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

.tp-cat-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: clamp(1.125rem, 2.8vw, 1.375rem);
    line-height: 1.25;
    letter-spacing: -.015em;
    font-weight: 700;
}

.tp-cat-title a {
    color: var(--heading-color);
    text-decoration: none;
}

.tp-cat-title a:hover {
    color: var(--h-accent-strong);
    text-decoration: none;
}

.tp-cat-count {
    flex: 0 0 auto;
    font-size: .8125rem;
    font-variant-numeric: tabular-nums;
    color: var(--h-muted);
    white-space: nowrap;
}

/* ---- tool grid ------------------------------------------------------ */
.tp-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: .6rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tp-tool {
    display: flex;
    align-items: center;
    gap: .7rem;
    height: 100%;
    padding: .7rem .85rem;
    text-decoration: none;
    color: var(--h-ink);
    background: var(--card-background);
    border: 1px solid var(--h-line);
    border-radius: var(--h-r-md);
    /* Same warm beige offset as the home page - the two pages are one
       design and a card must not look different depending on where it
       is seen. */
    box-shadow: var(--card-offset), var(--h-shadow-sm);
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease, background-color .16s ease;
}

.tp-tool:hover,
.tp-tool:focus-visible {
    border-color: var(--primary-blue);
    box-shadow: var(--card-offset-hover), var(--h-shadow-md);
    background: var(--primary-blue-soft);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--h-ink);
}

.tp-tool:active {
    transform: translateY(0);
    box-shadow: var(--card-offset), var(--h-shadow-sm);
}

.tp-tool-icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: var(--h-accent-soft);
}

.tp-tool-icon img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.tp-tool-name {
    min-width: 0;
    font-size: .875rem;
    font-weight: 550;
    line-height: 1.35;
    /* Two lines maximum, so one long name cannot stretch its row. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---- empty state ----------------------------------------------------- */
.tp-empty {
    margin: 2.5rem 0;
    padding: 2rem 1.25rem;
    text-align: center;
    font-size: .9375rem;
    color: var(--h-muted);
    background: var(--h-canvas);
    border: 1px dashed var(--h-line);
    border-radius: var(--h-r-lg);
}

.tp-empty strong {
    color: var(--h-ink);
}

.tp-empty-reset {
    display: inline-block;
    margin-left: .35rem;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: var(--h-accent-strong);
    background: none;
    border: 0;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* -------------------------------------------------------------------
   Breakpoints - these only add columns.
   ------------------------------------------------------------------- */
@media (min-width: 480px) {
    .tp-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 768px) {
    .tp-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 992px) {
    .tp-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .tp-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .toolspage *,
    .toolspage *::before,
    .toolspage *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }

    .tp-tool:hover {
        transform: none;
    }
}

@media (forced-colors: active) {
    .tp-tool,
    .tp-jump-link {
        border: 1px solid ButtonBorder;
    }
}
