/* ============================================================
   App shell: header, sidebar, content, bottom navigation
   ============================================================ */

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-soft);
}

/* ---------------------------------------------------------- header */

.appbar {
    position: sticky;
    top: 0;
    z-index: 60;
    height: var(--header-h);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.6) blur(10px);
    border-bottom: 1px solid transparent;
    transition: border-color var(--t), box-shadow var(--t);
}
.appbar.is-scrolled {
    border-bottom-color: var(--border);
    box-shadow: 0 1px 12px rgba(16, 18, 27, .06);
}
html[data-theme="dark"] .appbar.is-scrolled { box-shadow: 0 1px 14px rgba(0, 0, 0, .4); }
.appbar-inner {
    max-width: var(--content-max);
    margin: 0 auto;
    height: 100%;
    padding: 0 var(--sp-5);
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    min-width: 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 16px;
    color: var(--text-strong);
    letter-spacing: -.02em;
    /* the brand yields space before the actions ever get clipped */
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
}
.brand:hover { color: var(--text-strong); }
.brand-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.brand-mark {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: linear-gradient(140deg, var(--primary), var(--primary-dark));
    color: #fff;
    display: grid;
    place-items: center;
    box-shadow: 0 4px 12px var(--primary-ring);
    flex: none;
}
/* without this the name kept its full width and .brand simply clipped it, so a
   long site name lost its last word instead of ending in an ellipsis */
.brand-name {
    min-width: 0;
    overflow: hidden;
}
.brand-name small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: .04em;
    text-transform: uppercase;
}

.appnav {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: var(--sp-4);
}
.appnav a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: var(--fs-sm);
    font-weight: 600;
    transition: background var(--t-fast), color var(--t-fast);
}
.appnav a:hover { background: var(--surface); color: var(--text); }
.appnav a.is-active { background: var(--primary-soft); color: var(--primary-dark); }

.appbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    /* the search may narrow so a long site name is not the first thing cut;
       the bell and the avatar are still never squeezed */
    flex: 0 1 auto;
    min-width: 0;
}
.appbar-actions > :not(.searchbox) { flex: none; }

/* one class pair decides what survives on a narrow screen */
.only-narrow { display: none; }
@media (max-width: 700px) {
    .only-wide   { display: none !important; }
    .only-narrow { display: inline-flex; }
}

.searchbox {
    position: relative;
    width: min(320px, 34vw);
    min-width: 190px;      /* it may give room to the brand, but stays usable */
}
.searchbox .input { padding-left: 36px; height: 40px; border-radius: var(--radius-pill); background: var(--surface); }
.searchbox svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

/* ---------------------------------------------------------- page */

.page {
    flex: 1 1 auto;
    max-width: var(--content-max);
    width: 100%;
    margin: 0 auto;
    padding: var(--sp-6) var(--sp-5) calc(var(--sp-9) + env(safe-area-inset-bottom));
}
.page--wide { max-width: 1420px; }
.page--narrow { max-width: 760px; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
    flex-wrap: wrap;
}
.page-title { margin: 0; font-size: var(--fs-2xl); }
.page-sub { color: var(--muted); font-size: var(--fs-sm); margin: 4px 0 0; }

.section { margin-bottom: var(--sp-8); }
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}
.section-title {
    margin: 0;
    font-size: var(--fs-md);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 9px;
}
.section-title svg { color: var(--primary); }

.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* min() keeps a track from ever being wider than the screen it sits on */
.grid-auto    { grid-template-columns: repeat(auto-fill, minmax(min(100%, 255px), 1fr)); }
.grid-auto-lg { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.grid-cards   { grid-template-columns: repeat(auto-fit,  minmax(min(100%, 330px), 1fr)); }

.grid-split      { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid-split-wide { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
@media (max-width: 900px) {
    .grid-split, .grid-split-wide { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------------------------------------------------- hero */

.hero {
    position: relative;
    border-radius: var(--radius-lg);
    padding: var(--sp-8);
    color: #fff;
    background: linear-gradient(140deg, var(--primary-dark), #7d0d12 58%, #340609);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "copy art" "stats stats";
    gap: var(--sp-6) var(--sp-7);
    align-items: center;
    overflow: hidden;
}
.hero__copy  { grid-area: copy; min-width: 0; }
.hero__art   { grid-area: art;  min-width: 0; }
.hero__stats { grid-area: stats; }

.hero h1 {
    color: #fff;
    font-size: clamp(26px, 3.4vw, 40px);
    line-height: 1.18;
    margin: 14px 0 12px;
    max-width: 20ch;
    text-wrap: balance;
}
.hero p {
    color: rgba(255, 255, 255, .82);
    max-width: 54ch;
    font-size: var(--fs-md);
    margin: 0;
}
.hero__actions {
    display: flex;
    gap: var(--sp-3);
    flex-wrap: wrap;
    margin-top: var(--sp-5);
}
.hero-svg { width: 100%; height: auto; display: block; }

/* ---------------------------------------------------------- breadcrumb */

.crumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: var(--fs-xs);
    color: var(--muted);
    margin-bottom: var(--sp-3);
}
.crumbs a { color: var(--muted); font-weight: 600; }
.crumbs a:hover { color: var(--primary); }
.crumbs svg { opacity: .5; }

/* ---------------------------------------------------------- bottom nav (mobile) */

.bottomnav {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 70;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(12px) saturate(1.5);
    border-top: 1px solid var(--border);
}
.bottomnav-inner {
    height: var(--bottomnav-h);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
}
.bottomnav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 600;
    position: relative;
}
.bottomnav a.is-active { color: var(--primary); }
.bottomnav a.is-active::before {
    content: "";
    position: absolute;
    top: 0;
    width: 26px; height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--primary);
}

/* ---------------------------------------------------------- auth pages */

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    background: var(--bg);
}
.auth-aside {
    background:
        radial-gradient(900px 500px at 12% 8%, rgba(255,255,255,.16), transparent 62%),
        linear-gradient(150deg, var(--primary-dark), #6d0d11 62%, #2b0507);
    color: #fff;
    padding: var(--sp-9) var(--sp-8);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.auth-aside h1 { color: #fff; font-size: var(--fs-3xl); max-width: 15ch; }
.auth-aside p { color: rgba(255,255,255,.78); max-width: 44ch; }
.auth-flow {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: var(--sp-6);
}
.auth-flow span {
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: var(--radius-pill);
    padding: 6px 13px;
    font-size: var(--fs-xs);
    font-weight: 600;
}
.auth-main {
    display: grid;
    place-items: center;
    padding: var(--sp-8) var(--sp-6);
}
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: var(--fs-xl); margin-bottom: 4px; }

/* ---------------------------------------------------------- footer */

.appfoot {
    border-top: 1px solid var(--border);
    background: var(--bg);
    padding: var(--sp-6) var(--sp-5);
    color: var(--muted);
    font-size: var(--fs-xs);
}
.appfoot-inner {
    max-width: var(--content-max);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    gap: var(--sp-4);
    flex-wrap: wrap;
}
