/* Babywatch.
   Always dark. This gets used at 3am and a white screen is hostile.
   Every size is relative so it fits an SE and a Pro Max without a media query. */

:root {
  color-scheme: dark;

  --bg: #14141a;
  --surface: #1e1e27;
  --line: #2c2c38;
  --text: #e8e6ef;
  --muted: #8b8798;

  --calm: #4db6a4;      /* resting, tap to start */
  --active: #e8a33d;    /* a contraction is running */
  --quiet-red: #c9736b; /* delete, used sparingly */

  --ink: #14141a;       /* text on the coloured button */
  --pad: 1.25rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* ------------------------------------------------------------------ stage */
/* One screen. The button is always in the lower half, under a thumb, and never
   needs scrolling to reach. History lives below the fold on purpose. */

.stage {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    calc(env(safe-area-inset-top) + var(--pad))
    calc(env(safe-area-inset-right) + var(--pad))
    calc(env(safe-area-inset-bottom) + var(--pad))
    calc(env(safe-area-inset-left) + var(--pad));
  gap: 1rem;
}

/* ---------------------------------------------------------------- readout */

.readout { text-align: center; flex: 0 0 auto; }

.status {
  margin: 0;
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color .3s ease;
}
.status[data-running="true"] { color: var(--active); }

.counter {
  margin: .25rem 0 0;
  font-size: clamp(4rem, 23vw, 7rem);
  font-weight: 200;
  line-height: 1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.stats {
  display: flex;
  justify-content: center;
  gap: clamp(1rem, 7vw, 2.5rem);
  margin-top: 1rem;
}
.stat { display: flex; flex-direction: column; gap: .1rem; }
.stat-value {
  font-size: 1.0625rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: .6875rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}

/* -------------------------------------------------------------- the button */

.tap {
  flex: 1 1 auto;
  min-height: 38dvh;
  width: 100%;
  border-radius: 2rem;
  background: var(--calm);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  transition: background .25s ease, transform .08s ease;
}
.tap:active { transform: scale(.985); }
.tap[data-running="true"] { background: var(--active); }
.tap[data-locked="true"] { opacity: .75; }

.tap-label {
  font-size: clamp(2rem, 9vw, 2.75rem);
  font-weight: 600;
  letter-spacing: -.01em;
}
.tap-hint {
  font-size: .875rem;
  font-weight: 500;
  opacity: .68;
  min-height: 1.2em;
  padding: 0 1rem;
  text-align: center;
}

/* ------------------------------------------------------------------- tray */

.tray {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  min-height: 3.75rem;
  justify-content: center;
}

.undo {
  padding: .5rem 1.25rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: .9375rem;
  font-weight: 500;
}
.undo:active { background: var(--surface); }

.disclaimer {
  margin: 0;
  font-size: .75rem;
  color: var(--muted);
  text-align: center;
}

/* ---------------------------------------------------------------- history */

.history {
  padding:
    1.5rem
    calc(env(safe-area-inset-right) + var(--pad))
    calc(env(safe-area-inset-bottom) + 2rem)
    calc(env(safe-area-inset-left) + var(--pad));
  border-top: 1px solid var(--line);
}

.history-title {
  margin: 0 0 .75rem;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.row {
  display: grid;
  grid-template-columns: 2.25rem 1fr auto auto;
  align-items: center;
  gap: .75rem;
  padding: .8125rem .25rem;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.row:last-child { border-bottom: 0; }

.row-index { color: var(--muted); font-size: .8125rem; }
.row-time  { color: var(--muted); font-size: .875rem; }
.row-figure { font-size: .9375rem; font-weight: 500; }
.row-figure .row-gap { color: var(--muted); font-weight: 400; margin-left: .5rem; }

.row-delete {
  padding: .35rem .6rem;
  border-radius: 999px;
  font-size: .8125rem;
  color: var(--muted);
  border: 1px solid transparent;
}
.row-delete[data-armed="true"] {
  color: var(--quiet-red);
  border-color: var(--quiet-red);
}

.row[data-running="true"] .row-figure { color: var(--active); }

/* ----------------------------------------------------------------- banner */
/* Calm on purpose. The reviewed apps put "DANGER" in red here and people hated
   it. This states what the numbers say and what to do about it. */

.banner {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  padding:
    calc(env(safe-area-inset-top) + .75rem)
    calc(env(safe-area-inset-right) + .75rem)
    .75rem
    calc(env(safe-area-inset-left) + .75rem);
  animation: drop .4s ease both;
}
@keyframes drop { from { transform: translateY(-110%); } to { transform: none; } }

.banner-body {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--calm);
  border-radius: 1rem;
  padding: 1rem 1.125rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}
.banner-body p { margin: 0; font-size: .9375rem; line-height: 1.45; }

.banner-dismiss {
  align-self: flex-start;
  padding: .45rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: .875rem;
  font-weight: 500;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ------------------------------------------------------------------ share */
/* Deliberately quiet. It must never compete with the button above it. */

.share-row {
  display: flex;
  align-items: center;
  gap: .625rem;
  flex-wrap: wrap;
  justify-content: center;
}

.share {
  padding: .375rem .75rem;
  border-radius: 999px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--calm);
}
.share:active { opacity: .6; }
.share:disabled { opacity: .5; }

.share-state {
  font-size: .75rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.share-state[data-stalled="true"] { color: var(--active); }

/* ------------------------------------------------------------- watch page */
/* A mirror, not a control panel. There is nothing here to press. */

.stage-watch {
  height: auto;
  min-height: 62dvh;
  justify-content: flex-start;
  gap: 1.5rem;
}
.stage-watch .readout { margin-top: 1rem; }

.watch-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.watch-title, .watch-link {
  margin: 0;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.watch-link[data-live="true"] { color: var(--calm); }
.watch-link[data-live="false"] { color: var(--active); }

.watch-note {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: .875rem;
  padding: 0 1rem;
}

.watching .history { min-height: 38dvh; }

/* ------------------------------------------------------------------ reset */
/* Deliberately at the bottom of the history, past every row, so getting to it
   takes a scroll rather than a stray thumb. */

.reset-row {
  display: flex;
  justify-content: center;
  padding-top: 1.75rem;
}

.reset {
  padding: .5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: .8125rem;
  color: var(--muted);
}
.reset:active { color: var(--quiet-red); border-color: var(--quiet-red); }

/* ----------------------------------------------------------- reset dialog */

.sheet {
  border: 0;
  padding: 0;
  background: none;
  color: var(--text);
  max-width: 26rem;
  width: calc(100% - 2rem);
}
.sheet::backdrop { background: rgba(8, 8, 12, .78); }

.sheet-body {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .875rem;
}

.sheet-title { margin: 0; font-size: 1.125rem; font-weight: 600; }
.sheet-text  { margin: 0; font-size: .9375rem; line-height: 1.5; color: var(--muted); }

.sheet-label { font-size: .8125rem; color: var(--muted); }
.sheet-label b { color: var(--text); font-weight: 600; letter-spacing: .04em; }

.sheet-input {
  font: inherit;
  font-size: 1.0625rem;
  letter-spacing: .06em;
  padding: .75rem .875rem;
  border-radius: .75rem;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
.sheet-input:focus {
  outline: none;
  border-color: var(--calm);
}

.sheet-actions {
  display: flex;
  gap: .625rem;
  justify-content: flex-end;
  margin-top: .25rem;
}

.sheet-cancel, .sheet-confirm {
  padding: .625rem 1.125rem;
  border-radius: 999px;
  font-size: .9375rem;
  font-weight: 500;
  border: 1px solid var(--line);
}
.sheet-confirm {
  border-color: transparent;
  background: var(--quiet-red);
  color: var(--ink);
}
.sheet-confirm:disabled {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
  opacity: .55;
}
