/* ============================================================
   MEMBER SHELL — sidebar + topbar + content
   Pure CSS interactions (no JS): the drawer and the account menu
   are driven by a checkbox and <details>, so the layout can stay
   statically rendered while pages opt into interactivity.
   ============================================================ */

.shell {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--rsa-page-bg);
}

/* --- drawer state (checkbox lives at the top of the shell) --- */
.shell__drawer-state {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.shell__sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    height: 100vh;
    height: 100dvh;
    width: var(--rsa-sidebar-w);
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--rsa-purple-600) 0%, var(--rsa-purple-800) 100%);
    color: rgba(255, 255, 255, .78);
    z-index: 1000;
    /* The nav scrolls, not the sidebar: the glow and the water below are drawn bigger than the
       sidebar and move, and a scrolling box would count that as somewhere to scroll to. */
    overflow: hidden;
    transition: transform var(--rsa-base);
}
/* ---- The sidebar's sky (MemberLayout, MainLayout) ----
   The dashboard hero's look, moving: a pink glow and a gold one wandering slowly through the
   purple, and two bands of water rolling along the foot at different speeds. Real elements rather
   than pseudo ones, so each moves on its own and only by transform, which the browser hands to the
   compositor: nothing on the page is redrawn for it. Behind everything else in the sidebar, which
   is a stacking context of its own (position: fixed), so -1 still sits above its gradient. */
.shell__sky {
    position: absolute;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}
.shell__sky-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(48px);
    will-change: transform;
}
.shell__sky-glow--pink {
    top: -110px;
    right: -130px;
    width: 300px;
    height: 300px;
    background: color-mix(in srgb, var(--rsa-pink-500) 42%, transparent);
    animation: rsa-sky-pink 19s ease-in-out infinite alternate;
}
.shell__sky-glow--gold {
    bottom: 30px;
    left: -150px;
    width: 280px;
    height: 280px;
    /* A light wash of the club's own blue: yellow laid over purple went muddy brown however it was
       mixed. The name stays for the corner it lives in, where the old static yellow glow sat. */
    background: color-mix(in srgb, var(--rsa-purple-300) 40%, transparent);
    animation: rsa-sky-gold 24s ease-in-out infinite alternate;
}
@keyframes rsa-sky-pink {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    45%  { transform: translate3d(-80px, 110px, 0) scale(1.15); }
    100% { transform: translate3d(-20px, 220px, 0) scale(.92); }
}
@keyframes rsa-sky-gold {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    50%  { transform: translate3d(100px, -120px, 0) scale(1.12); }
    100% { transform: translate3d(40px, -230px, 0) scale(.95); }
}
/* Each band is one tile wider than the sidebar and slides by exactly one tile, so the loop has no seam. */
.shell__sky-water {
    position: absolute;
    bottom: -1px;
    left: calc(-1 * var(--tile));
    right: 0;
    height: var(--rise);
    background-repeat: repeat-x;
    background-position: left bottom;
    background-size: var(--tile) var(--rise);
    will-change: transform;
    animation: rsa-sky-water var(--speed) linear infinite;
}
.shell__sky-water--back {
    --tile: 320px;
    --rise: 58px;
    --speed: 23s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 28' preserveAspectRatio='none'%3E%3Cpath d='M0 14 Q15 4 30 14 T60 14 T90 14 T120 14 V28 H0 Z' fill='rgba(255,255,255,.06)'/%3E%3C/svg%3E");
}
.shell__sky-water--front {
    --tile: 220px;
    --rise: 34px;
    --speed: 12s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 28' preserveAspectRatio='none'%3E%3Cpath d='M0 14 Q15 4 30 14 T60 14 T90 14 T120 14 V28 H0 Z' fill='rgba(255,255,255,.11)'/%3E%3C/svg%3E");
}
@keyframes rsa-sky-water { to { transform: translate3d(var(--tile), 0, 0); } }

.shell__brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1.25rem 1.15rem 1.1rem;
    position: relative;
}
.shell__brand::after {
    content: '';
    position: absolute;
    left: 1.15rem;
    right: 1.15rem;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .16) 25%, rgba(255, 255, 255, .16) 75%, transparent);
}
/* A club's mark is whatever shape the club's designer drew. Height sets the optical weight;
   the width cap stops a wide wordmark from eating the club name beside it, and contain keeps
   a capped mark in proportion rather than squashing it. */
.shell__brand img {
    height: 38px;
    width: auto;
    max-width: 96px;
    object-fit: contain;
}
.shell__brand-text { min-width: 0; line-height: 1.15; }
/* Two lines, always. These were inline, so the name and the sub sat side by side unless the
   club's name happened to be long enough to wrap — which is how the first club's did, and the
   second club's did not. Blocks also give the sub's margin something to push against. */
.shell__brand-name {
    display: block;
    font-family: var(--rsa-font-display);
    font-weight: 700;
    font-size: .9375rem;
    color: #fff;
    letter-spacing: -.01em;
}
.shell__brand-sub {
    display: block;
    font-size: .6875rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .5);
    margin-top: .1rem;
}

.shell__nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1rem .75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.shell__nav-label {
    padding: 1rem .8rem .4rem;
    font-size: .625rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .35);
}
.shell__nav .nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .8rem;
    border-radius: 10px;
    font-size: .875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, .72);
    border-left: 3px solid transparent;
    transition: background var(--rsa-fast), color var(--rsa-fast), border-color var(--rsa-fast);
    position: relative;
}
.shell__nav .nav-link i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    transition: transform var(--rsa-fast);
}
.shell__nav .nav-link:hover {
    background: rgba(255, 255, 255, .09);
    color: #fff;
}
.shell__nav .nav-link:hover i { transform: translateX(1px) scale(1.06); }
.shell__nav .nav-link.active {
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-weight: 600;
    border-left-color: var(--rsa-yellow-500);
}
.shell__nav .nav-link.active i { color: var(--rsa-yellow-500); }

/* Dropdown group (admin): a <details> whose summary looks like a nav link. */
.shell__nav-group > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}
.shell__nav-group > summary::-webkit-details-marker { display: none; }
.shell__nav-group > summary.is-current { color: #fff; }
/* The caret turns with `rotate`, not `transform`, so the nav-link hover nudge (a transform)
   doesn't undo it. The open/close height animation is in App.razor (navGroupToggle); while a
   group is closing it keeps [open] until the animation ends, so .is-closing turns the caret back. */
.shell__nav-caret {
    margin-left: auto;
    font-size: .75rem !important;
    opacity: .6;
    transition: rotate .22s ease;
}
.shell__nav-group[open]:not(.is-closing) > summary .shell__nav-caret { rotate: 180deg; }
.shell__nav-sub {
    display: flex;
    flex-direction: column;
    gap: 2px;
    /* padding, not margin, top and bottom: the animated height includes padding */
    margin-left: 1.3rem;
    padding: 2px 0 4px .35rem;
    border-left: 1px solid rgba(255, 255, 255, .12);
}
@media (prefers-reduced-motion: reduce) {
    .shell__nav-caret { transition: none; }
}
.shell__nav-sub .nav-link { padding-top: .45rem; padding-bottom: .45rem; }

/* The badge's shape. On its own it is a neutral count; the modifiers below give it a meaning. */
.shell__nav-badge {
    margin-left: auto;
    min-width: 1.4rem;
    text-align: center;
    font-size: .6875rem;
    font-weight: 700;
    padding: .05rem .45rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, .2);
    color: #fff;
    line-height: 1.55;
    font-variant-numeric: tabular-nums;
}
/* A badge that asks for something: pink for money owed, yellow for something to finish. */
.shell__nav-badge--due { background: var(--rsa-pink-500); color: #fff; }
.shell__nav-badge--attention { background: var(--rsa-yellow-500); color: var(--rsa-purple-900); }

/* CTA that sits above the nav list */
.shell__cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    margin: 1rem .75rem .25rem;
    padding: .65rem .9rem;
    border-radius: 10px;
    background: var(--rsa-yellow-500);
    color: var(--rsa-purple-800);
    font-size: .875rem;
    font-weight: 650;
    transition: background var(--rsa-fast), transform var(--rsa-fast), box-shadow var(--rsa-fast);
}
.shell__cta:hover {
    background: var(--rsa-yellow-400);
    color: var(--rsa-purple-900);
    transform: translateY(-1px);
    box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--rsa-yellow-500) 80%, transparent);
}

/* --- sidebar footer: signed-in identity + sign out --- */
.shell__sidebar-foot {
    margin-top: auto;
    flex-shrink: 0;
    padding: .85rem .75rem calc(1.15rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255, 255, 255, .1);
}
.shell__who {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .4rem .55rem .7rem;
    min-width: 0;
}
.shell__who .avatar { flex-shrink: 0; }
.shell__who .avatar {
    background: rgba(255, 255, 255, .16);
    color: #fff;
    width: 36px;
    height: 36px;
    font-size: .78125rem;
}
/* Name over email, each clipped to the sidebar width. The children are <span>s:
   without display:block they sit inline on one line and the nowrap+ellipsis
   rules never apply, so a long email overflows the sidebar. */
.shell__who-text {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}
.shell__who-name,
.shell__who-mail { display: block; }
.shell__who-name {
    font-size: .8125rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.shell__who-mail {
    font-size: .6875rem;
    color: rgba(255, 255, 255, .5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.shell__signout {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    padding: .55rem .8rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: rgba(255, 255, 255, .6);
    font-size: .8125rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background var(--rsa-fast), color var(--rsa-fast);
}
.shell__signout:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.shell__signout i { width: 20px; text-align: center; }
/* The club's shop, styled as Sign out's neighbour: a link, so no underline, and a small "leaves the portal" arrow. */
.shell__shop { text-decoration: none; color: rgba(255, 255, 255, .85); }
.shell__shop:hover { text-decoration: none; }
.shell__signout .shell__shop-out { width: auto; margin-left: auto; font-size: .7rem; opacity: .6; }

/* ============================================================
   MAIN COLUMN
   ============================================================ */

.shell__main {
    margin-left: var(--rsa-sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.shell__topbar {
    position: sticky;
    top: 0;
    z-index: 500;
    height: var(--rsa-topbar-h);
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: 0 clamp(1rem, 3vw, 2rem);
    background: rgba(255, 255, 255, .88);
    backdrop-filter: saturate(1.6) blur(10px);
    -webkit-backdrop-filter: saturate(1.6) blur(10px);
    border-bottom: 1px solid var(--rsa-line);
}

.shell__burger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--rsa-line);
    background: #fff;
    color: var(--rsa-gray-600);
    font-size: 1.15rem;
    cursor: pointer;
    flex-shrink: 0;
}
.shell__burger:hover { background: var(--rsa-gray-100); color: var(--rsa-gray-900); }

/* compact mark in the topbar — only when the sidebar (and its logo) is hidden */
.shell__topbar-logo { display: none; line-height: 0; flex-shrink: 0; }
.shell__topbar-logo img { height: 26px; width: auto; max-width: 66px; object-fit: contain; }
@media (max-width: 991.98px) {
    .shell__topbar-logo { display: inline-block; }
}

/* The page's own heading says where you are, so the bar saying it as well was a duplicate. The
   bar's title waits until that heading has scrolled up under the bar, then fades in (App.razor
   sets .is-titled). It keeps its space while hidden, so nothing beside it moves. */
.shell__topbar-title {
    font-family: var(--rsa-font-display);
    font-size: .9375rem;
    font-weight: 650;
    color: var(--rsa-gray-800);
    margin: 0;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity var(--rsa-base), transform var(--rsa-base);
}
.shell__topbar.is-titled .shell__topbar-title { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
    .shell__topbar-title { transform: none; transition: none; }
}
.shell__topbar-actions {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-left: auto;
}

/* balance pill in the topbar */
.shell__balance {
    display: inline-flex;
    align-items: baseline;
    gap: .4rem;
    padding: .3rem .75rem;
    border-radius: 999px;
    font-size: .8125rem;
    border: 1px solid var(--rsa-line);
    background: #fff;
    white-space: nowrap;
}
a.shell__balance { transition: border-color var(--rsa-fast), box-shadow var(--rsa-fast); }
a.shell__balance:hover { border-color: var(--rsa-purple-300); box-shadow: var(--rsa-shadow-xs); }
.shell__balance span:first-child {
    font-size: .6875rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 700;
    color: var(--rsa-gray-400);
}

/* account menu — a JS-free <details> dropdown */
.shell__account { position: relative; }
.shell__account > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .2rem .55rem .2rem .2rem;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
}
.shell__account > summary::-webkit-details-marker { display: none; }
.shell__account > summary:hover { background: var(--rsa-gray-100); }
.shell__account[open] > summary { background: var(--rsa-gray-100); border-color: var(--rsa-line); }
.shell__account > summary .bi-chevron-down {
    font-size: .7rem;
    color: var(--rsa-gray-400);
    transition: transform var(--rsa-fast);
}
.shell__account[open] > summary .bi-chevron-down { transform: rotate(180deg); }

.shell__account-menu {
    position: absolute;
    right: 0;
    top: calc(100% + .5rem);
    min-width: 240px;
    background: #fff;
    border: 1px solid var(--rsa-line);
    border-radius: var(--rsa-radius);
    box-shadow: var(--rsa-shadow-lg);
    padding: .35rem;
    z-index: 1100;
    animation: rsa-fade-up .14s ease-out both;
}
.shell__account-head {
    padding: .6rem .7rem;
    border-bottom: 1px solid var(--rsa-line-soft);
    margin-bottom: .3rem;
}
.shell__account-head strong { display: block; font-size: .8125rem; color: var(--rsa-gray-800); }
.shell__account-head span { font-size: .75rem; color: var(--rsa-gray-500); word-break: break-all; }
.shell__account-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    width: 100%;
    padding: .5rem .7rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--rsa-gray-700);
    font-size: .8125rem;
    text-align: left;
    cursor: pointer;
    transition: background var(--rsa-fast), color var(--rsa-fast);
}
.shell__account-item:hover { background: var(--rsa-gray-100); color: var(--rsa-gray-900); }
.shell__account-item i { color: var(--rsa-purple-500); width: 18px; text-align: center; }
.shell__account-item--danger { color: var(--rsa-pink-600); }
.shell__account-item--danger:hover { background: var(--rsa-pink-50); color: var(--rsa-pink-700); }
.shell__account-item--danger i { color: var(--rsa-pink-500); }

/* ============================================================
   CONTENT
   ============================================================ */

/* The page fills the space beside the sidebar, as the admin console does. It used to stop at 1320px
   and centre, which on a 1920px screen left a wide empty band either side of every form. */
.shell__content {
    flex: 1;
    width: 100%;
    padding: clamp(1.25rem, 2.4vw, 2rem) clamp(1rem, 3vw, 2rem) 3rem;
}

.shell__foot {
    padding: 1.25rem clamp(1rem, 3vw, 2rem) calc(2rem + env(safe-area-inset-bottom, 0px));
    text-align: center;
    font-size: .75rem;
    color: var(--rsa-gray-400);
}

/* ============================================================
   OVERLAY + RESPONSIVE
   ============================================================ */

.shell__overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(21, 22, 66, .45);
    z-index: 999;
}

/* The drawer's shadow only while it is open: on the closed, off-screen drawer it bled a grey
   band down the left edge of every page. */
@media (max-width: 991.98px) {
    .shell__sidebar { transform: translateX(-100%); box-shadow: none; }
    .shell__main { margin-left: 0; }
    .shell__burger { display: inline-flex; }

    .shell__drawer-state:checked ~ .shell__sidebar { transform: translateX(0); box-shadow: var(--rsa-shadow-lg); }
    .shell__drawer-state:checked ~ .shell__overlay { display: block; }

    /* The drawer's sky only moves while the drawer is open; off screen it would only cost. */
    .shell__sky > * { animation-play-state: paused; }
    .shell__drawer-state:checked ~ .shell__sidebar .shell__sky > * { animation-play-state: running; }
}

@media (max-width: 575.98px) {
    .shell__balance { display: none; }
    .shell__topbar-title { font-size: .875rem; }

    /* Page-header actions on a phone: the action row drops under the title (the header wraps),
       and at desktop size two buttons ("Register for an event" + "Add swimmer") no longer fit
       side by side, so they stacked at two different widths. A touch smaller, they share one
       row and split it between them; where they still don't fit, each takes a full row. */
    .shell:not(.shell--admin) .page-head__actions { width: 100%; }
    .shell:not(.shell--admin) .page-head__actions > .btn:not(:only-child) {
        flex: 1 1 auto;
        font-size: .875rem;
        padding: .45rem .7rem;
    }
}

/* The nav closes itself when a link inside it is followed on mobile:
   the checkbox is reset by the label wrapping the overlay. */

/* ============================================================
   ADMIN VARIANT — same shell, calmer skin, denser content
   ============================================================ */

.shell--admin .shell__sidebar {
    /* no pink/yellow glow — admins stare at this all day; the water rolls, a touch quieter */
    background: linear-gradient(180deg, var(--rsa-purple-700) 0%, var(--rsa-purple-900) 100%);
}
.shell--admin .shell__sky-water { opacity: .75; }
.shell--admin .shell__nav .nav-link.active {
    border-left-color: var(--rsa-yellow-500);
}
.shell--admin .shell__nav .nav-link.active i { color: var(--rsa-yellow-400); }

/* Admin tables run wide; pages bring their own .container-fluid py-4,
   so the shell contributes almost no padding of its own. */
.shell--admin .shell__content {
    padding: .25rem .75rem 2rem;
}

.shell__topbar-date {
    font-size: .8125rem;
    color: var(--rsa-gray-400);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
/* The date gives way first, once the sidebar folds into a drawer, so the title keeps its room. */
@media (max-width: 991.98px) {
    .shell__topbar-date { display: none; }
}
/* On a phone the role pill goes too (the drawer's foot says it): the bar is the menu, the logo
   and the page's title. */
@media (max-width: 575.98px) {
    .shell--admin .shell__topbar-actions > .chip { display: none; }
}

/* Page-entrance animation is skipped for admin: list pages re-render
   constantly while filtering and the motion would get in the way. */
.shell--admin .shell__content > * { animation: none; }

/* Impersonation banner — only a super admin "logged in as" someone sees this. */
.shell__impersonating {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .6rem 1rem;
    margin: .75rem 1.25rem 0;
    padding: .6rem .9rem;
    border-radius: 10px;
    background: var(--rsa-yellow-500);
    color: var(--rsa-purple-900);
    font-size: .875rem;
}
.shell__impersonating form { margin-left: auto; }
