/* ==========================================================================
   Clientbase Media: TikTok Shop Launch Forecaster
   Builds on styles.css tokens. Scenario colours validated (dark surface #17141A):
   lightness band, chroma floor, all-pairs CVD ΔE ≥ 8.7, contrast ≥ 3:1.
   ========================================================================== */

:root {
  --sc-conservative: #C9705A;
  --sc-balanced: #14A89C;
  --sc-aggressive: #9A7BD0;
  --good: #5CC08A;
  --bad: #E07A7A;
}

.page-calc main { padding-top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- intro ---------- */
.fc-hero { position: relative; overflow: hidden; padding: calc(var(--nav-h) + clamp(48px, 7vw, 96px)) 0 clamp(40px, 5vw, 64px); }
.fc-hero__inner { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; text-align: center; }
.fc-title { font-size: clamp(40px, 6.4vw, 88px); line-height: 1; letter-spacing: -0.045em; font-weight: 600; max-width: 16ch; text-wrap: balance; }
.fc-lede { margin-top: 22px; max-width: 58ch; color: var(--text-muted); font-size: clamp(16px, 1.4vw, 19px); }
.fc-hero__tools { margin-top: 32px; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.calc-back { display: none; }
@media (min-width: 640px) { .calc-back { display: inline-flex; } }

.seg { display: inline-flex; padding: 4px; border-radius: 999px; border: 1px solid var(--line-strong); background: rgba(255,255,255,.02); }
.seg__btn { min-height: 36px; padding: 6px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--text-muted); transition: background-color .25s, color .25s; }
.seg__btn[aria-pressed="true"] { background: var(--offwhite); color: #141216; }
.seg__btn:not([aria-pressed="true"]):hover { color: var(--offwhite); }

/* ---------- steps ---------- */
.fc-step { padding-block: clamp(24px, 3vw, 40px); }
.fc-step__head { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.fc-step__head--split { justify-content: space-between; flex-wrap: wrap; gap: 16px 24px; }
.fc-step__head--split > .fc-step__head { margin-bottom: 0; }
.fc-step__num { font-family: var(--font-mono); font-size: 12px; color: var(--lavender); padding: 6px 10px; border-radius: 999px; border: 1px solid rgba(185,167,196,.3); }
.fc-step__lede { margin: -8px 0 24px; max-width: 68ch; color: var(--text-muted); font-size: 16px; }
.fc-step__title {font-size: clamp(24px, 2.6vw, 34px); letter-spacing: -0.03em; font-weight: 600; line-height: 1.1; }

/* strategy cards */
.strategies { display: grid; gap: 12px; }
@media (min-width: 820px) { .strategies { grid-template-columns: repeat(3, 1fr); } }
.strategy {
  position: relative; text-align: left; display: flex; flex-direction: column; gap: 8px;
  padding: 24px; border-radius: var(--radius); min-height: 44px;
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line);
  transition: border-color .3s, transform .4s var(--ease-out), box-shadow .4s var(--ease-out);
}
.strategy:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.strategy[aria-checked="true"] {
  border-color: var(--sc);
  box-shadow: 0 0 0 1px var(--sc), 0 20px 50px -24px var(--sc);
}
.strategy__dot { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; transition: border-color .3s; }
.strategy__dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--sc); transform: scale(0); transition: transform .35s var(--ease-out); }
.strategy[aria-checked="true"] .strategy__dot { border-color: var(--sc); }
.strategy[aria-checked="true"] .strategy__dot::after { transform: scale(1); }
.strategy__name { margin-top: 8px; font-size: 21px; font-weight: 600; letter-spacing: -0.02em; }
.strategy__desc { color: var(--text-muted); font-size: 15px; line-height: 1.5; }
.strategy__meta { margin-top: auto; padding-top: 10px; font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .04em; color: var(--text-dim); }

/* on/off switch styles live in styles.css (shared with the cookie panel) */

/* ---------- input groups ---------- */
.groups { display: grid; gap: 12px; }
.group { border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-2); overflow: hidden; }
.group[hidden] { display: none; }
.group > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 24px; min-height: 44px;
}
.group > summary::-webkit-details-marker { display: none; }
.group__title { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }
.group__hint { font-size: 13px; color: var(--text-dim); margin-left: 10px; font-weight: 400; }
@media (max-width: 560px) { .group__hint { display: block; margin: 4px 0 0; } }
.group__chev { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line-strong); transition: transform .35s var(--ease-out); }
.group[open] .group__chev { transform: rotate(180deg); }
.group__body { padding: 0 24px 8px; }

.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 16px 0; border-top: 1px solid var(--line); }
.field__label { font-size: 15px; font-weight: 500; }
.field__control { display: flex; align-items: center; gap: 10px; }
.field__control .input { flex: 1 1 0; min-width: 0; }
@media (min-width: 760px) {
  .field { grid-template-columns: 1fr minmax(0, 1.1fr); align-items: center; gap: 24px; }
}

.input {
  position: relative; display: flex; align-items: center; flex: 1 1 180px; max-width: 240px;
  height: 46px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-strong);
  transition: border-color .2s, box-shadow .2s;
}
.input:focus-within { border-color: var(--lavender); box-shadow: 0 0 0 3px rgba(185,167,196,.18); }
.input.is-invalid { border-color: var(--bad); }
.input__affix { padding: 0 0 0 14px; color: var(--text-dim); font-size: 15px; font-variant-numeric: tabular-nums; }
.input__affix--end { padding: 0 14px 0 0; }
.input input, .input select {
  flex: 1; min-width: 0; height: 100%; padding: 0 14px; border: 0; background: none; color: var(--offwhite);
  font: inherit; font-size: 16px; font-variant-numeric: tabular-nums; outline: none;
}
.input__affix + input { padding-left: 6px; }
.input select { appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 36px; }
.input select option { background: var(--surface); }
.input--select::after { content: ""; position: absolute; right: 16px; top: 50%; width: 7px; height: 7px; border-right: 1.5px solid var(--text-muted); border-bottom: 1.5px solid var(--text-muted); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.input input::-webkit-outer-spin-button, .input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input input[type=number] { -moz-appearance: textfield; }

.toggle { position: relative; display: inline-flex; min-height: 44px; align-items: center; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.avg {
  font-family: var(--font-mono); font-size: 12px; color: var(--text-muted);
  padding: 6px 10px; border-radius: 8px; border: 1px dashed var(--line-strong); white-space: nowrap;
}
.avg.is-off { color: var(--lavender); border-color: rgba(185,167,196,.4); }
.help {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: var(--text-muted); border: 1px solid var(--line-strong); transition: color .2s, border-color .2s;
  position: relative;
}
.help::before { content: ""; position: absolute; inset: -6px; } /* 44px hit target */
.help:hover, .help[aria-expanded="true"] { color: var(--offwhite); border-color: var(--lavender); }
.field[hidden] { display: none; }
.field--sub { padding-left: 16px; border-left: 2px solid rgba(185,167,196,.35); margin-left: 4px; animation: subIn .4s var(--ease-out) both; }
@keyframes subIn { from { opacity: 0; transform: translateY(-6px); } }
.btn--xs { min-height: 44px; padding: 6px 14px; font-size: 13px; }
.btn--xs[hidden] { display: none; }
.field__tip {grid-column: 1 / -1; font-size: 14px; color: var(--text-muted); background: var(--surface); border-radius: 12px; padding: 12px 14px; border-left: 2px solid var(--lavender); }
.field__tip[hidden] { display: none; }
.field__error { grid-column: 1 / -1; font-size: 13px; color: var(--bad); }
.field__error:empty { display: none; }

.fc-calc-bar { margin-top: 32px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.fc-calc-bar__note { font-size: 13px; color: var(--text-dim); }

/* ---------- results ---------- */
.fc-results { padding: clamp(64px, 8vw, 112px) 0 clamp(64px, 8vw, 96px); margin-top: clamp(40px, 5vw, 72px); border-top: 1px solid var(--line); position: relative; }
.fc-results::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 480px; pointer-events: none; background: radial-gradient(60% 100% at 50% 0%, rgba(91,63,104,.28), transparent 70%); }
.fc-results .container { position: relative; }
.fc-results__head { display: grid; gap: 24px; margin-bottom: 48px; }
@media (min-width: 860px) { .fc-results__head { grid-template-columns: 1fr auto; align-items: end; } }
.fc-results__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.fc-sub { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 16px; }

/* summary cards */
.summary { display: grid; gap: 12px; margin-bottom: 48px; }
@media (min-width: 820px) { .summary { grid-template-columns: repeat(3, 1fr); } }
.sum {
  position: relative; overflow: hidden; padding: 24px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.sum::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--sc); }
.sum.is-selected { border-color: var(--sc); }
.sum__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sum__name { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.sum__name::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--sc); }
.badge { font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; padding: 4px 8px; border-radius: 6px; background: rgba(185,167,196,.14); color: var(--lavender); }
.sum__be { margin-top: 20px; min-height: 108px; }
.sum__label { font-size: 13px; color: var(--text-muted); }
.sum__big { font-size: clamp(30px, 3vw, 40px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sum__none { display: flex; gap: 10px; align-items: flex-start; font-size: 16px; font-weight: 500; color: var(--offwhite); }
.sum__none svg { flex: none; color: var(--bad); margin-top: 3px; }
.sum__req { margin-top: 10px; font-size: 14px; color: var(--text-muted); }
.sum__req b { color: var(--offwhite); font-weight: 600; font-variant-numeric: tabular-nums; }
.sum__grid { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 16px 12px; }
.sum__grid dt { font-size: 12.5px; color: var(--text-muted); }
.sum__grid dd { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.sum__grid small { display: block; font-size: 11.5px; color: var(--text-dim); font-weight: 400; }
.neg { color: var(--bad); }
.pos { color: var(--good); }

/* charts */
.charts { display: grid; gap: 12px; margin-bottom: 48px; }
@media (min-width: 860px) { .charts { grid-template-columns: 1fr 1.3fr; } }
.chart-card { margin: 0; padding: 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.chart-card h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.chart-card figcaption p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.chart { position: relative; margin-top: 20px; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: rgba(227,224,226,.08); }
.chart .zero { stroke: rgba(227,224,226,.35); }
.chart text { fill: var(--text-dim); font-family: var(--font-sans); font-size: 12px; }
.chart .val { fill: var(--offwhite); font-weight: 600; font-size: 13px; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .xhair { stroke: rgba(227,224,226,.3); stroke-dasharray: 3 3; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; font-size: 13px; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; background: var(--c); }
.legend i.sq { width: 10px; height: 10px; border-radius: 3px; }
.legend i.tex { width: 10px; height: 10px; border-radius: 3px; background: repeating-linear-gradient(45deg, var(--text-muted) 0 1.5px, transparent 1.5px 4px); }
.tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 170px;
  padding: 10px 12px; border-radius: 12px; font-size: 13px;
  background: rgba(11,10,13,.94); border: 1px solid var(--line-strong);
  box-shadow: 0 16px 40px -16px rgba(0,0,0,.8);
  opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s;
}
.tip.is-on { opacity: 1; transform: none; }
.tip__title { font-weight: 600; margin-bottom: 6px; }
.tip__row { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.tip__row b { color: var(--offwhite); font-weight: 600; }
.tip__row i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--c); margin-right: 6px; }

/* tables */
.tables__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin-bottom: 16px; }
.tables__head .fc-sub { margin: 0; }
.tabs { display: inline-flex; flex-wrap: wrap; gap: 6px; padding: 4px; border-radius: 999px; border: 1px solid var(--line-strong); }
.tab { min-height: 40px; padding: 6px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--text-muted); display: inline-flex; align-items: center; gap: 8px; transition: background-color .25s, color .25s; }
.tab::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--sc); }
.tab[aria-selected="true"] { background: var(--surface-2); color: var(--offwhite); box-shadow: inset 0 0 0 1px var(--sc); }
.tab:hover { color: var(--offwhite); }
@media (max-width: 560px) {
  .tabs { display: flex; width: 100%; flex-wrap: nowrap; }
  .tab { flex: 1; justify-content: center; padding: 6px 8px; font-size: 13px; gap: 6px; }
}

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); -webkit-overflow-scrolling: touch; }
.ftable { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.ftable th, .ftable td { padding: 11px 16px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.ftable thead th { position: sticky; top: 0; font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: .06em; color: var(--text-muted); background: var(--surface-2); }
.ftable th[scope="row"], .ftable thead th:first-child { text-align: left; position: sticky; left: 0; z-index: 1; background: var(--surface); font-weight: 500; color: var(--soft-grey); }
.ftable thead th:first-child { background: var(--surface-2); z-index: 2; }
.ftable td { font-family: var(--font-mono); font-size: 13px; color: var(--soft-grey); }
.ftable tr.is-total th, .ftable tr.is-total td { color: var(--offwhite); font-weight: 600; }
.ftable tr.is-key th, .ftable tr.is-key td { background: rgba(91,63,104,.18); color: var(--offwhite); font-weight: 600; }
.ftable tr.is-key th[scope="row"] { background: #221C27; }
.ftable tr.sec th { text-align: left; font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--lavender); padding-top: 20px; background: var(--surface); }
.ftable tbody tr:not(.sec):hover th, .ftable tbody tr:not(.sec):hover td { background: rgba(255,255,255,.025); }
.ftable td.neg { color: var(--bad); }

/* final CTA */
.fc-cta {
  margin-top: 56px; display: grid; gap: 24px; align-items: center;
  padding: clamp(28px, 4vw, 48px); border-radius: 28px;
  background: linear-gradient(135deg, #2b2032, #17131a); border: 1px solid rgba(185,167,196,.2);
}
@media (min-width: 860px) { .fc-cta { grid-template-columns: 1fr auto; } }
.fc-cta h3 { font-size: clamp(26px, 3vw, 38px); letter-spacing: -0.03em; font-weight: 600; line-height: 1.1; }
.fc-cta p { margin-top: 10px; color: var(--text-muted); max-width: 52ch; }

/* nudge */
.nudge {
  position: fixed; z-index: 90; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); width: min(320px, calc(100vw - 32px));
  padding: 20px; border-radius: 20px;
  background: rgba(23,20,26,.94); border: 1px solid rgba(185,167,196,.3);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.8);
  animation: nudgeIn .6s var(--ease-out) both;
}
.nudge[hidden] { display: none; }
@keyframes nudgeIn { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.nudge__close { position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; display: grid; place-items: center; color: var(--text-muted); border-radius: 12px; }
.nudge__close:hover { color: var(--offwhite); }
.nudge__title { font-weight: 600; font-size: 16px; padding-right: 32px; }
.nudge__text { margin-top: 6px; font-size: 14px; color: var(--text-muted); }
.nudge .btn { margin-top: 14px; width: 100%; }

.footer--slim { padding-top: 0; }

/* motion initial states */
.motion [data-fade] { opacity: 0; }
.motion.gsap-failed [data-fade] { opacity: 1; }
