/* City Viewer — app shell (from the design project's css-plan).
   Conventions: one semantic class per component, CSS nesting for scoping,
   container queries for reflow, tokens.css variables only.
   The shell is the container-query root: every component file queries `app`.
   Load order is fixed by index.html <link>s (tokens first) — no @imports. */

/* The custom element wrapping .app defaults to display:inline; make it a block that fills the
   locked root so .app's height chain resolves (an inline wrapper adds baseline space and breaks
   the chain). */
fv-app { display: block; height: 100%; }

.app {
  container: app / inline-size;
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body, system-ui, sans-serif);
  /* Always full-bleed. The css-plan's centered 430px "phone column on desktop" is gone: it only
     ever applied between 430–700px viewports — which is large PHONES (Pixel 10 ≈ 448px), not
     desktops — and put gutters down both sides of the app. Wide layouts (≥700px container)
     reflow via @container queries on descendants instead. */
}

/* A screen = one routed view inside the shell */
.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;

  /* Wide: clear the left nav rail */
  @container app (min-width: 700px) {
    & { margin-left: 76px; }
  }

  /* The routed element itself (cv-home, cv-calendar, …) is a custom element — display:inline
     by default, which breaks the height chain: its inner scroll area (.screen-body, .home-body)
     never gets a bounded height, so long lists clip instead of scrolling. Make every screen
     element a full-height flex column; the inner scroll containers own the overflow. */
  & > * {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }
}

/* Scrollable stack of sections under a top bar (Services, Calendar, …) */
.screen-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-block: var(--space-4) var(--space-5);

  & > * { flex: none; }
}

/* ---- Top bar ------------------------------------------------------ */
/* City-level screens: solid navy block. (The facility viewer keeps its own
   floating .fv-header over the map.) */
.top-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: calc(env(safe-area-inset-top, 0px) + var(--space-5)) var(--space-4) var(--space-4);
  background: var(--brand);
  color: var(--ink-on-brand);

  & .top-bar-title {
    margin: 0;
    flex: 1;
    min-width: 0;
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--ink-on-brand); /* branding styles bare h1 navy — invisible here */
  }

  & .top-bar-subtitle {
    margin: var(--space-1) 0 0;
    font-size: .82rem;
    opacity: .85;
  }

}

/* Brand logo in any header band (top bar, home header) */
.top-bar-logo { display: block; height: 28px; width: auto; }

/* ---- Account button (top-right, every screen) ---------------------- */
.account-button {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  flex: none;
  position: relative;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--brand);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font: inherit;
  transition: opacity var(--dur-fast) var(--ease-standard);

  &:active { opacity: .85; }

  & svg { width: 1.15rem; height: 1.15rem; display: block; }

  /* Signed in: initials avatar */
  &.is-avatar {
    background: var(--brand);
    color: var(--ink-on-brand);
    font-size: .82rem;
    font-weight: 700;
    letter-spacing: .02em;
  }

  /* On a navy top bar */
  .top-bar & { background: rgba(255, 255, 255, .16); color: var(--ink-on-brand); box-shadow: none; }
  .top-bar &.is-avatar { background: var(--surface); color: var(--brand); }

  & .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 1.1rem;
    height: 1.1rem;
    padding: 0 var(--space-1);
    display: grid;
    place-items: center;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: var(--ink-on-brand);
    font-size: .68rem;
    font-weight: 700;
    border: 2px solid var(--bg);
  }

  & .presence-dot {
    position: absolute;
    top: -1px;
    right: -1px;
    width: .7rem;
    height: .7rem;
    border-radius: var(--radius-pill);
    background: var(--auburn-medium-green, #009C4F);
    border: 2px solid var(--bg);
  }
}

/* ---- App notice ------------------------------------------------------ */
/* Transient app-wide notice — a self-dismissing pill above the nav. Raised via cv:notice;
   the deep-link failure rule (docs/design/facility-view.html § Deep links) is its first user. */
.cv-notice {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--tap-min) + var(--space-3) + var(--space-2) + var(--space-3));
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  max-width: min(90%, 420px);
  padding: 0.45rem 1rem;
  border-radius: var(--radius-pill, 999px);
  background: var(--fv-navy);
  color: #fff;
  font-size: 0.85rem;
  text-align: center;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.25);
  animation: cv-notice-in 0.2s ease-out;
}
@keyframes cv-notice-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
}

/* ---- Get-the-app banner --------------------------------------------- */
/* Low-key, dismissible, mobile-web-only nudge to the native app (see APP-STORE-PUNCHLIST.md).
   A real flex row above the nav — it never covers screen content. Slides open from zero height
   (animating max-height avoids the reserved-gap glitch a transform on a flex child would cause);
   suppressed entirely for users who prefer reduced motion. */
.cv-appbanner {
  flex: none;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.85rem;
  overflow: hidden;
  animation: cv-appbanner-in 0.28s var(--ease-standard);

  & > svg { flex: none; width: 1.2rem; height: 1.2rem; color: var(--brand); }
  & .cv-appbanner-text { flex: 1; min-width: 0; }
  & .cv-appbanner-cta {
    flex: none;
    font-weight: 700;
    color: var(--brand);
    text-decoration: none;
    padding: var(--space-1) var(--space-2);
  }
  & .cv-appbanner-dismiss {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: var(--tap-min);
    min-height: var(--tap-min);
    border: 0;
    background: none;
    color: var(--ink-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: color var(--dur-fast) var(--ease-standard);
  }
  & .cv-appbanner-dismiss:active { color: var(--ink); }
}
@keyframes cv-appbanner-in {
  from { max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; }
  to { max-height: 4rem; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .cv-appbanner { animation: none; }
}

/* ---- Bottom nav ----------------------------------------------------- */
/* Persists across city-level screens AND facility viewers (Places stays lit). */
.bottom-nav {
  flex: none;
  z-index: 7;
  display: flex;
  padding: var(--space-2) var(--space-2) calc(env(safe-area-inset-bottom, 0px) + var(--space-3));
  background: var(--surface);
  border-top: 1px solid var(--line);

  & .nav-item {
    flex: 1;
    min-height: var(--tap-min);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    border: 0;
    background: none;
    cursor: pointer;
    font: inherit;
    font-size: .64rem;
    font-weight: 600;
    color: var(--ink-muted);
    transition: color var(--dur-fast) var(--ease-standard);

    &.is-active { color: var(--brand); }
    & svg { width: 1.15rem; height: 1.15rem; }
  }

  /* Wide: rail on the left instead of a bar */
  @container app (min-width: 700px) {
    & {
      position: absolute;
      inset: 0 auto 0 0;
      width: 76px;
      flex-direction: column;
      justify-content: center;
      gap: var(--space-4);
      border-top: 0;
      border-right: 1px solid var(--line);
      padding: var(--space-2);
    }
    & .nav-item { flex: none; }
  }
}
