/* Site chrome: header, main, footer. Header/footer follow the Kolekt "Epr" design,
 * mapped onto this project's tokens (--c-*, --sp-*, --fs-*). Fully responsive: the nav
 * collapses into a hamburger dropdown on small screens (both public and signed-in). */

/* ============================ HEADER ============================ */
.page-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-4) var(--sp-6);
    background-color: #fff;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}

.page-header__left,
.page-header__right {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.page-header__brand {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    color: var(--c-navy);
    font-weight: 600;
}

.page-header__brand:hover {
    text-decoration: none;
}

/* Kolekt company logo (image). Height fixed to the header; width auto keeps the aspect ratio. */
.page-header__logo {
    display: block;
    flex: 0 0 auto;
    height: 2.25rem;
    width: auto;
}

/* Tagline next to the Kolekt logo — the client asks for it in the light brand blue. */
.page-header__brand-name {
    font-size: var(--fs-300);
    white-space: nowrap;
    color: var(--c-blue);
}

.page-header__brand-name strong {
    font-weight: 700;
}

/* Compact brand name (public header) — shown only on mobile, where the big title is hidden. */
.page-header__brand-name--compact {
    display: none;
}

/* --- Public header: centered title --- */
.page-header__center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.page-header--public .page-header__center {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    flex: none;
    width: max-content;
    max-width: min(90vw, calc(100vw - 16rem));
    pointer-events: none;
    z-index: 0;
}

.page-header--public .page-header__left,
.page-header--public .page-header__nav-wrapper {
    position: relative;
    z-index: 1;
}

/* The app name in the light brand blue (client request). It is the only place a logged-out
 * visitor on a wide screen reads it — the tagline next to the logo is a mobile/signed-in thing. */
.page-header__title--center {
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: clamp(1.05rem, 2.2vw, 1.85rem);
    color: var(--c-blue);
    margin: 0;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* --- Navigation --- */
.page-header__nav-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.page-header__nav {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.page-header__nav-link {
    font-family: inherit;
    font-size: var(--fs-300);
    font-weight: 500;
    color: var(--c-navy);
    text-decoration: none;
    padding: var(--sp-2) var(--sp-3);
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease;
}

.page-header__nav-link:hover {
    background: var(--c-yellow);
    color: var(--c-navy);
    text-decoration: none;
}

.page-header__nav-link--active {
    background: var(--c-green);
    color: var(--c-navy);
    font-weight: 700;
}

.page-header__nav-link--logout {
    color: var(--color-text-muted);
}

.page-header__nav-link--logout:hover {
    color: var(--c-navy);
}

.page-header__logout-form {
    margin: 0;
}

/* --- "Calculate" dropdown (header perspective picker) --- */
.nav-calc {
    position: relative;
}

.nav-calc__toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
}

.nav-calc__caret {
    width: 1rem;
    height: 1rem;
    transition: transform 0.2s ease;
}

.nav-calc__toggle[aria-expanded="true"] .nav-calc__caret {
    transform: rotate(180deg);
}

.nav-calc__menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1001;
    display: none;
    margin-top: var(--sp-2);
    min-width: 15rem;
    padding: var(--sp-2);
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.nav-calc__menu.is-open {
    display: block;
}

.nav-calc__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-sm);
    color: var(--c-navy);
    font-size: var(--fs-300);
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.nav-calc__item:hover {
    background: var(--c-green);
    color: var(--c-navy);
    text-decoration: none;
}

.nav-calc__item--soon {
    opacity: 0.55;
}

.nav-calc__badge {
    padding: 0.1rem 0.5rem;
    font-size: var(--fs-100);
    font-weight: 600;
    color: var(--c-navy);
    background: var(--c-yellow);
    border-radius: 999px;
    white-space: nowrap;
}

/* --- Profile toggle (signed-in, all sizes): opens the account dropdown --- */
.page-header__profile-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--c-navy);
    cursor: pointer;
    transition: background 0.2s ease;
}

.page-header__profile-toggle:hover {
    background: var(--c-yellow);
}

.page-header__profile-toggle svg {
    width: 1.7rem;
    height: 1.7rem;
}

/* Signed-in email shown at the top of the account dropdown. */
.page-header__nav-user {
    display: block;
    padding: var(--sp-2) var(--sp-3) var(--sp-3);
    border-bottom: 1px solid var(--color-border);
    font-size: var(--fs-100);
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Account dropdown (signed-in, all sizes): anchored under the profile toggle. */
.page-header__nav-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 1001;
    display: none;
    margin-top: var(--sp-2);
    min-width: 13rem;
    padding: var(--sp-3);
    background: #fff;
    border: 2px solid var(--c-blue);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.page-header__nav-dropdown.is-open {
    display: block;
}

.page-header__nav--dropdown {
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-2);
}

.page-header__nav--dropdown .page-header__nav-link {
    display: block;
    width: 100%;
    text-align: left;
}

.page-header__nav--dropdown .page-header__logout-form {
    width: 100%;
}

/* ============================ MAIN ============================ */
.site-main {
    flex: 1 0 auto;
    padding-block: var(--sp-6);
}

/* ============================ FOOTER ============================ */
.footer {
    background: transparent;
}

.footer__info {
    margin-top: var(--sp-5);
    padding-bottom: var(--sp-5);
    text-align: center;
}

.footer__text {
    margin: 0;
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: var(--fs-200);
    color: var(--c-navy);
}

/* ============== RESPONSIVE: app shell (tab bar + profile menu) ============== */
@media (max-width: 760px) {
    .page-header {
        padding: var(--sp-3) var(--sp-4);
    }

    /* The bottom tab bar replaces the inline nav (the profile toggle and its account
       dropdown are base rules — they show on every size). */
    .page-header__nav--bar {
        display: none;
    }

    /* Public: hide the big centered title, show the compact brand name next to the logo. */
    .page-header--public .page-header__center {
        display: none;
    }

    .page-header__brand-name--compact {
        display: inline;
    }
}

/* Very small phones: keep the app name visible — shrink it a notch and let it
   truncate instead of hiding it (there is room now that the hamburger is gone). */
@media (max-width: 400px) {
    .page-header__left,
    .page-header__brand {
        min-width: 0;
    }

    .page-header__brand-name {
        font-size: var(--fs-200);
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ==================== BOTTOM TAB BAR (mobile app shell) ==================== */
.tab-bar {
    display: none;
}

@media (max-width: 760px) {
    /* Keep page content and the footer clear of the fixed tab bar. */
    body {
        padding-bottom: calc(3.9rem + env(safe-area-inset-bottom));
    }

    .tab-bar {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 60; /* above content, below the edit-modal overlay (z-index 100) */
        display: flex;
        align-items: stretch;
        background: #fff;
        border-top: 1px solid var(--color-border);
        box-shadow: 0 -2px 12px rgba(11, 45, 68, 0.06);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .tab-bar__item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: 3.6rem;
        padding: var(--sp-2) 0 var(--sp-1);
        color: var(--color-text-muted);
        font-size: 0.7rem;
        font-weight: 500;
        text-decoration: none;
    }

    .tab-bar__item:hover {
        text-decoration: none;
    }

    .tab-bar__item svg {
        width: 1.5rem;
        height: 1.5rem;
    }

    .tab-bar__item--active {
        color: var(--c-green-dark);
        font-weight: 600;
    }
}
