/* ═══════════════════════════════════════════════════════════════════════════
   DUO DESIGN TOKENS — the single place colour and spacing are defined.

   The same rule as BirdBrain's style.css: nothing else contains a raw hex value.
   The plum is a placeholder until there is a logo to take a colour from.
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
  --brand-plum:        #7A2E4D;   /* header, links                          */
  --brand-paper:       #F8F4F2;   /* the page                               */
  --brand-white:       #FFFFFF;   /* cards                                  */
  --brand-ink:         #241A1E;   /* text                                   */
  --brand-mauve:       #7D6F75;   /* inactive tabs, secondary text          */
  --brand-line:        #E6DCDF;   /* hairlines between surfaces             */
  --brand-blush:       #F3E4EA;   /* soft fill behind icons                 */

  /* The mood scale, Low to Great: a check-in's colour wherever it is shown
     (the calendar's dots first). Cool when low, warm when high. */
  --mood-low:          #6E7FA3;
  --mood-down:         #9DB1CB;
  --mood-okay:         #D8CBBE;
  --mood-good:         #E9A486;
  --mood-great:        #D4566F;

  --brand-alert:       #A8323E;   /* something went wrong                   */

  --surface:           var(--brand-paper);
  --surface-raised:    var(--brand-white);
  --surface-header:    var(--brand-plum);
  --text-primary:      var(--brand-ink);
  --text-muted:        var(--brand-mauve);
  --text-on-brand:     var(--brand-white);
  --line:              var(--brand-line);
  --surface-soft:      var(--brand-blush);
  --toast-bg:          var(--brand-ink);
  --text-alert:        var(--brand-alert);
  --scrim:             color-mix(in srgb, var(--brand-ink) 45%, transparent);  /* behind a sheet */

  --uni_margin:        16px;
  --radius:            12px;
  --topbar-h:          52px;
  --navbot-h:          60px;
  --gap:               12px;      /* between cards in a list                */
  --icon-disc:         48px;      /* the round icon in an empty state       */
  --tap:               44px;      /* smallest comfortable touch target      */
  --qr:                220px;     /* the pair code's QR in the linking sheet */
}

* { box-sizing: border-box; }

/* The hidden attribute wins over any display a class gives (.btn-block,
   .empty-state): link.js and nav.js show and hide things with it. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: var(--surface);
  color: var(--text-primary);
}

.topbar {
  height: var(--topbar-h);
  padding-top: env(safe-area-inset-top);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-header);
}

.wordmark {
  color: var(--text-on-brand);
  font-weight: 700;
  font-size: 20px;
  text-decoration: none;
}

/* The bottom bar is fixed, so the page stops short of it. */
#main {
  padding: var(--uni_margin);
  padding-bottom: calc(var(--navbot-h) + env(safe-area-inset-bottom) + var(--uni_margin));
}

.card {
  background: var(--surface-raised);
  border-radius: var(--radius);
  padding: var(--uni_margin);
}

.screen > .card + .card,
.screen > .card + .card-list,
.screen > .card-list + .card { margin-top: var(--gap); }

/* A section's own heading, under the topbar. */
.screen-head { margin-bottom: var(--uni_margin); }
.screen-head h1 { margin: 0 0 4px; font-size: 24px; }
.screen-head p { margin: 0; color: var(--text-muted); }

/* A stack of tappable cards: icon on the left, title and a line beside it. */
.card-list { display: flex; flex-direction: column; gap: var(--gap); }
.card-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--uni_margin);
  border: 0;
  font: inherit;
  color: inherit;
  text-align: left;
}
.card-icon {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--brand-plum);
}
.card-icon svg { width: 24px; height: 24px; }
.card-text { display: flex; flex-direction: column; gap: 2px; }
.card-text span { color: var(--text-muted); font-size: 14px; }

/* The empty-state pattern: icon, heading, one line of text, an action. */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--uni_margin) 0;
}
.empty-icon {
  width: var(--icon-disc);
  height: var(--icon-disc);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--brand-plum);
}
.empty-icon svg { width: 26px; height: 26px; }
.empty-state h2 { margin: var(--gap) 0 4px; font-size: 18px; }
.empty-state p { margin: 0; color: var(--text-muted); max-width: 28em; }
.empty-state .btn { margin-top: var(--uni_margin); }

.btn {
  min-height: var(--tap);
  padding: 0 20px;
  border: 0;
  border-radius: calc(var(--tap) / 2);
  background: var(--brand-plum);
  color: var(--text-on-brand);
  font: inherit;
  font-weight: 700;
}
.btn:disabled { opacity: 0.45; }

/* Mood: five faces in a row. */
.mood-row { display: flex; justify-content: space-between; }
.mood-face {
  min-width: var(--tap);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  font: inherit;
  color: var(--text-muted);
}
.mood-face span { font-size: 32px; line-height: 1; }
.mood-face small { font-size: 12px; }

/* Calendar: the month grid. */
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--gap);
}
.cal-head h2 { margin: 0; font-size: 18px; }
.cal-arrow {
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand-plum);
}
.cal-arrow svg { width: 22px; height: 22px; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  row-gap: 6px;
  text-align: center;
}
.cal-dow { color: var(--text-muted); font-size: 12px; font-weight: 700; padding-bottom: 4px; }

/* A day: its number, two mood dots (you on the left, your partner on the
   right; hollow when not shared) and a bar under it if anything is planned. */
.cal-day {
  position: relative;
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding-top: 4px;
}
.cal-day b {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 400;
  font-size: 14px;
}
.cal-day.is-today b { background: var(--brand-plum); color: var(--text-on-brand); font-weight: 700; }
.cal-day.is-future b { color: var(--text-muted); }
.cal-day.is-selected b { box-shadow: 0 0 0 2px var(--brand-plum); }
.cal-dots { display: flex; gap: 3px; }
.cal-dot { width: 7px; height: 7px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--line); }
.cal-dot[class*="mood-"] { box-shadow: none; }
.cal-day.is-future .cal-dot { visibility: hidden; }
.cal-plan {
  position: absolute;
  bottom: 2px;
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: var(--brand-plum);
}

/* A check-in's colour, as a fill. */
.mood-low   { background: var(--mood-low); }
.mood-down  { background: var(--mood-down); }
.mood-okay  { background: var(--mood-okay); }
.mood-good  { background: var(--mood-good); }
.mood-great { background: var(--mood-great); }

/* Says an entry is private until shared. */
.private-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: var(--uni_margin) 0 0;
  color: var(--text-muted);
  font-size: 13px;
}
.private-note svg { flex: none; width: 16px; height: 16px; }

/* main.js: 'coming soon', just above the bottom bar. */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--navbot-h) + env(safe-area-inset-bottom) + var(--gap));
  transform: translateX(-50%);
  z-index: 11;
  padding: 10px 18px;
  border-radius: var(--radius);
  background: var(--toast-bg);
  color: var(--text-on-brand);
  font-size: 14px;
}

/* ── Linking the phones (link.js, templates/_link.html) ─────────────── */
.link-card { cursor: pointer; }
.btn-ghost { background: var(--surface-soft); color: var(--brand-plum); }
.btn-block { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-block svg { width: 20px; height: 20px; }

/* backup.js: when this phone last backed up onto the partner's, on the linked card. */
.backup-status {
  align-self: stretch;
  margin-top: var(--uni_margin);
  padding-top: var(--gap);
  border-top: 1px solid var(--line);
}
.empty-state .backup-line { margin: 0 auto; font-size: 13px; color: var(--text-muted); }
.empty-state .btn-quiet {
  margin-top: 6px;
  min-height: var(--tap);
  padding: 0 var(--gap);
  border: 0;
  background: transparent;
  color: var(--brand-plum);
  font-size: 14px;
}

/* A sheet rises from the foot of the screen over everything, bar included. */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: var(--scrim); }
.sheet-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 92vh;
  overflow-y: auto;
  padding: calc(var(--uni_margin) * 1.5) var(--uni_margin) calc(var(--uni_margin) * 1.5 + env(safe-area-inset-bottom));
  border-radius: calc(var(--radius) * 1.5) calc(var(--radius) * 1.5) 0 0;
  background: var(--surface);
}
body.sheet-open { overflow: hidden; }
.sheet-close {
  position: absolute;
  top: 8px; right: 8px;
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--text-muted);
}
.sheet-close svg { width: 22px; height: 22px; }
.sheet-panel h2 { margin: 0 0 4px; padding-right: var(--tap); font-size: 20px; }
.sheet-lead { margin: 0 0 var(--uni_margin); color: var(--text-muted); }
.sheet-choice { cursor: pointer; }
.sheet-actions { display: flex; gap: var(--gap); }
.sheet-actions .btn { flex: 1; }

/* Show my code: the QR, the code to type, how long it lasts. */
.qr-box {
  width: calc(var(--qr) + 2 * var(--gap));
  margin: 0 auto;
  padding: var(--gap);
  border-radius: var(--radius);
  background: var(--brand-white);
}
.qr-box img { display: block; width: var(--qr); height: var(--qr); }
.pair-code {
  margin: var(--uni_margin) 0 4px;
  text-align: center;
  font: 700 34px/1 ui-monospace, monospace;
  letter-spacing: 0.12em;
}
.pair-wait {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* Scan partner's code: the camera, or the code typed in. */
.sheet-or {
  display: flex;
  align-items: center;
  gap: var(--gap);
  margin: var(--uni_margin) 0;
  color: var(--text-muted);
  font-size: 13px;
}
.sheet-or::before, .sheet-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.pair-form label { display: block; margin: var(--gap) 0 6px; font-weight: 700; }
.pair-row { display: flex; gap: 8px; }
.pair-row input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--text-primary);
  font: 700 20px ui-monospace, monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.pair-row input::placeholder { color: var(--text-muted); font-weight: 400; }
.pair-row input:focus { outline: 2px solid var(--brand-plum); outline-offset: 1px; }

.form-error { margin: var(--gap) 0 0; color: var(--text-alert); font-size: 14px; }
