/* Ideas: the top list and the topic groups, each idea's row and menu,
   and the instructions form. */
@layer views {
  /* Ideas: the top list, then the topic groups, in the Feed's centered
     reading column. */
  .ideas-page {
    flex: 1;
    min-height: 0;
    padding: var(--page-top) var(--page-x) 136px;
    overflow: auto;
  }

  .ideas-page > * {
    width: 100%;
    max-width: var(--column);
    margin-left: auto;
    margin-right: auto;
  }

  /* As in Feed Settings on a phone, put the sticky heading on an opaque
     surface so the settings rows disappear as they scroll behind it. */
  .ideas-page:has(> #ideas-instructions:not([hidden])) > .view-head {
    transition-property: padding, min-height;

    &.is-compact {
      background-color: var(--paper);
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }
  }

  /* The instructions form, which Todo's add form shares. In the views layer, since chat.css's phone .composer padding
     would beat them from the components layer. */
  .composer.ideas-instructions-composer,
  .composer.todo-add-composer {
    margin: 16px auto 32px;
    padding: 0 0 24px;
    border-top: 0;
    border-bottom: 1px solid var(--line);
  }
  .composer.ideas-instructions-composer { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
    .todo-add-composer .composer-input { display: block; width: 100%; }
    .todo-add-actions { margin-top: 8px; }

  .ideas-top + .ideas-topic,
  .ideas-topic + .ideas-topic { margin-top: 36px; }
  .ideas-topic-title { margin: 0 0 18px; }
  .ideas-item {
    position: relative;
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    margin: 0 -12px;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
  }
  .ideas-item + .ideas-item { margin-top: 2px; }
  .ideas-item:hover,
  .ideas-item:focus-visible,
  .ideas-item:focus-within { background: var(--hover-tint); }
  .ideas-item:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
  .ideas-shape-icon { margin-top: 1px; color: var(--ink-soft); }
  .ideas-shape-icon[data-ideas-shape="offer"] { color: var(--badge-0); }
  .ideas-content { min-width: 0; }
  .ideas-title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }
  .ideas-text {
    margin-top: 6px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }
  .ideas-text > :first-child { margin-top: 0; }
  .ideas-text > :last-child { margin-bottom: 0; }
  /* A table in the two-line card shows its first rows as lines of text,
     cropped at the edge. The line clamp does not reach into table cells. */
  .ideas-text:has(> .md-table) { display: block; max-height: 3em; }
  .ideas-text.markdown .md-table { overflow: hidden; margin-top: 0; }
  .ideas-text .md-table thead { display: none; }
  .ideas-text .md-table :is(th, td) { padding-block: 0; border-bottom: 0; white-space: nowrap; }
  .ideas-meta {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 13px;
    overflow-wrap: anywhere;
  }
  .ideas-meta a { color: inherit; }
  .ideas-row-buttons {
    display: flex;
    align-items: center;
    margin: -10px -10px 0 0;
  }
  .ideas-save-toggle,
  .ideas-menu-toggle,
  .ideas-feedback-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: none;
    color: var(--muted);
    cursor: pointer;
  }
  .ideas-menu-toggle svg { fill: currentColor; stroke: none; }
  :is(.ideas-save-toggle, .ideas-menu-toggle, .ideas-feedback-button):hover { background: var(--hover-tint); color: var(--ink); }
  :is(.ideas-save-toggle, .ideas-feedback-button):disabled { cursor: default; }
  .ideas-menu {
    top: 48px;
    right: 8px;
    width: 176px;
    z-index: 7;
  }
  .ideas-action { text-align: left; }
  .ideas-action:disabled { cursor: default; opacity: 0.5; }
  .ideas-reason {
    grid-column: 2 / -1;
    margin: 0;
    color: var(--red);
    font-size: 13px;
  }

  /* An open idea (ideas.js): the overlay a chat's document opens
     (artifact-overlay, on brief.css's overlay and sheet), centered on a
     desk and sized to the idea, above quick chat's pane and button. Close
     sits at the title's right, on its first line. The foot is sticky at
     the sheet's bottom, with the row's bookmark, its ⋯ (the shared row
     menu, opening upward), and the one button that moves the idea on. */
  .brief-overlay.ideas-overlay { z-index: 26; align-items: center; }
  .brief-sheet.ideas-sheet {
    display: flex;
    flex-direction: column;
    max-width: 640px;
    min-height: min(400px, 100%);
    padding-bottom: 0;
  }
  .ideas-sheet > * { flex-shrink: 0; }
  .ideas-detail { padding: 28px 0 32px; }
  .ideas-detail-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
  }
  .ideas-detail-head .ideas-shape-icon { flex: none; margin-top: 10px; }
  .ideas-detail-head .open-title { margin-top: 6px; }
  /* Centered on the title's first line (6px above it, half its 31.2px
     line), its right edge on the foot's Start. */
  .ideas-detail-close { flex: none; margin: calc(21.6px - var(--control-height) / 2) -24px 0 8px; }
  .ideas-detail-meta { margin: 6px 0 0 36px; }
  .ideas-detail-meta .ideas-meta { margin: 2px 0 0; font-size: 14px; }
  .ideas-detail-text,
  .ideas-detail-section {
    margin-top: 20px;
    color: var(--ink);
    font-size: 16px;
    line-height: 1.6;
    overflow-wrap: anywhere;
  }
  .ideas-detail-text > :first-child { margin-top: 0; }
  .ideas-detail-text > :last-child { margin-bottom: 0; }
  .ideas-detail-section h3 {
    margin: 0 0 6px;
    font: 600 20px/1.3 var(--serif);
  }
  .ideas-detail-section p { margin: 0; white-space: pre-line; }
  .ideas-detail-section p + p { margin-top: 6px; }
  .ideas-detail-reason { margin-top: 16px; }
  .ideas-detail-reason[hidden] { display: none; }
  .ideas-detail-foot {
    position: sticky;
    bottom: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin: auto -40px 0;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
    background: var(--paper);
  }
  .ideas-detail-foot .row-more { opacity: 1; }
  .ideas-detail-foot .row-menu-wrap { margin: 0; }
  .ideas-detail-foot .row-menu { top: auto; bottom: 48px; width: 224px; }
  .ideas-detail-primary {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    text-decoration: none;
  }

  @media (max-width: 719.98px) {
    /* The actions drop under the entry, in their own row below the title and
       text, the way the Feed's actions sit at the foot of each post; the
       title and text then span the card's full width. */
    .ideas-item {
      grid-template-columns: 24px minmax(0, 1fr);
      margin-right: -8px;
      margin-left: -8px;
      padding-right: 8px;
      padding-left: 8px;
    }
    .ideas-row-buttons {
      grid-column: 2 / -1;
      margin: 10px 0 0;
      justify-content: flex-start;
      gap: 4px;
    }

    /* The menu drops from the band across the phone's width. It sits here,
       after .ideas-menu above and before the rule below, because the Ideas
       menu carries .app-menu too: these win over its desk rule, and its
       phone rule wins over these. */
    .app-menu {
      position: fixed;
      top: calc(var(--controls-h) + 4px);
      right: 12px;
      left: 12px;
      width: auto;
      max-height: calc(100dvh - 130px);
      overflow: auto;
    }

    /* The menu is already a fixed sheet off the band on a phone (.app-menu
       above), so moving the row that holds its toggle does not move it. */
    .ideas-menu { right: 4px; max-width: calc(100vw - 32px); }

    /* The open idea fills the screen, as the brief does; its foot clears
       the home indicator, and its menu opens over the text from the
       sheet's right edge. */
    .brief-sheet.ideas-sheet { min-height: 0; padding-bottom: 0; }
    .ideas-detail { padding-top: max(16px, env(safe-area-inset-top)); }
    .ideas-detail-close { margin-right: 0; }
    .ideas-detail-foot {
      margin: auto -16px 0;
      padding: 12px 16px max(12px, env(safe-area-inset-bottom));
    }
    .ideas-detail-foot .row-menu { right: 0; max-width: calc(100vw - 32px); }
  }
}

@layer views { .ideas-lifecycle { color: var(--ink-soft); } @media (min-width: 720px) { .ideas-menu { width: 224px; } } }
