/* 46 Cartmel Drive. Indigo is night and cheap electricity, orange is daytime full price,
   gold is sunshine, green is the battery. Chart colours are validated for colour-blind
   separation and contrast in both modes (dataviz validate_palette.js). */

:root {
  color-scheme: light;
  --page: #eef1f6;
  --paper: #ffffff;
  --ink: #10223b;
  --ink-2: #34445c;
  --ink-3: #56637a;
  --rule: #d3dae6;
  --sky: #1b2559;
  --sky-ink: #ffffff;
  --sky-ink-2: #d6dcf5;
  --moon: #f2c14e;
  --focus: #2f6bff;
  --cheap: #4455c4;
  --dear: #e0761f;
  --sun: #c48500;
  --line: #10223b;
  --battery: #1f8a5b;
  --battery-track: #dcefe5;
  --problem: #b42318;
  --problem-bg: #fdecea;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d1324;
    --paper: #151c33;
    --ink: #eef2fa;
    --ink-2: #c6cddd;
    --ink-3: #9ea8bd;
    --rule: #2a3452;
    --sky: #242f6e;
    --sky-ink-2: #cdd4f2;
    --focus: #8fb0ff;
    --cheap: #6676e0;
    --dear: #d9691c;
    --sun: #b07a00;
    --line: #eef2fa;
    --battery: #2fa874;
    --battery-track: #1b3b30;
    --problem: #ffb4ab;
    --problem-bg: #3b1714;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d1324; --paper: #151c33; --ink: #eef2fa; --ink-2: #c6cddd; --ink-3: #9ea8bd;
  --rule: #2a3452; --sky: #242f6e; --sky-ink-2: #cdd4f2; --focus: #8fb0ff; --cheap: #6676e0;
  --dear: #d9691c; --sun: #b07a00; --line: #eef2fa; --battery: #2fa874; --battery-track: #1b3b30;
  --problem: #ffb4ab; --problem-bg: #3b1714;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, sans-serif;
  font-size: 1.25rem;
  line-height: 1.5;
  font-variant-numeric: lining-nums;
}

.page { max-width: 46rem; margin: 0 auto; padding: 0 16px 4rem; }

h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 7vw, 2.6rem); font-weight: 800; }
h2 { font-size: 1.65rem; font-weight: 700; }
h3 { font-size: 1.3rem; font-weight: 700; }
p { margin: 0; max-width: 38em; }
.quiet { color: var(--ink-3); font-size: 1.05rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }

/* ---- masthead */
.masthead {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 0.75rem 1.5rem; padding: 2rem 0 1.5rem;
}
.date { color: var(--ink-2); font-size: 1.3rem; margin-top: 0.35rem; }
.signout { display: flex; align-items: baseline; gap: 0.75rem; font-size: 1.05rem; color: var(--ink-3); }
.link {
  font: inherit; color: var(--ink); background: none; border: 0; padding: 0.5rem 0;
  text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer; min-height: 44px;
}

/* ---- tonight: the one bold thing on the page */
.sky {
  position: relative;
  background: var(--sky);
  color: var(--sky-ink);
  border-radius: 28px;
  padding: clamp(1.5rem, 5vw, 2.5rem);
  overflow: hidden;
}
.sky::before {          /* a few stars */
  content: ""; position: absolute; width: 3px; height: 3px; border-radius: 50%;
  top: 1.6rem; right: 2.2rem; background: #fff; opacity: 0.7;
  box-shadow: -1.8rem 1.6rem 0 -0.5px #fff, -4.5rem 0.4rem 0 #fff, -0.6rem 3rem 0 -0.5px #fff,
              -6.8rem 2.2rem 0 -0.5px #fff, -3rem 3.6rem 0 #fff;
}
.sky__inner { position: relative; }
.sky__moon { width: 3.25rem; height: 3.25rem; fill: var(--moon); display: block; margin-bottom: 1rem; }
.sky__headline { font-size: clamp(2rem, 6.5vw, 2.9rem); font-weight: 800; line-height: 1.1; max-width: 16em; }
.sky__explain { color: var(--sky-ink-2); font-size: 1.3rem; margin-top: 1rem; }
.sky__note { color: var(--sky-ink-2); font-size: 1.05rem; margin-top: 1rem; }
.sky__done, .sky__problem {
  margin-top: 1.25rem; padding: 0.85rem 1.1rem; border-radius: 14px; font-weight: 700;
}
.sky__done { background: var(--moon); color: #1b2559; }
.sky__problem { background: #fff; color: #b42318; }

.change { margin-top: 1.75rem; border-top: 1px solid rgba(255, 255, 255, 0.25); padding-top: 1.25rem; }
.change summary {
  cursor: pointer; font-weight: 700; font-size: 1.25rem; list-style: none;
  display: inline-flex; align-items: center; gap: 0.6rem; min-height: 48px;
}
.change summary::-webkit-details-marker { display: none; }
.change summary::before {
  content: ""; width: 0.6rem; height: 0.6rem; border-right: 3px solid currentColor; border-bottom: 3px solid currentColor;
  transform: rotate(-45deg); transition: transform 0.15s ease;
}
.change[open] summary::before { transform: rotate(45deg); }
.change__body { padding-top: 0.75rem; display: grid; gap: 1rem; }
.change__hint { color: var(--sky-ink-2); font-size: 1.05rem; }
.change__pause { border-top: 1px solid rgba(255, 255, 255, 0.25); padding-top: 1.25rem; margin-top: 0.5rem; display: grid; gap: 0.85rem; }

.choices { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.6rem; }
.choice {
  font: inherit; font-size: 1.35rem; font-weight: 800; min-height: 64px;
  border-radius: 16px; border: 2px solid rgba(255, 255, 255, 0.7);
  background: transparent; color: var(--sky-ink); cursor: pointer;
}
.choice:hover { background: rgba(255, 255, 255, 0.12); }
.choice[aria-pressed="true"] { background: var(--moon); border-color: var(--moon); color: #1b2559; }
.choice:disabled { opacity: 0.6; }
@media (max-width: 26rem) { .choices { grid-template-columns: repeat(3, 1fr); } }

/* ---- buttons */
.button {
  font: inherit; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
  min-height: 56px; padding: 0.7rem 1.4rem; border-radius: 14px; border: 2px solid var(--ink);
  background: var(--ink); color: var(--paper); text-decoration: none; cursor: pointer; justify-self: start;
}
.button--quiet { background: transparent; color: var(--ink); }
.sky .button { background: var(--sky-ink); color: var(--sky); border-color: var(--sky-ink); }
.sky .button--quiet { background: transparent; color: var(--sky-ink); border-color: rgba(255, 255, 255, 0.7); }
.button--big { font-size: 1.4rem; min-height: 68px; padding: 0.9rem 2rem; margin-top: 2rem; }

/* ---- right now */
.now { display: grid; gap: 1.75rem; padding: 2.25rem 0; border-bottom: 1px solid var(--rule); }
.gauge { display: flex; align-items: center; max-width: 30rem; }
.gauge__cell {
  flex: 1; height: 4.25rem; border: 4px solid var(--ink); border-radius: 16px; padding: 5px;
  background: var(--paper);
}
.gauge__fill { height: 100%; min-width: 6px; background: var(--battery); border-radius: 9px; transition: width 0.6s ease; }
.gauge__nub { width: 10px; height: 1.75rem; background: var(--ink); border-radius: 0 6px 6px 0; }
.gauge__words { margin-top: 0.85rem; font-size: 1.45rem; }
.gauge__words .quiet { display: block; margin-top: 0.15rem; }

.sun { display: flex; gap: 1rem; align-items: flex-start; }
.sun__icon { width: 3rem; height: 3rem; flex: none; fill: var(--sun); stroke: var(--sun); }
.sun__line { font-size: 1.35rem; font-weight: 700; }
.sun .quiet { margin-top: 0.25rem; }

/* ---- charts */
.history { padding-top: 2.25rem; }
.history > h2 { margin-bottom: 0.5rem; }
.chart { margin: 2rem 0 0; padding: 0; }
.chart + .chart { border-top: 1px solid var(--rule); padding-top: 2rem; }
.summary { margin-top: 0.5rem; }
.chart .quiet { margin-top: 0.4rem; }
.chart__box { position: relative; height: 270px; margin-top: 1rem; }
.chart__box--short { height: 220px; }
.key { list-style: none; padding: 0; margin: 0.75rem 0 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.5rem; font-size: 1.05rem; color: var(--ink-2); }
.key li { display: inline-flex; align-items: center; gap: 0.5rem; }
.swatch { width: 1rem; height: 1rem; border-radius: 4px; display: inline-block; }
.swatch--cheap { background: var(--cheap); }
.swatch--dear { background: var(--dear); }
.swatch--sun { background: var(--sun); }
.swatch--line { height: 3px; width: 1.4rem; border-radius: 2px; background: var(--line); }

/* ---- diary */
.diary { padding-top: 2.75rem; }
.diary ol { list-style: none; padding: 0; margin: 1rem 0 0; border-left: 3px solid var(--rule); }
.diary__item { position: relative; padding: 0 0 1.1rem 1.4rem; max-width: 38em; }
.diary__item::before {
  content: ""; position: absolute; left: -9px; top: 0.55em; width: 15px; height: 15px; border-radius: 50%;
  background: var(--sky); box-shadow: 0 0 0 3px var(--page);
}
.diary__item--change::before { background: var(--moon); }
.diary__item--error::before { background: var(--problem); }

/* ---- how this works, notices, sign-in */
.howto { margin-top: 2.5rem; border-top: 1px solid var(--rule); padding-top: 1.25rem; }
.howto summary { cursor: pointer; font-weight: 700; min-height: 48px; display: flex; align-items: center; }
.howto p { margin-top: 0.85rem; }

.notice { margin-top: 1.5rem; padding: 1rem 1.25rem; border-radius: 14px; background: var(--paper); border: 2px solid var(--rule); }
.notice--problem { background: var(--problem-bg); border-color: var(--problem); }
.signin .masthead { padding-top: 18vh; display: block; }
.lede { font-size: 1.4rem; color: var(--ink-2); margin-top: 0.75rem; }
.signin .quiet { margin-top: 1rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
