/* ============================================================
   SOJU88 — Mobile-First Master Responsive Fix
   Menggabungkan & memperbaiki semua isu responsif secara terpusat
   ============================================================ */

/* ── Safe area support (iPhone X+) ── */
:root {
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

/* ── Base fix: pastikan tidak ada overflow horizontal ── */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}

*, *::before, *::after {
  box-sizing: border-box;
}

/* ── Container fluid padding ── */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding-left: max(16px, var(--safe-left));
  padding-right: max(16px, var(--safe-right));
}

/* ── Images & media always fit ── */
img, video, iframe, embed {
  max-width: 100%;
  height: auto;
}

/* ============================================================
   NAVIGATION — Mobile hamburger & overlay
   ============================================================ */

/* Desktop nav hidden below 900px */
@media (max-width: 900px) {
  .main-nav,
  .navbar__nav,
  .nav-menu {
    display: none !important;
  }

  .hamburger,
  .navbar__hamburger,
  .nav-toggle {
    display: flex !important;
  }

  /* Pastikan header CTA tetap rapi */
  .header-cta {
    gap: 8px;
  }

  /* Sembunyikan teks Discord di header, hanya icon */
  .header-cta .btn.btn-primary.btn-sm {
    padding: 8px 12px;
    font-size: 0;          /* sembunyikan teks */
    gap: 0;
    min-width: 38px;
    min-height: 38px;
    border-radius: 50%;
  }
  .header-cta .btn.btn-primary.btn-sm .icon {
    font-size: 1rem;       /* tampilkan icon saja */
  }
}

/* Mobile nav overlay */
.mobile-nav {
  display: none;
  position: fixed;
  top: 72px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 10, 15, 0.97);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  padding: 24px 20px calc(24px + var(--safe-bottom));
  overflow-y: auto;
  z-index: 899;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}

.mobile-nav.open {
  display: flex;
  animation: slideDown 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-secondary, #94a3b8);
  border: 1px solid rgba(255, 255, 255, 0.07);
  transition: all 0.3s ease;
  min-height: 52px; /* touch target */
}

.mobile-nav-link:hover,
.mobile-nav-link:active {
  color: var(--text-primary, #f1f5f9);
  border-color: rgba(124, 58, 237, 0.4);
  background: rgba(124, 58, 237, 0.12);
}

/* Hamburger animation */
.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: translateX(-8px); }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ============================================================
   HERO SECTION — Mobile
   ============================================================ */

@media (max-width: 900px) {
  .hero {
    padding: 80px 0 60px !important;
    min-height: auto !important;
    text-align: center;
  }

  .hero-content {
    max-width: 100%;
    text-align: center;
  }

  .hero-badge {
    margin: 0 auto 20px;
    display: inline-flex;
  }

  .hero h1,
  .hero-title {
    font-size: clamp(1.9rem, 6vw, 3rem) !important;
  }

  .hero-desc,
  .hero-subtitle {
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
  }

  .hero-actions {
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
  }

  /* Stats: 2 kolom di mobile */
  .hero-stats {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
    padding: 20px !important;
  }

  .stat-divider {
    display: none !important;
  }
}

@media (max-width: 480px) {
  .hero {
    padding: 72px 0 48px !important;
  }

  .hero h1,
  .hero-title {
    font-size: clamp(1.6rem, 7.5vw, 2.2rem) !important;
    line-height: 1.2;
  }

  .hero-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .hero-stats {
    padding: 16px !important;
    gap: 10px;
  }
}

/* ============================================================
   GRID SYSTEMS — All breakpoints
   ============================================================ */

/* Tablet landscape (900–1100px) */
@media (max-width: 1100px) {
  .grid-4             { grid-template-columns: repeat(2, 1fr) !important; }
  .internal-links-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .footer-grid        { grid-template-columns: 1fr 1fr !important; gap: 2rem !important; }
  .footer-brand       { grid-column: 1 / -1; }
}

/* Tablet portrait (768–900px) */
@media (max-width: 900px) {
  .grid-3             { grid-template-columns: repeat(2, 1fr) !important; }
  .grid-4             { grid-template-columns: repeat(2, 1fr) !important; }
  .news-grid          { grid-template-columns: repeat(2, 1fr) !important; }
  .reviews-grid       { grid-template-columns: repeat(2, 1fr) !important; }
  .authors-grid       { grid-template-columns: 1fr !important; }
  .trending-reviews-grid { grid-template-columns: 1fr !important; }
  .content-layout     { grid-template-columns: 1fr !important; }
  .sidebar            { display: none; }
}

/* Mobile (≤ 640px) */
@media (max-width: 640px) {
  .grid-2,
  .grid-3,
  .grid-4,
  .news-grid,
  .reviews-grid       { grid-template-columns: 1fr !important; }
  .authors-grid       { grid-template-columns: 1fr !important; }
  .trending-reviews-grid { grid-template-columns: 1fr !important; }
  .internal-links-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* Extra small (≤ 360px) */
@media (max-width: 360px) {
  .internal-links-grid { grid-template-columns: 1fr !important; }
}

/* ============================================================
   CARDS — Mobile improvements
   ============================================================ */

@media (max-width: 640px) {
  .card-body,
  .guide-card-body,
  .review-card-body,
  .news-card-body {
    padding: 16px !important;
  }

  .card-img-wrap,
  .card-img-wrap-sm,
  .card-img-wrap-news {
    height: auto !important;
    aspect-ratio: 16 / 9;
  }

  /* Review cards: lebih kecil di mobile */
  .card-img-wrap-sm  { height: 160px !important; aspect-ratio: unset; }
  .card-img-wrap-news { height: 180px !important; aspect-ratio: unset; }

  .guide-card-img { height: auto !important; }

  /* Author mini row */
  .guide-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

/* ============================================================
   SECTIONS — Mobile padding
   ============================================================ */

@media (max-width: 767px) {
  .section     { padding: 60px 0 !important; }
  .section-sm  { padding: 44px 0 !important; }
  .section-padding { padding: 60px 0 !important; }
  .section-header  { margin-bottom: 36px !important; text-align: center; }

  .page-hero {
    padding: 96px 0 40px !important;
    text-align: center;
  }
}

@media (max-width: 480px) {
  h2.section-title,
  .section-title {
    font-size: clamp(1.4rem, 5vw, 1.9rem) !important;
    line-height: 1.3;
  }
}

/* ============================================================
   NEWSLETTER — Mobile stack
   ============================================================ */

@media (max-width: 900px) {
  .newsletter-inner,
  .nl-inner {
    flex-direction: column !important;
    gap: 24px !important;
  }

  .newsletter-text,
  .newsletter-form,
  .nl-text,
  .nl-form {
    max-width: 100% !important;
    width: 100% !important;
    flex: none !important;
    min-width: 0 !important;
  }
}

@media (max-width: 640px) {
  .newsletter-input-group,
  .nl-group {
    flex-direction: column !important;
    border-radius: 12px !important;
    overflow: hidden;
  }

  .newsletter-input,
  .nl-input {
    border-radius: 10px 10px 0 0 !important;
    padding: 14px 16px !important;
  }

  .newsletter-btn,
  .nl-btn {
    border-radius: 0 0 10px 10px !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 14px !important;
    width: 100%;
  }
}

/* ============================================================
   FOOTER — Mobile
   ============================================================ */

@media (max-width: 767px) {
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }

  .footer-bottom {
    flex-direction: column !important;
    text-align: center !important;
    gap: 12px !important;
  }

  .footer-bottom-links {
    justify-content: center !important;
    flex-wrap: wrap;
  }

  .footer-social {
    justify-content: flex-start;
  }
}

/* ============================================================
   AUTHOR BOX — Mobile
   ============================================================ */

@media (max-width: 640px) {
  .author-box {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
  }

  .author-credentials,
  .author-social {
    justify-content: center !important;
  }

  .author-card {
    flex-direction: column !important;
    padding: 20px !important;
  }

  .author-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }
}

/* ============================================================
   BUTTONS — Mobile touch targets
   ============================================================ */

@media (max-width: 480px) {
  .btn {
    padding: 12px 20px !important;
    font-size: 0.875rem !important;
    min-height: 44px; /* WCAG touch target */
  }

  .btn-sm {
    padding: 10px 16px !important;
    font-size: 0.8rem !important;
  }
}

/* ============================================================
   BREADCRUMB — Mobile
   ============================================================ */

@media (max-width: 480px) {
  .breadcrumb {
    font-size: 0.75rem;
  }
}

/* ============================================================
   FAQ — Mobile
   ============================================================ */

@media (max-width: 640px) {
  .faq-question {
    padding: 16px 18px !important;
    font-size: 0.9rem !important;
  }

  .faq-answer-inner,
  .faq-a-inner {
    padding: 0 18px 16px !important;
  }
}

/* ============================================================
   INTERNAL LINKS GRID — responsive icons
   ============================================================ */

@media (max-width: 640px) {
  .internal-link-card .il-icon {
    width: 52px !important;
    height: 52px !important;
    font-size: 2rem !important;
  }
}

/* ============================================================
   LANG CSS override for mobile (lang pages)
   ============================================================ */

@media (max-width: 900px) {
  .lang-banner {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .lang-banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .all-langs {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important;
    gap: 10px !important;
  }
}

/* ============================================================
   TABLE — horizontal scroll on mobile
   ============================================================ */

table {
  min-width: 480px;
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   CONTENT LAYOUT (article + sidebar)
   ============================================================ */

@media (max-width: 1024px) {
  .content-layout {
    grid-template-columns: 1fr !important;
  }

  .content-layout aside,
  .content-layout .sidebar {
    display: none;
  }
}

/* ============================================================
   CTA SECTION — Mobile padding
   ============================================================ */

@media (max-width: 640px) {
  .cta-section {
    padding: 48px 24px !important;
  }
}

/* ============================================================
   SCROLL-TO-TOP — safe area
   ============================================================ */

#scroll-top,
.scroll-top {
  bottom: calc(24px + var(--safe-bottom));
  right: calc(24px + var(--safe-right));
}

/* ============================================================
   TOUCH DEVICE — disable hover transforms (prevent stuck states)
   ============================================================ */

@media (hover: none) and (pointer: coarse) {
  .card:hover,
  .glass-card:hover,
  .news-card:hover,
  .review-card:hover,
  .guide-card:hover {
    transform: none !important;
    box-shadow: var(--shadow-card, 0 4px 24px rgba(0,0,0,.4)) !important;
  }

  .btn:hover {
    transform: none !important;
  }

  .social-link:hover,
  .social-a:hover {
    transform: none !important;
  }
}

/* ============================================================
   ACCESSIBILITY — prefers-reduced-motion
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  html { scroll-behavior: auto; }

  .orb,
  .particle,
  .hero-orb {
    animation: none !important;
  }
}

/* ============================================================
   LARGE DESKTOP — max container
   ============================================================ */

@media (min-width: 1440px) {
  .container {
    max-width: 1380px;
  }
}

/* ============================================================
   PRINT — hide nav & footer
   ============================================================ */

@media print {
  .site-header,
  .site-footer,
  .hamburger,
  .mobile-nav,
  #scroll-top,
  .scroll-top {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  a {
    color: inherit;
  }
}
