/* ============================================================
   GIRL+GRID — the finale: "Get in the group."

   Composition and the group-chat window built by scripts/clubchat.js.
   Loads after girl-type.css, so it re-cuts .club__inner from
   girl-chapters.css rather than editing it there.

   Desktop (>= 1100px): headline, card and ask in the left column;
   the chat window sticks beside them for the length of the section.
   Below that, one centred column: headline, chat, card, ask.
   ============================================================ */

.club {
  /* clip, not hidden: hidden makes .club a scroll container and the
     sticky chat window would stick to nothing. */
  overflow: hidden;
  overflow: clip;

  --chat-pink:   #ff1568;
  --chat-orchid: #e7a3ff;
  --chat-blush:  #ffd1e6;
  --chat-gum:    #ff6fb5;
  --chat-ink:    #0b0b12;
}

/* ---------- composition ---------- */
.club__inner { gap: clamp(1.6rem, 3.5vw, 2.6rem); }
.club__head { display: grid; gap: 1.2rem; justify-items: center; }
.club__ask { display: grid; gap: 0.9rem; justify-items: center; }
.club__ask .club__cta { margin: 0; }
.club__ask .club__small { margin: 0; }
.club__inner .club__card { margin-block: 0; }

.club__chat {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0.7rem;
  width: min(100%, 32rem);
  height: clamp(28rem, 68svh, 34rem);
  text-align: left;
}

@media (min-width: 1100px) {
  .club__inner {
    grid-template-columns: minmax(0, 1fr) clamp(22rem, 27vw, 26rem);
    grid-template-areas:
      "head chat"
      "card chat"
      "ask  chat";
    column-gap: clamp(3rem, 5vw, 6rem);
    align-items: start;
    justify-items: start;
    text-align: left;
  }
  .club__head { grid-area: head; justify-items: start; }
  .club__inner .club__card { grid-area: card; max-width: none; }
  .club__ask { grid-area: ask; justify-items: start; }
  .club__chat {
    grid-area: chat;
    width: 100%;
    /* Clear of the fixed next-up dial in the bottom-right corner. */
    height: min(42rem, calc(100svh - 15.5rem));
    position: sticky;
    top: 6rem;
  }
}
/* Between 1100 and the side-nav breakpoint the left column is too
   narrow to hold the card and its form side by side. */
@media (min-width: 1100px) and (max-width: 1279px) {
  .club__inner .club__card { grid-template-columns: 1fr; }
  .club__inner .card__stage { max-width: 34rem; }
}

/* ---------- the window ---------- */
.chat__window {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 1.6rem;
  overflow: hidden;
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(255, 21, 104, .16), transparent 60%),
    linear-gradient(180deg, rgba(36, 16, 38, .78), rgba(16, 9, 20, .86));
  border: 1px solid rgba(255, 255, 255, .12);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow:
    0 50px 90px -50px rgba(255, 21, 104, .6),
    0 24px 40px -30px rgba(0, 0, 0, .8),
    inset 0 1px 0 rgba(255, 255, 255, .14);
}

.chat__head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .03);
}
.chat__stack { display: flex; flex: none; }
.chat__stack .chat__av { box-shadow: 0 0 0 2px #1d0f20; }
.chat__stack .chat__av + .chat__av { margin-left: -0.55rem; }
.chat__who { display: grid; gap: 0.1rem; min-width: 0; }
.chat__title {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat__status { font-size: 0.8rem; color: var(--chat-orchid); }

.chat__av {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--chat-ink);
}
.chat__av--pink   { background: var(--chat-pink); }
.chat__av--orchid { background: var(--chat-orchid); }
.chat__av--blush  { background: var(--chat-blush); }
.chat__av--gum    { background: var(--chat-gum); }

/* ---------- the stream ---------- */
.chat__body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  /* Older messages fade out under the header instead of being cut. */
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 2.6rem);
  mask-image: linear-gradient(to bottom, transparent, #000 2.6rem);
}
.chat__stream {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1rem 0.9rem 0.9rem;
}
.chat__day {
  align-self: center;
  margin-bottom: 0.4rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.chat__row { display: flex; align-items: flex-end; gap: 0.45rem; }
.chat__row--me { justify-content: flex-end; }
.chat__row.has-react { margin-bottom: 0.85rem; }
.chat__row--invite { justify-content: center; padding-top: 0.5rem; }

.chat__bubble {
  position: relative;
  max-width: 80%;
  padding: 0.5rem 0.75rem 0.4rem;
  border-radius: 1.1rem 1.1rem 1.1rem 0.3rem;
  background: rgba(255, 255, 255, .085);
  border: 1px solid rgba(255, 255, 255, .1);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.92rem;
  line-height: 1.35;
  transform-origin: 0% 100%;   /* springs out of the tail */
  overflow-wrap: anywhere;
}
.chat__row--me .chat__bubble {
  border-radius: 1.1rem 1.1rem 0.3rem 1.1rem;
  background: linear-gradient(140deg, var(--chat-pink), #ff4f9e);
  border-color: transparent;
  color: var(--chat-ink);
  transform-origin: 100% 100%;
}

.chat__name { display: block; font-size: 0.76rem; font-weight: 700; margin-bottom: 0.1rem; }
.chat__name--pink   { color: #ff5d95; }
.chat__name--orchid { color: var(--chat-orchid); }
.chat__name--blush  { color: var(--chat-blush); }
.chat__name--gum    { color: var(--chat-gum); }

.chat__meta {
  float: right;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0.35rem 0 0 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  line-height: 1;
  color: var(--muted);
  white-space: nowrap;
}
.chat__row--me .chat__meta { color: rgba(11, 11, 18, .62); }
.chat__ticks { width: 0.95rem; height: 0.6rem; color: rgba(11, 11, 18, .45); transition: color 0.4s var(--ease-out); }
.chat__ticks.is-read { color: #4b0f7a; }

.chat__react {
  position: absolute;
  bottom: -0.95rem;
  right: 0.5rem;
  padding: 0.12rem 0.38rem;
  border-radius: 999px;
  background: #24122a;
  border: 1px solid rgba(255, 255, 255, .14);
  font-size: 0.88rem;
  line-height: 1.2;
}
.chat__row--me .chat__react { right: auto; left: 0.5rem; }

/* photo */
.chat__bubble--photo { padding: 0.3rem 0.3rem 0.4rem; }
.chat__bubble--photo .chat__name { padding: 0.15rem 0.45rem 0.1rem; }
.chat__photo {
  display: block;
  width: min(10rem, 100%);
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 0.85rem;
}
.chat__bubble--photo .chat__text { display: inline-block; padding: 0.35rem 0.45rem 0; max-width: 10rem; }
.chat__bubble--photo .chat__meta { margin-right: 0.35rem; }

/* voice note */
.chat__voice { display: inline-flex; align-items: center; gap: 0.6rem; padding-block: 0.15rem; }
.chat__play {
  position: relative;
  flex: none;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--chat-blush);
}
.chat__play::after {
  content: "";
  position: absolute;
  left: 55%; top: 50%;
  translate: -50% -50%;
  border-style: solid;
  border-width: 0.38rem 0 0.38rem 0.6rem;
  border-color: transparent transparent transparent var(--chat-ink);
}
.chat__wave { display: inline-flex; align-items: center; gap: 2px; height: 1.6rem; color: var(--chat-blush); }
.chat__wave i {
  display: block;
  width: 3px;
  height: calc(var(--h) * 1.5px);
  border-radius: 2px;
  background: currentColor;
  animation: chat-wave 0.9s ease-in-out infinite alternate;
  animation-delay: calc(var(--i) * -0.11s);
}
.chat__dur { font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); }
@keyframes chat-wave {
  from { transform: scaleY(0.35); opacity: .6; }
  to   { transform: scaleY(1);    opacity: 1; }
}

/* typing */
.chat__typing { display: inline-flex; gap: 0.25rem; padding: 0.7rem 0.85rem; }
.chat__typing i {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: var(--chat-orchid);
  animation: chat-dot 1s ease-in-out infinite;
}
.chat__typing i:nth-child(2) { animation-delay: 0.15s; }
.chat__typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30%           { transform: translateY(-0.3rem); opacity: 1; }
}

/* the invite: the one real control in the window */
.chat__invite {
  appearance: none;
  padding: 0.75rem 1.25rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(140deg, var(--chat-pink), var(--chat-gum));
  color: var(--chat-ink);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transform-origin: 50% 100%;
  box-shadow: 0 14px 30px -14px rgba(255, 21, 104, .9);
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
}
.chat__invite:hover { transform: translateY(-2px); box-shadow: 0 20px 36px -14px rgba(255, 21, 104, 1); }
.chat__invite:active { transform: translateY(0) scale(0.97); }
.chat__invite:focus-visible { outline: 2px solid var(--chat-blush); outline-offset: 3px; }

/* ---------- composer (decorative) ---------- */
.chat__compose {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, .07);
}
.chat__field {
  flex: 1;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
  font-size: 0.85rem;
  color: var(--muted);
}
.chat__mic {
  position: relative;
  flex: none;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--chat-pink);
}
.chat__mic::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  translate: -50% -60%;
  width: 0.45rem;
  height: 0.75rem;
  border-radius: 0.3rem;
  background: var(--chat-ink);
}

.chat__tag {
  margin: 0;
  justify-self: center;
  color: var(--muted);
  font-size: 0.68rem;
}

/* ---------- motion states ---------- */
.club__chat[data-paused] :is(.chat__wave i, .chat__typing i) { animation-play-state: paused; }
.club__chat[data-motion="off"] .chat__wave i { animation: none; }

@media (prefers-reduced-motion: reduce) {
  .chat__wave i, .chat__typing i { animation: none; }
  .chat__ticks, .chat__invite { transition: none; }
}
