/* Kindred — warm, playful, self-contained (no external fonts/libs).
   Palette: cream surface, ink text, validated diverging pair
   violet #6E56CF (pole A) <-> terracotta #C4643B (pole B). */

:root {
  --cream: #FAF7F2;
  --card: #FFFFFF;
  --ink: #26221E;
  --muted: #6B645C;
  --hairline: #E4DDD3;
  --violet: #6E56CF;
  --violet-soft: #EFEBFA;
  --terra: #C4643B;
  --terra-soft: #F8ECE5;
  --mid: #EFEAE3;
  --good: #3E7A46;
  --radius: 16px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 680px; margin: 0 auto; padding: 20px 18px 90px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 4px 18px;
}
.wordmark {
  font-family: var(--serif); font-size: 1.35rem; font-weight: 700;
  letter-spacing: -0.01em; cursor: pointer; user-select: none;
}
.wordmark .tilde { color: var(--terra); }
.topnav { display: flex; gap: 14px; align-items: center; }
.topnav a { color: var(--muted); text-decoration: none; font-size: .9rem; cursor: pointer; }
.topnav a:hover { color: var(--ink); }

h1 { font-family: var(--serif); font-size: 2.1rem; line-height: 1.15; letter-spacing: -0.02em; }
h2 { font-family: var(--serif); font-size: 1.4rem; margin-bottom: .5rem; letter-spacing: -0.01em; }
h3 { font-size: 1.02rem; }
p.lede { color: var(--muted); font-size: 1.06rem; margin: 12px 0 20px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
strong { font-weight: 650; }

.card {
  background: var(--card); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 20px; margin: 14px 0;
}
.card.tinted-a { background: var(--violet-soft); border-color: transparent; }
.card.tinted-b { background: var(--terra-soft); border-color: transparent; }

.btn {
  display: inline-block; border: none; cursor: pointer; user-select: none;
  background: var(--ink); color: var(--cream);
  font-size: 1rem; font-weight: 600; font-family: var(--sans);
  padding: 13px 26px; border-radius: 100px;
  transition: transform .08s ease, opacity .15s;
}
.btn:hover { opacity: .9; }
.btn:active { transform: scale(.97); }
.btn.secondary { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.btn.quiet { background: transparent; color: var(--muted); border: 1px solid var(--hairline); font-weight: 500; }
.btn.terra { background: var(--terra); }
.btn:disabled { opacity: .35; cursor: default; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

input[type=text] {
  width: 100%; font-size: 1.05rem; font-family: var(--sans);
  padding: 13px 16px; border: 1.5px solid var(--hairline); border-radius: 12px;
  background: var(--card); color: var(--ink); outline: none;
}
input[type=text]:focus { border-color: var(--ink); }

/* ---------------- mode picker ---------------- */
.mode-row { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.mode-chip {
  flex: 1 1 30%; min-width: 150px; text-align: left; cursor: pointer;
  border: 1.5px solid var(--hairline); border-radius: 12px; padding: 12px 14px;
  background: var(--card); transition: border-color .12s;
}
.mode-chip.active { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.mode-chip .m-name { font-weight: 650; }
.mode-chip .m-sub { color: var(--muted); font-size: .82rem; }

/* ---------------- reflect flow ---------------- */
.progress-track {
  height: 5px; background: var(--hairline); border-radius: 3px;
  margin: 6px 0 26px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--terra); border-radius: 3px;
  transition: width .25s ease;
}
.reflect-stage { min-height: 380px; display: flex; flex-direction: column; justify-content: center; }
.stmt-text {
  font-family: var(--serif); font-size: 1.45rem; line-height: 1.35;
  margin: 8px 0 30px; letter-spacing: -0.01em;
  animation: cardIn .28s ease;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.dot-scale { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin: 4px 0 8px; }
.dot {
  flex: 1; aspect-ratio: 1; max-width: 64px; border-radius: 50%;
  border: 2px solid var(--hairline); background: var(--card); cursor: pointer;
  transition: transform .1s, border-color .1s, background .1s;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; color: transparent;
}
.dot:hover { transform: scale(1.12); border-color: var(--ink); }
.dot.d1, .dot.d2 { border-color: #D9CBF3; }
.dot.d4, .dot.d5 { border-color: #EFD3C4; }
.dot.d1:hover, .dot.d2:hover { background: var(--violet-soft); border-color: var(--violet); }
.dot.d4:hover, .dot.d5:hover { background: var(--terra-soft); border-color: var(--terra); }
.dot.chosen { transform: scale(1.15); }
.scale-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; margin-bottom: 18px; }
.skip-row { text-align: center; margin-top: 18px; }
.skip-link { color: var(--muted); font-size: .85rem; background: none; border: none; cursor: pointer; text-decoration: underline; }

.img-frame {
  border-radius: var(--radius); overflow: hidden; margin: 4px 0 18px;
  aspect-ratio: 4 / 3; background: var(--mid); position: relative;
}
.img-frame img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  animation: kenburns 6s ease-out forwards;
}
@keyframes kenburns { from { transform: scale(1.06); } to { transform: scale(1.0); } }
.img-dots .dot { max-width: 48px; }
.img-caption {
  text-align: center; color: var(--muted); font-size: .86rem;
  margin: -8px 0 12px; font-style: italic;
}

.interstitial { text-align: center; }
.interstitial .big {
  font-family: var(--serif); font-size: 1.6rem; margin: 16px 0; line-height: 1.3;
}

/* ---------------- result ---------------- */
.hex-wrap { display: flex; flex-direction: column; align-items: center; }
.hex-svg { width: 100%; max-width: 430px; height: auto; }
.axis-label { font-size: 11.5px; fill: var(--ink); font-weight: 600; font-family: var(--sans); }
.axis-sublabel { font-size: 9.5px; fill: var(--muted); font-family: var(--sans); }
.legend-row { display: flex; gap: 16px; justify-content: center; margin: 8px 0 4px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); cursor: pointer; user-select: none; }
.legend-swatch { width: 18px; height: 4px; border-radius: 2px; }
.legend-item.off { opacity: .35; }
.signature {
  font-family: var(--serif); font-size: 1.18rem; line-height: 1.45;
  text-align: center; margin: 14px auto 6px; max-width: 480px;
}
.axis-rows { margin-top: 20px; }
.axis-row {
  display: grid; grid-template-columns: 86px 1fr 86px 14px; gap: 10px; align-items: center;
  padding: 11px 6px; border-bottom: 1px solid var(--hairline); cursor: pointer;
}
.axis-mid { display: flex; flex-direction: column; gap: 5px; }
.wvg-pill {
  align-self: center; font-size: .66rem; font-weight: 650; color: var(--terra);
  background: var(--terra-soft); border-radius: 100px; padding: 1px 9px;
}
.axis-chevron {
  color: var(--muted); font-size: 1.1rem; line-height: 1;
  transition: transform .15s; user-select: none;
}
.axis-chevron.open { transform: rotate(90deg); }
.axis-row:hover { background: rgba(0,0,0,.02); }
.axis-pole { font-size: .8rem; color: var(--muted); }
.axis-pole.right { text-align: right; }
.axis-pole.dominant { color: var(--ink); font-weight: 650; }
.axis-track { position: relative; height: 8px; background: var(--mid); border-radius: 4px; }
.axis-center { position: absolute; left: 50%; top: -3px; width: 1.5px; height: 14px; background: var(--hairline); }
.axis-dot {
  position: absolute; top: 50%; width: 16px; height: 16px; border-radius: 50%;
  transform: translate(-50%, -50%); border: 2.5px solid var(--card);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.axis-dot.gut { width: 11px; height: 11px; opacity: .75; }
.mismatch-flag { font-size: .78rem; color: var(--terra); margin-left: 4px; }

.explainer { background: var(--cream); border-radius: 12px; padding: 14px 16px; margin: 8px 0; animation: cardIn .2s ease; }
.consult-card { border-left: 3px solid var(--terra); }
.consult-card.k-mismatch { border-left-color: var(--violet); }
.consult-card.k-question, .consult-card.k-bridge { border-left-color: var(--good); }
.consult-card h3 { margin-bottom: 6px; }
.consult-kicker { text-transform: uppercase; letter-spacing: .08em; font-size: .7rem; color: var(--muted); margin-bottom: 2px; }

/* ---------------- circles ---------------- */
.circle-item { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--hairline); }
.member-status { margin-left: auto; font-size: .85rem; color: var(--muted); }
.member-status .done { color: var(--good); font-weight: 650; }
.invite-box {
  display: flex; gap: 8px; align-items: center; background: var(--cream);
  border-radius: 10px; padding: 10px 12px; margin-top: 10px;
}
.group-code-band {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--terra-soft); border-radius: 12px; padding: 12px 16px; margin-top: 12px;
}
.group-code-label {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
}
.group-code {
  font-family: var(--serif); font-size: 1.7rem; font-weight: 700;
  letter-spacing: .12em; color: var(--ink);
}
.admin-circle-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.invite-box code { font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.toggle-row { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.toggle-chip {
  border: 1.5px solid var(--hairline); background: var(--card); border-radius: 100px;
  padding: 7px 16px; font-size: .85rem; cursor: pointer; color: var(--muted);
}
.toggle-chip.active { border-color: var(--ink); color: var(--ink); font-weight: 600; }

.heatmap { width: 100%; border-collapse: separate; border-spacing: 3px; table-layout: fixed; }
.heatmap th { font-size: .74rem; font-weight: 600; color: var(--muted); padding: 4px 2px; overflow: hidden; text-overflow: ellipsis; }
.heatmap th.rowhead { text-align: left; width: 34%; font-weight: 500; }
.heatmap td {
  height: 44px; border-radius: 8px; text-align: center; font-size: .72rem;
  cursor: default; position: relative; color: var(--ink);
}
.heatmap td.gap-edge { outline: 2px solid var(--ink); outline-offset: -2px; }
.heatmap tr.row-muted td { opacity: .3; }
.heatmap td.paircell { cursor: pointer; }
.heatmap td.paircell:hover { outline: 2px solid var(--ink); outline-offset: -2px; }
.heatmap td.inert { background: var(--mid); opacity: .4; }
.hm-note { font-size: .8rem; color: var(--muted); margin-top: 8px; }
.hm-scale { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: .76rem; color: var(--muted); }
.hm-scale .bar { flex: 1; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, #6E56CF, #EFEAE3 50%, #C4643B); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(38,34,30,.45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--cream); border-radius: 20px 20px 0 0; width: 100%; max-width: 680px;
  max-height: 86vh; overflow-y: auto; padding: 22px 20px 40px;
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-close { float: right; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--muted); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--cream); border-radius: 100px;
  padding: 10px 22px; font-size: .9rem; z-index: 99; animation: cardIn .2s ease;
}

.footer-note { text-align: center; color: var(--muted); font-size: .78rem; margin-top: 40px; }
.footer-note a { color: var(--muted); }

/* ---------------- emoji chips + swipe ---------------- */
.chip-row { display: flex; justify-content: center; gap: 9px; margin: 4px 0 8px; }
.chip {
  min-width: 52px; height: 52px; padding: 0 10px; border-radius: 100px;
  border: 2px solid var(--hairline); background: var(--card); cursor: pointer;
  font-size: 1.35rem; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: transform .1s, border-color .1s, background .1s;
  letter-spacing: -2px;
}
.chip:hover { transform: scale(1.12); border-color: var(--ink); }
.chip.neg:hover { background: var(--violet-soft); border-color: var(--violet); }
.chip.pos:hover { background: var(--terra-soft); border-color: var(--terra); }
.chip.pending { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); transform: scale(1.12); }
.chip.chosen { transform: scale(1.22); border-color: var(--ink); }

.swipe-card {
  position: relative; touch-action: pan-y; user-select: none; cursor: grab;
  will-change: transform;
}
.swipe-card.dragging { cursor: grabbing; }
.swipe-card.dragging .stmt-text, .swipe-card.dragging img { pointer-events: none; }
.swipe-badge {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  background: var(--terra); color: #fff; border-radius: 100px;
  padding: 8px 18px; font-size: 1.05rem; font-weight: 700; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 5;
  box-shadow: 0 3px 10px rgba(0,0,0,.18);
}
.swipe-badge.show { opacity: 1; }
.swipe-badge.neg { background: var(--violet); }

.gesture-hint {
  text-align: center; color: var(--muted); font-size: .8rem; margin-top: 14px;
  animation: cardIn .3s ease;
}

/* ---------------- UX pass additions ---------------- */
.btn-big { font-size: 1.08rem; padding: 15px 32px; }

.depth-details { margin-top: 14px; }
.depth-details summary {
  cursor: pointer; color: var(--muted); font-size: .88rem; user-select: none;
  list-style-position: inside;
}
.depth-details summary:hover { color: var(--ink); }

.invite-banner h2 { margin-bottom: 4px; }

.progress-parts { display: flex; gap: 14px; align-items: flex-end; margin: 4px 0 24px; }
.progress-seg { flex: 1; }
.progress-seg.dim { opacity: .38; }
.progress-label {
  font-size: .68rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 5px;
}
.progress-parts .progress-track { margin: 0; }
.undo-btn {
  border: 1px solid var(--hairline); background: var(--card); color: var(--muted);
  border-radius: 100px; font-size: .78rem; padding: 5px 12px; cursor: pointer;
  white-space: nowrap; align-self: center;
}
.undo-btn:hover { color: var(--ink); border-color: var(--ink); }

.halfway-note {
  text-align: center; color: var(--terra); font-size: .85rem; font-weight: 600;
  margin-bottom: 10px; animation: cardIn .3s ease;
}
.key-hint { text-align: center; color: var(--muted); font-size: .74rem; margin-top: 14px; }

.scale-wrap { transition: opacity .45s ease; }
.scale-wrap.scale-hidden { opacity: 0; pointer-events: none; }

.name-card { border-color: var(--terra); }
.name-row { display: flex; gap: 8px; margin-top: 10px; }
.name-row input { flex: 1; }

/* result reveal: fingerprint draws itself, then the words arrive */
.hex-reveal .series-poly, .hex-reveal .series-dot {
  transform-box: view-box; transform-origin: 50% 52%;
  animation: hexGrow .95s cubic-bezier(.2, .8, .3, 1) .15s both;
}
@keyframes hexGrow {
  from { transform: scale(.05); opacity: 0; }
  60% { opacity: 1; }
  to { transform: scale(1); opacity: 1; }
}
.hex-reveal .legend-row, .hex-reveal .signature, .hex-reveal > p {
  animation: fadeUp .5s ease .85s both;
}
.card-stagger { animation: fadeUp .45s ease both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.share-modal { text-align: center; }
.share-preview {
  width: 100%; max-width: 360px; border: 1px solid var(--hairline);
  border-radius: 12px; margin: 10px auto; display: block;
}
.share-modal .btn-row { justify-content: center; }

/* ---------------- responsive: mobile tightening ---------------- */
@media (max-width: 480px) {
  h1 { font-size: 1.7rem; }
  .stmt-text { font-size: 1.25rem; }
  .axis-row { grid-template-columns: 70px 1fr 70px 12px; }
  .progress-label { font-size: .6rem; }
}

/* ---------------- responsive: desktop layout ---------------- */
@media (min-width: 920px) {
  #app { max-width: 1060px; padding: 24px 32px 90px; }
  h1 { font-size: 2.5rem; }
  p.lede { max-width: 620px; }

  /* result: fingerprint and axis detail side by side */
  .result-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start;
  }
  .result-grid .card { margin: 14px 0 0; }
  .hex-svg { max-width: 500px; }
  .signature { font-size: 1.24rem; }

  /* reflect flow stays a focused column even on wide screens */
  .reflect-stage, .progress-parts { max-width: 640px; margin-left: auto; margin-right: auto; }
  .progress-parts { margin-bottom: 26px; }

  /* consultation cards flow two-up */
  .consult-card { display: inline-block; width: calc(50% - 8px); vertical-align: top; }
  .consult-card + .consult-card { margin-left: 0; }
  div:has(> .consult-card) { display: flex; flex-wrap: wrap; gap: 14px; }
  div:has(> .consult-card) .consult-card { width: calc(50% - 7px); margin: 0; }
  div:has(> .consult-card) h2 { width: 100%; margin-bottom: 0; }

  /* heat map gets room to breathe */
  .heatmap td { height: 52px; font-size: .8rem; }
  .heatmap th { font-size: .8rem; }

  /* modals center on desktop instead of bottom-sheeting */
  .modal-overlay { align-items: center; }
  .modal { border-radius: 20px; max-width: 720px; max-height: 82vh; }
}
