/* ---------------------------------------------------------------------
   tasklist — Manaurum Platform v2 sample

   Two voices, deliberately:
     · human  — the task text. The largest type on screen. There is no
                headline; the content is the display type.
     · machine — every piece of chrome (state bar, telemetry rail) is
                monospace, small, and quiet.

   Accent is gold, from the aurum in Manaurum. It appears in exactly
   three places: the composer's focus state, a completed checkbox, and
   the keyboard focus ring. Completion is otherwise expressed by
   typography — muted ink and a rule drawn through the text — not by
   adding a second colour.
   --------------------------------------------------------------------- */

:root {
  --bg:        #fcfcfb;
  --panel:     #ffffff;
  --ink:       #15171b;
  --ink-2:     #5a616e;
  --ink-3:     #696f7c;  /* 4.9:1 on --bg — muted, still AA */
  --rule:      #e7e7e3;
  --rule-firm: #d8d8d2;
  --accent:    #a8761a;  /* strokes, rings, marks (3.98:1 — non-text) */
  --accent-solid: #8a6114; /* button fill: 5.5:1 behind white text */
  --accent-bg: rgba(168, 118, 26, 0.10);
  --danger:    #a3382a;

  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
          Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono",
          Menlo, Consolas, "Liberation Mono", monospace;

  --pad: 20px;
  --measure: 34rem;
}

body[data-appearance="dark"] {
  --bg:        #17181c;
  --panel:     #1e2025;
  --ink:       #edeef0;
  --ink-2:     #9aa0ac;
  --ink-3:     #878d99;  /* 5.3:1 on --bg */
  --rule:      #2a2d34;
  --rule-firm: #383c45;
  --accent:    #e4b23e;
  --accent-solid: #e4b23e; /* dark ink on gold — already high contrast */
  --accent-bg: rgba(228, 178, 62, 0.14);
  --danger:    #e0705f;
}

/* Opened directly in a browser tab, before/without a shell handshake:
   follow the OS. Scoped to :not([data-appearance="light"]) so that once
   the shell says "light", it stays light even on a dark-mode machine —
   putting these tokens on :root instead would silently override the
   shell for every dark-OS user. */
@media (prefers-color-scheme: dark) {
  body:not([data-appearance="light"]) {
    --bg:        #17181c;
    --panel:     #1e2025;
    --ink:       #edeef0;
    --ink-2:     #9aa0ac;
    --ink-3:     #878d99;
    --rule:      #2a2d34;
    --rule-firm: #383c45;
    --accent:    #e4b23e;
    --accent-solid: #e4b23e;
    --accent-bg: rgba(228, 178, 62, 0.14);
    --danger:    #e0705f;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

:where(button, input):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* --- state bar ----------------------------------------------------- */

.bar {
  flex: 0 0 auto;
  padding: 14px var(--pad) 0;
  display: flex;
  justify-content: center;
}

.bar__state {
  width: 100%;
  max-width: var(--measure);
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* --- sheet --------------------------------------------------------- */

.sheet {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px var(--pad) 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.sheet > * {
  width: 100%;
  max-width: var(--measure);
}

/* --- composer ------------------------------------------------------ */

.composer {
  display: flex;
  gap: 8px;
  align-items: stretch;
  background: var(--panel);
  border: 1px solid var(--rule-firm);
  border-radius: 10px;
  padding: 4px 4px 4px 14px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.composer__input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.4;
  padding: 10px 0;
}

.composer__input:focus { outline: none; }
.composer__input::placeholder { color: var(--ink-3); }

.composer__go {
  flex: 0 0 auto;
  border: 0;
  border-radius: 7px;
  padding: 0 16px;
  background: var(--accent-solid);
  color: var(--bg);
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: opacity 140ms ease, transform 100ms ease;
}

.composer__go:disabled {
  opacity: 0.28;
  cursor: default;
}

.composer__go:not(:disabled):active { transform: scale(0.97); }

/* --- list ---------------------------------------------------------- */

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

.task {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 12px;
  padding: 11px 4px 11px 2px;
  border-bottom: 1px solid var(--rule);
}

.task:last-child { border-bottom: 0; }

@media (prefers-reduced-motion: no-preference) {
  .task--enter { animation: rowIn 160ms cubic-bezier(0.2, 0.7, 0.3, 1) both; }
}

@keyframes rowIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

.task__box {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  margin: 0;
  /* Optically centred on the FIRST line, not on the whole row — a
     two-line task should not push its marker halfway down. */
  align-self: start;
  margin-top: 4px;
  border: 1.5px solid var(--rule-firm);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.task__box:hover { border-color: var(--ink-3); }

.task__box:checked {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.task__box:checked::after {
  content: "";
  width: 8px;
  height: 4px;
  border-left: 1.75px solid var(--accent);
  border-bottom: 1.75px solid var(--accent);
  transform: rotate(-45deg) translate(1px, -1px);
}

.task__title {
  font-size: 1.0625rem;
  line-height: 1.45;
  color: var(--ink);
  cursor: pointer;
  overflow-wrap: anywhere;
  transition: color 180ms ease;
}

.task__text { position: relative; }

/* The rule draws through the text left-to-right when a task is
   completed — the only other motion in the app. */
.task__text::after {
  content: "";
  position: absolute;
  left: 0;
  top: 55%;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

.task--done .task__title { color: var(--ink-3); }
.task--done .task__text::after { transform: scaleX(1); }

@media (prefers-reduced-motion: reduce) {
  .task__text::after { transition: none; }
}

.task__del {
  align-self: start;
  border: 0;
  background: none;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 1rem;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease, color 120ms ease;
}

.task:hover .task__del,
.task__del:focus-visible { opacity: 1; }

.task__del:hover { color: var(--danger); }

/* Nothing to hover on touch — keep the control reachable. */
@media (hover: none) {
  .task__del { opacity: 1; }
}

/* --- note ---------------------------------------------------------- */

.note {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ink-2);
}

.note:empty { display: none; }

.note--error { color: var(--danger); }

/* --- telemetry rail ------------------------------------------------ */

/* The signature element. A task list is a task list anywhere; what
   makes this one a Platform v2 sample is that the identity, the
   storage location, and the running version are visible facts rather
   than assumptions. It is also the fastest way to debug a v2 app.
   A production app would drop this. */

.rail {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px var(--pad);
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--rule);
  background: var(--panel);
  font-family: var(--mono);
  font-size: 0.6875rem;
  line-height: 1.4;
  color: var(--ink-3);
  user-select: text;
}

/* Real schema names are app_tasklist__<tenant hex> — long. Give them
   room, let the rail wrap rather than ellipsing the interesting part,
   and keep the full value on the element's title. */
.rail__cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 24rem;
}

.rail__dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--rule-firm);
}

.rail--live .rail__cell { color: var(--ink-2); }

@media (max-width: 30rem) {
  :root { --pad: 14px; }
  .rail__cell { max-width: 9rem; }
}
