/* ---------------------------------------------------------------------------
   Reset, document defaults, and the primitives shared by more than one card.
   A rule earns its place here only when two components need it.
   --------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input { font: inherit; color: inherit; }
button { background: none; border: 0; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- scrollbars ----------------------------------------------------------- */

/* Only visible at all when the system is set to show them permanently rather
   than as an overlay — but then the default track is an opaque rectangle
   running the whole edge of the scrollport, and a card with an 18px radius
   slices its end into a wedge. That is the notch in the bottom corner of the
   calendar: not the corner itself, the scrollbar being cut by it.
   A transparent track leaves nothing rectangular to clip. The thumb is drawn
   inside a 3px transparent border so it floats clear of the edges and never
   reaches the curve either. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

*::-webkit-scrollbar { width: 12px; height: 12px; }
*::-webkit-scrollbar-track,
*::-webkit-scrollbar-corner { background: transparent; }

*::-webkit-scrollbar-thumb {
  background: var(--line);
  background-clip: content-box;
  border: 3px solid transparent;
  border-radius: 8px;
}

*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

/* Every figure in the interface is tabular — times, counts, dates, percentages
   all have to line up in a column somewhere. */
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* --- shared primitives --------------------------------------------------- */

/* A tinted label. Reads --tint/--tint-bg from its own data-color. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--tint);
  background: var(--tint-bg);
  border-radius: var(--r-pill);
  padding: 1px 7px;
  white-space: nowrap;
  flex: none;
}

/* The completion checkbox. Shared, because a task looks the same whether it is
   in the workspace list or on a project page — and because the project page
   spent a while with an unstyled box that never showed a tick. */
.tick {
  appearance: none;
  width: 14px;
  height: 14px;
  flex: none;
  display: grid;
  place-content: center;
  border: 1.5px solid var(--line);
  border-radius: 5px;
  background: var(--fill);
  cursor: pointer;
}

.tick:hover { border-color: var(--muted); }

.tick::after {
  content: "";
  width: 7px;
  height: 4px;
  border-left: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg) translate(.5px, -1px);
  opacity: 0;
}

.tick:checked {
  background: var(--ok);
  border-color: var(--ok);
}

.tick:checked::after { opacity: 1; }

/* Count badge, used in card headers and task group headers. */
.tally {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--muted);
  background: var(--fill-2);
  border: 1px solid var(--hair);
  border-radius: var(--r-pill);
  padding: 0 7px;
  flex: none;
}

.linkish {
  padding: 0;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--line);
  white-space: nowrap;
}

.linkish:hover {
  color: var(--accent-ink);
  text-decoration-color: currentColor;
}

.empty {
  padding: 30px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--faint);
}

kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  background: var(--fill);
  border: 1px solid var(--hair);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  min-width: 20px;
  text-align: center;
  display: inline-block;
}

.spacer { margin-left: auto; }

/* --- rendered markdown ---------------------------------------------------- */

/* Produced by lib/markdown.js and used by every block of prose someone typed:
   a briefing, a finding, a project summary, a note in the editor. Here rather
   than in any one section's stylesheet for the same reason the task marks are —
   and because the alternative is four copies of a paragraph rule that drift.

   Sizing is inherited on purpose. A note in the editor and a briefing on Today
   want different type sizes, so each host sets `font-size` on its own container
   and everything below is relative to it. */
.md-p,
.md-list,
.md-quote,
.md-pre {
  /* Space below rather than above, so the first block in a container sits flush
     with the top of it and the container's own padding is the only thing above. */
  margin-bottom: .7em;
  line-height: 1.68;
  color: var(--ink-2);
}

.md-p:last-child,
.md-list:last-child,
.md-quote:last-child,
.md-pre:last-child { margin-bottom: 0; }

/* h3 and down — the cards these render inside already own h2, and a note is not
   allowed to outrank the panel it is sitting in. All one size: a note with six
   levels of heading in it is a document, and this is not where you write one. */
.md-h {
  margin: 1.1em 0 .35em;
  font-size: 1.06em;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--ink);
}

.md-h:first-child { margin-top: 0; }

.md-list { padding-left: 1.35em; }
.md-item { margin-bottom: .18em; }
.md-item::marker { color: var(--faint); }

.md-quote {
  padding-left: .9em;
  border-left: 2px solid var(--hair);
  color: var(--muted);
}

.md-strong { font-weight: 640; color: var(--ink); }
.md-em { font-style: italic; }
.md-del { color: var(--faint); }

.md-code,
.md-pre {
  font-family: var(--font-mono);
  font-size: .88em;
}

.md-code {
  padding: .1em .35em;
  border-radius: 5px;
  border: 1px solid var(--hair);
  background: var(--fill-2);
  color: var(--ink-2);
}

/* The one block allowed its own scrollbar. A pasted line of code is as long as
   it is, and wrapping it would be a worse lie than making it scroll. */
.md-pre {
  padding: .7em .8em;
  border-radius: 9px;
  border: 1px solid var(--hair);
  background: var(--fill-2);
  overflow-x: auto;
}

.md-pre .md-code,
.md-pre code {
  padding: 0;
  border: 0;
  background: none;
  white-space: pre;
}

.md-rule {
  margin: 1em 0;
  border: 0;
  border-top: 1px solid var(--hair);
}

.md-link {
  color: var(--accent-ink);
  text-decoration: underline;
  text-decoration-color: var(--hair);
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.md-link:hover { text-decoration-color: currentColor; }

/* --- what a task carries -------------------------------------------------- */

/* Drawn by views/taskmeta.js and used by all three places a task appears — the
   list in Plan, the day's cards in Today, the work under a project — plus the
   milestone rows, which carry a note in exactly the same way. They live here
   rather than in any one section's stylesheet because a mark shared by four
   views belongs to none of them, and because two copies of `.rem` in two files
   is the collision the suite exists to catch. */

/* Says there is more written down than the row is showing. Kept even though the
   note's first line is now on the row beneath: that line is clipped, and a
   clipped line cannot say it was clipped. This can, in the width of a dot. */
.has-note {
  margin-left: 6px;
  font-size: 15px;
  line-height: 0;
  vertical-align: middle;
  color: var(--tint, var(--muted));
}

/* The opening of a note. One line, always — a note can run to four thousand
   characters and a row is not where any of them past the first are read. */
.note-peek {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--faint);
}

/* The deadline: the flag, and how many days.
   The flag is what stops it reading as a third plain date beside the other two.
   `due` is when you meant to do it and moves freely; this one does not move,
   which is why it is the only thing in these rows allowed to turn red. */
.dl {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: none;
  padding: 0 6px 0 4px;
  border-radius: var(--r-pill);
  border: 1px solid var(--hair);
  background: var(--fill-2);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  color: var(--muted);
}

.dl.is-late {
  color: var(--danger);
  border-color: var(--danger);
  background: transparent;
  font-weight: 500;
}

/* The reminder marker. Quieter than the time it hangs off — a time is a fact
   about the task, this is a fact about your phone — but it keeps the mono
   digits so "10m" lines up with the "09:00" beside it. */
.rem {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  color: var(--faint);
}

.rem svg { opacity: .8; }

/* Already sent, so it has stopped being something that is going to happen.
   Hollowed out rather than hidden: the row should still say a reminder was on
   it, or a message you half-remember has no explanation on the board. */
.rem.is-sent { opacity: .45; }

/* Set, but there is no bot for it to go to. The one state in these rows worth a
   colour: everything else is a fact about the task, and this is a promise the
   board cannot keep until you go and connect one. */
.rem.is-idle { color: var(--danger); }
.rem.is-idle svg { opacity: 1; }

/* Finished work drops out of the conversation, wherever it is drawn. */
.done .note-peek,
.done .has-note,
.done .dl,
.done .rem { color: var(--faint); opacity: .6; }

.done .dl { border-color: var(--hair); background: var(--fill-2); font-weight: 400; }

.sub-head {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
}

/* Reduced motion is a hard stop: nothing here is load-bearing. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
