/* ============================================================================
   CruiseFeed app shell — the sidebar the signed-in pages share.

   Signed-in pages only (/explore/, /dashboard/). The marketing site keeps its own
   top nav: a sidebar is for moving between the rooms of a tool, and a landing page
   has one room.

   Deliberately NOT built on /assets/tailwind.css, for the same reason the explorer
   is not: that stylesheet is purged against a page list in frontend/tailwind.config.js,
   so a shared component would depend on every utility it uses surviving a build it
   does not control. Brand tokens come from theme.css; the components are here.
   ========================================================================== */

:root {
  --shell-w: 232px;
  --shell-w-collapsed: 68px;
}

body.has-shell { margin: 0; background: var(--mist); }

/* The grid. One column on phones, sidebar + content from 900px up. */
.app-shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
@media (min-width: 900px) {
  .app-shell { grid-template-columns: var(--shell-w) minmax(0, 1fr); }
}

/* --- Sidebar -------------------------------------------------------------- */
.app-sidebar {
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  padding: .9rem .7rem 1rem;
  /* Sticky, not fixed: fixed takes it out of the grid and the content slides under. */
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

/* Phones: the sidebar becomes an off-canvas drawer. `hidden` would remove it from
   the a11y tree even when open, so visibility is done with a transform. */
@media (max-width: 899px) {
  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(82vw, var(--shell-w));
    z-index: 70;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 12px 0 40px -20px rgba(7, 17, 31, .8);
  }
  /* The state class goes on the SIDEBAR, not on an ancestor.
     A `.app-shell.nav-open .app-sidebar` descendant override works in principle, but
     it makes the open state depend on a cascade relationship across two elements —
     and when it silently failed to apply, nothing about the element said why. One
     element, one class, one rule is a thing that can be checked at a glance. */
  .app-sidebar.is-open { transform: translateX(0); }
  .app-scrim {
    position: fixed; inset: 0; z-index: 69;
    background: rgba(7, 17, 31, .45);
    opacity: 0; pointer-events: none; transition: opacity .22s;
  }
  .app-scrim.is-open { opacity: 1; pointer-events: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .app-sidebar, .app-scrim { transition: none; }
}

.app-brand {
  display: flex; align-items: center; gap: .55rem;
  text-decoration: none; color: #fff; padding: .3rem .5rem .9rem;
}
.app-brand .mark {
  width: 30px; height: 30px; border-radius: 8px; background: #fff; color: var(--navy);
  display: grid; place-items: center; font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 800; flex: none;
}
.app-brand .name { font-family: 'Cabinet Grotesk', sans-serif; font-weight: 800; font-size: 1.1rem; }
.app-brand .name .sub { color: var(--aqua); }

.app-navgroup {
  font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .09em;
  color: rgba(255, 255, 255, .45); padding: .8rem .6rem .3rem;
}
.app-nav { display: flex; flex-direction: column; gap: 2px; }
.app-nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .6rem; border-radius: 10px;
  color: rgba(255, 255, 255, .8); text-decoration: none;
  font-size: .9rem; font-weight: 600; line-height: 1.2;
}
.app-nav a:hover { background: rgba(255, 255, 255, .09); color: #fff; }
/* aria-current, not a class: the state is "this is the page you are on", which is
   exactly what the attribute means, so the styling and the a11y tree cannot disagree. */
.app-nav a[aria-current="page"] { background: var(--teal); color: #fff; }
.app-nav a .ico { width: 17px; height: 17px; flex: none; opacity: .9; }
.app-nav a .ext { margin-left: auto; opacity: .5; font-size: .8rem; }

.app-sidefoot { margin-top: auto; padding-top: .8rem; display: grid; gap: .5rem; }
.app-plan {
  border: 1px solid rgba(255, 255, 255, .16); border-radius: 12px;
  padding: .55rem .65rem; font-size: .78rem; color: rgba(255, 255, 255, .75);
}
.app-plan strong { display: block; color: #fff; font-family: 'Cabinet Grotesk', sans-serif;
                   font-size: .92rem; text-transform: uppercase; letter-spacing: .04em; }
.app-plan .bar { height: 6px; background: rgba(255,255,255,.16); border-radius: 99px;
                 overflow: hidden; margin: .4rem 0 .25rem; }
.app-plan .bar > span { display: block; height: 100%; background: var(--aqua); border-radius: 99px; }
.app-plan .bar > span.warn { background: var(--gold); }
.app-plan .bar > span.out { background: var(--coral); }
.app-plan a { color: var(--aqua); font-weight: 700; text-decoration: none; }
.app-plan a:hover { text-decoration: underline; }

.app-signout {
  width: 100%; border: 1px solid rgba(255, 255, 255, .18); background: transparent;
  color: rgba(255, 255, 255, .85); border-radius: 10px; padding: .5rem .6rem;
  font: inherit; font-size: .86rem; font-weight: 600; cursor: pointer;
}
.app-signout:hover { background: rgba(255, 255, 255, .09); color: #fff; }

/* --- Mobile top bar ------------------------------------------------------- */
.app-topbar {
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem .8rem; background: #fff; border-bottom: 1px solid var(--fog);
  position: sticky; top: 0; z-index: 40;
}
@media (min-width: 900px) { .app-topbar { display: none; } }
.app-burger {
  border: 1px solid var(--fog); background: #fff; border-radius: 9px;
  width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer; flex: none;
}
.app-burger span { display: block; width: 17px; height: 2px; background: var(--navy);
                   box-shadow: 0 -5px 0 var(--navy), 0 5px 0 var(--navy); }
.app-topbar .title { font-family: 'Cabinet Grotesk', sans-serif; font-weight: 800; font-size: 1rem; }

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

/* --- Adopted pages --------------------------------------------------------
   `AppShell.auto()` wraps a page that was written with its own top nav. That nav is
   the sidebar's job now, so it is hidden rather than deleted: these pages are also
   served to signed-OUT visitors, who still need it, and one stylesheet rule is a
   smaller thing to get wrong than an edit to seven pages.

   Scoped to a DIRECT child of the main column so an in-article <header> — a section
   heading inside the terms, say — is untouched. */
body.has-shell .app-main > header { display: none; }

/* Marketing pages centre on the viewport; inside the shell they should centre on the
   column that is left. `max-width` containers do this on their own, but a few use
   100vw, which is the whole window and now overflows by the width of the sidebar. */
@media (min-width: 900px) {
  body.has-shell .app-main [class*="w-screen"],
  body.has-shell .app-main .w-screen { width: 100%; max-width: 100%; }
}
