/* adhno — arcade design system.
 *
 * Loud on purpose. The counterweight to a task list that otherwise feels like a
 * chore is a screen that looks like something worth opening.
 *
 * Two rules run through all of it:
 *   - Red is never used for an unfinished task, only for destructive actions.
 *     Nothing on the home screen should read as "you failed".
 *   - The pixel/display treatment decorates numbers and headings only. Task
 *     titles and body copy stay in a plainly legible face, because ADHD often
 *     travels with dyslexia and a hard-to-read task is a task that doesn't get
 *     started.
 */

:root {
  color-scheme: dark;

  --bg:        #0b0d14;
  --panel:     #151824;
  --panel-2:   #1c2030;
  --line:      #2b3145;

  --ink:       #e8ecf4;
  --muted:     #98a3b8;
  --dim:       #6b7488;

  --cyan:      #22d3ee;   /* primary */
  --cyan-dk:   #0f7f92;
  --magenta:   #e879f9;   /* quests */
  --magenta-dk:#8b3d99;
  --gold:      #fbbf24;   /* xp and coins */
  --gold-dk:   #92700f;
  --green:     #34d399;   /* done */
  --green-dk:  #197a5a;
  --red:       #f87171;   /* destructive only */
  --red-dk:    #8c3535;

  --shadow:    4px 4px 0 var(--cyan-dk);
  --radius:    0px;

  /* Display face: swap in a pixel WOFF2 here and it applies everywhere at once.
     Kept to a system stack by default so the app has no external font
     dependency and no flash of unstyled text. */
  --font-display: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --font-body:    ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --tap: 44px; /* minimum comfortable touch target */
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100dvh;
  /* Room for the fixed bottom nav plus the iPhone home indicator. */
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}

/* Scanlines: a very light CRT texture. Deliberately faint — anything stronger
   costs legibility, and it is switched off entirely with reduced motion. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    to bottom, rgba(255,255,255,.012) 0 1px, transparent 1px 3px);
}
body.no-fx::after { display: none; }

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-weight: 700;
  margin: 0 0 .75rem;
}
h1 { font-size: 1.05rem; color: var(--cyan); }
h2 { font-size: .85rem; color: var(--muted); }
h3 { font-size: .75rem; color: var(--muted); }

/* --------------------------------------------------------------- layout -- */

.wrap {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1rem 1rem 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .85rem 1rem;
  border-bottom: 2px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  font-family: var(--font-display);
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: .22em;
  color: var(--cyan);
  text-transform: uppercase;
}
.brand:hover { text-decoration: none; }

/* ---------------------------------------------------------------- cards -- */

.card {
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: 4px 4px 0 #0a0c12;
  padding: 1rem;
  margin-bottom: 1rem;
}

.card-cyan    { border-color: var(--cyan);    box-shadow: 4px 4px 0 var(--cyan-dk); }
.card-magenta { border-color: var(--magenta); box-shadow: 4px 4px 0 var(--magenta-dk); }
.card-gold    { border-color: var(--gold);    box-shadow: 4px 4px 0 var(--gold-dk); }
.card-green   { border-color: var(--green);   box-shadow: 4px 4px 0 var(--green-dk); }

.eyebrow {
  font-family: var(--font-display);
  font-size: .65rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0 0 .5rem;
}

/* ------------------------------------------------------------- hud bits -- */

.hud {
  display: flex;
  align-items: center;
  gap: .9rem;
  flex-wrap: wrap;
}

.stat {
  font-family: var(--font-display);
  display: inline-flex;
  align-items: baseline;
  gap: .3rem;
  font-size: .8rem;
  letter-spacing: .1em;
}
.stat b { font-size: 1.05rem; font-weight: 700; }
.stat-streak b { color: var(--gold); }
.stat-level  b { color: var(--cyan); }
.stat-coins  b { color: var(--gold); }

/* Segmented XP meter — discrete blocks, not a smooth fill. */
.meter { display: flex; gap: 2px; margin-top: .5rem; }
.meter i {
  display: block;
  flex: 1 1 0;
  height: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.meter i.on { background: var(--cyan); border-color: var(--cyan); }
.meter-gold i.on { background: var(--gold); border-color: var(--gold); }

.meter-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-display);
  font-size: .62rem;
  letter-spacing: .14em;
  color: var(--dim);
  margin-top: .35rem;
  text-transform: uppercase;
}

/* --------------------------------------------------------------- tasks -- */

.task {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem;
  border: 2px solid var(--line);
  background: var(--panel-2);
  margin-bottom: .6rem;
}
.task.is-quest { border-color: var(--magenta); box-shadow: 3px 3px 0 var(--magenta-dk); }
.task.is-boss  { border-color: var(--gold);    box-shadow: 3px 3px 0 var(--gold-dk); }
.task.is-done  { border-color: var(--green-dk); opacity: .6; }
.task.is-done .task-title { text-decoration: line-through; color: var(--muted); }

/* The checkbox is a big square target: a task should never be hard to tick. */
.tick {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border: 2px solid var(--cyan);
  background: transparent;
  cursor: pointer;
  display: grid; place-items: center;
  color: var(--cyan);
  font-size: 1rem; line-height: 1;
  padding: 0;
}
.tick:hover { background: rgba(34,211,238,.12); }
.tick.on { background: var(--green); border-color: var(--green); color: var(--bg); }

.task-body { flex: 1 1 auto; min-width: 0; }

/* The title is a link to the detail page, but it should read as the task itself,
   not as navigation — the tick beside it is the action that matters. */
.task-title {
  display: block;
  font-size: .95rem;
  word-break: break-word;
  color: var(--ink);
}
.task-title:hover { color: var(--cyan); text-decoration: none; }
.task-meta {
  display: flex; gap: .5rem; flex-wrap: wrap;
  margin-top: .3rem;
  font-family: var(--font-display);
  font-size: .6rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--dim);
}

.chip {
  border: 1px solid var(--line);
  padding: .1rem .35rem;
  font-family: var(--font-display);
  font-size: .6rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
}
.chip-xp      { border-color: var(--gold-dk);    color: var(--gold); }
.chip-quest   { border-color: var(--magenta-dk); color: var(--magenta); }
.chip-boss    { border-color: var(--gold);       color: var(--gold); }
.chip-private { border-color: var(--cyan-dk);    color: var(--cyan); }
.chip-energy-high { border-color: var(--magenta-dk); color: var(--magenta); }

/* -------------------------------------------------------------- buttons -- */

.btn {
  font-family: var(--font-display);
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--bg);
  background: var(--cyan);
  border: 2px solid var(--cyan);
  box-shadow: 3px 3px 0 var(--cyan-dk);
  padding: .6rem 1rem;
  min-height: var(--tap);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }
/* Pressing moves the button onto its own shadow — a physical arcade click. */
.btn:active { transform: translate(3px, 3px); box-shadow: none; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-ghost {
  background: transparent; color: var(--cyan);
  box-shadow: 3px 3px 0 var(--cyan-dk);
}
.btn-muted {
  background: transparent; color: var(--muted);
  border-color: var(--line); box-shadow: 3px 3px 0 #0a0c12;
}
.btn-danger {
  background: transparent; color: var(--red);
  border-color: var(--red); box-shadow: 3px 3px 0 var(--red-dk);
}
.btn-sm { padding: .35rem .6rem; min-height: 0; font-size: .62rem; }
.btn-block { display: flex; width: 100%; }

/* ---------------------------------------------------------------- forms -- */

label {
  display: block;
  font-family: var(--font-display);
  font-size: .65rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .35rem;
}

input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  border: 2px solid var(--line);
  padding: .65rem .7rem;
  font-family: var(--font-body);
  font-size: .95rem;
  min-height: var(--tap);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 3px 3px 0 var(--cyan-dk);
}
textarea { min-height: 5rem; resize: vertical; }
.field { margin-bottom: .9rem; }

/* Segmented picker for effort and energy — four visible options beat a select,
   because opening a dropdown to choose is itself a small hurdle. */
.seg { display: flex; gap: 3px; }
.seg button {
  flex: 1 1 0;
  font-family: var(--font-display);
  font-size: .6rem; letter-spacing: .08em; text-transform: uppercase;
  padding: .55rem .2rem;
  min-height: var(--tap);
  background: var(--panel-2);
  color: var(--muted);
  border: 2px solid var(--line);
  cursor: pointer;
}
.seg button.on { background: var(--cyan); border-color: var(--cyan); color: var(--bg); }

/* ------------------------------------------------------------ nav / tabs -- */

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  background: var(--panel);
  border-top: 2px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1 1 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .15rem;
  padding: .55rem .2rem;
  min-height: var(--tap);
  color: var(--dim);
  font-family: var(--font-display);
  font-size: .55rem; letter-spacing: .1em; text-transform: uppercase;
  position: relative;
}
.tabs a:hover { text-decoration: none; }
.tabs a .ico { font-size: 1.15rem; line-height: 1; }
.tabs a.on { color: var(--cyan); }
.tabs a.on::before {
  content: ""; position: absolute; top: 0; left: 20%; right: 20%; height: 3px; background: var(--cyan);
}

.pip {
  position: absolute; top: .3rem; right: 50%; transform: translateX(1.1rem);
  background: var(--magenta); color: var(--bg);
  font-size: .55rem; font-weight: 700;
  min-width: 1.1rem; height: 1.1rem;
  display: grid; place-items: center;
  border-radius: 999px; padding: 0 .2rem;
}

/* --------------------------------------------------------------- flash --- */

#flash:empty { display: none; }
.flash {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(80px + env(safe-area-inset-bottom));
  z-index: 60;
  max-width: 90vw;
  padding: .6rem .9rem;
  border: 2px solid var(--cyan);
  background: var(--panel);
  box-shadow: 4px 4px 0 var(--cyan-dk);
  font-family: var(--font-display);
  font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
  animation: pop .18s ease-out;
}
.flash.err { border-color: var(--red); box-shadow: 4px 4px 0 var(--red-dk); color: var(--red); }
.flash.ok  { border-color: var(--green); box-shadow: 4px 4px 0 var(--green-dk); color: var(--green); }

@keyframes pop { from { transform: translateX(-50%) scale(.9); opacity: 0; } }

/* ---------------------------------------------------------- celebration -- */

#xp-toast:empty { display: none; }
.xp-toast {
  position: fixed;
  left: 50%; top: 30%;
  transform: translateX(-50%);
  z-index: 70;
  font-family: var(--font-display);
  font-size: 2rem; font-weight: 700; letter-spacing: .06em;
  color: var(--gold);
  text-shadow: 3px 3px 0 var(--gold-dk);
  pointer-events: none;
  animation: rise 1.1s ease-out forwards;
}
@keyframes rise {
  0%   { opacity: 0; transform: translate(-50%, 1rem) scale(.8); }
  20%  { opacity: 1; transform: translate(-50%, 0) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -3rem) scale(1); }
}

#confetti {
  position: fixed; inset: 0; z-index: 65; pointer-events: none;
}

/* ---------------------------------------------------------------- misc --- */

.muted { color: var(--muted); }
.dim   { color: var(--dim); }
.center { text-align: center; }
.row { display: flex; gap: .5rem; align-items: center; }
.row-between { display: flex; gap: .5rem; align-items: center; justify-content: space-between; }
.grow { flex: 1 1 auto; }
.stack > * + * { margin-top: .6rem; }

.empty {
  border: 2px dashed var(--line);
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--dim);
  font-family: var(--font-display);
  font-size: .68rem; letter-spacing: .12em; text-transform: uppercase;
}

/* ------------------------------------------------------------- reduced --- */

/* Motion is a preference, not a given. Everything above still reads correctly
   with all of it switched off. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  body::after { display: none; }
  .btn:active { transform: none; }
}

/* ------------------------------------------------------------ utilities -- */

/* The content security policy is style-src 'self', which blocks inline
   style="..." attributes outright. That is deliberate — it keeps injected markup
   from restyling the page — so spacing and sizing live here as named classes
   instead of being scattered through the templates. */

.mt-0  { margin-top: 0; }
.mt-1  { margin-top: .4rem; }
.mt-2  { margin-top: .6rem; }
.mt-3  { margin-top: .8rem; }
.mt-4  { margin-top: 1rem; }
.mb-0  { margin-bottom: 0; }
.mb-2  { margin-bottom: .6rem; }
.mb-3  { margin-bottom: .9rem; }
.mb-4  { margin-bottom: 1rem; }
.mb-6  { margin-bottom: 1.5rem; }
.m-0   { margin: 0; }

.fs-sm  { font-size: .85rem; }
.fs-xs  { font-size: .75rem; }
.fs-2xs { font-size: .68rem; }
.fs-md  { font-size: 1rem; }

.wrap-lines { white-space: pre-wrap; }
.inline-block { display: inline-block; }
.align-start { align-items: flex-start; }
.flex-wrap { flex-wrap: wrap; }

.text-green { color: var(--green); }
.text-gold  { color: var(--gold); }

/* Selected state for the filter chips and other pickers. */
.chip.on  { border-color: var(--cyan); color: var(--cyan); }
.chip.done { border-color: var(--green); color: var(--green); }

.tick-sm { width: 22px; height: 22px; font-size: .8rem; }
.task-compact { padding: .5rem .6rem; }
.step-title { font-size: .85rem; }
.step-title.done { text-decoration: line-through; color: var(--muted); }

.step-preview { margin: .7rem 0 0; padding-left: 1.1rem; font-size: .8rem; }

.back-link {
  font-size: .7rem; letter-spacing: .14em; text-transform: uppercase;
}

/* Login screen: centred card on an otherwise empty page. */
.signin { min-height: 70dvh; display: grid; place-items: center; }
.signin-inner { width: 100%; max-width: 20rem; }
.wordmark { font-size: 1.6rem; letter-spacing: .3em; }
.tagline {
  font-size: .68rem; letter-spacing: .18em; text-transform: uppercase; margin: .4rem 0 0;
}

.hint { font-size: .65rem; margin: .35rem 0 0; }
.note { font-size: .7rem; margin: 0 0 .9rem; }
.note-tight { font-size: .75rem; margin: 0 0 .7rem; }
.lede { font-size: .72rem; margin: 0 0 1rem; }

/* --------------------------------------------------------------- badges -- */

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr));
  gap: .5rem;
}
.badge {
  border: 2px solid var(--line);
  background: var(--panel-2);
  padding: .6rem .3rem;
  text-align: center;
  /* Unearned badges are dimmed, never hidden and never marked as missing: the
     grid should read as things to aim at, not as a list of failures. */
  opacity: .35;
  filter: grayscale(1);
}
.badge.on {
  opacity: 1;
  filter: none;
  border-color: var(--gold);
  box-shadow: 3px 3px 0 var(--gold-dk);
}
.badge-emoji { display: block; font-size: 1.4rem; line-height: 1.2; }
.badge-title {
  display: block;
  font-family: var(--font-display);
  font-size: .5rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
  margin-top: .25rem;
}
.badge.on .badge-title { color: var(--gold); }

/* ---------------------------------------------------------------- chart -- */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 64px;
}
.chart-col { flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; }
.chart-bar {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  min-height: 3px;
}
.chart-bar.on { background: var(--cyan); border-color: var(--cyan); }

/* Fixed height steps, because the CSP blocks inline style attributes. */
.chart-bar.h0 { height: 3px; }
.chart-bar.h1 { height: 12%; }
.chart-bar.h2 { height: 25%; }
.chart-bar.h3 { height: 37%; }
.chart-bar.h4 { height: 50%; }
.chart-bar.h5 { height: 62%; }
.chart-bar.h6 { height: 75%; }
.chart-bar.h7 { height: 87%; }
.chart-bar.h8 { height: 100%; }

/* ---------------------------------------------------------------- timer -- */

.timer {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--magenta);
  text-shadow: 4px 4px 0 var(--magenta-dk);
  line-height: 1.1;
}

/* ------------------------------------------------------------ misc bits -- */

.assigned-row { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.assigned-row:last-child { border-bottom: 0; }

.chip.muted { border-color: var(--line); color: var(--dim); }

.code {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: .6rem .7rem;
  font-size: .72rem;
  overflow-x: auto;
  color: var(--cyan);
  margin: 0;
}

/* Checkbox rows read as labels, not as headings. */
label > input[type=checkbox] {
  width: auto; min-height: 0; margin-right: .4rem; accent-color: var(--cyan);
}
