/* Board view: header, columns, cards (BRD-6, COL-*, CARD-1..4, UI-2, UI-3). */

.board-page {
  min-height: 100%;
  background-color: var(--board-tint);
  color: var(--on-glass);
}

/* The gradient + grain sit on their own fixed layer, so menus, dialogs and drags on top never
   force the big background to be repainted (UI-12: smooth dragging). */
.board-page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--grain), linear-gradient(var(--board-dim), var(--board-dim)), var(--board-bg);
  pointer-events: none;
  will-change: transform;
}

.board-screen {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

/* ---- Header (BRD-6) ---- */

.board-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: 0 calc(var(--space-4) + var(--safe-right)) var(--space-3) calc(var(--space-4) + var(--safe-left));
  --ring: rgb(0 0 0 / 0.25);
}

.board-head__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.board-title {
  font-size: var(--text-xl);
  font-weight: 750;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-head__filter {
  width: 220px;
}

.board-head__nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.board-head__nav .count {
  background: rgb(255 255 255 / 0.22);
  color: inherit;
}

.input--glass {
  min-height: var(--control);
  border-color: var(--glass-edge);
  background: var(--glass);
  color: var(--on-glass);
  font-size: var(--text-sm);
}

.input--glass::placeholder {
  color: rgb(255 255 255 / 0.72);
}

.input--glass:focus {
  border-color: transparent;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 3px rgb(255 255 255 / 0.35);
}

.input-icon:has(.input--glass) > .icon {
  color: rgb(255 255 255 / 0.8);
}

.input-icon:has(.input--glass:focus) > .icon {
  color: var(--ink-subtle);
}

.board-head__more .menu {
  color: var(--ink);
}

/* ---- Columns (COL-1..5) ---- */

.board {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px calc(var(--space-4) + var(--safe-right)) calc(var(--space-4) + var(--safe-bottom))
    calc(var(--space-4) + var(--safe-left));
  overscroll-behavior-x: contain;
  scrollbar-color: rgb(255 255 255 / 0.5) transparent;
}

.column {
  display: flex;
  flex-direction: column;
  flex: none;
  width: var(--column-width);
  max-height: 100%;
  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);
}

.column__head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 6px 4px 14px;
  cursor: grab;
}

.column__name {
  flex: 1;
  min-width: 0;
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.005em;
  overflow-wrap: anywhere;
}

.column__head .count {
  background: rgb(0 0 0 / 0.07);
}

.column__head .btn--icon {
  color: var(--ink-muted);
}

.column__head .btn--icon:hover {
  background: rgb(0 0 0 / 0.07);
}

.column__cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1 1 auto;
  min-height: 8px;
  margin: 0;
  padding: 4px 8px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  list-style: none;
  scrollbar-width: thin;
}

.column__foot {
  padding: 4px 8px 8px;
}

.add-card {
  justify-content: flex-start;
  width: 100%;
  color: var(--ink-muted);
}

.add-card:hover {
  background: rgb(0 0 0 / 0.06);
  color: var(--ink);
}

.column--add {
  justify-content: flex-start;
  width: var(--column-width);
  min-height: 48px;
  border: 1.5px dashed rgb(255 255 255 / 0.45);
  border-radius: var(--radius-lg);
  background: var(--glass);
  color: var(--on-glass);
  flex: none;
}

.column--add:hover {
  background: var(--glass-strong);
}

@media (prefers-color-scheme: dark) {
  .column__head .count,
  .column__head .btn--icon:hover,
  .add-card:hover {
    background: rgb(255 255 255 / 0.08);
  }
}

/* Quick add (CARD-1) */

.quick-add {
  padding: 8px;
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
}

.quick-add__input {
  width: 100%;
  min-height: 52px;
  padding: 2px 4px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.35;
  resize: none;
}

.quick-add__input:focus {
  outline: none;
}

.quick-add__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.quick-add__hint {
  margin-left: auto;
  color: var(--ink-subtle);
  font-size: var(--text-xs);
}

/* ---- Cards (CARD-4) ---- */

.card {
  position: relative;
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--ink);
  box-shadow: var(--card-shadow);
  text-decoration: none;
  cursor: pointer;
  transition:
    box-shadow var(--fast) var(--ease),
    transform var(--fast) var(--ease);
  -webkit-touch-callout: none;
}

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

.card:focus-visible {
  outline-offset: 1px;
}

.card__labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 7px;
}

.card__title {
  display: block;
  font-size: 0.90625rem;
  font-weight: 550;
  line-height: 1.38;
  overflow-wrap: anywhere;
}

.card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 8px;
  color: var(--ink-subtle);
}

.card__badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--text-xs);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.card__badge--complete {
  color: var(--ok);
}

/* CARD-4: checklist progress as a thin bar (the shared .progress look, smaller). */
.card .card__progress {
  height: 3px;
  margin: 8px 0 0;
}

.card .card__progress--complete::-webkit-progress-value {
  background: var(--ok);
}

.card .card__progress--complete::-moz-progress-bar {
  background: var(--ok);
}

.card__more {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--ink-muted);
  opacity: 0;
}

.column__cards > li {
  position: relative;
}

.column__cards > li:hover .card__more,
.card__more:focus-visible {
  opacity: 1;
}

.card__more:hover {
  background: var(--paper-sunken);
}

@media (pointer: coarse) {
  .card__more {
    display: none;
  }
}

/* Drag & drop (CARD-2, FE-3) */

.card--dragging {
  transform: rotate(2.5deg) scale(1.03);
  box-shadow: var(--card-shadow-drag);
  cursor: grabbing;
}

.card--ghost {
  opacity: 0.4;
}

.drop-slot {
  height: 58px;
  border: 2px dashed rgb(0 0 0 / 0.18);
  border-radius: var(--radius);
  background: rgb(0 0 0 / 0.04);
}

@media (prefers-color-scheme: dark) {
  .drop-slot {
    border-color: rgb(255 255 255 / 0.2);
    background: rgb(255 255 255 / 0.04);
  }
}

/* ---- Phone (UI-2) ---- */

@media (max-width: 640px) {
  .board-head {
    flex-wrap: nowrap;
  }

  .board-head__title {
    flex: 1;
  }

  .board-title {
    font-size: var(--text-lg);
  }

  .board {
    gap: 10px;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: calc(var(--space-4) + var(--safe-left));
  }

  .column,
  .column--add {
    width: var(--column-width-phone);
    scroll-snap-align: start;
  }

  .card {
    padding: 12px 13px;
  }
}

/* ---- The board screen inside the app shell (M3) ---- */

.board-page .app-shell {
  height: 100vh;
  height: 100dvh;
}

.board-page .app-main {
  overflow: hidden;
}

.board-view {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.board-view__state {
  padding: var(--space-6) var(--space-4);
}

.column__head--static {
  cursor: default;
}

.column__rename {
  flex: 1;
  min-width: 0;
  min-height: 32px;
  padding: 2px 8px;
  font-weight: 700;
}

.column--new {
  gap: var(--space-2);
  padding: var(--space-2);
}

.board-empty {
  flex: none;
  width: var(--column-width);
  padding: var(--space-4);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius-lg);
  background: var(--glass);
  color: var(--on-glass);
}

.board-empty .empty__body {
  color: inherit;
  opacity: 0.85;
}

/* The card menu sits in the card's corner; the menu itself opens fixed (not clipped by the
   scrolling column). */
.card__menu {
  position: absolute;
  top: 5px;
  right: 5px;
}

.card__menu .card__more {
  position: static;
}

.card,
.column__head,
.board-tile {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Drag & drop (FE-3): the lifted item follows the pointer above everything. */
.dnd-lifted {
  position: fixed !important;
  z-index: 1000;
  margin: 0;
  list-style: none;
  pointer-events: none;
  will-change: transform;
}

.dnd-lifted > .card {
  rotate: 2.5deg;
  scale: 1.03;
  box-shadow: var(--card-shadow-drag);
}

.column.dnd-lifted {
  rotate: 1.5deg;
  box-shadow: var(--card-shadow-drag);
}

.board-item.dnd-lifted {
  display: grid;
}

.board-item.dnd-lifted > .board-tile {
  rotate: 2deg;
  box-shadow: var(--card-shadow-drag);
}

.dnd-active,
.dnd-active * {
  cursor: grabbing !important;
  -webkit-user-select: none;
  user-select: none;
}

.drop-slot {
  flex: none;
  list-style: none;
}

.column-slot {
  flex: none;
  border: 2px dashed rgb(255 255 255 / 0.55);
  border-radius: var(--radius-lg);
  background: rgb(255 255 255 / 0.12);
}

.board-slot {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--paper-sunken);
}

@media (max-width: 640px) {
  .board-empty {
    width: var(--column-width-phone);
  }
}

/* ---- Filter (FLT-1) ---- */

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.filter-chip {
  gap: 4px;
  border: 0;
  cursor: pointer;
}

.card .label {
  cursor: pointer;
}

@media (max-width: 640px) {
  .board-head--filtering {
    flex-wrap: wrap;
  }

  .board-head__filter--phone.phone-only {
    display: block !important;
    order: 10;
    width: 100%;
  }

  .board-head__filter--phone .input {
    width: 100%;
  }
}

/* UI-12: cards scrolled out of view inside a column skip style and layout work until they
   come close (300-card boards stay fast on phones). Browsers without support ignore it. */
.column__cards > li.card-item {
  /* Without `flex: none` the column squeezes cards the browser hasn't laid out yet. */
  flex: none;
  content-visibility: auto;
  contain-intrinsic-size: auto 64px;
}

/* Three dots drawn by CSS until the card menu is first opened (no SVG per card). */
.card__more--lazy::before {
  content: "";
  width: 14px;
  height: 4px;
  background: radial-gradient(circle at 2px 2px, currentColor 1.6px, transparent 2.2px) 0 0 / 5px 4px repeat-x;
}
