/* Pinelume dashboard — base: reset, typography, focus, utilities. Built only on tokens.css. */
@layer base, components, layout, pages, utilities;

@layer base {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  * {
    margin: 0;
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: calc(var(--pl-topbar-height) + var(--pl-space-4));
  }

  html.has-dialog {
    overflow: hidden;
  }

  body {
    min-height: 100dvh;
    font-family: var(--pl-font-sans);
    font-size: var(--pl-text-md);
    line-height: var(--pl-leading-normal);
    font-feature-settings: "cv11", "ss03";
    color: var(--pl-color-text);
    background-color: var(--pl-color-bg);
    background-image: var(--pl-color-bg-accent);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }

  h1,
  h2,
  h3,
  h4 {
    color: var(--pl-color-heading);
    line-height: var(--pl-leading-tight);
    letter-spacing: var(--pl-tracking-tight);
    text-wrap: balance;
  }

  h1,
  h2 {
    font-family: var(--pl-font-display);
    font-weight: 600;
    font-variation-settings: "SOFT" 50, "WONK" 0;
  }

  h1 {
    font-size: var(--pl-text-3xl);
  }

  h2 {
    font-size: var(--pl-text-xl);
  }

  h3 {
    font-size: var(--pl-text-lg);
    font-weight: var(--pl-weight-semibold);
  }

  h4 {
    font-size: var(--pl-text-md);
    font-weight: var(--pl-weight-semibold);
  }

  p {
    text-wrap: pretty;
  }

  a {
    color: var(--pl-color-link);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
    transition: color var(--pl-duration-fast) var(--pl-ease-standard);
  }

  a:hover {
    color: var(--pl-color-primary-hover);
  }

  img,
  svg {
    display: block;
    max-width: 100%;
  }

  /* An icon dropped straight into a link or a button keeps the size of its text, never the width of the container;
     component rules (in later layers) still set their own size. */
  :where(a, button) > svg {
    width: 1.1em;
    height: 1.1em;
    flex: none;
  }

  button,
  input,
  select,
  textarea {
    font: inherit;
    color: inherit;
  }

  button {
    cursor: pointer;
  }

  code,
  kbd,
  pre {
    font-family: var(--pl-font-mono);
    font-size: 0.9em;
  }

  :not(pre) > code {
    padding: 0.1em 0.4em;
    border-radius: var(--pl-radius-sm);
    background: var(--pl-color-code-bg);
    overflow-wrap: anywhere;
  }

  kbd {
    padding: 0.05em 0.4em;
    border: 1px solid var(--pl-color-border-strong);
    border-bottom-width: 2px;
    border-radius: var(--pl-radius-sm);
    background: var(--pl-color-surface);
    font-size: 0.8em;
  }

  hr {
    border: 0;
    border-top: 1px solid var(--pl-color-border);
  }

  table {
    border-collapse: collapse;
  }

  ::selection {
    background: var(--pl-lume-200);
    color: var(--pl-pine-950);
  }

  :focus {
    outline: none;
  }

  :focus-visible {
    outline: 2px solid var(--pl-color-focus);
    outline-offset: 2px;
    border-radius: var(--pl-radius-sm);
  }

  [hidden] {
    display: none !important;
  }

  * {
    scrollbar-width: thin;
    scrollbar-color: var(--pl-color-border-strong) transparent;
  }

  /* Before Blazor starts: the brand mark and a thin progress bar, no text. */
  .boot {
    display: grid;
    place-items: center;
    align-content: center;
    gap: var(--pl-space-5);
    min-height: 100dvh;
    color: var(--pl-color-primary);
  }

  .boot__mark {
    width: 3.5rem;
    height: 3.5rem;
    animation: boot-breathe 1.6s var(--pl-ease-standard) infinite alternate;
  }

  .boot__lume {
    fill: var(--pl-color-accent);
  }

  .boot__bar {
    position: relative;
    width: 8rem;
    height: 3px;
    border-radius: var(--pl-radius-pill);
    background: var(--pl-color-border);
    overflow: hidden;
  }

  .boot__bar::after {
    content: "";
    position: absolute;
    inset: 0;
    width: calc(var(--blazor-load-percentage, 10%));
    border-radius: inherit;
    background: var(--pl-color-accent);
    transition: width var(--pl-duration-base) var(--pl-ease-standard);
  }

  #blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto var(--pl-space-4) var(--pl-space-4);
    z-index: var(--pl-z-toast);
    gap: var(--pl-space-3);
    align-items: center;
    padding: var(--pl-space-3) var(--pl-space-4);
    border: 1px solid var(--pl-color-danger-border);
    border-radius: var(--pl-radius-md);
    background: var(--pl-color-danger-bg);
    color: var(--pl-color-danger-text);
    box-shadow: var(--pl-shadow-lg);
    font-size: var(--pl-text-sm);
  }

  #blazor-error-ui .reload {
    margin-left: auto;
    font-weight: var(--pl-weight-bold);
    color: inherit;
  }

  .noscript {
    padding: var(--pl-space-6);
    text-align: center;
  }

  @keyframes boot-breathe {
    from {
      transform: translateY(0);
      opacity: 0.75;
    }

    to {
      transform: translateY(-4px);
      opacity: 1;
    }
  }
}

@layer utilities {
  .grid-span-all {
    grid-column: 1 / -1;
  }

  .visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }

  .skip-link {
    position: fixed;
    top: var(--pl-space-3);
    left: var(--pl-space-3);
    z-index: calc(var(--pl-z-tooltip) + 1);
    padding: var(--pl-space-2) var(--pl-space-4);
    border-radius: var(--pl-radius-md);
    background: var(--pl-color-accent);
    color: var(--pl-color-on-accent);
    font-weight: var(--pl-weight-semibold);
    text-decoration: none;
    transform: translateY(-200%);
    transition: transform var(--pl-duration-base) var(--pl-ease-standard);
  }

  .skip-link:focus-visible {
    transform: none;
  }

  .num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum", "cv11";
  }

  .muted {
    color: var(--pl-color-text-muted);
  }

  .mono {
    font-family: var(--pl-font-mono);
  }

  .nowrap {
    white-space: nowrap;
  }

  .truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .stack {
    display: flex;
    flex-direction: column;
    gap: var(--pl-space-4);
  }

  .stack--lg {
    gap: var(--pl-space-6);
  }

  .stack--sm {
    gap: var(--pl-space-2);
  }

  .cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--pl-space-3);
  }

  .cluster--end {
    justify-content: flex-end;
  }

  .cluster--between {
    justify-content: space-between;
  }

  .text-sm {
    font-size: var(--pl-text-sm);
  }

  .text-xs {
    font-size: var(--pl-text-xs);
  }

  .w-30 {
    width: 30%;
  }

  .w-40 {
    width: 40%;
  }

  .w-60 {
    width: 60%;
  }

  .w-70 {
    width: 70%;
  }

  .w-90 {
    width: 90%;
  }

  .positive {
    color: var(--pl-color-success-text);
  }

  .negative {
    color: var(--pl-color-danger-text);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Windows high contrast and other forced palettes: the system colours win; keep the outlines that carry meaning. */
@media (forced-colors: active) {
  :focus-visible {
    outline: 2px solid CanvasText;
  }

  .btn,
  .card,
  .input,
  .select,
  .badge,
  .alert,
  .dialog {
    border: 1px solid CanvasText;
  }

  .skeleton {
    background: GrayText;
  }
}
