/* ==========================================================================
   Layout: container, header, navigation, footer
   ========================================================================== */

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 var(--space-6);
}

.container-sm {
    max-width: var(--container-sm);
}

.section {
    padding: var(--space-24) 0;
}

.section-tight {
    padding: var(--space-16) 0;
}

.section-alt {
    background: var(--gray-50);
}

.section-dark {
    background: var(--navy);
    color: var(--gray-200);
}

.section-dark h2,
.section-dark h3 {
    color: var(--white);
}

.section-header {
    max-width: 720px;
    margin: 0 auto var(--space-12);
    text-align: center;
}

.section-header p {
    color: var(--gray-500);
    font-size: var(--text-lg);
    margin-bottom: 0;
}

/* ==========================================================================
   Top bar
   ========================================================================== */
.top-bar {
    background: var(--navy-deep);
    color: var(--gray-300);
    font-size: var(--text-xs);
}

.top-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: 40px;
    flex-wrap: wrap;
}

.top-bar a {
    color: var(--gray-200);
    font-weight: 500;
}

.top-bar a:hover {
    color: var(--amber);
}

.top-bar-credentials {
    display: flex;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.top-bar-contact {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.top-bar .icon {
    width: 14px;
    height: 14px;
    display: inline-block;
    vertical-align: -2px;
    margin-right: var(--space-1);
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-6);
    min-height: 76px;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--navy);
    /* Flex items default to min-width:auto and refuse to shrink below their
       content, which pushed the header past the viewport on small phones.
       Letting the logo shrink makes it the element that absorbs the squeeze. */
    min-width: 0;
}

.logo-text {
    min-width: 0;
    overflow: hidden;
}

.logo-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logo-mark {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
}

.logo-name {
    display: block;
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

.logo-tagline {
    display: block;
    font-size: 0.6875rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-top: 2px;
    /* Taglines are a full sentence; wrapping one would push the header to
       two lines, so it is clipped here and hidden entirely below 1280px. */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 34ch;
}

/* ==========================================================================
   Primary navigation
   ========================================================================== */
.main-navigation ul {
    display: flex;
    align-items: center;
    gap: var(--space-6);
    list-style: none;
    margin: 0;
    padding: 0;
}

.main-navigation a {
    display: block;
    padding: var(--space-2) 0;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--navy);
    border-bottom: 2px solid transparent;
    /* "For Shippers" / "For Carriers" must stay on one line. */
    white-space: nowrap;
}

.main-navigation a:hover,
.main-navigation .current-menu-item > a {
    color: var(--orange);
    border-bottom-color: var(--orange);
}

.main-navigation .sub-menu {
    display: none;
    position: absolute;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-2);
    min-width: 220px;
    flex-direction: column;
    gap: 0;
}

.main-navigation li:hover > .sub-menu,
.main-navigation li:focus-within > .sub-menu {
    display: flex;
}

.main-navigation .sub-menu a {
    padding: var(--space-2) var(--space-3);
    border-bottom: 0;
    border-radius: var(--radius);
}

.main-navigation .sub-menu a:hover {
    background: var(--gray-50);
}

.main-navigation li {
    position: relative;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    /* The CTA and menu button keep their size; the logo shrinks instead. */
    flex-shrink: 0;
}

/* The header CTA carries a short label on phones so the company name keeps
   enough room to render without an ellipsis. */
.header-cta-short {
    display: none;
}

.mobile-menu-toggle {
    display: none;
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
}

.mobile-menu-toggle .bar {
    display: block;
    width: 20px;
    height: 2px;
    margin: 4px auto;
    background: var(--navy);
    transition: transform var(--transition), opacity var(--transition);
}

.mobile-menu-toggle[aria-expanded="true"] .bar:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.mobile-menu-toggle[aria-expanded="true"] .bar:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle[aria-expanded="true"] .bar:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
    background: var(--navy-deep);
    color: var(--gray-300);
    padding-top: var(--space-16);
    font-size: var(--text-sm);
}

.site-footer h4 {
    color: var(--white);
    font-size: var(--text-base);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: var(--space-4);
}

.site-footer a {
    color: var(--gray-300);
}

.site-footer a:hover {
    color: var(--amber);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr 1.2fr;
    gap: var(--space-8);
    padding-bottom: var(--space-12);
}

.footer-grid ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.footer-grid li {
    margin-bottom: var(--space-2);
}

.footer-brand .logo-name {
    color: var(--white);
}

.footer-brand p {
    color: var(--gray-500);
    margin-top: var(--space-4);
}

.footer-contact-item {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
    align-items: flex-start;
}

.footer-contact-item .icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 3px;
    color: var(--orange);
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: var(--space-6) 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    font-size: var(--text-xs);
    color: var(--gray-500);
}

.footer-bottom ul {
    display: flex;
    gap: var(--space-4);
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
/* The header runs out of room for the tagline well before the mobile
   breakpoint, once the nav, phone and CTA are all present. */
@media (max-width: 1280px) {
    .site-header .logo-tagline {
        display: none;
    }
}

@media (max-width: 1024px) {
    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 900px) {
    .mobile-menu-toggle {
        display: block;
    }

    .main-navigation {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--white);
        border-bottom: 1px solid var(--gray-200);
        box-shadow: var(--shadow);
        padding: var(--space-4) var(--space-6);
    }

    .main-navigation.is-open {
        display: block;
    }

    .main-navigation ul {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .main-navigation li {
        border-bottom: 1px solid var(--gray-100);
    }

    .main-navigation a {
        padding: var(--space-3) 0;
    }

    .main-navigation .sub-menu {
        display: flex;
        position: static;
        border: 0;
        box-shadow: none;
        padding-left: var(--space-4);
    }

    .header-actions .btn-outline {
        display: none;
    }

    .top-bar-credentials {
        display: none;
    }
}

/* Keep the utility bar to a single line on phones: the dispatch number is the
   only item worth the space, and the email is repeated in the footer. */
@media (max-width: 640px) {
    .top-bar-contact a[href^="mailto:"] {
        display: none;
    }

    .top-bar-inner {
        justify-content: center;
        min-height: 34px;
    }
}

@media (max-width: 640px) {
    .section {
        padding: var(--space-16) 0;
    }

    .container {
        padding: 0 var(--space-4);
    }

    /* Reclaim header width so the logo has room without truncating. */
    .header-container {
        gap: var(--space-3);
        min-height: 64px;
    }

    /* Sized so a typical company name clears the CTA and menu button without
       hitting the ellipsis. */
    .site-header .logo-name {
        font-size: 1.1rem;
    }

    .logo-mark {
        width: 36px;
        height: 36px;
    }

    .header-cta-long {
        display: none;
    }

    .header-cta-short {
        display: inline;
    }

    .header-actions {
        gap: var(--space-2);
    }

    .header-actions .btn {
        padding: var(--space-3) var(--space-4);
    }

    .footer-grid {
        grid-template-columns: 1fr;
    }
}
