/*
 * layout.css: the page frame, i.e. the frozen header, footer, container, and the shell with its sidebar.
 *
 * Part of the new stylesheet stack (redesign Step 3). Loaded by
 * templates/base.html.twig in this order, one <link> each: tokens.css,
 * base.css, layout.css, components.css, forms.css, admin.css, parent.css.
 * Never use @import here: every file is linked on its own so that
 * FileModifiedVersionStrategy versions each one by its modification time.
 */

/* ------------------------------------------------------------------ header
   FROZEN by owner decision: do not restyle. This block is the header as it was
   before the redesign, copied verbatim, except that (1) tokens whose value moved are pinned
   (--header-muted keeps the name and Sign out at #7c7386) and (2) .site-header
   states the font, size and line height it used to inherit from body.
   Raw values are allowed here and nowhere else in the stack. */

.site-header {
    /* Pinned to what the header inherited from the old body, so the new body
       rules (16px / 25px line height) cannot move it. */
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.55;
    font-weight: 400;
    color: var(--ink);
    background: var(--card);
    border-bottom: 1px solid var(--line);
}

.site-header__inner {
    max-width: 1060px;
    margin: 0 auto;
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.wordmark {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--ink);
}

.wordmark__text {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.05;
    display: flex;
    flex-direction: column;
}

.wordmark__text small {
    font-family: var(--font-body);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--oak);
}

.acorn { flex-shrink: 0; }

.site-nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.site-nav a {
    text-decoration: none;
    font-weight: 600;
    color: var(--ink);
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
}

.site-nav a:hover { background: var(--plum-tint); }

.site-nav a.is-active {
    background: var(--plum);
    color: #fff;
}

.site-nav__user {
    color: var(--header-muted);
    padding-left: 0.5rem;
    border-left: 1px solid var(--line);
    margin-left: 0.35rem;
}

.site-nav__signout { color: var(--header-muted); font-weight: 400; }

@media (max-width: 560px) {
    .site-header__inner { justify-content: center; text-align: center; }
}

/* Width hook: the admin host puts `has-app-shell` on <body> (base.html.twig),
   so the header's inner row follows the shell width instead of 1060px. */
body.has-app-shell .site-header__inner { max-width: var(--shell-max); }

/* ---------------------------------------------------------------- skip link
   The first thing in <body> on the admin host (templates/admin/_layout.html.twig).
   Visually hidden, not display: none, so it stays in the tab order; shown at the
   top-left over the page when it has focus, so the header never moves. It keeps
   the standard focus ring from base.css. It jumps to <main id="main-content"
   tabindex="-1">, which takes focus without drawing a ring around the whole
   page when it was not reached by keyboard. */

.skip-link {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    z-index: 100;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--card);
    color: var(--plum-dark);
    font-weight: var(--weight-semibold);
    transform: translateY(-300%);
}

.skip-link:focus { transform: none; }

#main-content:focus:not(:focus-visible) { outline: none; }

/* ------------------------------------------------------------------ layout */

.container {
    width: 100%;
    max-width: var(--parent-max);
    margin: 0 auto;
    padding: var(--space-6) var(--space-5) var(--space-12);
    flex: 1;
}

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

.site-footer {
    border-top: 1px solid var(--line);
    padding: var(--space-5);
    text-align: center;
    font-size: var(--text-small);
    line-height: var(--leading-small);
    color: var(--muted);
}

.site-footer p { margin: 0; }
.site-footer p + p { margin-top: var(--space-1); }

/* --------------------------------------------------- app shell and sidebar
   templates/admin/_layout.html.twig renders this markup, and
   templates/admin/_nav.html.twig the sidebar. The shape (from the design
   system's AppShell, SideNav and the phone's shell bar):

     <div class="shell-frame" data-controller="drawer">
       <div class="shell-bar">...a Menu button + where you are...</div>
       <div class="app-shell">
         <nav class="side-nav" aria-label="Admin">
           <button class="side-nav__close">...</button>
           <div class="side-nav__group">
             <p class="side-nav__label">Families</p>
             <a href="...">Children <span class="count">12</span></a>
             <a href="..." aria-current="page">Staff</a>
           </div>
         </nav>
         <main>...</main>
       </div>
     </div>

   .shell-frame only scopes the drawer controller; it is `display: contents`
   so the body's flex column still sees the shell bar and .app-shell as its
   children. A page with no sidebar adds `.app-shell--bare` (one column), and
   the schedule grids add `.app-shell--wide`.

   Drawer state hook (the one assets/controllers/drawer_controller.js
   toggles): the class `is-drawer-open` on `.app-shell`. Below 1024px the sidebar is hidden; with
   that class it opens as a fixed panel on a scrim (the scrim is the shell's
   own ::before, so a click whose event.target is the shell itself, not a
   child, is a click on the scrim). It sits at z-index 40/41, under the
   onboarding .guide-modal (60) and the fee gate (1000), and native <dialog>s
   render in the top layer above everything.

   The content column is minmax(0, 1fr), so a wide table or timeline scrolls
   inside its own wrapper (.table-wrap) instead of widening the page. The
   shell clips with `overflow-x: clip`, never `hidden`: `hidden` makes the
   shell a scroll container, and the sticky sidebar then sticks to it instead
   of the window. */

.app-shell {
    width: 100%;
    max-width: var(--shell-max);
    margin: 0 auto;
    padding: var(--space-6) var(--space-5) var(--space-12);
    flex: 1;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    gap: var(--space-8);
    align-items: start;
    overflow-x: clip;
}

.has-app-shell .app-shell {
    font-size: var(--text-table);
    line-height: var(--leading-table);
}

.shell-frame { display: contents; }

.app-shell--wide { max-width: none; }

/* No sidebar on this page (the authenticator setup, the camera slideshow). */
.app-shell--bare { grid-template-columns: minmax(0, 1fr); }

.app-shell > main { min-width: 0; }

/* Sticky, and scrollable on its own when it is taller than the window. The
   small padding (cancelled by the negative margin) keeps the focus ring of an
   item at the edge from being clipped by that scrolling. */
.side-nav {
    position: sticky;
    top: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    max-height: calc(100vh - var(--space-8));
    overflow-y: auto;
    padding: var(--space-1);
    margin: calc(var(--space-1) * -1);
}

.side-nav__group { display: flex; flex-direction: column; gap: 2px; }

.side-nav__label {
    margin: 0 0 var(--space-1);
    padding: 0 var(--space-3);
    font-size: var(--text-overline);
    line-height: var(--leading-overline);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-overline);
    text-transform: uppercase;
    color: var(--muted);
}

.side-nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    min-height: 36px;
    padding: 0 var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--text-button);
    line-height: var(--leading-button);
    font-weight: var(--weight-semibold);
    color: var(--ink);
    text-decoration: none;
}

.side-nav a:hover { background: var(--sunken); }

/* The current page: plum-tint ground, plum-dark bold. (The current section of
   the old tab row is the oak underline; the two never look alike.) */
.side-nav a[aria-current="page"] {
    background: var(--plum-tint);
    color: var(--plum-dark);
    font-weight: var(--weight-bold);
}

/* .count itself is in components.css; on the plum-tint pill it sits on card. */
.side-nav a[aria-current="page"] .count { background: var(--card); }

/* The drawer's own close button; the sidebar needs none where it is always shown. */
.side-nav .side-nav__close { display: none; }

/* The bar under the header that opens the drawer; only where the sidebar is hidden. */
.shell-bar {
    display: none;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-5);
    border-bottom: 1px solid var(--line);
    background: var(--card);
    font-size: var(--text-button);
    line-height: var(--leading-button);
    font-weight: var(--weight-semibold);
}

@media (max-width: 1023px) {
    .app-shell {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
        padding-top: var(--space-5);
    }

    .app-shell > .side-nav { display: none; }

    .shell-bar { display: flex; }

    .app-shell.is-drawer-open > .side-nav {
        display: flex;
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 41;
        width: min(320px, calc(100vw - var(--space-12)));
        max-height: none;
        margin: 0;
        padding: var(--space-5);
        background: var(--card);
        box-shadow: var(--shadow-raised);
        overflow-y: auto;
        animation: side-nav-in 150ms ease-out;
    }

    /* The drawer's top-right corner. Its focus ring is the one every .btn gets. */
    .app-shell.is-drawer-open > .side-nav .side-nav__close {
        display: inline-flex;
        align-self: flex-end;
        flex-shrink: 0;
    }

    .app-shell.is-drawer-open::before {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 40;
        background: color-mix(in srgb, var(--ink) 45%, transparent);
    }
}

@keyframes side-nav-in {
    from { transform: translateX(-100%); }
    to { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .app-shell.is-drawer-open > .side-nav { animation: none; }
}

/* A parent page: no sidebar, within --parent-max. (.container does the same
   job on the pages that exist today.) */
.parent-main {
    width: 100%;
    max-width: var(--parent-max);
    margin: 0 auto;
    padding: var(--space-8) var(--space-5) var(--space-12);
    flex: 1;
}

@media print {
    .skip-link,
    .side-nav,
    .shell-bar { display: none; }
    .app-shell { display: block; padding: 0; }
}

/* ------------------------------------------------------------------- print */

@media print {
    .no-print,
    .site-header,
    .site-footer,
    .flash { display: none !important; }
    body { background: #fff; }
    .printable .table-wrap { overflow: visible; }
    .printable .data-table { font-size: 11pt; }
}
