/* ================================================================
   IT-Universe: раздел «Шаблоны» (главная и /shablony/)
================================================================ */

#templates {
	padding: 100px 0;
	text-align: center;
	scroll-margin-top: 90px;
}

/* --- Фильтр --- */
.tpl-toolbar { margin: 10px 0 35px; }
.tpl-filters { display: flex; flex-wrap: wrap; gap: 10px; }
.tpl-chip {
	font-family: inherit; font-size: 0.9em; font-weight: 600; cursor: pointer;
	padding: 9px 18px; border-radius: 30px; color: var(--text-muted);
	background: var(--card-bg); border: 1px solid var(--card-border); transition: all 0.3s ease;
}
.tpl-chip span { opacity: 0.6; margin-left: 4px; }
.tpl-chip:hover { color: var(--text-main); border-color: rgba(0, 242, 254, 0.4); }
.tpl-chip.is-active { background: var(--gradient-btn); color: #000; border-color: transparent; }
.tpl-chip.is-active span { opacity: 0.7; }

/* --- Сетка и карточка --- */
.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; text-align: left; }
.tpl-card {
	display: flex; flex-direction: column; background: var(--card-bg); border: 1px solid var(--card-border);
	border-radius: 15px; overflow: hidden; transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.tpl-card:hover { transform: translateY(-5px); border-color: rgba(0, 242, 254, 0.4); box-shadow: 0 15px 35px rgba(0, 0, 0, 0.35); }
.tpl-card[hidden] { display: none; }

.tpl-thumb {
	position: relative; display: block; width: 100%; aspect-ratio: 4 / 3; padding: 0; border: 0;
	background: #111a30; overflow: hidden; cursor: pointer;
}
.tpl-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; transition: transform 0.5s ease; }
.tpl-card:hover .tpl-thumb img { transform: scale(1.05); }
.tpl-overlay {
	position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
	background: rgba(15, 23, 42, 0.65); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
	opacity: 0; transition: opacity 0.35s ease;
}
.tpl-overlay span {
	color: #fff; font-weight: 700; text-transform: uppercase; letter-spacing: 2px; font-size: 0.85em;
	padding: 10px 24px; border: 2px solid var(--accent-1); border-radius: 30px;
}
.tpl-card:hover .tpl-overlay, .tpl-thumb:focus-visible .tpl-overlay { opacity: 1; }

.tpl-meta { padding: 22px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.tpl-tag {
	--tag: var(--accent-1);
	align-self: flex-start; font-size: 0.72em; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px;
	color: var(--tag); padding: 3px 10px; border-radius: 12px;
	border: 1px solid color-mix(in srgb, var(--tag) 45%, transparent);
	background: color-mix(in srgb, var(--tag) 12%, transparent);
}
.tpl-name { font-size: 1.2em; font-weight: 600; color: var(--text-main); margin: 0; }
.tpl-desc { color: var(--text-muted); font-size: 0.92em; line-height: 1.5; flex: 1; }
.tpl-actions { display: flex; gap: 10px; margin-top: 6px; }

/* Компактные кнопки (основные .btn темы слишком крупные для карточки) */
.tpl-btn {
	flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	font-family: inherit; font-size: 0.82em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
	padding: 11px 14px; border-radius: 30px; cursor: pointer; text-decoration: none; white-space: nowrap;
	transition: all 0.3s ease;
}
.tpl-btn-primary { background: var(--gradient-btn); color: #000; border: none; box-shadow: 0 8px 18px rgba(0, 242, 254, 0.2); }
.tpl-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(0, 242, 254, 0.35); color: #000; }
.tpl-btn-outline { background: rgba(0, 242, 254, 0.05); border: 2px solid var(--accent-1); color: var(--text-main); }
.tpl-btn-outline:hover { background: rgba(0, 242, 254, 0.15); color: #fff; }

/* --- Шаги --- */
.tpl-steps { list-style: none; counter-reset: s; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin: 60px 0 0; }
.tpl-steps li {
	counter-increment: s; background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 15px;
	padding: 24px; display: flex; flex-direction: column; gap: 6px;
}
.tpl-steps li::before {
	content: counter(s); display: flex; align-items: center; justify-content: center; width: 38px; height: 38px;
	border-radius: 50%; background: var(--gradient-btn); color: #000; font-weight: 700; margin-bottom: 8px;
}
.tpl-steps strong { color: var(--text-main); }
.tpl-steps span { color: var(--text-muted); font-size: 0.92em; }

/* --- Окно просмотра --- */
body.tpl-modal-open { overflow: hidden; }
.tpl-modal {
	position: fixed; inset: 0; z-index: 100000; display: none; flex-direction: column;
	background: rgba(2, 6, 23, 0.94); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.tpl-modal.is-open { display: flex; }
.tpl-modal-bar {
	display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
	padding: 12px 20px; background: var(--bg-dark); border-bottom: 1px solid var(--card-border);
}
.tpl-modal-title { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.tpl-devices { display: flex; gap: 4px; padding: 4px; border-radius: 30px; background: var(--card-bg); border: 1px solid var(--card-border); }
.tpl-device {
	display: flex; align-items: center; gap: 6px; padding: 7px 14px; border: 0; border-radius: 30px; background: none;
	color: var(--text-muted); font-family: inherit; font-size: 0.82em; font-weight: 600; cursor: pointer;
}
.tpl-device.is-active { background: var(--gradient-btn); color: #000; }
.tpl-modal-actions { display: flex; gap: 8px; }
.tpl-modal-actions .tpl-btn { flex: none; padding: 9px 16px; }
.tpl-stage { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: 20px; overflow: auto; }
.tpl-frame {
	position: relative; width: 100%; height: 100%; background: #fff; border-radius: 12px; overflow: hidden;
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); transition: width 0.35s ease;
}
.tpl-frame[data-device="tablet"] { width: 820px; max-width: 100%; border: 14px solid #1e293b; border-radius: 28px; }
.tpl-frame[data-device="mobile"] { width: 400px; max-width: 100%; border: 12px solid #1e293b; border-radius: 36px; }
.tpl-frame iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.tpl-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #0f172a; font-weight: 600; background: #f1f5f9; }
.tpl-loading[hidden] { display: none; }

/* --- Адаптив --- */
@media (max-width: 1024px) {
	.tpl-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
	#templates { padding: 70px 0; }
	.tpl-grid, .tpl-steps { grid-template-columns: 1fr; }
	.tpl-device span { display: none; }
	.tpl-modal-actions #tpl-modal-open { display: none; }
}
