/* ============================================================
   COMPONENTS. Aesthetic-neutral: this file reads variables from
   the active theme and has no idea what it looks like. To change
   the look, change theme-*.css, not this.

   One rule specific to this app: meaning is never carried by
   colour alone. Stance and friction are told apart by line style
   and shape, so the whole thing still works in pure black and
   white, which is where the design is headed.
   ============================================================ */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font: var(--body-size) / var(--body-leading) var(--font-body);
  background:
    radial-gradient(60rem 40rem at 0% 0%, var(--field-1), transparent 60%),
    radial-gradient(60rem 40rem at 100% 100%, var(--field-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  padding-bottom: env(safe-area-inset-bottom);
}

button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- masthead ------------------------------------------------- */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: var(--space-3);
  padding: calc(var(--space-3) + env(safe-area-inset-top)) var(--pad) var(--space-3);
  background: var(--masthead-fill);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  color: var(--masthead-ink);
}
.bar h1 {
  flex: 1; margin: 0; min-width: 0;
  font: var(--display-weight) var(--text-lg) / 1.2 var(--font-display);
  letter-spacing: var(--display-track);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar .icon-btn { flex: none; }

.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--space-3) var(--pad) var(--space-7);
  display: grid; gap: var(--gap);
  grid-template-columns: minmax(0, 1fr);   /* grid items default to min-content width; this lets long words shrink */
}

/* ---- surfaces --------------------------------------------------- */
.card {
  padding: var(--card-pad);
  background: var(--surface);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  border: var(--border) solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--specular), var(--shadow-card);
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card h2 {
  margin: 0 0 var(--space-2);
  font: var(--display-weight) var(--text-md) / 1.3 var(--font-display);
  letter-spacing: var(--display-track);
}
.card h3 {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-soft);
}
.muted { color: var(--ink-soft); }
.small { font-size: var(--text-sm); }
.lead { font-size: var(--text-lg); line-height: 1.35; margin: 0 0 var(--space-2); font-weight: var(--title-weight); }

/* ---- controls --------------------------------------------------- */
.btn, .icon-btn {
  appearance: none; cursor: pointer;
  border: var(--border) solid var(--hairline-strong);
  background: var(--surface-strong);
  box-shadow: var(--specular);
  min-height: 44px;                       /* a thumb-sized target */
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.btn { padding: 0 var(--space-5); border-radius: var(--radius-btn); font-weight: 600; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.quiet { background: transparent; box-shadow: none; }
.btn:active, .icon-btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.icon-btn { width: 44px; border-radius: var(--radius-btn); display: grid; place-items: center; padding: 0; font-size: var(--text-lg); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

input[type=text], input[type=email], textarea, select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  min-height: 44px;
  font-size: 1rem;                        /* below 16px and iOS zooms the page on focus */
  background: var(--surface-sunk);
  border: var(--border) solid var(--hairline-strong);
  border-radius: var(--radius-field);
}
textarea { resize: vertical; min-height: 5.5rem; line-height: 1.4; }
label.field { display: grid; gap: var(--space-1); font-size: var(--text-sm); color: var(--ink-soft); }
.row { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 8rem; }
.stack { display: grid; gap: var(--space-3); }

/* three-way stance switch. Position and label say which; colour is not needed. */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: var(--border) solid var(--hairline-strong); border-radius: var(--radius-btn); overflow: hidden; background: var(--surface-sunk); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { display: grid; place-items: center; min-height: 40px; padding: 0 var(--space-2); font-size: var(--text-sm); text-align: center; cursor: pointer; }
.seg input:checked + label { background: var(--ink); color: var(--bg); font-weight: 600; }
.seg input:focus-visible + label { outline: 2px solid var(--ink); outline-offset: -2px; }

/* ---- chips ------------------------------------------------------ */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.chip {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.25em 0.8em; border-radius: var(--radius-chip);
  font-size: var(--text-sm);
  border: var(--border) solid var(--hairline-strong);
  background: var(--surface-sunk);
}
/* stance by line style: solid = like, dashed = dislike, double = dealbreaker */
.chip { max-width: 100%; }
.chip > span:not(.sym) { min-width: 0; overflow-wrap: anywhere; }
.chip.like { border-style: solid; }
.chip.dislike { border-style: dashed; }
.chip.dealbreaker { border-style: double; border-width: 3px; font-weight: 600; }
.chip.shared { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .sym { font-weight: 700; }

/* ---- lists ------------------------------------------------------ */
.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list > li { padding: var(--space-3) 0; border-top: var(--border) solid var(--hairline); }
.list > li:first-child { border-top: 0; }
.person-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-1) var(--space-3); align-items: center; color: inherit; text-decoration: none; min-height: 44px; }
.person-row .name { font-weight: 600; overflow-wrap: anywhere; }
.person-row .score { font-size: var(--text-xl); font-weight: var(--title-weight); font-variant-numeric: tabular-nums; }
.person-row .meta { grid-column: 1 / -1; font-size: var(--text-sm); color: var(--ink-soft); }
.bar-meter { height: 4px; border-radius: 2px; background: var(--hairline); overflow: hidden; grid-column: 1 / -1; }
.bar-meter > i { display: block; height: 100%; background: var(--ink); }

.friction { display: grid; gap: 2px; }
.friction .vs { font-size: var(--text-sm); color: var(--ink-soft); }

/* ---- the map and the venn --------------------------------------- */
.viz { width: 100%; max-width: 34rem; margin: 0 auto; display: block; touch-action: manipulation; }
.map .halo { fill: color-mix(in srgb, var(--ink) 7%, transparent); stroke: var(--ink-faint); stroke-width: 0.006; }
.map .halo.me { fill: color-mix(in srgb, var(--ink) 14%, transparent); stroke: var(--ink); stroke-width: 0.012; }
.map .dot { fill: var(--ink); }
.map .label { fill: var(--ink); font-family: var(--font-body); paint-order: stroke; stroke: var(--bg); stroke-width: 0.025; stroke-linejoin: round; text-anchor: middle; }
.map a { cursor: pointer; }
.map a:focus-visible .halo, .map a:hover .halo { stroke: var(--ink); stroke-width: 0.014; }
.venn .set { fill: color-mix(in srgb, var(--ink) 10%, transparent); stroke: var(--ink); stroke-width: 0.5; }
.venn .set.b { stroke-dasharray: 2 1.2; }
.venn text { fill: var(--ink); font-family: var(--font-body); text-anchor: middle; }
.venn .count { font-size: 9px; font-weight: 650; }
.venn .name { font-size: 4px; }
.venn .sub { font-size: 3px; fill: var(--ink-soft); }

.score-line { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.score-big { font: var(--display-weight) var(--text-2xl) / 1 var(--font-display); font-variant-numeric: tabular-nums; }

/* ---- misc --------------------------------------------------------- */
.notice { padding: var(--space-3) var(--space-4); border-radius: var(--radius-field); border: var(--border) solid var(--hairline-strong); background: var(--surface-sunk); font-size: var(--text-sm); }
.notice.err { border-style: dashed; border-color: var(--ink); }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.12em; font-size: var(--text-lg); font-weight: 650; }
.sub-chip { font-size: var(--text-xs); color: var(--ink-soft); }
.status { font-size: var(--text-xs); color: var(--ink-soft); }
.spin { display: inline-block; width: 0.9em; height: 0.9em; border: 2px solid var(--ink-faint); border-top-color: var(--ink); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -0.1em; }
@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--space-5) + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  max-width: min(90vw, 28rem); padding: var(--space-3) var(--space-5);
  background: var(--ink); color: var(--bg); border-radius: var(--radius-btn); font-size: var(--text-sm);
  opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

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