/* =========================================================================
   Company Comparison + Find-Your-Fit pages

   Enqueued only on the two page templates (see blogza_enqueue_scripts in
   functions.php). Does NOT depend on the parent (blogus) stylesheet — these
   rules should keep working even if the parent CSS is dequeued.
   ========================================================================= */

.cult-compare-page .lead,
.cult-fit-page .lead {
    color: #555;
    margin-bottom: 1.25rem;
}

/* --- Compare picker ------------------------------------------------------ */

.compare-picker {
    margin: 1.5rem 0 2rem;
}
.compare-picker-input {
    position: relative;
    max-width: 480px;
}
#compare-search {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid #bbb;
    border-radius: 4px;
    font-size: 1rem;
}
.compare-suggestions {
    list-style: none;
    margin: 2px 0 0;
    padding: 0;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    max-height: 280px;
    overflow-y: auto;
    z-index: 30;
}
.compare-suggestions li {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
}
.compare-suggestions li:hover {
    background: #f4f4f4;
}

.compare-chips {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.compare-chips .chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #1d594e;
    color: #fff;
    padding: 0.3rem 0.55rem 0.3rem 0.75rem;
    border-radius: 999px;
    font-size: 0.95rem;
}
.compare-chips .chip-x {
    background: transparent;
    color: #fff;
    border: 0;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
}
.compare-limit-msg {
    margin-top: 0.6rem;
    color: #a00;
    font-size: 0.9rem;
}

/* --- Compare grid -------------------------------------------------------- */

.compare-empty {
    color: #666;
    font-style: italic;
    padding: 2rem 0;
    text-align: center;
}
#compare-grid.compare-grid {
    display: grid;
    gap: 0.75rem 1.25rem;
    margin-top: 1rem;
    align-items: start;
}
.compare-cell {
    padding: 0.6rem 0.5rem;
    min-width: 0;
    border-bottom: 1px solid #e2e2e2;
}
.compare-label {
    font-weight: 600;
    padding-right: 1rem;
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 4;
}
/* Company name + logo row stays pinned to the top of the viewport
   while you scroll through attribute rows. */
.compare-header-row {
    position: sticky;
    top: var(--site-header-height);
    background: var(--color-bg);
    z-index: 5;
    border-bottom: 2px solid #1d594e;
    padding-bottom: 0.75rem;
    padding-top: var(--space-3);
}
/* The label cell in the header row needs both top + left sticky. */
.compare-header-row.compare-label {
    z-index: 6;
}
.compare-company-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
}
.compare-logo {
    max-height: 48px;
    width: auto;
}
.compare-company-link {
    font-weight: 600;
    font-size: 1.05rem;
}
.compare-section-heading {
    margin-top: 0.75rem;
    padding: 0.5rem 0.5rem 0.4rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.85rem;
    color: #fff;
    background: #1d594e;
    border: 0;
}
.compare-text-cell {
    color: #333;
}
.compare-na {
    color: #999;
}

@media (max-width: 768px) {
    /* Task 1: Company-names sticky header row */
    .cult-compare-page .compare-grid {
        overflow-x: auto;
    }
    .cult-compare-page .compare-header-row {
        padding: var(--space-2) 0 var(--space-1);
    }
    .cult-compare-page .compare-company-header {
        gap: 0.15rem;
    }
    .cult-compare-page .compare-logo {
        max-height: 24px;
    }
    .cult-compare-page .compare-company-link {
        font-size: 0.85rem;
        line-height: 1.2;
    }
    .cult-compare-page .compare-header-row .compare-cell {
        background: var(--color-bg);
    }

    /* Task 2: Sticky label column — opaque background + separator shadow */
    .cult-compare-page .compare-label {
        background: var(--color-bg);
        box-shadow: 1px 0 0 var(--color-border);
    }

    /* Task 3: Bar chart label readability */
    .cult-compare-page .compare-chart-cell svg text {
        font-size: 11px;
    }

    /* Task 4: Responsive chart sizing */
    .cult-compare-page .compare-chart-cell svg {
        max-width: 100%;
        height: auto;
        display: block;
    }
}

/* --- Find-Your-Fit page -------------------------------------------------- */

.fit-layout {
    margin-top: 1rem;
}
.fit-form-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.25rem;
}
#fit-reset {
    background: transparent;
    border: 0;
    color: #1d594e;
    text-decoration: underline;
    cursor: pointer;
    padding: 0.25rem 0;
}
.fit-section {
    margin-bottom: 0.75rem;
}
.fit-section-heading {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #1d594e;
    border-bottom: 2px solid #1d594e;
    padding-bottom: 0.25rem;
    margin: 0.5rem 0 0;
}
/* Zebra-striped rows — visible regardless of border overrides from the
   parent theme, and adds zero extra height. */
#fit-form .fit-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0;
    padding: 0.35rem 0.6rem;
    border-bottom: 1px solid #d8d8d8;
}
#fit-form .fit-row:nth-child(odd) {
    background: #f6f6f6;
}
#fit-form .fit-row:last-child {
    border-bottom: 0;
}
.fit-row-label {
    flex: 1 1 240px;
    min-width: 0;
    font-size: 0.95rem;
    line-height: 1.35;
}
.fit-row-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}
/* Belt and suspenders: gap may be ignored if parent theme resets `display`
   on labels, so we also add explicit margins between radio chips. */
#fit-form .fit-radio {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    margin: 0 0.75rem 0 0;
    white-space: nowrap;
}
#fit-form .fit-radio:last-child {
    margin-right: 0;
}
#fit-form .fit-radio input[type="radio"] {
    margin: 0;
}
.fit-row-controls select {
    padding: 0.3rem 0.5rem;
    border: 1px solid #bbb;
    border-radius: 3px;
    font-size: 0.95rem;
    max-width: 220px;
}

.fit-empty {
    color: #666;
    font-style: italic;
    padding: 1.5rem 0;
}
/* Matches panel sticks to the top of the viewport so it stays visible
   as the user scrolls through the form on the left. */
.fit-results-panel {
    position: sticky;
    top: calc(var(--site-header-height) + var(--space-4));
    align-self: flex-start;
    max-height: calc(100vh - var(--site-header-height) - var(--space-4) - 1rem);
    display: flex;
    flex-direction: column;
}
.fit-results-heading {
    margin: 0 0 var(--space-3);
    padding-top: var(--space-2);
    flex: 0 0 auto;
}
.fit-results-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-right: 0.25rem;
    min-height: 0;
}
.fit-results {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: fit-rank;
}
/* Grid layout per row: rank | logo | name | score bar.
   Bar column has a fixed width so bars start at the same x across
   every row — that's what makes them visually comparable. */
.fit-result {
    counter-increment: fit-rank;
    display: grid;
    grid-template-columns: 1.5rem 36px minmax(60px, 1fr) minmax(0, 300px);
    column-gap: 0.6rem;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid #eee;
}
.fit-result::before {
    content: counter(fit-rank);
    font-weight: 700;
    color: #1d594e;
    text-align: right;
    font-size: 0.9rem;
}
.fit-result-logo {
    max-height: 32px;
    max-width: 36px;
    width: auto;
    justify-self: center;
}
.fit-result-title {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fit-result-bar {
    position: relative;
    height: 22px;
    width: 100%;
    min-width: 0;
    background: var(--color-data-bar-track, #ddd);
    border-radius: 4px;
    overflow: hidden;
}
.fit-result-bar__fill {
    height: 100%;
    background: var(--color-data-bar, #1d594e);
}
.fit-result-bar__label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-data-bar-text, #fff);
    mix-blend-mode: difference;
    pointer-events: none;
}

.fit-results-toggle { display: none; }

.fit-results-scroll { overflow-x: hidden; }
.fit-result { min-width: 0; }
.fit-result-title { min-width: 0; }

@media (max-width: 768px) {
    /* Stack label above controls with almost no gap — the base .fit-row's
       0.5rem flex gap becomes a tall vertical space once flex-direction
       flips, so override it here. */
    #fit-form .fit-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.15rem;
        padding: 0.3rem 0.6rem;
    }
    /* Reset flex-basis: the base rule's `flex: 1 1 240px` makes the label
       240px *tall* once the row is flex-direction: column. */
    .fit-row-label { flex: 0 0 auto; font-size: 0.9rem; line-height: 1.25; }
    .fit-row-controls { gap: 0.2rem 0.4rem; }

    .cult-fit-page > h1 {
        font-size: var(--text-2xl);
        margin-top: var(--space-2);
        margin-bottom: var(--space-1);
    }
    .cult-fit-page > p.text-lg {
        font-size: var(--text-sm);
        margin-bottom: var(--space-2);
    }
    .cult-fit-page .fit-layout {
        margin-top: 0.5rem;
        display: flex;
        flex-direction: column;
    }
    .cult-fit-page .fit-layout > [class*="col-"] {
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
    }
    /* Form on top, fixed bottom sheet beneath — no order swap. */
    .cult-fit-page .fit-layout > .col-md-5 { order: 0; }
    .cult-fit-page .fit-layout > .col-md-7 { order: 1; }

    /* Reserve space so the fixed sheet never covers form content. */
    .cult-fit-page main { padding-bottom: 260px; }

    .fit-results-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        z-index: 20;
        background: var(--color-bg);
        border-top: var(--border-thin);
        box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
        max-height: 38vh;
        display: flex;
        flex-direction: column;
        transition: max-height 0.25s ease;
        padding: 0 var(--space-3) var(--space-2);
        margin: 0;
    }
    .fit-results-panel[data-expanded="true"] {
        max-height: 80vh;
    }

    .fit-results-toggle {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        background: transparent;
        border: 0;
        padding: 6px 0 4px;
        cursor: pointer;
        font-size: 0.78rem;
        color: var(--color-text-muted, #6b6356);
        width: 100%;
    }
    .fit-results-toggle__grip {
        display: block;
        width: 36px;
        height: 4px;
        border-radius: 2px;
        background: var(--color-border-strong, #999);
    }

    .fit-results-heading {
        margin: 0 0 var(--space-2);
        padding-top: 0;
        font-size: var(--text-base);
    }
    .fit-results-scroll {
        flex: 1 1 auto;
        overflow-y: auto;
        overflow-x: hidden;
        padding-right: 0;
        min-height: 0;
    }

    /* Tight result row — bar wraps below title, never overflows. */
    .fit-result {
        display: grid;
        grid-template-columns: 1.25rem 28px minmax(0, 1fr);
        grid-template-areas:
            "rank logo title"
            "rank logo bar";
        column-gap: 0.5rem;
        row-gap: 0.2rem;
        padding: 0.35rem 0;
    }
    .fit-result-title { grid-area: title; }
    .fit-result-bar  { grid-area: bar; }

    /* Bigger tap targets on form controls. */
    #fit-form .fit-radio {
        padding: 0.4rem 0.55rem;
        font-size: 0.95rem;
        min-height: 32px;
    }
    .fit-row-controls select {
        max-width: 100%;
        width: 100%;
        padding: 0.5rem 0.6rem;
        font-size: 1rem;
    }

    .cult-fit-page main,
    .cult-fit-page {
        overflow-x: hidden;
    }
}
