/* ============================================================
   GigaGym app chrome: reset, shell, side nav, shared primitives.
   Screen-specific styles live in css/gym.css and css/food.css.
   ============================================================ */

*, *::before, *::after {
    box-sizing: border-box;
    border-radius: 0; /* the design system: radius 0, no exceptions */
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--gg-ground);
    color: var(--gg-ink);
    font-family: var(--gg-font);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}

#app { height: 100%; }

h1, h2, h3, h4, p { margin: 0; }

button {
    font-family: inherit;
    color: inherit;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

input, select, textarea {
    font-family: inherit;
    color: var(--gg-ink);
    background: var(--gg-ground);
    border: 2px solid var(--gg-divider);
}

a { color: inherit; text-decoration: none; }

:focus-visible {
    outline: 2px solid var(--gg-accent);
    outline-offset: 2px;
}

::selection { background: var(--gg-accent); color: var(--gg-on-accent); }

/* Blazor error UI — keep on-brand, no default yellow bar */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--gg-row);
    border-top: 2px solid var(--gg-accent);
    color: var(--gg-ink);
    padding: 12px 16px;
    font-size: 13px;
    z-index: 1000;
}

/* ============================================================
   Shell: side nav (persistent ≥1024px, drawer below)
   ============================================================ */

.gg-shell {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

.gg-nav {
    width: 248px;
    flex-shrink: 0;
    background: var(--gg-ground);
    border-right: 2px solid var(--gg-divider);
    display: flex;
    flex-direction: column;
    /* Full-height drawer: clears the status bar above and gesture nav below. */
    padding-top: var(--gg-safe-top);
    padding-bottom: calc(var(--gg-s4) + var(--gg-safe-bottom));
    padding-left: var(--gg-safe-left);
}

.gg-nav__wordmark {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 var(--gg-s4);
    border-bottom: 2px solid var(--gg-divider);
    letter-spacing: .04em;
}

.gg-nav__mark { font-size: 19px; font-weight: 800; }
.gg-nav__mark--accent { color: var(--gg-accent); }

.gg-nav__section {
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--gg-dim);
    margin: var(--gg-s6) var(--gg-s4) var(--gg-s2);
}

.gg-nav__items { display: flex; flex-direction: column; }

.gg-nav__item {
    display: flex;
    align-items: center;
    gap: var(--gg-s3);
    height: var(--gg-tap-min);
    padding: 0 var(--gg-s4);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--gg-muted);
}

.gg-nav__item .gg-icon { color: var(--gg-dim); }

.gg-nav__item:hover { background: var(--gg-surface); color: var(--gg-ink); }

.gg-nav__item.active {
    color: var(--gg-ink);
    background: var(--gg-row);
    box-shadow: inset 3px 0 0 var(--gg-accent);
}

.gg-nav__item.active .gg-icon { color: var(--gg-accent); }

/* Section children: indented to the parent's label column (icon 20px + gap), shorter
   and dimmer so the group reads as one block rather than five peers. */
.gg-nav__item--sub {
    height: var(--gg-tap-chip);
    padding-left: calc(var(--gg-s4) + 20px + var(--gg-s3));
    font-size: 11.5px;
    color: var(--gg-dim);
}

/* The parent is active for the whole section, so the child carries the accent bar
   and the parent's own bar is suppressed — one marker per active row, not two. */
.gg-nav__item--sub.active {
    color: var(--gg-ink);
    background: var(--gg-row);
    box-shadow: inset 3px 0 0 var(--gg-accent);
}

.gg-nav__item:has(~ .gg-nav__item--sub.active) { box-shadow: none; }

.gg-nav__tag {
    margin-left: auto;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .12em;
    color: var(--gg-dim);
    border: 1px solid var(--gg-divider);
    padding: 2px 6px;
}

.gg-nav__foot { margin-top: auto; }
.gg-nav__item--dim { color: var(--gg-dim); }

.gg-shell__main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.gg-topbar {
    display: none;
    align-items: center;
    gap: var(--gg-s2);
    /* min-height, not height: the status-bar inset grows the bar rather than
       squashing its contents. */
    min-height: 56px;
    box-sizing: content-box;
    padding: var(--gg-safe-top) calc(var(--gg-s2) + var(--gg-safe-right)) 0
             calc(var(--gg-s2) + var(--gg-safe-left));
    border-bottom: 2px solid var(--gg-divider);
    background: var(--gg-ground);
    position: sticky;
    top: 0;
    z-index: 40;
}

.gg-topbar__menu {
    width: var(--gg-tap-min);
    height: var(--gg-tap-min);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gg-ink);
}

.gg-topbar__title { font-size: 16px; font-weight: 800; letter-spacing: .04em; }
.gg-topbar__title--accent { color: var(--gg-accent); }

.gg-main {
    flex: 1;
    min-width: 0;
    /* Landscape notch: content must not slide under the cutout. */
    padding-left: var(--gg-safe-left);
    padding-right: var(--gg-safe-right);
    padding-bottom: var(--gg-safe-bottom);
}

.gg-shell__scrim {
    display: none;
}

@media (max-width: 1023px) {
    .gg-nav {
        position: fixed;
        top: 0; bottom: 0; left: 0;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform 200ms ease-out;
        box-shadow: none;
    }

    .gg-nav.is-open {
        transform: translateX(0);
        box-shadow: var(--gg-shadow-l2);
    }

    .gg-shell__scrim.is-visible {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 50;
        background: var(--gg-scrim);
    }

    .gg-topbar { display: flex; }
}

/* ============================================================
   Shared primitives
   ============================================================ */

/* --- Buttons --- */
.gg-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* labels flush left per the system */
    gap: var(--gg-s2);
    min-height: var(--gg-tap-min);
    padding: 0 var(--gg-s4);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    border: 2px solid var(--gg-divider);
    color: var(--gg-ink);
    background: transparent;
    user-select: none;
}

.gg-btn:active { background: var(--gg-row); }

.gg-btn--accent {
    background: var(--gg-accent);
    border-color: var(--gg-accent);
    color: var(--gg-on-accent);
}

.gg-btn--accent:active { background: var(--gg-accent-pressed); border-color: var(--gg-accent-pressed); }

.gg-btn--ink {
    background: var(--gg-ink);
    border-color: var(--gg-ink);
    color: var(--gg-ground);
}

.gg-btn--set { min-height: var(--gg-tap-set); }
.gg-btn--primary-bar { min-height: var(--gg-tap-primary); }

.gg-btn[disabled] { color: var(--gg-dim); border-color: var(--gg-divider); background: transparent; cursor: default; }

.gg-iconbtn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--gg-tap-min);
    height: var(--gg-tap-min);
    color: var(--gg-muted);
}

.gg-iconbtn:active { color: var(--gg-ink); }

/* --- Segmented control --- */
.gg-segments {
    display: flex;
    border: 2px solid var(--gg-divider);
}

.gg-segments__cell {
    flex: 1;
    min-height: var(--gg-tap-chip);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--gg-muted);
    border-right: 2px solid var(--gg-divider);
    user-select: none;
}

.gg-segments__cell:last-child { border-right: none; }

.gg-segments__cell.is-active {
    background: var(--gg-accent);
    color: var(--gg-on-accent);
}

.gg-segments--tall .gg-segments__cell { min-height: var(--gg-tap-min); }

/* --- Chips --- */
.gg-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: var(--gg-tap-chip);
    padding: 0 var(--gg-s3);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    border: 1px solid var(--gg-divider);
    color: var(--gg-muted);
    user-select: none;
}

.gg-chip.is-active {
    background: var(--gg-accent);
    border-color: var(--gg-accent);
    color: var(--gg-on-accent);
}

/* --- Cards / rules --- */
.gg-card {
    background: var(--gg-surface);
}

.gg-rule-2 { border-top: 2px solid var(--gg-divider); }
.gg-rule-1 { border-top: 1px solid var(--gg-divider); }

/* --- Bottom sheet --- */
.gg-sheet-host {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background: var(--gg-scrim);
}

.gg-sheet {
    background: var(--gg-surface);
    border-top: 2px solid var(--gg-divider);
    animation: gg-sheet-up 200ms ease-out;
    max-height: 92vh;
    max-height: 92dvh;
    display: flex;
    flex-direction: column;
    /* Bottom-anchored: its last action sits right where gesture nav is. */
    padding-bottom: var(--gg-safe-bottom);
    padding-left: var(--gg-safe-left);
    padding-right: var(--gg-safe-right);
}

.gg-sheet--accent-rule { border-top-color: var(--gg-accent); }

.gg-sheet__handle {
    width: 56px;
    height: 4px;
    background: var(--gg-divider);
    margin: 10px auto 6px;
    flex-shrink: 0;
}

@keyframes gg-sheet-up {
    from { transform: translateY(24px); opacity: .6; }
    to   { transform: translateY(0); opacity: 1; }
}

/* --- Field / search input --- */
.gg-field {
    height: var(--gg-tap-min);
    width: 100%;
    padding: 0 var(--gg-s3);
    font-size: 14px;
    font-weight: 400;
}

.gg-field:focus { outline: none; border-color: var(--gg-accent); }

/* --- Stepper --- */
.gg-stepper {
    display: flex;
    align-items: stretch;
    border: 2px solid var(--gg-divider);
}

.gg-stepper__key {
    width: 72px;
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gg-ink);
    flex-shrink: 0;
    user-select: none;
}

.gg-stepper__key:active { background: var(--gg-row); }

.gg-stepper__value {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-left: 2px solid var(--gg-divider);
    border-right: 2px solid var(--gg-divider);
    padding: var(--gg-s2) 0;
}

.gg-stepper--compact .gg-stepper__key { width: 48px; min-height: 48px; }

/* --- Page scaffolding --- */
.gg-page {
    max-width: 640px;
    margin: 0 auto;
    padding: var(--gg-s4);
}

.gg-page--wide { max-width: 1360px; }

.gg-page__header { margin-bottom: var(--gg-s6); }

.gg-page__title { font-size: 26px; font-weight: 800; }

.gg-notfound, .gg-placeholder {
    padding: 64px var(--gg-s4);
    text-align: left;
    max-width: 640px;
    margin: 0 auto;
}

.gg-placeholder h1, .gg-notfound h1 { font-size: 26px; font-weight: 800; margin-top: var(--gg-s2); }
.gg-placeholder p { margin-top: var(--gg-s3); }

/* --- Progress ring (square ends, -90deg start applied on the svg) --- */
.gg-ring { transform: rotate(-90deg); }
.gg-ring circle { fill: none; stroke-width: 9; }
.gg-ring__track { stroke: var(--gg-divider); }
.gg-ring__fill { stroke: var(--gg-accent); }

/* --- Design sheet (/design) --- */
.gg-design__row {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: var(--gg-s4);
    padding: var(--gg-s6) 0;
    border-top: 2px solid var(--gg-divider);
}

.gg-design__label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--gg-dim);
}

.gg-design__stack { display: flex; flex-direction: column; gap: var(--gg-s3); align-items: flex-start; }

.gg-design__swatches { display: flex; flex-wrap: wrap; gap: var(--gg-s3); }

.gg-design__swatch { width: 84px; }

.gg-design__swatch-fill {
    height: 56px;
    border: 1px solid var(--gg-divider);
    margin-bottom: var(--gg-s1);
}

.gg-design__icons { display: flex; flex-wrap: wrap; gap: var(--gg-s3); }

.gg-design__icon {
    width: 96px;
    height: 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--gg-surface);
    color: var(--gg-muted);
}

@media (max-width: 720px) {
    .gg-design__row { grid-template-columns: 1fr; }
}

/* --- Settings / profile --- */
.gg-settings__section {
    display: flex;
    flex-direction: column;
    gap: var(--gg-s3);
    margin-bottom: var(--gg-s6);
}

.gg-settings__section--ruled { padding-top: var(--gg-s6); }

.gg-settings__error { margin-bottom: var(--gg-s4); }

.gg-settings__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
    gap: 2px;
}

.gg-settings__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: var(--gg-s3);
    background: var(--gg-surface);
}

.gg-settings__field--wide { grid-column: 1 / -1; }

.gg-settings__field .gg-field { min-height: var(--gg-tap-min); font-size: 17px; font-weight: 800; }
.gg-settings__field--wide .gg-field { font-size: 14px; font-weight: 400; }

.gg-settings__actions { display: flex; gap: var(--gg-s2); margin-bottom: var(--gg-s6); }

.gg-settings__note { color: var(--gg-dim); font-size: 12px; }
.gg-settings__note code { color: var(--gg-muted); }

.gg-weights { display: flex; flex-direction: column; gap: 1px; }

.gg-weights__row {
    display: grid;
    grid-template-columns: 1fr auto 62px;
    align-items: center;
    gap: var(--gg-s3);
    min-height: 48px;
    padding: 0 var(--gg-s3);
    background: var(--gg-surface);
}

.gg-weights__date { font-size: 13px; color: var(--gg-muted); }
.gg-weights__value { font-size: 17px; font-weight: 800; }
.gg-weights__delta { font-size: 12px; font-weight: 800; text-align: right; }

/* --- Utility --- */
.gg-flex { display: flex; align-items: center; }
.gg-spread { display: flex; align-items: center; justify-content: space-between; }
.gg-num { font-variant-numeric: tabular-nums; }
.gg-accent-text { color: var(--gg-accent); }
.gg-good-text { color: var(--gg-good); }
.gg-dim-text { color: var(--gg-dim); }
.gg-muted-text { color: var(--gg-muted); }
