/* ==========================================================================
   AURALAR — foundations: tokens, reset, typography, shared controls.

   The house style is print. A household calendar is a thing you read across a
   kitchen at a glance, and the medium that has solved that problem for three
   hundred years is the printed page: a serif face, hairline rules doing the
   work that borders and shadows do on screen, and numerals set in a column so
   the eye can run down them.

   Two rules carried over from the previous version, both learned the hard way:

     * Cards are LIGHTER than the page, in BOTH themes. A sunken darker panel
       reads as a hole in the screen rather than a card on it.
     * Anything that changes once a second is tabular-figure and fixed-width. A
       clock that shifts the buttons beside it every second is worse than no
       clock at all.

   No web fonts anywhere. A wall panel that has just lost its wifi must still
   come up looking like itself, and Georgia has shipped on everything since
   1996.
   ========================================================================== */

:root {
  /* --- Paper: the daytime kitchen --------------------------------------- */
  --bg:        #f4f1e8;   /* the stock */
  --panel:     #faf8f2;   /* a card, lighter than the page */
  --panel-2:   #efeadb;   /* a warmer stock: the diary, sunken wells */
  --panel-3:   #e6e0cd;
  --line:      #cdc6b1;   /* the hairline rule */
  --line-2:    #b5ac92;

  --ink:       #17150f;
  --ink-2:     #57523f;
  --ink-3:     #8e8873;

  --good:      #3d6b40;   /* moss — settled */
  --good-dim:  #cfe0cd;
  --warn:      #8a5f12;
  --bad:       #a3241b;   /* the red used on a printed page: late, errors */

  --shadow:    0 1px 0 rgba(23,21,15,.06), 0 10px 30px -20px rgba(23,21,15,.5);
  --shadow-sm: 0 1px 0 rgba(23,21,15,.07);

  /* --- Geometry ----------------------------------------------------------
     Print has corners. Everything here is square or very nearly so; the only
     round things in the app are the things that are round in life — a dot
     beside a name, a switch. */
  --r-sm: 2px;
  --r:    3px;
  --r-lg: 4px;
  --r-xl: 5px;

  /* A thumb on a wall panel is not a mouse pointer. Nothing tappable goes
     below this, anywhere, ever. */
  --tap: 56px;

  --serif: Georgia, "Iowan Old Style", "Times New Roman", "Nimbus Roman", serif;
  --sans:  "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif;
  --mono:  ui-monospace, "SF Mono", SFMono-Regular, "Roboto Mono", Menlo,
           Consolas, "Liberation Mono", monospace;

  /* Native controls — date and time fields, select arrows, scrollbars — are
     painted by the browser, and without this they arrive in the OS's own
     colours: a grey time field and a grey clock button sitting in the middle
     of a dark page. This is the one line that makes them follow the theme. */
  color-scheme: light;

  --ease: cubic-bezier(.2, .7, .3, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

/* --- Slate: the same page after dark --------------------------------------
   Not an inversion, and not the warm stock turned down. The first dark theme
   here tried to be the light one at night — a warm near-black with an olive
   cast — and warm colours at low luminance go muddy rather than cosy: the
   background read as dim rather than dark and the member colours sat in it
   without ever quite separating.

   This is cool instead, deliberately. Against a warm cream day theme, a cool
   night theme reads as a different time rather than a faded version of the
   same one, and every accent the app uses — the member dots, the ochre and
   blue of the charts, the red of a late job — gains separation against it
   instead of losing it.

   Not black, either. Pure black on a panel that is on all night is harsh, and
   it leaves nowhere to put a raised surface: a sheet lifting off the page has
   to be lighter than it, and #000 has no room underneath.

   Contrast, measured, not guessed (WCAG, against the darkest surface each is
   used on): ink 13.3:1, ink-2 7.2:1, ink-3 4.6:1 — the last one is the italic
   hint text, and it is the reason ink-3 is not darker than it looks like it
   wants to be.

   Other palettes were drawn and rejected: a warmer espresso, a neutral
   graphite, a bluer midnight, and a lifted pewter that was not really dark at
   all. Any of them is a five-line swap here if this one wears badly. */
:root[data-theme="dark"] {
  --bg:        #0f1319;
  --panel:     #171d26;
  --panel-2:   #1d2430;
  --panel-3:   #28303e;
  --line:      #2e3745;
  --line-2:    #455063;

  --ink:       #e9edf3;
  --ink-2:     #a7b1c0;
  --ink-3:     #8f99aa;

  --good:      #6fc08c;
  --good-dim:  #1c352a;
  --warn:      #d7a747;
  --bad:       #e8766c;

  --shadow:    0 1px 0 rgba(0,0,0,.4), 0 12px 34px -22px #000;
  --shadow-sm: 0 1px 0 rgba(0,0,0,.5);

  color-scheme: dark;
}

* { box-sizing: border-box; }

/* --- Scrollbars ------------------------------------------------------------
   A default scrollbar is a slab of the operating system's grey dropped down
   the side of a printed page. Thin, in the page's own ink, with the track left
   as paper. */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;       /* no rubber-band on a wall panel */
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

/* Text selection is only ever accidental here — a child dragging a finger
   across a list should not end up with half the screen highlighted. Inputs
   are exempt, obviously. */
body { user-select: none; -webkit-user-select: none; }
input, textarea, select, [contenteditable] { user-select: text; -webkit-user-select: text; }

h1, h2, h3, h4, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.app { height: 100%; }
[hidden] { display: none !important; }

/* A small-caps label in the sans face: kickers, column heads, field labels.
   The one place the app leaves the serif, and it is always doing the job a
   printed page gives to a rule and a caption. */
.kicker {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* --- Boot splash ---------------------------------------------------------- */
.boot {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--bg);
  z-index: 200;
  transition: opacity .3s var(--ease);
}
.boot.is-gone { opacity: 0; pointer-events: none; }
.boot-mark {
  width: 46px; height: 46px;
  border: 2px solid var(--line);
  border-top-color: var(--ink-2);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.noscript {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: 40px; text-align: center;
  background: var(--bg); color: var(--ink);
  font-size: 20px; z-index: 300;
}

/* ==========================================================================
   Shared controls
   ========================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 20px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--panel);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16.5px; font-weight: 400;
  cursor: pointer;
  transition: background .14s var(--ease), transform .1s var(--ease),
              border-color .14s var(--ease);
}
.btn:hover  { background: var(--panel-2); border-color: var(--ink-3); }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; pointer-events: none; }

.btn-primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
  font-weight: 700;
}
.btn-primary:hover { background: var(--ink); border-color: var(--ink); filter: brightness(1.35); }
:root[data-theme="dark"] .btn-primary:hover { filter: brightness(.9); }

.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}
.btn-quiet:hover { background: var(--panel-2); color: var(--ink); }

.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); border-color: var(--bad); }

.btn-icon {
  min-width: var(--tap);
  padding: 0 14px;
}

.btn-sm {
  min-height: 42px; padding: 0 14px;
  font-size: 14px; font-family: var(--sans);
  letter-spacing: .04em;
}

/* --- Form fields ---------------------------------------------------------- */
.field { display: grid; gap: 7px; }
.field > label {
  font-family: var(--sans);
  font-size: 10.5px; font-weight: 600; letter-spacing: .22em;
  text-transform: uppercase; color: var(--ink-3);
}
.input {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
}
.input:focus { border-color: var(--ink); background: var(--panel); }
.input::placeholder { color: var(--ink-3); font-style: italic; }

/* A serif is for prose. An email address, a password, a time and a date are
   machine strings — set in the sans face they stop looking like a quotation
   and start looking like something you typed. */
.input[type="email"],
.input[type="password"],
.input[type="date"],
.input[type="time"],
.input[type="number"] {
  font-family: var(--sans);
  font-size: 17px;
  letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
}
.input[type="password"] { letter-spacing: .2em; font-size: 19px; }
.input[type="password"]::placeholder { letter-spacing: .2em; }

/* One ring, not two: the global focus outline plus a border change drew a
   double box around every field. */
.input:focus-visible {
  outline: none;
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

/* Native date/time fields carry a picker button drawn by the browser. It is
   hidden and stretched across the right-hand end of the field, so the tap
   still opens the real picker while the icon you see is ours.

   Named `pickfield`, not `when`: a class this generic once collided with
   `<td class="when">` in the admin tables and `display: block` quietly pulled
   two cells out of their column. Component classes get component names. */
.pickfield {
  position: relative;
  display: block;
}
.pickfield .input { padding-right: 48px; }
.pickfield .pick-ic {
  position: absolute;
  right: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
  display: flex;
}
.pickfield .input:hover + .pick-ic,
.pickfield .input:focus + .pick-ic { color: var(--ink); }
.input[type="date"]::-webkit-calendar-picker-indicator,
.input[type="time"]::-webkit-calendar-picker-indicator {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: auto;
  width: 48px; height: auto;
  margin: 0; padding: 0;
  opacity: 0;
  cursor: pointer;
}
/* Chrome pads the internal fields of a time input on its own terms. */
.input[type="time"]::-webkit-datetime-edit,
.input[type="date"]::-webkit-datetime-edit { padding: 0; }
.input[type="time"]::-webkit-datetime-edit-fields-wrapper,
.input[type="date"]::-webkit-datetime-edit-fields-wrapper { padding: 0; }
textarea.input { min-height: 84px; resize: vertical; line-height: 1.45; }

/* Segmented control — used for event / chore / task. Reads as a set of tabs
   ruled off from one another rather than a set of pills. */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  overflow: hidden;
}
.seg button {
  min-height: 48px;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 12.5px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  cursor: pointer;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* --- Chips ---------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 14px;
  border-radius: var(--r);
  border: 1px solid var(--line-2);
  background: var(--panel);
  font-family: var(--serif);
  font-size: 16px;
  cursor: pointer;
  transition: border-color .14s var(--ease), background .14s var(--ease);
}
.chip[aria-pressed="true"] {
  border-color: var(--dot, var(--ink));
  box-shadow: inset 0 0 0 1px var(--dot, var(--ink));
  background: color-mix(in srgb, var(--dot, var(--ink)) 10%, transparent);
  color: var(--ink);
  font-weight: 700;
}
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--dot, var(--ink-3));
  flex: none;
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* The idle countdown that rides inside the settings button. Monospaced and
   spaced off the cog, so it cannot shunt the button's width once a second. */
.count {
  margin-left: 7px;
  font-family: var(--mono); font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}
/* Figures set for a column: the clock, points, credits, counts. */
.fig  { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

.row  { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1 1 auto; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Toasts --------------------------------------------------------------- */
.toasts {
  position: fixed;
  /* Well clear of the bottom edge. A toast sitting on the gesture bar is both
     hard to read and easy to swipe away by accident. */
  left: 50%; bottom: calc(38px + var(--safe-b));
  transform: translateX(-50%);
  display: grid; gap: 8px; justify-items: center;
  z-index: 160; pointer-events: none;
}
.toast {
  padding: 13px 22px;
  background: var(--panel);
  border: 1px solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  font-size: 16.5px;
  animation: toast-in .26s var(--ease);
  max-width: min(92vw, 560px);
  text-align: center;
}
.toast.is-bad  { border-color: var(--bad);  color: var(--bad); }
.toast.is-good { border-color: var(--good); color: var(--good); }
.toast.is-out  { animation: toast-out .22s var(--ease) forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(8px)  scale(.97); } }

/* --- Offline banner ------------------------------------------------------- */
.offline {
  position: fixed; top: var(--safe-t); left: 0; right: 0;
  padding: 8px 16px;
  background: var(--ink); color: var(--bg);
  font-family: var(--sans);
  font-size: 11.5px; font-weight: 600; text-align: center;
  letter-spacing: .18em; text-transform: uppercase;
  z-index: 170;
}

/* ==========================================================================
   Auth screen — the masthead of a paper nobody has printed yet
   ========================================================================== */
.auth {
  height: 100%;
  display: grid; place-items: center;
  padding: 28px calc(28px + var(--safe-l)) calc(28px + var(--safe-b));
  background: var(--bg);
}
.auth-card {
  width: min(470px, 100%);
  display: grid; gap: 18px;
  padding: 38px 36px 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px double var(--ink);
  border-bottom: 3px double var(--ink);
  border-radius: 0;
  box-shadow: var(--shadow);
}
.auth-head {
  display: grid; gap: 6px; justify-items: center; text-align: center;
  padding-bottom: 14px; margin-bottom: 2px;
  border-bottom: 1px solid var(--line);
}
.auth-logo {
  /* The mark is the name set as a masthead, not a rounded app tile. */
  font-family: var(--serif);
  font-variant: small-caps;
  font-size: 10.5px; letter-spacing: .3em;
  text-transform: uppercase; font-variant: normal;
  font-family: var(--sans); font-weight: 600;
  color: var(--ink-3);
  padding-bottom: 4px;
}
.auth-head h1 {
  font-family: var(--serif);
  font-size: 42px; font-weight: 400;
  font-variant: small-caps; letter-spacing: .09em;
  line-height: 1;
}
.auth-head p {
  color: var(--ink-2); font-size: 15.5px; font-style: italic;
  max-width: 42ch;
}
.auth-switch {
  text-align: center; color: var(--ink-2); font-size: 15.5px;
  padding-top: 12px; border-top: 1px solid var(--line);
  font-style: italic;
}
.auth-switch button {
  background: none; border: 0; padding: 4px;
  font-family: var(--serif); font-style: normal;
  color: var(--ink); font-weight: 700; text-decoration: underline;
  text-underline-offset: 3px; cursor: pointer;
}
/* The fields swap out between sign in, register, forgot and the code, so they
   live in their own box and the card keeps its rhythm whatever is in it. */
.auth-fields { display: grid; gap: 18px; }
.auth-aside { display: flex; justify-content: flex-end; margin-top: -8px; }

/* A button that reads as a link: used where the action is a change of mind
   ("forgot the password?"), not a thing to press. */
.linky {
  background: none; border: 0; padding: 2px;
  font: inherit; font-size: 14.5px;
  color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.linky:hover { color: var(--ink); }

/* A small stamp of state — confirmed, sent, failed. Never a button. */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  font-family: var(--sans); font-size: 11px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
}
.badge.is-good { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.badge.is-bad  { color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 45%, transparent); }

.auth-error {
  padding: 11px 14px;
  border-radius: 0;
  border-left: 3px solid var(--bad);
  background: color-mix(in srgb, var(--bad) 8%, transparent);
  color: var(--bad); font-size: 15.5px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ==========================================================================
   The room a chore is in
   --------------------------------------------------------------------------
   One element, printed inside the title, and three ways of setting it. The
   treatment is chosen once on <html data-cat="…">; the markup never changes,
   so the wall and the planner cannot drift apart.

     kicker  (default) — a standfirst above the name, in the same small-caps
                         the section headings use. It reads as a label rather
                         than as part of the job, and it costs the name
                         nothing: the title keeps its full size and weight.
     inline            — in front of the name on the same line, lighter, with
                         a thin separator. Saves a line; costs a little
                         scanning speed when the list is long.
     tag               — a boxed chip. Loudest of the three, and the one that
                         starts to compete with the points badge.
   ========================================================================== */

.cat {
  font-family: var(--sans);
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
}

/* kicker — the default */
:root[data-cat="kicker"] .cat,
:root:not([data-cat]) .cat {
  display: block;
  font-size: .46em;                 /* against the title, so it scales with it */
  letter-spacing: .18em;
  text-transform: uppercase;
  line-height: 1.1;
  margin-bottom: .18em;
}

/* inline — in front of the name, quieter than it */
:root[data-cat="inline"] .cat {
  display: inline;
  font-size: .74em;
  letter-spacing: .02em;
  opacity: .72;
}
:root[data-cat="inline"] .cat::after {
  content: " / ";
  opacity: .6;
  letter-spacing: 0;
}

/* tag — a boxed chip */
:root[data-cat="tag"] .cat {
  display: inline-block;
  font-size: .5em;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: .18em .5em;
  margin-right: .5em;
  border: 1px solid var(--line-2);
  vertical-align: middle;
}

/* In the planner the type is already small; the kicker needs a floor or it
   turns into grey dust. */
.pill-title .cat { font-size: 9.5px; letter-spacing: .14em; }
:root[data-cat="inline"] .pill-title .cat { font-size: 11px; letter-spacing: .02em; }
:root[data-cat="tag"] .pill-title .cat { font-size: 9px; padding: 1px 4px; }

/* --- The five steps of difficulty ---------------------------------------- */
/* Five steps do not fit one row on a phone, and .seg is a single-row grid —
   flex-wrap does nothing to it. Two rows of a grid, then: three and two. */
.seg-diff { grid-auto-flow: row; grid-template-columns: repeat(5, 1fr); }
.seg-diff button { font-size: 14.5px; padding: 0 6px; }
@media (max-width: 560px) {
  .seg-diff { grid-template-columns: repeat(3, 1fr); }
  .seg-diff button { font-size: 13.5px; min-height: 48px; }
  /* The last row is two buttons wide; stretch the last one so the block stays
     a rectangle rather than trailing off. */
  .seg-diff button:nth-child(4) { grid-column: span 2; }
  .seg-diff button:nth-child(5) { grid-column: span 1; }
}

/* A day of something longer: "day 2 of 3" on the wall, "2/3" in the planner. */
.span-tag {
  font-family: var(--sans);
  font-size: .78em; font-weight: 600;
  letter-spacing: .06em;
  color: var(--ink-3);
  white-space: nowrap;
}
