@layer components {
  /* -------------- Demo Skeleton -------------- */
  /* --------------
  Temporary demo styles. Empty cards stand in for charts while data loads, sitting
  at the page's own background and pulsing one step away from it: darker in light
  mode and lighter in dark mode, so they barely show against the page.
  -------------- */
  .demo-skeleton {
    background-color: var(--nn-color-level-0);
    animation: demo-skeleton-pulse var(--nn-anima-time-1200ms)
      var(--nn-anima-ease-in-out) infinite alternate;
  }

  @keyframes demo-skeleton-pulse {
    to {
      background-color: light-dark(var(--nn-neutral-20), var(--nn-neutral-90));
    }
  }

  /* -------------- Demo Loader -------------- */
  /* --------------
  Temporary demo styles. The loader fades in when it arrives and out before it
  leaves, and the three parts of the Pantacosm mark each turn around the mark's
  center at their own speed, the middle ring the opposite way.
  -------------- */
  .demo-loader {
    opacity: 1;
    transition: opacity var(--nn-anima-time-400ms) var(--nn-anima-ease-out);
  }

  @starting-style {
    .demo-loader {
      opacity: 0;
    }
  }

  .demo-loader--leaving {
    opacity: 0;
  }

  .demo-loader__outer,
  .demo-loader__middle,
  .demo-loader__inner {
    transform-box: view-box;
    transform-origin: 36px 40px;
    animation: demo-loader-turn linear infinite;
  }

  .demo-loader__outer {
    animation-duration: 6s;
  }

  .demo-loader__middle {
    animation-duration: 3s;
    animation-direction: reverse;
  }

  .demo-loader__inner {
    animation-duration: 1.5s;
  }

  @keyframes demo-loader-turn {
    to {
      rotate: 360deg;
    }
  }

  /* -------------- Demo Series Toggle -------------- */
  /* --------------
  Temporary demo styles. A legend's series checkboxes are North Node's checkbox
  made smaller, with the box outlined and filled in the series' own color, so
  the legend doubles as the key and the control.
  -------------- */
  .demo-series-toggle .nn-field-checkbox__control {
    min-block-size: var(--nn-space-4x6);
  }

  .demo-series-toggle .nn-field-checkbox__input,
  .demo-series-toggle .nn-field-checkbox__mark {
    inline-size: var(--nn-space-4x4);
    block-size: var(--nn-space-4x4);
  }

  .demo-series-toggle .nn-field-checkbox__input {
    border-color: var(--demo-series-color);
    --nn-anima-color-var1: var(--demo-series-color);
  }

  .demo-series-toggle .nn-field-checkbox__mark {
    background: var(--nn-color-typo-on-fill);
    mask-size: 75%;
  }

  .demo-series-toggle .nn-field-checkbox__label {
    font-size: var(--nn-typo-details-size);
    color: var(--nn-color-typo-secondary);
  }

  /* -------------- Demo Card Grid -------------- */
  /* --------------
  Temporary demo styles for the flow grid. Hovering a card rings it the way a
  desk work item is ringed, on the card's own edge, in the brand's 50 step;
  hovering its right or bottom edge, or dragging one, takes the selection's
  stronger ring, and the ghost of the new size is that ring with the inside
  tinted at 20%. The edges reach a few pixels past the line on either side so
  they are easy to catch, and the right edge goes away where every card takes
  the full width. A card's tools stay out of the way until it is hovered or
  focused, and a card whose menu is open sits over its neighbors. The spot a
  card or report would land in is outlined in the accent, a card being
  dragged floats over the page, and a report or version in a panel's list
  shows it can be picked up. A selected card takes the desk's stronger
  selection ring, with nothing tinting its inside so it stays easy to read. A card just added
  pulses the hover ring twice, softly, then rests, and a panel whose subject
  has just switched tints once in the selection color.
  -------------- */
  .demo-grid-card {
    --demo-grid-selection: light-dark(var(--nn-brand-70), var(--nn-brand-30));

    outline: var(--nn-border-width-strong) solid transparent;
    outline-offset: 0;
    transition: outline-color var(--nn-anima-time-150ms)
      var(--nn-anima-ease-out);
  }

  .demo-grid-card:is(:hover, :focus-within) {
    outline-color: var(--nn-brand-50);
  }

  .demo-grid-card:has(.demo-grid-edge:hover),
  .demo-grid-card.demo-grid-resizing,
  .demo-grid-card[data-demo-selected] {
    outline-color: var(--demo-grid-selection);
  }

  .demo-switched {
    animation: demo-switched var(--nn-anima-time-700ms)
      var(--nn-anima-ease-in-out);
  }

  @keyframes demo-switched {
    30% {
      background-color: color-mix(
        in srgb,
        light-dark(var(--nn-brand-70), var(--nn-brand-30)) 20%,
        transparent
      );
    }
  }

  .demo-grid-card.demo-grid-arriving {
    animation: demo-grid-arrive var(--nn-anima-time-1200ms)
      var(--nn-anima-ease-in-out);
  }

  @keyframes demo-grid-arrive {
    25%,
    75% {
      outline-color: var(--nn-brand-50);
    }

    0%,
    50%,
    100% {
      outline-color: transparent;
    }
  }

  .demo-grid-card:has([aria-expanded="true"]) {
    z-index: var(--nn-z-raised);
  }

  .demo-grid-edge {
    position: absolute;
    z-index: var(--nn-z-raised);
    touch-action: none;
  }

  .demo-grid-edge--columns {
    inset-block: 0;
    inset-inline-end: calc(var(--nn-space-4x1) * -1);
    inline-size: var(--nn-space-4x2);
    cursor: ew-resize;
  }

  .demo-grid-edge--rows {
    inset-inline: 0;
    inset-block-end: calc(var(--nn-space-4x1) * -1);
    block-size: var(--nn-space-4x2);
    cursor: ns-resize;
  }

  .demo-flow--stacked .demo-grid-edge--columns {
    display: none;
  }

  .demo-grid-ghost {
    --demo-grid-selection: light-dark(var(--nn-brand-70), var(--nn-brand-30));

    position: absolute;
    z-index: var(--nn-z-raised);
    pointer-events: none;
    outline: var(--nn-border-width-strong) solid var(--demo-grid-selection);
    background-color: color-mix(in srgb, var(--demo-grid-selection) 20%,
      transparent);
  }

  .demo-grid-tools {
    position: absolute;
    inset-block-start: var(--nn-space-4x2);
    inset-inline-end: var(--nn-space-4x2);
    z-index: var(--nn-z-raised);
    opacity: 0;
    transition: opacity var(--nn-anima-time-150ms) var(--nn-anima-ease-out);
  }

  .demo-grid-card:is(:hover, :focus-within) .demo-grid-tools,
  .demo-grid-tools:has([aria-pressed="true"], [aria-expanded="true"]) {
    opacity: 1;
  }

  .demo-grid-handle {
    cursor: grab;
  }

  .demo-grid-placeholder {
    border: var(--nn-border-width-strong) dashed var(--nn-color-accent);
    background: var(--nn-color-accent-surface);
  }

  .demo-report-item[draggable="true"] {
    cursor: grab;
  }

  .demo-grid-dragging {
    z-index: var(--nn-z-sticky);
    pointer-events: none;
    opacity: 0.9;
    cursor: grabbing;
  }

  .demo-visually-hidden {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* -------------- Demo Dense Table -------------- */
  /* --------------
  Temporary demo styles. A table packed tighter than North Node's table for
  scanning many learners at once: short rows, light rules between them, a header
  row that stays in view while the card scrolls, and no wrapping so columns keep
  their shape.
  -------------- */
  .demo-table {
    inline-size: max-content;
    min-inline-size: 100%;
    border-collapse: separate;
    border-spacing: 0;
  }

  .demo-table :is(th, td) {
    padding-block: var(--nn-space-4x1);
    padding-inline: var(--nn-space-4x2);
    border-block-end: var(--nn-border-width) solid
      var(--nn-color-border-subtle);
    text-align: start;
    white-space: nowrap;
  }

  .demo-table thead th {
    position: sticky;
    inset-block-start: 0;
    background: var(--nn-color-level-1);
    border-block-end-color: var(--nn-color-border);
  }

  .demo-table tbody tr:hover {
    background: var(--nn-color-state-hover);
  }

  @media (prefers-reduced-motion: reduce) {
    .demo-skeleton,
    .demo-loader__outer,
    .demo-loader__middle,
    .demo-loader__inner {
      animation: none;
    }

    .demo-loader,
    .demo-grid-card,
    .demo-grid-tools {
      transition-duration: var(--nn-anima-time-0ms);
    }

    .demo-grid-card.demo-grid-arriving,
    .demo-switched {
      animation: none;
    }
  }
}
