/* =========================================
   字幕アトリエ — word-replacement tab

   js/ui-filter.js: the two rule lists.

   Split out of styles.css. Everything stays inside @layer components:
   styles.css declares the layer order and must load first, and a rule
   left outside a layer would outrank every layered rule in the app.
   ========================================= */

@layer components {
  /* --- word-replacement tab: one list at a time under a head row. The
     section fills its tab panel and only the list itself scrolls, so the
     switch, the toggles and the add button always stay in reach. --- */
  .filter-section {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);

    .filter-list-wrap { flex: 1 1 auto; }
  }

  /* The switch at the left, the shown list's toggles at the right end, in the
     same spot whichever list is showing. */
  .filter-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-shrink: 0;
  }

  /* A dot after a segment's name while that list's feature is on: the other
     list's toggle is out of sight, and a mask left running should not be. */
  .filter-switch {
    label > span {
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }

    .seg-dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: var(--color-success);
    }
  }

  .filter-controls {
    display: flex;
    align-items: center;
    gap: var(--space-1);

    /* A second toggle stands apart from the first one's ⓘ. */
    .hint-btn + .filter-toggle { margin-left: var(--space-3); }
  }

  /* Label then switch, clicked as one. */
  .filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-md);
    color: var(--color-text);
    cursor: pointer;
    white-space: nowrap;
  }

  .hint-btn {
    width: 24px;
    height: 24px;
    color: var(--color-text-dim);

    svg { width: 14px; height: 14px; }
  }

  /* Above its ⓘ (the invoker is the implicit anchor), ending at its right
     edge — the toggles sit at the panel's right end, so the note grows
     leftward into the room there. */
  .hint-tip {
    position-area: top span-left;
    position-try-fallbacks: flip-inline;
    margin: var(--space-2) 0;
    max-width: min(360px, 80vw);
  }

  /* List + its add buttons: the list takes all the height the column leaves,
     so the buttons stay pinned to the panel floor — at the same height in both
     columns, and not moving as the panel is resized or rows are added. Once
     the list outgrows its space it scrolls. */
  .filter-list-wrap {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-height: 0;

    .filter-list { flex: 1 1 0; }
  }

  /* empty state — a quiet hint instead of a void */
  .filter-empty {
    margin: 0;
    padding: var(--space-3) 0;
    text-align: center;
    color: var(--color-text-faint);
    font-size: var(--text-sm);
  }

  /* --- word-replacement rule list --- */
  .filter-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-height: 0;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }

  .filter-row {
    display: grid;
    grid-template-columns: 1fr 16px 1fr 28px;
    align-items: center;
    gap: var(--space-1);

    .filter-arrow {
      color: var(--color-text-faint);
      font-size: var(--text-sm);
      text-align: center;
    }

    .text-input {
      padding: 3px 8px;
      font-size: var(--text-sm);
    }

    .icon-btn {
      width: 28px;
      height: 28px;

      svg { width: 14px; height: 14px; }
    }
  }

  .filter-add {
    width: 100%;
    justify-content: center;
    background: transparent;
    border: 1px dashed var(--color-border-strong);
    color: var(--color-text-dim);

    &:hover:not(:disabled) {
      border-color: var(--color-accent);
      color: var(--color-text);
      background: transparent;
    }
  }

  /* blacklist rows: single word input + delete (no replacement target) */
  .blacklist-row {
    grid-template-columns: 1fr 28px;
  }

  /* Words are short, so the list takes them several to a line rather than
     one per full-width row; the empty note spans them all. */
  .blacklist-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    align-content: start;
    column-gap: var(--space-3);

    .filter-empty { grid-column: 1 / -1; }
  }

  .blacklist-actions {
    display: flex;
    gap: var(--space-1);

    .filter-add { flex: 1; }
  }

  /* One mask for the whole column rather than a toggle per row: this panel can
     be on camera, and per-row eye buttons would be one mis-click per row. Same
     -webkit-text-security technique as .secret-input-wrap, and not
     type="password" for the same reason (see js/ui-secret-input.js).

     The delete buttons stay usable while masked — removing a word you cannot
     read is still the right thing to be able to do in a hurry. */
  .blacklist-mask[data-secret-visible="false"] .filter-source {
    -webkit-text-security: disc;
  }
}
