/* Layout */
.template-detail {
  --th-header-h: 96px;
  --th-header-edge: 20px;
  color: var(--text-color);
  min-height: 100vh;
}

.template-detail > section {
  padding: 64px 0;
}

/* Hero — отступ сверху под фиксированную шапку (как на /templates, /integrations) */
.template-detail > .template-detail__hero {
  padding-top: calc(var(--th-header-h) + var(--th-header-edge) + 24px);
}

@media (max-width: 768px) {
  .template-detail > section { padding: 40px 0; }
  .template-detail > .template-detail__hero {
    padding-top: calc(var(--th-header-h) + var(--th-header-edge) + 16px);
  }
}

/* hidden-атрибут перебивает display: flex */
.template-detail [hidden] { display: none !important; }

.template-detail .container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

@media (max-width: 768px) {
  .template-detail .container { padding: 0 16px; }
}

/* Breadcrumb */
.td-breadcrumb {
  display: flex;
  gap: 8px;
  align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(225, 241, 255, 0.45);
  margin-bottom: 32px;
}

.td-breadcrumb a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

.td-breadcrumb a:hover { color: rgba(40, 148, 236, 1); }

.td-breadcrumb__current { color: var(--text-color); }

.td-breadcrumb__sep { opacity: 0.5; }

/* Hero */
.td-hero__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
}

@media (max-width: 900px) {
  .td-hero__grid { grid-template-columns: 1fr; gap: 32px; }
}

.td-hero__cover {
  aspect-ratio: 16 / 9;
  border-radius: 20px;
  overflow: hidden;
  background: rgba(79, 70, 229, 0.15);
}

.td-hero__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.td-hero__cover-fallback {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.3), rgba(40, 148, 236, 0.3));
}

.td-hero__badges {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.td-hero__badge-free {
  padding: 4px 10px;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 999px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgb(74, 222, 128);
}

.td-hero__title {
  font-size: clamp(28px, 3.5vw, 48px);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 16px 0;
}

.td-hero__description {
  font-size: 18px;
  line-height: 1.5;
  color: rgba(225, 241, 255, 0.7);
  margin: 0 0 32px 0;
}

/* Отступ снизу для CTA в hero (сам стиль кнопки — .int-cta-primary) */
.td-hero .int-cta-primary,
.td-hero__body .int-cta-primary {
  margin-bottom: 24px;
}

.td-hero__meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(225, 241, 255, 0.5);
}

/* Section title */
.td-section-title {
  font-size: clamp(24px, 2.5vw, 32px);
  font-weight: 600;
  margin: 0 0 24px 0;
}

.td-section-title--center { text-align: center; }

/* About + Inside layout */
.td-about-inside {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 48px;
}

.td-about-inside__text,
.td-about-inside__aside {
  flex: 1 1 360px;
  display: flex;
  min-width: 0;
}

.td-about-inside__aside {
  flex-direction: column;
}

.td-inside__stack {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.td-inside__col-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(225, 241, 255, 0.45);
  margin: 0 0 16px 0;
}

.td-inside__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.td-inside__item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.td-inside__icon {
  width: 24px;
  height: 24px;
  margin-top: 2px;
  flex-shrink: 0;
  color: rgba(225, 241, 255, 0.7);
}

.td-inside__name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-color);
  margin-bottom: 2px;
}

.td-inside__desc {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(225, 241, 255, 0.55);
}

/* How — переиспользуем .next-flow / .flow-node из contact-us */
.next-flow__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  column-gap: 5rem;
  row-gap: 4rem;
  position: relative;
  max-width: 64rem;
  margin: 0 auto;
}

.next-flow__grid[data-count="1"],
.next-flow__grid[data-count="2"],
.next-flow__grid[data-count="3"],
.next-flow__grid[data-count="5"],
.next-flow__grid[data-count="6"] {
  grid-template-columns: 1fr;
  max-width: 48rem;
  row-gap: 1.5rem;
}

.flow-connections {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.flow-node {
  position: relative;
  z-index: 2;
  padding: 1.5rem;
  background: #11141f;
  border: 1px solid rgba(225, 241, 255, 0.08);
  border-radius: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  transition: border-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.flow-node:hover {
  border-color: rgba(79, 70, 229, 0.4);
  transform: translateY(-0.125rem);
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.3);
}

.flow-node--active {
  border-color: var(--accentcolor2);
  box-shadow:
    inset 0 0 0 1px rgba(79, 70, 229, 0.15),
    0 0 1.25rem rgba(79, 70, 229, 0.18),
    0 0 2.5rem rgba(79, 70, 229, 0.1);
}

.flow-node--active::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 1rem;
  right: 1rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accentcolor2), transparent);
  box-shadow: 0 0 0.5rem var(--accentcolor2);
}

.flow-node__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.flow-node__icon {
  width: 2.625rem;
  height: 2.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(79, 70, 229, 0.1);
  border: 1px solid rgba(79, 70, 229, 0.4);
  border-radius: 0.625rem;
  color: var(--accentcolor);
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.flow-node--active .flow-node__icon {
  background: rgba(79, 70, 229, 0.2);
  box-shadow: 0 0 0.875rem rgba(79, 70, 229, 0.18);
  color: white;
}

.flow-node__step {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(225, 241, 255, 0.4);
  padding: 0.3125rem 0.75rem;
  background: rgba(225, 241, 255, 0.04);
  border: 1px solid rgba(225, 241, 255, 0.08);
  border-radius: 6.25rem;
}

.flow-node--active .flow-node__step {
  color: var(--accentcolor);
  background: rgba(79, 70, 229, 0.1);
  border-color: rgba(79, 70, 229, 0.4);
}

.flow-node__title {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.3;
}

.flow-node__meta {
  font-size: 0.9375rem;
  color: rgba(225, 241, 255, 0.65);
  line-height: 1.5;
}

@keyframes flow-dash {
  to { stroke-dashoffset: -200; }
}

@media (max-width: 1100px) {
  .next-flow__grid {
    column-gap: 3.5rem;
    row-gap: 3rem;
  }
}

@media (max-width: 768px) {
  .next-flow__grid,
  .next-flow__grid[data-count="4"] {
    grid-template-columns: 1fr;
    column-gap: 0;
    row-gap: 1.5rem;
    max-width: 100%;
  }
  .flow-connections { display: none; }
}

/* Use-cases */
.td-use-cases__grid {
  display: grid;
  gap: 24px;
}

.td-use-cases__grid[data-count="2"] { grid-template-columns: repeat(2, 1fr); }
.td-use-cases__grid[data-count="3"] { grid-template-columns: repeat(3, 1fr); }
.td-use-cases__grid[data-count="4"] { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
  .td-use-cases__grid,
  .td-use-cases__grid[data-count="2"],
  .td-use-cases__grid[data-count="3"],
  .td-use-cases__grid[data-count="4"] { grid-template-columns: 1fr; }
}

.td-use-case {
  padding: 24px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(225, 241, 255, 0.08);
  border-radius: 16px;
}

.td-use-case__icon {
  width: 40px;
  height: 40px;
  margin-bottom: 12px;
}

.td-use-case__icon img {
  width: 100%;
  height: 100%;
}

.td-use-case__title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px 0;
}

.td-use-case__audience {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(225, 241, 255, 0.5);
  margin-bottom: 12px;
}

.td-use-case__scenario {
  font-size: 14px;
  line-height: 1.5;
  color: rgba(225, 241, 255, 0.65);
  margin: 0;
}

/* Requirements */
.td-requirements__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  max-width: 1000px;
}

@media (max-width: 700px) {
  .td-requirements__list { grid-template-columns: 1fr; }
}

.td-requirements__item {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(225, 241, 255, 0.08);
  border-radius: 12px;
  align-items: flex-start;
}

.td-requirements__icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.td-requirements__name {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
}

.td-requirements__desc {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(225, 241, 255, 0.6);
}

/* CTA mid */
.td-cta-mid {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 32px;
  background: linear-gradient(90deg, rgba(79, 70, 229, 0.1), rgba(40, 148, 236, 0.1));
  border: 1px solid rgba(79, 70, 229, 0.2);
  border-radius: 16px;
}

.td-cta-mid__text {
  font-size: 18px;
  margin: 0;
  color: var(--text-color);
}

/* FAQ */
.td-faq__list {
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.td-faq__item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(225, 241, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.td-faq__item[open] {
  border-color: rgba(79, 70, 229, 0.3);
}

.td-faq__q {
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.td-faq__q::-webkit-details-marker { display: none; }

.td-faq__q::after {
  content: '+';
  font-size: 24px;
  color: rgba(225, 241, 255, 0.5);
  transition: transform 0.2s ease;
}

.td-faq__item[open] .td-faq__q::after {
  content: '−';
}

.td-faq__a {
  padding: 0 20px 20px 20px;
  font-size: 15px;
  line-height: 1.6;
  color: rgba(225, 241, 255, 0.75);
}

/* Related */
.td-related__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

@media (max-width: 1100px) {
  .td-related__grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .td-related__grid { grid-template-columns: 1fr; }
}

/* Footer CTA */
.td-footer-cta__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

@media (max-width: 768px) {
  .td-footer-cta__grid { grid-template-columns: 1fr; }
}

.td-footer-cta__block {
  padding: 40px;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(40, 148, 236, 0.1));
  border: 1px solid rgba(79, 70, 229, 0.2);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
}

.td-footer-cta__title {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 12px 0;
}

.td-footer-cta__text {
  font-size: 15px;
  line-height: 1.6;
  color: rgba(225, 241, 255, 0.7);
  margin: 0 0 24px 0;
  flex: 1;
}

.td-footer-cta__button {
  align-self: flex-start;
}
