/* 
   PREMIUM TECH DESIGN SYSTEM 
   Theme: Future Education / Clean Tech / Glassmorphism
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;800&display=swap');

:root {
  /* Colors */
  --bg-body: #f4f6f9;
  --bg-surface: #ffffff;
  --bg-surface-glass: rgba(255, 255, 255, 0.85);

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --accent-purple: #7c3aed;
  --accent-cyan: #06b6d4;

  /* Spacing & Layout */
  --container-width: 1200px;
  --header-height: 80px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  /* Effects */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.3);

  --glass-border: 1px solid rgba(255, 255, 255, 0.5);
  --glass-backdrop: blur(12px);

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

img {
  max-width: 100%;
  display: block;
  border-radius: var(--radius-md);
}

a {
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Utilities */
.container {
  width: min(100% - 40px, var(--container-width));
  margin: 0 auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 28px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
}

.btn--black {
  background: var(--text-main);
  color: var(--text-inverse);
  box-shadow: var(--shadow-md);
}

.btn--black:hover {
  background: #000;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn--gray {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid #e2e8f0;
}

.btn--gray:hover {
  border-color: var(--text-muted);
  background: #f8fafc;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: var(--glass-backdrop);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand__logo {
  height: 48px;
  width: auto;
  border-radius: 0;
}

.header-nav {
  display: flex;
  gap: 32px;
  align-items: center;
}

.header-nav__link {
  font-weight: 500;
  font-size: 16px;
  color: var(--text-muted);
}

.header-nav__link:hover {
  color: var(--primary);
}

/* Hero Section */
.hero {
  position: relative;
  height: 80vh;
  min-height: 600px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.hero__bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, #1e293b, #0f172a);
  z-index: -1;
}

.hero__bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url('https://images.unsplash.com/photo-1563770094211-1ee79986b208?auto=format&fit=crop&q=80') center/cover;
  opacity: 0.4;
  mix-blend-mode: overlay;
}

.hero__content {
  position: relative;
  width: 100%;
}

.hero__title {
  font-size: clamp(48px, 8vw, 96px);
  font-weight: 800;
  line-height: 1;
  color: transparent;
  background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  margin-bottom: 64px;
  letter-spacing: -0.02em;
}

.hero__links {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
}

.hero__item {
  font-size: clamp(24px, 4vw, 48px);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
  padding-left: 24px;
  border-left: 4px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
}

.hero__item:hover {
  color: #fff;
  padding-left: 36px;
  border-left-color: var(--primary);
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}


/* Detail Page */
.detail-page {
  padding-bottom: 80px;
}

.detail-page__toplink {
  margin: 24px 0;
}

.detail-title {
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 800;
  margin: 40px 0 60px;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--text-main), var(--text-muted));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 32px;
  margin-bottom: 120px;
}

/* Game section should be FULL WIDTH, not 2-column */
#interactive-game {
  display: block !important;
  grid-template-columns: none !important;
}

.text-block {
  font-size: 18px;
  color: var(--text-muted);
}

.big-paragraph {
  margin-bottom: 24px;
  line-height: 1.7;
}

.section__title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 24px;
}

.list--big li {
  position: relative;
  padding-left: 28px;
  margin-bottom: 16px;
}

.list--big li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--primary);
  font-size: 24px;
  line-height: 1;
}

.gallery-float img {
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
  transition: transform 0.4s ease;
}

.gallery-float img:hover {
  transform: scale(1.02);
}

/* Interactive & Video Area */
.video-area {
  margin-top: 40px;
}

.video-card {
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.video-card__fake {
  background: #0f172a;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.play {
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.play::after {
  content: "";
  margin-left: 4px;
  border-left: 14px solid #fff;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
}

.video-card__fake:hover .play {
  transform: scale(1.1);
  background: var(--primary);
  border-color: var(--primary);
}

.btn-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 80px;
}

/* COCKPIT LAYOUT (Ideal Tab) */
.cockpit-layout {
  display: grid;
  grid-template-columns: 7fr 3fr;
  /* Sim takes 70% */
  gap: 24px;
  height: 80vh;
  min-height: 650px;
  max-height: 950px;
  direction: ltr;
  /* Force LTR always */
}

/* Left: Simulator */
.cockpit-sim {
  background: #0f172a;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-lg);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.cockpit-sim .canvas-wrapper {
  flex: 1;
  height: 100%;
  position: relative;
}

/* Force canvas to fill container */
#game-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
}

/* Right: Station */
.cockpit-station {
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100%;
}

/* Code Panel */
.code-panel {
  flex: 2;
  /* Takes more space */
  background: #1e293b;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  border: 1px solid #334155;
  overflow: hidden;
}

.code-header {
  background: #0f172a;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #334155;
}

.code-header span {
  font-weight: 700;
  font-size: 13px;
  color: #94a3b8;
  letter-spacing: 0.05em;
}

.code-input {
  flex: 1;
  background: #1e293b;
  /* VS Code-like bg */
  color: #e2e8f0;
  border: none;
  border-radius: 0;
  padding: 20px;
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 15px;
  line-height: 1.6;
  resize: none;
}

.code-input:focus {
  border: none;
  outline: none;
  background: #233044;
}

.run-btn {
  border-radius: 6px;
  padding: 8px 20px;
  font-size: 14px;
  background: #1e293b;

}

.run-btn:hover {
  background: #293850;
}


/* Instructions Panel (Bottom Right) */
.instructions-panel {
  flex: 1;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid #e2e8f0;
  overflow-y: auto;
}

.instructions-panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--text-muted);
}

.cmd-grid-compact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.cmd-grid-compact div {
  font-family: 'Monaco', monospace;
  font-size: 13px;
  color: var(--primary);
  background: #f1f5f9;
  padding: 8px;
  border-radius: 6px;
}

.cmd-grid-compact small {
  display: block;
  font-family: var(--font-sans);
  color: var(--text-muted);
  font-size: 11px;
}

.level-status-row {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
  font-weight: 700;
  font-size: 18px;
}

.level-status-row span {
  color: var(--primary);
  font-size: 24px;
}


/* Responsive */
@media (max-width: 1000px) {
  .cockpit-layout {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
  }

  .cockpit-sim {
    height: 500px;
  }

  .code-panel {
    height: 400px;
  }
}

/* Responsive adjustments */
@media (max-width: 900px) {

  .detail-section,
  .detail-section:nth-child(even) {
    grid-template-columns: 1fr;
    gap: 40px;
    direction: ltr;
    /* Reset direction */
  }

  .hero {
    height: auto;
    padding: 120px 0;
  }

  .hero__title {
    font-size: 48px;
  }
}


/* ========================================
   CATALOG PAGE STYLES
   ======================================== */

/* Catalog Hero */
.catalog-hero {
  position: relative;
  padding: 100px 0 80px;
  overflow: hidden;
}

.catalog-hero__bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
  z-index: -1;
}

.catalog-hero__bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(37, 99, 235, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 80% 50%, rgba(124, 58, 237, 0.2) 0%, transparent 50%);
}

.catalog-hero__bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.5;
}

.catalog-hero__content {
  text-align: center;
}

.catalog-hero__title {
  font-size: clamp(36px, 6vw, 64px);
  font-weight: 800;
  color: #fff;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.catalog-hero__subtitle {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
  font-weight: 400;
}

/* Catalog Section */
.catalog-section {
  padding: 60px 0;
}

/* Catalog Block */
.catalog-block {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 40px;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.catalog-block:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.catalog-block__header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--bg-body);
}

.catalog-block__icon {
  font-size: 48px;
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--primary-light) 0%, #e0e7ff 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.catalog-block__title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 4px;
}

.catalog-block__desc {
  font-size: 15px;
  color: var(--text-muted);
  margin: 0;
}

/* Product Grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

/* Product Card */
.product-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid #e2e8f0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: block;
  position: relative;
}

.product-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
  border-color: var(--primary);
}

.product-card--featured {
  border: 2px solid var(--primary);
}

.product-card__badge {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-purple) 100%);
  color: #fff;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.product-card__image {
  position: relative;
  height: 200px;
  overflow: hidden;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

.product-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
  transition: transform 0.5s ease;
}

.product-card:hover .product-card__image img {
  transform: scale(1.1);
}

.product-card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.8) 0%, transparent 50%);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.product-card:hover .product-card__overlay {
  opacity: 1;
}

.product-card__view {
  background: #fff;
  color: var(--text-main);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 600;
  transform: translateY(10px);
  transition: transform 0.3s ease;
}

.product-card:hover .product-card__view {
  transform: translateY(0);
}

.product-card__content {
  padding: 24px;
}

.product-card__name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 8px;
}

.product-card__info {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 16px;
  line-height: 1.5;
}

.product-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Tags */
.tag {
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
}

.tag--blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.tag--green {
  background: #dcfce7;
  color: #16a34a;
}

.tag--purple {
  background: #ede9fe;
  color: #7c3aed;
}

.tag--orange {
  background: #ffedd5;
  color: #ea580c;
}

.tag--cyan {
  background: #cffafe;
  color: #0891b2;
}

.tag--pink {
  background: #fce7f3;
  color: #db2777;
}

.tag--yellow {
  background: #fef9c3;
  color: #ca8a04;
}

/* Catalog Stats */
.catalog-stats {
  padding: 60px 0 80px;
  background: linear-gradient(180deg, var(--bg-body) 0%, #e2e8f0 100%);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
}

.stat-card__number {
  font-size: 48px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-purple) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 8px;
}

.stat-card__label {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Footer styles */
.site-footer {
  background: #0f172a;
  padding: 24px 0;
}

.footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.muted {
  color: #64748b;
  font-size: 14px;
}

/* Category Page (legacy support) */
.category-page {
  padding: 40px 0 80px;
}

.category-page__back {
  margin-bottom: 32px;
  display: inline-block;
}

.page-title {
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 800;
  margin: 0 0 48px;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--text-main), var(--text-muted));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.category-row {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 24px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
  transition: all 0.3s ease;
}

.category-row:hover {
  transform: translateX(8px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.category-row__name {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-main);
}

/* Responsive */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .product-grid {
    grid-template-columns: 1fr;
  }

  .catalog-block {
    padding: 24px;
  }

  .catalog-block__header {
    flex-direction: column;
    text-align: center;
  }
}

/* ========================================
   МОБИЛЬНЫЕ ФИКСЫ:
   границы сайта, перенос текста,
   ограничение видео/изображений
   ======================================== */
img,
video,
canvas,
iframe {
  max-width: 100%;
  height: auto;
}

pre,
code,
textarea {
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: pre-wrap;
}

.code-input {
  white-space: pre;
  overflow: auto;
}

.detail-title,
.hero__title,
.catalog-hero__title,
.section__title,
.product-card__name {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.video-card,
.video-card__fake {
  max-width: 100%;
}

/* Кнопка "Наверх" — глобальная плавающая */
.to-top-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--text-main);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: transform 0.2s ease, opacity 0.2s ease;
  opacity: 0.9;
}

.to-top-btn:hover {
  transform: translateY(-3px);
  background: var(--primary);
  opacity: 1;
}

.to-top-btn.visible {
  display: flex;
}

@media (max-width: 768px) {
  .to-top-btn {
    width: 44px;
    height: 44px;
    right: 14px;
    bottom: 14px;
    font-size: 20px;
  }
}

/* Доп. адаптация под телефон */
@media (max-width: 768px) {
  .container {
    width: min(100% - 24px, var(--container-width));
  }

  .detail-section {
    margin-bottom: 60px;
    gap: 24px;
  }

  .text-block {
    font-size: 18px;
  }

  .big-paragraph {
    font-size: 16px;
    line-height: 1.6;
  }

  .btn {
    padding: 10px 18px;
    font-size: 14px;
  }

  .btn-row {
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 40px;
  }

  .footer-row {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  .header-nav {
    gap: 16px;
  }

  /* Чтобы Симулятор не вылезал за границы */
  .cockpit-sim {
    height: 380px;
  }

  .code-panel {
    height: 320px;
  }

  .code-input {
    font-size: 13px;
    padding: 14px;
  }

  .instructions-panel {
    padding: 14px;
  }

  .cmd-grid-compact {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .detail-title {
    font-size: 28px;
    margin: 24px 0 32px;
  }

  .section__title {
    font-size: 22px;
  }
}