/* ============================================================
   RESPONSIVE.CSS — Mobile-first responsive overrides
   LiveJS Playground © 2025

   Breakpoints:
     1024px  tablet landscape
      768px  tablet portrait
      640px  large phone
      480px  small phone
      360px  tiny phone
   ============================================================ */

/* ══════════════════════════════════════════════════════════════
   LANDING — NAVIGATION
══════════════════════════════════════════════════════════════ */

/* Hamburger button (hidden on desktop) */
.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.2s;
}
.nav-hamburger:hover { background: var(--surface2); }
.nav-hamburger span {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: all 0.25s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile drawer */
.nav-drawer {
  display: none;
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px 24px;
  z-index: 199;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-lg);
  transform: translateY(-10px);
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
}
.nav-drawer.open {
  display: flex;
  transform: translateY(0);
  opacity: 1;
}
.nav-drawer a {
  display: block;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-drawer a:hover { background: var(--surface2); color: var(--text); }
.nav-drawer .drawer-sep {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}
.nav-drawer .drawer-cta {
  display: block;
  text-align: center;
  margin-top: 8px;
  padding: 13px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  box-shadow: 0 0 20px var(--accent-glow);
}

/* ── ≤640px: show hamburger, hide desktop links ── */
@media (max-width: 640px) {
  .nav { padding: 0 16px; height: 56px; }
  .nav-links { display: none; }
  .nav-hamburger { display: flex; }
  .nav-actions .btn { display: none; }  /* replaced by drawer CTA */
  .nav-drawer { top: 56px; }
}


/* ══════════════════════════════════════════════════════════════
   LANDING — HERO
══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .hero { padding: 72px 20px 60px; }
  .hero-title { letter-spacing: -2px; }
  .hero-stats { gap: 28px; margin-top: 40px; }
  .stat-val { font-size: 20px; }
  .preview-wrap { margin-top: 52px; }
  .hero-shell { grid-template-columns: 1fr; gap: 28px; }
  .hero-copy { max-width: none; }
  .hero-proof { grid-template-columns: 1fr; }
  .hero-stage { gap: 14px; }
  .hero-learn-strip { grid-template-columns: 1fr; }
  .value-grid { grid-template-columns: 1fr; }
  .learn-section { padding: 72px 0; }
  .learn-shell { grid-template-columns: 1fr; }
  .learn-overview { position: static; }
  .themes-grid-compact { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .hero { padding: 56px 16px 48px; }
  .hero-badge { font-size: 12px; padding: 5px 13px; margin-bottom: 24px; }
  .hero-title { letter-spacing: -1.5px; margin-bottom: 20px; }
  .hero-desc  { font-size: 15px; margin-bottom: 32px; }
  .hero-cta   { gap: 10px; }
  .hero-cta   { justify-content: flex-start; }
  .hero-cta .btn-lg { padding: 12px 24px; font-size: 15px; }
  .hero-stats { gap: 20px; flex-wrap: wrap; justify-content: center; }
  .preview-wrap { margin-top: 40px; }
  .preview-topbar { padding: 0 12px; }
  .preview-filename { display: none; }
  .preview-actions { display: none; }
  .preview-code-area { padding: 16px 14px; font-size: 12px; }
  .hero-glow-2, .hero-glow-3 { display: none; }
  .value-card { padding: 22px; }
  .learn-card { min-height: auto; padding: 22px; }
  .learn-card h3 { font-size: 24px; }
}

@media (max-width: 420px) {
  .hero { padding: 48px 14px 40px; }
  .hero-cta { flex-direction: column; width: 100%; }
  .hero-cta .btn { width: 100%; justify-content: center; }
  .hero-stats { gap: 16px; }
  .learn-actions { flex-direction: column; }
  .learn-actions .btn { width: 100%; }
}


/* ══════════════════════════════════════════════════════════════
   LANDING — SECTIONS padding
══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .features-section,
  .themes-section     { padding: 72px 0; }
  .how-section        { padding: 72px 0; }
  .cta-section        { padding: 80px 0; }
  .section-header     { margin-bottom: 44px; }
  .steps-grid         { margin-top: 44px; }
  .themes-grid        { margin-top: 44px; }
}

@media (max-width: 480px) {
  .features-section,
  .themes-section     { padding: 56px 0; }
  .how-section        { padding: 56px 0; }
  .cta-section        { padding: 60px 0; }
  .section-header     { margin-bottom: 32px; }
  .section-title      { letter-spacing: -1px; }
  .section-desc       { font-size: 15px; }
}


/* ══════════════════════════════════════════════════════════════
   LANDING — FEATURES GRID
══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .features-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
}
@media (max-width: 560px) {
  .features-grid { grid-template-columns: 1fr; gap: 12px; }
  .feature-card  { padding: 22px 20px; }
  .feature-icon-wrap { width: 42px; height: 42px; font-size: 20px; margin-bottom: 16px; }
}


/* ══════════════════════════════════════════════════════════════
   LANDING — HOW IT WORKS
══════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
  .steps-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .steps-grid::after { display: none; }
  .step-card { flex-direction: row; text-align: left; gap: 20px; align-items: flex-start; }
  .step-number { width: 48px; height: 48px; font-size: 18px; flex-shrink: 0; }
  .step-card h3 { font-size: 15px; }
}

@media (max-width: 420px) {
  .step-card { flex-direction: column; text-align: center; gap: 14px; align-items: center; }
}


/* ══════════════════════════════════════════════════════════════
   LANDING — THEMES GRID
══════════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
  .themes-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}
@media (max-width: 480px) {
  .themes-grid { grid-template-columns: 1fr; gap: 10px; }
  .theme-preview { height: 80px; }
  .themes-grid-compact { grid-template-columns: 1fr; }
}


/* ══════════════════════════════════════════════════════════════
   LANDING — CTA
══════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .cta-section h2 { letter-spacing: -1px; }
  .cta-section p  { font-size: 15px; margin-bottom: 32px; }
  .cta-buttons    { flex-direction: column; align-items: center; gap: 10px; }
  .cta-buttons .btn { width: 100%; max-width: 280px; justify-content: center; }
  .cta-note { font-size: 12px; }
}


/* ══════════════════════════════════════════════════════════════
   LANDING — FOOTER
══════════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  .footer-top { grid-template-columns: 1fr; gap: 28px; padding: 40px 0 28px; }
  .footer-brand p { max-width: 100%; }
  .footer-bottom { flex-direction: column; align-items: flex-start; gap: 12px; }
  .footer-legal  { flex-wrap: wrap; gap: 16px; }
}

@media (max-width: 480px) {
  .footer-top { padding: 32px 0 24px; }
  .footer-badges { gap: 6px; }
  .footer-badge  { font-size: 11px; }
}


/* ══════════════════════════════════════════════════════════════
   EDITOR — TOPBAR
══════════════════════════════════════════════════════════════ */

/* 860px: hide file tab and some separators */
@media (max-width: 860px) {
  .tb-file-tab { display: none; }
  .tb-sep.sep-file { display: none; }
}

/* 680px: hide theme select label text, shrink */
@media (max-width: 680px) {
  .tb-select { min-width: 90px; font-size: 11px; }
  .tb-run-btn kbd { display: none; }
  .tb-back-btn span { display: none; }
  .tb-back-btn::before { content: '←'; }
}

/* 520px: hide theme select, hide back text */
@media (max-width: 520px) {
  .editor-topbar { padding: 0 10px; gap: 5px; height: 48px; }
  .tb-select { display: none; }
  .tb-sep.sep-theme { display: none; }
  .tb-logo { font-size: 15px; padding: 4px 6px; }
  .tb-run-btn { padding: 0 12px; font-size: 12px; }
  .tb-mode-btn { width: 28px; height: 28px; font-size: 13px; }
  .tb-back-btn { height: 28px; padding: 0 8px; }
  .tb-autorun { gap: 5px; }
}

/* 400px: minimal topbar */
@media (max-width: 400px) {
  .tb-autorun { display: none; }
  .tb-sep.sep-autorun { display: none; }
  .tb-back-btn { display: none; }
}


/* ══════════════════════════════════════════════════════════════
   EDITOR — MOBILE LAYOUT (vertical stacking)
   Below 700px: stack editor on top, console on bottom.
   A touch-friendly horizontal drag handle separates them.
   Below 520px: tab-based switching (Editor / Console).
══════════════════════════════════════════════════════════════ */

/* ── 700px: vertical layout ── */
@media (max-width: 700px) {
  .editor-layout {
    flex-direction: column;
    height: calc(100vh - 48px);
  }

  .editor-panel {
    flex: none;
    height: 55%;
    width: 100% !important;
    min-width: 0;
    border-bottom: none;
  }

  .editor-divider {
    width: 100%;
    height: 6px;
    cursor: row-resize;
    background: var(--border);
    position: relative;
    flex-shrink: 0;
    touch-action: none;
  }
  .editor-divider::after { inset: -8px 0; } /* larger touch target */
  .editor-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 3px;
    background: var(--border-strong);
    border-radius: 2px;
  }
  .editor-divider:hover,
  .editor-divider.dragging { background: var(--accent); }
  .editor-divider.dragging::before { background: var(--accent-light); }

  .output-panel {
    width: 100% !important;
    min-width: 0;
    max-width: 100%;
    flex: 1;
  }
}

/* ── 520px: full tab-based layout ── */
@media (max-width: 520px) {
  .editor-layout {
    flex-direction: column;
    height: calc(100vh - 48px - 44px); /* minus topbar minus tab bar */
    position: relative;
  }

  /* hide the drag divider on tiny screens */
  .editor-divider { display: none; }

  /* panels become full size, one shown at a time via JS class */
  .editor-panel,
  .output-panel {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    flex: none;
    transition: opacity 0.2s, transform 0.2s;
  }
  .editor-panel.tab-hidden,
  .output-panel.tab-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(16px);
  }

  /* Bottom tab bar */
  .mobile-tab-bar {
    display: flex !important;
    height: 44px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
  }
  .mobile-tab-bar-wrap {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 48px);
    overflow: hidden;
  }

  /* editor layout fills remaining space above tab bar */
  .mobile-tab-bar-wrap .editor-layout {
    flex: 1;
    height: auto;
  }
}

/* Mobile tab bar (hidden on desktop) */
.mobile-tab-bar {
  display: none;
  position: relative;
}
.mob-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: var(--sans);
  transition: color 0.15s, background 0.15s;
  border-top: 2px solid transparent;
  padding: 0 8px;
}
.mob-tab:hover { color: var(--text-secondary); background: var(--surface2); }
.mob-tab.active {
  color: var(--accent-light);
  border-top-color: var(--accent);
  background: var(--accent-subtle);
}
.mob-tab svg { width: 15px; height: 15px; flex-shrink: 0; }
.mob-tab-badge {
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
}


/* ══════════════════════════════════════════════════════════════
   EDITOR — LOG LINES on mobile
══════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
  .log-line {
    font-size: 12px;
    padding: 6px 12px;
    gap: 8px;
  }
  #empty-hint { font-size: 12px; padding: 24px 16px; }
  .empty-icon { font-size: 28px; }
}

@media (max-width: 520px) {
  .log-line { font-size: 11.5px; padding: 5px 10px; }
  .panel-tabs { padding: 0 8px; }
  .panel-tab  { padding: 0 10px; font-size: 11px; }
}


/* ══════════════════════════════════════════════════════════════
   GLOBAL — Touch improvements
══════════════════════════════════════════════════════════════ */
@media (hover: none) {
  /* Remove hover-only transforms on touch devices */
  .feature-card:hover  { transform: none; }
  .theme-card:hover    { transform: none; }
  .btn-primary:hover   { transform: none; }

  /* Larger tap targets */
  .btn { min-height: 44px; }
  .btn-lg { min-height: 50px; }
  .mob-tab { min-height: 44px; }
  .nav-drawer a { min-height: 44px; display: flex; align-items: center; }
  .out-action-btn { height: 30px; padding: 0 14px; }
  .tb-run-btn { height: 36px; }
  .tb-mode-btn { width: 36px; height: 36px; }
  .tb-back-btn { height: 36px; }

  /* Disable cursor animations on touch */
  .editor-divider { cursor: default; }
}


/* ══════════════════════════════════════════════════════════════
   GLOBAL — Reduce motion
══════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .badge-dot { animation: none; }
  html { scroll-behavior: auto; }
}


/* ══════════════════════════════════════════════════════════════
   GLOBAL — Print
══════════════════════════════════════════════════════════════ */
@media print {
  .nav, footer, .hero-cta, .cta-section { display: none; }
  body { background: white; color: black; }
}
