/* Global shell — header, profile menu, search panel strip, footer (Phase 1 mobile) */

/* ------------------------------------------------------------------ */
/* Header navigation                                                  */
/* ------------------------------------------------------------------ */

div.header_navigation_tools {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    padding: 10px 12px;
    gap: 12px;
    max-width: 100%;
    box-sizing: border-box;
}

.site_logo_link,
.site_logo_spacer {
    grid-column: 1;
    justify-self: start;
    min-width: 0;
}

.site_logo_link {
    display: flex;
    align-items: center;
}

.site_logo {
    display: block;
    height: 42px;
    width: auto;
    max-width: min(300px, 58vw);
    object-fit: contain;
}

.header_nav_actions {
    grid-column: 2;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    justify-self: end;
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.header_nav_spacer {
    display: block;
    width: 0;
    min-width: 0;
    height: 44px;
    pointer-events: none;
}

div#profile_container.profile_container {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
    padding-right: 0;
    margin-bottom: 0;
    position: relative;
}

.profile_auth_link {
    text-decoration: none;
}

.profile_frame,
button.profile_frame.profile_toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #7b6581;
    border-radius: 50%;
    background-color: #342c43;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
    cursor: pointer;
}

button.profile_frame.profile_toggle {
    appearance: none;
    -webkit-appearance: none;
}

.profile_frame:hover,
button.profile_frame.profile_toggle:hover {
    border-color: #FC851D;
}

.profile.site_header {
    width: 40px;
    height: 40px;
    object-fit: cover;
}

.profile.loggedin.site_header {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

/* ------------------------------------------------------------------ */
/* Profile menu                                                       */
/* ------------------------------------------------------------------ */

div#expanded_profile_container.profile_menu_panel {
    text-align: center;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    margin-bottom: 0;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 7px;
    background-color: var(--background-color);
    min-width: 200px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    font-family: Economica, sans-serif;
    z-index: 1001;
}

div#expanded_profile_container.profile_menu_panel[hidden] {
    display: none !important;
}

a.profile_menu_link {
    text-decoration: none;
}

.profile_menu_backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(12, 8, 18, 0.55);
    z-index: 1000;
    cursor: pointer;
}

.profile_menu_backdrop.is_visible {
    display: block;
}

/* ------------------------------------------------------------------ */
/* Search panel strip (search_view, topic hub, detail)                */
/* ------------------------------------------------------------------ */

div.search_panel,
div.detail_view_search_panel {
    min-height: auto;
    height: auto;
    padding: 12px 16px;
    gap: 12px;
    box-sizing: border-box;
}

div.search_field_container.search_view {
    width: 100%;
    max-width: 378px; /* was 504px; −25% */
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

input.field.search_bar.search_view {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
}

div.clip_art_buttons.container {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 2px;
}

div.clip_art_buttons.container::-webkit-scrollbar {
    height: 6px;
}

div.clip_art_buttons.container::-webkit-scrollbar-thumb {
    background: rgba(252, 133, 29, 0.45);
    border-radius: 999px;
}

div.detail_view_search_panel .search_field_container.search_view {
    max-width: 378px; /* was 504px; −25% */
    margin-left: auto;
    margin-right: auto;
}

/* ------------------------------------------------------------------ */
/* Footer                                                             */
/* ------------------------------------------------------------------ */

@media (max-width: 768px) {
    #footer {
        margin-top: 12vh;
    }

    .footer_container {
        margin-left: auto;
        margin-right: auto;
        max-width: 360px;
        width: 100%;
        grid-template-columns: 1fr;
        padding-bottom: 24px;
    }

    .footer_inner {
        display: flex;
        justify-content: center;
        align-items: flex-start;
        gap: 28px;
        margin-bottom: 10px;
    }

    .footer_inner .footer_links:first-child {
        justify-self: auto;
    }

    .footer_inner .footer_links:last-child {
        justify-self: auto;
    }

    .footer_bottom {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 4px;
        padding-bottom: 12px;
        text-align: center;
    }

    .footer_bottom .contact_links {
        order: 1;
        justify-self: center;
    }

    .footer_bottom h5 {
        order: 2;
        justify-self: center;
        margin: 0;
    }
}

/* ------------------------------------------------------------------ */
/* Narrow phones                                                      */
/* ------------------------------------------------------------------ */

@media (max-width: 640px) {
    div.header_navigation_tools {
        padding: 8px 10px;
        gap: 8px;
    }

    .site_logo {
        height: 34px;
        max-width: min(220px, 52vw);
    }

    .profile_frame,
    button.profile_frame.profile_toggle {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }

    .profile.site_header {
        width: 36px;
        height: 36px;
    }

    div#expanded_profile_container.profile_menu_panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        border-radius: 16px 16px 0 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        padding: 20px 16px calc(16px + env(safe-area-inset-bottom, 0px));
        max-height: 85vh;
        overflow-y: auto;
    }

    div#expanded_profile_frame {
        width: 120px;
        height: 120px;
        margin: 0 auto;
        padding-top: 0;
        padding-left: 0;
    }

    img#expanded_profile {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 50%;
    }

    h2#profile_monster_name {
        font-size: 26px;
    }

    div.search_panel,
    div.detail_view_search_panel {
        padding: 10px 12px;
    }

    div.search_view_topic_trail.search_view,
    div.search_panel nav.search_view_topic_trail {
        font-size: 1.25rem;
        gap: 0.25em 0.35em;
        min-width: 0;
        max-width: 100%;
        flex-wrap: wrap;
        align-self: stretch;
    }

    input.field.search_bar.search_view {
        font-size: 18px;
        height: 32px;
    }

    button.search_icon_button.search_view {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
    }

    img.search_icon.search_view {
        width: 22px;
    }

    .footer_links h3 {
        font-size: 26px;
    }

    .footer_links a {
        font-size: 18px;
    }
}
