/* The account shell: the side nav (_includes/header-account.html), the page frame
   every account page sits in, and the few pieces more than one account page draws
   (the page title row, the back link, the on/off switch and loading skeletons). The palette, radii and controls come from global.css
   :root, so the account pages and the public pages read the same values. */
:root {
    /* The shell: 1280px of content (the width Deals needs for its filter rail),
       a 184px nav and 64px between the nav and the page. Every account page shares
       the one width, so the nav and the page edges don't move between tabs. */
    --account-width: 1280px;
    --account-nav-width: 184px;
    --account-nav-gap: 64px;

    /* the page frame: side gutter, the space under the header and above the footer */
    --account-gutter: 32px;
    --account-page-top: 48px;
    --account-page-bottom: 80px;
}

/************ Side nav ************/

/* The layout includes the nav between the site header and <main>, so it cannot
   share a grid with the page. It is taken out of the flow instead: absolutely
   positioned with no top, it stays where the flow put it (right under the header)
   and lines up with the left edge of the centred frame; .accountPage leaves the
   nav's column empty on its left. The containing block is the viewport, so 100%
   here is the page width. */
#accountNav {
    position: absolute;
    left: calc(max(0px, (100% - var(--account-width) - 2 * var(--account-gutter)) / 2) + var(--account-gutter));
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: var(--account-nav-width);
    padding-top: var(--account-page-top);
}

.accountNavItem {
    display: flex;
    align-items: center;
    min-height: var(--control-height);
    padding: 0 12px;
    border-radius: var(--radius);
    color: var(--black);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color var(--transition), color var(--transition);
}

.accountNavItem:hover {
    background-color: var(--surface);
    color: var(--primary);
}

/* the page's own item, or its section's on the alert detail page */
.accountNavItem[aria-current] {
    background-color: var(--tint);
    color: var(--primary);
    font-weight: 700;
}

/* "wines" in "Saved wines", dropped on the phone tab row; pre keeps its leading
   space, which a flex item would otherwise drop */
.accountNavItemExtra {
    white-space: pre;
}

#accountNavDivider {
    height: 1px;
    margin: 12px;
    background-color: var(--hairline);
}

#accountNavLogOut {
    color: var(--muted);
}

/************ Page frame ************/

/* The root of every account page: centred at the shell width, with the nav's
   column and gap reserved on the left. The minimum height keeps the footer below
   the nav on a short page (an empty state, a not found message). */
.accountPage {
    box-sizing: border-box;
    max-width: calc(var(--account-width) + 2 * var(--account-gutter));
    min-height: 420px;
    margin: 0 auto;
    padding: var(--account-page-top) var(--account-gutter) var(--account-page-bottom) calc(var(--account-gutter) + var(--account-nav-width) + var(--account-nav-gap));
}

/* the title row: the H1 (with an optional count beside it) on the left and the
   page's one primary action on the right */
.accountPageHeader {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 24px;
}

.accountPageTitle {
    font-size: var(--font-size-h1);
    font-weight: 800;
    letter-spacing: var(--letter-spacing-title);
    line-height: 1.2;
}

.accountPageIntro {
    margin-top: 8px;
    color: var(--muted);
    font-size: var(--font-size-body);
    line-height: 1.5;
}

/* "< Alerts" above a sub page's title */
.accountPageBack {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: var(--control-height);
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.accountPageBack:hover {
    color: var(--primary);
}

.accountPageBackIcon {
    flex: none;
    width: 16px;
    height: 16px;
}

/************ Shared pieces ************/

/* The on/off switch for an alert: a real button with role="switch", the state in
   aria-checked, and a visible "Active" / "Paused" label beside the track. The
   button itself is the 44px target; the track is drawn inside it. */
.accountSwitch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: var(--control-height);
    min-height: var(--control-height);
    padding: 0;
    border: 0;
    background: none;
    color: var(--black);
    font-size: 14px;
    font-weight: 600;
}

.accountSwitchTrack {
    position: relative;
    display: inline-block;
    flex: none;
    width: 36px;
    height: 20px;
    border-radius: var(--radius-pill);
    background-color: var(--control-border);
    transition: background-color var(--transition);
}

.accountSwitch[aria-checked="true"] .accountSwitchTrack {
    background-color: var(--positive);
}

.accountSwitchTrackThumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: var(--radius-pill);
    background-color: #FFF;
    transition: left var(--transition);
}

.accountSwitch[aria-checked="true"] .accountSwitchTrackThumb {
    left: 18px;
}

.accountSwitch[aria-checked="false"] {
    color: var(--muted);
}

/* while the change saves */
.accountSwitch.loading {
    opacity: .6;
    pointer-events: none;
}

/* A grey placeholder bar for content that is still loading, so the page keeps
   its shape instead of a blocking dialog. Width comes from the page's own class. */
.accountSkeleton {
    display: block;
    height: 14px;
    border-radius: var(--radius-small);
    background-color: var(--track);
    animation: accountSkeletonPulse 1.4s ease-in-out infinite;
}

@keyframes accountSkeletonPulse {
    50% {
        opacity: .5;
    }
}

@media (prefers-reduced-motion: reduce) {
    .accountSkeleton {
        animation: none;
    }
}

/************ Phone ************/

@media (max-width: 800px) {
    :root {
        --account-gutter: 16px;
        --account-page-top: 28px;
        --account-page-bottom: 48px;
    }

    /* the nav becomes the tab row under the header: in the flow, one line, the
       current tab underlined; Log out lives in the header menu on a phone */
    #accountNav {
        position: static;
        flex-direction: row;
        gap: 24px;
        width: auto;
        height: 48px;
        padding: 0 var(--account-gutter);
        overflow-x: auto;
        border-bottom: 1px solid var(--hairline);
        scrollbar-width: none;
    }

    .accountNavItem {
        flex: none;
        min-height: 0;
        padding: 0;
        border-radius: 0;
    }

    .accountNavItem:hover {
        background-color: transparent;
    }

    .accountNavItem[aria-current] {
        background-color: transparent;
        box-shadow: inset 0 -2px 0 var(--primary);
    }

    .accountNavItemExtra,
    #accountNavDivider,
    #accountNavLogOut {
        display: none;
    }

    /* the page takes the full width under the tab row */
    .accountPage {
        min-height: 0;
        padding-left: var(--account-gutter);
    }

    .accountPageTitle {
        font-size: 28px;
    }

    .accountPageIntro {
        font-size: 15px;
    }
}
