/* The site header and footer of every public page: the marketing page
   (index.html), the Merchant Navy guide (merchant-navy.html) and the policy
   and company pages from the sitePage Cloud Function (/pricing, /terms, ...).
   One file so the three cannot drift apart: same logo, links, buttons, widths
   and breakpoints everywhere. The links themselves are listed once in
   functions/lib/siteChrome.js (functions/test/siteChrome.spec.js checks the
   three pages against it).

   Self-contained: no variables or resets from a page's own stylesheet.
   Signed-in states of the marketing page (guest-only, hide-navbar) stay in
   styles.css. */

.navbar,
.section-bar,
.footer {
    --chrome-primary: #0066cc;
    --chrome-primary-dark: #004d99;
    --chrome-primary-light: #e6f0ff;
    --chrome-navy: #1a365d;
    --chrome-text: #1a202c;
    --chrome-text-2: #4a5568;
    --chrome-line: #e2e8f0;
    --chrome-soft: #f7fafc;
    --chrome-width: 1200px;
    --chrome-gutter: 24px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
}

.navbar *,
.section-bar *,
.footer * {
    box-sizing: border-box;
}

/* Pages without their own offset for the fixed header (index.html pads its pages itself) */
body.has-site-header {
    padding-top: 70px;
}

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

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #ffffff;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    padding: 0;
}

/* The same grid as the page content below it (1200px wide, 24px gutters),
   so the logo, the headings and the footer share one left edge */
.nav-container {
    max-width: var(--chrome-width);
    margin: 0 auto;
    padding: 0 var(--chrome-gutter);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    height: 70px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--chrome-primary);
    text-decoration: none;
    white-space: nowrap;
    /* A comfortable tap target inside the 70px bar */
    min-height: 44px;
}

.nav-logo i {
    font-size: 1.5rem;
}

/* Groups links and buttons for the phone menu; invisible on wide screens */
.nav-collapse {
    display: contents;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav-link {
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--chrome-text-2);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: var(--chrome-primary);
}

/* The page you are on. Colour and an underline, not a heavier weight: the
   links keep exactly the same places on every page. */
.nav-link[aria-current="page"] {
    color: var(--chrome-primary-dark);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 8px;
}

.nav-buttons {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Login and Register look the same on every page, whatever .btn means there */
.nav-buttons .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 0;
    padding: 10px 20px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.6;
    border-radius: 8px;
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.nav-buttons .btn-outline {
    background: #ffffff;
    border-color: var(--chrome-line);
    color: var(--chrome-text);
}

.nav-buttons .btn-outline:hover {
    background: var(--chrome-soft);
    border-color: var(--chrome-primary);
    color: var(--chrome-primary);
}

.nav-buttons .btn-primary {
    background: var(--chrome-primary);
    border-color: var(--chrome-primary);
    color: #ffffff;
}

.nav-buttons .btn-primary:hover {
    background: var(--chrome-primary-dark);
    border-color: var(--chrome-primary-dark);
    transform: none;
}

.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin: 0 -10px 0 0;
    padding: 0;
    background: none;
    border: none;
    border-radius: 8px;
    font-size: 1.5rem;
    color: var(--chrome-text);
    cursor: pointer;
}

.nav-logo:focus-visible,
.nav-link:focus-visible,
.nav-buttons .btn:focus-visible,
.nav-toggle:focus-visible {
    outline: 3px solid var(--chrome-primary-dark);
    outline-offset: 2px;
    border-radius: 8px;
}

/* Phones and small tablets: the links and buttons move into one menu.
   The menu needs a script to open; until the script has started
   (.nav-ready) the bar shows the logo only and the footer carries the links. */
@media (max-width: 960px) {
    .navbar.nav-ready .nav-toggle {
        display: flex;
    }

    .nav-collapse {
        display: none;
    }

    .navbar.nav-ready .nav-collapse.active {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 70px;
        left: 0;
        right: 0;
        z-index: 999;
        max-height: calc(100vh - 70px);
        overflow-y: auto;
        background: #ffffff;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    }

    .nav-menu {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 12px 24px;
    }

    .nav-menu .nav-link {
        min-height: 44px;
        font-size: 1rem;
    }

    .nav-buttons {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 16px 24px 24px;
        border-top: 1px solid var(--chrome-line);
    }

    .nav-buttons .btn {
        width: 100%;
        padding: 14px 24px;
        font-size: 1rem;
    }
}

@media (max-width: 400px) {
    .navbar,
    .section-bar,
    .footer {
        --chrome-gutter: 16px;
    }

    .nav-logo {
        font-size: 1.125rem;
    }

    .nav-menu,
    .nav-buttons {
        padding-left: 16px;
        padding-right: 16px;
    }
}

/* ---------- Section bar ----------
   Links to the sections of a long page: the Merchant Navy guide, and the home
   page (the sections an admin can show or hide). It stays under the fixed
   header while the page scrolls; js/section-bar.js marks the section in view. */

.section-bar {
    position: sticky;
    top: 70px;
    z-index: 900;
    background: #ffffff;
    border-bottom: 1px solid var(--chrome-line);
}

.section-bar[hidden] {
    display: none;
}

.section-bar-inner {
    position: relative;
    max-width: var(--chrome-width);
    margin: 0 auto;
    padding: 0 var(--chrome-gutter);
}

/* The first link's text starts on the page grid, like the logo above it.
   When the links do not fit, the list scrolls sideways; js/section-bar.js
   then shows a fade and an arrow button at each cut-off edge. */
.section-bar ul {
    position: relative;
    list-style: none;
    margin: 0 -12px;
    padding: 0;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}

.section-bar ul::-webkit-scrollbar {
    display: none;
}

.section-bar-inner::before,
.section-bar-inner::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 64px;
    pointer-events: none;
    opacity: 0;
    z-index: 1;
}

.section-bar-inner::before {
    left: 0;
    background: linear-gradient(to right, #ffffff 40%, rgba(255, 255, 255, 0));
}

.section-bar-inner::after {
    right: 0;
    background: linear-gradient(to left, #ffffff 40%, rgba(255, 255, 255, 0));
}

.section-bar-inner.is-cut-start::before,
.section-bar-inner.is-cut-end::after {
    opacity: 1;
}

.section-bar-arrow {
    position: absolute;
    top: 50%;
    z-index: 2;
    width: 44px;
    height: 44px;
    margin-top: -22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--chrome-line);
    border-radius: 999px;
    background: #ffffff;
    color: var(--chrome-primary-dark);
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(26, 54, 93, 0.15);
}

.section-bar-arrow[hidden] {
    display: none;
}

.section-bar-arrow-left {
    left: 4px;
}

.section-bar-arrow-right {
    right: 4px;
}

.section-bar-arrow:hover {
    background: var(--chrome-primary-light);
}

.section-bar-arrow:focus-visible {
    outline: 3px solid var(--chrome-primary-dark);
    outline-offset: 2px;
}

.section-bar li {
    margin: 0;
    padding: 0;
}

.section-bar li[hidden] {
    display: none;
}

.section-bar a {
    display: block;
    min-width: 44px;
    padding: 12px 12px 9px;
    text-align: center;
    border-bottom: 3px solid transparent;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.6;
    color: var(--chrome-text-2);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.section-bar a:hover {
    color: var(--chrome-primary-dark);
}

.section-bar a[aria-current="true"] {
    color: var(--chrome-primary-dark);
    border-bottom-color: var(--chrome-primary);
}

.section-bar a:focus-visible {
    outline: 3px solid var(--chrome-primary-dark);
    outline-offset: -3px;
    border-radius: 8px;
}

/* Small phones: three short links still fit on one line at 360px */
@media (max-width: 400px) {
    .section-bar ul {
        margin: 0 -6px;
        gap: 2px;
    }

    /* 13px is the one size off the scale (12, 14, 16...): at 14px the third
       link is cut off on a 360px phone */
    .section-bar a {
        padding-left: 6px;
        padding-right: 6px;
        font-size: 13px;
    }
}

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

.footer {
    background: var(--chrome-navy);
    color: #ffffff;
    padding: 48px 0 24px;
    font-size: 14px;
    text-align: left;
}

.footer-inner {
    max-width: var(--chrome-width);
    margin: 0 auto;
    padding: 0 var(--chrome-gutter);
    display: grid;
    grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(150px, 1fr));
    gap: 32px;
}

.footer-brand {
    display: block;
    margin: 0;
}

.footer-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    color: #ffffff;
    text-decoration: none;
    min-height: 44px;
}

.footer-logo i {
    font-size: 1.5rem;
}

.footer-tagline {
    max-width: 320px;
    margin: 12px 0 0;
    padding: 0;
    font-size: 14px;
    color: #cbd5e1;
    opacity: 1;
}

.footer-group h2 {
    margin: 0 0 12px;
    padding: 0;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.6;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #cbd5e1;
}

.footer-group ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 4px;
}

.footer-group li {
    margin: 0;
    padding: 0;
}

.footer-group a,
.footer-contact a {
    color: #ffffff;
    text-decoration: none;
}

.footer-group a {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    font-size: 14px;
}

.footer-group a:hover,
.footer-contact a:hover {
    text-decoration: underline;
}

.footer-group a[aria-current="page"] {
    font-weight: 600;
    text-decoration: underline;
}

.footer-logo:focus-visible,
.footer-group a:focus-visible,
.footer-contact a:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
    border-radius: 4px;
}

/* As wide as the columns above it (the grid less its gutters) */
.footer-bottom {
    width: min(100% - 2 * var(--chrome-gutter), var(--chrome-width) - 2 * var(--chrome-gutter));
    margin: 32px auto 0;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 24px;
}

.footer-bottom p {
    margin: 0;
    padding: 0;
    font-size: 14px;
    color: #cbd5e1;
    opacity: 1;
}

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

    .footer-brand {
        grid-column: 1 / -1;
    }

    .footer-group a {
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .footer {
        padding: 40px 0 20px;
    }

    .footer-inner {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

@media print {
    .navbar,
    .section-bar,
    .footer {
        display: none;
    }

    body.has-site-header {
        padding-top: 0;
    }
}
