/*
 * Bottom sheets rendered by app/views/ui/_sheet.html.erb: a modal <dialog>
 * that slides up from the bottom edge across the full width, for a short
 * list of actions on a phone. It closes by Escape, a tap on the backdrop or
 * a swipe down (sheet Stimulus controller), so it has no close button.
 *
 *   <a class="sheet__option" href="…">Add Note</a>
 *   <button class="sheet__option" data-variant="danger">Delete Note</button>
 */
@layer components {
  .sheet {
    inline-size: 100%;
    max-inline-size: none;
    margin-block-end: 0;
    padding: var(--space-3) var(--space-6) var(--space-8);
    background: var(--color-surface);
    color: var(--color-text);
    border: none;
    border-block-start: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
    box-shadow: var(--shadow-overlay);
    touch-action: none;

    &::backdrop { background: oklch(0% 0 0 / 0.5); }

    /* Only an open sheet lays out; a layout primitive on the dialog itself
       would override the browser's display: none and show it closed. */
    &[open] {
      display: flex;
      flex-direction: column;
      gap: var(--space-4);
      animation: sheet-slide-up var(--duration-base) ease-out;
    }
  }

  @keyframes sheet-slide-up {
    from { translate: 0 100%; }
  }

  /* The handle that invites a swipe */
  .sheet__handle {
    inline-size: 2rem;
    block-size: 0.25rem;
    margin-inline: auto;
    background: var(--color-border-strong);
    border-radius: var(--radius-full);
  }

  /* A sheet's title is a heading at whatever level the page needs, sized
     for the sheet rather than for its level. */
  .sheet__title { font-size: var(--text-lg); }

  /* One action in the sheet: a full-width row, whether it's a link or a
     button (button_to wraps it in a form, so it fills the form). */
  .sheet__option {
    --option-fg: var(--color-text);

    display: block;
    inline-size: 100%;
    padding: var(--space-4);
    background: var(--color-bg);
    color: var(--option-fg);
    border: none;
    border-radius: var(--radius-control);
    font-weight: 600;
    text-align: start;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--duration-fast), color var(--duration-fast);

    &:hover { background: var(--color-accent); color: var(--color-on-accent); }

    &[data-variant="danger"] {
      --option-fg: var(--color-danger);

      &:hover { background: var(--color-danger); color: var(--color-on-danger); }
    }
  }
}
