@layer layout {
  .stage {
    --stage-max: 650px;
    /* this demo reacts to a custom-property VALUE, not the container's size — the drag
       handle every other demo relies on would be a dead, misleading affordance here */
    resize: none;
  }
}

@layer components {
  .toggle-input {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;

    &:checked ~ .toggle-label::before {
      background: var(--color-accent);
    }

    /* the real checkbox is visually hidden, so its focus ring has to be forwarded to the label */
    &:focus-visible ~ .toggle-label {
      outline: 2px solid var(--color-text);
      outline-offset: 2px;
    }

    &:checked ~ .panel {
      --variant: accent;
    }
  }

  .toggle-label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-5);
    margin-block-end: var(--space-10);
    padding-block: var(--space-5);
    padding-inline: var(--space-9);
    border-radius: var(--radius-full);
    background: var(--color-surface-2);
    color: var(--color-text);
    cursor: pointer;
    user-select: none;

    &::before {
      content: "";
      inline-size: var(--space-9);
      block-size: var(--space-9);
      border-radius: 50%;
      background: var(--color-border);
    }
  }

  .panel {
    /* container-type isn't required for style queries (only size queries need containment) —
       set explicitly anyway so the query container is unambiguous */
    container-type: normal;
    container-name: panel;
    --variant: default;
    padding: var(--space-13);
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-l);

    p {
      color: var(--color-muted);
      margin-block-start: var(--space-10);
    }

    /* queries the container's --variant VALUE, not its width — a completely different axis
       from every @container rule elsewhere in this lab */
    @container panel style(--variant: accent) {
      .badge {
        background: var(--color-accent);
        color: var(--color-bg);
        border-radius: var(--radius-full);
      }
    }
  }

  .badge {
    display: inline-block;
    padding-block: var(--space-3);
    padding-inline: var(--space-7);
    border-radius: var(--radius-xs);
    background: var(--color-surface-2);
    border: 1px solid transparent;
    font-size: .85rem;
  }
}
