/* Dashboard shell: the page column beside the rail, the reporting window and
 * the page header. The rail itself is kairo/rail.css, drawn here as a drawer
 * on a narrow screen (`rail--drawer`). Colours use the canonical tokens.css
 * palette. */

:root {
  --topbar: 64px;
  /* The top bar's contents line up with .page-content (kairo/topbar.css). */
  --kairo-topbar-width: 1560px;
}

body.dashboard {
  color: var(--k-color-ink);
  font-family: var(--sans);
  background: var(--k-color-ivory);
}

.app-shell {
  min-height: 100vh;
}

/* Right column */

.main {
  min-width: 0;
  margin-inline-start: var(--rail);
}

/* Follows the rail as the reader folds it (kairo/rail.css). */
@media (width > 920px) {
  .main {
    transition: margin-inline-start var(--k-duration-standard) var(--k-ease-standard);
  }
}

.mobile-menu {
  display: none;
}

.page-content {
  max-width: 1560px;
  margin: 0 auto;
  padding: 32px 28px 20px;
  /* A page's layout answers to the column it has, not to the window: Ask
     Neo's drawer takes 420px off the column without the viewport changing,
     and a breakpoint on the viewport keeps the desktop grid in a column too
     narrow for it. Page stylesheets ask `@container page`. */
  container: page / inline-size;
}

/* Reporting window */

.period-switch {
  position: relative;
  display: flex;
  gap: 2px;
  padding: 0;
  background: var(--k-color-lavender-soft);
  border: 1px solid var(--k-color-line);
  border-radius: var(--k-radius-control);
}

.period-switch__option {
  display: inline-flex;
  align-items: center;
  /* The option is the target, not the group around it: 44px on its own. */
  min-height: 44px;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  color: var(--k-color-ink-soft);
  border-radius: 6px;
}

.period-switch__option:hover {
  color: var(--k-color-ink);
}

.period-switch__option.active {
  color: var(--k-color-violet-deep);
  background: var(--k-color-paper);
  box-shadow: 0 1px 2px rgb(23 32 51 / 10%);
}

/* The custom option is a button among links, and has to look like one of them:
   the same face, and a popover hung off the group underneath it (positioned
   against .period-switch). */
.period-switch__option--custom {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  border: 0;
  background: none;
  cursor: pointer;
}

.period-switch__option--custom[aria-expanded="true"] {
  color: var(--k-color-ink);
}

.period-popover {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 30;
  display: grid;
  gap: 14px;
  width: min(340px, calc(100vw - 24px));
  padding: 16px;
  background: var(--k-color-paper);
  border: 1px solid var(--k-color-line);
  border-radius: var(--k-radius-panel);
  box-shadow: var(--k-shadow-raised);
}

/* `display: grid` above would otherwise beat the attribute the controller
   toggles, and the popover would be open on every page load. */
.period-popover[hidden] {
  display: none;
}

.period-popover__fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.period-popover__field {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--k-color-ink-soft);
}

.period-popover__field input {
  min-width: 0;
  height: 44px;
  padding: 0 10px;
  font: inherit;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--k-color-ink);
  background: var(--k-color-paper);
  border: 1px solid var(--k-color-control-border);
  border-radius: var(--k-radius-control);
}

.period-popover__field input:hover {
  border-color: var(--k-color-ink);
}

.period-popover__note {
  margin: 0;
  font-size: 12px;
  color: var(--k-color-muted);
}

.period-popover__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.period-popover__actions .button {
  min-height: 44px;
  margin-top: 0;
  padding: 0 14px;
  font-size: 13px;
}

/* Page header */

.welcome {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 30px;
  margin-bottom: 26px;
}

/* The metadata line over the heading: what the page is reporting on, and
   whether it is live. Set in the meta voice at normal case, as the system
   sets every date and identifier. */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--k-color-muted);
}

.status-pulse {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--k-color-success);
  box-shadow: 0 0 0 3px var(--k-color-success-bg);
}

/* The system's headline step: fluid 32–44px, Space Grotesk, tracked to the
   floor it sets. Balanced so a two-line heading breaks evenly. */
.welcome h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(32px, 3.5vw, 44px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.12;
  text-wrap: balance;
}

.welcome p {
  margin: 10px 0 0;
  font-size: 15px;
  color: var(--k-color-muted);
}

.period-label {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: end;
}

.period-label span {
  font-size: 12px;
  font-weight: 700;
  color: var(--k-color-muted);
}

.period-label strong {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
}

.period-label small {
  margin-top: 3px;
  font-size: 12px;
  color: var(--k-color-muted);
}

/* Tab panels */

.panel-empty {
  margin: 0;
  padding: 72px 0;
  font-size: 14px;
  text-align: center;
  color: var(--k-color-muted);
}

/* Narrow screens */

@media (width <= 920px) {
  /* The way to the rail's drawer, before the crumbs in the top bar. */
  .mobile-menu {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    font-size: 15px;
    color: var(--k-color-ink-soft);
    background: var(--k-color-paper);
    border: 1px solid var(--k-color-line);
    border-radius: var(--k-radius-control);
    cursor: pointer;
  }
}

@media (width <= 680px) {
  .page-content {
    padding: 24px 12px 16px;
  }

  .welcome {
    align-items: flex-start;
  }

  .period-label {
    display: none;
  }

  .period-switch__option {
    padding: 0 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .main {
    transition: none;
  }
}
