/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE.CSS — Mobile-first breakpoint overrides
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Base mobile resets ──────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

img,
video,
canvas {
  max-width: 100%;
  height: auto;
}

/* ── Touch: disable custom cursor ────────────────────────────────────────── */
@media (pointer: coarse) {
  body,
  a,
  button,
  [role="button"],
  label {
    cursor: auto !important;
  }
  #anime-cursor-wrap {
    display: none !important;
  }
}

/* ── < 480px — small phones ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  .container {
    padding: 0 1rem;
  }
  .section-pad {
    padding: 3.5rem 0;
  }

  h1.hero-title {
    font-size: clamp(2rem, 9vw, 2.8rem) !important;
  }

  /* Single column everywhere */
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  [style*="grid-template-columns: 1fr 380px"],
  [style*="grid-template-columns:1fr 380px"] {
    grid-template-columns: 1fr !important;
  }
  [style*="grid-template-columns: 1fr 320px"],
  [style*="grid-template-columns:1fr 320px"] {
    grid-template-columns: 1fr !important;
  }

  /* Stack flex rows */
  [style*="display:flex"][style*="gap"],
  [style*="display: flex"][style*="gap"] {
    flex-wrap: wrap;
  }

  .btn-anime,
  .btn-outline {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    width: 100%;
    justify-content: center;
  }

  /* OTP boxes */
  .otp-input {
    width: 2.5rem;
    height: 3rem;
    font-size: 1.25rem;
  }

  /* Hide 3D canvases on very small screens */
  #hero-canvas,
  #about-canvas,
  #contact-canvas {
    display: none;
  }

  /* Reduce particle canvases opacity */
  #sparkle-canvas,
  #sakura-canvas {
    opacity: 0.4;
  }

  /* Auth card */
  .auth-card {
    padding: 1.5rem !important;
    border-radius: 1rem !important;
  }

  /* Admin sidebar collapse by default */
  .sidebar {
    width: 0;
    overflow: hidden;
  }
  .sidebar.mobile-open {
    width: 260px;
    position: fixed;
    z-index: 999;
    height: 100vh;
  }
}

/* ── < 640px — phones ────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .container {
    padding: 0 1.25rem;
  }

  /* Nav */
  #navbar .hidden.md\\:flex {
    display: none !important;
  }

  /* Project/blog grids — 1 col */
  [style*="grid-template-columns: repeat(auto-fill, minmax(300px"],
  [style*="grid-template-columns:repeat(auto-fill,minmax(300px"] {
    grid-template-columns: 1fr !important;
  }
  [style*="grid-template-columns: repeat(auto-fit, minmax(300px"],
  [style*="grid-template-columns:repeat(auto-fit,minmax(300px"] {
    grid-template-columns: 1fr !important;
  }

  /* Featured blog hero — stack */
  .featured-blog-grid {
    grid-template-columns: 1fr !important;
  }
  .featured-blog-grid img {
    height: 200px;
    border-radius: 1rem 1rem 0 0 !important;
  }

  /* Project show — remove sticky sidebar */
  [style*="grid-template-columns: 1fr 320px"],
  [style*="grid-template-columns:1fr 320px"] {
    grid-template-columns: 1fr !important;
  }
  [style*="position:sticky"],
  [style*="position: sticky"] {
    position: static !important;
  }

  /* Admin table — horizontal scroll */
  .admin-card {
    overflow-x: auto;
  }
  .admin-table {
    min-width: 600px;
  }

  /* Footer grid */
  footer [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
}

/* ── < 768px — tablets portrait ──────────────────────────────────────────── */
@media (max-width: 768px) {
  /* About split */
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }

  /* Services grid — 2 cols */
  [style*="grid-template-columns: repeat(auto-fit, minmax(300px"] {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)) !important;
  }

  /* Reduce hero height */
  section[style*="min-height:100vh"] {
    min-height: 90vh !important;
    padding-top: 5rem !important;
  }

  /* Smaller section tags */
  .section-tag {
    font-size: 0.72rem;
  }

  /* Timeline — single column */
  .timeline-item {
    flex-direction: column;
  }

  /* Admin layout — sidebar overlay mode */
  .sidebar {
    position: fixed;
    z-index: 999;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  body.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
  }
  .flex-1.min-w-0 {
    width: 100%;
  }

  /* Topbar adjustments */
  .topbar {
    padding: 0 1rem;
  }

  /* Charts responsive */
  canvas[id$="Chart"] {
    max-height: 220px;
  }

  /* Particle canvas — reduce opacity on mobile */
  #sparkle-canvas {
    opacity: 0.5;
  }
  #sakura-canvas {
    opacity: 0.5;
  }
}

/* ── < 1024px — tablets landscape ────────────────────────────────────────── */
@media (max-width: 1024px) {
  /* 3-col admin stats → 2 col */
  .grid.grid-cols-2.lg\\:grid-cols-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Dashboard charts — stack */
  .grid.grid-cols-1.lg\\:grid-cols-3 {
    grid-template-columns: 1fr !important;
  }

  /* Contact page — stack */
  [style*="grid-template-columns: 1fr 380px"] {
    grid-template-columns: 1fr !important;
  }

  /* Sidebar in admin — collapsed by default */
  .sidebar {
    width: 70px;
  }
  .sidebar .nav-label,
  .sidebar .brand-text,
  .sidebar .nav-badge {
    display: none;
  }
  .sidebar .nav-item {
    justify-content: center;
    padding: 0.75rem;
  }
}

/* ── Print ───────────────────────────────────────────────────────────────── */
@media print {
  #navbar,
  footer,
  #preloader,
  #anime-cursor-wrap,
  #sparkle-canvas,
  #sakura-canvas,
  #hero-canvas,
  .btn-anime,
  .btn-outline {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }
  .anime-card {
    border: 1px solid #ccc;
    box-shadow: none;
  }
}

/* ── 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;
  }
  #sparkle-canvas,
  #sakura-canvas {
    display: none;
  }
}

/* ── High contrast ───────────────────────────────────────────────────────── */
@media (prefers-contrast: high) {
  :root {
    --border-color: rgba(139, 92, 246, 0.6);
    --text-secondary: #c4c4c7;
  }
  .anime-card {
    border-width: 2px;
  }
  .btn-anime {
    outline: 2px solid white;
  }
}
