/* ============================================
   RESPONSIVE.CSS — Mobile-First Breakpoints
   ============================================ */

/* ── Mobile (< 480px) ── */
@media (max-width: 480px) {
  :root {
    --font-size-hero: 2rem;
    --font-size-3xl: 1.75rem;
    --container-padding: var(--space-4);
  }

  .hero {
    padding-block: var(--space-16) var(--space-12);
  }

  .hero__cta {
    flex-direction: column;
    align-items: center;
  }

  .hero__cta .btn {
    width: 100%;
    max-width: 300px;
  }
}

/* ── Small screens (max 768px) ── */
@media (max-width: 768px) {
  :root {
    --font-size-hero: 2.25rem;
    --font-size-3xl: 1.875rem;
    --header-height: 64px;
  }

  /* Header: show hamburger, hide nav links */
  .header__links {
    display: none;
  }

  .header__menu-toggle {
    display: flex;
  }

  /* Mobile nav overlay */
  .header__nav.mobile-open .header__links {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background-color: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-6);
    gap: var(--space-4);
    box-shadow: var(--shadow-lg);
  }

  /* Grids: single column */
  .simulators__grid,
  .content-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .stats__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
  }

  /* Footer: stack columns */
  .footer__grid {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }

  .footer__bottom {
    flex-direction: column;
    gap: var(--space-4);
    text-align: center;
  }

  /* Section spacing */
  .section {
    padding-block: var(--space-12);
  }

  .section__header {
    margin-bottom: var(--space-8);
  }
}

/* ── Tablet (481px - 1023px) ── */
@media (min-width: 481px) and (max-width: 1023px) {
  :root {
    --font-size-hero: 2.75rem;
  }

  .simulators__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Third card spans full on tablet for balance */
  .simulators__grid .sim-card:last-child {
    grid-column: 1 / -1;
    max-width: 400px;
    margin-inline: auto;
  }

  .content-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer__grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Desktop (1024px+) ── */
@media (min-width: 1024px) {
  .simulators__grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .content-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── Wide (1280px+) ── */
@media (min-width: 1280px) {
  :root {
    --container-padding: clamp(16px, 2.5vw, 32px);
  }
}

/* ── RTL Support (Arabic) ── */
[dir="rtl"] {
  direction: rtl;
}

[dir="rtl"] body {
  text-align: right;
}

/* RTL: Header */
[dir="rtl"] .header .container {
  flex-direction: row-reverse;
}

[dir="rtl"] .header__nav {
  flex-direction: row-reverse;
}

[dir="rtl"] .header__links {
  flex-direction: row-reverse;
}

[dir="rtl"] .header__actions {
  flex-direction: row-reverse;
}

/* RTL: Hero */
[dir="rtl"] .hero__content {
  text-align: center;
}

/* RTL: Sections - center alignment stays */
[dir="rtl"] .section__header {
  text-align: center;
}

/* RTL: Simulator cards */
[dir="rtl"] .sim-card {
  text-align: center;
}

[dir="rtl"] .sim-card__features {
  text-align: right;
}

[dir="rtl"] .sim-card__features li {
  padding-inline-start: var(--space-5);
  padding-inline-end: 0;
}

[dir="rtl"] .sim-card__features li::before {
  inset-inline-start: 0;
  inset-inline-end: auto;
}

/* RTL: Flip arrows */
[dir="rtl"] .sim-card__link-arrow,
[dir="rtl"] .btn svg {
  transform: scaleX(-1);
}

[dir="rtl"] .sim-card__link:hover .sim-card__link-arrow {
  transform: scaleX(-1) translateX(4px);
}

/* RTL: Content cards */
[dir="rtl"] .content-card {
  text-align: right;
}

[dir="rtl"] .content-card__meta {
  flex-direction: row-reverse;
  justify-content: flex-end;
}

/* RTL: Tab bar stays centered */
[dir="rtl"] .tab-bar {
  flex-direction: row-reverse;
}

/* RTL: Language dropdown */
[dir="rtl"] .lang-selector__dropdown {
  right: auto;
  left: 0;
}

[dir="rtl"] .lang-selector__option {
  text-align: right;
}

/* RTL: Footer */
[dir="rtl"] .footer__grid {
  direction: rtl;
}

[dir="rtl"] .footer__col-links {
  align-items: flex-start;
}

[dir="rtl"] .footer__bottom {
  flex-direction: row-reverse;
}

[dir="rtl"] .footer__bottom-links {
  flex-direction: row-reverse;
}

/* RTL: Back to top - inset-inline-end handles this via CSS already */

/* RTL: Mobile nav */
@media (max-width: 768px) {
  [dir="rtl"] .header__nav.mobile-open .header__links {
    align-items: flex-end;
  }
}

/* Responsive Simulator Modal */
@media (max-width: 480px) {
  .sim-modal__dialog {
    padding: var(--space-4);
  }
  .sim-modal__title {
    font-size: 1.2rem;
  }
  .sim-modal__rings {
    width: 90px;
    height: 90px;
  }
  .sim-modal__ring--outer {
    width: 90px;
    height: 90px;
  }
  .sim-modal__ring--mid {
    width: 72px;
    height: 72px;
  }
  .sim-modal__ring--inner {
    width: 56px;
    height: 56px;
  }
  .sim-modal__core-chip {
    width: 40px;
    height: 40px;
  }
  .sim-modal__chip-icon {
    width: 24px;
    height: 24px;
  }
  .sim-modal__terminal-stream {
    min-height: 100px;
    font-size: 0.72rem;
  }
}
