/* ==========================================================================
   Meet the team — animated character cards (Home + About)
   Pairs with /assets/js/team.js. Without JS everything shows, static.
   ========================================================================== */

.tm-section {
  position: relative;
  background-color: var(--cream);
  background-image:
    linear-gradient(rgba(138, 69, 19, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(138, 69, 19, 0.06) 1px, transparent 1px);
  background-size: 32px 32px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.tm-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; }
.tm-item { perspective: 1200px; }

/* Card */
.tm-card {
  --accent: var(--blue); --accent-text: var(--blue-dark); --soft: var(--blue-soft);
  position: relative; height: 100%;
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--line); border-radius: 24px;
  box-shadow: 0 1px 2px rgba(18,18,18,0.04), 0 10px 30px rgba(18,18,18,0.06);
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(var(--lift, 0px));
  transform-style: preserve-3d;
  transition: transform .25s ease, box-shadow .25s ease;
}
.tm-card::before {
  content: ""; position: absolute; left: 22px; right: 22px; top: -1px; height: 5px;
  border-radius: 0 0 6px 6px; background: var(--accent);
}
.tm-card:hover, .tm-card:focus-within { --lift: -6px; box-shadow: 0 2px 4px rgba(18,18,18,0.05), 0 24px 48px rgba(18,18,18,0.12); }
.tm-card.is-boss { --accent: #1F4FD8; --accent-text: #14348F; --soft: #EAF0FD; }
.tm-card.is-hustler { --accent: #E8650F; --accent-text: #B5470B; --soft: #FEF0E4; }
.tm-card.is-builder { --accent: #8A4513; --accent-text: #6E370F; --soft: #F5ECE4; }

/* Portrait stage */
.tm-stage {
  position: relative; aspect-ratio: 4 / 5; margin: 10px 10px 0;
  border-radius: 18px; overflow: hidden; background: #F3EEE6;
}
.tm-portrait, .tm-portrait img { display: block; width: 100%; height: 100%; }
.tm-portrait img { object-fit: cover; transform-origin: 50% 85%; }

/* Speech bubble */
.tm-bubble {
  position: absolute; left: 12px; right: 12px; bottom: 76px;
  margin: 0; padding: 10px 14px;
  background: #fff; border: 2px solid var(--accent); border-radius: 16px;
  font-family: var(--font-display); font-size: 15px; font-weight: 700; line-height: 1.25; color: var(--accent-text);
  box-shadow: 0 8px 20px rgba(18,18,18,0.12);
  transform-origin: 18% 0%;
}
.tm-bubble::after {
  content: ""; position: absolute; left: 22px; top: -9px; width: 14px; height: 14px;
  background: #fff; border-left: 2px solid var(--accent); border-top: 2px solid var(--accent);
  transform: rotate(45deg);
}

/* Mood badge (cycles through the expression sheet) */
.tm-mood {
  position: absolute; right: 12px; bottom: 12px;
  display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px;
  background: rgba(255,255,255,0.94); border-radius: 999px;
  box-shadow: 0 8px 20px rgba(18,18,18,0.16);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.tm-mood-face {
  width: 46px; height: 46px; border-radius: 999px; object-fit: cover;
  border: 2px solid var(--accent); background: #F3EEE6;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .2s ease;
}
.tm-mood-label { font-size: 13px; font-weight: 700; color: var(--ink); white-space: nowrap; transition: opacity .2s ease; }
.tm-mood.is-swap .tm-mood-face { transform: scale(.5) rotate(-20deg); opacity: 0; }
.tm-mood.is-swap .tm-mood-label { opacity: 0; }

/* Body */
.tm-body { display: flex; flex-direction: column; gap: 8px; padding: 18px 22px 22px; flex: 1; }
.tm-tag {
  align-self: flex-start; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-text); background: var(--soft); padding: 4px 10px; border-radius: 999px;
}
.tm-name { margin: 0; font-family: var(--font-display); font-size: 32px; font-weight: 800; line-height: 1.05; letter-spacing: -0.02em; }
.tm-role { margin: 0; font-size: 15px; font-weight: 600; color: var(--text-3); }
.tm-desc { margin: 0; font-size: 15px; color: var(--text-2); }

/* Expression picker */
.tm-moods { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-top: auto; padding-top: 10px; }
.tm-face {
  width: 100%; max-width: 48px; aspect-ratio: 1; height: auto; min-height: 36px; padding: 0; border-radius: 999px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; background: #F3EEE6;
  transition: transform .2s ease, border-color .2s ease;
}
.tm-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tm-face:hover { transform: translateY(-3px); }
.tm-face[aria-pressed="true"] { border-color: var(--accent); transform: scale(1.08); }
.tm-face:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Motion (only once team.js has run) ---------- */
.tm-ready .tm-item { opacity: 0; transform: translateY(48px) rotate(-1.5deg); }
.tm-ready .tm-in .tm-item { animation: tm-rise .8s cubic-bezier(.2,.8,.2,1) forwards; }
.tm-ready .tm-in .tm-item:nth-child(2) { animation-delay: .14s; }
.tm-ready .tm-in .tm-item:nth-child(3) { animation-delay: .28s; }
@keyframes tm-rise { to { opacity: 1; transform: none; } }

.tm-ready .tm-bubble { opacity: 0; transform: scale(.4) translateY(-12px); }
.tm-ready .tm-in .tm-bubble { animation: tm-pop .55s cubic-bezier(.34,1.56,.64,1) forwards; animation-delay: .7s; }
.tm-ready .tm-in .tm-item:nth-child(2) .tm-bubble { animation-delay: .85s; }
.tm-ready .tm-in .tm-item:nth-child(3) .tm-bubble { animation-delay: 1s; }
@keyframes tm-pop { to { opacity: 1; transform: none; } }
.tm-ready .tm-in .tm-card:hover .tm-bubble { animation: tm-wiggle .6s ease both; opacity: 1; }
@keyframes tm-wiggle {
  0% { transform: none; } 25% { transform: rotate(-3deg) scale(1.04); } 50% { transform: rotate(2deg) scale(1.04); }
  75% { transform: rotate(-1deg); } 100% { transform: none; }
}

.tm-ready .tm-in .tm-portrait img { animation: tm-breathe 6s ease-in-out infinite alternate; }
.tm-ready .tm-in .tm-item:nth-child(2) .tm-portrait img { animation-delay: -2s; }
.tm-ready .tm-in .tm-item:nth-child(3) .tm-portrait img { animation-delay: -4s; }
@keyframes tm-breathe { from { transform: scale(1) translateY(0); } to { transform: scale(1.035) translateY(-6px); } }
.tm-card:hover .tm-portrait img { animation-play-state: paused; }

/* Phones: swipeable row */
@media (max-width: 900px) {
  .tm-grid { grid-template-columns: repeat(3, minmax(260px, 1fr)); overflow-x: auto; scroll-snap-type: x mandatory;
    margin: 0 calc(var(--gutter) * -1); padding: 8px var(--gutter) 16px; scrollbar-width: none; }
  .tm-grid::-webkit-scrollbar { display: none; }
  .tm-item { scroll-snap-align: start; }
}
@media (max-width: 720px) {
  .tm-grid { grid-template-columns: repeat(3, 264px); gap: 14px; }
  .tm-name { font-size: 26px; }
  .tm-bubble { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .tm-ready .tm-item, .tm-ready .tm-bubble { opacity: 1; transform: none; animation: none !important; }
  .tm-portrait img { animation: none !important; }
  .tm-card { transition: none; }
}
@media print {
  .tm-ready .tm-item, .tm-ready .tm-bubble { opacity: 1 !important; transform: none !important; }
}
