/* Lineup filter sheet (spec §4.4).
 *
 * Native <dialog> styled as a bottom sheet: slides up from the bottom
 * edge, leaves ~80px of the dimmed Lineup list peeking at the top. All
 * dismiss affordances (drag handle, X button, backdrop tap) are wired
 * through the filter_sheet controller.
 */

@layer components {
  /* ── Sheet container ─────────────────────────────────────────────── */

  .filter-sheet {
    inline-size: 100%;
    max-inline-size: 100%;
    max-block-size: calc(100dvh - 5rem);
    margin-block: auto 0;
    padding: 0;
    background: var(--color-surface);
    border: 0;
    border-start-start-radius: var(--radius-xl);
    border-start-end-radius: var(--radius-xl);
    color: var(--color-ink);
    box-shadow: 0 -12px 32px -12px oklch(0% 0 0 / 0.45);

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

    /* On wide screens, cap the sheet so chips and the close button
     * don't hug both edges of the viewport. Mobile keeps full-bleed. */
    @media (width >= 56rem) {
      max-inline-size: 36rem;
      margin-inline: auto;
    }
  }

  /* Slide-up entrance via @starting-style (matches the rest of the
   * codebase). Respects prefers-reduced-motion. */
  @media (prefers-reduced-motion: no-preference) {
    .filter-sheet[open] {
      transition: translate 220ms ease-out, opacity 220ms ease-out;
      @starting-style { translate: 0 12%; opacity: 0; }
    }
  }

  .filter-sheet__form {
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    max-block-size: calc(100dvh - 5rem);
    padding: 0 var(--inline-space) var(--block-space);
  }

  /* ── Drag handle + header ────────────────────────────────────────── */

  .filter-sheet__handle {
    justify-self: center;
    inline-size: 36px;
    block-size: 4px;
    margin-block: 0.5rem 0.75rem;
    background: var(--color-border);
    border-radius: var(--radius-pill);
  }

  .filter-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-block-end: var(--block-space-s);
  }

  .filter-sheet__title {
    font-family: "Outfit", system-ui, sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-ink);
    margin: 0;
  }

  .filter-sheet__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: var(--touch-min);
    block-size: var(--touch-min);
    background: transparent;
    border: 0;
    color: var(--color-ink-muted);
    border-radius: var(--radius);
    cursor: pointer;

    &:hover { color: var(--color-ink); }

    &:focus-visible {
      outline: 2px solid oklch(var(--lch-flare));
      outline-offset: 1px;
    }
  }

  /* ── Sections ────────────────────────────────────────────────────── */

  .filter-sheet__section {
    padding-block: var(--block-space-s);
    border-block-end: 0.5px solid var(--color-border);

    &:last-of-type { border-block-end: 0; }
  }

  .filter-sheet__overline {
    font-family: "Outfit", system-ui, sans-serif;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--color-ink-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-block-end: var(--block-space-s);
  }

  .filter-sheet__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
  }

  /* ── Multi-select chip ───────────────────────────────────────────── */

  .chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3125rem 0.6875rem;
    background: transparent;
    border: 0.5px solid var(--color-border);
    border-radius: var(--radius-pill);
    font-size: 0.8125rem;
    color: var(--color-ink);
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;

    & input[type="checkbox"] {
      position: absolute;
      opacity: 0;
      pointer-events: none;
    }

    &:hover { border-color: var(--color-ink-muted); }

    &:has(input:focus-visible) {
      outline: 2px solid oklch(var(--lch-flare));
      outline-offset: 2px;
    }

    &:has(input:checked) {
      background: oklch(var(--lch-sky));
      border-color: oklch(var(--lch-sky));
      color: var(--color-canvas);
    }

    &:not(:has(input:checked)) .chip__check {
      display: none;
    }
  }

  .chip__check {
    font-size: 0.8125rem;
    font-weight: 700;
  }

  /* ── Toggle rows ─────────────────────────────────────────────────── */

  .filter-sheet__toggles {
    display: flex;
    flex-direction: column;
    border: 0.5px solid var(--color-border);
    border-radius: var(--radius);

    & .toggle-row + .toggle-row {
      border-block-start: 0.5px solid var(--color-border);
    }
  }

  .toggle-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    cursor: pointer;

    & input[type="checkbox"] {
      accent-color: oklch(var(--lch-sky));
      inline-size: 1.125rem;
      block-size: 1.125rem;
    }
  }

  .toggle-row__text {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
  }

  .toggle-row__title {
    font-size: 0.875rem;
    font-weight: 500;
  }

  .toggle-row__hint {
    font-size: 0.8125rem;
    color: var(--color-ink-muted);
  }

  /* ── Footer ──────────────────────────────────────────────────────── */

  .filter-sheet__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--inline-space);
    padding-block-start: var(--block-space-s);
    border-block-start: 0.5px solid var(--color-border);
  }

  .filter-sheet__reset {
    background: transparent;
    border: 0;
    color: var(--color-ink-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    padding-inline: var(--inline-space-s);
    min-block-size: var(--touch-min);
    text-decoration: underline;
    text-underline-offset: 0.2em;
    text-decoration-color: color-mix(in oklch, var(--color-ink-muted) 40%, transparent);

    &:hover {
      color: var(--color-ink);
      text-decoration-color: var(--color-ink);
    }
  }

  .filter-sheet__submit {
    flex: 1 1 auto;
  }

  /* ── Toolbar filter badge ────────────────────────────────────────── */

  .lineup-toolbar__btn--filter {
    position: relative;
  }

  .lineup-toolbar__badge {
    position: absolute;
    inset-block-start: -4px;
    inset-inline-end: -4px;
    min-inline-size: 1rem;
    block-size: 1rem;
    padding: 0 0.25rem;
    background: oklch(var(--lch-flare));
    color: var(--color-canvas);
    font-size: 0.6875rem;
    font-weight: 700;
    border-radius: var(--radius-pill);
    display: inline-flex;
    align-items: center;
    justify-content: center;

    &[hidden] { display: none; }
  }
}
