/*
 * The brain dump template (tools/brain-dump.html, brain-dump.js), over the free tools' kit (tools.css). What comes out
 * of a head lands as a scatter of notes; each line is then sorted, one card at a time, into five places, each in one of
 * My Life's colours; the one thing picked wears the amber glow of the thing the magpie holds.
 */

/* Each place's colour: the same hue on its button, its count and the printed page. */
.dump {
  --dated: var(--star-3);
  --week: var(--accent);
  --someday: var(--star-4);
  --note: var(--star-2);
  --crossed: var(--ink-4);
}

.dump-place[data-place="dated"] {
  --place: var(--dated);
}

.dump-place[data-place="week"] {
  --place: var(--week);
}

.dump-place[data-place="someday"] {
  --place: var(--someday);
}

.dump-place[data-place="note"] {
  --place: var(--note);
}

.dump-place[data-place="crossed"] {
  --place: var(--crossed);
}

/* 1. Get it all out: the count, the timer, the field, and the lines landing as notes. */

.dump-top {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.dump-count {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: baseline;
  margin: 0;
  color: var(--ink-2);
  font-weight: 700;
}

.dump-count .tool-count {
  color: var(--ink);
  font-size: 2.5rem;
  font-weight: 850;
  line-height: 1;
}

.dump-timer {
  font-variant-numeric: tabular-nums;
}

.dump-timer svg {
  display: block;
  width: 20px;
  height: 20px;
}

.dump-timer .dump-timer-left {
  transition: stroke-dashoffset 1s linear;
}

.dump-form {
  display: flex;
  gap: 10px;
}

.dump-form .tool-field {
  flex: 1;
  min-width: 0;
}

.dump-form .tool-button {
  flex: none;
  min-height: 54px;
}

.dump-nudge {
  margin: 12px 0 0;
  color: var(--ink-3);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.dump-nudge-ask {
  padding: 0;
  color: var(--accent-text);
  font: inherit;
  font-weight: 700;
  text-align: left;
  text-decoration: underline dotted;
  text-underline-offset: 4px;
  background: none;
  border: 0;
  cursor: pointer;
}

/* A hover lifts only where a pointer can hover: a phone keeps the last tap's hover, and the glow would stick. */
@media (hover: hover) {
  .dump-nudge-ask:hover {
    text-decoration-style: solid;
  }
}

.dump-nudge-ask:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 3px;
  border-radius: 4px;
}

.dump-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.dump-list:empty {
  display: none;
}

/* A line out of your head: a small note, each a slightly different tilt and colour. */
.dump-line {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  max-width: 100%;
  box-sizing: border-box;
  padding: 5px 4px 5px 14px;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 650;
  line-height: 1.3;
  background: linear-gradient(180deg, var(--card-top), var(--card-bottom));
  border: 1px solid var(--line);
  border-left: 3px solid var(--c, var(--accent));
  border-radius: 12px;
  box-shadow: 0 12px 24px -16px rgb(0 0 0 / 0.85);
  transform: rotate(var(--tilt, 0deg));
}

.dump-line span {
  overflow-wrap: anywhere;
}

.dump-line-remove {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--ink-4);
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

@media (hover: hover) {
  .dump-line-remove:hover {
    color: var(--ink);
    background: var(--well-hover);
  }
}

.dump-line-remove:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 0;
}

/* The way on sits under the field, so it stays in reach however long the pile below it grows. */
[data-stage="dump"] > .tool-actions {
  margin-top: 18px;
}

/* 2. Give each a place: the card in play, then five places to send it. */

.dump-lead {
  max-width: 34rem;
  margin: 0 auto;
  color: var(--ink-2);
  font-size: 1.0625rem;
  line-height: 1.5;
  text-align: center;
}

.dump-meter {
  max-width: 28rem;
  height: 6px;
  margin: 18px auto 0;
  overflow: hidden;
  background: var(--well);
  border-radius: 999px;
}

.dump-meter i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--lit));
  border-radius: inherit;
  box-shadow: 0 0 12px var(--lit-glow);
  transition: width 420ms var(--spring);
}

.dump-progress {
  margin: 10px 0 0;
  color: var(--ink-4);
  font-size: 0.875rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.dump-card-slot {
  display: grid;
  place-items: center;
  min-height: 132px;
  margin: 12px 0 18px;
}

.dump-card {
  box-sizing: border-box;
  width: min(100%, 26rem);
  margin: 0;
  padding: 26px 24px;
  color: var(--ink);
  font-size: clamp(1.25rem, 1.1rem + 0.8vw, 1.5rem);
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: anywhere;
  background: linear-gradient(180deg, rgb(86 62 52 / 0.96), rgb(64 46 39 / 0.96));
  border: 1px solid var(--edge);
  border-radius: 22px;
  box-shadow:
    0 1px 0 var(--glass-shine) inset,
    0 28px 50px -24px rgb(0 0 0 / 0.85);
}

/* The last card gone: the slot keeps its room while the copy flies. */
.dump-card.is-gone {
  visibility: hidden;
}

/* The copy of a card that flies into the place it was given (brain-dump.js's fly). */
.dump-ghost {
  position: fixed;
  z-index: 45;
  pointer-events: none;
}

.dump-places {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.dump-place {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  padding: 14px 10px 12px;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  background: var(--well);
  border: 1px solid var(--line);
  border-top: 3px solid var(--place);
  border-radius: 18px;
  cursor: pointer;
  transition:
    transform 180ms var(--spring),
    background-color 180ms ease,
    box-shadow 180ms ease;
  -webkit-tap-highlight-color: transparent;
}

/* Cross it out sits on a row of its own on a phone, so the four places pair up above it. */
.dump-place.is-cross {
  grid-column: 1 / -1;
  min-height: 60px;
  color: var(--ink-2);
}

.dump-place small {
  color: var(--ink-3);
  font-size: 0.8125rem;
  font-weight: 600;
}

@media (hover: hover) {
  .dump-place:hover {
    background: var(--well-hover);
    box-shadow: 0 16px 30px -20px var(--place);
    transform: translateY(-2px);
  }
}

.dump-place:active {
  transform: scale(0.96);
}

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

/* The place a card just landed in flashes its colour. */
.dump-place.is-hit {
  animation: dump-hit 440ms var(--spring);
}

@keyframes dump-hit {
  35% {
    background: color-mix(in srgb, var(--place) 24%, transparent);
    box-shadow:
      0 0 0 2px var(--place),
      0 0 32px -4px var(--place);
    transform: scale(1.05);
  }
}

/* The keyboard's number for each place: a computer's shortcut, so a phone never shows it. */
.dump-key {
  position: absolute;
  top: 7px;
  left: 11px;
  color: var(--ink-4);
  font-size: 0.75rem;
  font-weight: 800;
}

@media (hover: none) {
  .dump-key {
    display: none;
  }
}

/* How many lines a place holds, on its button: it pops as each card lands. */
.dump-place-count {
  position: absolute;
  top: 6px;
  right: 8px;
  min-width: 22px;
  padding: 2px 6px;
  box-sizing: border-box;
  color: var(--on-accent);
  font-size: 0.75rem;
  font-weight: 850;
  line-height: 1.25;
  background: var(--place);
  border-radius: 999px;
  box-shadow: 0 0 12px -2px var(--place);
}

.dump-place-count.is-empty {
  visibility: hidden;
}

@media (min-width: 720px) {
  .dump-places {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .dump-place,
  .dump-place.is-cross {
    grid-column: auto;
    min-height: 96px;
  }
}

/* 3. Pick one thing: the choices to circle, then the one, lit. */

.dump-choices {
  display: grid;
  gap: 10px;
  max-width: 30rem;
  margin: 20px auto 0;
  padding: 0;
  list-style: none;
}

.dump-choice {
  display: flex;
  gap: 14px;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  min-height: 58px;
  padding: 14px 18px;
  color: var(--ink);
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 750;
  line-height: 1.3;
  text-align: left;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 16px;
  cursor: pointer;
  transition:
    transform 180ms var(--spring),
    border-color 180ms ease,
    background-color 180ms ease;
  -webkit-tap-highlight-color: transparent;
}

/* The circle you would draw round it on paper. */
.dump-choice::before {
  flex: none;
  width: 20px;
  height: 20px;
  box-sizing: border-box;
  border: 2px solid var(--ink-4);
  border-radius: 50%;
  content: "";
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease;
}

@media (hover: hover) {
  .dump-choice:hover {
    background: var(--well-hover);
    border-color: rgb(255 176 113 / 0.45);
    transform: translateY(-1px);
  }
}

@media (hover: hover) {
  .dump-choice:hover::before {
    border-color: var(--lit);
    box-shadow: 0 0 10px var(--lit-glow);
  }
}

.dump-choice:active {
  transform: scale(0.98);
}

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

.dump-next {
  max-width: 30rem;
  margin: 20px auto 0;
  padding: 26px clamp(18px, 4vw, 28px);
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgb(255 154 77 / 0.2), transparent 70%),
    linear-gradient(180deg, var(--card-top), var(--card-bottom));
  border-radius: 24px;
}

.dump-next-kicker {
  margin: 0;
  color: var(--accent-text);
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dump-next-title {
  margin: 10px 0 0;
  color: var(--ink);
  font-size: clamp(1.375rem, 1.2rem + 1vw, 1.75rem);
  font-weight: 850;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.dump-smaller {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  text-align: left;
}

.dump-smaller span {
  color: var(--ink-3);
  font-size: 0.875rem;
  font-weight: 650;
  line-height: 1.4;
}

.dump-next .tool-actions {
  margin-top: 18px;
}

/* Done: the step keeps its glow and gains a tick; the field and the choice go. */
.dump-next.is-done .dump-smaller,
.dump-next.is-done .tool-actions {
  display: none;
}

.dump-next.is-done .dump-next-title::before {
  margin-right: 8px;
  color: var(--lit);
  content: "✓";
}

/* Keep it: copy, download, print or start again. */

.dump-keep {
  max-width: 36rem;
  margin: 26px auto 0;
  text-align: center;
}

.dump-keep-words {
  margin: 0;
  color: var(--ink-2);
  font-size: 1.0625rem;
  font-weight: 650;
  line-height: 1.5;
}

.dump-keep .tool-actions {
  margin-top: 14px;
}

.dump-keep-text {
  margin-top: 16px;
  min-height: 12rem;
  font-size: 0.9375rem;
}

/* The printed page, filled by the script just before it prints. */
.dump-print {
  display: none;
}

/* Paper, for anyone who empties a head better with a pen. */
.dump-paper {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  max-width: 56rem;
  margin: 18px auto 0;
  color: var(--ink-3);
  font-size: 0.9375rem;
  font-weight: 650;
  text-align: center;
}

.dump-paper .tool-button {
  min-height: 40px;
  padding: 8px 16px;
  font-size: 0.875rem;
  text-decoration: none;
}

@media print {
  @page {
    margin: 16mm;
  }

  .tool-head,
  .dump-stage,
  .dump-keep,
  .dump-paper,
  .tool-words {
    display: none !important;
  }

  .dump-print {
    display: block;
  }

  .dump-print,
  .dump-print * {
    color: #3e2c20 !important;
  }

  .dump-print h2 {
    margin: 0 0 12px;
    font-size: 22pt;
    font-weight: 850;
  }

  .dump-print-step {
    margin: 0 0 14px;
    padding: 10px 14px;
    font-size: 14pt;
    font-weight: 800;
    border: 2px solid #ff7a1a;
    border-radius: 12px;
  }

  .dump-print h3 {
    margin: 16px 0 4px;
    font-size: 13pt;
    font-weight: 800;
  }

  .dump-print ul {
    margin: 0;
    padding-left: 20px;
  }

  .dump-print li {
    margin: 3px 0;
    font-size: 11.5pt;
    line-height: 1.4;
  }

  /* Nothing typed yet: the page says where the paper template is, rather than printing blank. */
  .dump-print:empty::before {
    content: "Nothing written yet. The printable brain dump template is at mindpocket.app/tools/brain-dump";
    font-size: 13pt;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dump-place,
  .dump-choice,
  .dump-choice::before,
  .dump-meter i,
  .dump-timer .dump-timer-left {
    transition: none;
  }

  .dump-place.is-hit {
    animation: none;
  }
}
