/*
 * THE WATCHTOWER. Night is a gradient, not an animation loop.
 *
 * Everything about the passage of time is expressed through ONE custom property, --sun
 * (0 = midnight, 1 = full day). app.js sets it; these rules react to it. That is deliberate:
 * the sky can change continuously without a single tappable element being touched.
 */
:root {
  --sun: 1;
  --ink: #f2f6ff;
  --panel: rgba(10, 16, 34, 0.62);
  /* Buttons need to be MORE opaque than a card. A card is read against itself; a button can
     end up anywhere on the sky, and the bottom of the daylight gradient is nearly white. */
  --btn: rgba(10, 16, 34, 0.78);
  --edge: rgba(160, 190, 255, 0.28);
  --go: #7fd48a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  background: #06080f;
}

.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  transition: background 1.2s linear;
  background:
    linear-gradient(180deg,
      color-mix(in srgb, #0a1030 calc((1 - var(--sun)) * 100%), #4aa3ff) 0%,
      color-mix(in srgb, #141b3c calc((1 - var(--sun)) * 100%), #bfe3ff) 62%,
      color-mix(in srgb, #1d1430 calc((1 - var(--sun)) * 100%), #ffd9a8) 100%);
}
.sky__stars {
  position: absolute; inset: 0;
  opacity: calc(1 - var(--sun));
  transition: opacity 1.2s linear;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 22%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 68% 14%, #fff, transparent),
    radial-gradient(1.6px 1.6px at 38% 46%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 84% 58%, #fff, transparent),
    radial-gradient(1.3px 1.3px at 24% 72%, #fff, transparent),
    radial-gradient(1.1px 1.1px at 56% 82%, #fff, transparent);
}
.sky__sun {
  /* Off to one side, not dead centre: behind the stack of cards it read as a smudge rather
     than a sun, and the sun's height is the one thing this screen most needs to say. */
  position: absolute;
  right: 8%;
  top: calc(86% - var(--sun) * 74%);
  width: 74px; height: 74px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff6d8, #ffcf6b 60%, transparent 72%);
  opacity: calc(0.25 + var(--sun) * 0.75);
  transition: top 1.2s linear, opacity 1.2s linear;
}

.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
}
.top__back, .top__clock {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 999px;
  backdrop-filter: blur(8px);
}
.top__back {
  color: var(--ink); text-decoration: none;
  padding: 10px 16px; min-height: 44px; display: flex; align-items: center;
}
.top__clock {
  margin: 0; font-variant-numeric: tabular-nums;
  padding: 10px 16px; min-height: 44px; display: flex; align-items: center;
}
/* display:flex above would beat the user-agent [hidden] rule on its own. */
.top__clock[hidden], .top__back[hidden] { display: none; }

.wrap { max-width: 640px; margin: 0 auto; padding: 8px 16px 96px; }

.card {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 18px;
  padding: 16px;
  margin: 0 0 14px;
  backdrop-filter: blur(8px);
}

h1, h2 { margin: 0 0 8px; line-height: 1.2; overflow-wrap: anywhere; }
h1 { font-size: clamp(21px, 5.6vw, 30px); }
h2 { font-size: clamp(17px, 4.4vw, 21px); }
p { margin: 0 0 10px; }
label { display: block; margin-bottom: 4px; }
.muted { opacity: 0.78; font-size: 15px; }

button, .act {
  font: inherit;
  min-height: 44px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--edge);
  /* NOT a translucent white wash. That is what made the four buttons at the foot of the
     field almost invisible in daylight: near-white text over a 5%-white veil sitting on a
     near-white sky, measured at 1.2:1. A button carries its own dark ground now. */
  background: var(--btn);
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible, a:focus-visible { outline: 3px solid #ffd166; outline-offset: 2px; }

.act--go {
  display: block;
  width: 100%;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  background: linear-gradient(180deg, #2f7d4a, #24603a);
  border-color: #55c07d;
}
.act--ghost { width: 100%; background: var(--btn); }

.row { display: flex; flex-wrap: wrap; gap: 8px; }
.row > * { flex: 1 1 40%; }

.mob { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--edge); }
.mob:first-child { border-top: 0; }
.mob__face { font-size: 24px; }
.mob__body { flex: 1 1 auto; min-width: 0; }
.mob__name { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.mob__hp { display: block; height: 8px; border-radius: 6px; background: rgba(255,255,255,0.14); overflow: hidden; margin: 6px 0 2px; }
.mob__fill { display: block; height: 100%; background: linear-gradient(90deg, #ff7a7a, #ffb45c); transition: width .6s linear; }
.mob--down .mob__name { text-decoration: line-through; opacity: 0.6; }

/* The one he is on. The big green button belongs to this row and nothing said so. */
.mob--now {
  background: rgba(127, 212, 138, 0.14);
  border-radius: 12px;
  box-shadow: inset 3px 0 0 var(--go);
  padding-left: 10px;
}
/* A hobby is not a monster. Same bar, friendlier colour. */
.mob--fun .mob__fill { background: linear-gradient(90deg, #7fd48a, #bfe3ff); }

.tick { display: flex; align-items: center; gap: 10px; padding: 8px 0; min-height: 44px; }
.tick input { width: 22px; height: 22px; flex: 0 0 auto; }
/* The label fills the row, so the whole 44px band is the tap target and not just the two
   lines of text inside it. On a checklist of seven this is the difference between tapping
   and aiming. */
/* A day heading inside the parent list — quieter than a card heading, because it is a label
   on a group of rows and not a new subject. */
.pending__day { font-size: 0.95rem; margin: 14px 0 2px; opacity: 0.85; }
.pending__day:first-of-type { margin-top: 4px; }
/* The hint takes a line of its own rather than squeezing in beside a long title, where it
   wrapped into a two-word column and read as part of the name. */
.pending__hint { flex-basis: 100%; font-size: 0.85rem; }

/* The whiteboard reminder. Loud enough that a parent standing at the screen cannot miss it,
   quiet enough that it never looks like a score the app is keeping. */
.whiteboard__call { font-size: 1.05rem; margin: 6px 0 10px; }

/* A break that has run out takes over the screen. It is the one moment in the app that is
   allowed to be loud — everywhere else, loud would mean nagging. */
.break--over {
  background: #b8451f;
  border-color: #ff9b6a;
  text-align: center;
  animation: shout 1.1s ease-in-out infinite alternate;
}
.break--over h1 { font-size: 2rem; }
@keyframes shout { from { filter: brightness(1); } to { filter: brightness(1.35); } }
/* Anyone who has asked for less movement gets a still card that says the same thing. */
@media (prefers-reduced-motion: reduce) { .break--over { animation: none; } }

.tick label {
  margin: 0;
  overflow-wrap: anywhere;
  flex: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-height: 44px;
}

.ask { margin: 14px 0 0; font-weight: 600; }
.sizes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.sizes > button { flex: 1 1 30%; display: flex; flex-direction: column; gap: 2px; align-items: center; }
.sizes > button > b { font-size: 14px; font-weight: 500; opacity: 0.82; }
/* Chosen: a solid green, not a translucent one — the same daylight that washed out the
   ghost buttons would wash out a 28% tint of green just as thoroughly. */
button[aria-pressed="true"] { background: #2c6b45; border-color: var(--go); }

.spare { font-size: clamp(22px, 6vw, 30px); }
.spare--green { color: #b9f6c4; }
.spare--amber { color: #ffd166; }
.spare--red   { color: #ff8a8a; }

.win { margin: 0 0 6px; font-size: 20px; font-weight: 700; color: #b9f6c4; }
.fed { margin: 0 0 6px; color: #ffd9a8; }

@keyframes wonPop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}
.mob--won { animation: wonPop 480ms ease-out; }
.mob--won .mob__face { animation: wonPop 620ms 80ms ease-out; }

.err { color: #ffc9c9; }
.loading { opacity: .7; }

/* The field timeline: numbers, never names — a ten-minute block is too narrow for a title. */
.timeline__track {
  position: relative;
  height: 40px;
  margin-top: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
}
.timeline__block {
  position: absolute;
  top: 0; bottom: 0;
  min-width: 22px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  color: var(--ink);
}
.timeline__block--raid { background: linear-gradient(180deg, #a0e6ac, #5cae6c); }
.timeline__block--busy {
  background: repeating-linear-gradient(45deg,
    rgba(255, 255, 255, 0.20) 0 6px, rgba(255, 255, 255, 0.06) 6px 12px);
  pointer-events: none;
}
.timeline__now {
  position: absolute;
  top: -20px;
  transform: translateX(-50%);
  transition: left 1s linear;
  font-size: 18px;
}

.block-list { margin: 12px 0 0; }
.block { display: flex; align-items: center; justify-content: space-between; gap: 10px;
         padding: 8px 0; border-top: 1px solid var(--edge); }
.block:first-child { border-top: 0; }
.block__info { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.block__remove { flex: 0 0 auto; min-width: 44px; padding: 0; }

.add-block { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--edge); }

input[type="text"], input[type="password"], input[type="time"], textarea {
  font: inherit; width: 100%; min-height: 44px; padding: 10px 12px;
  border-radius: 12px; border: 1px solid var(--edge);
  background: rgba(255,255,255,0.06); color: var(--ink);
}
textarea { resize: vertical; }

@media (prefers-reduced-motion: reduce) {
  .sky, .sky__sun, .sky__stars, .mob__fill, .timeline__now { transition: none; }
  .mob--won, .mob--won .mob__face { animation: none; }
}

/* ── the raid ───────────────────────────────────────────────────────────────
   The tower is the timer. It only ever grows, which is the whole point: a
   countdown made him watch the clock, and a build-up makes him watch his work.
   Nothing here animates on a loop — a block gains a class once, and stays.   */
.tower {
  display: flex;
  flex-wrap: wrap-reverse;      /* bottom-up: a tower is built from the ground */
  align-content: flex-start;
  justify-content: center;
  gap: 4px;
  /* Six to a row, so thirty minutes is five courses high and an hour is ten. Wider than this
     and it stops reading as a tower and starts reading as a progress bar. */
  max-width: 164px;
  margin: 0 auto;
  min-height: 200px;            /* the sky it grows into, so the tower sits on the ground */
  padding: 10px 0;
}
.tower__block {
  width: 22px; height: 22px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.07);
}
.tower__block--laid {
  background: linear-gradient(180deg, #a0e6ac, #5cae6c);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.raid__built { margin: 4px 0 0; font-size: 15px; text-align: center; }
.raid__built b { font-size: 34px; line-height: 1; }

/* The break screens. This countdown is deliberate and the raid's absence of one is too:
   he should feel a break running out, and never feel a raid running out. */
.break__left { margin: 6px 0 0; }
.break__left b { font-size: 40px; line-height: 1; }

/* The skyline: every raid he has finished, standing in a row. */
.skyline { display: flex; align-items: flex-end; gap: 4px; height: 120px; overflow-x: auto; }
.skyline__tower {
  flex: 0 0 12px;
  min-height: 4px;
  border-radius: 3px 3px 0 0;
  background: rgba(255, 255, 255, 0.18);
}
.skyline__tower--clean { background: linear-gradient(180deg, #a0e6ac, #5cae6c); }

/* The exam paper ledger. */
.papers__count { font-size: 22px; font-weight: 700; }
.papers__chart { display: flex; align-items: flex-end; gap: 6px; height: 90px; }
.papers__bar {
  flex: 1 1 0; min-height: 3px; border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #ff9a6b, #d2523c);
}

/*
 * THE WEEK BOARD. One row per day, and it has to STAY one row.
 *
 * He asked for a glance and said so twice — "one glance", "I don't want a super long list".
 * So the day label is a fixed column and the classes are chips that wrap beside it, rather
 * than a block per class. A layout test measures the row height and fails the build if a day
 * ever costs more than a line or two.
 */
.weekrow {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--edge);
}
.weekrow:first-of-type { border-top: 0; }
.weekrow--today { font-weight: 600; }
.weekrow--today .weekrow__day { color: var(--go); }

.weekrow__day {
  flex: 0 0 64px;
  white-space: nowrap;          /* 'Mon 24' on two lines doubles the row height */
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}
.weekrow__chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }

.chip {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  font-size: 14px;
  line-height: 1.6;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip--none { border-color: transparent; opacity: 0.45; }
/* A class that has not happened yet is not a hole — it is simply not its turn. */
.chip--soon { opacity: 0.45; }
.chip--tally { border-color: transparent; opacity: 0.7; }
.chip--done { opacity: 0.7; }

/* The one chip that is a button. It has to look like the thing to tap without becoming the
   loudest thing on a screen whose job is to be quiet. */
button.chip--miss {
  width: auto;
  min-height: 0;
  margin: 0;
  font-size: 14px;
  padding: 2px 10px;
  background: var(--btn);
  border-color: var(--go);
}

/*
 * THE RECORD. Streaks, and four weeks of days read two ways.
 *
 * "I feel discouraged when I cannot see the amount of tasks I completed and some recurring
 * tasks like drum rudiments practice that I'm practicing persistently."
 *
 * The two trails share one x-axis on purpose: 28 days, same order, same width, so a week of
 * focus and a week of finished jobs can be compared by looking rather than by counting. The
 * label is a fixed column for the same reason the week board's day label is.
 */
.streak {
  display: flex; align-items: baseline; justify-content: space-between; gap: 4px 10px;
  flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.streak:last-child { border-bottom: 0; }
.streak__name { min-width: 0; }
/* Name and numbers each stay whole: on a narrow screen the row breaks BETWEEN them, never
   through the middle of "12 in a row", which is what made the first draft unreadable. */
.streak__now { font-weight: 700; white-space: nowrap; }
.streak__best { font-weight: 400; font-size: .85em; }

.trail { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 10px; }
.trail__label { flex: 0 0 58px; font-size: .8em; white-space: nowrap; padding-bottom: 2px; }
.trail__bars { flex: 1 1 auto; display: flex; align-items: flex-end; gap: 2px; height: 56px; }
.trail__bar { flex: 1 1 0; min-height: 2px; border-radius: 2px 2px 0 0; background: #4a3b2a; }
.trail--focus .trail__bar { background: linear-gradient(180deg, #ffd08a, #c88a3a); }
.trail--jobs .trail__bar { background: linear-gradient(180deg, #9fe08a, #4f9a3c); }

.finished__day { font-size: .9em; margin: 12px 0 4px; opacity: .8; }
.finished__row {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 4px 0; border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.finished__row:last-child { border-bottom: 0; }

/* The ordering screen's job name: the whole row is the tap target, and the text stays left
   where a list of names is read from, not centred like a choice of three. */
.plan__name {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  overflow-wrap: anywhere;
}

/*
 * THE MINUTE PICKERS — how long to focus, how long to rest.
 *
 * Three to a row at 320px, so six lengths are two rows and never a scroll. Which one is
 * pressed is drawn by the app's existing button[aria-pressed="true"] rule, because a second
 * way to say "this one is chosen" is a second thing to keep in step.
 */
.row--pick > * { flex: 1 1 28%; min-width: 88px; }
