/*
Theme Name: KUBHD Elementor
Description: Elementor Free layouts with the independent KUBHD Core engine.
Version: 1.0.1
Requires PHP: 8.0
*/

/* Shared page geometry. Keep the header aligned with the content on wide screens. */
body {
    margin: 0;
    background: #111827;
    color: #e2e8f0;
    font-family: system-ui, sans-serif;
}

.kubhd-layout {
    box-sizing: border-box;
    width: 100%;
    max-width: 1280px;
    margin-inline: auto;
    padding: 20px 16px;
}

.kubhd-layout .elementor-widget,
.kubhd-layout .elementor-widget-container,
.kubhd-layout .kubhd-block {
    min-width: 0;
}

/* Elementor containers keep their editable content; these are theme defaults. */
.elementor .kubhd-header.e-con {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    --flex-direction: row;
    --flex-wrap: wrap;
    --align-items: center;
    --justify-content: space-between;
    --gap: 18px;
    width: 100%;
    max-width: 1280px;
    margin-inline: auto;
    padding: 20px 28px;
    background: #1f2937;
    color: #e2e8f0;
}

.kubhd-header > .elementor-widget:has(.kubhd-brand) {
    width: 150px;
    flex: 0 0 150px;
}

.kubhd-header > .elementor-widget:has(.kubhd-block-menu) {
    width: auto;
    flex: 1 1 430px;
}

.kubhd-header > .elementor-widget:has(.kubhd-block-search) {
    width: auto;
    flex: 0 1 270px;
}

.elementor .kubhd-brand img {
    display: block;
    width: 150px;
    max-width: 100%;
    height: auto;
}

.kubhd-brand {
    font-size: 28px;
    font-weight: 700;
}

.kubhd-header a,
.kubhd-footer a {
    color: inherit;
}

.kubhd-header nav ul,
.kubhd-footer nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.kubhd-header nav a {
    display: inline-block;
    padding-block: 8px;
    line-height: 1.6;
    font-size: 14px;
}

.kubhd-header form[role="search"] {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.kubhd-header form[role="search"] label {
    min-width: 0;
    flex: 1;
}

.kubhd-header input[type="search"] {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #64748b;
    border-radius: 8px;
    background: #111827;
    color: #fff;
}

.kubhd-header button[type="submit"] {
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 8px;
    background: #2563eb;
    color: #fff;
    white-space: nowrap;
}

/* Headings need enough line height for Thai vowels and tone marks. */
.kubhd-layout h1 {
    font-size: clamp(24px, 2.4vw, 32px);
    font-weight: 700;
    line-height: 1.5;
    overflow-wrap: break-word;
}

.kubhd-layout h2 {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.5;
}

.kubhd-layout .kubhd-card-grid {
    width: 100%;
}

.kubhd-layout .sidebar {
    width: 100%;
    padding: 0;
}

.kubhd-layout .sidebar .widget {
    margin: 0 0 16px;
    padding: 14px;
    border-radius: 12px;
    background: #1f2937;
}

.kubhd-layout .sidebar .widget-title,
.kubhd-layout .sidebar h2 {
    margin: 0 0 12px;
    font-size: 18px;
    line-height: 1.6;
}

.kubhd-layout .sidebar li a {
    display: block;
    padding: 8px 10px;
    line-height: 1.6;
}

/* Footer text comes from the existing widget option, without rewriting it. */
.elementor .kubhd-footer.e-con {
    width: 100%;
    max-width: 1280px;
    margin-inline: auto;
    padding: 24px 28px;
    background: #1f2937;
    color: #e2e8f0;
}

.kubhd-footer p {
    line-height: 1.9;
}

.kubhd-layout .page-numbers {
    display: inline-block;
    margin: 3px;
    padding: 8px 12px;
    border-radius: 6px;
    background: #1f2937;
}

.kubhd-layout .page-numbers.current {
    background: #2563eb;
}

.kubhd-block a:focus-visible,
.kubhd-header input:focus-visible,
.kubhd-header button:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 3px;
}

.kubhd-menu-toggle {
    display: none;
}

@media (max-width: 767px) {
    .elementor .kubhd-header.e-con,
    .elementor .kubhd-footer.e-con {
        padding: 16px;
    }

    .kubhd-header > .elementor-widget:has(.kubhd-brand) {
        flex-basis: 100%;
    }

    .elementor .kubhd-brand img {
        width: 130px;
    }

    .kubhd-header > .elementor-widget:has(.kubhd-block-menu),
    .kubhd-header > .elementor-widget:has(.kubhd-block-search) {
        width: 100%;
        flex-basis: 100%;
    }

    .kubhd-layout {
        padding: 12px 4px;
    }

    /* Inline disclosure: search stays available while navigation is collapsed. */
    .elementor .kubhd-header.e-con {
        gap: 14px;
    }

    .kubhd-header .kubhd-brand {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
    }

    .elementor .kubhd-header .kubhd-brand img {
        width: 112px;
    }

    .kubhd-header .kubhd-menu-toggle:not([hidden]) {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        min-height: 46px;
        padding: 10px 14px;
        border: 1px solid #475569;
        border-radius: 12px;
        background: #111827;
        color: #f8fafc;
        font: 600 14px/1.5 system-ui, sans-serif;
        cursor: pointer;
    }

    .kubhd-menu-icon {
        position: relative;
        width: 18px;
        height: 12px;
        border-block: 2px solid currentColor;
    }

    .kubhd-menu-icon::after {
        content: "";
        position: absolute;
        inset: 4px 0 auto;
        border-top: 2px solid currentColor;
    }

    .kubhd-menu-open .kubhd-menu-icon {
        border: 0;
    }

    .kubhd-menu-open .kubhd-menu-icon::before,
    .kubhd-menu-open .kubhd-menu-icon::after {
        content: "";
        position: absolute;
        inset: 5px 0 auto;
        border-top: 2px solid currentColor;
        transform: rotate(45deg);
    }

    .kubhd-menu-open .kubhd-menu-icon::after {
        transform: rotate(-45deg);
    }

    .kubhd-header > .elementor-widget:has(.kubhd-block-search) {
        order: 2;
    }

    .kubhd-header > .elementor-widget:has(.kubhd-block-menu) {
        order: 3;
    }

    .kubhd-menu-ready:not(.kubhd-menu-open) > .elementor-widget:has(.kubhd-block-menu) {
        display: none;
    }

    .kubhd-header nav > ul {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        padding-top: 14px;
        border-top: 1px solid #334155;
    }

    .kubhd-header nav li {
        min-width: 0;
    }

    .kubhd-header nav a {
        display: flex;
        align-items: center;
        min-height: 48px;
        padding: 10px 12px;
        border: 1px solid #334155;
        border-radius: 10px;
        background: #172131;
        color: #e2e8f0;
        font-size: 14px;
        line-height: 1.6;
        overflow-wrap: anywhere;
    }

    .kubhd-header nav a:hover,
    .kubhd-header nav a[aria-current="page"] {
        border-color: #3b82f6;
        background: #1e3a5f;
        color: #fff;
    }

    .kubhd-header nav ul ul {
        display: grid;
        gap: 6px;
        margin-top: 6px;
    }
}
