/* Page chrome for a mixing desk around an embedded terminal.

   Everything lands in the `overrides` layer the shipped stylesheet declares and leaves empty,
   so these rules win by position rather than by specificity (PC-5), and every value comes
   from the tokens the page already ships (PC-1). Separation is the container's (PC-2): there
   is no margin on a child and no `:last-child` undoing one. */

@layer overrides {
  /* This layout's own tokens. The shipped table has no "how tall is an embedded terminal"
     or "how wide is a level name" entry, because neither is a property of the design system
     - so they are bound here, once, and consumed by name below (PC-1). */
  :root {
    --desk-terminal-block-size: 20rem;
    --desk-column-min-inline-size: 22rem;
    --desk-label-inline-size: 4.5rem;
    --desk-readout-inline-size: 2.5rem;
  }

  .article {
    display: block;
    background: var(--color-surface);
    block-size: auto;
    min-block-size: 100dvb;
    padding-block: var(--space-5);
    padding-inline: var(--space-4);
  }

  .prose {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    inline-size: min(var(--measure), 100%);
    margin-inline: auto;
  }

  .prose h1 {
    font-family: var(--font-display);
    font-size: var(--text-3);
    line-height: var(--line-tight);
  }

  .prose h2 {
    font-family: var(--font-display);
    font-size: var(--text-2);
  }

  .prose pre {
    background: var(--color-terminal-bg);
    border-radius: var(--radius-1);
    color: var(--color-ink-dim);
    font-family: var(--font-terminal);
    font-size: var(--text-1);
    overflow: auto;
    padding: var(--space-3);
  }

  /* Terminal and desk side by side when there is room for both, stacked when there is not -
     stated as a minimum column width rather than as a breakpoint, so the arrangement follows
     the space actually available to it (PC-7). */
  .embed {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--desk-column-min-inline-size), 1fr));
    gap: var(--space-3);
  }

  /* A character grid needs a real block size to measure against; `auto` collapses it to
     nothing. The decoration is on the frame because `FitAddon` sizes the grid from the
     mount's parent box, and padding on the mount is counted as room for text. */
  .embed .terminal-frame {
    block-size: var(--desk-terminal-block-size);
    border: var(--space-1) solid var(--color-edge);
    border-radius: var(--radius-2);
    padding: var(--space-3);
  }

  .desk {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
  }

  .levels {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    border: var(--space-1) solid var(--color-edge);
    border-radius: var(--radius-2);
    padding: var(--space-3);
  }

  .levels legend {
    color: var(--color-ink-dim);
    font-size: var(--text-1);
    padding-inline: var(--space-2);
  }

  .level {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  .level-name {
    font-family: var(--font-terminal);
    font-size: var(--text-1);
    inline-size: var(--desk-label-inline-size);
  }

  .level input {
    flex: 1;
    min-inline-size: 0;
  }

  /* Tinting the slider is an enhancement, and Safari only reached `accent-color` in 26.2 -
     so it is asked for rather than assumed (PC-9). Without it the control renders in the
     platform's own accent, which is correct, just not this page's blue. */
  @supports (accent-color: currentcolor) {
    .level input {
      accent-color: var(--color-brand);
    }
  }

  .level output {
    color: var(--color-ink-dim);
    font-family: var(--font-terminal);
    font-size: var(--text-1);
    inline-size: var(--desk-readout-inline-size);
    text-align: end;
  }

  /* Closed variance: the two states are enumerated and each rebinds one private custom
     property, so a third state is a new entry rather than an override (PC-3). Selected by a
     `data-state` the DOM already carries (PC-6). */
  .clipping {
    --_clip-ink: var(--color-ink-dim);

    border-inline-start: var(--space-1) solid var(--_clip-ink);
    color: var(--_clip-ink);
    font-family: var(--font-terminal);
    font-size: var(--text-1);
    padding-inline-start: var(--space-3);
  }

  .clipping[data-state="hot"] {
    --_clip-ink: var(--color-warn);
  }

  .note {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    font-size: var(--text-1);
  }

  .note input {
    background: transparent;
    border: var(--space-1) solid var(--color-edge);
    border-radius: var(--radius-1);
    color: var(--color-ink);
    font: inherit;
    padding-block: var(--space-2);
    padding-inline: var(--space-3);
  }

  .note input:focus-visible {
    border-color: var(--color-brand);
  }

  /* In the flow here rather than pinned to a corner: this page has content of its own, and a
     floating overlay would sit on top of it. */
  .article .status {
    position: static;
  }
}
