@layer plotline;

/* Colors come from the MUI CSS-variables stylesheet (theme/Theme.ts, emitted by the global
   root); the fallbacks are the same values so the shell is correct before JS runs. Fonts
   mirror ClientComponents/src/theme/tokens.ts -- keep the two in sync. */
:root {
  --pl-font-title: 'aleo', Georgia, 'Times New Roman', serif;
  --pl-font-body: 'brown-pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --pl-topbar-h: 80px;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--pl-palette-background-default, #F2F1EF);
}

body.plotline-body {
  font-family: var(--pl-font-body);
  color: var(--pl-palette-text-primary, #1A1A19);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* App-shell scrolling: sidebar and topbar stay fixed, only the content
   region scrolls. */
.pl-shell {
  position: relative;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.pl-shell__main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  /* Not decoration: without this a MUI DataGrid in the content area refuses
     to shrink and blows the flex container wide -- the single most common
     MUI-in-flex bug. */
  min-width: 0;
}

.pl-shell__content {
  flex: 1 1 auto;
  overflow: auto;
  padding: 6px 16px 32px;
}

@media (min-width: 600px) {
  .pl-shell__content {
    padding: 6px 32px 48px;
  }
}

/* Flush pages (the map) fill the content area edge to edge and don't scroll; their React root takes
   all the height. Set with ViewData["ContentClass"]. */
.pl-shell__content.pl-shell__content--flush {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.pl-shell__content--flush > .plotline-react-root {
  flex: 1 1 auto;
  min-height: 0;
}

/* Page title for Razor pages (from ViewData["Title"]); pages that draw their own heading set
   ViewData["HidePageTitle"]. Matches the prototype's .hd h1. */
.pl-page-header {
  margin: 0 0 22px;
}

/* Back link above the title; the arrow is decoration, not part of the accessible name. */
.pl-back-link {
  display: inline-block;
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--pl-palette-primary-main, #009845);
  text-decoration: none;
}

.pl-back-link::before {
  content: "\2190\00a0";
}

.pl-back-link:hover,
.pl-back-link:focus-visible {
  text-decoration: underline;
}

/* Same ring MUI draws on its own controls (theme.focusVisible). */
.pl-back-link:focus-visible {
  outline: 2px solid var(--pl-palette-primary-main, #009845);
  outline-offset: 2px;
  border-radius: 2px;
}

.pl-page-title {
  margin: 0;
  font-family: var(--pl-font-title);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--pl-palette-text-primary, #1A1A19);
}

/* Topbar sits in the main column on the page background, above the content. Reserving its
   height up front keeps the content from jumping when React mounts. */
.plotline-react-root--plotline-topbar {
  flex: 0 0 auto;
  min-height: var(--pl-topbar-h);
}

/* Sidebar's permanent Drawer IS a real flex item once mounted (MUI sizes its
   root div to `width: drawerWidth`). Before hydration the mount point has no
   children, so without an explicit width it collapses to 0 and .pl-shell__main
   fills the row -- then jumps left by the drawer's width the instant React
   mounts. Reserve that width up front instead, and only switch to
   `display: contents` once bound (data-plotline-bound, set by
   Website.bind()), at which point the real Drawer -- same width -- takes over
   the box with no visible delta. */
.plotline-react-root--plotline-sidebar {
  flex: 0 0 auto;
  overflow: hidden;
  background: var(--pl-palette-background-paper, #FFFFFF);
  border-right: 1px solid var(--pl-palette-hairline, rgba(151, 139, 135, 0.16));
}

@media (min-width: 600px) {
  .plotline-react-root--plotline-sidebar {
    /* Tablet (sm-md) always starts collapsed -- shell.navExpandedMobile
       defaults to false -- so a static width matches with no cookie needed. */
    width: 80px;
  }
}

@media (min-width: 900px) {
  .plotline-react-root--plotline-sidebar {
    /* Desktop's expanded/collapsed choice is user-persisted
       (shell.navExpandedDesktop) and can't be known from CSS alone --
       PlotlineSidebarTagHelper sets this variable from a cookie mirror of
       that preference (see persistence.ts) so a user who collapsed the
       sidebar doesn't see it flash open on reload. */
    width: var(--pl-sidebar-w, 244px);
  }
}

.plotline-react-root--plotline-sidebar[data-plotline-bound] {
  display: contents;
  width: auto;
  overflow: visible;
}
