/* ===== RESET & ROOT ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f8f9fa;
  --bg-alt: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --accent: #14b8a6;
  --accent-light: rgba(20, 184, 166, 0.08);
  --border: #e5e7eb;
  --shadow: rgba(0, 0, 0, 0.04);
  --nav-h: 64px;
  --container-px: 1.5rem;
}

body.dark {
  --bg: #0f0f13;
  --bg-alt: #1a1a22;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --accent: #14b8a6;
  --accent-light: rgba(20, 184, 166, 0.06);
  --border: #2a2a35;
  --shadow: rgba(0, 0, 0, 0.15);
}

/* ===== BASE ===== */
html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
  overflow-x: hidden;
  word-break: break-word;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

img, video, iframe, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

a { color: inherit; }

/* ===== LAYOUT ===== */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--container-px);
}

/* ===== HEADER ===== */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-h);
  gap: 1rem;
}

/* ===== LOGO ===== */
.logo {
  text-decoration: none;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  z-index: 2;
}

.logo img {
  height: 36px;
  width: auto;
  display: block;
}

/* ===== DESKTOP NAV ===== */
nav {
  display: flex;
  align-items: center;
}

nav ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

nav a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
  display: block;
  /* Minimum tap target */
  min-height: 40px;
  display: flex;
  align-items: center;
}

nav a:hover { color: var(--accent); background: var(--accent-light); }
nav a.active { color: var(--accent); background: var(--accent-light); }

/* ===== DROPDOWN ===== */
.dropdown { position: relative; }

.dropdown.has-active > .dropdown-toggle {
  color: var(--accent);
  background: var(--accent-light);
}

.dropdown-toggle {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  user-select: none;
}

.dropdown-toggle i {
  font-size: 0.65rem;
  transition: transform 0.2s;
  pointer-events: none;
}

.dropdown.open .dropdown-toggle i { transform: rotate(180deg); }

.dropdown-menu {
  list-style: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 200px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.4rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  display: none;
  z-index: 100;
  /* Prevent overflow on small screens */
  max-width: calc(100vw - 2rem);
}

.dropdown.open .dropdown-menu {
  display: flex;
  flex-direction: column;
}

.dropdown-menu li { width: 100%; }

.dropdown-menu a {
  display: flex;
  align-items: center;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  white-space: nowrap;
  text-align: left;
  min-height: 40px;
  font-size: 0.85rem;
}

/* ===== HAMBURGER ===== */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  padding: 8px;
  background: none;
  border: none;
  border-radius: 8px;
  transition: background 0.2s;
  z-index: 55;
  /* Ensure proper tap target */
  min-width: 44px;
  min-height: 44px;
  align-items: center;
}

.hamburger:hover { background: var(--accent-light); }

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.25s, width 0.25s;
  transform-origin: center;
}

/* Hamburger → X animation */
.hamburger.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.hamburger.active span:nth-child(2) {
  opacity: 0;
  width: 0;
}
.hamburger.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ===== MOBILE MENU OVERLAY ===== */
/* Hidden checkbox trick removed — use JS class instead */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 41;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.mobile-overlay.active { display: block; }

/* First-section top offset to clear sticky header */
.page-hero {
  padding-top: clamp(3.5rem, 6vw, 5rem) !important;
}

/* ===== FOOTER ===== */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

footer p { margin-bottom: 0.25rem; }
footer p:last-child { margin-bottom: 0; }

/* ===== UTILITY ===== */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); border: 0;
}

.text-center { text-align: center; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* ===== SECTION TITLES ===== */
.section-title {
  font-size: clamp(1.3rem, 4vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  color: var(--text);
  position: relative;
  display: inline-block;
}

.section-title::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.section-title.reveal.visible::after,
.reveal.visible .section-title::after { width: 48px; }

.section-sub {
  font-size: clamp(0.85rem, 2.5vw, 0.95rem);
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  max-width: 560px;
  line-height: 1.6;
}

/* ===== THEME TOGGLE ===== */
#theme-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 40;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 12px var(--shadow);
  /* Always reachable above mobile nav */
}

#theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.1);
}

/* ===== SCROLL INDICATOR ===== */
#scroll-indicator {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  width: 0%;
  z-index: 60;
  transition: width 0.1s linear;
  border-radius: 0 2px 2px 0;
}

/* ===== REVEAL ANIMATIONS ===== */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }
.reveal-delay-5 { transition-delay: 0.5s; }
.reveal-delay-6 { transition-delay: 0.6s; }

/* ===== RESPONSIVE ===== */

/* ── Large screens: comfortable nav ── */
@media (max-width: 1100px) {
  nav a {
    padding: 0.45rem 0.75rem;
    font-size: 0.825rem;
  }
}

/* ── Medium: collapse to hamburger ── */
@media (max-width: 900px) {
  :root { --nav-h: 56px; }

  .hamburger { display: flex; }

  /* Slide-in mobile menu */
  nav {
    position: fixed;
    top: 0;
    right: -100%;
    bottom: 0;
    width: min(320px, 85vw);
    background: var(--bg-alt);
    border-left: 1px solid var(--border);
    padding: calc(var(--nav-h) + 1rem) 1rem 2rem;
    overflow-y: auto;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 45;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.08);
    /* Scrollable if many items */
    -webkit-overflow-scrolling: touch;
    visibility: hidden;
    pointer-events: none;
  }

  nav.open { right: 0; visibility: visible; pointer-events: auto; }

  nav ul {
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    width: 100%;
  }

  nav ul li { width: 100%; }

  nav a {
    padding: 0.8rem 1rem;
    border-radius: 10px;
    font-size: 0.95rem;
    min-height: 48px;
    width: 100%;
  }

  /* Dropdown inside mobile menu */
  .dropdown-menu {
    position: static;
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0 0 0.25rem 1rem;
    background: transparent;
    max-width: 100%;
    /* Always show when dropdown open on mobile */
  }

  .dropdown.open .dropdown-menu { display: flex; }

  .dropdown-menu a {
    white-space: normal;
    font-size: 0.875rem;
    padding: 0.6rem 0.75rem;
    min-height: 44px;
  }

  .logo img { height: 30px; }
}

/* ── Tablet ── */
@media (max-width: 768px) {
  :root { --container-px: 1rem; }

  .section-sub { margin-bottom: 1.75rem; }

  .hero {
    padding-top: 2rem;
    padding-bottom: 1.5rem;
    flex-direction: column;
    gap: 1.5rem;
  }

  .hero-content h2 { font-size: clamp(1.3rem, 5vw, 1.6rem); }
  .hero-video { margin-bottom: 1.5rem; max-width: 100%; }

  #theme-toggle {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
    bottom: 1rem;
    right: 1rem;
  }

  /* Section paddings */
  .about-section,
  .services-section,
  .gallery-section,
  .founder-section,
  .policies-section,
  .testimonials-section,
  .history-section,
  .timeline-section,
  .contact-section,
  .featured-section,
  .mv-section { padding-top: 2.5rem; padding-bottom: 2.5rem; }

  /* Grids → single column */
  .about-grid,
  .services-grid,
  .policies-grid,
  .testimonials-grid { grid-template-columns: 1fr; gap: 1rem; }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
  }

  .values-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }

  .founder-grid { grid-template-columns: 1fr; }
  .founder-img { text-align: center; }
  .founder-img img { max-width: 200px; margin: 0 auto; }

  .contact-grid { grid-template-columns: 1fr; gap: 1.25rem; }
  .featured-grid { grid-template-columns: 1fr; gap: 1.25rem; }
  .mv-grid { grid-template-columns: 1fr; gap: 1rem; }

  .product-image { height: 150px; }
  .carousel-slide img { aspect-ratio: 4/3; }

  .stats { gap: 1rem; }
  .stat h3 { font-size: 1.25rem; }

  .carousel-btn { width: 32px; height: 32px; font-size: 0.75rem; }

  /* Timeline mobile */
  .timeline-section .tl-line { left: 20px; }
  .timeline-section .tl-item {
    flex-direction: column;
    padding-left: 52px;
    gap: 0.75rem;
  }
  .timeline-section .tl-badge {
    left: 20px;
    top: 0;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    font-size: 0.65rem;
  }
  .timeline-section .tl-item:hover .tl-badge {
    transform: translateX(-50%) scale(1.08);
  }
  .timeline-section .tl-card,
  .timeline-section .tl-item:nth-child(odd) .tl-card {
    width: 100%;
    margin: 0;
  }
}

/* ── Phone ── */
@media (max-width: 480px) {
  :root { --container-px: 0.875rem; }

  .section-title::after { height: 2px; bottom: -2px; }
  .reveal.visible .section-title::after { width: 32px; }

  .section-sub { margin-bottom: 1.25rem; }

  /* Reduce section vertical padding on phone */
  .about-section,
  .services-section,
  .gallery-section,
  .founder-section,
  .policies-section,
  .testimonials-section,
  .history-section,
  .timeline-section,
  .contact-section,
  .featured-section,
  .mv-section { padding-top: 2rem; padding-bottom: 2rem; }

  .hero { padding-top: 1.5rem; padding-bottom: 1rem; gap: 1rem; }
  .hero-content p { font-size: 0.875rem; }

  .gallery-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .values-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }

  .product-image { height: 130px; }
  .product-info { padding: 0.75rem; }
  .product-info h3 { font-size: 0.85rem; }
  .product-description { font-size: 0.75rem; }
  .product-footer {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
    text-align: center;
  }
  .btn-contact { justify-content: center; width: 100%; padding: 0.5rem; }

  .mv-card { padding: 1.25rem; }
  .mv-icon { width: 46px; height: 46px; font-size: 1rem; }
  .mv-card h3 { font-size: 1rem; }
  .mv-card p { font-size: 0.83rem; }

  .service { padding: 1.25rem; }
  .service-icon { width: 40px; height: 40px; font-size: 1rem; }

  .policy { padding: 1rem; }
  .testimony { padding: 1rem; }

  footer { padding: 1.5rem 0; font-size: 0.8rem; }

  .filters { gap: 0.35rem; }
  .filter-btn { padding: 0.35rem 0.75rem; font-size: 0.78rem; min-height: 36px; }

  #gallery-search { max-width: 100%; }

  .form-card .row { grid-template-columns: 1fr; gap: 0; }

  .founder-text h3 { font-size: 0.9rem; }

  .stats { gap: 0.75rem; }
  .stat h3 { font-size: 1rem; }

  .btn-featured,
  .btn-tutorial {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  /* Lightbox full screen on phone */
  .lightbox { padding: 0.75rem; }
  .lightbox-content { border-radius: 10px; padding: 1rem; }

  #theme-toggle { bottom: 0.75rem; right: 0.75rem; }
}

/* ── Very small screens ── */
@media (max-width: 360px) {
  :root { --container-px: 0.75rem; }

  nav { width: 100vw; border-left: none; }

  .gallery-grid { grid-template-columns: 1fr; }
  .values-grid { grid-template-columns: 1fr; }

  .product-image { height: 160px; }

  .mv-card { padding: 1rem; }
  .service { padding: 1rem; }
  .service-icon { width: 36px; height: 36px; font-size: 0.85rem; }

  .stats { flex-direction: column; align-items: center; gap: 1rem; }
}

/* ── Print: hide chrome ── */
@media print {
  header, footer, #theme-toggle, #scroll-indicator, .hamburger, .mobile-overlay {
    display: none !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ===== MOBILE NAV FIX ===== */

@media (max-width: 900px) {
  .dropdown {
    width: 100%;
  }

  .dropdown-toggle {
    width: 100%;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    font-size: 0.95rem;
    min-height: 48px;
    justify-content: space-between;
  }
}