:root {
  line-height: 1.4rem;
  --line-length: 23rem;
  --big: 2rem;
}

a.brand {
  color: var(--fg);
  text-decoration: none;
  background-image: url("/logo.png");
  background-size: contain;
  background-repeat: no-repeat;
  display: inline-block;
}

a.brand:hover {
  text-decoration: none;
}

@media (prefers-color-scheme: dark) {
  a.brand {
    background-image: url("/logo-light.png");
  }
}

.brand h1 {
  margin: 0;
  padding: 0;
  color: transparent;
}

.wide {
  --line-length: 42rem;
}

#totals,
#links {
  --density: 0.33;
}

/* The ways to the cosymbionts share one row, and a way broken over two
 * lines would make it two. */

#totals a {
  white-space: nowrap;
}

/* On a phone held upright that row has no room for all of them, so it
 * becomes two: the ways stand in pairs, one at each edge. */

@media (max-width: 720px) and (orientation: portrait) {
  #totals > small {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: space-between;
    row-gap: calc(var(--gap) / 2);
  }

  #totals > small > :nth-child(even) {
    justify-self: end;
  }
}

header {
  border: none;
}

/* The thicket's navigation: the brand in the middle, what comes before it
 * on the left and what comes after it on the right. The two sides are
 * equal, so the brand stays centred however much either of them holds. */

header > nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

header > nav > .brand {
  grid-column: 2;
}

header > nav > .brand ~ * {
  grid-column: 3;
  justify-self: end;
}

/* The dashboard's navigation, which carries the ways to the cosymbionts,
 * stands in two rows instead: the brand at the left with Leave and
 * Refresh at its right, and the ways under them, across the whole row. */

header > nav:has(> #totals) {
  grid-template-columns: auto 1fr;
  row-gap: calc(var(--gap) / 2);
}

header > nav:has(> #totals) > .brand {
  grid-column: 1;
  grid-row: 1;
}

header > nav:has(> #totals) > #links {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  text-align: end;
}

header > nav:has(> #totals) > #totals {
  grid-column: 1 / -1;
  grid-row: 2;
  justify-self: stretch;
}

/* The entrance, for as long as a guardian is standing in the stage.
 *
 * A door looks nothing like the place behind it: one element centred in an
 * empty stage, which is nothing the place itself would ever ask for. That
 * used to be a stylesheet of its own, named by an element the guardian and
 * the symbiont exchanged as the place changed hands. Following the
 * entrance instead, it needs no exchanging and leaves when the entrance
 * does -- and a cosymbiont's door, which renews its document rather than
 * handing it on, never wears it at all. */

#entrance {
  text-align: center;
}

#entrance #gate {
  gap: var(--gap);
}

/* The project filters, a cloud: each name sized by its todos, wrapping
 * within the line length -- a long name with nowhere to break breaks
 * anywhere rather than run past it. The box is hidden but still takes the
 * focus, and a chosen project stands out the way a selected todo does. */

#filters {
  gap: 0.25rem 0.75rem;
}

#filters label {
  overflow-wrap: anywhere;
  line-height: 1.2;
  padding: 0 0.25rem;
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  cursor: pointer;
}

#filters input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

#filters label:has(:checked) {
  background: var(--box-bg);
  border-color: var(--graphical-fg);
}

#filters label:has(:focus-visible) {
  outline: 2px solid var(--graphical-fg);
}

.todos li {
  margin: var(--gap) 0;
  padding: var(--gap);
  border: 1px solid var(--bg);
  scroll-margin: 1rem;
}

/* A lane whose lines are put in order by the page rather than by where
 * they stand, as the Planner's are: a flex column, which keeps no
 * collapsing margins, so its gap stands where a Todo lane's collapsed
 * margin does, and the lines read the same. */

.todos.ordered {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.todos.ordered li {
  margin-block: 0;
}

/* The line the Todo page's carriage stands on, and the Planner's line
 * under the pointer: each is the line a click or a key moves. */

.todos li.selected,
#draft .todos li:not(.done):hover {
  background: var(--box-bg);
  border-radius: var(--border-radius);
  background: var(--box-bg);
  border: 1px solid var(--graphical-fg);
  overflow: clip;
}

/* The day's MITs, in the todo list's own box made green by missing.css's
 * `ok`, drawn as the list draws its todos. A done one stays, checked and
 * struck through, so it is done without its colour too. The way to the
 * Planner is drawn before there is a Planner, and looks like the words it
 * then is.
 *
 * Tracking an MIT, the whole page wears the box's green: missing.css
 * paints the page with `--bg`, so that is all that changes. */

#mits a[aria-disabled] {
  color: var(--faded-fg);
  text-decoration: none;
  cursor: not-allowed;
}

#mits li.done {
  list-style-type: "✓ ";
  color: var(--faded-fg);
  text-decoration: line-through;
}

/* The Planner's MIT lane keeps the day's done MITs too. Its lanes have no
 * room at the left for a mark, so the check stands inside the line. */

#draft li.done {
  list-style-position: inside;
}

/* The focused MIT stays in the box too, marked rather than numbered: the
 * console numbers only what the list can focus. */

#mits li.focused {
  list-style-type: "▸ ";
}

html:has(#track.mit) {
  --bg: var(--ok-bg);
}

#console {
  padding: 1rem 0 0;
}

#explanation {
  position: absolute;
  max-width: calc(var(--line-length) - 2rem);
  padding: 1rem;
  background: var(--box-bg);
  z-index: 1;
}

#console textarea:focus-visible {
  outline: none;
}

#explanation small {
  text-align: right;
  color: var(--fg-faded);
}

#input {
  resize: none;
  width: 100%;
  font-size: 1.4rem;
  padding: 0.5rem;
  border-bottom: 0.125rem solid var(--fg) !important;
  transition: height 250ms ease;
}

#focus {
  user-select: none;
  -webkit-user-select: none; /* Safari */
  touch-action: none;
}

.pressed {
  background-color: var(--lime-1);
}

/* The console, kept at the top of a phone's screen.
 *
 * The explanation, with the button that confirms it, hangs under the input,
 * and a soft keyboard takes the lower half of the screen. A console that
 * scrolls away with the header leaves that button wherever the page was
 * last left, so on a phone it stays where the eye already is.
 *
 * Sticky holds an element inside its parent, and the parent here is the
 * header, barely taller than the console: pinned there, it would scroll off
 * with the header. So the header gives up its own box, which makes the body
 * the console's parent, and what that box gave -- the room above the nav
 * and the room below the console -- goes to those two instead. Pinning the
 * header itself would hold three times as much of the screen. The input is
 * held to four lines, so a long one cannot push the button back down.
 *
 * Pinned is not yet at the top: at rest the console sits under the nav.
 * So the nav gives way while the console has focus, and the console is the
 * top of the screen for as long as it is in use. It comes back a moment
 * after focus leaves, not at once, so that a tap which leaves the console
 * cannot have the page move from under it between the press and the
 * release. */

@media (max-width: 720px) {
  header:has(> #console) {
    display: contents;
  }

  header:has(> #console) > nav {
    padding-top: var(--rhythm);
    max-height: 12rem;
    overflow: hidden;
    transition: max-height 0s 300ms, padding-top 0s 300ms, visibility 0s 300ms;
  }

  header:has(> #console:focus-within) > nav {
    padding-top: 0;
    max-height: 0;
    visibility: hidden;
    transition-delay: 0s;
  }

  #console {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg);
    margin-bottom: calc(var(--rhythm) + 2 * var(--gap));
  }

  #input {
    font-size: 1rem;
    padding: 0.25rem;
    max-height: calc(4 * var(--rhythm) + 0.5rem + 0.1875rem);
    overflow-y: auto;
  }
}

.season-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.35rem 1rem;
}

.season-duration {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.season-summary {
  color: var(--fg-faded);
  margin-top: -0.4rem;
}

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

.season-project {
  display: grid;
  grid-template-columns: minmax(4rem, 1fr) auto minmax(11rem, 1.6fr) auto;
  align-items: baseline;
  gap: 0.1rem 0.8rem;
  padding: 0.2rem 0;
}

.season-project-name,
.season-project-duration {
  font-variant-numeric: tabular-nums;
}

.season-rhythm {
  width: 154px;
  height: 27px;
  overflow: visible;
}

.season-rhythm text {
  fill: var(--fg-faded);
  font-size: 8px;
}

.season-rhythm-cell.unspent { fill: #795548; }
.season-rhythm-cell.negrido { fill: #4d5358; }
.season-rhythm-cell.albedo { fill: #d9e2df; }
.season-rhythm-cell.citrinas { fill: #d69a3a; }
.season-rhythm-cell.rubedo { fill: #a4423b; }

@media (max-width: 720px) {
  .season-project {
    grid-template-columns: minmax(4rem, 1fr) auto;
  }

  .season-project-sittings,
  .season-rhythm {
    grid-column: 1 / -1;
  }

  .track-totals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.season-week > summary,
.season-month > summary,
.current-week > summary {
  cursor: pointer;
}

.season-body {
  padding-top: 0.35rem;
}

.track-totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem 1rem;
  align-items: baseline;
  margin: 0.75rem 0 1rem;
}

.track-totals div {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  white-space: nowrap;
}

.track-totals span {
  color: var(--fg-faded);
}

.track-totals strong {
  font-variant-numeric: tabular-nums;
}

.track-report > summary {
  cursor: pointer;
}

.track-report form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.5rem 1rem;
  margin-top: 0.5rem;
}

.current-week-summary {
  font-size: 1.25rem;
  font-weight: bold;
}

.track-note {
  background: var(--bg);
}

.current-week > table {
  margin-top: 0.5rem;
}
