/* WordyKid streak POC - controlled visual polish of the existing home header.
   Loaded AFTER streak-nav-layout.css; no navigation or account logic changes.
   Player identity, currency balances and language remain live product controls. */

#homeScreen:not([hidden]) .home-dashboard-header {
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    align-items: center;
    justify-items: stretch;
}

#homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-brand {
    box-sizing: border-box;
    min-width: 0;
    padding: 0;
    overflow: visible;
}

#homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-logo-img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    transform: none;
}

/* Exactly three active items: coins, diamonds and language.
   The level control is intentionally hidden by the existing product CSS;
   the streak control already lives in the fixed navigation. */
#homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-metrics {
    box-sizing: border-box;
    min-width: 0;
    width: min(100%, 455px);
    max-width: 100%;
    display: grid;
    grid-template-columns: max-content max-content minmax(0, 1fr);
    align-items: center;
    justify-content: stretch;
    justify-items: stretch;
    gap: 8px;
    overflow: visible;
}

#homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-coins,
#homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-diamonds {
    box-sizing: border-box;
    min-width: 0;
    min-height: 43px;
    padding: 5px 9px;
    gap: 5px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, .68);
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(255,255,255,.84), rgba(242,230,255,.8));
    box-shadow: 0 6px 18px rgba(61,25,117,.12), inset 0 1px 0 rgba(255,255,255,.9);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
#homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-coins span:not(.score-icon),
#homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-diamonds span:not(.score-icon) {
    min-width: 10px;
    font-size: clamp(13px, 1.15vw, 16px);
    line-height: 1;
    color: #35165d;
    font-weight: 900;
    text-shadow: 0 1px 0 #fff;
}
#homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-coins .score-icon,
#homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-diamonds .score-icon {
    flex: 0 0 26px;
    width: 26px;
    height: 26px;
}
#homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-lang {
    box-sizing: border-box;
    min-width: 0;
    min-height: 48px;
    width: 100%;
    padding: 5px 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border-radius: 999px;
    color: #fff;
    box-shadow: 0 7px 15px rgba(47,57,177,.22), inset 0 1px 0 rgba(255,255,255,.55);
}
#homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-lang .home-lang-icon {
    box-sizing: border-box;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
#homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-lang-label {
    display: block;
    min-width: 0;
    width: auto;
    max-width: 100%;
    font-size: clamp(13px, 1vw, 15px);
    line-height: 1.12;
    font-weight: 900;
    white-space: normal;
    overflow-wrap: normal;
    text-align: center;
    text-wrap: balance;
}

/* Use the generated fantasy gear as a real, optimized transparent WebP asset. */
#homeScreen:not([hidden]) .home-dashboard-header .wk-streak-settings-launch {
    position: relative;
    box-sizing: border-box;
    flex: 0 0 57px;
    width: 57px;
    height: 57px;
    min-width: 57px;
    min-height: 57px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: url("../img/streak/settings-fantasy.webp") center / contain no-repeat;
    box-shadow: none;
    cursor: pointer;
    filter: drop-shadow(0 4px 8px rgba(96,45,150,.28));
    transition: transform 160ms ease, filter 160ms ease;
    -webkit-tap-highlight-color: transparent;
}
#homeScreen:not([hidden]) .home-dashboard-header .wk-streak-settings-launch svg {
    display: none;
}
#homeScreen:not([hidden]) .home-dashboard-header .wk-streak-settings-launch:hover {
    transform: translateY(-2px) scale(1.05);
    filter: drop-shadow(0 6px 11px rgba(96,45,150,.35));
}
#homeScreen:not([hidden]) .home-dashboard-header .wk-streak-settings-launch[aria-pressed="true"] {
    background: url("../img/streak/settings-fantasy.webp") center / contain no-repeat;
    box-shadow: 0 0 0 3px rgba(255,201,80,.95);
}
#homeScreen:not([hidden]) .home-dashboard-header .wk-streak-settings-launch:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
    box-shadow: 0 0 0 6px #7032c6;
}
#homeScreen:not([hidden]) .home-dashboard-header .wk-streak-profile-slot {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    min-width: 0;
    max-width: 100%;
}
#homeScreen:not([hidden]) .home-dashboard-header .wk-streak-profile-slot > .home-dashboard-profile {
    box-sizing: border-box;
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    min-height: 59px;
    padding: 5px 12px 5px 6px;
    margin: 0;
    gap: 8px;
}
#homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-profile .player-avatar {
    box-sizing: border-box;
    width: 53px;
    height: 53px;
    flex: 0 0 53px;
}
#homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-profile .player-name {
    font-size: clamp(14px, 1.3vw, 17px);
    line-height: 1.13;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (min-width: 1181px) {
    #homeScreen:not([hidden]) .home-dashboard-header {
        width: min(100%, 1160px);
        grid-template-columns: minmax(190px, .80fr) minmax(380px, 1.25fr) minmax(265px, 1fr);
        grid-template-areas: "brand metrics profile";
        gap: clamp(14px, 2vw, 24px);
        margin: 0 auto 16px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-logo-img {
        width: min(100%, 238px);
        max-height: 105px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .wk-streak-profile-slot {
        justify-self: end;
        width: min(100%, 350px);
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-metrics {
        justify-self: center;
    }
}

/* Tablets and smaller desktops need two deliberate rows, not three squeezed columns. */
@media (min-width: 641px) and (max-width: 1180px) {
    #homeScreen:not([hidden]) .home-dashboard-header {
        width: min(100%, 910px);
        grid-template-columns: minmax(190px, 1fr) minmax(250px, 1fr);
        grid-template-areas: "brand profile" "metrics metrics";
        column-gap: 20px;
        row-gap: 5px;
        margin: 0 auto 18px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-logo-img {
        width: min(100%, 230px);
        max-height: 92px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .wk-streak-profile-slot {
        justify-self: end;
        width: min(100%, 335px);
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-metrics {
        justify-self: center;
        width: min(100%, 455px);
    }
}

/* One tidy header composition on phones: logo, child + gear, then one row
   of balances and a legible language selector. No isolated tiny button. */
@media (max-width: 640px) {
    #homeScreen:not([hidden]) .home-dashboard-header {
        width: min(100%, 390px);
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "brand" "profile" "metrics";
        justify-items: center;
        align-items: center;
        gap: 9px;
        margin: 0 auto 15px;
        min-height: 0;
        padding: 0 4px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-brand {
        width: 100%;
        min-height: 90px;
        justify-content: center;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-logo-img {
        width: min(72vw, 252px);
        max-height: 108px;
        object-position: center;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .wk-streak-profile-slot {
        justify-self: center;
        width: min(100%, 344px);
        gap: 8px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .wk-streak-profile-slot > .home-dashboard-profile {
        min-height: 60px;
        padding: 4px 9px 4px 5px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-profile .player-avatar {
        width: 49px;
        height: 49px;
        flex-basis: 49px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-profile .player-name {
        font-size: 15px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .wk-streak-settings-launch {
        flex-basis: 55px;
        min-width: 55px;
        min-height: 55px;
        width: 55px;
        height: 55px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-metrics {
        justify-self: center;
        width: min(100%, 344px);
        max-width: 100%;
        grid-template-columns: max-content max-content minmax(0, 1fr);
        gap: 6px;
        padding: 0;
        margin: 0;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-coins,
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-diamonds {
        min-height: 43px;
        padding: 3px 6px;
        gap: 3px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-coins .score-icon,
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-diamonds .score-icon {
        width: 24px;
        height: 24px;
        flex-basis: 24px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-coins span:not(.score-icon),
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-diamonds span:not(.score-icon) {
        font-size: 13px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-lang {
        min-height: 48px;
        padding: 5px 8px;
        gap: 5px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-lang .home-lang-icon {
        width: 27px;
        height: 27px;
        flex-basis: 27px;
        font-size: 17px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-lang-label {
        font-size: 13px;
        line-height: 1.12;
    }
}

@media (max-width: 340px) {
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-metrics {
        width: 100%;
        grid-template-columns: max-content max-content minmax(0, 1fr);
        gap: 4px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-coins,
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-diamonds {
        padding-inline: 4px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-lang {
        padding-inline: 4px;
        gap: 3px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-pill-lang .home-lang-icon {
        flex-basis: 24px;
        width: 24px;
        height: 24px;
    }
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-lang-label {
        font-size: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #homeScreen:not([hidden]) .home-dashboard-header .wk-streak-settings-launch {
        transition: none;
    }
}

/* WK_HEADER_PRODUCTION_LAYOUT_V3 */

/* Position the gear relative to the header, not the profile. */
#homeScreen:not([hidden]) .home-dashboard-header {
    position: relative;
}

#homeScreen:not([hidden]) .home-dashboard-header .wk-streak-profile-slot {
    position: static;
    z-index: auto;
}

#homeScreen:not([hidden]) .home-dashboard-header .wk-streak-settings-launch {
    position: absolute;
    top: 6px;
    right: max(12px, env(safe-area-inset-right));
    left: auto;
    z-index: 10;
    flex: 0 0 55px;
    width: 55px;
    height: 55px;
    min-width: 55px;
    min-height: 55px;
    margin: 0;
}

/* Preserve the desktop grid and enlarge only the logo. */
@media (min-width: 1181px) {
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-logo-img {
        max-height: 126px;
        transform: scale(1.6);
        transform-origin: center center;
        pointer-events: none;
    }
}

@media (min-width: 641px) and (max-width: 1180px) {
    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-logo-img {
        max-height: 118px;
        transform: scale(1.2);
        transform-origin: center center;
        pointer-events: none;
    }
}

/* Match the production mobile logo geometry. */
@media (max-width: 640px) {
    #homeScreen:not([hidden]) .home-dashboard-header {
        padding: 0 4px;
        overflow: visible;
    }

    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-brand {
        min-height: 118px;
        height: 118px;
        overflow: visible;
        align-items: center;
        justify-content: center;
    }

    #homeScreen:not([hidden]) .home-dashboard-header .home-dashboard-logo-img {
        width: min(88vw, 340px);
        max-width: 100%;
        max-height: 118px;
        height: auto;
        object-fit: contain;
        transform: scale(2);
        transform-origin: center center;
        pointer-events: none;
    }

    #homeScreen:not([hidden]) .home-dashboard-header .wk-streak-profile-slot {
        position: static;
        z-index: auto;
        width: min(100%, calc(100vw - 28px), 344px);
    }
}

/* WK_HOME_CARD_HORIZONTAL_CLIP_V1 */
/* Keep oversized artwork from creating horizontal scrolling on Home. */
#homeScreen:not([hidden]) > .card {
    overflow-x: clip;
}
/* WK_DESKTOP_SETTINGS_INLINE_V1 */
/* Keep the settings gear beside the profile on wide desktops only. */
@media (min-width: 1181px) {
    #homeScreen:not([hidden]) .home-dashboard-header .wk-streak-settings-launch {
        position: relative;
        top: auto;
        right: auto;
        bottom: auto;
        left: auto;
    }
}
