/* Kindbody — soft + calm. Feels safe at 2am. */

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/nunito-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/nunito-latin-700-normal.woff2') format('woff2');
}

:root {
  --bg: #fbf6f3;
  --surface: #fffdfb;
  --ink: #36324a;
  --ink-soft: #6b6580;
  --line: #ecdfd8;
  --accent: #4f8780;
  --accent-ink: #ffffff;
  --lilac: #8c86c8;
  --mark: #d9d5f2;
  --flash: #f2e6b8;
  --tint-sea: #e3f0ec;
  --tint-lilac: #ebe8f7;
  --tint-peach: #fbe9df;
  --tint-sky: #e4eef7;
  --exit: #b05468;
  --exit-ink: #ffffff;
  --radius-card: 16px;
  --radius-panel: 22px;
  --gutter: 16px;
  --measure: 46rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111a2c;
    --surface: #18233a;
    --ink: #e8e5f1;
    --ink-soft: #aaa6c2;
    --line: #273452;
    --accent: #8fcfc3;
    --accent-ink: #0f1a2a;
    --lilac: #aaa5ee;
    --mark: #3a3f72;
    --flash: #4a4670;
    --tint-sea: #16303a;
    --tint-lilac: #222649;
    --tint-peach: #2d2939;
    --tint-sky: #182a45;
    --exit: #e2899b;
    --exit-ink: #1b1424;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Nunito', ui-rounded, 'Segoe UI', system-ui, sans-serif;
  font-size: 1.125rem;
  line-height: 1.65;
  padding-bottom: 6rem; /* room for the quick exit button */
}

a { color: var(--accent); text-underline-offset: 0.2em; }

:focus-visible {
  outline: 3px solid var(--lilac);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Top bar ---------- */
.top, main, footer {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.top { padding-top: 1.25rem; }

.top-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand::before {
  content: '';
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-right: 0.45em;
  border-radius: 50%;
  background: var(--lilac);
  box-shadow: 0.22em -0.12em 0 0 var(--bg) inset; /* a small crescent */
  vertical-align: 0.02em;
}

nav { display: flex; gap: 1.1rem; flex-wrap: wrap; font-size: 1rem; }
nav a { color: var(--ink-soft); text-decoration: none; }
nav a:hover { color: var(--ink); text-decoration: underline; }

/* ---------- Picker ---------- */
#kb-picker { margin-top: 1rem; }
#kb-picker:empty { display: none; }

.kb-panel > summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.1rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  padding: 0.7rem 1.1rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
  cursor: pointer;
}
.kb-summary-choice { color: var(--ink); font-weight: 600; }
.kb-summary-choice::after { content: ' ▾'; color: var(--ink-soft); }
.kb-panel[open] .kb-summary-choice::after { content: ' ▴'; }
.kb-panel[open] > summary { margin-bottom: 0.5rem; }
@media (min-width: 40rem) {
  .kb-panel > summary { display: none; }
}

.kb-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 1.75rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  padding: 0.9rem 1.1rem 0.8rem;
}

.kb-group, .kb-grammar {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.kb-group legend, .kb-grammar legend {
  font-size: 0.85rem;
  color: var(--ink-soft);
  padding: 0;
  margin-bottom: 0.35rem;
}

.kb-pills { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.kb-pill {
  font: inherit;
  font-size: 0.98rem;
  line-height: 1;
  min-height: 2.5rem;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}
.kb-pill:hover { border-color: var(--accent); }
.kb-pill[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.kb-hint {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--ink-soft);
}

.kb-remember {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.1rem 1rem;
  border-top: 1px solid var(--line);
  padding-top: 0.6rem;
}
.kb-remember .kb-hint { margin: 0; }
.kb-remember label {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.98rem;
  cursor: pointer;
  min-height: 2.5rem;
  position: relative;
}
.kb-remember input {
  position: absolute;
  opacity: 0;
  width: 2.6rem;
  height: 1.5rem;
  margin: 0;
  cursor: pointer;
}
.kb-switch {
  flex: none;
  width: 2.6rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  transition: background-color 160ms ease;
}
.kb-switch::after {
  content: '';
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: var(--ink-soft);
  transition: transform 160ms ease, background-color 160ms ease;
}
.kb-remember input:checked + .kb-switch { background: var(--accent); }
.kb-remember input:checked + .kb-switch::after { transform: translateX(1.1rem); background: var(--accent-ink); }
.kb-remember input:focus-visible + .kb-switch { outline: 3px solid var(--lilac); outline-offset: 2px; }

/* Custom pronoun form */
.kb-custom {
  margin-top: 0.6rem;
  background: var(--tint-lilac);
  border-radius: var(--radius-panel);
  padding: 1rem 1.1rem 1.1rem;
}
.kb-custom[hidden] { display: none; }
.kb-custom-intro { margin: 0 0 0.75rem; font-size: 0.95rem; }
.kb-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 0.6rem 0.8rem;
}
.kb-field { display: flex; flex-direction: column; gap: 0.2rem; }
.kb-field label { font-size: 0.85rem; color: var(--ink-soft); }
.kb-field input {
  font: inherit;
  font-size: 1rem;
  padding: 0.45rem 0.7rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  min-width: 0;
}
.kb-field input::placeholder { color: var(--ink-soft); opacity: 0.7; }
.kb-grammar { margin-top: 0.85rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1.1rem; }
.kb-grammar legend { float: left; margin: 0 0.4rem 0 0; }
.kb-radio { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.98rem; cursor: pointer; }
.kb-radio input { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; margin: 0; }

/* ---------- Quick exit ---------- */
#kb-exit {
  position: fixed;
  right: var(--gutter);
  bottom: var(--gutter);
  z-index: 10;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  min-height: 3rem;
  padding: 0.7rem 1.3rem;
  border: 0;
  border-radius: 999px;
  background: var(--exit);
  color: var(--exit-ink);
  cursor: pointer;
  box-shadow: 0 6px 18px -8px var(--exit);
  text-align: center;
  text-decoration: none;
}
#kb-exit:hover { filter: brightness(1.06); }
@media (hover: hover) and (min-width: 40rem) {
  #kb-exit::after {
    content: 'Esc';
    margin-left: 0.6rem;
    padding: 0.1rem 0.45rem;
    border-radius: 6px;
    font-weight: 400;
    font-size: 0.8rem;
    border: 1px solid currentColor;
    opacity: 0.8;
  }
}

/* ---------- Content ---------- */
main { padding-top: 2.5rem; }

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h3 { font-size: 1.2rem; font-weight: 700; margin: 1.75rem 0 0.4rem; }

/* Words that follow the reader's choices */
[data-t] {
  border-radius: 4px;
  transition: background-color 900ms ease;
}
.kb-changed { animation: kb-flash 1400ms ease-out; }
@keyframes kb-flash {
  0% { background-color: var(--flash); }
  100% { background-color: transparent; }
}

/* Home */
.hero { margin-bottom: 2.75rem; }
.hero h1 {
  font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.6rem);
  line-height: 1.25;
  font-weight: 700;
  margin: 0 0 0.75rem;
  max-width: 18em;
  text-wrap: balance;
}
.sample {
  margin: 0;
  color: var(--ink-soft);
  max-width: 34em;
}
.sample [data-t] {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--mark);
  text-decoration-thickness: 0.18em;
  text-underline-offset: 0.15em;
  text-decoration-skip-ink: none;
}

.topics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.9rem;
}
.topic {
  display: block;
  padding: 1.15rem 1.25rem 1.2rem;
  border-radius: var(--radius-card);
  color: var(--ink);
  text-decoration: none;
  border: 1px solid transparent;
  transition: border-color 160ms ease;
}
.topic:hover { border-color: var(--accent); }
.topic h2 { font-size: 1.2rem; margin: 0 0 0.3rem; }
.topic p { margin: 0; font-size: 1rem; line-height: 1.5; color: var(--ink-soft); }
.topic-anatomy { background: var(--tint-sea); }
.topic-periods { background: var(--tint-peach); }
.topic-sexual { background: var(--tint-lilac); }
.topic-questions { background: var(--tint-sky); }
.topic-queer { background: var(--tint-sky); }
.topic-trans { background: var(--tint-peach); }
.topic-intersex { background: var(--tint-sea); }
.topic-about { background: var(--tint-lilac); }
.topic-doctor, .topic-help {
  grid-column: 1 / -1;
  background: var(--surface);
  border-color: var(--line);
  border-left: 6px solid var(--accent);
}
.topic-help { border-left-color: var(--lilac); }

/* Quick questions */
#kb-search {
  display: block;
  width: 100%;
  font: inherit;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
#kb-search::placeholder { color: var(--ink-soft); }
#kb-search-empty { margin: 1rem 0 0; color: var(--ink-soft); }
.qa-group[hidden], .qa[hidden] { display: none; }
.qa {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 0.5rem 1.1rem;
  margin: 0.5rem 0;
}
.qa summary { cursor: pointer; font-weight: 700; padding: 0.25rem 0; }
.qa p { margin: 0.4rem 0 0.6rem; }

/* Get help */
.services { padding-left: 1.2rem; }
.services li { margin: 0.55rem 0; }
.services .place { font-weight: 700; }

/* Sources (footnotes) */
.sources-note { font-size: 0.95rem; color: var(--ink-soft); margin-bottom: 0.4rem; }
.sources { font-size: 0.95rem; color: var(--ink-soft); padding-left: 1.4rem; }
.sources .tag {
  font-size: 0.8rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: var(--tint-peach);
  color: var(--ink);
}

/* ---------- Footer ---------- */
footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.95rem;
}

@media (max-width: 30rem) {
  .kb-bar { gap: 0.8rem 1.2rem; padding: 0.8rem 0.9rem; }
  main { padding-top: 1.75rem; }
}

/* Phone: the menu is one row to swipe, running off the edge so it's clear there's more. */
@media (max-width: 40rem) {
  .top { padding-top: 0.9rem; }
  .top-row { gap: 0.35rem; }
  nav {
    flex-basis: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-inline: calc(-1 * var(--gutter));
    padding-inline: var(--gutter);
    max-width: 100vw;
  }
  nav::-webkit-scrollbar { display: none; }
  nav a { flex: none; padding-block: 0.55rem; }
  #kb-picker { margin-top: 0.35rem; }
}

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

/* ---------- What a paragraph was checked against ---------- */
.v-line {
  margin: -0.35rem 0 1rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}
.v-line a { color: inherit; }
li > .v-line, details > .v-line { margin: 0.2rem 0 0.4rem; }

/* ---------- Diagrams (hidden until asked for) ---------- */
.diagram {
  margin: 1rem 0 1.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 0.6rem 1rem;
}
.diagram summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
  padding: 0.4rem 0;
}
.diagram svg {
  display: block;
  width: 100%;
  max-width: 34rem;
  height: auto;
  margin: 0.5rem auto 0.75rem;
  color: var(--ink);
}
.kb-d-line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kb-d-fill-outer { fill: var(--tint-peach); }
.kb-d-fill-inner { fill: var(--tint-lilac); }
.kb-d-lead { fill: none; stroke: var(--ink-soft); stroke-width: 1; }
.kb-d-label { fill: currentColor; font-family: inherit; font-size: 15px; }
.kb-d-small { fill: var(--ink-soft); font-size: 13px; }
