/* Application styles for the Web Awesome based shell.
 *
 * The theme itself comes from the vendored Web Awesome stylesheets (see
 * index.html); this file carries the token adjustments and the shell layout.
 * Component styles live in the components, so there is one place to look for
 * each of them. */


/* -------------------------------------------------------------------------- */
/* Design tokens
/* -------------------------------------------------------------------------- */

/* The studio runs the theme's own scales down a notch.
 *
 * The premium theme's defaults are generous: 16px body text and spacing that
 * grows from a 16px base. That looks well on a marketing page and is
 * uncomfortably large in a tool that wants to show a 300 DPI card and a table
 * of properties in the same window. The type scale drops by one pixel (16px ->
 * 15px) and the space scale by an eighth (16px -> 14px), which tightens every
 * component's padding at once without changing any of the theme's colours,
 * radii or font families.
 *
 * These selectors carry the theme's classes on purpose: the theme defines its
 * tokens on `.wa-theme-premium.wa-dark` and friends, so a plain `:root` override
 * would lose to it on specificity. Naming the same element and classes here
 * means these values win, and both pinned schemes stay covered. */
html.wa-theme-premium,
html.wa-theme-premium.wa-light,
html.wa-theme-premium.wa-dark {
  --wa-font-size-scale: 0.9375;
  --wa-space-scale: 0.875;
}


/* Content columns.
 *
 * The shell is the whole window and the rail runs its full height; only the
 * content is held to a column. Each page centres its column inside the content
 * area rather than inside the window, so the rail keeps its edge and the
 * content reads as sitting beside it instead of drifting toward the middle.
 *
 * The widths differ by what the page holds, not by taste: a line of prose stops
 * being readable somewhere past a hundred characters, while a list of projects
 * and a table of properties want more room. The designer pages do not use a
 * column at all — their canvas and their table take every pixel. */
html.wa-theme-premium,
html.wa-theme-premium.wa-light,
html.wa-theme-premium.wa-dark {
  --page-column: 54rem;
  --page-index: 60rem;
  --page-data: 70rem;
}


/* -------------------------------------------------------------------------- */
/* Base
/* -------------------------------------------------------------------------- */

body {
  margin: 0;
  font-family: var(--wa-font-family-body);
  background: var(--wa-color-surface-default);
  color: var(--wa-color-text-normal);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--wa-font-family-heading);
  color: var(--wa-color-text-normal);
}

a {
  color: var(--wa-color-text-link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}


/* -------------------------------------------------------------------------- */
/* Shell
/* -------------------------------------------------------------------------- */

/* The shell is pinned to the viewport and the document never scrolls: the
 * header and the rail stay put and only the content region scrolls, so the
 * scrollbar belongs to the content column rather than to the window. The
 * document is contained as well so no stale scroll offset can nudge the page.
 *
 * The height is in svh, the smallest the viewport ever gets, because vh and
 * percentage heights resolve against the large viewport (bars hidden) and push
 * the shell past the visible area on some tablets. */
html, body {
  overflow: hidden;
  overflow: clip;
  overscroll-behavior: none;
}

wa-page {
  height: 100svh;
  overflow: hidden;
}

wa-page::part(page) {
  height: 100svh;
  min-height: 0;
  overflow: hidden;
}

wa-page::part(body) {
  min-height: 0;
}

/* The header, the rail and the drawer drawer share the recessed surface so they
 * read as chrome around the canvas rather than as content. */
wa-page::part(header),
wa-page::part(navigation-desktop),
wa-page::part(drawer) {
  background: var(--wa-color-surface-lowered);
}

wa-page::part(header) {
  min-height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid color-mix(in oklab, currentColor 12%, transparent);
}

wa-page::part(navigation-desktop) {
  border-right: 1px solid color-mix(in oklab, currentColor 12%, transparent);
}

/* The main region is the app's only scroll container, and the content area is a
 * flex column so a page can decide whether it scrolls (the overview) or fills
 * the space exactly (the designer). */
wa-page::part(main) {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--wa-color-surface-default);
}

wa-page::part(main-content) {
  height: 100%;
  min-height: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* The rail's link list scrolls on its own so a long list can never paint over
 * the footer button underneath it. */
wa-page nav[slot='navigation'] {
  min-height: 0;
  overflow-y: auto;
}

/* The rail footer is a bar, not loose text: same chrome, with a rule marking
 * the seam. */
wa-page span[slot='navigation-footer'] {
  width: 100%;
  background: var(--wa-color-surface-lowered);
  border-top: 1px solid color-mix(in oklab, currentColor 12%, transparent);
  padding: 0;
}

/* Pull the narrow-screen menu button closer to the title so it reads as the
 * start of the header row. */
wa-page::part(navigation-toggle) {
  margin-inline-start: var(--wa-space-xs);
  margin-inline-end: 0;
}
