/* KSO Market Indicators 1.2.0
 * Final header composition:
 *   Row 1: centered tagline
 *   Row 2: original KSO logo at left + Market Indicators at right
 * Mobile keeps Cocoon's centered logo, then full-width indicators.
 */

#header-in {
    position: relative !important;
    box-sizing: border-box !important;
}

/* =========================
   DESKTOP — FINAL LAYOUT
   ========================= */
@media screen and (min-width: 1101px) {

    /* Reserve a clean two-row header: tagline / logo + indicators. */
    #header-in {
        min-height: 205px !important;
        position: relative !important;
    }

    /* Row 1: keep the existing Cocoon tagline centered and untouched. */
    #header-in > .tagline {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        text-align: center !important;
        z-index: 2 !important;
    }

    /* Row 2 — left: restore the original horizontal KSO logo at its native
       LP size (500px wide, proportional height). Cocoon's logo-width rules are explicitly
       neutralized here so the image cannot collapse to a small percentage. */
    #header-in > .logo.logo-header.logo-image {
        position: absolute !important;
        left: 0 !important;
        top: 58px !important;
        display: block !important;
        flex: none !important;
        flex-basis: 500px !important;
        width: 500px !important;
        min-width: 500px !important;
        max-width: 500px !important;
        height: 103px !important;
        min-height: 103px !important;
        max-height: 103px !important;
        margin: 0 !important;
        padding: 0 !important;
        text-align: left !important;
        transform: none !important;
        zoom: 1 !important;
        z-index: 5 !important;
        box-sizing: border-box !important;
    }

    #header-in > .logo.logo-header.logo-image > a.site-name,
    #header-in > .logo.logo-header.logo-image .site-name-text {
        display: block !important;
        position: relative !important;
        width: 500px !important;
        min-width: 500px !important;
        max-width: 500px !important;
        height: 103px !important;
        min-height: 103px !important;
        max-height: 103px !important;
        margin: 0 !important;
        padding: 0 !important;
        transform: none !important;
    }

    /* Explicitly restore the normal horizontal logo used by the LP. */
    #header-in > .logo.logo-header.logo-image img.site-logo-image {
        display: block !important;
        position: static !important;
        width: 500px !important;
        min-width: 500px !important;
        max-width: 500px !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        transform: none !important;
        zoom: 1 !important;
        object-fit: contain !important;
        object-position: left center !important;
        aspect-ratio: auto !important;
    }

    /* The sticky/fixed variant must not replace the normal LP logo. */
    #header-in > .logo.logo-header.logo-image img.site-fixed-logo-image {
        display: none !important;
    }

    /*
     * Row 2 — right: indicator panel.
     * 536px = 500px logo + 36px visual gap.
     * The panel occupies only the remaining header space.
     */
    #header-in > .kso-market-indicators {
        position: absolute !important;
        left: 536px !important;
        right: 0 !important;
        top: 48px !important;
        width: calc(100% - 536px) !important;
        max-width: calc(100% - 536px) !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 11px 14px 9px !important;
        box-sizing: border-box !important;
        border: 1px solid rgba(0,0,0,.16) !important;
        border-radius: 5px !important;
        background: rgba(255,255,255,.97) !important;
        z-index: 6 !important;
        transform: none !important;
    }

    .kso-mi-title {
        margin: 0 0 7px;
        font-size: 11px;
        line-height: 1.1;
        font-weight: 700;
        letter-spacing: .09em;
        white-space: nowrap;
    }

    .kso-mi-grid {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 0;
        align-items: stretch;
    }

    .kso-mi-card {
        min-width: 0;
        line-height: 1.15;
        padding: 0 10px;
        border-left: 1px solid rgba(0,0,0,.18);
    }

    .kso-mi-card:first-child {
        border-left: 0;
        padding-left: 0;
    }

    .kso-mi-card:nth-child(n+6) {
        margin-top: 8px;
        border-left: 0;
    }

    .kso-mi-label {
        display: flex;
        align-items: baseline;
        gap: 3px;
        min-width: 0;
        font-size: 9px;
        font-weight: 700;
        letter-spacing: .02em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .kso-mi-label-name {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .kso-mi-source {
        flex: 0 0 auto;
        color: inherit;
        font-size: .82em;
        font-weight: 600;
        letter-spacing: 0;
        text-decoration: underline;
        text-underline-offset: 2px;
        opacity: .68;
    }

    .kso-mi-source:hover,
    .kso-mi-source:focus {
        opacity: 1;
    }

    .kso-mi-value {
        margin-top: 3px;
        font-size: clamp(12px, 1vw, 16px);
        font-weight: 700;
        white-space: nowrap;
    }

    .kso-mi-change {
        min-height: 10px;
        margin-top: 1px;
        font-size: 8px;
        white-space: nowrap;
    }

    .kso-mi-change.is-up::before { content: "↑ "; }
    .kso-mi-change.is-down::before { content: "↓ "; }

    .kso-mi-updated {
        margin-top: 7px;
        font-size: 8px;
        line-height: 1.1;
        opacity: .65;
        white-space: nowrap;
    }
}

/* =========================
   TABLET
   ========================= */
@media screen and (min-width: 769px) and (max-width: 1100px) {
    #header-in {
        min-height: 175px !important;
        position: relative !important;
    }

    #header-in > .tagline {
        position: relative !important;
        width: 100% !important;
        margin: 0 !important;
        text-align: center !important;
    }

    #header-in > .logo.logo-header.logo-image {
        position: absolute !important;
        left: 0 !important;
        top: 52px !important;
        width: 48% !important;
        max-width: 500px !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        text-align: left !important;
        z-index: 5 !important;
    }

    #header-in > .logo.logo-header.logo-image img.site-logo-image {
        display: block !important;
        width: 100% !important;
        max-width: 500px !important;
        height: auto !important;
        object-fit: contain !important;
        object-position: left center !important;
    }

    #header-in > .logo.logo-header.logo-image img.site-fixed-logo-image {
        display: none !important;
    }

    #header-in > .kso-market-indicators {
        position: absolute !important;
        left: 51% !important;
        right: 0 !important;
        top: 44px !important;
        width: auto !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 9px 10px !important;
        border: 1px solid rgba(0,0,0,.16) !important;
        border-radius: 5px !important;
        background: rgba(255,255,255,.97) !important;
        z-index: 6 !important;
    }

    .kso-mi-grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0,1fr));
        gap: 6px;
    }
}

/* =========================
   MOBILE — preserve working layout
   ========================= */
@media screen and (max-width: 768px) {
    #header-in {
        position: relative !important;
        min-height: 0 !important;
    }

    /* Existing centered Cocoon logo. */
    #header-in > .logo.logo-header.logo-image {
        position: relative !important;
        left: auto !important;
        top: auto !important;
        width: auto !important;
        max-width: 100% !important;
        height: auto !important;
        margin-left: auto !important;
        margin-right: auto !important;
        padding: 0 !important;
        text-align: center !important;
    }

    #header-in > .logo.logo-header.logo-image img.site-logo-image {
        display: inline-block !important;
        width: auto !important;
        max-width: 100% !important;
        height: auto !important;
        object-fit: contain !important;
        object-position: center !important;
    }

    /* Compact mobile panel: keep the visual hierarchy
       Logo -> Indicators -> Navigation, without letting the panel
       become taller/larger than the menu area. */
    #header-in > .kso-market-indicators {
        position: relative !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        display: block !important;
        width: calc(100% - 16px) !important;
        max-width: calc(100% - 16px) !important;
        margin: 8px 8px 0 !important;
        padding: 6px 8px 5px !important;
        box-sizing: border-box !important;
        border: 1px solid rgba(0,0,0,.14) !important;
        border-radius: 4px !important;
        background: rgba(255,255,255,.97) !important;
        transform: none !important;
    }

    .kso-mi-title {
        margin: 0 0 4px !important;
        font-size: 10px !important;
        line-height: 1.05 !important;
        letter-spacing: .07em !important;
    }

    .kso-mi-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0,1fr));
        gap: 5px 9px;
    }

    .kso-mi-card {
        padding: 0 6px !important;
        line-height: 1.05 !important;
    }

    .kso-mi-card:first-child {
        padding-left: 0 !important;
    }

    .kso-mi-label {
        gap: 2px !important;
        font-size: 8px !important;
    }

    .kso-mi-source {
        font-size: .8em !important;
    }

    .kso-mi-value {
        margin-top: 2px !important;
        font-size: 11px !important;
    }

    .kso-mi-change {
        min-height: 6px !important;
        margin-top: 0 !important;
        font-size: 7px !important;
    }

    .kso-mi-updated {
        margin-top: 5px !important;
        font-size: 7px !important;
        line-height: 1 !important;
    }
}

/* =========================
   PHASE 6-B DATA LABELS — 1.0.10
   Titles are server-rendered and therefore remain visible while data loads.
   No header positioning/dimensions are changed.
   ========================= */
.kso-mi-secondary {
    min-height: 1em;
    margin-top: 2px;
    font-size: 8px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: .72;
}

@media screen and (max-width: 768px) {
    .kso-mi-secondary {
        min-height: 1em;
        margin-top: 1px;
        font-size: 7px;
        line-height: 1;
    }
}
