/* ============================================================
   OnlyCharr — App shell
   Header, rails, bottom nav, footer, page containers.
   ============================================================ */

.site {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 0 var(--sp-4);
    padding-top: env(safe-area-inset-top);
    background: var(--bg-header);
    backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--border-subtle);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-shrink: 0;
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
    letter-spacing: var(--tracking-tight);
    /* Flat colour. The old wordmark used gradient-filled text, which was
       applied in eight places and is the clearest "template" tell. */
    color: var(--text-primary);
}
.brand:hover { color: var(--text-primary); }
.brand-mark { color: var(--accent); }

.header-search {
    flex: 1 1 auto;
    max-width: 420px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    margin-left: auto;
}
.site-header .spacer { flex: 1 1 auto; }
.header-nav .nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: 40px;
    padding: 0 var(--sp-3);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    transition: background-color var(--transition), color var(--transition);
}
.header-nav .nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.header-nav .nav-link.is-active { color: var(--accent); }
.nav-link .nav-badge { position: absolute; top: 2px; right: 2px; }

.user-menu { position: relative; flex-shrink: 0; }

/* ============================================================
   PAGE CONTAINERS
   ============================================================ */
.site-main {
    flex: 1 1 auto;
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--sp-5) var(--sp-4) var(--sp-8);
}
.site-main.is-flush { padding-left: 0; padding-right: 0; }

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

/* Feed column, for post-shaped content. */
.feed { max-width: var(--feed-max); margin: 0 auto; }

/* Two-column: content + sticky rail, as on the real app's desktop view. */
.with-rail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--rail-w);
    gap: var(--sp-6);
    align-items: start;
}
.rail {
    position: sticky;
    top: calc(var(--header-h) + var(--sp-4));
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}
@media (max-width: 68rem) {
    .with-rail { grid-template-columns: minmax(0, 1fr); }
    .rail { display: none; }
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    margin-top: auto;
    padding: var(--sp-6) var(--sp-4);
    padding-bottom: calc(var(--sp-6) + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: var(--fs-sm);
}
.footer-inner {
    max-width: var(--content-max);
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
}
.footer-links { display: flex; flex-wrap: wrap; gap: var(--sp-4); }
.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--text-primary); }
.footer-note { font-size: var(--fs-xs); color: var(--text-dimmed); max-width: 52ch; }

/* ============================================================
   MOBILE BOTTOM NAV
   Replaces the hamburger, which rendered as unstyled links
   floating over the page with no background panel.
   ============================================================ */
.bottom-nav { display: none; }

@media (max-width: 52rem) {
    .bottom-nav {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        z-index: var(--z-bottomnav);
        display: flex;
        align-items: stretch;
        height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--bg-surface);
        border-top: 1px solid var(--border-subtle);
    }
    .bottom-nav a {
        position: relative;
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: var(--text-muted);
        font-size: 0.625rem;
        font-weight: var(--fw-medium);
        transition: color var(--transition);
    }
    .bottom-nav a.is-active { color: var(--accent); }
    .bottom-nav .icon { width: 22px; height: 22px; }
    .bottom-nav .nav-badge {
        position: absolute;
        top: 4px;
        left: 50%;
        margin-left: 4px;
    }

    body.has-bottomnav .site-main { padding-bottom: calc(var(--bottomnav-h) + var(--sp-6)); }
    body.has-bottomnav .site-footer { padding-bottom: calc(var(--bottomnav-h) + var(--sp-6)); }

    /* The header sheds its nav links on small screens — they live in the
       bottom bar — keeping brand, search and avatar only. */
    .header-nav .nav-link { display: none; }
    .site-header { padding: 0 var(--sp-3); }
}

/* ============================================================
   SCROLL TO TOP
   ============================================================ */
.scroll-top {
    position: fixed;
    right: var(--sp-4);
    bottom: max(var(--sp-4), env(safe-area-inset-bottom));
    z-index: var(--z-sticky);
    width: 42px; height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-pill);
    background: var(--bg-elevated);
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
}
.scroll-top.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
body.has-bottomnav .scroll-top { bottom: calc(var(--bottomnav-h) + var(--sp-3)); }

/* ============================================================
   ADMIN / STUDIO PANEL SHELL
   ============================================================ */
.panel-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    align-items: start;
    min-height: calc(100dvh - var(--header-h));
}

.panel-sidebar {
    position: sticky;
    top: var(--header-h);
    height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    padding: var(--sp-4) var(--sp-3);
    border-right: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}
.sidebar-group + .sidebar-group { margin-top: var(--sp-5); }
.sidebar-heading {
    padding: 0 var(--sp-3) var(--sp-2);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semi);
    color: var(--text-dimmed);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-height: 40px;
    padding: 0 var(--sp-3);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    transition: background-color var(--transition), color var(--transition);
}
.sidebar-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-link.is-active { background: var(--accent-soft); color: var(--accent); }
.sidebar-link .sidebar-badge { margin-left: auto; }
.sidebar-link .nav-badge { margin-left: auto; }

.panel-main { padding: var(--sp-5) var(--sp-5) var(--sp-8); min-width: 0; }

@media (max-width: 60rem) {
    .panel-layout { grid-template-columns: minmax(0, 1fr); }
    .panel-sidebar {
        position: static;
        height: auto;
        display: flex;
        gap: var(--sp-1);
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        padding: var(--sp-2) var(--sp-3);
        scrollbar-width: none;
    }
    .panel-sidebar::-webkit-scrollbar { display: none; }
    .sidebar-group { display: contents; }
    .sidebar-heading { display: none; }
    .sidebar-link { white-space: nowrap; }
    .sidebar-group + .sidebar-group { margin-top: 0; }
    .panel-main { padding: var(--sp-4) var(--sp-3) var(--sp-8); }
}

/* ============================================================
   HORIZONTAL SCROLLER (pinned / featured strips)
   ============================================================ */
.scroller {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(190px, 1fr);
    gap: var(--sp-3);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: var(--sp-4);
    padding-bottom: var(--sp-2);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.scroller > * { scroll-snap-align: start; }
@media (min-width: 52rem) {
    .scroller { grid-auto-columns: minmax(230px, 1fr); }
}
