/*
 * TeleXtra phase 19 (R28.1, RULE 2 point 5): the home page (resources/views/pages/home.php), loaded on the public pages
 * through config/registry.php → public_styles. The hero's visual — a Telegram chat with a bot menu, a channel post with
 * reactions and a members chart — is drawn here in CSS; light and dark follow the Kit's tokens and Telegram's own chat
 * colours. Phones from 320 px: the visual stacks under the text, nothing scrolls sideways.
 */
.tg-home {
  --tg-chat-bg: #dfe7ee;
  --tg-chat-in: #ffffff;
  --tg-chat-out: #e3fbd3;
  --tg-chat-text: #0f1729;
  --tg-chat-sub: #5b6b7d;
  --tg-chat-head: #3e6f9c;
  --tg-chat-kb: rgb(62 111 156 / 0.88);
  --tg-chat-link: #2f6ea5;
  overflow-x: clip;
}

[data-theme="dark"] .tg-home {
  --tg-chat-bg: #0e1621;
  --tg-chat-in: #182533;
  --tg-chat-out: #2b5278;
  --tg-chat-text: #f1f4f8;
  --tg-chat-sub: #93a4b6;
  --tg-chat-head: #17212b;
  --tg-chat-kb: rgb(43 82 120 / 0.92);
  --tg-chat-link: #7cb6ec;
}

.tg-home-hero {
  text-align: left;
}

.tg-home-hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-10);
  align-items: center;
}

@media (min-width: 960px) {
  .tg-home-hero-inner {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  }
}

.tg-home-hero-text {
  min-width: 0;
}

.tg-home-hero h1 {
  margin-inline: 0;
  font-size: var(--text-5xl);
  overflow-wrap: anywhere;
}

.tg-home-hero .lead {
  margin-inline: 0;
}

.tg-home-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-full);
  background: var(--brand-soft);
  color: var(--brand-text);
  font-size: var(--text-sm);
  font-weight: 600;
  max-width: 100%;
}

.tg-home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-8);
}

.tg-home-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin: var(--space-6) 0 0;
  padding: 0;
  list-style: none;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.tg-home-chips li {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.tg-home-chips .icon {
  color: var(--brand-text);
}

/* ---------- the visual ---------- */
.tg-home-art {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  margin: 0;
  min-width: 0;
}

@media (min-width: 560px) {
  .tg-home-art {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    align-items: end;
  }
}

.tg-home-phone {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 22rem;
  border: 6px solid var(--text);
  border-radius: 28px;
  background: var(--tg-chat-bg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  color: var(--tg-chat-text);
  font-size: var(--text-sm);
}

[data-theme="dark"] .tg-home-phone {
  border-color: #2a3442;
}

.tg-home-phone-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--tg-chat-head);
  color: #fff;
}

.tg-home-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 2rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  font-weight: 700;
}

.tg-home-phone-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.tg-home-phone-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tg-home-phone-name span {
  opacity: 0.8;
  font-size: var(--text-xs);
}

.tg-home-chat {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  min-width: 0;
}

.tg-home-msg {
  position: relative;
  max-width: 85%;
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: 14px;
  background: var(--tg-chat-in);
  box-shadow: 0 1px 1px rgb(0 0 0 / 0.08);
  overflow-wrap: anywhere;
}

.tg-home-msg p {
  margin: 0;
}

.tg-home-msg-in {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.tg-home-msg-out {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: var(--tg-chat-out);
}

.tg-home-tick {
  display: inline-flex;
  margin-left: var(--space-1);
  color: #4fae4e;
  vertical-align: middle;
}

.tg-home-kb {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  max-width: 90%;
}

.tg-home-kb span,
.tg-home-pay {
  display: block;
  padding: var(--space-1) var(--space-2);
  border-radius: 8px;
  background: var(--tg-chat-kb);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tg-home-pay {
  margin-top: var(--space-2);
}

.tg-home-input {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin: 0 var(--space-2) var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--tg-chat-in);
  color: var(--tg-chat-sub);
}

.tg-home-send {
  color: var(--tg-chat-link);
}

.tg-home-side {
  display: grid;
  gap: var(--space-4);
  min-width: 0;
}

.tg-home-post,
.tg-home-chart {
  min-width: 0;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.tg-home-post-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
  color: var(--tg-chat-link);
  font-size: var(--text-sm);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.tg-home-post-text {
  margin: 0;
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.tg-home-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin: var(--space-3) 0 0;
}

.tg-home-reactions span {
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--brand-soft);
  color: var(--brand-text);
  font-size: var(--text-xs);
  font-weight: 600;
}

.tg-home-chart-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.tg-home-chart-head strong {
  color: var(--brand-text);
}

.tg-home-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 5.5rem;
}

.tg-home-bar {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--brand), color-mix(in srgb, var(--brand) 55%, transparent));
}

.tg-home-bar-3 { height: 27%; }
.tg-home-bar-4 { height: 36%; }
.tg-home-bar-5 { height: 45%; }
.tg-home-bar-6 { height: 54%; }
.tg-home-bar-7 { height: 63%; }
.tg-home-bar-8 { height: 72%; }
.tg-home-bar-9 { height: 81%; }
.tg-home-bar-10 { height: 90%; }
.tg-home-bar-11 { height: 100%; }

@media (prefers-reduced-motion: no-preference) {
  .tg-home-msg,
  .tg-home-kb {
    animation: tg-home-in 420ms ease-out both;
  }

  .tg-home-chat > :nth-child(2) { animation-delay: 150ms; }
  .tg-home-chat > :nth-child(3) { animation-delay: 300ms; }
  .tg-home-chat > :nth-child(4) { animation-delay: 450ms; }
  .tg-home-chat > :nth-child(5) { animation-delay: 600ms; }

  .tg-home-bar {
    transform-origin: bottom;
    animation: tg-home-grow 700ms ease-out both;
  }
}

@keyframes tg-home-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes tg-home-grow {
  from {
    transform: scaleY(0.1);
  }
  to {
    transform: scaleY(1);
  }
}

/* ---------- sections ---------- */
.tg-home-section {
  padding-block: clamp(2.5rem, 1.5rem + 4vw, 4.5rem);
}

.tg-home-band {
  background: var(--bg-subtle);
  border-block: 1px solid var(--border);
}

.tg-home-head {
  max-width: 44rem;
  margin: 0 auto var(--space-8);
  text-align: center;
}

.tg-home-head h2 {
  font-size: var(--text-3xl);
  overflow-wrap: anywhere;
}

.tg-home-head p {
  margin: var(--space-3) 0 0;
  color: var(--text-muted);
}

.tg-home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: var(--space-4);
}

.tg-home-grid-4 {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr));
}

.tg-home-feature {
  padding: var(--space-5);
  min-width: 0;
}

.tg-home-feature h3,
.tg-home-who h3,
.tg-home-steps h3 {
  margin: var(--space-3) 0 var(--space-1);
  font-size: var(--text-lg);
}

.tg-home-feature p,
.tg-home-who p,
.tg-home-steps p {
  margin: 0;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.tg-home-icon {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius);
  background: var(--brand-soft);
  color: var(--brand-text);
}

.tg-home-who {
  min-width: 0;
}

.tg-home-who > .icon {
  color: var(--brand-text);
}

.tg-home-steps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: var(--space-6);
  margin: 0;
  padding: 0;
  list-style: none;
}

.tg-home-steps li {
  min-width: 0;
}

.tg-home-step-no {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-fg);
  font-weight: 700;
}

.tg-home-narrow {
  max-width: 48rem;
}

.tg-home-faq {
  display: grid;
  gap: var(--space-3);
}

.tg-home-faq details {
  padding: var(--space-4) var(--space-5);
}

.tg-home-faq summary {
  cursor: pointer;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.tg-home-faq p {
  margin: var(--space-3) 0 0;
  color: var(--text-muted);
}

.tg-home-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  padding: clamp(1.25rem, 1rem + 2vw, 2.5rem);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-xl);
  background: var(--brand-soft);
}

.tg-home-cta > div {
  flex: 1 1 18rem;
  min-width: 0;
}

.tg-home-cta h2 {
  font-size: var(--text-2xl);
}

.tg-home-logins {
  display: grid;
  gap: var(--space-1);
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
}

.tg-home-logins li {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-width: 0;
}

.tg-home-logins span {
  min-width: 5rem;
  color: var(--text-muted);
}

.tg-home-logins code {
  overflow-wrap: anywhere;
}

.tg-home-doors {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: var(--space-4);
}

.tg-home-door {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-5);
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}

.tg-home-door > .icon {
  color: var(--brand-text);
}

.tg-home-door span {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.tg-home-door:hover {
  border-color: var(--brand-border);
}

/* the Kit's home hero parts the page keeps (data-hero-* for Admin → Homepage) */
.tg-home .hero-inner {
  position: relative;
}

.tg-home .hero-actions {
  justify-content: flex-start;
}

.home-hero {
  min-width: 0;
}

/* The sign-in page of a demo (KIT-REQUESTS.md 14): the Kit's auth grid takes the demo sign-ins' widest line as its
   column, which ran 200 px past a 320 px phone. One column the width of the page; the sign-in rows wrap. */
.auth-wrap {
  grid-template-columns: minmax(0, 1fr);
}

.auth-card {
  max-width: 100%;
  min-width: 0;
}

/* Phase 20: one row per demo role (nine of them): the alert is a flex row in the Kit, so its rows would share one line */
[data-demo-logins] {
  flex-direction: column;
  align-items: stretch;
}

[data-demo-logins] .cluster {
  flex-wrap: wrap;
  min-width: 0;
  width: 100%;
}

[data-demo-logins] .cluster > *,
[data-demo-logins] .small {
  min-width: 0;
  overflow-wrap: anywhere;
}
