/* UnbrokenDay — tracker app surface.
   Light only. Warm off-white, near-black ink, one forest-green accent.
   The urge protocol is a deliberate full-screen deep-green focus mode, not a dark theme.
*/

:root {
  --c-text: #171717;
  --c-muted: #5c5c5c;
  --c-soft: #6f6f6f;
  --c-bg: #fafaf7;
  --c-card: #ffffff;
  --c-border: #e3e0d8;
  --c-border-strong: #cfcabf;

  --c-accent: #1f4535;
  --c-accent-hover: #163025;
  --c-accent-soft: #e8efe9;
  --c-accent-soft-2: #d9e4dc;

  --c-danger: #9c4a2f;
  --c-danger-soft: #f7e8e1;

  /* Warm parchment zone — intentionally one step warmer than --c-bg (pod card). */
  --c-parchment: #f6f1e6;
  --c-parchment-border: #e7dfca;


  --s-1: 8px; --s-2: 16px; --s-3: 24px; --s-4: 32px; --s-5: 48px; --s-6: 64px;

  --r-sm: 12px; --r-md: 14px; --r-lg: 16px; --r-xl: 20px;

  --maxw: 480px;

  --f-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --f-display: "Fraunces", Georgia, "Times New Roman", serif;

  --shadow-sm: 0 1px 2px rgba(23, 23, 23, 0.04);
  --shadow-md: 0 2px 8px rgba(23, 23, 23, 0.05), 0 12px 32px rgba(23, 23, 23, 0.05);
  --shadow-focus: 0 0 0 3px rgba(31, 69, 53, 0.18);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

button { font-family: inherit; }

:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--r-sm);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--c-accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 var(--r-sm) 0;
  z-index: 100;
}
.skip:focus { left: 0; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ─── Top bar ──────────────────────────────────────────────────────────── */

.topbar {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: calc(var(--s-2) + env(safe-area-inset-top)) var(--s-3) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}

.wordmark {
  font-family: var(--f-display);
  font-weight: 560;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--c-accent);
  background: var(--c-accent-soft);
  border: 1px solid var(--c-accent-soft-2);
  border-radius: 999px;
  padding: 5px 11px;
  white-space: nowrap;
}

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--s-3) var(--s-5);
}

/* ─── First-visit pitch ────────────────────────────────────────────────── */

.hero-pitch {
  padding-top: var(--s-5);
  text-align: center;
}
.returning .hero-pitch { display: none; }

.hero-h1 {
  font-family: var(--f-display);
  font-weight: 560;
  font-size: clamp(2.4rem, 11vw, 3.4rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
  margin: 0 0 var(--s-2);
}
.hero-h1 em { font-style: italic; color: var(--c-accent); }

.hero-lede {
  color: var(--c-muted);
  font-size: 1.05rem;
  max-width: 36ch;
  margin: 0 auto;
}

.hero-proof {
  margin: var(--s-2) auto 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--c-accent);
  font-variant-numeric: tabular-nums;
}
.hero-proof strong { font-family: var(--f-display); font-size: 1.05rem; }

/* ─── Streak stage ─────────────────────────────────────────────────────── */

.app { padding-top: var(--s-4); }
html:not(.returning) .app { padding-top: var(--s-3); }

.streak-stage { text-align: center; }

.plant {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 170px;
  margin: 0 auto;
}
.plant svg { overflow: visible; }
.plant .leaf { fill: var(--c-accent-soft-2); stroke: var(--c-accent); stroke-width: 2; stroke-linejoin: round; }
.plant .stem { fill: none; stroke: var(--c-accent); stroke-width: 2.5; stroke-linecap: round; }
.plant .trunk { fill: none; stroke: var(--c-accent); stroke-width: 3.5; stroke-linecap: round; }
.plant .canopy { fill: var(--c-accent-soft); stroke: var(--c-accent); stroke-width: 2.5; stroke-linejoin: round; }
.plant .ground { fill: none; stroke: var(--c-border-strong); stroke-width: 2.5; stroke-linecap: round; }
.plant .seed { fill: var(--c-accent); }
.plant.grew svg { animation: plantGrow 0.9s cubic-bezier(0.22, 1, 0.36, 1); transform-origin: 50% 100%; }
@keyframes plantGrow {
  0% { transform: scale(0.96); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

.day-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: var(--s-2);
}

.day-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--c-soft);
}

.streak-number {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: clamp(4rem, 22vw, 5.6rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.streak-number.bump { animation: bump 0.45s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.streak-number.fading { opacity: 0.15; transition: opacity 0.6s ease; }

.identity-line {
  font-family: var(--f-display);
  font-style: italic;
  font-size: 1.3rem;
  margin: var(--s-3) 0 0;
  color: var(--c-text);
  min-height: 1.6em;
}
.identity-line.defense { color: var(--c-danger); }
.identity-line.glow { color: var(--c-accent); }

/* ─── Week strip ───────────────────────────────────────────────────────── */

.week-strip {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: var(--s-3);
}

.day-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--c-soft);
  border: 1.5px solid var(--c-border);
  background: var(--c-card);
}
.day-dot.clean {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #fff;
}
.day-dot.relapsed {
  background: var(--c-danger-soft);
  border-color: var(--c-danger);
  color: var(--c-danger);
}
.day-dot.today-active {
  border-color: var(--c-accent);
  border-style: dashed;
  color: var(--c-accent);
}

/* ─── Grow line (the one quiet stat) ───────────────────────────────────── */

.grow-line {
  font-size: 0.85rem;
  color: var(--c-muted);
  margin: var(--s-2) 0 0;
  font-variant-numeric: tabular-nums;
}

/* ─── Why card ─────────────────────────────────────────────────────────── */

.why-card {
  margin-top: var(--s-4);
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--s-2);
  box-shadow: var(--shadow-sm);
}

.why-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-soft);
  margin-bottom: 4px;
}

.why-text {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 6px 0;
  min-height: 44px;
  font-size: 1rem;
  font-family: var(--f-display);
  font-style: italic;
  color: var(--c-muted);
  cursor: pointer;
}
.why-text.has-why { color: var(--c-text); }

.why-edit {
  width: 100%;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-family: var(--f-body);
  font-size: 1rem;
  resize: vertical;
  background: var(--c-bg);
  color: var(--c-text);
}

/* ─── Buttons ──────────────────────────────────────────────────────────── */

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: var(--s-3);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 14px 20px;
  font-size: 1.02rem;
  font-weight: 600;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease, background-color 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.985); }

.btn-clean {
  background: var(--c-accent);
  color: #fff;
  width: 100%;
}
.btn-clean:hover { background: var(--c-accent-hover); }
.btn-clean:disabled {
  background: var(--c-accent-soft);
  color: var(--c-accent);
  cursor: default;
  transform: none;
}

.btn-urge {
  background: var(--c-card);
  color: var(--c-accent);
  border-color: var(--c-accent-soft-2);
  width: 100%;
}
.btn-urge:hover { background: var(--c-accent-soft); }

.btn-quiet {
  width: 100%;
  background: none;
  border: none;
  min-height: 44px;
  font-size: 0.85rem;
  color: var(--c-soft);
  cursor: pointer;
  border-radius: var(--r-sm);
  padding: 10px;
}
.btn-quiet:hover { color: var(--c-muted); background: rgba(23, 23, 23, 0.03); }
.btn-quiet-danger:hover { color: var(--c-danger); background: var(--c-danger-soft); }
.btn-quiet:disabled { opacity: 0.4; cursor: default; }

.btn-danger {
  background: var(--c-danger);
  color: #fff;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--c-border-strong);
  color: var(--c-text);
}

/* ─── Hint, warnings ───────────────────────────────────────────────────── */

.hint-card {
  margin-top: var(--s-3);
  background: var(--c-accent-soft);
  border: 1px solid var(--c-accent-soft-2);
  border-radius: var(--r-lg);
  padding: var(--s-2);
  font-size: 0.92rem;
}
.hint-card p { margin: 0 0 10px; }

.hint-dismiss {
  background: none;
  border: none;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--c-accent);
  cursor: pointer;
  padding: 8px 0;
  min-height: 44px;
}

.storage-warning {
  margin-top: var(--s-2);
  font-size: 0.85rem;
  color: var(--c-danger);
  background: var(--c-danger-soft);
  border-radius: var(--r-sm);
  padding: 10px 14px;
}

.install-hint {
  margin-top: var(--s-2);
  font-size: 0.85rem;
  color: var(--c-muted);
  text-align: center;
}
.install-hint button {
  background: none;
  border: 1px solid var(--c-border-strong);
  border-radius: 999px;
  padding: 8px 16px;
  min-height: 44px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--c-accent);
  cursor: pointer;
}

/* ─── Info section ─────────────────────────────────────────────────────── */

.info { margin-top: var(--s-6); border-top: 1px solid var(--c-border); padding-top: var(--s-4); }

.info .info-h1 {
  font-family: var(--f-display);
  font-weight: 560;
  font-size: clamp(1.7rem, 6vw, 2.1rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 var(--s-2);
}

.info h2 {
  font-family: var(--f-display);
  font-weight: 540;
  font-size: 1.4rem;
  margin: var(--s-4) 0 var(--s-1);
}

.info p { color: var(--c-muted); margin: 0 0 var(--s-2); }

.info-steps { padding-left: 1.2em; color: var(--c-muted); margin: 0; }
.info-steps li { margin-bottom: 10px; }
.info-steps strong { color: var(--c-text); }

.info-install { font-size: 0.95rem; }

/* ─── Guides ───────────────────────────────────────────────────────────── */

.guides { margin-top: var(--s-5); }

.guides h2 {
  font-family: var(--f-display);
  font-weight: 540;
  font-size: 1.4rem;
  margin: 0 0 4px;
}

.guides-sub { color: var(--c-muted); font-size: 0.95rem; margin: 0 0 var(--s-2); }

.guide-list { display: flex; flex-direction: column; gap: 10px; }

.guides-all { margin: var(--s-1) 0 0; font-size: 0.9rem; }
.guides-all a { display: inline-block; padding: 14px 0; color: var(--c-accent); font-weight: 600; text-decoration: none; }
.guides-all a:hover { text-decoration: underline; }

/* ─── FAQ ──────────────────────────────────────────────────────────────── */

.faq { margin-top: var(--s-5); }

.faq h2 {
  font-family: var(--f-display);
  font-weight: 540;
  font-size: 1.4rem;
  margin: 0 0 var(--s-2);
}

.faq details {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}

.faq summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 14px 16px;
  min-height: 44px;
  position: relative;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-soft);
  font-size: 1.2rem;
}
.faq details[open] summary::after { content: "–"; }

.faq details p {
  margin: 0;
  padding: 0 16px 14px;
  color: var(--c-muted);
  font-size: 0.92rem;
}
.faq details a { color: var(--c-accent); }

/* ─── Final CTA ────────────────────────────────────────────────────────── */

.final-cta { margin-top: var(--s-5); }
.final-cta .btn { width: 100%; }

/* ─── Pod capture ──────────────────────────────────────────────────────── */

.pod-capture {
  margin-top: var(--s-5);
  background: var(--c-parchment);
  border: 1px solid var(--c-parchment-border);
  border-radius: var(--r-xl);
  padding: var(--s-3);
}

.pod-capture h2 {
  font-family: var(--f-display);
  font-weight: 540;
  font-size: 1.4rem;
  margin: 0 0 6px;
}
.pod-capture > p { color: var(--c-muted); margin: 0 0 var(--s-2); font-size: 0.95rem; }

.pod-form-row { display: flex; flex-direction: column; gap: 10px; }

.pod-form input[type="email"] {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 1rem;
  font-family: var(--f-body);
  background: var(--c-card);
  color: var(--c-text);
}
.pod-form input[type="email"]:focus-visible { box-shadow: var(--shadow-focus); outline: none; }

.pod-fine { font-size: 0.78rem; color: var(--c-soft); margin: 10px 0 0; }

.honeypot { position: absolute; left: -9999px; }

.notice {
  background: var(--c-accent-soft);
  border: 1px solid var(--c-accent-soft-2);
  color: var(--c-accent);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.95rem;
}

/* ─── More links / footer ──────────────────────────────────────────────── */

.more { margin-top: var(--s-4); display: flex; flex-direction: column; gap: 10px; }

.more-link {
  display: block;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  min-height: 44px;
  color: var(--c-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}
.more-link:hover { border-color: var(--c-accent); color: var(--c-accent); }

.footer {
  max-width: var(--maxw);
  margin: var(--s-6) auto 0;
  padding: var(--s-3) var(--s-3) var(--s-4);
  border-top: 1px solid var(--c-border);
}

.footer-close {
  font-family: var(--f-display);
  font-weight: 540;
  font-size: clamp(1.3rem, 5vw, 1.6rem);
  line-height: 1.25;
  margin: var(--s-1) 0 var(--s-3);
}
.footer-close em { font-style: italic; color: var(--c-accent); }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  align-items: center;
}
.footer-links a, .linklike {
  color: var(--c-muted);
  font-size: 0.85rem;
  text-decoration: none;
  background: none;
  border: none;
  padding: 10px 0;
  min-height: 44px;
  cursor: pointer;
}
.footer-links a:hover, .linklike:hover { color: var(--c-accent); text-decoration: underline; }

.footer-fine { font-size: 0.78rem; color: var(--c-soft); margin: 6px 0 0; }

.noscript {
  max-width: var(--maxw);
  margin: var(--s-3) auto;
  padding: var(--s-2) var(--s-3);
  background: var(--c-danger-soft);
  color: var(--c-danger);
  border-radius: var(--r-md);
}

/* ─── Relapse modal ────────────────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(23, 23, 23, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-3);
  z-index: 50;
}

.modal {
  background: var(--c-card);
  border-radius: var(--r-xl);
  padding: var(--s-3);
  width: min(100%, 420px);
  box-shadow: var(--shadow-md);
}

.modal-heading {
  font-family: var(--f-display);
  font-weight: 540;
  font-size: 1.45rem;
  line-height: 1.2;
  margin: 0 0 var(--s-2);
}

.modal-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--c-muted);
  margin-bottom: 6px;
}

.modal textarea {
  width: 100%;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-family: var(--f-body);
  font-size: 1rem;
  resize: vertical;
  background: var(--c-bg);
  color: var(--c-text);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: var(--s-2);
}
.modal-actions .btn { flex: 1; }

/* ─── Urge protocol (deliberate full-screen focus mode) ────────────────── */

.urge-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #142e24;
  color: #f3efe4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--s-4);
  overflow-y: auto;
}

.urge-close {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(243, 239, 228, 0.08);
  border: none;
  color: rgba(243, 239, 228, 0.7);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.urge-micro {
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(243, 239, 228, 0.55);
  margin: 0 0 var(--s-1);
  max-width: 34ch;
}

.urge-headline {
  font-family: var(--f-display);
  font-style: italic;
  font-size: clamp(1.8rem, 7vw, 2.4rem);
  line-height: 1.15;
  margin: 0 0 var(--s-2);
}

.urge-timer {
  font-family: var(--f-display);
  font-size: clamp(3.4rem, 18vw, 4.6rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  margin: 0;
}

.urge-science {
  font-size: 0.88rem;
  color: rgba(243, 239, 228, 0.6);
  margin: 6px 0 var(--s-3);
}

.urge-steps {
  list-style: none;
  counter-reset: step;
  margin: 0 0 var(--s-3);
  padding: 0;
  width: min(100%, 300px);
  text-align: left;
}
.urge-steps li {
  counter-increment: step;
  padding: 10px 0;
  border-bottom: 1px solid rgba(243, 239, 228, 0.12);
  font-size: 0.98rem;
}
.urge-steps li::before {
  content: counter(step) ". ";
  color: rgba(243, 239, 228, 0.5);
}
.urge-steps li:last-child { border-bottom: none; }

.urge-why {
  font-family: var(--f-display);
  font-style: italic;
  font-size: 1.1rem;
  color: rgba(243, 239, 228, 0.85);
  max-width: 36ch;
  margin: 0 0 var(--s-3);
  min-height: 1em;
}

.btn-leave {
  background: rgba(243, 239, 228, 0.1);
  border: 1px solid rgba(243, 239, 228, 0.25);
  color: #f3efe4;
  border-radius: var(--r-md);
  min-height: 50px;
  padding: 12px 28px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.leave-screen { cursor: pointer; }

.leave-text {
  font-family: var(--f-display);
  font-style: italic;
  font-size: clamp(2rem, 8vw, 2.8rem);
  margin: 0;
}

.leave-sub {
  font-size: 0.85rem;
  color: rgba(243, 239, 228, 0.45);
  margin-top: var(--s-2);
}

/* ─── Wider screens ────────────────────────────────────────────────────── */

@media (min-width: 560px) {
  .more { flex-direction: row; }
  .more-link { flex: 1; }
}

@media (min-width: 900px) {
  :root { --maxw: 520px; }
  .app { padding-top: var(--s-5); }
}

/* ─── Reduced motion ───────────────────────────────────────────────────── */

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