/* ourfam
 *
 * The visual argument: this app replaces the whiteboard on the fridge door, so
 * it borrows the two things that made the fridge door work — a colour per
 * person, and rows you can read from across the kitchen — and none of the
 * things that made it fail.
 *
 * The accent is not the app's. It is whoever is holding the phone: --me is set
 * from the signed-in person's colour, so Bradley's app is blue and Amelia's is
 * green. Nothing else in here is allowed to be loud.
 */

:root {
  color-scheme: light dark;

  --paper:      #f2f3ef;   /* pale sage paper, not cream */
  --raise:      #ffffff;
  --ink:        #16201c;   /* deep green-black */
  --ink-soft:   #5a655e;
  --ink-faint:  #8b958d;
  --line:       #dee1d8;
  --line-soft:  #e9ebe4;
  --late:       #b3492f;
  --me:         #4c7ef3;   /* replaced at runtime by the person's colour */

  --tap: 3rem;
  --gut: 1.15rem;
  --radius: 0.7rem;

  --display: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --text: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:     #121815;
    --raise:     #1a211d;
    --ink:       #e8ede7;
    --ink-soft:  #9aa49c;
    --ink-faint: #6d786f;
    --line:      #27312b;
    --line-soft: #1f2823;
    --late:      #e08268;
  }
}

* { box-sizing: border-box; }

/* The hidden attribute has to beat any display a class sets, or an element
   toggled with el.hidden stays on screen. A class selector and the UA's
   [hidden] rule have the same specificity, and ours is later. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.45 var(--text);
  font-synthesis-weight: none;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.02em; margin: 0; }

button, input, textarea, select { font: inherit; color: inherit; }

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--me);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- shell ------------------------------------------------------------- */

.view {
  max-width: 40rem;
  margin: 0 auto;
  padding: max(1.1rem, env(safe-area-inset-top)) var(--gut) 7.5rem;
}

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}

.tabs a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.6rem 0 0.55rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-faint);
}

.tabs a.on { color: var(--ink); }

/* The tab marker is a bar of the person's colour, so the app is visibly
   somebody's rather than everybody's. */
.tab-mark {
  width: 1.6rem; height: 3px;
  border-radius: 2px;
  background: transparent;
}
.tabs a.on .tab-mark { background: var(--me); }

/* ---- the day headline: the one loud thing ------------------------------ */

.day {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.4rem 0 1.6rem;
}

.day-date {
  font-family: var(--display);
  font-size: clamp(2rem, 9vw, 2.9rem);
  line-height: 0.98;
  letter-spacing: -0.035em;
  margin: 0;
}
.day-date .dow { display: block; color: var(--me); }

.day-state {
  margin: 0.6rem 0 0;
  color: var(--ink-soft);
  font-size: 1rem;
}

.who {
  flex: none;
  width: 2.6rem; height: 2.6rem;
  border-radius: 50%;
  border: 0;
  display: grid; place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  background: var(--me);
  cursor: pointer;
}

/* ---- rows -------------------------------------------------------------- */

.group { margin: 0 0 2rem; }

.group > h2 {
  font-size: 0.95rem;
  font-weight: 500;
  font-family: var(--text);
  color: var(--ink-faint);
  margin: 0 0 0.5rem;
}

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

.row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: var(--tap);
  padding: 0.65rem 0 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line-soft);
  position: relative;
}

/* The magnet: a bar of the owner's colour on the left edge of the row. */
.row::before {
  content: "";
  position: absolute;
  left: 0; top: 0.55rem; bottom: 0.55rem;
  width: 3px;
  border-radius: 2px;
  background: var(--own, transparent);
}

.row.late::before {
  background: repeating-linear-gradient(
    -45deg, var(--late) 0 3px, transparent 3px 6px);
}

.row-main { flex: 1 1 auto; min-width: 0; }

.row-title {
  display: block;
  font-size: 1.02rem;
  line-height: 1.25;
  word-break: break-word;
}

.row-sub {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.83rem;
  color: var(--ink-faint);
}
.row-sub .late-note { color: var(--late); }

.row.is-done .row-title { color: var(--ink-faint); text-decoration: line-through; }
.row.is-done::before { opacity: 0.35; }

/* The tick target sits on the right, where a thumb is. */
.tick {
  flex: none;
  width: 2.15rem; height: 2.15rem;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: transparent;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background-color .14s ease, border-color .14s ease, transform .14s ease;
}
.tick svg { width: 1.05rem; height: 1.05rem; stroke: #fff; stroke-width: 2.6; fill: none; opacity: 0; }
.tick[aria-pressed="true"] { background: var(--own, var(--me)); border-color: var(--own, var(--me)); }
.tick[aria-pressed="true"] svg { opacity: 1; }
.tick:active { transform: scale(0.9); }

@media (prefers-reduced-motion: reduce) {
  .tick { transition: none; }
}

/* ---- events ------------------------------------------------------------ */

.ev {
  display: flex;
  gap: 0.85rem;
  padding: 0.55rem 0 0.55rem 0.85rem;
  border-bottom: 1px solid var(--line-soft);
  position: relative;
  align-items: baseline;
}
.ev::before {
  content: "";
  position: absolute; left: 0; top: 0.5rem; bottom: 0.5rem;
  width: 3px; border-radius: 2px; background: var(--own, transparent);
}
.ev-time {
  flex: none;
  width: 4.4rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.86rem;
  color: var(--ink-soft);
}
.ev-title { flex: 1 1 auto; }
.ev-where { display: block; font-size: 0.83rem; color: var(--ink-faint); }

/* ---- meals ------------------------------------------------------------- */

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

.night {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.night.today { border-left: 3px solid var(--me); padding-left: 0.7rem; margin-left: -0.7rem; }

.night-day {
  flex: none;
  width: 3.1rem;
  font-family: var(--display);
  font-weight: 500;
  line-height: 1.05;
}
.night-day small { display: block; font-family: var(--text); font-weight: 400; font-size: 0.78rem; color: var(--ink-faint); }

.night-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  border-bottom: 1px dashed transparent;
  background: transparent;
  padding: 0.35rem 0;
  font-size: 1.02rem;
}
/* A planned evening: one pack per line, wrapping, never truncated. */
.night-plan {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0.35rem 0;
  cursor: pointer;
  display: grid;
  gap: 0.1rem;
}
.night-dish { font-size: 1rem; line-height: 1.25; }
.night-dish + .night-dish { color: var(--ink-soft); }

.night-input::placeholder { color: var(--ink-faint); }
.night-input:focus { outline: none; border-bottom-color: var(--me); }
.night-input:not(:placeholder-shown) { border-bottom-color: transparent; }

.cook {
  flex: none;
  border: 0; background: transparent;
  width: 1.9rem; height: 1.9rem; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.78rem; font-weight: 600;
  color: var(--ink-faint);
  cursor: pointer;
}
.cook[data-set="1"] { color: #fff; }

/* ---- forms and buttons ------------------------------------------------- */

.add {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 1.2rem;
}

.add input[type="text"], .field input, .field textarea, .field select {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
}
.field textarea { min-height: 5rem; resize: vertical; width: 100%; }

.btn {
  border: 1px solid transparent;
  background: var(--me);
  color: #fff;
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  font-weight: 600;
  cursor: pointer;
}
.btn.quiet { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn.plain { background: transparent; color: var(--ink-soft); border: 0; padding: 0.5rem 0; text-decoration: underline; text-underline-offset: 3px; }
.btn:disabled { opacity: 0.5; }

.field { display: block; margin: 0 0 0.9rem; }
.field > span { display: block; font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 0.3rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  border: 1px solid var(--line);
  background: var(--raise);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.88rem;
  cursor: pointer;
}
.chip[aria-pressed="true"] { border-color: var(--pick, var(--me)); color: var(--pick, var(--me)); font-weight: 600; }

.sheet {
  position: fixed; inset: 0;
  background: color-mix(in srgb, var(--ink) 45%, transparent);
  display: grid; align-items: end;
  z-index: 40;
}
.sheet-inner {
  background: var(--paper);
  border-radius: 1.1rem 1.1rem 0 0;
  padding: 1.2rem var(--gut) calc(1.4rem + env(safe-area-inset-bottom));
  max-height: 88vh; overflow: auto;
  max-width: 40rem; width: 100%; margin: 0 auto;
}
.sheet h2 { font-size: 1.35rem; margin: 0 0 1rem; }

/* ---- who am I ---------------------------------------------------------- */

.pick { position: fixed; inset: 0; background: var(--paper); display: grid; place-items: center; z-index: 50; }
.pick-inner { width: min(22rem, 88vw); }
.pick-title { font-size: 2rem; margin: 0 0 1.4rem; }
.pick-list { display: grid; gap: 0.6rem; }
.pick-list button {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line); background: var(--raise);
  border-radius: var(--radius); cursor: pointer; text-align: left;
}
.pick-list .dot { width: 1.7rem; height: 1.7rem; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-family: var(--display); font-size: 0.85rem; }

/* ---- odds and ends ----------------------------------------------------- */

.empty { color: var(--ink-faint); padding: 1.2rem 0 0; }
.empty strong { display: block; font-family: var(--display); font-size: 1.15rem; color: var(--ink); font-weight: 500; margin-bottom: 0.2rem; }

.toast {
  position: fixed;
  left: 50%; bottom: calc(5.2rem + env(safe-area-inset-bottom));
  transform: translate(-50%, 1rem);
  background: var(--ink); color: var(--paper);
  padding: 0.6rem 1rem; border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 60;
}
.toast.up { opacity: 1; transform: translate(-50%, 0); }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 0 1rem; }
.bar h1 { font-size: 1.8rem; }

.sub { color: var(--ink-soft); margin: -0.4rem 0 1.4rem; }

.strike { text-decoration: line-through; color: var(--ink-faint); }

.linkrow {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 0; border-bottom: 1px solid var(--line-soft);
}
.linkrow small { color: var(--ink-faint); }

/* ---- what the first month taught us --------------------------------------
 * Added with the Week, the kitchen wall and real project pages. Everything
 * below reuses the row, the tick and the person's colour; nothing here is
 * allowed to be louder than the date at the top of Today.
 */

/* The row's main target is a button or a link; either way it is plain. */
.row-main {
  border: 0; background: transparent; text-align: left; padding: 0;
  cursor: pointer; color: inherit; font: inherit; display: block;
}
.row-sub.soon { color: var(--late); }
.chev { color: var(--ink-faint); font-size: 1.3rem; padding-right: 0.3rem; }

/* Quick add: one box, one button, and the long form behind an ellipsis. */
.quick { margin: 0 0 1.6rem; }
.quick .btn.quiet { flex: none; padding-inline: 0.8rem; }

.streak { color: var(--me); font-weight: 600; white-space: nowrap; }

.empty.clear { padding: 0.6rem 0 1.4rem; }
.empty.clear .btn { margin-top: 0.8rem; }

.pre { white-space: pre-wrap; }
.faint { color: var(--ink-faint); }
.quiet-line { color: var(--ink-faint); padding: 0.55rem 0 0.55rem 0.85rem; margin: 0; list-style: none; }

.more-link {
  display: inline-block; margin-top: 0.55rem; padding-left: 0.85rem;
  color: var(--ink-soft); font-size: 0.9rem;
  text-decoration: underline; text-underline-offset: 3px;
}

.back {
  display: inline-block; color: var(--ink-faint); font-size: 0.85rem;
  margin-bottom: 0.2rem;
}
.bar-nav { display: flex; gap: 0.9rem; align-items: center; }

/* Events: the whole row is the tap target for the sheet. */
.ev-main {
  flex: 1 1 auto; min-width: 0; border: 0; background: transparent; padding: 0;
  text-align: left; color: inherit; font: inherit; cursor: pointer;
}
.ev-cal { font-size: 0.78rem; color: var(--ink-faint); margin-left: 0.45rem; }

/* Dinner, as a line under a day. */
.dinner-line {
  display: flex; gap: 0.7rem; align-items: baseline;
  padding: 0.55rem 0 0.55rem 0.85rem; list-style: none;
  border-bottom: 1px solid var(--line-soft);
}
.dinner-line a { display: contents; }
.dinner-tag {
  flex: none; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-faint); width: 4.4rem;
}

/* ---- the week ------------------------------------------------------------ */

.dayblock { margin: 0 0 1.4rem; }
.dayhead {
  display: flex; align-items: baseline; gap: 0.45rem;
  font-family: var(--display); font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em;
  margin: 0 0 0.35rem; padding-top: 0.4rem;
  border-top: 2px solid var(--line);
}
.dayhead.today { border-top-color: var(--me); }
.dayhead.today .dayhead-dow { color: var(--me); }
.dayhead.past { color: var(--ink-faint); }
.dayhead small {
  font-family: var(--text); font-weight: 500; font-size: 0.75rem;
  color: var(--me); text-transform: uppercase; letter-spacing: 0.06em; margin-left: 0.3rem;
}

/* ---- projects ------------------------------------------------------------ */

.meta { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 0.9rem; }
.pill {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0.2rem 0.65rem; font-size: 0.82rem; color: var(--ink-soft);
}
.pill.soon { border-color: var(--late); color: var(--late); }

.progress {
  height: 6px; border-radius: 3px; background: var(--line-soft);
  overflow: hidden; margin: 0 0 1.2rem;
}
.progress > i { display: block; height: 100%; background: var(--me); border-radius: 3px; transition: width .3s ease; }

/* An unplanned step: a dashed circle, because ticking it is "I just did it"
   rather than "the thing that was due is done". */
.tick.unplanned { border-style: dashed; }

/* ---- the kitchen wall ---------------------------------------------------- */

body.wall .tabs { display: none; }
body.wall .view {
  max-width: 76rem;
  padding: max(1.4rem, env(safe-area-inset-top)) 2rem 2rem;
  font-size: 1.12rem;
}
body.wall .row-title { font-size: 1.15rem; }
body.wall .row-sub { font-size: 0.92rem; }
body.wall .ev-title { font-size: 1.1rem; }
body.wall .tick { width: 2.5rem; height: 2.5rem; }
body.wall .group > h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; }
body.wall .sheet-inner { font-size: 1.1rem; }

.wall-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; margin: 0 0 1.8rem;
}
.wall-date { font-size: clamp(2.4rem, 6vw, 3.6rem); }
.wall-clock {
  font-family: var(--display); font-weight: 500; font-size: clamp(1.6rem, 4vw, 2.4rem);
  color: var(--ink-soft); font-variant-numeric: tabular-nums; line-height: 1;
  padding-top: 0.3rem;
}

.wall-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 2.4rem; }
@media (max-width: 52rem) { .wall-grid { grid-template-columns: 1fr; gap: 0; } }

.dinner-big { font-family: var(--display); font-weight: 500; font-size: 1.5rem; line-height: 1.2; margin: 0 0 0.6rem; }
.dinner-big p { margin: 0 0 0.25rem; }
.dinner-big p + p { color: var(--ink-soft); }
.dinner-big small { display: block; font-family: var(--text); font-weight: 400; font-size: 0.9rem; color: var(--ink-faint); margin-top: 0.3rem; }
.dinner-big.faint { font-weight: 400; }

.wall-week {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.9rem;
  margin-top: 1.6rem; padding-top: 1.2rem; border-top: 1px solid var(--line);
}
@media (max-width: 52rem) { .wall-week { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 30rem) { .wall-week { grid-template-columns: repeat(2, 1fr); } }
.wall-day h3 { font-size: 1rem; margin: 0 0 0.35rem; color: var(--ink-soft); }
.wall-day p { margin: 0 0 0.25rem; font-size: 0.86rem; line-height: 1.3; }
.wall-ev { border-left: 3px solid var(--own, var(--line)); padding-left: 0.4rem; }
.wall-ev-time { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.wall-count { color: var(--ink-soft); display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.wall-dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; }
.wall-dinner { color: var(--ink-faint); margin-top: 0.4rem !important; }

/* <main> is focused after every screen swap for screen readers; the ring that
   focus-visible would draw around the whole page is not for anyone. */
.view:focus-visible { outline: none; }
