/* "Meet the family" section on the homepage: the five LittleNest characters around a sleeping baby. */
.family {
  position: relative;
  overflow: hidden;
  padding-bottom: clamp(3.5rem, 7vw, 6.5rem);
  --nest-straw: #E4C690;
  --nest-straw-deep: #C79F62;
  --nest-lip: #F0DBB0;
  --nest-inner: #B98F55;
}
.family::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 50% at 50% 62%, color-mix(in srgb, var(--warm) 16%, transparent), transparent 70%),
    radial-gradient(40% 35% at 14% 20%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    radial-gradient(36% 32% at 88% 30%, color-mix(in srgb, var(--sage) 14%, transparent), transparent 70%);
  pointer-events: none;
}
.family > .container { position: relative; }
.family .section-heading { margin-bottom: clamp(1.5rem, 3vw, 2.5rem); }

/* Tiny stars and hearts drifting in the background */
.family-sparks { position: absolute; inset: 0; pointer-events: none; }
.family-sparks i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s, 10px);
  height: var(--s, 10px);
  border-radius: 999px;
  background: var(--c, var(--warm));
  opacity: 0.35;
  animation: spark-drift 9s ease-in-out infinite;
  animation-delay: var(--d, 0s);
}
@keyframes spark-drift {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.25; }
  50%      { transform: translateY(-14px) scale(1.25); opacity: 0.55; }
}

/* ── Stage ── */
.family-stage {
  --u: clamp(56px, 15.2vw, 205px);
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: calc(var(--u) * 0.08);
  /* room above the figures for the speech bubbles */
  padding-top: calc(var(--u) * 0.55);
  padding-bottom: calc(var(--u) * 0.42);
  margin: 0 auto;
  max-width: 1000px;
  user-select: none;
  -webkit-user-select: none;
}
.family-stage::after {
  /* the floor the whole family stands on */
  content: "";
  position: absolute;
  left: 4%; right: 4%;
  bottom: calc(var(--u) * 0.34);
  height: calc(var(--u) * 0.22);
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--ink) 14%, transparent), transparent);
  filter: blur(6px);
  z-index: 0;
}

.fig {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: calc(var(--u) * var(--w));
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  rotate: var(--lean, 0deg);
  transform-origin: 50% 100%;
  transition: rotate 0.5s cubic-bezier(0.3, 1.4, 0.5, 1), translate 0.5s cubic-bezier(0.3, 1.4, 0.5, 1);
  translate: 0 var(--lift, 0);
}
.fig:hover { rotate: calc(var(--lean, 0deg) * 0.35); translate: 0 calc(var(--lift, 0px) - 6px); }
.fig:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 6px; border-radius: 28px; }

.fig-body {
  display: block;
  transform-origin: 50% 100%;
  animation: fam-breathe 4.8s ease-in-out infinite;
  animation-delay: var(--breath, 0s);
  will-change: transform;
}
.fig-body img {
  width: 100%;
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 calc(var(--u) * 0.05) calc(var(--u) * 0.07) color-mix(in srgb, var(--ink) 16%, transparent));
}
@keyframes fam-breathe {
  0%, 100% { transform: scale(1, 1); }
  50%      { transform: scale(1.022, 0.972); }
}

/* Squash-and-hop when poked or when it is their turn to speak */
.fig.hop .fig-body { animation: fam-hop 0.7s cubic-bezier(0.3, 0.7, 0.3, 1) both; }
@keyframes fam-hop {
  0%   { transform: scale(1, 1); }
  18%  { transform: scale(1.1, 0.88); }
  45%  { transform: translateY(-14%) scale(0.95, 1.07); }
  72%  { transform: translateY(0) scale(1.07, 0.93); }
  100% { transform: scale(1, 1); }
}

.fig-name {
  position: absolute;
  left: 50%;
  bottom: calc(var(--u) * -0.3);
  translate: -50% 0;
  padding: 0.28rem 0.8rem;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: clamp(0.7rem, 1.6vw, 0.85rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  white-space: nowrap;
  transition: color 0.3s, background 0.3s, border-color 0.3s;
}
.fig.is-on .fig-name,
.fig:hover .fig-name { color: var(--ink); border-color: color-mix(in srgb, var(--warm) 55%, transparent); }

/* Speech bubbles */
.fig-say {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  width: max-content;
  max-width: clamp(7.5rem, 24vw, 12.5rem);
  padding: 0.55rem 0.8rem;
  border-radius: 18px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: clamp(0.72rem, 1.7vw, 0.95rem);
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px) scale(0.85);
  transform-origin: 50% 100%;
  transition: opacity 0.25s ease, transform 0.45s cubic-bezier(0.3, 1.5, 0.5, 1);
  z-index: 4;
}
.fig-say::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 12px; height: 12px;
  background: inherit;
  border: inherit;
  border-top: 0; border-left: 0;
  border-radius: 0 0 4px 0;
  transform: translateX(-50%) rotate(45deg);
}
.fig.is-on .fig-say { opacity: 1; transform: translate(-50%, 0) scale(1); }
/* keep outer bubbles on screen */
.fig[data-who="grandma"] .fig-say { left: 30%; }
.fig[data-who="grandpa"] .fig-say { left: 70%; }
.fig[data-who="grandma"] .fig-say::after { left: 70%; }
.fig[data-who="grandpa"] .fig-say::after { left: 30%; }

/* The characters: size, lean toward the baby, depth */
.fig[data-who="grandma"] { --w: 0.93; --lean: 6deg; --lift: -2%; --breath: -0.6s; }
.fig[data-who="mom"]     { --w: 0.93; --lean: 5deg; --breath: -1.9s; }
.fig[data-who="baby"]    { --w: 0.78; --lean: 0deg; --breath: -3.2s; margin: 0 calc(var(--u) * 0.08); z-index: 2; }
.fig[data-who="dad"]     { --w: 0.84; --lean: -5deg; --breath: -2.6s; }
.fig[data-who="grandpa"] { --w: 0.98; --lean: -6deg; --lift: -2%; --breath: -1.2s; }

/* The nest: a back rim behind the baby and the woven front lip over her lower half */
.fig[data-who="baby"] .fig-body { padding-bottom: 0; }
.nest {
  position: absolute;
  left: -16%;
  width: 132%;
  height: auto;
  pointer-events: none;
  overflow: visible;
}
.nest-back  { bottom: -12%; z-index: -1; }
.nest-front { bottom: -12%; z-index: 3; }

/* Zzz */
.zzz {
  position: absolute;
  right: 14%;
  top: -6%;
  z-index: 5;
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  color: var(--accent-strong);
  pointer-events: none;
}
.zzz span {
  position: absolute;
  left: 0; top: 0;
  font-size: calc(var(--u) * 0.2);
  opacity: 0;
  animation: fam-zzz 4.2s ease-in-out infinite;
  animation-delay: var(--zd);
}
.zzz span:nth-child(2) { font-size: calc(var(--u) * 0.26); }
.zzz span:nth-child(3) { font-size: calc(var(--u) * 0.32); }
@keyframes fam-zzz {
  0%   { opacity: 0; transform: translate(0, 10px) rotate(-6deg); }
  20%  { opacity: 0.9; }
  80%  { opacity: 0.5; }
  100% { opacity: 0; transform: translate(calc(var(--u) * 0.08), calc(var(--u) * -0.45)) rotate(10deg); }
}

/* Hearts that float from whoever was poked */
.heart {
  position: absolute;
  left: var(--hx);
  top: var(--hy);
  width: var(--hs, 20px);
  height: var(--hs, 20px);
  color: var(--hc, var(--warm));
  pointer-events: none;
  z-index: 6;
  animation: fam-heart 1.7s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
.heart svg { display: block; width: 100%; height: 100%; }
@keyframes fam-heart {
  0%   { opacity: 0; transform: translate(-50%, 0) scale(0.3); }
  15%  { opacity: 1; transform: translate(-50%, -10px) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--hdx, 0px)), calc(var(--u) * -1.1)) scale(0.8) rotate(var(--hr, 0deg)); }
}

/* Entrance: everyone pops up from the floor, one after another */
html.js .family-stage.reveal .fig { opacity: 0; }
html.js .family-stage.reveal.in .fig {
  animation: fam-pop 0.9s cubic-bezier(0.3, 1.5, 0.5, 1) both;
  animation-delay: calc(var(--i, 0) * 120ms + 150ms);
}
@keyframes fam-pop {
  0%   { opacity: 0; transform: translateY(40px) scale(0.8); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.family-stage.reveal { transform: none; }

.family-hint {
  text-align: center;
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-mute);
}

/* ── Shared timeline card ── */
.family-feed {
  max-width: 34rem;
  margin: clamp(1.75rem, 3vw, 2.75rem) auto 0;
  padding: 1.1rem 1.1rem 0.9rem;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}
.family-feed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.35rem 0.7rem;
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.15rem;
  letter-spacing: -0.015em;
}
.family-live {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sage);
}
.family-live::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 999px;
  background: currentColor;
  animation: pulse 2.4s ease-in-out infinite;
}
.family-feed ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.feed-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.55rem 0.6rem;
  border-radius: 16px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.4s ease, border-color 0.4s ease, transform 0.5s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.feed-row.is-on {
  background: color-mix(in srgb, var(--c) 18%, transparent);
  border-color: color-mix(in srgb, var(--c) 45%, transparent);
  transform: scale(1.015);
}
.feed-avatar {
  width: 42px; height: 42px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 32%, var(--surface));
  display: grid;
  place-items: center;
  overflow: hidden;
}
.feed-avatar img { width: 78%; height: auto; margin-top: 8%; }
.feed-text { min-width: 0; line-height: 1.3; }
.feed-text strong { display: block; font-size: 0.95rem; font-weight: 700; }
.feed-text span { font-size: 0.9rem; color: var(--ink-soft); }
.feed-time {
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-mute);
}
.family-fineprint {
  margin: 0.55rem 0.35rem 0;
  font-size: 0.8rem;
  color: var(--ink-mute);
  text-align: center;
}

.fig[data-who="grandma"], .feed-row[data-who="grandma"] { --c: #A98BDB; }
.fig[data-who="mom"],     .feed-row[data-who="mom"]     { --c: #F28B5E; }
.fig[data-who="dad"],     .feed-row[data-who="dad"]     { --c: #5FB89B; }
.fig[data-who="grandpa"], .feed-row[data-who="grandpa"] { --c: #A39A8C; }
.fig[data-who="baby"]                                   { --c: #F5C79A; }

@media (max-width: 520px) {
  .family-stage { gap: calc(var(--u) * 0.02); }
  .fig[data-who="baby"] { margin: 0 calc(var(--u) * 0.04); }
  .fig-say { max-width: 8.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .fig-body, .zzz span, .family-sparks i { animation: none !important; }
  .zzz span:first-child { opacity: 0.7; }
  html.js .family-stage.reveal .fig { opacity: 1; animation: none; }
}

/* Phones: five name pills would collide, so only the one whose turn it is shows (the timeline names everyone). */
@media (max-width: 520px) {
  .fig-name { opacity: 0; font-size: 0.7rem; padding: 0.22rem 0.6rem; z-index: 5; transition: opacity 0.3s; }
  .fig.is-on .fig-name { opacity: 1; }
}
