/* ---------- Page frame ---------- */

/* Column layout keeps the footer at the bottom of the screen on short pages */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

#app {
    flex: 1;
}

/* Phones get a fixed bottom nav, and sometimes the workout bars above it, so the page needs room underneath to scroll the last line into view */
@media (max-width: 767px) {
    body {
        padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + var(--bottom-bars-height, 0px));
    }
}

.skip-link {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: calc(var(--z-header) + 1);
    padding: 10px 16px;
    background: var(--color-accent-fill);
    color: var(--color-on-accent-fill);
    font-weight: 600;
    text-decoration: none;
}

/* Clipped instead of moved above the page, so it can't peek out when a phone bounces at the top, and only keyboard focus shows it */
.skip-link:not(:focus-visible) {
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ---------- Brand ---------- */

/* justify-self keeps the link as wide as the logo, as a grid item in the top nav it would stretch across the whole first column */
.brand {
    justify-self: start;
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: var(--tracking-brand);
    text-transform: uppercase;
    color: var(--color-text);
    text-decoration: none;
}

.brand b {
    font-weight: inherit;
    color: var(--color-accent);
}

/* ---------- Top nav ---------- */

#site-header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
}

/* A card reached by a #link stops below the sticky header instead of under it */
#app [id] {
    scroll-margin-top: calc(var(--header-height) + 16px);
}

.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--header-height);
    /* On wide screens the padding grows so the brand lines up with the page content below, the rule still runs edge to edge */
    padding: 0 max(var(--gutter), calc((100% - var(--max-width)) / 2 + var(--gutter)));
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.top-nav__menu {
    display: none;
}

.top-nav__end {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* On a phone the account link sits flush with the gutter, its padding is only there for the touch target */
.top-nav__end .link-strong {
    margin-right: -12px;
    padding: 12px;
}

/* Two classes so this wins over .btn, which is loaded later in components.css */
.top-nav__end .top-nav__cta {
    display: none;
}

.top-nav__item {
    padding: 18px 0 16px;
    border-bottom: 2px solid transparent;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--color-text-muted);
    text-decoration: none;
}

.top-nav__item[aria-current] {
    color: var(--color-text);
    border-bottom-color: var(--color-accent);
}

@media (hover: hover) {
    .top-nav__item:hover {
        color: var(--color-text);
    }
}

/* Three equal columns from here, so the menu sits in the true centre whatever the two sides hold */
@media (min-width: 768px) {
    .top-nav {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
    }

    .top-nav__menu {
        display: flex;
        gap: 40px;
    }

    .top-nav__end .link-strong {
        margin-right: 0;
    }

    .top-nav__end .top-nav__cta {
        display: inline-flex;
    }
}

/* ---------- Bottom nav (phones) ---------- */

.bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: var(--z-bottom-bars);
    display: flex;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
}

.bottom-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: var(--bottom-nav-height);
    padding: 8px 0 6px;
    color: var(--color-text-muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav__item .icon {
    width: 22px;
    height: 22px;
}

.bottom-nav__item[aria-current] {
    color: var(--color-accent);
}

@media (min-width: 768px) {
    .bottom-nav {
        display: none;
    }
}

/* ---------- Footer ---------- */

.site-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
}

.site-footer__inner {
    display: grid;
    gap: 28px;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 36px var(--gutter) 24px;
}

.site-footer__brand {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 34ch;
}

.site-footer__brand p {
    font-size: 14px;
    color: var(--color-text-muted);
}

.site-footer__cols {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 20px;
}

.site-footer__heading {
    margin-bottom: 8px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--color-text-muted);
}

.site-footer__list {
    display: flex;
    flex-direction: column;
    list-style: none;
}

.site-footer__link {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch-target);
    font-size: 14px;
    color: var(--color-text-muted);
    text-decoration: none;
}

.site-footer__link[aria-current] {
    color: var(--color-text);
}

@media (hover: hover) {
    .site-footer__link:hover {
        color: var(--color-text);
    }
}

.site-footer__base {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 16px var(--gutter) 22px;
    border-top: 1px solid var(--color-border);
    font-size: 12px;
    color: var(--color-text-muted);
}

/* The app pages on a phone already have the bottom nav, so only public pages like the front page keep the footer */
@media (max-width: 767px) {
    body:not([data-mobile-footer]) #site-footer {
        display: none;
    }
}

@media (min-width: 900px) {
    .site-footer__inner {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 64px;
        padding: 48px var(--gutter) 32px;
    }

    .site-footer__cols {
        grid-template-columns: repeat(4, 150px);
        gap: 24px;
    }
}

/* ---------- Page grid ---------- */

/* Sections inside a page are 32px apart, related things inside a .group 16px apart */
.page {
    display: flex;
    flex-direction: column;
    gap: 32px;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 24px var(--gutter) 32px;
}

.group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Main content left, a fixed side column right (stats, muscle map), stacked below 900px */
.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 48px;
    align-items: start;
}

.split__main,
.split__side {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.split__main {
    gap: 40px;
}

.split__side {
    gap: 32px;
}

.grid2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    gap: 12px;
}

.narrow {
    display: flex;
    flex-direction: column;
    gap: 28px;
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
}

.center-column {
    display: flex;
    flex-direction: column;
    gap: 32px;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .page {
        gap: 40px;
        padding: 40px var(--gutter) 72px;
    }
}

@media (min-width: 900px) {
    .split {
        grid-template-columns: minmax(0, 1fr) var(--side-column);
    }
}

/* ---------- Site notices ---------- */

.site-notices:empty {
    display: none;
}

.site-notices {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 16px var(--gutter) 0;
}
/* ---------- Bottom bars (workout running, page actions) ---------- */

/* On phones the bars sit on top of the bottom nav, activeBar.js keeps --bottom-bars-height in step with what they show */
.bottom-bars {
    position: fixed;
    right: 0;
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    left: 0;
    z-index: var(--z-bottom-bars);
}

/* Desktop has no bottom nav, the rest timer floats in the corner and page actions are in the page header instead */
@media (min-width: 768px) {
    /* In the window's own corner and not the content column's, it belongs to the app and not to the page under it */
    .bottom-bars {
        right: var(--gutter);
        bottom: var(--gutter);
        left: auto;
        /* A fixed width, so the floating bar doesn't grow and shrink as its text and numbers change */
        width: 400px;
    }

    .bottom-bars__page {
        display: none;
    }
}