/* The app's own layer, on top of the shared design system in
 * _content/Droomploeg.SportDex.Branding/sportdex.css.
 *
 * Only the shell lives here: the header, the tab bar, the content column and
 * the two banners. The tokens, the typography and the primitives the screens
 * are built from are shared with the public website, so the two look like one
 * product. Anything a single screen needs stays in that screen's scoped
 * .razor.css.
 */

/* ----------------------------------------------------------------- shell -- */

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    background: var(--surface);
}

/* Sticky because on iOS the page runs under the status bar — see the
   apple-mobile-web-app-status-bar-style meta in index.html. The padding keeps
   the header's own text clear of the clock and the notch; staying put keeps the
   white status bar lettering on the header's colour instead of letting the
   agenda scroll underneath it. */
.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface-brand);
    padding-top: env(safe-area-inset-top);
    color: #fff;
}

.app-header::after {
    content: '';
    display: block;
    height: 2px;
    background: var(--orange-500);
}

.app-header-inner {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 3.25rem;
    padding: 0 var(--space-4);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    text-decoration: none;
    --mark-crest: rgb(255 255 255 / 16%);
    --mark-figure: #fff;
}

.app-brand span {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

/* The content column stops growing well before the window does: an agenda line
   read across 1400 pixels is a worse agenda than one read across 700. */
.app-content {
    flex: 1;
    width: 100%;
    max-width: 44rem;
    margin-inline: auto;
    padding: var(--space-5) var(--space-4);
    /* Room for the tab bar, which floats over the page on a phone. */
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
}

@media (min-width: 48rem) {
    .app-content {
        padding: var(--space-6) var(--space-5) var(--space-8);
    }
}

/* ------------------------------------------------------------------ tabs -- */

/* Within thumb's reach at the bottom of a phone, and up in the header once
   there is a pointer and a wide window. Three destinations is what a bottom bar
   is for; a hamburger holding three links would be a menu hiding a menu. */
.app-tabs {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
}

@supports (backdrop-filter: blur(12px)) {
    .app-tabs {
        background: color-mix(in srgb, var(--surface) 82%, transparent);
        backdrop-filter: saturate(180%) blur(12px);
    }
}

.app-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.125rem;
    min-height: 3.5rem;
    padding: 0.375rem 0.25rem;
    color: var(--ink-muted);
    font-size: var(--text-xs);
    font-weight: 600;
    text-decoration: none;
}

.app-tab svg {
    width: 1.375rem;
    height: 1.375rem;
}

/* Where you are. The accent earns its place here: it is the only thing on the
   bar that is not grey, so the answer is readable without reading. */
.app-tab.active {
    color: var(--orange-500);
}

@media (min-width: 48rem) {
    .app-tabs {
        position: static;
        display: flex;
        gap: var(--space-2);
        margin-left: auto;
        padding: 0;
        border-top: 0;
        background: none;
        backdrop-filter: none;
    }

    .app-tab {
        flex: 0 0 auto;
        flex-direction: row;
        gap: 0.4375rem;
        min-height: 2.25rem;
        padding: 0.375rem 0.75rem;
        border-radius: var(--radius-pill);
        color: rgb(255 255 255 / 78%);
        font-size: 0.9375rem;
    }

    .app-tab:hover {
        background: rgb(255 255 255 / 10%);
        color: #fff;
    }

    .app-tab.active {
        background: rgb(255 255 255 / 14%);
        color: #fff;
    }

    .app-tab.active svg {
        color: var(--orange-500);
    }

    .app-tab svg {
        width: 1.125rem;
        height: 1.125rem;
    }
}

/* ----------------------------------------------------------------- theme -- */

/* The switch ends the bar. What pushes it over is whatever comes before it: the
   tab bar on a wide window, the session bar on a phone. Neither is there on the
   very first frame — the session bar has to ask the server who is signed in
   first — so on a phone the switch carries the push itself until the session
   bar turns up and takes it over. */
.app-header-inner > .theme-toggle {
    margin-left: auto;
    margin-right: calc(var(--space-2) * -1);
}

.app-header-inner > .session-bar + .theme-toggle {
    margin-left: 0;
}

@media (min-width: 48rem) {
    .app-header-inner > .theme-toggle {
        margin-left: var(--space-1);
    }
}

/* --------------------------------------------------------------- session -- */

.session-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-left: auto;
    font-size: 0.875rem;
}

@media (min-width: 48rem) {
    .session-bar {
        margin-left: var(--space-4);
    }
}

.session-name {
    color: rgb(255 255 255 / 70%);
    max-width: 10rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-action {
    color: #fff;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

/* --------------------------------------------------------------- banners -- */

/* A new version is waiting. Louder than the install hint: that one is a
   suggestion, this one says what is on screen is out of date. */
.app-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--wait-surface);
    border-bottom: 1px solid var(--wait-line);
    color: var(--wait);
    font-size: 0.9375rem;
}

.app-banner button {
    margin-left: auto;
    min-height: 2.25rem;
    padding: 0.3125rem 0.875rem;
    border: 1px solid currentColor;
    border-radius: var(--radius-pill);
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

/* How to put the app on the home screen. A suggestion, shown to people who have
   not taken it yet, so it stays quiet. */
.app-hint {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--surface-sunken);
    border-bottom: 1px solid var(--line);
    color: var(--ink-muted);
    font-size: 0.9375rem;
}

.app-hint button {
    margin-left: auto;
    min-height: var(--tap);
    padding: 0.375rem 0;
    border: 0;
    background: transparent;
    color: var(--link);
    font: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 0.18em;
    cursor: pointer;
}

/* --------------------------------------------------------------- loading -- */

/* What is on screen while the runtime downloads. Deliberately the mark and a
   bar rather than a spinner: on a cold first load over a phone connection this
   is visible for a few seconds, and a bar that moves says the wait is finite. */
.app-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    min-height: 100dvh;
    padding: var(--space-5);
}

.app-loading-bar {
    width: min(14rem, 70vw);
    height: 0.25rem;
    border-radius: var(--radius-pill);
    background: var(--line);
    overflow: hidden;
}

.app-loading-bar span {
    display: block;
    height: 100%;
    width: var(--blazor-load-percentage, 0%);
    border-radius: inherit;
    background: var(--orange-500);
    transition: width 0.15s ease-out;
}

.app-loading-text {
    color: var(--ink-muted);
    font-size: var(--text-sm);
}

.app-loading-text::after {
    content: var(--blazor-load-percentage-text, 'Laden…');
}
