/* Stillbough: a quiet studio. One lit tree on a deep slate ground (or, by
   day, on pale stone), a book serif for the words, and little else. */

:root {
  --ground: #161d1f;
  --glow: #34403f;
  --ink: #e8ece8;
  --soft: #a7b1ae;
  --faint: #6f7a78;
  --line: rgba(232, 236, 232, 0.13);
  --panel: rgba(255, 255, 255, 0.045);
  --solid: #dfe7e1;
  --on-solid: #17201f;
  --accent: #b9cf9c;
  --bar: #45514f;
  --serif: "Iowan Old Style", "Palatino Nova", Palatino, "Book Antiqua", ui-serif, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --ground: #d9d8d1;
    --glow: #f6f4ee;
    --ink: #1d2624;
    --soft: #4d5956;
    --faint: #77827f;
    --line: rgba(29, 38, 36, 0.14);
    --panel: rgba(255, 255, 255, 0.5);
    --solid: #1f2b29;
    --on-solid: #f1f3ee;
    --accent: #4f6f35;
    --bar: #aab2aa;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--ground);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 400 14px/1.5 var(--sans);
  background: radial-gradient(120% 90% at 22% 8%, var(--glow), var(--ground) 62%) fixed;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
p,
ul,
ol,
dl,
dd {
  margin: 0;
  padding: 0;
}

ul,
ol {
  list-style: none;
}

h1,
h2 {
  font-family: var(--serif);
  font-weight: 400;
}

/* ---------- The top: also the window's title bar in Entry for Mac ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  min-height: 52px;
  /* Clear of the traffic lights on a Mac, the window buttons on Windows. */
  padding: 8px calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw) + 20px) 8px
    calc(env(titlebar-area-x, 0px) + 20px);
  -webkit-app-region: drag;
  app-region: drag;
  -webkit-user-select: none;
  user-select: none;
}

body:not([data-view="tree"]) .top {
  background: var(--ground);
}

.top a {
  -webkit-app-region: no-drag;
  app-region: no-drag;
}

.mark {
  font: 400 18px/1 var(--serif);
  letter-spacing: 0.01em;
}

.top nav {
  display: flex;
  gap: 2px;
}

.top nav a {
  padding: 6px 12px;
  border-radius: 7px;
  color: var(--soft);
  text-decoration: none;
  font-size: 13px;
}

.top nav a[aria-current="page"] {
  color: var(--ink);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

/* ---------- The tree ---------- */

/* A link to a section starts at its top, not under the bar. */
.view {
  scroll-margin-top: 80px;
}

.view-tree {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "stage words" "time kinds";
  column-gap: 28px;
  row-gap: 8px;
  padding: 0 28px 24px;
  height: calc(100vh - 52px);
  min-height: 600px;
}

.stage {
  grid-area: stage;
  position: relative;
  min-height: 0;
}

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: pan-y;
}

.stage canvas:active {
  cursor: grabbing;
}

/* Until the first frame: a pot's outline with a sprout, breathing slowly,
   and a line to say the tree is coming. Where the pot will stand. */
.tree-wait {
  position: absolute;
  inset: 0;
  display: grid;
  justify-items: center;
  align-content: end;
  gap: 18px;
  padding-bottom: 18%;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.tree-wait.gone {
  opacity: 0;
}

.tree-wait[hidden] {
  display: none;
}

.tree-wait-pot {
  position: relative;
  width: min(46%, 340px);
  aspect-ratio: 4 / 1;
  border: 1px solid var(--line);
  border-radius: 50% 50% 46% 46% / 40% 40% 60% 60%;
  background: var(--panel);
}

.tree-wait-pot::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 70%;
  width: 2px;
  height: 120%;
  border-radius: 1px;
  background: var(--faint);
  transform: translateX(-50%);
  opacity: 0.6;
}

.tree-wait-words {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--faint);
}

@media (prefers-reduced-motion: no-preference) {
  .tree-wait-pot {
    animation: tree-wait 1.6s ease-in-out infinite alternate;
  }
}

@keyframes tree-wait {
  from {
    opacity: 0.45;
  }
  to {
    opacity: 1;
  }
}

.no-gl {
  position: absolute;
  inset: 40% 10% auto;
  text-align: center;
  color: var(--soft);
}

.words {
  grid-area: words;
  align-self: center;
  display: grid;
  gap: 18px;
  max-width: 400px;
}

.words h1 {
  display: grid;
  line-height: 1.02;
}

.eyebrow {
  font-size: clamp(24px, 2.6vw, 32px);
}

.clock {
  font-size: clamp(68px, 9vw, 112px);
  letter-spacing: -0.02em;
  font-variant-numeric: lining-nums tabular-nums;
}

.lead {
  font: 400 17px/1.55 var(--serif);
  color: var(--soft);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: 500 14px/1 var(--sans);
  white-space: nowrap;
  cursor: pointer;
}

.button.solid {
  background: var(--solid);
  color: var(--on-solid);
}

.button.quiet {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}

.button:disabled {
  opacity: 0.45;
  cursor: default;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

kbd {
  font: 500 11px/1 var(--sans);
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 2px 5px;
  opacity: 0.7;
}

.stats {
  display: flex;
  gap: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.stats dt {
  font-size: 12px;
  color: var(--faint);
}

.stats dd {
  font: 400 28px/1.2 var(--serif);
  font-variant-numeric: lining-nums tabular-nums;
}

.setup a {
  color: var(--accent);
  text-decoration: none;
}

.sync {
  font-size: 12px;
  color: var(--faint);
  min-height: 1.5em;
}

/* ---------- Looking back over its growth ---------- */

.timeline {
  grid-area: time;
  align-self: end;
  display: grid;
  gap: 8px;
}

.timeline-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.day {
  font: 400 28px/1.1 var(--serif);
}

.date {
  color: var(--faint);
  margin-left: 8px;
}

.count {
  font: 400 24px/1.1 var(--serif);
  font-variant-numeric: lining-nums tabular-nums;
}

.track {
  display: flex;
  gap: 14px;
  align-items: center;
}

.play {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.play svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.play .i-pause,
.play[aria-pressed="true"] .i-play {
  display: none;
}

.play[aria-pressed="true"] .i-pause {
  display: inline;
}

.scrub {
  position: relative;
  flex: 1;
  min-width: 0;
}

.bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 22px;
  padding: 0 4px;
}

.bars li {
  width: 5px;
  min-height: 3px;
  border-radius: 2px;
  background: var(--bar);
}

.bars li[data-seen="true"] {
  background: var(--soft);
}

.scrub input {
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: linear-gradient(var(--line), var(--line)) center / 100% 2px no-repeat;
  cursor: pointer;
}

.scrub input::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink);
}

.scrub input::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
}

.ends {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--faint);
}

.caption {
  font-size: 12.5px;
  color: var(--faint);
}

.kinds {
  grid-area: kinds;
  align-self: end;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  max-width: 400px;
}

.kind,
.swatch {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 10px;
  border: 1px solid transparent;
  text-align: center;
  font-size: 12px;
  color: var(--soft);
  cursor: pointer;
}

.kind:has(input:checked),
.swatch:has(input:checked) {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}

.kind:has(input:focus-visible),
.swatch:has(input:focus-visible) {
  outline: 2px solid var(--accent);
}

.kind input,
.swatch input {
  position: absolute;
  opacity: 0;
}

.kind canvas,
.swatch canvas {
  width: 100%;
  aspect-ratio: 1.2;
  display: block;
}

/* ---------- The other sections ---------- */

.page {
  display: grid;
  gap: 16px;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 20px 56px;
}

.page h1 {
  font-size: 40px;
  line-height: 1.1;
}

.panel {
  display: grid;
  gap: 12px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.panel h2 {
  font-size: 21px;
}

.note {
  color: var(--soft);
}

.chart {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 6px;
  align-items: end;
  height: 150px;
}

.chart li {
  display: grid;
  grid-template-rows: 1fr auto auto;
  height: 100%;
  text-align: center;
  font-size: 11px;
  color: var(--faint);
}

.chart .bar {
  align-self: end;
  min-height: 3px;
  border-radius: 3px;
  background: var(--bar);
}

.chart li:last-child .bar {
  background: var(--accent);
}

.chart .n {
  color: var(--ink);
}

.log li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.log li:last-child {
  border-bottom: 0;
}

.log [data-outcome="completed"] .outcome {
  color: var(--accent);
}

.shore {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.shore li {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 8px;
}

.shore canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1.2;
}

.shore p {
  padding: 6px 4px 2px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

select,
input[type="text"] {
  font: inherit;
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  min-width: 200px;
  padding: 0 10px;
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.check input {
  width: 17px;
  height: 17px;
  margin: 2px 0 0;
  accent-color: #7f9c62;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

legend {
  color: var(--soft);
  margin-bottom: 6px;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.swatch canvas {
  border-radius: 8px;
  background: radial-gradient(circle at 30% 15%, var(--glow), var(--ground) 80%);
}

.powers li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.powers p {
  font-size: 12.5px;
  color: var(--soft);
}

.powers .state {
  white-space: nowrap;
  color: var(--faint);
}

.powers .state[data-state="granted"] {
  color: var(--accent);
}

/* ---------- The warning, the dim, the break ---------- */

.dim {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #05080b;
  opacity: 0;
  /* Everything underneath stays usable while it fades. */
  pointer-events: none;
}

.warning {
  position: fixed;
  z-index: 11;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  width: min(540px, calc(100vw - 32px));
  display: grid;
  gap: 14px;
  padding: 18px 20px;
  background: color-mix(in srgb, var(--ground) 92%, white);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.warning h2 {
  font-size: 22px;
}

.warning .row {
  justify-content: flex-end;
}

/* The break is always evening, whatever the system says. */
.break {
  --ink: #e8ece8;
  --soft: #a7b1ae;
  --panel: rgba(255, 255, 255, 0.05);
  --line: rgba(232, 236, 232, 0.16);
  --solid: #dfe7e1;
  --on-solid: #17201f;
  --last: 0;
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  justify-items: center;
  gap: 14px;
  padding: max(44px, env(titlebar-area-height, 0px)) 16px 28px;
  color: var(--ink);
  background: #0b1014;
}

/* The light in the room, going: warm low sun, then a blue afterglow. */
.break::before,
.break::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.break::before {
  background: radial-gradient(90% 70% at 12% 62%, rgba(196, 112, 58, 0.34), transparent 70%),
    radial-gradient(120% 90% at 30% 10%, #2b3534, #12181a 70%);
  opacity: calc(1 - var(--last) * 0.9);
}

.break::after {
  background: radial-gradient(80% 60% at 82% 70%, rgba(58, 72, 130, 0.26), transparent 70%);
  opacity: var(--last);
}

.break > * {
  position: relative;
  z-index: 1;
}

.break canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.break-words {
  text-align: center;
}

.break-line {
  font: 400 clamp(22px, 3.2vw, 32px)/1.25 var(--serif);
}

.break-left {
  color: var(--soft);
  font-variant-numeric: tabular-nums;
}

.break .row {
  justify-content: center;
}

.done {
  position: fixed;
  inset: 0;
  z-index: 19;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(5, 8, 10, 0.5);
}

#elsewhere {
  z-index: 30;
}

.done .panel {
  width: min(420px, 100%);
  justify-items: start;
  background: color-mix(in srgb, var(--ground) 92%, white);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

@media (max-width: 860px) {
  .view-tree {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "stage" "words" "kinds" "time";
    height: auto;
    row-gap: 20px;
    padding: 0 16px 28px;
  }

  .stage {
    height: min(86vw, 520px);
  }

  .words,
  .kinds {
    justify-self: center;
    width: 100%;
  }

  .bars li {
    width: 3px;
  }
}

@media (max-width: 460px) {
  .powers li {
    flex-wrap: wrap;
  }
  .chart {
    gap: 2px;
  }
}
