/*
 * Break it down (tools.ts): the app's tree (tree.css), grown by hand. Its blocks are buttons here: a tap picks one, and
 * it wears the orange glow; a ring ticks a step with nothing under it, filling orange with the tick drawn in. The next
 * step wears the amber glow of the thing the magpie holds, as every tree's does. Under the tree, the panel that breaks
 * the picked block down, in the tools' glass, fields and chips (tools.css). Paper prints the tree, or the list where
 * the tree is too bushy for the page, in dark ink and no sky. Under Reduce Motion nothing moves.
 */

@import url("/tree.css");

.bid {
  --bid-pad: clamp(20px, 4vw, 36px);
}

.bid [hidden] {
  display: none !important;
}

.bid-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  border: 0;
  clip-path: inset(50%);
}

.bid-noscript {
  margin: 0;
  color: var(--ink-2);
  line-height: 1.55;
  text-align: center;
}

/* Starting: the big thing, or the example. */

.bid-start {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(4px, 1.5vw, 12px) 0;
  text-align: center;
}

.bid-start-label {
  color: var(--ink);
  font-size: clamp(1.375rem, 1.15rem + 1vw, 1.875rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.012em;
}

.bid-start-row {
  display: flex;
  gap: 10px;
  width: min(100%, 36rem);
  margin-top: 18px;
}

.bid-start-row .tool-field {
  flex: 1 1 auto;
  min-width: 0;
}

.bid-start-row .tool-button {
  flex: none;
}

.bid-start-hint {
  margin: 12px 0 0;
  color: var(--accent-text);
  font-size: 0.9375rem;
  font-weight: 700;
}

.bid-or {
  margin: 14px 0 0;
}

.bid-restore {
  margin: 12px 0 0;
}

@media (max-width: 559px) {
  .bid-start-row {
    flex-direction: column;
  }

  .bid-start-row .tool-button {
    width: 100%;
  }
}

/* Without a script, the stage keeps the method, in a sentence (after the rules above, which it overrides). */
@media (scripting: none) {
  .bid-start {
    display: none;
  }
}

/* What to do here, and the cheer once every step is done. */

.bid-status {
  max-width: 34rem;
  margin: 0 auto;
  color: var(--ink-3);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
  text-wrap: balance;
}

.bid-status.is-cheer {
  color: var(--ink);
  font-size: 1.0625rem;
  font-weight: 800;
}

/* The tree: the stage's whole width, so a bushy one pans edge to edge, with room for the glows. */

.bid-canvas {
  margin: 4px calc(var(--bid-pad) * -1) 0;
  padding: 22px var(--bid-pad) 26px;
}

.bid-canvas .bid-select,
.bid-canvas .bid-tick {
  margin: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.bid-canvas .bid-select {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: center;
  align-self: stretch;
  gap: 6px;
  min-width: 0;
}

/* The whole block answers a tap, not only its words: the button reaches over all of it. */
.bid-canvas .bid-select::after {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  content: "";
}

.bid-canvas .bid-root .bid-select::after {
  border-radius: 15px;
}

.bid-canvas .bid-select:focus-visible,
.bid-canvas .bid-tick:focus-visible {
  outline: none;
}

.bid-canvas .bid-select:focus-visible::after {
  outline: 2px solid var(--accent-text);
  outline-offset: 3px;
}

/* A step done keeps a step's height, so nothing jumps as it's ticked (ADR-0036: task and done stand alike). */
.bid-canvas .tree-done {
  min-height: 3.5rem;
}

/* The ring: a target the size of a fingertip around it, over the block's own button. */
.bid-canvas .bid-tick {
  position: relative;
  z-index: 1;
  display: grid;
  flex: none;
  place-items: center;
  margin: -10px;
  padding: 10px;
  border-radius: 50%;
}

.bid-canvas .bid-tick .tree-ring {
  position: relative;
  transition:
    background-color 200ms ease,
    border-color 200ms ease,
    box-shadow 200ms ease,
    transform 220ms var(--spring);
}

.bid-canvas .bid-tick svg {
  position: absolute;
  top: -2.5px;
  left: -2.5px;
  display: block;
  width: 18px;
  height: 18px;
}

/* The tick draws itself in as the ring fills. */
.bid-canvas .bid-tick path {
  opacity: 0;
  stroke-dasharray: 10.2;
  stroke-dashoffset: 10.2;
  transition:
    stroke-dashoffset 320ms var(--ease-out) 90ms,
    opacity 0s linear 90ms;
}

.bid-canvas .tree-done .tree-ring {
  background: var(--tree-accent);
  border-color: var(--tree-accent);
  box-shadow: 0 0 14px rgb(255 138 51 / 0.55);
}

.bid-canvas .tree-done .bid-tick path {
  opacity: 1;
  stroke-dashoffset: 0;
}

.bid-canvas .bid-tick:focus-visible .tree-ring {
  outline: 2px solid var(--accent-text);
  outline-offset: 3px;
}

@media (hover: hover) {
  .bid-canvas .bid-tick:hover .tree-ring {
    border-color: var(--accent-text);
    transform: scale(1.1);
  }

  .bid-canvas .tree-task:hover,
  .bid-canvas .tree-goal:hover {
    background: #44312a;
  }

  .bid-canvas .tree-done:hover {
    background: #55301c;
  }
}

/* The block you picked: the app's orange, glowing. Its ring is drawn inside its edge, where no rail can cross it. */
.bid-canvas .tree-block.is-selected {
  background: #47332a;
  box-shadow:
    inset 0 0 0 2px var(--tree-accent),
    0 0 34px -6px rgb(255 138 51 / 0.75);
}

.bid-canvas .tree-done.is-selected {
  background: #58311c;
}

/* Every step done: the big thing wears the glow of the thing the magpie holds. */
.bid-canvas .bid-root.is-complete:not(.is-selected) {
  box-shadow:
    0 0 0 1px var(--tree-next),
    0 0 40px -6px rgb(255 154 77 / 0.6);
}

/* The panel: break the picked block down, or rename it, tick it, remove it. */

.bid-panel {
  margin-top: 2px;
  padding: clamp(16px, 3vw, 24px);
  background: rgb(20 13 15 / 0.3);
  border: 1px solid var(--line);
  border-radius: 22px;
}

.bid-panel-title {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  font-weight: 800;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.bid-name {
  color: var(--accent-text);
}

.bid-add {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.bid-add .tool-field {
  flex: 1 1 auto;
  min-width: 0;
}

.bid-add .tool-button {
  flex: none;
}

.bid-nudges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.bid-nudges .tool-chip {
  min-height: 36px;
  padding: 7px 14px;
  font-size: 0.875rem;
  line-height: 1.3;
  text-align: left;
}

.bid-nudge {
  margin: 10px 2px 0;
  color: var(--ink-2);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.bid-nudge:empty {
  display: none;
}

.bid-note {
  margin: 14px 0 0;
  padding: 11px 15px;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.45;
  background: var(--accent-tint);
  border: 1px solid rgb(255 138 51 / 0.32);
  border-radius: 14px;
}

.bid-undo {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: center;
  margin: 14px 0 0;
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.bid-edit {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* A small action: a quiet pill, the tools' chip in a size smaller. */
.bid-small {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 7px 15px;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 750;
  line-height: 1.25;
  text-align: left;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition:
    color 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms var(--spring);
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
  .bid-small:hover {
    color: var(--ink);
    background: var(--well-hover);
    border-color: rgb(255 176 113 / 0.45);
  }
}

.bid-small:active {
  transform: scale(0.96);
}

.bid-small:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 3px;
}

.bid-small.is-tick {
  color: var(--accent-text);
}

/* Small enough to do: ticking it is the move, so it's the capsule. */
.bid-small.is-big {
  color: var(--on-accent);
  background: var(--accent);
  border-color: transparent;
  box-shadow: 0 8px 18px -10px rgb(255 138 51 / 0.9);
}

@media (hover: hover) {
  .bid-small.is-big:hover {
    color: var(--on-accent);
    background: #ff9a4d;
  }
}

@media (max-width: 559px) {
  .bid-rename .bid-add {
    flex-wrap: wrap;
  }

  .bid-rename .tool-field {
    flex-basis: 100%;
  }

  .bid-rename .tool-button {
    flex: 1 1 0;
  }
}

/* Keeping it. */

.bid-keep .tool-button.is-copied {
  color: var(--accent-text);
  box-shadow: inset 0 0 0 1px rgb(255 176 113 / 0.55);
}

/* Motion: blocks spring in, a whole tree breaks down a row at a time, finishing it all lights the stage. */

@media (prefers-reduced-motion: no-preference) {
  .bid-canvas .tree-block.bid-arrive {
    animation: bid-arrive 640ms var(--spring) both;
  }

  .bid-canvas .tree-block.bid-root,
  .bid-canvas.is-growing .tree > .tree-node > .tree-block {
    animation: bid-root 760ms var(--spring) both;
  }

  .bid-canvas.is-growing .tree-children {
    animation: bid-unfold 640ms var(--ease-out) both;
    animation-delay: 300ms;
  }

  .bid-canvas.is-growing .tree-children .tree-children {
    animation-delay: 600ms;
  }

  .bid-canvas.is-growing .tree-children .tree-children .tree-children {
    animation-delay: 900ms;
  }

  .bid-canvas .tree-block.bid-morph {
    animation: bid-morph 520ms var(--spring);
  }

  .bid-canvas .tree-block.bid-picked {
    animation: bid-picked 380ms var(--spring);
  }

  .bid-canvas .tree-node.bid-leave {
    animation: bid-leave 240ms ease-in forwards;
  }

  .bid-canvas .tree-ring.pop {
    animation: bid-ring-pop 520ms var(--spring);
  }

  .bid-note.bid-nudged {
    animation: bid-nudged 760ms var(--ease-out);
  }

  .bid-nudge.bid-rise {
    animation: bid-rise 380ms var(--spring);
  }

  .bid.is-complete {
    animation: bid-complete 1.5s var(--ease-out);
  }
}

@keyframes bid-arrive {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.84);
  }
}

@keyframes bid-root {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.7);
  }
}

@keyframes bid-unfold {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
}

@keyframes bid-morph {
  35% {
    transform: scale(1.06);
  }
}

@keyframes bid-picked {
  40% {
    transform: scale(1.045);
  }
}

@keyframes bid-leave {
  to {
    opacity: 0;
    transform: scale(0.88);
  }
}

@keyframes bid-ring-pop {
  40% {
    transform: scale(1.32);
  }
}

@keyframes bid-nudged {
  25% {
    background: rgb(255 138 51 / 0.26);
    box-shadow: 0 0 0 4px rgb(255 138 51 / 0.18);
  }
}

@keyframes bid-rise {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

@keyframes bid-complete {
  30% {
    box-shadow:
      0 1px 0 var(--glass-shine) inset,
      0 0 0 2px rgb(255 138 51 / 0.6),
      0 0 70px 8px rgb(255 138 51 / 0.32);
  }
}

/* Paper: the tree where it fits the page, or the list (break-it-down.js chooses before printing), in dark ink. */

.bid-paper,
.bid-print-foot {
  display: none;
}

@media print {
  .tool-break-it-down .tool-head,
  .tool-break-it-down .tool-words,
  .bid-start,
  .bid-status,
  .bid-panel,
  .bid .tree-hint {
    display: none !important;
  }

  /* The page's whole width for the tree: a page's gutters would leave a five-step row no room. */
  .tool-break-it-down {
    width: auto;
  }

  .bid-canvas,
  .bid-canvas.is-wide {
    --tree-surface: transparent;
    --tree-tint: transparent;
    --tree-accent: #1e1418;
    --tree-strong: #1e1418;
    --tree-muted: #5a4338;
    --tree-ring: #1e1418;
    --tree-rail: #8a776c;
    --tree-track: transparent;
    --tree-next: #1e1418;
    margin: 0;
    padding: 8px 0 0;
    overflow: visible;
    -webkit-mask-image: none;
    mask-image: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .bid-canvas .tree-block,
  .bid-canvas .tree-block.is-selected,
  .bid-canvas .tree-block.is-next,
  .bid-canvas .bid-root.is-complete {
    background: none;
    border: 1.5px solid #1e1418;
    box-shadow: none;
    break-inside: avoid;
  }

  .bid-canvas .tree-done,
  .bid-canvas .tree-done.is-selected {
    border-color: #a8958a;
  }

  .bid-canvas .tree-dot,
  .bid-canvas .tree-done .tree-ring {
    box-shadow: none;
  }

  .bid-canvas .tree-bar {
    border: 1px solid #1e1418;
  }

  .bid-canvas .tree-bar i {
    background: #1e1418;
  }

  .bid-canvas .tree-done .bid-tick path {
    stroke: #fffaf4;
  }

  .bid-canvas .tree-next-label {
    background: #fffaf4;
  }

  .bid[data-print="list"] .bid-canvas {
    display: none;
  }

  .bid[data-print="list"] .bid-paper {
    display: block;
  }

  .bid-paper {
    color: #1e1418;
    font-size: 12pt;
    line-height: 1.5;
  }

  .bid-paper-title {
    margin: 0 0 10pt;
    font-size: 18pt;
    font-weight: 800;
  }

  .bid-paper ul {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .bid-paper ul ul {
    padding-left: 22pt;
  }

  .bid-paper li {
    margin: 5pt 0;
    break-inside: avoid;
  }

  .bid-paper .bid-mark {
    display: inline-block;
    width: 18pt;
  }

  .bid-paper .is-done > .bid-paper-step {
    color: #5a4338;
    text-decoration: line-through;
  }

  .bid-print-foot {
    display: block;
    margin: 24pt 0 0;
    color: #5a4338;
    font-size: 9pt;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bid-canvas .bid-tick .tree-ring,
  .bid-canvas .bid-tick path,
  .bid-small {
    transition: none;
  }
}
