/*
 * Compatibility fixes for styles inherited from the CoverNews parent theme.
 */

/*
 * CoverNews treats #primary as the left content column. Our custom homepage
 * uses #primary for the full-width main element, so the parent width/float
 * must be reset before the centered .sg-shell containers can work correctly.
 */
body.home main#primary.sg-main,
body.home #primary.sg-main,
.sg-main#primary {
    display: block !important;
    float: none !important;
    clear: both !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

body.home .sg-home {
    width: 100%;
    max-width: none;
    margin-right: auto;
    margin-left: auto;
}

body.home .sg-shell {
    float: none !important;
    clear: both;
    margin-right: auto !important;
    margin-left: auto !important;
}

/* SomGeek image branding. The source files contain a large dark canvas,
 * therefore they are displayed inside fixed, overflow-safe crop boxes. */
.sg-brand--picture {
    min-width: 0;
}

.sg-brand-picture {
    display: block;
    flex: 0 0 auto;
    overflow: hidden;
    background: #050709;
}

.sg-brand-picture img {
    width: 100%;
    height: 100%;
    max-width: none;
    display: block;
    object-fit: cover;
    object-position: 50% 47%;
    transform: scale(1.34);
    transform-origin: center;
}

.sg-brand-picture--header {
    width: 270px;
    height: 82px;
}

.sg-brand-picture--footer {
    width: 240px;
    height: 72px;
}

.sg-community-brand__picture {
    width: 58px;
    height: 58px;
    display: block;
    flex: 0 0 auto;
    overflow: hidden;
    background: #050709;
}

.sg-community-brand__picture img {
    width: 100%;
    height: 100%;
    max-width: none;
    display: block;
    object-fit: cover;
    object-position: center;
    transform: scale(1.04);
}

/* Main homepage story. Long real article titles must stay readable and
 * visually match the approved concept instead of filling the whole image. */
.sg-hero-main .sg-media-card__overlay {
    background:
        linear-gradient(90deg, rgba(2, 4, 6, 0.9) 0%, rgba(2, 4, 6, 0.68) 48%, rgba(2, 4, 6, 0.12) 82%),
        linear-gradient(180deg, rgba(2, 4, 6, 0.02) 20%, rgba(2, 4, 6, 0.97) 100%);
}

.sg-hero-main .sg-media-card__content {
    max-width: 760px;
}

body.home .sg-hero-main h1 {
    max-width: 690px;
    margin-top: 12px;
    margin-bottom: 14px;
    color: #fff !important;
    font-family: "Bahnschrift Condensed", "Arial Narrow", "Roboto Condensed", Impact, sans-serif !important;
    font-size: clamp(2.05rem, 2.55vw, 2.85rem) !important;
    font-weight: 800 !important;
    line-height: 1.02 !important;
    letter-spacing: -0.015em !important;
    text-wrap: pretty;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
    text-shadow: 0 3px 18px rgba(0, 0, 0, 0.92);
}

body.home .sg-hero-main h1 a,
body.home .sg-hero-main h1 a:visited,
body.home .sg-hero-main h1 a:hover,
body.home .sg-hero-main h1 a:focus {
    display: block;
    color: #fff !important;
}

/* Keep the homepage sidebar visible while the article columns scroll. */
body.home .sg-sidebar {
    position: sticky;
    top: 24px;
    align-self: start;
    z-index: 5;
}

body.admin-bar.home .sg-sidebar {
    top: 56px;
}

/* Header dropdown for the editorial sections that do not fit in the main row. */
.sg-more-toggle {
    position: relative;
    min-height: 104px;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 20px;
    border: 0;
    background: transparent;
    color: #f2f3f4;
    font-family: "Arial Narrow", "Roboto Condensed", Impact, sans-serif;
    font-size: 1.08rem;
    font-weight: 800;
    letter-spacing: 0.015em;
    text-transform: uppercase;
    white-space: nowrap;
}

.sg-more-toggle::after {
    content: "";
    position: absolute;
    right: 20px;
    bottom: 0;
    left: 20px;
    height: 4px;
    background: var(--sg-gold);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 180ms ease;
}

.sg-menu-more:hover > .sg-more-toggle::after,
.sg-menu-more:focus-within > .sg-more-toggle::after,
.sg-menu-more.is-open > .sg-more-toggle::after {
    transform: scaleX(1);
}

.sg-more-toggle span {
    transition: transform 180ms ease;
}

.sg-menu-more.is-open > .sg-more-toggle span,
.sg-menu-more:hover > .sg-more-toggle span,
.sg-menu-more:focus-within > .sg-more-toggle span {
    transform: rotate(180deg);
}

.sg-nav .sub-menu {
    position: absolute;
    top: calc(100% - 1px);
    right: 0;
    z-index: 90;
    min-width: 310px;
    display: none;
    padding: 8px 0;
    margin: 0;
    background: #090d11;
    border: 1px solid var(--sg-border);
    border-top: 3px solid var(--sg-gold);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.42);
    list-style: none;
}

.sg-menu-more:hover > .sub-menu,
.sg-menu-more:focus-within > .sub-menu,
.sg-menu-more.is-open > .sub-menu {
    display: block;
}

.sg-nav .sub-menu > li {
    width: 100%;
}

.sg-nav .sub-menu > li > a {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 0 18px;
    color: #d8dce0;
    border-bottom: 1px solid var(--sg-border-soft);
    font-family: "Arial Narrow", "Roboto Condensed", Impact, sans-serif;
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
}

.sg-nav .sub-menu > li:last-child > a {
    border-bottom: 0;
}

.sg-nav .sub-menu > li > a::after {
    display: none;
}

.sg-nav .sub-menu > li > a:hover,
.sg-nav .sub-menu > li > a:focus {
    padding-left: 24px;
    background: rgba(226, 170, 22, 0.08);
    color: var(--sg-gold-bright);
}

@media (max-width: 1280px) {
    .sg-brand-picture--header {
        width: 220px;
        height: 72px;
    }

    body.home .sg-hero-main h1 {
        font-size: clamp(2rem, 2.8vw, 2.7rem) !important;
    }

    .sg-more-toggle {
        padding-inline: 12px;
        font-size: 0.95rem;
    }

    .sg-more-toggle::after {
        right: 12px;
        left: 12px;
    }
}

@media (max-width: 1024px) {
    .sg-brand-picture--header {
        width: 205px;
        height: 68px;
    }

    body.home .sg-hero-main h1 {
        max-width: 620px;
        font-size: clamp(1.95rem, 4.4vw, 2.55rem) !important;
    }

    body.home .sg-sidebar,
    body.admin-bar.home .sg-sidebar {
        position: static;
        top: auto;
    }

    .sg-more-toggle {
        width: 100%;
        min-height: 56px;
        justify-content: space-between;
        padding: 0 14px;
        border-bottom: 1px solid var(--sg-border);
        text-align: left;
    }

    .sg-more-toggle::after {
        top: 0;
        right: auto;
        bottom: 0;
        left: 0;
        width: 4px;
        height: 100%;
        transform: scaleY(0);
    }

    .sg-menu-more.is-open > .sg-more-toggle::after {
        transform: scaleY(1);
    }

    .sg-nav .sub-menu {
        position: static;
        min-width: 0;
        padding: 0;
        background: #080b0f;
        border: 0;
        border-bottom: 1px solid var(--sg-border);
        box-shadow: none;
    }

    .sg-menu-more:hover > .sub-menu,
    .sg-menu-more:focus-within > .sub-menu {
        display: none;
    }

    .sg-menu-more.is-open > .sub-menu {
        display: block;
    }

    .sg-nav .sub-menu > li > a {
        min-height: 50px;
        padding-left: 30px;
        border-bottom-color: #171d24;
        font-size: 0.88rem;
    }

    .sg-nav .sub-menu > li > a:hover,
    .sg-nav .sub-menu > li > a:focus {
        padding-left: 36px;
    }
}

@media (max-width: 760px) {
    .sg-brand-picture--header {
        width: 165px;
        height: 56px;
    }

    .sg-brand-picture--footer {
        width: 215px;
        height: 66px;
    }

    .sg-community-brand__picture {
        width: 50px;
        height: 50px;
    }

    body.home .sg-hero-main h1 {
        max-width: 100%;
        font-size: clamp(1.8rem, 8vw, 2.35rem) !important;
        line-height: 1.03 !important;
    }
}
