/* Design notes tab (index.html #ideas): category index, controls bar, grouped notes table.
   Tokens come from hub/hub.css :root. --ideas-top and --thead-h are set by hub/ideas.js. */

.ideas { --ideas-top: 0px; --thead-h: 41px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; align-items: start; }
@media (min-width: 1100px) {
  .ideas { grid-template-columns: 262px minmax(0, 1fr); }
}

/* Category index (left column, wide screens only) */
.ideas-side { display: none; position: sticky; top: calc(var(--ideas-top) + 20px); }
@media (min-width: 1100px) { .ideas-side { display: block; } }
.ideas-side h3 { margin: 4px 10px 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.ideas-side ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.ideas-side button {
  width: 100%; min-height: 40px; display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink); font-size: 14.5px; font-weight: 600;
  text-align: left; cursor: pointer; line-height: 1.25; transition: background-color var(--t-hover), color var(--t-hover);
}
.ideas-side button svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.ideas-side .ix-all { width: 18px; flex: none; }
.ideas-side .ix-label { flex: 1; min-width: 0; }
.ideas-side .ix-n { font-size: 14px; font-weight: 600; color: var(--faint); }
.ideas-side button:hover { background: var(--soft); }
.ideas-side button:active { background: var(--line); }
.ideas-side button[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); }
.ideas-side button[aria-pressed="true"] svg, .ideas-side button[aria-pressed="true"] .ix-n { color: var(--primary); }
.ideas-side button.zero { color: var(--faint); }
.ideas-side .ix-foot { margin: 14px 10px 0; font-size: 14px; color: var(--muted); }

/* Controls above the table */
.ideas-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 16px; margin-bottom: 14px; }
.ideas-bar .field.cat-pick { display: grid; }
@media (min-width: 1100px) { .ideas-bar .field.cat-pick { display: none; } }
.ideas-bar .field.sort-pick { display: none; }
.groupby { display: grid; gap: 4px; }
.groupby > span { font-size: 14px; font-weight: 600; color: var(--muted); }
.groupby .opts { display: flex; gap: 4px; padding: 4px; background: var(--soft); border-radius: var(--radius-sm); }
.groupby button { min-height: 36px; padding: 0 12px; border: 0; background: transparent; border-radius: calc(var(--radius-sm) - 4px); font-weight: 600; font-size: 14px; cursor: pointer; color: var(--muted); transition: transform var(--t-press) var(--ease-out), background-color var(--t-hover), color var(--t-hover); }
.groupby button:active { transform: scale(.98); }
.groupby button[aria-pressed="true"] { background: var(--bg); color: var(--ink); box-shadow: 0 1px 2px rgb(22 22 22 / 10%); }
.ideas-fold { margin-left: auto; min-height: 44px; padding: 0 4px; border: 0; background: none; font-size: 14px; font-weight: 600; color: var(--primary); cursor: pointer; }
.ideas-fold:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Shown while some notes are locked: one line instead of a note on every row */
.ideas-lock { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 10px; margin: 0 0 14px; font-size: 15px; color: var(--muted); }
.ideas-lock svg { width: 16px; height: 16px; flex: none; margin-top: 4px; color: var(--ink); }
.ideas-lock span { flex: 1 1 200px; }

/* The table */
.ntable { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 15px; }
.ntable thead th {
  position: sticky; top: var(--ideas-top); z-index: 3; background: var(--bg);
  border-bottom: 1px solid var(--line-strong); padding: 0; text-align: left;
  font-size: 14px; font-weight: 700; color: var(--muted); white-space: nowrap;
}
.ntable thead th > button, .ntable thead th > span:not(.sr-only) {
  display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 12px;
  border: 0; background: none; font: inherit; color: inherit; cursor: pointer;
}
.ntable thead th > button:hover { color: var(--ink); }
.ntable thead th > button::after { content: ""; width: 10px; height: 10px; opacity: 0; transition: opacity var(--t-hover);
  background: currentColor; clip-path: polygon(50% 20%, 90% 75%, 10% 75%); }
.ntable thead th > button:hover::after { opacity: .35; }
.ntable th[aria-sort] > button { color: var(--ink); }
.ntable th[aria-sort] > button::after { opacity: 1; }
.ntable th[aria-sort="descending"] > button::after { transform: rotate(180deg); }
.ntable .c-open { width: 104px; text-align: right; }
.ntable .c-cat { width: 196px; }
.ntable .c-dash { width: 196px; }
.ntable .c-screen { width: 176px; }

/* Group header rows: pinned under the column headers while their group scrolls */
.ntable .g-row th { position: sticky; top: calc(var(--ideas-top) + var(--thead-h)); z-index: 2; padding: 0; background: var(--bg); text-align: left; }
.g-toggle {
  width: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; min-height: 44px; padding: 6px 12px 6px 6px;
  border: 0; border-bottom: 1px solid var(--line); background: var(--soft); color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
tbody.g + tbody.g .g-toggle { border-top: 12px solid var(--bg); }
.g-toggle:hover { background: #efeff5; }
.g-chev { display: inline-flex; width: 22px; justify-content: center; transition: transform var(--t-hover) var(--ease-out); }
.g-chev svg { width: 16px; height: 16px; color: var(--muted); }
.g-toggle[aria-expanded="false"] .g-chev { transform: rotate(-90deg); }
.g-name { font-size: 16px; font-weight: 700; }
.g-count { font-size: 14px; font-weight: 600; color: var(--faint); }
.g-sub { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 4px; }
tbody.collapsed .n-row { display: none; }

/* Note rows */
.n-row td { padding: 12px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.n-row:hover td { background: #fbfbfd; }
.c-note { min-width: 0; }
.n-title { display: block; font-size: 16px; font-weight: 700; line-height: 1.35; text-decoration: none; color: var(--ink); }
.n-title:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.n-why { display: block; width: 100%; margin: 3px 0 0; padding: 0; border: 0; background: none; text-align: left; font: inherit; font-size: 14.5px; line-height: 1.5; color: var(--muted); cursor: pointer; }
.n-why span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; line-clamp: 1; overflow: hidden; }
.n-why[aria-expanded="true"] span { display: block; color: #45454c; }
.n-why:hover span { color: var(--ink); }

.cat { font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.d-ind { display: block; font-size: 14px; font-weight: 600; line-height: 1.35; }
.d-co { display: block; font-size: 14px; color: var(--muted); line-height: 1.35; }
.c-screen { font-size: 14px; color: var(--muted); line-height: 1.35; }
.c-screen .dash { color: var(--faint); }
.n-open {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; color: var(--ink);
  transition: transform var(--t-press) var(--ease-out), background-color var(--t-hover), border-color var(--t-hover), color var(--t-hover);
}
.n-open:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.n-open:active { transform: scale(.98); }
.n-open svg { width: 15px; height: 15px; }
.ntable mark { background: #fff0b8; color: inherit; border-radius: 3px; padding: 0 1px; }

/* A column is dropped when the grouping already says it */
.ntable[data-group="category"] .c-cat { display: none; }
.ntable[data-group="dashboard"] .c-dash { display: none; }
.ntable[data-one-cat] .c-cat { display: none; }

/* Load more (the table renders in steps of 40 while scrolling) */
.ideas-more { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px; padding: 20px 0 4px; font-size: 14px; color: var(--muted); }
.ideas-more .btn { min-height: 40px; font-size: 14px; }
.ideas-end { height: 1px; }

/* Mid widths: the screen column folds under the dashboard */
@media (max-width: 960px) and (min-width: 721px) {
  .ntable .c-screen { display: none; }
  .ntable .c-cat, .ntable .c-dash { width: 168px; }
}

/* Phones: the table becomes a list with the same groups; no sideways scroll */
@media (max-width: 720px) {
  .ideas-bar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
  .ideas-bar .field.cat-pick, .ideas-bar .groupby { grid-column: 1 / -1; }
  .ideas-bar .field.sort-pick { order: 2; }
  .ideas-bar .ideas-fold { order: 3; justify-self: end; align-self: end; }
  .ideas-bar .field.sort-pick { display: grid; }
  .ideas-bar .field select { width: 100%; }
  .groupby .opts button { flex: 1; min-height: 40px; }
  .ideas-fold { margin-left: 0; text-align: right; }
  .ntable, .ntable tbody, .ntable tr, .ntable th, .ntable td { display: block; }
  .ntable thead { display: none; }
  .ntable .g-row { position: sticky; top: var(--ideas-top); z-index: 2; }
  .ntable .g-row th { position: static; }
  .g-toggle { min-height: 52px; padding: 10px 8px 10px 2px; }
  tbody.g + tbody.g .g-toggle { border-top-width: 16px; }
  .g-sub { display: none; }
  .ntable .n-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .n-row td { padding: 0; border: 0; background: none !important; }
  .n-row .c-note { flex: 1 1 100%; margin-bottom: 8px; }
  .n-title { font-size: 17px; }
  .n-why { font-size: 15px; min-height: 44px; }
  .n-why span { -webkit-line-clamp: 2; line-clamp: 2; }
  .n-row .c-cat, .n-row .c-dash, .n-row .c-screen { width: auto; font-size: 14px; color: var(--muted); }
  .n-row .c-cat .cat { font-weight: 600; color: var(--muted); }
  .n-row .d-co { display: none; }
  .n-row .d-ind { font-weight: 600; color: var(--muted); }
  .n-row .c-dash::before, .n-row .c-screen::before { content: "\00b7"; margin: 0 7px; color: var(--faint); }
  .ntable[data-group="category"] .n-row .c-dash::before, .ntable[data-one-cat] .n-row .c-dash::before { content: none; }
  .ntable[data-one-cat][data-group="dashboard"] .n-row .c-screen::before { content: none; }
  .n-row .c-screen { flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
  .n-row .c-open { width: auto; margin-left: auto; padding-left: 8px; }
  .n-open { min-height: 44px; }
}
