/* Themes, picked in prefs (prefs.js sets data-theme on <html>).
   gruvbox: Gruvbox Material Dark, the custom theme imported into Rex from Ghostty. */
:root {
  --bg: #282828;     /* background */
  --text: #d4be98;   /* foreground, 8.2:1 */
  --accent: #d8a657; /* yellow, 6.7:1: titles, prompt, focus */
  --ok: #a9b665;     /* green, 6.7:1: done, progress, strike line */
  --info: #7daea3;   /* blue, 5.9:1: sparks */
  --line: #7c6f64;   /* bright black: borders and decoration */
  --danger: #ea6962; /* red, 4.7:1: delete */
  --dim: color-mix(in srgb, var(--text) 70%, var(--bg)); /* 4.8:1: dates, counts, hints, history */
  --tint: #d4be98;   /* selection background, with --bg text */
}
/* dark: neutral grays. */
:root[data-theme="dark"] {
  --bg: #1c1c1c;     /* text 13.7:1 */
  --text: #e6e6e6;
  --accent: #8ab4f8; /* 8.1:1 */
  --ok: #81c995;     /* 8.7:1 */
  --info: #fdd663;
  --line: #5f6368;
  --danger: #f28b82; /* 7.1:1 */
  --dim: color-mix(in srgb, var(--text) 65%, var(--bg)); /* 6.4:1 */
  --tint: #e6e6e6;
}
/* light: near-white paper. */
:root[data-theme="light"] {
  --bg: #fafafa;     /* text 15.8:1 */
  --text: #1f1f1f;
  --accent: #1a5fc8; /* 5.7:1 */
  --ok: #137333;     /* 5.7:1 */
  --info: #9a5b00;
  --line: #b8b8b8;
  --danger: #c5221f; /* 5.6:1 */
  --dim: color-mix(in srgb, var(--text) 70%, var(--bg)); /* 5.9:1 */
  --tint: #1f1f1f;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html {
  background: var(--bg);
  color: var(--text);
  /* Installed fonts only, nothing downloaded. The Nerd Font Mono build has every weight; plain JetBrains Mono is regular only. */
  font: var(--size, 15px)/1.5 "JetBrainsMono NFM", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}
body { margin: 0; padding: 12px 14px; }
::selection { background: var(--tint); color: var(--bg); }

header { display: flex; justify-content: space-between; align-items: baseline; gap: 1ch; padding: 0 4px; }
h1 { margin: 0; color: var(--accent); font: inherit; font-weight: bold; }
#today { color: var(--dim); }

/* Tiles: boxed windows with the title set into the top border, like ┌─ - todo ──── 3 ─ x ┐.
   The focused tile's border turns yellow. Drag the bar or press J/K to move one. */
#tiles { display: flex; flex-direction: column; gap: 18px; margin-top: 22px; }
.tile { position: relative; padding: 14px 6px 6px; border: 1px solid var(--line); transition: border-color 0.15s; }
.tile:focus-within, .dragging { border-color: var(--accent); }
.dragging { z-index: 1; box-shadow: 0 8px 20px rgb(0 0 0 / 0.4); }
.bar { position: absolute; top: -0.78em; left: 8px; right: 8px; display: flex; align-items: center; cursor: grab; user-select: none; }
.dragging .bar { cursor: grabbing; }
.bar > * { flex: none; padding: 0 0.6ch; background: var(--bg); }
.fold { color: var(--dim); }
.fold:hover { color: var(--accent); }
.title { field-sizing: content; min-width: 5ch; max-width: 60%; font-weight: bold; cursor: text; }
.tile:focus-within .title { color: var(--accent); }
.n { margin-left: auto; color: var(--dim); }
.n:empty { padding: 0; }
.close { color: var(--dim); visibility: hidden; }
.tile:hover .close, .tile:focus-within .close { visibility: visible; }
.close:hover, .close.confirm { color: var(--danger); }
#tiles.only .close { display: none; }
.collapsed { padding: 6px; }
.collapsed .body { display: none; }
#actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 2ch; margin-top: 16px; }
#actions button, #actions a { padding: 6px 10px; color: var(--dim); white-space: nowrap; text-decoration: none; }
#actions a:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
#actions button:hover, #actions a:hover, #prefs-btn[aria-expanded="true"] { color: var(--accent); }

/* Prefs: a box like a tile, with ASCII radio buttons ( ) (*). */
#prefs { position: relative; margin-top: 22px; padding: 14px 10px 8px; border: 1px solid var(--accent); }
#prefs .bar { cursor: default; }
#prefs .bar span { color: var(--accent); font-weight: bold; }
.pref { display: flex; align-items: flex-start; gap: 1ch; }
.pref .key { flex: none; width: 6ch; line-height: 40px; color: var(--dim); }
.opts { display: flex; flex-wrap: wrap; align-items: center; gap: 0 2ch; }
.pref label { display: flex; align-items: center; min-height: 40px; cursor: pointer; }
.pref input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.mark::before { content: "( ) "; color: var(--dim); white-space: pre; }
input:checked + .mark::before { content: "(*) "; color: var(--accent); }
input:focus-visible + .mark { outline: 1px solid var(--accent); }
.pref button { min-height: 40px; color: var(--dim); }
.pref button:hover { color: var(--accent); }
.pref button:disabled { opacity: 0.4; cursor: default; }
#size-out { min-width: 4ch; text-align: center; }

.prompt { display: flex; gap: 1ch; align-items: center; min-height: 40px; padding: 0 4px; color: var(--accent); }
input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
  font: inherit;
  caret-color: var(--accent);
}
input::placeholder { color: var(--dim); }

ul { margin: 0; padding: 0; list-style: none; }
li { display: flex; border-radius: 3px; }
button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
button:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
.task { flex: 1; min-width: 0; display: flex; gap: 1ch; align-items: baseline; min-height: 40px; padding: 8px 4px; }
.box { flex: none; color: var(--dim); }
.task:hover .box { color: var(--accent); }
.text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.del { flex: none; width: 40px; color: var(--dim); text-align: center; }
.del:hover { color: var(--danger); }
.open .label:hover { cursor: text; text-decoration: underline dotted var(--dim); text-underline-offset: 3px; }
li.editing .task { display: none; }
li.editing::before { content: "[ ]"; flex: none; padding: 8px 1ch 8px 4px; color: var(--accent); }
.edit { flex: 1; min-height: 40px; box-shadow: inset 0 -1px var(--accent); }
.done .box { color: var(--ok); }
.deleted .box { color: var(--dim); }
.done .text { color: var(--dim); text-decoration: line-through; }
.empty { margin: 4px 4px 8px; color: var(--dim); }

/* Today's progress: [#######-------------] 2/5 */
#progress { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 1ch; padding: 0 4px; color: var(--dim); white-space: pre; }
#fill { color: var(--ok); }
#rest { color: var(--line); }

.away h1 { color: var(--dim); }
.away .tile:focus-within { border-color: var(--line); }
.away .keys, :root:not(.away) .hint { display: none; }
footer { margin-top: 16px; padding: 0 4px; color: var(--dim); font-size: 0.8em; text-align: center; }

/* Finishing a task: the box spins [-] [\] [|] [/] [x] (panel.js), sparks fly,
   a green line strikes through, the row flashes, then slides away. */
.label {
  background: linear-gradient(var(--ok), var(--ok)) no-repeat 0 55% / 0 2px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-size 0.25s 0.15s ease-out;
}
.finished .label { background-size: 100% 2px; color: var(--dim); transition: background-size 0.25s 0.15s ease-out, color 0.3s 0.2s; }
.finished .box { color: var(--accent); }
.finished { animation: flash 0.5s ease-out, leave 0.2s 0.45s ease-in forwards; }
.restored .box { color: var(--accent); }
.restored { animation: leave 0.2s 0.2s ease-in forwards; }
.gone .label { color: var(--dim); text-decoration: line-through var(--danger) 2px; }
.gone { animation: gone 0.2s ease-in forwards; }
.fresh { animation: enter 0.25s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--ok) 22%, transparent); } }
@keyframes leave { to { opacity: 0; transform: translateX(8px); } }
@keyframes gone { to { opacity: 0; transform: translateX(-8px); } }
@keyframes enter { from { opacity: 0; transform: translateX(-6px); } }
.spark { position: fixed; z-index: 1; pointer-events: none; font-size: 1.13em; font-weight: bold; }
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { animation: none !important; transition: none !important; }
}

/* Theme change: the new theme wipes across from the left (prefs.js starts it). */
::view-transition-old(root) { animation: none; }
::view-transition-new(root) { animation: wipe 0.5s cubic-bezier(0.65, 0, 0.35, 1); }
@keyframes wipe { from { clip-path: inset(0 100% 0 0); } }

.when { flex: none; color: var(--dim); }
.history { margin-top: 4px; }
summary { padding: 8px 4px; border-radius: 3px; color: var(--dim); list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "+ "; }
.history[open] summary::before { content: "- "; }
summary:hover { color: var(--accent); }
summary:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
