/* Board sub-views: archive, recycle bin (BIN-4, BIN-8) and wiki (WIKI-1, WIKI-2). They look
   like the board (BRD-6): its header on its background, the content in column-like panels and
   rows that look like cards. */

a.board-title {
  color: inherit;
  text-decoration: none;
}

a.board-title:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
}

/* The current view's button stands out like a column on the board. */
.board-head__tabs .btn--glass[aria-current="page"] {
  border-color: transparent;
  background: var(--column-bg);
  color: var(--column-text);
}

.board-head__tabs .btn--glass[aria-current="page"] .count {
  background: rgb(0 0 0 / 0.07);
}

/* The board screen doesn't scroll (its columns do); these views scroll as a whole. */
.sub-view {
  position: relative; /* contains absolutely positioned bits (hidden labels, checkboxes) */
  height: 100%;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.sub-board {
  padding: 2px calc(var(--space-4) + var(--safe-right)) calc(var(--space-6) + var(--safe-bottom))
    calc(var(--space-4) + var(--safe-left));
}

.sub-panel {
  max-width: 1120px;
  border: 1px solid var(--column-edge);
  border-radius: var(--radius-lg);
  background: var(--column-bg);
  color: var(--column-text);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}

.sub-panel__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 2px;
}

.sub-panel__head > .icon {
  color: var(--ink-subtle);
}

.sub-panel__title {
  margin: 0;
  font-size: var(--text-md);
  font-weight: 700;
  line-height: 1.3;
}

.sub-panel__head .count {
  background: rgb(0 0 0 / 0.07);
}

.sub-panel__body {
  padding: var(--space-3) 10px 12px;
}

@media (max-width: 640px) {
  /* The view buttons get their own row under the name (labels only, so all four fit). */
  .board-head--sub {
    flex-wrap: wrap;
  }

  .board-head__tabs {
    flex: 1 0 100%;
    margin-left: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .board-head__tabs .btn {
    flex: none;
    padding: 0 10px;
  }

  .board-head__tabs .btn > .icon {
    display: none;
  }

  .sub-board {
    padding-left: calc(var(--space-2) + var(--safe-left));
    padding-right: calc(var(--space-2) + var(--safe-right));
  }
}

/* ---- Archive / recycle bin (BIN-4) ---- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.toolbar__search {
  flex: 1 1 240px;
  max-width: 420px;
}

.toolbar__end {
  margin-left: auto;
}

.selection-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  min-height: 52px;
  margin-bottom: var(--space-2);
  padding: 6px 8px 6px 14px;
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.selection-bar__count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.selection-bar .btn--link {
  min-height: 32px;
  padding: 0 8px;
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-left: auto;
}

.item-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Each row looks like a card on the board. */
.item-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) 7.5rem 10rem auto;
  align-items: center;
  gap: var(--space-3);
  min-height: 60px;
  padding: 6px 6px 6px 4px;
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--ink);
  box-shadow: var(--card-shadow);
  transition: box-shadow var(--fast) var(--ease);
}

.item-row:hover {
  box-shadow: var(--card-shadow-hover);
}

.item-row.is-selected {
  background: var(--accent-soft);
}

.row-check {
  display: grid;
  place-items: center;
  width: var(--touch);
  height: var(--touch);
  cursor: pointer;
}

.item-type {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--paper-sunken);
  color: var(--ink-muted);
}

.item-type--wiki {
  background: var(--label-teal-bg);
  color: var(--label-teal-fg);
}

.item-row__main {
  min-width: 0;
}

.item-row__title {
  display: block;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-row__title:hover {
  text-decoration: underline;
}

.item-row__sub {
  margin-top: 2px;
  color: var(--ink-subtle);
  font-size: var(--text-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-row__sub strong {
  color: var(--ink-muted);
  font-weight: 600;
}

.item-row__date {
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.item-row__by {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.item-row__by span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-3);
  color: var(--ink-subtle);
  font-size: var(--text-sm);
}

@media (max-width: 760px) {
  .item-row {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
  }

  .item-row__date,
  .item-row__by {
    display: none;
  }
}

/* Phone: selection actions in a sticky bottom bar (UI-2) */
@media (max-width: 640px) {
  .item-type {
    display: none;
  }

  .item-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: var(--space-2);
  }

  .selection-bar {
    margin-bottom: var(--space-2);
  }

  .bulk-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    flex-wrap: nowrap;
    margin: 0;
    padding: var(--space-2) calc(var(--space-3) + var(--safe-right)) calc(var(--space-2) + var(--safe-bottom))
      calc(var(--space-3) + var(--safe-left));
    border-top: 1px solid var(--line);
    background: var(--surface);
    box-shadow: 0 -6px 20px rgb(0 0 0 / 0.08);
  }

  .bulk-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .has-bulk-actions {
    padding-bottom: calc(80px + var(--safe-bottom));
  }

  /* Toasts (e.g. Undo) sit above the bottom action bar instead of covering it. */
  body:has(.bulk-actions) .toasts {
    bottom: calc(68px + var(--safe-bottom));
  }
}

/* ---- Wiki (WIKI-1..3) ---- */

.wiki {
  display: grid;
  grid-template-columns: var(--column-width) minmax(0, 1fr);
  align-items: start;
  gap: var(--space-3);
  max-width: calc(1120px + var(--column-width));
}

.wiki .sub-panel {
  max-width: none;
}

.wiki-side {
  position: sticky;
  top: var(--space-3);
}

.wiki-main {
  padding: 8px;
}

.wiki-nav {
  display: grid;
  gap: var(--space-3);
}

/* Slots that are redrawn without touching the search field; they don't take part in layout. */
.wiki-nav__slot {
  display: contents;
}

.wiki-nav__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.wiki-nav__link {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 550;
  text-decoration: none;
}

.wiki-nav__link:hover {
  background: rgb(0 0 0 / 0.05);
  color: var(--ink);
}

/* The open page looks like a card. */
.wiki-nav__link[aria-current="page"] {
  background: var(--card-bg);
  color: var(--ink);
  font-weight: 700;
  box-shadow: var(--card-shadow);
}

.wiki-nav__link .icon {
  color: var(--ink-subtle);
}

.wiki-page {
  padding: var(--space-6) var(--space-6) var(--space-7);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--ink);
  box-shadow: var(--card-shadow);
}

.wiki-page__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--line);
}

.wiki-page__title {
  font-size: var(--text-2xl);
  font-weight: 750;
  letter-spacing: -0.025em;
}

.wiki-page__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--ink-subtle);
  font-size: var(--text-sm);
}

.wiki-page__actions {
  display: flex;
  gap: var(--space-2);
}

.wiki-page .md {
  max-width: 70ch;
  font-size: 1rem;
  line-height: 1.6;
}

.wiki-back {
  display: none;
}

@media (max-width: 760px) {
  .wiki {
    grid-template-columns: minmax(0, 1fr);
  }

  /* On phone the page list is its own screen. */
  .wiki--page .wiki-side {
    display: none;
  }

  .wiki-side {
    position: static;
  }

  .wiki-back {
    display: inline-flex;
    margin-bottom: var(--space-2);
  }

  .wiki-main {
    padding: 6px;
  }

  .wiki-page {
    padding: var(--space-5) var(--space-4) var(--space-6);
  }

  .wiki-page__title {
    font-size: var(--text-xl);
  }
}

button.item-row__title {
  display: block;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.list-foot__empty {
  width: auto;
}

.page-preview {
  max-height: 60vh;
  margin-bottom: var(--space-4);
  overflow-y: auto;
}
