/* ---------------------------------------------------------------------------
   wehumanhuman — app styles (tokens live in tokens.css)
   --------------------------------------------------------------------------- */
:root { --maxw: 480px; }

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100dvh;
}

.app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  padding: 24px 20px calc(96px + env(safe-area-inset-bottom));
  outline: none;
}

/* --- typography ----------------------------------------------------------- */

h1, h2, .display {
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.15;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }

.num {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
}

.muted { color: var(--ink-70); }
.small { font-size: 0.85rem; }

.wordmark { font-size: 1.15rem; }

/* --- giant countdown numeral ---------------------------------------------- */

.giant-num {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(7rem, 40vw, 11rem);
  line-height: 1;
  color: var(--ink);
  text-align: center;
  user-select: none;
  animation: breathe 4.5s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

/* --- breathing pacer -------------------------------------------------------- */

.breath {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}

.breath-circle {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--marker-soft);
  animation: breath-cycle 9s ease-in-out infinite;
}

@keyframes breath-cycle {
  0%, 100% { transform: scale(0.7); }
  50% { transform: scale(1.15); }
}

/* --- cards & layout -------------------------------------------------------- */

.card {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.stack > * + * { margin-top: 12px; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* --- buttons --------------------------------------------------------------- */

button {
  font-family: inherit;
  font-size: 1rem;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
  border-radius: 4px;
}

.btn {
  display: inline-block;
  width: 100%;
  padding: 15px 24px;
  border-radius: var(--radius);
  font-weight: 600;
  text-align: center;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:disabled { opacity: 0.3; cursor: default; transform: none; }
.btn-ghost { background: none; color: var(--ink-70); width: auto; padding: 12px 16px; }

/* --- chips ------------------------------------------------------------------ */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--ink-12);
  font-size: 0.9rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.chip:hover { border-color: var(--ink); }

.chip.added {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

/* your anchors get literally highlighted */
.entry-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--marker-soft);
  color: var(--ink);
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.entry-pill .x { color: var(--ink-45); font-size: 1rem; line-height: 1; }

/* --- inputs ----------------------------------------------------------------- */

.text-input {
  flex: 1;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--ink-12);
  background: var(--paper);
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  min-width: 0;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--ink);
  height: 32px;
}

.slider-value {
  font-family: var(--serif);
  font-style: italic;
  font-size: 5.5rem;
  line-height: 1;
  text-align: center;
  color: var(--ink);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  color: var(--ink-45);
  font-size: 0.8rem;
}

/* --- toggles (challenges) ---------------------------------------------------- */

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  width: 100%;
  text-align: left;
}

.toggle-row + .toggle-row { border-top: 1px solid var(--line); }

.toggle-pill {
  flex-shrink: 0;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: var(--ink-12);
  position: relative;
  transition: background 0.2s ease;
}

.toggle-pill::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--paper);
  transition: transform 0.2s ease;
}

.toggle-row[aria-pressed="true"] .toggle-pill { background: var(--ink); }
.toggle-row[aria-pressed="true"] .toggle-pill::after { transform: translateX(22px); }

.streak {
  font-weight: 600;
  font-size: 0.9rem;
  background: linear-gradient(100deg,
    transparent 0%, var(--marker-soft) 4%,
    var(--marker-soft) 95%, transparent 100%);
  padding: 0.08em 0.35em;
  border-radius: 0.3em 0.5em 0.4em 0.35em;
  white-space: nowrap;
}

/* --- bottom nav --------------------------------------------------------------- */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--maxw);
  display: flex;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-btn {
  flex: 1;
  padding: 16px 8px;
  color: var(--ink-45);
  font-weight: 600;
  font-size: 0.9rem;
}

.nav-btn[aria-current="page"] {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--marker);
  text-decoration-thickness: 4px;
  text-underline-offset: 6px;
}

/* --- check-in flow -------------------------------------------------------------- */

.flow { display: flex; flex-direction: column; min-height: calc(100dvh - 48px); }
.flow-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.flow-body { flex: 1; display: flex; flex-direction: column; gap: 16px; }
.flow-footer { padding-top: 16px; display: flex; gap: 12px; align-items: center; }

.step-enter { animation: step-in 0.35s ease both; }

@keyframes step-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.count-progress {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.3rem;
  color: var(--ink-45);
  white-space: nowrap;
}
.count-progress.done { color: var(--ink); }

/* --- trends ----------------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 6px;
  background: var(--ink-06);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  padding: 9px 4px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-70);
}

.tab-btn[aria-selected="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px var(--ink-12); }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.stat .num { font-size: 2.2rem; color: var(--ink); }
.stat .label { font-size: 0.78rem; color: var(--ink-70); }

.chart-wrap { overflow-x: auto; }
.chart-legend { display: flex; gap: 16px; font-size: 0.78rem; color: var(--ink-70); margin-top: 8px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: baseline; }

.hbar { height: 10px; border-radius: 999px; background: var(--ink-06); overflow: hidden; margin-top: 6px; }
.hbar-fill { height: 100%; border-radius: 999px; background: var(--marker); }

.word-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.word-tag {
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--marker-soft);
  font-size: 0.88rem;
}
.word-tag .num { color: var(--ink-70); margin-left: 4px; }

.insight {
  padding: 12px 0;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.insight + .insight { border-top: 1px solid var(--line); }
.insight-dot {
  flex-shrink: 0;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink);
  margin-top: 8px;
}
.insight.gentle .insight-dot { background: var(--marker); }

/* --- misc -------------------------------------------------------------------------- */

.empty {
  text-align: center;
  color: var(--ink-45);
  padding: 32px 16px;
}

.delta-line {
  font-family: var(--serif);
  font-style: italic;
  font-size: 3rem;
  text-align: center;
  color: var(--ink);
}

.app-footer-links {
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 24px 0 4px;
  font-size: 0.8rem;
}
.app-footer-links a { color: var(--ink-45); text-decoration-thickness: 1px; text-underline-offset: 3px; }

.crisis-note {
  text-align: center;
  color: var(--ink-45);
  font-size: 0.75rem;
  padding: 8px 12px 0;
  line-height: 1.5;
}

/* --- link button (secondary text action) ---------------------------------------------- */

.link-btn {
  background: none;
  border: none;
  color: var(--ink-45);
  font-size: 0.85rem;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  padding: 4px;
  align-self: center;
}
.link-btn:hover { color: var(--ink); }

/* --- back-dated entry: date row -------------------------------------------------------- */

.date-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px 0;
}
.date-row input[type="date"] {
  font-family: var(--sans);
  font-size: 0.9rem;
  padding: 8px 12px;
  border: 1px solid var(--ink-12);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
}

/* --- circle-of-life wheel -------------------------------------------------------------- */

.wheel { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }

.wheel-row { padding: 10px 0; border-top: 1px solid var(--line); }
.wheel-row:first-child { border-top: none; }

.wheel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.wheel-label { font-weight: 600; font-size: 0.95rem; }

.wheel-levels { display: flex; gap: 6px; }

.wheel-lv {
  font-family: var(--sans);
  font-size: 0.8rem;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--ink-12);
  background: var(--paper);
  color: var(--ink-70);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.wheel-lv:hover { border-color: var(--ink); }
.wheel-lv.sel { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.wheel-lv.sel.lv-base { background: var(--ink); color: var(--paper); }
.wheel-lv.sel.lv-below,
.wheel-lv.sel.lv-above { background: var(--marker-soft); }

.wheel-note { margin-top: 10px; width: 100%; }

/* --- challenge editor ------------------------------------------------------------------ */

.sub-head {
  font-size: 1rem;
  font-weight: 700;
  margin: 24px 0 10px;
}

.ed-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.ed-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}
.ed-item:first-child { border-top: none; }

.ed-text { min-width: 0; }
.ed-name { font-weight: 600; }

.ed-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.ed-toggle {
  min-width: 52px;
  text-align: center;
  cursor: pointer;
}

.ed-remove { color: var(--ink-45); font-size: 0.8rem; padding: 6px 8px; }
.ed-remove:hover { color: var(--ink); }

/* --- reduced motion ------------------------------------------------------------------ */

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