/**
 * TroubleshooterNext — Frontend Stylesheet
 *
 * Public-facing styles for the troubleshooting guide landing page, single
 * guide page, step display, option buttons, resolution state, product cards,
 * progress bar, back button, animations, and responsive breakpoints.
 *
 * Mobile-first approach with breakpoints at 768px and 1024px.
 * Primary colour: #2271b1 (WordPress blue).
 *
 * CSS class prefix: tsn-
 *
 * @package    TroubleshooterNext
 * @subpackage Public/CSS
 * @since      1.0.0
 */


/* ==========================================================================
   1. Landing Page
   ========================================================================== */

/**
 * Landing page container — full-width wrapper for the guide archive.
 */
.tsn-landing {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

/**
 * Page header — title and description.
 */
.tsn-landing__header {
    text-align: center;
    margin-bottom: 32px;
}

.tsn-landing__title {
    font-size: 28px;
    font-weight: 700;
    color: #1d2327;
    margin: 0 0 12px;
    line-height: 1.3;
}

.tsn-landing__description {
    font-size: 16px;
    color: #50575e;
    margin: 0;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

/**
 * Guide card grid — CSS Grid. 1 column mobile, 2 tablet, 3 desktop.
 */
.tsn-guide-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (min-width: 768px) {
    .tsn-guide-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .tsn-guide-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/**
 * Guide card — individual card in the grid.
 */
.tsn-guide-card {
    background: #fff;
    border: 1px solid #e2e4e7;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    display: flex;
    flex-direction: column;
}

/* Honour the [hidden] attribute. The .tsn-guide-card rule above sets
 * display: flex, which (as author CSS) outranks the browser's
 * user-agent `[hidden] { display: none }` rule. Without this explicit
 * override the live guide search marks cards as hidden but the
 * display: flex keeps them visible — defeating the filter. */
.tsn-guide-card[hidden] {
    display: none;
}

.tsn-guide-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/**
 * Card image area — thumbnail or placeholder.
 */
.tsn-guide-card__image {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #f0f0f1;
}

.tsn-guide-card__image a {
    display: block;
    width: 100%;
    height: 100%;
}

.tsn-guide-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/**
 * Placeholder icon when no featured image is set.
 */
.tsn-guide-card__img--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f1;
    color: #a7aaad;
    height: 100%;
}

.tsn-guide-card__img--placeholder .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
}

/**
 * Card body — text content area.
 */
.tsn-guide-card__body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.tsn-guide-card__title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px;
    line-height: 1.3;
}

.tsn-guide-card__title a {
    color: #1d2327;
    text-decoration: none;
}

.tsn-guide-card__title a:hover {
    color: #2271b1;
}

.tsn-guide-card__excerpt {
    font-size: 14px;
    color: #50575e;
    line-height: 1.5;
    margin: 0 0 12px;
    flex: 1;
}

.tsn-guide-card__excerpt p {
    margin: 0;
}

/**
 * Metadata badges row — difficulty and estimated time.
 */
.tsn-guide-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.tsn-guide-card__time {
    font-size: 12px;
    color: #646970;
}

/**
 * Taxonomy labels row — appliance type and brand pills.
 */
.tsn-guide-card__labels {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/**
 * Empty state — no guides found.
 */
.tsn-landing__empty {
    text-align: center;
    padding: 60px 20px;
    color: #50575e;
}

.tsn-landing__empty-icon .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #a7aaad;
}

.tsn-landing__empty-title {
    font-size: 20px;
    font-weight: 600;
    margin: 16px 0 8px;
    color: #1d2327;
}

.tsn-landing__empty-message {
    font-size: 14px;
    max-width: 500px;
    margin: 0 auto 16px;
    line-height: 1.6;
}

.tsn-landing__empty-clear {
    display: inline-block;
    padding: 8px 20px;
    background: #2271b1;
    color: #fff;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.tsn-landing__empty-clear:hover {
    background: #135e96;
    color: #fff;
}

/**
 * Pagination — standard WordPress pagination styling override.
 */
.tsn-pagination {
    margin-top: 40px;
    text-align: center;
}


/* ==========================================================================
   1b. Funnel Navigation
   ========================================================================== */

/**
 * Funnel breadcrumb — horizontal trail showing the user's path through
 * the funnel (e.g. "All Appliances > Vacuums > No Suction > Dyson").
 * Each segment links back to the corresponding earlier step.
 */
.tsn-funnel-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #646970;
    margin-bottom: 24px;
    padding: 12px 16px;
    background: #f6f7f7;
    border: 1px solid #e2e4e7;
    border-radius: 6px;
}

.tsn-funnel-breadcrumb a {
    color: #2271b1;
    text-decoration: none;
    font-weight: 500;
}

.tsn-funnel-breadcrumb a:hover {
    text-decoration: underline;
}

.tsn-funnel-breadcrumb__sep {
    color: #a7aaad;
    font-size: 16px;
}

.tsn-funnel-breadcrumb__current {
    color: #1d2327;
    font-weight: 600;
}

/**
 * Funnel step heading — large heading for each funnel step.
 */
.tsn-funnel-heading {
    font-size: 28px;
    font-weight: 700;
    color: #1d2327;
    margin: 0 0 12px;
    line-height: 1.3;
}

/**
 * Funnel search input — full-width search box for filtering brands/models
 * client-side. Positioned above the card grid.
 */
.tsn-funnel-search {
    display: block;
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    color: #2c3338;
    background: #fff;
    border: 1px solid #8c8f94;
    border-radius: 6px;
    margin-bottom: 20px;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tsn-funnel-search:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
    outline: none;
}

.tsn-funnel-search::placeholder {
    color: #a7aaad;
}

/**
 * Funnel back link — styled as a subtle text link with left arrow.
 * Positioned above the card grid, below the header.
 */
.tsn-funnel-back {
    display: inline-block;
    font-size: 14px;
    font-weight: 500;
    color: #2271b1;
    text-decoration: none;
    margin-bottom: 20px;
    transition: color 0.2s ease;
}

.tsn-funnel-back:hover {
    color: #135e96;
    text-decoration: underline;
}


/* ==========================================================================
   1c. Term Cards Grid (Funnel Steps)
   ========================================================================== */

/**
 * Term card grid — CSS Grid. 1 column mobile, 2 tablet, 3 desktop.
 * Used for appliance type, symptom, brand, and model cards.
 */
.tsn-term-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 32px;
}

@media (min-width: 768px) {
    .tsn-term-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .tsn-term-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/**
 * Individual term card — clickable card linking to the next funnel step.
 * White background, subtle border, rounded corners, hover shadow.
 */
.tsn-term-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 0;
    background: #fff;
    border: 1px solid #e2e4e7;
    border-radius: 8px;
    text-decoration: none;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    overflow: hidden;
}

.tsn-term-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    border-color: #2271b1;
}

.tsn-term-card:focus-visible {
    outline: 3px solid #2271b1;
    outline-offset: 2px;
}

/**
 * Term card image — displayed above the name/count text.
 */
.tsn-term-card__image {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 6px 6px 0 0;
}

/**
 * Term card placeholder — grey box when no image is set.
 */
.tsn-term-card__placeholder {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #f0f0f1;
    border-radius: 6px 6px 0 0;
}

/**
 * Term card name — large, prominent text.
 */
.tsn-term-card__name {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: #1d2327;
    margin-bottom: 6px;
    line-height: 1.3;
    padding: 16px 16px 0;
}

/**
 * Term card count — small guide count below the name.
 */
.tsn-term-card__count {
    display: block;
    font-size: 13px;
    color: #646970;
    line-height: 1.4;
    padding: 0 16px 16px;
}

/**
 * Hidden state for cards filtered out by the search box.
 */
.tsn-term-card--hidden {
    display: none;
}


/* ==========================================================================
   1d. Funnel Pagination
   ========================================================================== */

/**
 * Pagination nav — horizontal row of page numbers for brands/models
 * when there are more than 20 items.
 */
.tsn-funnel-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 24px;
    margin-bottom: 32px;
}

.tsn-funnel-pagination__link,
.tsn-funnel-pagination__current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 4px;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.tsn-funnel-pagination__link {
    color: #2271b1;
    background: #fff;
    border: 1px solid #e2e4e7;
}

.tsn-funnel-pagination__link:hover {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.tsn-funnel-pagination__current {
    background: #2271b1;
    color: #fff;
    border: 1px solid #2271b1;
}

/**
 * v2 funnel search (AJAX) — loading, empty, and current-page states.
 *
 * The JS controller toggles `.tsn-funnel-loading` on the body element
 * during fetches, renders `.tsn-funnel-empty` on zero results, and
 * marks the current pagination link with aria-current="page" so CSS
 * can style it without needing a separate tag.
 */
.tsn-funnel-results {
    position: relative;
}

.tsn-funnel-loading {
    opacity: 0.6;
    transition: opacity 0.2s ease;
    pointer-events: none;
    position: relative;
}

.tsn-funnel-loading::after {
    content: "";
    position: absolute;
    top: 24px;
    right: 24px;
    width: 22px;
    height: 22px;
    border: 3px solid #e2e4e7;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: tsnFunnelSpin 0.8s linear infinite;
    z-index: 2;
}

.tsn-funnel-loading__indicator {
    text-align: center;
    padding: 40px 20px;
    color: #646970;
    font-size: 14px;
}

@keyframes tsnFunnelSpin {
    to { transform: rotate(360deg); }
}

.tsn-funnel-empty {
    text-align: center;
    padding: 40px 20px;
    color: #50575e;
    font-size: 14px;
}

.tsn-funnel-empty p {
    margin: 0 0 12px;
}

/**
 * Current page indicator — the v2 pagination emits plain anchors for
 * every page (so no-JS users can click through), and marks the active
 * one with aria-current="page".
 */
.tsn-funnel-pagination__link[aria-current="page"] {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
    pointer-events: none;
    cursor: default;
}

.tsn-funnel-pagination__link[aria-current="page"]:hover {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}


/* ==========================================================================
   2. Guide Page
   ========================================================================== */

/**
 * Guide container — centred layout for the interactive troubleshooter.
 * 1200px gives plenty of room for product cards alongside step content
 * on desktop screens, while still feeling contained and readable.
 *
 * The width:100% and box-sizing ensure the guide fills whatever
 * container the theme provides, and the max-width caps it at 1200px.
 */
.tsn-guide {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    box-sizing: border-box;
}

/**
 * Override theme containers that restrict content width.
 * Astra uses .ast-container, other themes use .site-content
 * or .content-area. Force these to be full-width when they
 * contain our guide.
 */
.ast-container:has(.tsn-guide),
.ast-container:has(.tsn-landing),
.site-content:has(.tsn-guide),
.site-content:has(.tsn-landing) {
    max-width: 100%;
    padding-left: 0;
    padding-right: 0;
}

/**
 * Same for the landing page.
 */
.tsn-landing {
    width: 100%;
    box-sizing: border-box;
}

/**
 * Breadcrumb navigation — contextual navigation trail.
 */
.tsn-breadcrumb {
    margin-bottom: 24px;
}

.tsn-breadcrumb__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #646970;
}

/* Separator between breadcrumb items. */
.tsn-breadcrumb__item + .tsn-breadcrumb__item::before {
    content: "/";
    margin-right: 4px;
    color: #a7aaad;
}

.tsn-breadcrumb__link {
    color: #2271b1;
    text-decoration: none;
}

.tsn-breadcrumb__link:hover {
    text-decoration: underline;
}

.tsn-breadcrumb__item--current {
    color: #1d2327;
    font-weight: 500;
}

/**
 * Guide header — title and metadata.
 */
.tsn-guide__header {
    margin-bottom: 24px;
}

.tsn-guide__title {
    font-size: 28px;
    font-weight: 700;
    color: #1d2327;
    margin: 0 0 12px;
    line-height: 1.3;
}

.tsn-guide__description {
    font-size: 15px;
    color: #50575e;
    line-height: 1.6;
    margin-bottom: 16px;
}

.tsn-guide__description p {
    margin: 0 0 8px;
}

.tsn-guide__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.tsn-guide__time {
    font-size: 13px;
    color: #646970;
}

/**
 * Guide navigation container (back button).
 */
.tsn-guide__nav {
    margin-top: 24px;
}


/* ==========================================================================
   3. Step Display
   ========================================================================== */

/**
 * Step container — wraps the currently visible step.
 */
.tsn-step-container {
    min-height: 200px;
    position: relative;
}

/**
 * Empty state for steps not yet configured.
 */
.tsn-step-container__empty {
    text-align: center;
    padding: 40px 20px;
    color: #50575e;
    font-size: 15px;
}

/**
 * Individual step wrapper. Positioned relative for fade transition stacking.
 */
.tsn-step {
    padding: 24px 0;
}

/**
 * Step type badge — small coloured pill above the step title.
 */
.tsn-step__type-badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    border-radius: 10px;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Step badge — blue. */
.tsn-step__type-badge--step {
    background: #e7f2fa;
    color: #0a4b78;
}

/* Question badge — blue (backwards compat alias for step). */
.tsn-step__type-badge--question {
    background: #e7f2fa;
    color: #0a4b78;
}

/* Instruction badge — blue (backwards compat alias for step). */
.tsn-step__type-badge--instruction {
    background: #e7f2fa;
    color: #0a4b78;
}

/* Resolution badge — green. */
.tsn-step__type-badge--resolution {
    background: #e0f2e9;
    color: #00450c;
}

/**
 * Step title — large heading.
 */
.tsn-step__title {
    font-size: 24px;
    font-weight: 700;
    color: #1d2327;
    margin: 0 0 16px;
    line-height: 1.3;
}

/**
 * Step image — responsive with rounded corners.
 */
.tsn-step-image {
    margin-bottom: 20px;
}

.tsn-step-image__img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    display: block;
}

/**
 * Step content — readable typography.
 */
.tsn-step__content {
    font-size: 15px;
    line-height: 1.7;
    color: #2c3338;
    margin-bottom: 24px;
}

.tsn-step__content p {
    margin: 0 0 12px;
}

.tsn-step__content p:last-child {
    margin-bottom: 0;
}

.tsn-step__content ul,
.tsn-step__content ol {
    margin: 0 0 12px 20px;
}

.tsn-step__content a {
    color: #2271b1;
    text-decoration: underline;
}

.tsn-step__content a:hover {
    color: #135e96;
}

.tsn-step__content img {
    max-width: 100%;
    height: auto;
}

/**
 * AI-imported steps emit standard Gutenberg blocks: Custom HTML for
 * the YouTube embed, Paragraph for intro/branch question text, and
 * one Media & Text block per illustrated action. The block CSS that
 * ships with WordPress core + the active theme handles in-block
 * layout; the overrides below force consistent OUTER spacing
 * between consecutive blocks within a step.
 *
 * Why !important: Astra (and several other themes) target
 * `.entry-content > *` with high-specificity margin rules. Our
 * step content lives in `.tsn-step__content`, NOT `.entry-content`,
 * so theme rules don't apply — and core block CSS resets
 * Media & Text margins to 0. The result without these overrides
 * is consecutive action blocks butted right up against each other
 * with no visible boundary. !important here just stakes a claim
 * over a CSS rule that hasn't been claimed by anything else.
 */

/* Zero out any inherited margin so we control spacing exclusively
 * from the rules below. Reset only direct children of the step
 * content wrapper; nested elements (paragraphs inside Media & Text
 * content columns, etc.) keep their own margins. */
.tsn-step__content > * {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* Spacing + visible divider between consecutive blocks. The `> * + *`
 * selector matches every direct child that has a sibling before it,
 * so the very first block (the YouTube embed) gets no spacing or
 * border above it — separators only appear BETWEEN sections.
 *
 * Generous spacing + a 2px line is intentional: the previous 1px
 * line at 36px+32px was still being lost in dense pages. Total
 * separation here is 48px above + 2px line + 40px below = 90px
 * of unmistakable boundary between actions. */
.tsn-step__content > * + * {
    margin-top: 48px !important;
    padding-top: 40px !important;
    border-top: 2px solid #d4d8dd !important;
}

/* Image styling inside Media & Text — block display, full column
 * width, rounded corners to soften the screenshot edge. */
.tsn-step__content .wp-block-media-text__media img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 6px;
}

/* Mobile (≤600px): when Media & Text stacks, the image lands ABOVE
 * its own text. Two things matter here:
 *  - Generous margin-bottom on the image so the text below it
 *    reads as paired, not orphaned.
 *  - The block separator (set via `> * + *` above) still applies,
 *    so the boundary BETWEEN actions stays clear. We just shrink
 *    the gap a touch on small screens to avoid wasting scroll. */
@media (max-width: 600px) {
    .tsn-step__content > * + * {
        margin-top: 36px !important;
        padding-top: 28px !important;
    }
    .tsn-step__content .wp-block-media-text.is-stacked-on-mobile .wp-block-media-text__media {
        margin-bottom: 18px !important;
    }
}


/* ==========================================================================
   3b. Step Tools
   ========================================================================== */

/**
 * Tools Needed section — displayed between step content and option buttons.
 * Shows ts_tool taxonomy terms assigned to the current step post.
 */
/* Use high-specificity selectors with !important to prevent
 * theme CSS/JS from hiding the tools section. Astra and other
 * themes apply display/visibility rules to lists and sections
 * within content areas that can conflict. */
.tsn-step .tsn-step-tools {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    overflow: visible !important;
    margin: 20px 0;
    padding: 16px;
    background: #f8f9fa;
    border: 1px solid #e2e4e7;
    border-radius: 6px;
}

.tsn-step .tsn-step-tools__heading {
    display: block !important;
    visibility: visible !important;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 10px;
    color: #1d2327;
}

.tsn-step .tsn-step-tools__list {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    visibility: visible !important;
    flex-wrap: wrap;
    gap: 10px;
}

.tsn-step .tsn-step-tools__item {
    display: flex !important;
    visibility: visible !important;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 13px;
    list-style: none !important;
}

.tsn-step .tsn-step-tools__image {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 3px;
}

.tsn-step .tsn-step-tools__name {
    display: inline !important;
    visibility: visible !important;
    color: #1d2327;
}


/* ==========================================================================
   4. Option Buttons
   ========================================================================== */

/**
 * Option buttons container — vertical flex column of choice buttons.
 */
.tsn-step-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

/**
 * Recommended products section — appears below option buttons on
 * non-terminal steps. Small top margin separates it from the
 * buttons without pushing the products below the fold on desktop.
 */
.tsn-step-products {
    margin-top: 20px;
}

.tsn-step-products__heading {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 16px;
    color: #1d2327;
    line-height: 1.3;
}

/**
 * Individual option button — large, prominent, clickable choice.
 */
.tsn-option-btn {
    display: block;
    width: 100%;
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 500;
    color: #1d2327;
    background: #fff;
    border: 2px solid #2271b1;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    line-height: 1.4;
}

.tsn-option-btn:hover {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.tsn-option-btn:focus-visible {
    outline: 3px solid #2271b1;
    outline-offset: 2px;
}

.tsn-option-btn:active {
    background: #135e96;
    border-color: #135e96;
    color: #fff;
}


/* ==========================================================================
   5. Resolution
   ========================================================================== */

/**
 * Resolution wrapper — structural container when resolution is embedded
 * inside a step. Provides top margin separation from step content.
 */
.tsn-step__resolution-wrapper {
    margin-top: 24px;
}

/**
 * Resolution container — success state with green tinting.
 */
.tsn-resolution {
    background: #f0faf4;
    border: 1px solid #b8e6c8;
    border-radius: 8px;
    padding: 32px 24px;
    text-align: center;
    margin-top: 16px;
}

/**
 * Checkmark icon — centred green circle with checkmark SVG.
 */
.tsn-resolution__icon {
    margin-bottom: 16px;
    color: #00a32a;
}

.tsn-resolution__checkmark {
    display: inline-block;
}

/**
 * "Further Action Needed" variant — red warning instead of green
 * success. Used when the troubleshooting couldn't fully resolve
 * the issue and the user needs to take additional steps (contact
 * support, ship in for repair, etc.).
 */
.tsn-resolution--warning {
    background: #fef0f0;
    border-color: #f0a8aa;
}

.tsn-resolution--warning .tsn-resolution__icon {
    color: #d63638;
}

.tsn-resolution__warning-icon {
    display: inline-block;
}

/**
 * Resolution title.
 */
.tsn-resolution__title {
    font-size: 22px;
    font-weight: 700;
    color: #1d2327;
    margin: 0 0 12px;
    line-height: 1.3;
}

/**
 * Resolution content — detailed instructions or answer text.
 */
.tsn-resolution__content {
    font-size: 15px;
    line-height: 1.7;
    color: #2c3338;
    text-align: left;
    margin-bottom: 24px;
}

.tsn-resolution__content p {
    margin: 0 0 12px;
}

.tsn-resolution__content p:last-child {
    margin-bottom: 0;
}

/**
 * Recommended products section.
 */
.tsn-resolution__products {
    margin-top: 24px;
    text-align: left;
}

.tsn-resolution__products-heading {
    font-size: 18px;
    font-weight: 600;
    color: #1d2327;
    margin: 0 0 16px;
}

/**
 * Navigation actions — Start Over and Back to Guides.
 */
.tsn-resolution__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
}

.tsn-start-over {
    display: inline-block;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    color: #fff;
    background: #2271b1;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.tsn-start-over:hover {
    background: #135e96;
}

.tsn-start-over:focus-visible {
    outline: 3px solid #2271b1;
    outline-offset: 2px;
}

.tsn-resolution__back-link {
    display: inline-block;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    color: #2271b1;
    background: transparent;
    border: 2px solid #2271b1;
    border-radius: 6px;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.tsn-resolution__back-link:hover {
    background: #2271b1;
    color: #fff;
}


/* ==========================================================================
   6. Product Cards
   ========================================================================== */

/**
 * Product grid — CSS Grid. 1 column mobile, 2 tablet, 3 desktop.
 */
.tsn-product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

@media (min-width: 768px) {
    .tsn-product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1024px) {
    .tsn-product-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/**
 * Individual product card.
 */
.tsn-product-card {
    background: #fff;
    border: 1px solid #e2e4e7;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s ease;
}

.tsn-product-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/**
 * Product image area.
 */
.tsn-product-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f6f7f7;
}

.tsn-product-image a {
    display: block;
    width: 100%;
    height: 100%;
}

.tsn-product-image__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/**
 * Product details section.
 */
.tsn-product-card__details {
    padding: 7px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.tsn-product-card__name {
    font-size: 11px;
    font-weight: 600;
    margin: 0 0 3px;
    line-height: 1.3;
}

.tsn-product-card__name a {
    color: #1d2327;
    text-decoration: none;
}

.tsn-product-card__name a:hover {
    color: #2271b1;
}

.tsn-product-card__price {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #1d2327 !important;
    margin-bottom: 4px;
    display: block !important;
    visibility: visible !important;
}

/* Ensure WooCommerce price markup inside our cards is visible.
 * Theme CSS may hide or restyle these spans. */
.tsn-product-card__price .woocommerce-Price-amount,
.tsn-product-card__price .woocommerce-Price-currencySymbol,
.tsn-product-card__price bdi {
    display: inline !important;
    visibility: visible !important;
    color: #1d2327 !important;
    font-size: inherit !important;
}

.tsn-product-card__sku {
    font-size: 10px;
    color: #646970;
    display: block;
    margin-bottom: 3px;
}

/**
 * Stock status badges.
 */
.tsn-product-card__stock {
    font-size: 10px;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 12px;
}

.tsn-product-card__stock--in {
    color: #00a32a;
}

.tsn-product-card__stock--out {
    color: #d63638;
}

.tsn-product-card__stock--backorder {
    color: #dba617;
}

/**
 * Add to cart / view product button — styled to match WooCommerce.
 */
.tsn-add-to-cart {
    display: inline-block;
    width: 100%;
    padding: 5px 8px;
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    color: #fff;
    background: #2271b1;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s ease;
    margin-top: auto;
    box-sizing: border-box;
}

.tsn-add-to-cart:hover {
    background: #135e96;
    color: #fff;
}

.tsn-add-to-cart:focus-visible {
    outline: 3px solid #2271b1;
    outline-offset: 2px;
}


/* ==========================================================================
   7. Progress Bar
   ========================================================================== */

/**
 * Progress bar container — thin horizontal bar with step counter label.
 */
.tsn-progress {
    margin-bottom: 24px;
}

.tsn-progress__label {
    display: block;
    font-size: 13px;
    color: #646970;
    margin-bottom: 6px;
    font-weight: 500;
}

/**
 * Track — the grey background bar.
 */
.tsn-progress__track {
    width: 100%;
    height: 6px;
    background: #e2e4e7;
    border-radius: 3px;
    overflow: hidden;
}

/**
 * Fill — the coloured portion that grows as the user progresses.
 */
.tsn-progress__fill {
    height: 100%;
    background: #2271b1;
    border-radius: 3px;
    transition: width 0.4s ease;
    min-width: 0;
}


/* ==========================================================================
   8. Back Button
   ========================================================================== */

/**
 * Back button — subtle, with a left-pointing arrow (CSS pseudo-element).
 */
.tsn-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #2271b1;
    background: transparent;
    border: 1px solid #2271b1;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Left arrow character before the button text. */
.tsn-back-btn::before {
    content: "\2190";
    font-size: 16px;
}

.tsn-back-btn:hover {
    background: #2271b1;
    color: #fff;
}

.tsn-back-btn:focus-visible {
    outline: 3px solid #2271b1;
    outline-offset: 2px;
}


/* ==========================================================================
   8b. YouTube Lazy-Load Placeholders
   ========================================================================== */

/**
 * YouTube placeholder — lightweight thumbnail + play button that replaces
 * hidden YouTube iframes. Clicking plays the video immediately; navigating
 * to the panel restores the original iframe.
 */
.tsn-youtube-placeholder {
    position: relative;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
}

.tsn-youtube-placeholder__thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tsn-youtube-placeholder__play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: opacity 0.2s;
}

.tsn-youtube-placeholder:hover .tsn-youtube-placeholder__play {
    opacity: 0.9;
}

.tsn-youtube-placeholder__play svg {
    display: block;
}


/* ==========================================================================
   9. Animations
   ========================================================================== */

/**
 * Fade-in animation class — applied to steps on entry.
 */
.tsn-fade-in {
    animation: tsnFadeIn 0.3s ease forwards;
}

/**
 * Fade-out animation class — applied to steps on exit.
 */
.tsn-fade-out {
    animation: tsnFadeOut 0.3s ease forwards;
}

@keyframes tsnFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes tsnFadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}


/* ==========================================================================
   10. Responsive
   ========================================================================== */

/**
 * Tablet adjustments (768px+).
 * Most grid layouts switch from 1-column to 2-column here (handled above
 * inline in grid sections). Additional tweaks below.
 */
@media (min-width: 768px) {
    .tsn-landing__title,
    .tsn-funnel-heading {
        font-size: 32px;
    }

    .tsn-guide__title {
        font-size: 32px;
    }

    .tsn-step__title {
        font-size: 26px;
    }

    .tsn-option-btn {
        padding: 18px 24px;
    }
}

/**
 * Desktop adjustments (1024px+).
 */
@media (min-width: 1024px) {
    .tsn-landing {
        padding: 48px 24px;
    }

    .tsn-guide {
        padding: 48px 24px;
    }
}

/**
 * Small screens (below 768px) — mobile-first base styles handle most
 * of this. Explicit overrides for elements that need tighter spacing.
 */
@media (max-width: 767px) {
    .tsn-guide__meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .tsn-resolution {
        padding: 24px 16px;
    }

    .tsn-resolution__actions {
        flex-direction: column;
    }

    .tsn-start-over,
    .tsn-resolution__back-link {
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }
}


/* ==========================================================================
   11. Accessibility
   ========================================================================== */

/**
 * Focus-visible outlines — provide visible focus indicators for keyboard
 * users without affecting mouse users.
 */
.tsn-guide a:focus-visible,
.tsn-guide button:focus-visible,
.tsn-landing a:focus-visible {
    outline: 3px solid #2271b1;
    outline-offset: 2px;
}

/**
 * Screen-reader-only class — hidden visually but available to assistive
 * technology.
 */
.tsn-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/**
 * Reduced motion — disable animations for users who prefer reduced motion.
 */
@media (prefers-reduced-motion: reduce) {
    .tsn-fade-in,
    .tsn-fade-out {
        animation: none;
    }

    .tsn-option-btn,
    .tsn-guide-card,
    .tsn-term-card,
    .tsn-back-btn,
    .tsn-start-over,
    .tsn-resolution__back-link,
    .tsn-progress__fill,
    .tsn-funnel-search {
        transition: none;
    }
}

/**
 * Aria-live region — used by JavaScript to announce step changes to
 * screen readers. Hidden visually but spoken by assistive technology.
 */
.tsn-aria-live {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}


/* ==========================================================================
   12. Guide Card Badges
   ========================================================================== */

/**
 * Shared badge base for the landing page and guide header.
 * Used with BEM modifier classes for difficulty, appliance, and brand.
 */
.tsn-badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    border-radius: 10px;
    white-space: nowrap;
}

/**
 * Difficulty badges — colour-coded by level.
 */
.tsn-badge--difficulty.tsn-badge--easy {
    background: #e0f2e9;
    color: #00450c;
}

.tsn-badge--difficulty.tsn-badge--medium {
    background: #fcf0e3;
    color: #8a5c00;
}

.tsn-badge--difficulty.tsn-badge--hard {
    background: #fce2e2;
    color: #8a0000;
}

/**
 * Appliance type and brand labels — neutral pills.
 */
.tsn-label {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.4;
    border-radius: 10px;
    white-space: nowrap;
}

.tsn-label--appliance {
    background: #f0f0f1;
    color: #50575e;
}

.tsn-label--brand {
    background: #f0f0f1;
    color: #50575e;
}


/* ==========================================================================
   13. Filter Bar
   ========================================================================== */

/**
 * Filter bar form — horizontal layout of select dropdowns and action buttons.
 */
.tsn-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 32px;
    padding: 16px;
    background: #f6f7f7;
    border: 1px solid #e2e4e7;
    border-radius: 8px;
}

/**
 * Individual filter field — label and select dropdown.
 */
.tsn-filter-bar__field {
    flex: 1;
    min-width: 160px;
}

.tsn-filter-bar__label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #1d2327;
    margin-bottom: 4px;
}

/**
 * Select dropdowns — consistent styling across browsers.
 */
.tsn-filter-bar__select {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    color: #2c3338;
    background: #fff;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    cursor: pointer;
    appearance: auto;
    box-sizing: border-box;
}

.tsn-filter-bar__select:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 1px #2271b1;
}

/**
 * Filter action buttons.
 */
.tsn-filter-bar__actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 1px;
}

.tsn-filter-bar__submit {
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    background: #2271b1;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.tsn-filter-bar__submit:hover {
    background: #135e96;
}

.tsn-filter-bar__submit:focus-visible {
    outline: 3px solid #2271b1;
    outline-offset: 2px;
}

/**
 * Clear filters link.
 */
.tsn-filter-bar__clear {
    font-size: 13px;
    color: #2271b1;
    text-decoration: none;
}

.tsn-filter-bar__clear:hover {
    text-decoration: underline;
}

/**
 * Stack filter fields vertically on mobile.
 */
@media (max-width: 767px) {
    .tsn-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .tsn-filter-bar__field {
        min-width: 0;
    }

    .tsn-filter-bar__actions {
        justify-content: center;
    }
}


/* ==========================================================================
   "Any model / Not specified" — funnel + guide list adornments
   ========================================================================== */

/**
 * Pinned card on step 4 (model picker) that bypasses model selection
 * and lands the user on a guide list including every guide for the
 * brand+symptom — including the "applies to all models" ones tagged
 * with no specific model. Styled to stand out from the model grid
 * below it as a distinct entry point.
 */
.tsn-funnel-any-model {
    margin: 0 0 24px;
}

.tsn-funnel-any-model .tsn-term-card--any-model {
    /* Horizontal layout: question-mark icon on the left, text stack
     * on the right. Distinct from the default vertical .tsn-term-card
     * so it reads as an entry point rather than another model card. */
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 18px;
    padding: 18px 22px;
    background: linear-gradient(135deg, #f0f6fc 0%, #e6f0fa 100%);
    border: 1px dashed #2271b1;
    border-radius: 8px;
    text-align: left;
    color: #135e96;
}

.tsn-term-card--any-model__icon {
    /* Inline-svg circle-with-question-mark. `currentColor` lets us
     * recolour the whole icon by changing the link's text colour
     * (e.g. on hover) without touching the SVG markup. */
    flex: 0 0 auto;
    display: inline-flex;
    width: 56px;
    height: 56px;
    color: #2271b1;
}

.tsn-term-card--any-model__icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.tsn-term-card--any-model__text {
    /* Wraps the name + count so the text stack flows independently
     * of the icon. */
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.tsn-funnel-any-model .tsn-term-card--any-model .tsn-term-card__name {
    font-size: 16px;
    font-weight: 600;
    color: #135e96;
    margin: 0;
}

.tsn-funnel-any-model .tsn-term-card--any-model .tsn-term-card__count {
    font-size: 13px;
    color: #50575e;
    background: transparent;
    padding: 0;
    border: 0;
}

/* Hover: bump the icon's colour and the card's border to make the
 * affordance clearer that this is a clickable entry point. The
 * default .tsn-term-card:hover already raises a shadow + nudges
 * the card up — these rules just tint the icon to match. */
.tsn-funnel-any-model .tsn-term-card--any-model:hover {
    border-color: #135e96;
    background: linear-gradient(135deg, #e6f0fa 0%, #d8e8f6 100%);
}

.tsn-funnel-any-model .tsn-term-card--any-model:hover .tsn-term-card--any-model__icon {
    color: #135e96;
}

/**
 * Search bar at the top of step 5 (guide list). Filters specific-
 * model guides by the names of their attached `model` terms; the
 * unspecified guides survive the filter (they apply to every model)
 * but get reordered to the bottom by the server. Plain GET form so
 * search state is bookmarkable.
 */
.tsn-guide-search {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0 24px;
}

.tsn-guide-search__input {
    flex: 1 1 280px;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid #c3c4c7;
    border-radius: 6px;
    font-size: 14px;
}

.tsn-guide-search__input:focus {
    outline: 2px solid #2271b1;
    outline-offset: 1px;
    border-color: #2271b1;
}

.tsn-guide-search__submit {
    padding: 8px 18px;
    background: #2271b1;
    color: #fff;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.tsn-guide-search__submit:hover {
    background: #135e96;
}

.tsn-guide-search__clear {
    align-self: center;
    color: #50575e;
    font-size: 13px;
    text-decoration: underline;
}

/**
 * Badge on guide cards whose backing post has no `model` term —
 * i.e. the brand-wide "applies to all models" guides. Visually
 * distinct from the difficulty badge so the user can scan the list
 * and pick the broadly-applicable guide without having to read every
 * card body.
 */
.tsn-badge--any-model {
    background: #e6f0fa;
    color: #135e96;
    border: 1px solid #c5d9eb;
    font-weight: 600;
}

.tsn-guide-card--unspecified {
    border-left: 3px solid #2271b1;
}


/* ==========================================================================
   Related Guides — bottom-of-guide cross-sell section
   ========================================================================== */

/**
 * Renders below the main troubleshooting flow on every single-guide
 * page. Reuses the existing .tsn-guide-card styling so cards match
 * the funnel guide-list visually. Scoped wrapper provides separation
 * from the main flow content above it.
 */
.tsn-related-guides {
    margin: 48px 0 24px;
    padding-top: 32px;
    border-top: 2px solid #e2e4e7;
}

.tsn-related-guides__heading {
    font-size: 22px;
    font-weight: 600;
    color: #1d2327;
    margin: 0 0 20px;
}

.tsn-related-guides__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}


/* ==========================================================================
   Edit-step affordance (logged-in editors only)
   ========================================================================== */

/**
 * Small inline edit link rendered at the top-right of each step
 * panel for users with edit_posts capability. Server-side gates
 * via current_user_can() so anonymous visitors never see this rule
 * fire — the CSS exists for the markup we know will be present
 * when an editor is viewing.
 *
 * Floats top-right of .tsn-step so it doesn't push the step
 * content down. Subtle styling so it doesn't look like part of
 * the user-facing UI — clearly an admin affordance.
 */
.tsn-step {
    position: relative; /* anchor for the absolutely-positioned edit link */
}

.tsn-step__edit-link {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px 4px 8px;
    font-size: 12px;
    font-weight: 500;
    color: #50575e;
    background: rgba(241, 244, 247, 0.92);
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    text-decoration: none;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    z-index: 5; /* above floated images that might overlap the corner */
}

.tsn-step__edit-link:hover,
.tsn-step__edit-link:focus {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
    text-decoration: none;
    outline: none;
}

.tsn-step__edit-link .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}
