/* =========================================================================
   The Weight. A KDH scroll experience.
   Style sheet. All classes prefixed kdh- to keep this embeddable later.
   ========================================================================= */

:root {
  --midnight: #1a1f2e;
  --terracotta: #c45d4a;
  --ivory: #fdfcfa;
  --pearl: #f8f7f4;
  --sand: #f0eeea;
  --mist: #e8e6e1;
  --stone: #a8a49d;
  --graphite: #64615b;
  --whisper: #5e5b53;

  /* Live, mutated by script.js as the user scrolls. */
  --kdh-bg: var(--ivory);
  --kdh-fg: var(--midnight);
  --kdh-fg-soft: rgba(26, 31, 46, 0.72);
  --kdh-accent: var(--terracotta);
  --kdh-panel-bg: rgba(253, 252, 250, 0.86);
  --kdh-panel-border: rgba(26, 31, 46, 0.12);

  --kdh-display: 'Amatic SC', 'Lora', Georgia, serif;
  --kdh-serif: 'Lora', Georgia, serif;
  --kdh-script: 'Caveat', 'Lora', cursive;
  --kdh-sans: 'Inter', system-ui, -apple-system, sans-serif;

  --kdh-measure: 32rem;
}

/* Reset, modest. */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body.kdh-body {
  font-family: var(--kdh-sans);
  font-weight: 400;
  font-size: clamp(1.0625rem, 1vw + 0.85rem, 1.25rem);
  line-height: 1.6;
  color: var(--kdh-fg);
  background: var(--kdh-bg);
  transition: background-color 0.6s linear, color 0.6s linear;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a { color: inherit; }

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 4px;
  border-radius: 2px;
}

/* =========================================================================
   Accessibility helpers
   ========================================================================= */

.kdh-visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.kdh-visually-hidden-focusable {
  position: absolute;
  left: 1rem; top: -3rem;
  padding: 0.5rem 1rem;
  background: var(--ivory);
  color: var(--midnight);
  z-index: 100;
  transition: top 0.2s ease;
  font-family: var(--kdh-sans);
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--midnight);
}
.kdh-visually-hidden-focusable:focus { top: 1rem; }

/* =========================================================================
   Persistent UI: flat-toggle, panel
   ========================================================================= */

.kdh-flat-toggle {
  position: fixed;
  top: 1.25rem;
  left: 1.5rem;
  z-index: 30;
  font-family: var(--kdh-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--kdh-fg);
  opacity: 0.55;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  padding-bottom: 1px;
  transition: opacity 0.3s ease;
}
.kdh-flat-toggle:hover { opacity: 1; }

.kdh-audio-toggle {
  position: fixed;
  top: 3rem;
  left: 1.5rem;
  z-index: 35;
  width: 44px;
  height: 44px;
  border-radius: 6px;
  border: 1.5px solid var(--kdh-fg);
  background: transparent;
  color: var(--kdh-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  opacity: 0.85;
  transition: opacity 0.2s ease, color 0.6s linear, border-color 0.6s linear, background-color 0.2s ease;
}
.kdh-audio-toggle:hover {
  opacity: 1;
  background: rgba(26, 31, 46, 0.06);
}
.kdh-audio-toggle svg { width: 20px; height: 20px; }
.kdh-audio-icon-on { display: none; }
.kdh-audio-toggle[aria-pressed="true"] .kdh-audio-icon-off { display: none; }
.kdh-audio-toggle[aria-pressed="true"] .kdh-audio-icon-on  { display: inline-flex; }
body.kdh-flat .kdh-audio-toggle { display: none; }

.kdh-panel {
  position: fixed;
  top: 1.25rem;
  right: 1.5rem;
  z-index: 30;
  width: 16rem;
  min-width: 16rem;
  padding: 0.4rem 0.875rem 0.3rem;
  background: var(--kdh-panel-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--kdh-panel-border);
  border-radius: 4px;
  transition: background-color 0.6s linear, border-color 0.6s linear, color 0.6s linear;
  color: var(--kdh-fg);

  /* Tremor. Driven by --kdh-shake (0..1) set from script.js as the debt
     load grows. Silent at 0, full anxious jitter at 1. */
  --kdh-shake: 0;
  animation: kdh-tremor 0.42s linear infinite;
  will-change: transform;
}

@keyframes kdh-tremor {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(calc(var(--kdh-shake) * -2.6px), calc(var(--kdh-shake) *  1.4px)); }
  40%  { transform: translate(calc(var(--kdh-shake) *  2.8px), calc(var(--kdh-shake) * -1.2px)); }
  60%  { transform: translate(calc(var(--kdh-shake) * -2.0px), calc(var(--kdh-shake) * -2.4px)); }
  80%  { transform: translate(calc(var(--kdh-shake) *  1.8px), calc(var(--kdh-shake) *  2.2px)); }
  100% { transform: translate(0, 0); }
}

.kdh-panel-rows { display: grid; gap: 0.125rem; }
.kdh-panel-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.kdh-panel-label {
  font-family: var(--kdh-sans);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.72;
  line-height: 1;
}
.kdh-label-short { display: none; }
@media (max-width: 760px) {
  .kdh-label-long { display: none; }
  .kdh-label-short { display: inline; }
}

.kdh-panel-value {
  font-family: var(--kdh-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1;
}
.kdh-panel-value.kdh-is-never {
  font-family: var(--kdh-script);
  font-style: normal;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
}

/* Panel state machine. The same fixed surface shows three different
   meanings over the course of the climb. Cross-fade between them. */
.kdh-panel-personal,
.kdh-panel-family,
.kdh-panel-community {
  transition: opacity 600ms ease, transform 600ms ease;
}
/* Family section is retired so the panel never changes height
   mid-story. Personal counters carry through scene 18. */
.kdh-panel-family { display: none !important; }
.kdh-panel-divider {
  height: 1px;
  background: rgba(127, 122, 113, 0.22);
  margin-bottom: 0.5rem;
}
.kdh-panel-row-tight { gap: 0.75rem; }
.kdh-panel-value-sm {
  font-size: 1.125rem;
  letter-spacing: 0;
}
.kdh-panel-community {
  display: grid;
  gap: 0.5rem;
}
/* The hidden HTML attribute is overridden by display:grid above —
   restore it explicitly so the community section actually disappears
   when not in scene 19. Without this, the section keeps taking
   layout space invisibly and pushes the personal counters down. */
.kdh-panel-community[hidden] { display: none; }
.kdh-panel-community-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.0625rem;
}
.kdh-panel-value-lg {
  font-family: var(--kdh-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.kdh-panel-bar {
  margin-top: 0.3rem;
  height: 1.5px;
  width: 100%;
  background: rgba(127, 122, 113, 0.18);
  border-radius: 2px;
  overflow: hidden;
}
.kdh-panel-bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--kdh-accent);
  transition: width 0.2s linear;
}

/* =========================================================================
   Story scenes
   ========================================================================= */

.kdh-story { position: relative; z-index: 1; }

.kdh-scene {
  min-height: 72vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem;
  position: relative;
}
/* Anchor scenes earn their full-viewport weight. */
.kdh-scene-bottom,
.kdh-scene-silence,
.kdh-scene-community,
.kdh-scene-comesback {
  min-height: 90vh;
}

.kdh-scene-inner {
  width: 100%;
  max-width: var(--kdh-measure);
  text-align: left;
  opacity: 1;
  transform: none;
  transition: opacity 0.6s cubic-bezier(0.2, 0.8, 0.2, 1),
              transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Reveal-on-scroll. Once the script flips data-revealed=false on scenes
   that have not yet been seen, the .kdh-scene-inner starts hidden and
   transitions up when the scene crosses the trigger threshold. */
.kdh-scene[data-revealed="false"] .kdh-scene-inner {
  opacity: 0;
  transform: translateY(20px);
}
.kdh-scene[data-revealed="true"] .kdh-scene-inner {
  opacity: 1;
  transform: translateY(0);
}

/* Scene illustrations: line-art SVGs above the headline. Stroke uses
   currentColor so they invert with the page palette. A subtle turbulence
   filter (defined in the sprite) gives the strokes a hand-drawn wobble. */
.kdh-illo {
  display: block;
  width: clamp(110px, 18vw, 200px);
  height: auto;
  margin: 0 0 2rem;
  color: var(--kdh-fg);
  opacity: 0.88;
  transition: color 0.6s linear;
}
.kdh-illo svg, svg.kdh-illo {
  width: 100%;
  height: auto;
  display: block;
}
.kdh-illo-center { margin-left: auto; margin-right: auto; }
.kdh-illo-row {
  display: flex;
  gap: 0.5rem;
  width: clamp(220px, 36vw, 420px);
  align-items: flex-end;
  margin: 0 0 2rem;
  color: var(--kdh-fg);
  opacity: 0.88;
}
.kdh-illo-row > svg { flex: 1; height: auto; min-width: 0; }

.kdh-eyebrow {
  font-family: var(--kdh-sans);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--kdh-accent);
  margin: 0 0 1.75rem;
}

.kdh-scene-headline {
  font-family: var(--kdh-display);
  font-weight: 700;
  font-size: clamp(3.25rem, 6vw + 1rem, 6.5rem);
  line-height: 1.02;
  letter-spacing: 0.015em;
  margin: 0 0 1.5rem;
  color: var(--kdh-fg);
}
.kdh-scene-headline em {
  font-style: normal; /* Amatic SC has no italic; do not fake it. */
}

.kdh-scene-body {
  font-family: var(--kdh-sans);
  font-size: clamp(1.125rem, 0.4vw + 1rem, 1.25rem);
  line-height: 1.6;
  color: var(--kdh-fg);
  opacity: 0.86;
  margin: 0;
  max-width: 28rem;
}

/* Scroll cue on scene 1. */
.kdh-scroll-cue {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  margin-top: 3.5rem;
  font-family: var(--kdh-sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--kdh-fg);
  opacity: 0.55;
}
.kdh-scroll-cue-chevron {
  width: 14px;
  height: 14px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  animation: kdh-cue 1.8s ease-in-out infinite;
}
@keyframes kdh-cue {
  0%, 100% { transform: rotate(45deg) translate(0, 0); opacity: 0.55; }
  50%      { transform: rotate(45deg) translate(2px, 2px); opacity: 1; }
}

/* Scene 5: subtle horizontal statement-page lines. */
.kdh-scene-statement {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0 36px,
    rgba(60, 60, 60, 0.06) 36px 37px
  );
  background-attachment: local;
}

/* Scene 14: the breaking point. */
.kdh-scene-bottom .kdh-scene-inner { text-align: center; }
.kdh-scene-headline-bottom {
  font-family: var(--kdh-display);
  font-weight: 700;
  font-size: clamp(4rem, 11vw + 1rem, 9rem);
  line-height: 1.02;
  letter-spacing: 0.02em;
  color: var(--ivory);
}
.kdh-scene-headline-bottom em {
  font-family: var(--kdh-display);
  font-weight: 700;
  font-style: normal;
}
.kdh-scene-body-bottom {
  font-family: var(--kdh-script);
  font-style: normal;
  font-weight: 500;
  font-size: clamp(1.875rem, 2.2vw + 1rem, 3rem);
  opacity: 0.82;
  margin-top: 1.25rem;
  color: var(--ivory);
  letter-spacing: 0.005em;
}

/* Scene 15: silence. */
.kdh-scene-silence .kdh-scene-inner { text-align: center; }
.kdh-scene-silence-line {
  font-family: var(--kdh-sans);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ivory);
  opacity: 0.7;
  margin: 0;
}

/* Scene 16: divider re-appears for the first time since the descent. */
.kdh-divider {
  display: block;
  width: 56px;
  height: 1px;
  background: var(--kdh-accent);
  margin-top: 3rem;
}

/* Anchor: emphasized line used in scene 21 as a quiet promise. */
.kdh-anchor {
  font-family: var(--kdh-script);
  font-style: normal;
  font-weight: 500;
  font-size: clamp(1.625rem, 1.8vw + 1rem, 2.25rem);
  line-height: 1.3;
  color: var(--kdh-accent);
  margin: 0 0 1.5rem;
  opacity: 1;
  max-width: 32rem;
  letter-spacing: 0.005em;
}

/* Whisper: low-contrast small italic captions, used in scenes 17 and 21. */
.kdh-whisper {
  font-family: var(--kdh-serif);
  font-style: italic;
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--whisper);
  margin-top: 1.25rem;
  max-width: 26rem;
}
.kdh-whisper-footer {
  font-family: var(--kdh-sans);
  font-style: normal;
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
  margin-top: 2rem;
  opacity: 0.85;
}

/* Scene 17 divider: the first terracotta accent since the descent began. */
.kdh-scene #kdh-scene-17 + * {}

/* Scene 18: composite family prose. Wider, breathable paragraph rhythm. */
.kdh-scene-family .kdh-scene-headline { margin-bottom: 2.25rem; }
.kdh-prose {
  display: grid;
  gap: 1.5rem;
  max-width: 32rem;
}
.kdh-prose p {
  font-family: var(--kdh-sans);
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--kdh-fg);
  opacity: 0.9;
  margin: 0;
}

/* Scene 19: community totals. Centered, full-bleed display numerals. */
.kdh-scene-inner-center { text-align: center; max-width: 38rem; }
.kdh-scene-body-center { margin-left: auto; margin-right: auto; }
.kdh-community-figure {
  font-family: var(--kdh-display);
  font-size: clamp(4rem, 9vw, 7.5rem);
  line-height: 1.04;
  font-weight: 700;
  letter-spacing: 0.015em;
  margin: 0;
  color: var(--kdh-fg);
}
.kdh-community-figure + .kdh-community-figure { margin-top: 0.25rem; }
.kdh-community-figure + .kdh-scene-body-center { margin-top: 2.25rem; opacity: 0.78; }

/* Scene 20: what comes back. Word-by-word "scroll-darken" reveal —
   text starts faint and each word turns full-opacity as the scroll
   line passes it. Matches the Apple-style progressive paragraph
   pattern used on collective-kindness-chi.vercel.app. */
.kdh-scene-comesback {
  align-items: center;
}
.kdh-scene-comesback .kdh-scene-inner {
  width: 100%;
  max-width: 38rem;
  text-align: center;
}
.kdh-scene-comesback .kdh-scene-headline {
  margin-bottom: 2.5rem;
}
.kdh-life-block {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin: 0 auto;
}
.kdh-life-block p {
  font-family: var(--kdh-display);
  font-weight: 700;
  font-size: clamp(1.875rem, 2.1vw + 1rem, 2.875rem);
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: var(--kdh-fg);
  margin: 0;
}

/* Scroll-darken: words start faint, brighten word-by-word as the
   scroll line crosses them. The JS adds .is-active to each word in
   turn. */
.kdh-scroll-darken .kdh-word {
  opacity: 0.18;
  transition: opacity 0.4s ease-out;
}
.kdh-scroll-darken .kdh-word.is-active {
  opacity: 1;
}

@media (max-width: 760px) {
  .kdh-life-block { gap: 1.25rem; }
  .kdh-scene-comesback .kdh-scene-headline { margin-bottom: 1.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .kdh-scroll-darken .kdh-word {
    opacity: 1;
    transition: none;
  }
}

/* Scene 21: actions. */
.kdh-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
  margin-top: 2.5rem;
}
.kdh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.95rem 1.5rem;
  font-family: var(--kdh-sans);
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  border-radius: 999px;
  transition: background-color 0.25s ease, color 0.25s ease, transform 0.25s ease;
}
.kdh-btn-primary {
  background: var(--terracotta);
  color: var(--ivory);
}
.kdh-btn-primary:hover {
  background: var(--midnight);
  transform: translateX(2px);
}
.kdh-btn-secondary {
  background: transparent;
  color: var(--midnight);
  border: 1.5px solid var(--midnight);
}
.kdh-btn-secondary:hover {
  background: var(--midnight);
  color: var(--ivory);
}
.kdh-btn-link {
  display: inline-flex;
  align-items: center;
  padding: 0.95rem 0.25rem;
  font-family: var(--kdh-sans);
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--kdh-fg);
  text-decoration: underline;
  text-decoration-color: var(--terracotta);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 5px;
  transition: color 0.25s ease, text-decoration-color 0.25s ease;
}
.kdh-btn-link:hover {
  color: var(--terracotta);
}

.kdh-footnote {
  margin-top: 2.25rem;
  font-family: var(--kdh-sans);
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
  color: var(--kdh-fg);
  opacity: 0.6;
  max-width: 28rem;
  line-height: 1.55;
}

/* =========================================================================
   Site header. In normal flow at the top, scrolls away as the user
   enters the story. Logos rendered B&W via brightness(0). Always sits
   on the ivory top of the page, so a single black render is enough.
   ========================================================================= */
.kdh-header {
  padding: 1.5rem 1.5rem;
  background: var(--ivory);
  position: relative;
  z-index: 25;
}
.kdh-header-inner {
  max-width: 1090px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}
.kdh-header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.kdh-header-icon {
  height: 56px;
  width: auto;
  filter: brightness(0);
  transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.kdh-header-logo:hover .kdh-header-icon { transform: rotate(180deg); }
.kdh-header-wordmark {
  height: 26px;
  width: auto;
  filter: brightness(0);
}

.kdh-header-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.kdh-header-nav a {
  padding: 0.625rem 1rem;
  border-radius: 999px;
  font-family: var(--kdh-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--midnight);
  text-decoration: none;
  transition: background-color 0.25s ease, color 0.25s ease;
}
.kdh-header-nav a:hover { background: rgba(26, 31, 46, 0.08); }
.kdh-header-cta {
  background: var(--midnight);
  color: var(--ivory) !important;
  margin-left: 0.5rem;
  padding: 0.7rem 1.25rem !important;
}
.kdh-header-cta:hover { background: var(--terracotta) !important; }

.kdh-header-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0.5rem;
}
.kdh-header-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--midnight);
  border-radius: 2px;
}

@media (max-width: 860px) {
  .kdh-header { padding: 1rem 1rem; }
  .kdh-header-icon { height: 44px; }
  .kdh-header-wordmark { height: 22px; }
  .kdh-header-toggle { display: inline-flex; }
  .kdh-header-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--ivory);
    border-bottom: 1px solid rgba(26, 31, 46, 0.08);
    flex-direction: column;
    align-items: stretch;
    padding: 1rem 1.25rem;
    gap: 0.25rem;
    z-index: 26;
  }
  .kdh-header-nav.open { display: flex; }
  .kdh-header-nav a { text-align: center; }
  .kdh-header-cta { margin-left: 0; margin-top: 0.5rem; }
}

/* =========================================================================
   Site footer, B&W. Sits at the very end of the page in normal flow.
   ========================================================================= */
.kdh-site-footer {
  background: var(--ivory);
  color: var(--midnight);
  border-top: 1px solid rgba(26, 31, 46, 0.08);
}
.kdh-site-footer-top {
  max-width: 1090px;
  margin: 0 auto;
  padding: 4rem 1.5rem 3rem;
  text-align: center;
}
.kdh-site-footer-logo {
  height: 76px;
  width: auto;
  margin: 0 auto 1.25rem;
  display: block;
  filter: brightness(0);
}
.kdh-site-footer-tag {
  font-family: var(--kdh-sans);
  font-size: 1.0625rem;
  color: var(--midnight);
  margin: 0 auto 2rem;
  max-width: 32rem;
  line-height: 1.55;
}
.kdh-site-footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
}
.kdh-site-footer-links a {
  color: var(--midnight);
  font-family: var(--kdh-sans);
  font-size: 0.875rem;
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: color 0.25s ease;
}
.kdh-site-footer-links a:hover { color: var(--terracotta); }
.kdh-site-footer-bottom {
  border-top: 1px solid rgba(26, 31, 46, 0.08);
  max-width: 1090px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.kdh-site-footer-copy {
  font-family: var(--kdh-sans);
  font-size: 0.8125rem;
  color: var(--midnight);
  opacity: 0.7;
  margin: 0;
}
.kdh-site-footer-top-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--midnight);
  background: transparent;
  color: var(--midnight);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}
.kdh-site-footer-top-btn:hover {
  background: var(--midnight);
  color: var(--ivory);
}
.kdh-site-footer-top-btn svg { width: 16px; height: 16px; }
@media (max-width: 600px) {
  .kdh-site-footer-bottom { justify-content: center; text-align: center; }
  .kdh-site-footer-links { gap: 0.625rem 1.25rem; }
}

/* Flat view hides the chrome too. */
body.kdh-flat .kdh-header,
body.kdh-flat .kdh-site-footer { display: none; }

/* Header gating: the floating counter and the floating audio toggle
   stay hidden while the menu is visible up top. Once the header
   scrolls out of view, both fade in. JS toggles body.kdh-after-header. */
.kdh-panel,
.kdh-audio-toggle {
  opacity: 0;
  pointer-events: none;
  transition: opacity 500ms ease;
}
body.kdh-after-header .kdh-panel { opacity: 1; pointer-events: auto; }
body.kdh-after-header .kdh-audio-toggle { opacity: 0.85; pointer-events: auto; }
body.kdh-after-header .kdh-audio-toggle:hover { opacity: 1; }

/* Audio hint: small curved arrow + label nudging the reader to the
   audio button. Body class kdh-audio-hint-show toggles its visibility;
   the JS adds the class on scenes 1-2 only, then removes it. */
.kdh-audio-hint {
  position: fixed;
  top: 5.75rem;
  left: 4.5rem;
  z-index: 34;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  color: var(--kdh-fg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 700ms ease, color 0.6s linear;
}
body.kdh-audio-hint-show .kdh-audio-hint { opacity: 0.78; }

.kdh-audio-hint-svg {
  width: 60px;
  height: auto;
  animation: kdh-hint-pulse 1.6s ease-in-out infinite;
}
.kdh-audio-hint-label {
  font-family: var(--kdh-script);
  font-size: 1.125rem;
  font-weight: 500;
  margin-top: 2px;
  margin-left: 8px;
  white-space: nowrap;
}

@keyframes kdh-hint-pulse {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-5px, -5px); }
}

@media (max-width: 760px) {
  .kdh-audio-hint {
    top: 5rem;
    left: 0.5rem;
    gap: 0.25rem;
  }
  .kdh-audio-hint-svg {
    width: 48px;
    margin-left: 0.5rem;
  }
  .kdh-audio-hint-label {
    font-size: 0.95rem;
    margin-top: 0.25rem;
    margin-left: 0.5rem;
  }
}

body.kdh-flat .kdh-audio-hint { display: none; }

/* Helping-hands animation for scene 21. Inline SVG with CSS keyframes.
   Lower hand reaches up from lower-left, upper hand reaches down from
   upper-right, they meet, the upper lifts the lower, tiny soft bounce,
   then a quiet return. Loops every 6 seconds. */
.kdh-helping-hands {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
  margin: 0 auto 2rem;
  color: #111827;
}
.kdh-helping-hands path {
  filter: url(#kdh-rough);
  vector-effect: non-scaling-stroke;
}
.kdh-helping-hands-lower {
  animation: kdh-helping-lower 6s ease-in-out infinite;
  will-change: transform;
  transform-origin: 24px 258px;
}
.kdh-helping-hands-upper {
  animation: kdh-helping-upper 6s ease-in-out infinite;
  will-change: transform;
  transform-origin: 396px 22px;
}
@keyframes kdh-helping-lower {
  0%, 100% { transform: translate(0, 0); }
  25%      { transform: translate(4px, -8px); }    /* reaches up */
  50%      { transform: translate(4px, -8px); }    /* contact holds */
  70%      { transform: translate(4px, -22px); }   /* lifted by upper hand */
  78%      { transform: translate(4px, -16px); }   /* tiny bounce settle */
  86%      { transform: translate(4px, -24px); }   /* tiny bounce up */
  94%      { transform: translate(2px, -4px); }    /* quietly returns */
}
@keyframes kdh-helping-upper {
  0%, 100% { transform: translate(0, 0); }
  30%      { transform: translate(-4px, 6px); }    /* reaches down to meet */
  50%      { transform: translate(-4px, 6px); }    /* contact holds */
  70%      { transform: translate(-4px, -12px); }  /* lifts together */
  78%      { transform: translate(-4px, -7px); }   /* tiny bounce settle */
  86%      { transform: translate(-4px, -14px); }  /* tiny bounce up */
  94%      { transform: translate(-2px, 3px); }    /* quietly returns */
}
@media (prefers-reduced-motion: reduce) {
  .kdh-helping-hands-lower,
  .kdh-helping-hands-upper {
    animation: none;
    transform: none;
  }
}

/* =========================================================================
   Mobile
   ========================================================================= */

@media (max-width: 760px) {
  /* Scene layout: align content near the top of the viewport so the
     headline comes into view as soon as the user enters the scene.
     Centering on tall phones leaves a dead zone above the headline. */
  .kdh-scene {
    padding: 4.5rem 1.25rem 3rem;
    align-items: flex-start;
  }
  .kdh-scene-inner { padding-top: 0.25rem; }
  /* Anchor-scene exceptions: the breaking point and silence keep their
     center alignment so the weight lands. */
  .kdh-scene-bottom, .kdh-scene-silence { align-items: center; }
  .kdh-scene-headline { font-size: clamp(2.25rem, 10vw, 3.25rem); line-height: 1.1; }
  .kdh-scene-body { font-size: 1.0625rem; }

  /* Illustrations shrink on phones and free up vertical space. */
  .kdh-illo { width: clamp(96px, 30vw, 160px); margin-bottom: 1.25rem; }
  .kdh-illo-row { width: clamp(220px, 60vw, 320px); }

  /* Audio toggle slots into the panel row on the far left, vertically
     centered with the counter row. */
  .kdh-audio-toggle {
    top: 0.375rem;
    left: 0.4rem;
    width: 28px;
    height: 28px;
    border-radius: 5px;
    border-width: 1.25px;
  }
  .kdh-audio-toggle svg { width: 15px; height: 15px; }

  /* Top bar on mobile sits flush against the very top of the viewport,
     edge-to-edge horizontally. No borders so nothing renders as a
     stray line at the top of the page. */
  .kdh-panel {
    top: 0;
    left: 0;
    right: 0;
    width: auto;       /* override the desktop 16rem cap so it spans full-width */
    min-width: 0;
    padding: 0.35rem 0.625rem 0.35rem 2.4rem;
    border-radius: 0;
    border: 0;
    background: var(--kdh-bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  /* Half-size: tighter rows, smaller fonts, smaller gap. */
  .kdh-panel-rows {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: end;
    gap: 0.5rem;
  }
  .kdh-panel-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.0625rem;
    min-width: 0;
  }
  .kdh-panel-label {
    font-size: 0.625rem;
    letter-spacing: 0.03em;
    line-height: 1.15;
    /* Show full label — allow wrap if needed, no ellipsis truncation. */
    white-space: normal;
    max-width: 100%;
  }
  .kdh-panel-value {
    font-size: 1.625rem;
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  .kdh-panel-bar { margin-top: 0.25rem; height: 1.5px; }

  .kdh-flat-toggle {
    top: auto;
    bottom: 1rem;
    left: 1rem;
    font-size: 0.75rem;
  }

  .kdh-story { padding-top: 0; }
  /* Audio toggle clears the now-shorter top panel. */
  .kdh-audio-toggle { top: 4.5rem; right: 0.75rem; }

  .kdh-scene-headline-bottom { font-size: clamp(2.5rem, 13vw, 4.5rem); }
  .kdh-community-figure { font-size: clamp(2.25rem, 11vw, 3.75rem); }
  .kdh-life-lines li { font-size: clamp(1.25rem, 5.6vw, 1.75rem); }
  .kdh-life-lines { gap: 0.875rem; }
  .kdh-actions { flex-direction: column; align-items: stretch; }
  .kdh-btn { justify-content: center; }
  .kdh-btn-link { justify-content: center; }
}

/* Very narrow phones: iPhone SE class. */
@media (max-width: 380px) {
  .kdh-scene { padding: 4.25rem 1rem; }
  .kdh-illo { width: clamp(80px, 32vw, 130px); margin-bottom: 1rem; }
  .kdh-scene-headline { font-size: clamp(2rem, 11vw, 2.75rem); }
  .kdh-scene-body { font-size: 1rem; }
  .kdh-panel-value { font-size: 1rem; }
  .kdh-panel-label { font-size: 0.5625rem; letter-spacing: 0.04em; }
}

/* =========================================================================
   Flat view: ?flat=1 strips the scroll machinery. Same content,
   readable as a regular article.
   ========================================================================= */

body.kdh-flat {
  background: var(--ivory);
  color: var(--midnight);
}
body.kdh-flat .kdh-panel,
body.kdh-flat .kdh-flat-toggle,
body.kdh-flat .kdh-scroll-cue { display: none; }

body.kdh-flat .kdh-scene {
  min-height: 0;
  padding: 2.5rem 1.5rem;
  border-bottom: 1px solid rgba(26, 31, 46, 0.08);
  background: var(--ivory);
}
body.kdh-flat .kdh-scene:last-of-type { border-bottom: 0; }
body.kdh-flat .kdh-scene-inner {
  opacity: 1;
  transform: none;
  max-width: 38rem;
  margin: 0 auto;
}
body.kdh-flat .kdh-scene-headline,
body.kdh-flat .kdh-scene-body,
body.kdh-flat .kdh-scene-headline-bottom,
body.kdh-flat .kdh-scene-body-bottom,
body.kdh-flat .kdh-scene-silence-line,
body.kdh-flat .kdh-prose p,
body.kdh-flat .kdh-community-figure,
body.kdh-flat .kdh-life-lines li { color: var(--midnight); }
body.kdh-flat .kdh-whisper { color: var(--whisper); }
body.kdh-flat .kdh-scene-headline-bottom em { font-style: italic; }
body.kdh-flat .kdh-scene-bottom,
body.kdh-flat .kdh-scene-silence,
body.kdh-flat .kdh-scene-surface,
body.kdh-flat .kdh-scene-community,
body.kdh-flat .kdh-scene-comesback { background: var(--ivory); }
body.kdh-flat .kdh-scene-bottom .kdh-scene-headline-bottom { font-size: clamp(2.25rem, 5vw, 3.5rem); }
body.kdh-flat .kdh-divider { background: var(--terracotta); }
body.kdh-flat .kdh-community-figure { font-size: clamp(2.25rem, 5vw, 3.5rem); }
body.kdh-flat .kdh-footer { color: var(--midnight); opacity: 0.6; }

/* =========================================================================
   prefers-reduced-motion: no transitions, no fades, no animated counters,
   no smooth background crossfade. The page still works.
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  html { scroll-behavior: auto; }
  .kdh-scene[data-revealed="false"] .kdh-scene-inner,
  .kdh-scene[data-revealed="true"] .kdh-scene-inner {
    opacity: 1;
    transform: none;
  }
  .kdh-scroll-cue-chevron { animation: none; }
  .kdh-panel { animation: none; transform: none; }
}
