/* Joint Cost — styles
   Looks like a finance calculator, not a cannabis app (PLAN §14.2).
   Mobile-first. Big type, big tap targets, assume the user is stoned (§4.5). */

:root {
  --bg:        #f4f4f1;
  --surface:   #ffffff;
  --ink:       #1a1c1e;
  --muted:     #6a6d70;
  --line:      #e4e4df;
  --accent:    #0f766e;
  --accent-ink:#ffffff;
  --error:     #b42318;
  --warn-ink:  #7c4a03;
  --warn-bg:   #fdf3e3;
  --radius:    14px;
  --shadow:    0 1px 2px rgba(0,0,0,.05), 0 6px 18px rgba(0,0,0,.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #16181a;
    --surface:   #1f2325;
    --ink:       #eceeef;
    --muted:     #9aa0a4;
    --line:      #2e3336;
    --accent:    #2dd4bf;
    --accent-ink:#08201d;
    --error:     #ff7b6b;
    --warn-ink:  #f0c67a;
    --warn-bg:   #2c2513;
    --shadow:    0 1px 2px rgba(0,0,0,.35), 0 6px 18px rgba(0,0,0,.25);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 34rem;
  margin: 0 auto;
  padding: 24px 16px calc(40px + env(safe-area-inset-bottom));
}

/* ───────── Age gate ───────── */

.gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 10;
}
.gate__box { max-width: 22rem; width: 100%; text-align: center; }
.gate__title { font-size: 2rem; letter-spacing: -.02em; margin: 0 0 4px; }
.gate__q { font-size: 1.15rem; color: var(--muted); margin: 0 0 24px; }
.gate__btns { display: grid; gap: 10px; }
.gate__no { margin-top: 20px; color: var(--muted); }

/* ───────── Masthead ───────── */

.masthead { margin-bottom: 22px; }
.masthead__title { font-size: 1.5rem; letter-spacing: -.02em; margin: 0; }
.masthead__sub { margin: 2px 0 0; color: var(--muted); font-size: .95rem; }

/* ───────── Cards ───────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin-bottom: 14px;
}

/* ───────── Questions ───────── */

.q__title {
  font-size: 1.05rem;
  line-height: 1.35;
  margin: 0 0 6px;
  font-weight: 650;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}
.q__title em { font-style: normal; text-decoration: underline; text-underline-offset: 3px; }

.q__num {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: .85rem;
  font-weight: 700;
  display: grid; place-items: center;
}

.q__hint { margin: 0 0 14px; color: var(--muted); font-size: .9rem; }

/* Two sub-questions inside one card (amount, then price). */
.field + .field {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.field__label { margin: 0 0 9px; font-weight: 650; font-size: .95rem; }
.field__label em { font-style: normal; text-decoration: underline; text-underline-offset: 3px; }
.field__hint { margin: 8px 0 0; color: var(--muted); font-size: .85rem; }

/* Live feedback worked out from what they've already typed. */
.derived {
  margin: 10px 0 0;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: .88rem;
  font-weight: 600;
}

.tag {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
}

/* ───────── Entry boxes ───────── */

.entry__field {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 0 14px;
  background: var(--bg);
}
.entry__field:focus-within { border-color: var(--accent); }
.entry__field--inline { flex: 1 1 90px; background: var(--surface); }
.entry__prefix, .entry__suffix { color: var(--muted); font-weight: 600; flex: none; }

.entry__field input {
  flex: 1;
  min-width: 0;
  width: 100%;
  min-height: 54px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  padding: 0;
}
.entry__field input:focus { outline: none; }
.entry__field input::placeholder { font-weight: 500; color: var(--muted); opacity: .5; }
.entry__field--inline input { text-align: center; }

input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* A number box next to its unit picker. */
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.row .entry__field { flex: 1 1 100px; }

/* ───────── Toggle ───────── */

.toggle {
  display: flex;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
}
.toggle__opt {
  min-height: 48px;
  padding: 0 14px;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
  white-space: nowrap;
}
.toggle__opt.is-selected { background: var(--accent); color: var(--accent-ink); }
.toggle--years { margin: 14px 0 12px; }

/* ───────── Messages ───────── */

.msg { margin: 12px 0 0; font-size: .88rem; font-weight: 600; }
.msg--error { color: var(--error); }
.msg--warn {
  color: var(--warn-ink);
  background: var(--warn-bg);
  padding: 9px 11px;
  border-radius: 9px;
  font-weight: 500;
}

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

.btn {
  min-height: 52px;
  padding: 0 20px;
  font: inherit;
  font-weight: 650;
  border-radius: 11px;
  border: 1.5px solid transparent;
  cursor: pointer;
}
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--quiet { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn--skip { min-height: 48px; padding: 0 16px; }
.btn--go { display: block; width: 100%; margin-top: 6px; font-size: 1.05rem; }

.link {
  background: none;
  border: 0;
  padding: 10px 0 0;
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ───────── Result ───────── */

.card--headline { text-align: center; padding: 26px 16px 20px; }
.headline__label { margin: 0; color: var(--muted); font-size: .95rem; }
.headline__figure {
  margin: 4px 0 0;
  font-size: clamp(2.9rem, 15vw, 4.2rem);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.03;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.headline__unit { margin: 2px 0 0; color: var(--muted); font-size: 1.05rem; }
.headline__check {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 1rem;
}

.card--invest { text-align: center; }
.invest__label { margin: 0; color: var(--muted); font-size: .95rem; }
.invest__figure {
  margin: 4px 0 0;
  font-size: clamp(2rem, 10vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.card--invest .toggle { display: inline-flex; }
.invest__note { margin: 0; color: var(--muted); font-size: .85rem; line-height: 1.5; }
.invest__caveat { display: block; margin-top: 6px; }

.stats { list-style: none; margin: 0; padding: 0; }
.stats li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.stats li:last-child { border-bottom: 0; padding-bottom: 0; }
.stats li:first-child { padding-top: 0; }
.stats__label { color: var(--muted); font-size: .95rem; }
.stats__value { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats__note { display: block; font-weight: 400; font-size: .75rem; color: var(--muted); text-align: right; }

/* ───────── Share card ───────── */

.share { text-align: center; }
.share__label { margin: 0 0 14px; color: var(--muted); font-size: .95rem; }

.share__preview {
  display: block;
  width: 100%;
  max-width: 240px;
  height: auto;
  aspect-ratio: 1 / 1;
  margin: 0 auto 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.share__fallback { display: grid; gap: 10px; }
.share__fallback .btn { width: 100%; }

.share__note { margin: 12px 0 0; color: var(--muted); font-size: .8rem; }

/* ───────── Working ───────── */

.working { padding: 0; }
.working__summary {
  padding: 16px;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}
.working__summary::-webkit-details-marker { display: none; }
.working__summary::after { content: " ▾"; color: var(--muted); }
.working[open] .working__summary::after { content: " ▴"; }
.working__body { padding: 0 16px 16px; }

.sum {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  font-size: .92rem;
}
.sum__calc { color: var(--muted); }
.sum__result { font-weight: 650; white-space: nowrap; }
.working__note { margin: 12px 0 0; font-size: .8rem; color: var(--muted); }

/* ───────── Footer ───────── */

.footer {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.55;
}
.footer p { margin: 0 0 6px; }
.footer__small { opacity: .8; }

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