/* A customization money page's demo board (kit/BuildBoard.astro), its board map (kit/BuildMap.astro) and monday.com's
   API calendar (kit/Upkeep.astro), rule 500. The board map and the calendar are in kit-build-map.css, the
   build-or-not check and its note in kit-build-parts.css.
   SectionRenderer links both only on a page that draws one of them. Status colours echo a monday.com board. */

.kbb,
.kup {
  --st-done: #00c875;
  --st-work: #fdab3d;
  --st-stuck: #df2f4a;
  --st-todo: #c4c4c4;
  --st-ink: #0b1015;
}
.kbb [hidden],
.kbm [hidden],
.kup [hidden] {
  display: none !important;
}

/* ---------- the demo board ---------- */

.hero__build {
  align-self: center;
}
.kbb {
  display: grid;
  min-width: 0;
}
.kbb__card {
  position: relative;
  padding: var(--s-5);
  border: 1px solid var(--line);
  background:
    radial-gradient(90% 60% at 100% 0%, var(--accent-tint) 0%, transparent 65%),
    var(--paper);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.kbb__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.kbb__title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.kbb__title > span:last-child {
  display: grid;
  gap: 2px;
}
.kbb__name {
  font-weight: 550;
  color: var(--ink);
  line-height: 1.2;
}
.kbb__sub {
  font-size: var(--fs-mono-sm);
}
.kbb__replay {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.kbb__replay:hover {
  color: var(--ink);
  border-color: var(--accent);
}
.kbb__frame {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 31%;
  gap: 8px;
}
.kbb__main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

/* every place: dims while another is lit, glows when it is the one */
.kbb__place {
  position: relative;
  transition: opacity 400ms var(--ease), box-shadow 400ms var(--ease), border-color 400ms var(--ease), transform 400ms var(--ease);
}
.kbb.is-lit .kbb__place:not(.is-on) {
  opacity: 0.45;
}
.kbb .kbb__place.is-on {
  z-index: 1;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent), 0 10px 26px -12px color-mix(in srgb, var(--accent) 60%, transparent);
}

/* the tabs: the custom view is the new one */
.kbb__tabs {
  display: flex;
  gap: 4px;
  min-width: 0;
  border-bottom: 1px solid var(--line);
}
.kbb__tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-bottom: 0;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}
.kbb__tab.is-on {
  color: var(--ink);
  border-bottom: 2px solid var(--accent);
}
.kbb__tab--new {
  border: 1px dashed var(--line-2);
  border-bottom: 0;
  color: var(--accent-deep);
  background: var(--paper);
}
.kbb__tab--new.is-on {
  border-style: solid;
  background: var(--accent-tint);
}

/* the table */
.kbb__table {
  border: 1px solid var(--line);
  background: var(--paper);
}
.kbb__th,
.kbb__tr {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px 82px 44px;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 0 0 10px;
  border-left: 4px solid var(--accent);
}
.kbb__th {
  min-height: 24px;
  font-size: 10px;
  color: var(--faint);
  border-bottom: 1px solid var(--line);
}
.kbb__tr + .kbb__tr {
  border-top: 1px solid var(--line);
}
.kbb__item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
  color: var(--ink-2);
  font-size: 12px;
  white-space: nowrap;
  overflow: visible;
}
.kbb__tr.is-pick .kbb__item {
  font-weight: 550;
  color: var(--ink);
}
.kbb__who {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent-deep);
  font-size: 9.5px;
  font-weight: 600;
}
.kbb__st {
  display: grid;
  place-items: center;
  align-self: stretch;
  color: #fff;
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
}
.kbb__st[data-st='done'] {
  background: var(--st-done);
}
.kbb__st[data-st='work'] {
  background: var(--st-work);
  color: var(--st-ink);
}
.kbb__st[data-st='stuck'] {
  background: var(--st-stuck);
}
.kbb__st[data-st='todo'] {
  background: var(--st-todo);
  color: var(--st-ink);
}
.kbb__due {
  color: var(--muted);
  font-size: 10.5px;
  padding-right: 6px;
}
.kbb__dots {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 20px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--paper);
}
.kbb__menu {
  position: absolute;
  left: calc(100% + 4px);
  top: -4px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border: 1px solid var(--accent);
  background: var(--paper);
  box-shadow: var(--shadow-card);
  color: var(--ink);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 300ms var(--ease), transform 300ms var(--ease);
}
.kbb__dots.is-on .kbb__menu {
  opacity: 1;
  transform: none;
}

/* the automation sentence */
.kbb__auto {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: 11.5px;
  line-height: 1.45;
}
.kbb__auto svg {
  flex: none;
  color: var(--st-work);
  transform: translateY(2px);
}
.kbb__auto b {
  font-weight: 600;
  color: var(--accent-deep);
}
.kbb__custom {
  padding: 0 3px;
  border-bottom: 1px dashed var(--accent);
}

/* the item panel */
.kbb__panel {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  min-width: 0;
}
.kbb__ptitle {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 550;
  line-height: 1.3;
}
.kbb__ptabs {
  display: flex;
  gap: 8px;
  margin: 0 0 2px;
  font-size: 9.5px;
  border-bottom: 1px solid var(--line);
}
.kbb__ptabs span {
  padding-bottom: 4px;
}
.kbb__ptabs .is-on {
  color: var(--accent-deep);
  border-bottom: 2px solid var(--accent);
}
.kbb__pline {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin: 0;
  color: var(--ink-2);
  font-size: 11px;
}
.kbb__pline b {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.kbb__pline--sum {
  padding-top: 5px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-weight: 550;
}

.kbb__pline--ok {
  color: var(--ok-ink);
}
.kbb__pbtn {
  margin-top: auto;
  padding: 5px 8px;
  border: 1px dashed var(--line-2);
  color: var(--accent-deep);
  font-size: 10.5px;
  text-align: center;
}
.kbb__panel {
  grid-auto-rows: min-content;
}
.kbb__panel .kbb__pbtn {
  align-self: end;
}

/* the three tiles: a widget, a sync, a portal */
.kbb__tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.kbb__tile {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 74px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  min-width: 0;
}
.kbb__tl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 9.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}
.kbb__bars {
  display: grid;
  gap: 4px;
}
.kbb__bars i {
  display: block;
  height: 6px;
  width: calc(var(--v) * 100%);
  border-radius: var(--radius-pill);
  background: var(--accent);
  transform-origin: left;
}
.kbb__bars i:nth-child(2) {
  background: var(--st-done);
}
.kbb__bars i:nth-child(3) {
  background: var(--st-work);
}
.kbb__wire {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
}
.kbb__box {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 26px;
  padding: 0 5px;
  border: 1px solid var(--line-2);
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: 10px;
  font-weight: 600;
}
.kbb__box--m {
  padding: 0 3px;
  background: var(--paper);
}
.kbb__flow {
  position: relative;
  height: 14px;
  overflow: hidden;
}
.kbb__flow::before {
  content: '';
  position: absolute;
  inset: 50% 0 auto;
  border-top: 1px dashed var(--line-2);
}
.kbb__flow i {
  position: absolute;
  top: 2px;
  width: 8px;
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
}
.kbb__flow i:nth-child(2) {
  top: 8px;
  background: var(--st-done);
}
.kbb__portal {
  display: grid;
  gap: 4px;
}
.kbb__portal i {
  display: block;
  height: 7px;
  border-radius: 2px;
  background: var(--paper-3);
}
.kbb__portal i:first-child {
  width: 80%;
  background: color-mix(in srgb, var(--accent) 40%, var(--paper-3));
}
.kbb__portal i:nth-child(2) {
  width: 60%;
}
.kbb__portal i.is-lock {
  width: 92%;
  background: repeating-linear-gradient(135deg, var(--paper-3) 0 4px, transparent 4px 8px);
  border: 1px solid var(--line);
}

/* the "lives in" tag that follows the lit place */
.kbb__tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: var(--s-3) 0 0;
  padding: 4px 10px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-pill);
  background: var(--accent-tint);
  color: var(--accent-deep);
  font-size: var(--fs-mono-sm);
}
.kbb__line {
  margin: var(--s-3) 0 0;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  line-height: 1.5;
}

/* the need picker */
.kbb__needs {
  margin: var(--s-4) 0 0;
  padding: var(--s-4) 0 0;
  border: 0;
  border-top: 1px dashed var(--line-2);
  min-width: 0;
}
.kbb__ask {
  margin-bottom: var(--s-2);
  padding: 0;
  color: var(--accent-deep);
}
.kbb__opts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.kbb__opt {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-pill);
  background: var(--paper);
  color: var(--ink-2);
  font: inherit;
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.kbb__opt svg {
  color: var(--accent-deep);
}
.kbb__opt:hover {
  border-color: var(--accent);
  color: var(--ink);
}
.kbb__opt[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 550;
}
.kbb__opt[aria-pressed='true'] svg {
  color: var(--on-accent);
}
.kbb__opt:focus-visible,
.kbb__replay:focus-visible,
.kbm__row:focus-visible,
.kup__opt:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.kbb__go {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--s-3);
  color: var(--accent-text);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* the little builds: what appears when a place lights (off under reduced motion, build-board.ts) */
.kbb__tab--new.is-build {
  animation: kbb-tab 700ms var(--ease) both;
}
@keyframes kbb-tab {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.kbb__panel.is-build {
  animation: kbb-slide 700ms var(--ease) both;
}
@keyframes kbb-slide {
  from { transform: translateX(24px); opacity: 0.2; }
  to { transform: none; opacity: 1; }
}
.kbb__panel.is-build .kbb__pline {
  animation: kbb-row 500ms var(--ease) both;
}
.kbb__panel.is-build .kbb__pline:nth-of-type(2) { animation-delay: 300ms; }
.kbb__panel.is-build .kbb__pline:nth-of-type(3) { animation-delay: 450ms; }
.kbb__panel.is-build .kbb__pline:nth-of-type(4) { animation-delay: 600ms; }
@keyframes kbb-row {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: none; }
}
.kbb__tile.is-build .kbb__bars i {
  animation: kbb-bar 900ms var(--ease) both;
}
.kbb__tile.is-build .kbb__bars i:nth-child(2) { animation-delay: 150ms; }
.kbb__tile.is-build .kbb__bars i:nth-child(3) { animation-delay: 300ms; }
@keyframes kbb-bar {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
.kbb__tile.is-on .kbb__flow i {
  animation: kbb-flow 1.6s linear infinite;
}
.kbb__tile.is-on .kbb__flow i:nth-child(2) {
  animation-direction: reverse;
  animation-delay: -0.8s;
}
@keyframes kbb-flow {
  from { left: -10px; }
  to { left: 100%; }
}
.kbb__tile.is-build .kbb__portal i {
  animation: kbb-row 500ms var(--ease) both;
}
.kbb__tile.is-build .kbb__portal i:nth-child(2) { animation-delay: 150ms; }
.kbb__tile.is-build .kbb__portal i:nth-child(3) { animation-delay: 300ms; }
.kbb__auto.is-build .kbb__custom {
  animation: kbb-type 1.1s steps(28) both;
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  vertical-align: bottom;
  max-width: 100%;
}
@keyframes kbb-type {
  from { max-width: 0; }
  to { max-width: 100%; }
}
.kbb__table.is-build .kbb__th {
  animation: kbb-flash 900ms var(--ease) both;
}
@keyframes kbb-flash {
  0% { background: var(--accent-tint); }
  100% { background: transparent; }
}
/* the scan line that sweeps the board when a need is picked */
.kbb__card::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 -30%;
  width: 30%;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 12%, transparent), transparent);
  pointer-events: none;
  opacity: 0;
}
.kbb.is-scan .kbb__card::after {
  animation: kbb-scan 1.2s var(--ease);
}
@keyframes kbb-scan {
  from { left: -30%; opacity: 1; }
  to { left: 110%; opacity: 0; }
}

/* map mode: numbered pins on every place */
.kbb__pin {
  position: absolute;
  top: -8px;
  left: -8px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: 10px;
  letter-spacing: 0;
}
.kbb__place.is-on > .kbb__pin {
  background: var(--accent);
  color: var(--on-accent);
}
.kbb__tab .kbb__pin {
  top: -10px;
  left: -6px;
}
.kbb__dots .kbb__pin {
  top: -12px;
  left: -10px;
}
.kbb--map .kbb__place {
  cursor: pointer;
}
.kbb--map .kbb__card {
  overflow: visible;
}

/* the hero card holds the picker: the tag and the line under the board */
.kbb--hero .kbb__tag {
  margin-top: var(--s-4);
}
.kbb--hero .kbb__line {
  margin-top: 8px;
}

/* a page with the build tools shows its steps at the full width (no empty right third) */
.ktime {
  max-width: none;
}

@media (prefers-reduced-motion: reduce) {
  .kbb *,
  .kbb__card::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 640px) {
  .kbb__card {
    padding: var(--s-4);
  }
  .kbb__frame {
    grid-template-columns: minmax(0, 1fr);
  }
  .kbb__th,
  .kbb__tr {
    grid-template-columns: minmax(0, 1fr) 24px 74px;
  }
  .kbb__th span:last-child,
  .kbb__due {
    display: none;
  }
  .kbb__tiles {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .kbb__tile:last-child {
    grid-column: 1 / -1;
  }
  /* the hero keeps the board short on a phone: the item panel shows in the board map below */
  .kbb--hero .kbb__panel {
    display: none;
  }
  .kbb--hero .kbb__opts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .kbb--hero .kbb__opt {
    border-radius: var(--radius);
    padding: 6px 10px;
    line-height: 1.25;
    text-align: left;
  }
  .kbb__menu {
    left: auto;
    right: 0;
    top: 24px;
  }
}
