/*
  NOADIC GLOBAL ENTERPRISE LTD - Shared Styles
  Tech: Tailwind (CDN) + minimal custom CSS for premium micro-interactions.

  Notes:
  - Keep this file lightweight; most styling lives in Tailwind classes.
  - Custom CSS here focuses on: reveal effects, patterns, and subtle UI polish.
*/

:root {
  --navy: #0c3b5c;
  --gold: #e8b12d;
  --green: #1fa34a;
  --ink: #0f172a;
  --bg: #f8fafc;
}

::selection {
  background: rgba(232, 177, 45, 0.35);
}

/* Smooth scrolling (disabled for reduced motion below) */
html {
  scroll-behavior: smooth;
}

/* Page enter/leave transitions (applies only when JS is enabled) */
html.js body {
  opacity: 0;
}

/* Header surface styling (JS toggles [data-header].is-scrolled) */
[data-header-surface] {
  background: transparent;
  border-bottom: 1px solid transparent;
  transition:
    background-color 220ms ease,
    box-shadow 220ms ease,
    border-color 220ms ease;
}

[data-header].is-scrolled [data-header-surface] {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.1);
  border-bottom-color: rgba(148, 163, 184, 0.38);
}

/* Brand logo tint: show white logo on transparent header, restore on scroll */
.brand-logo {
  filter: brightness(0) invert(1) saturate(100%);
  transition:
    filter 220ms ease,
    opacity 220ms ease;
  will-change: filter, opacity;
}

[data-header].is-scrolled .brand-logo {
  filter: none;
}

/* Mobile menu motion (JS toggles .menu-open / .menu-closed) */
[data-menu] {
  transform-origin: top;
  transition:
    opacity 200ms ease,
    transform 200ms ease;
}

[data-menu].menu-closed {
  opacity: 0;
  transform: translate3d(0, -8px, 0);
}

[data-menu].menu-open {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

/* Filter buttons + cards (prevents Tailwind CDN JIT issues with runtime-only classes) */
[data-filter-group] [data-filter] {
  transition:
    background-color 200ms ease,
    color 200ms ease,
    border-color 200ms ease;
}

[data-filter-group] [data-filter].is-active {
  background-color: var(--navy);
  border-color: var(--navy);
  color: #ffffff;
}

[data-filter-group] [data-filter-item] {
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  will-change: opacity, transform;
}

[data-filter-group] [data-filter-item].is-filter-hidden {
  opacity: 0;
  transform: translate3d(0, 10px, 0) scale(0.98);
}

/* Form validation (JS sets aria-invalid) */
input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2);
}

/* Navbar color system (transparent-on-hero -> solid) */
[data-header] {
  --nav-fg: rgba(255, 255, 255, 0.92);
  --nav-muted: rgba(255, 255, 255, 0.72);
  --nav-border: rgba(255, 255, 255, 0.12);
}

[data-header].is-scrolled {
  --nav-fg: rgba(15, 23, 42, 0.9);
  --nav-muted: rgba(15, 23, 42, 0.68);
  --nav-border: rgba(148, 163, 184, 0.38);
}

.nav-fg {
  color: var(--nav-fg);
}

.nav-muted {
  color: var(--nav-muted);
}

.nav-border {
  border-color: var(--nav-border);
}

html.js body.is-ready {
  opacity: 1;
  transition: opacity 500ms ease;
}

html.js body.is-leaving {
  opacity: 0;
  transition: opacity 200ms ease;
}

/* Premium, subtle engineering grid background utility */
.bg-engineering-grid {
  background-image:
    linear-gradient(to right, rgba(12, 59, 92, 0.07) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(12, 59, 92, 0.07) 1px, transparent 1px);
  background-size: 44px 44px;
}

/* Slow grid drift (opt-in). Keeps the site feeling alive. */
@keyframes grid-drift {
  0% {
    background-position:
      0 0,
      0 0;
  }
  100% {
    background-position:
      44px 0,
      0 44px;
  }
}

.bg-engineering-grid.bg-grid-drift {
  animation: grid-drift 18s linear infinite;
  will-change: background-position;
}

/* Subtle floating accents */
@keyframes float-slow {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -10px, 0);
  }
}

.float-slow {
  animation: float-slow 10s ease-in-out infinite;
}

/* Gentle sheen for premium borders */
@keyframes sheen {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 100% 50%;
  }
}

.border-sheen {
  background-size: 200% 200%;
  animation: sheen 8s ease-in-out infinite;
}

/* Section reveal effect (IntersectionObserver toggles .is-visible) */
.reveal {
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  transition:
    opacity 700ms cubic-bezier(0.2, 0.65, 0.2, 1),
    transform 700ms cubic-bezier(0.2, 0.65, 0.2, 1);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}

.reveal.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.reveal.reveal-left {
  transform: translate3d(-16px, 0, 0);
}

.reveal.reveal-right {
  transform: translate3d(16px, 0, 0);
}

.reveal.reveal-scale {
  transform: translate3d(0, 10px, 0) scale(0.98);
}

/* Scrollspy active link polish */
[data-scrollspy] a.is-active {
  color: var(--navy);
}

/* Button glow (kept subtle) */
.btn-glow {
  position: relative;
  overflow: hidden;
}

.btn-glow::after {
  content: "";
  position: absolute;
  inset: 0; /* keep the glow clipped inside the button */
  border-radius: inherit;
  background:
    radial-gradient(
      600px 120px at 20% 0%,
      rgba(232, 177, 45, 0.1),
      transparent 60%
    ),
    radial-gradient(
      600px 120px at 80% 100%,
      rgba(31, 163, 74, 0.05),
      transparent 60%
    );
  opacity: 0;
  transition:
    opacity 220ms ease,
    transform 220ms ease;
  pointer-events: none;
  mix-blend-mode: normal;
}

.btn-glow:hover::after,
.btn-glow:focus-visible::after {
  /* subtle visible glow on hover, but low enough to avoid strong colour casts */
  opacity: 0.16;
}

/* Underline animation for links */
.underline-sweep {
  background-image: linear-gradient(
    90deg,
    rgba(232, 177, 45, 0.95),
    rgba(31, 163, 74, 0.85)
  );
  background-size: 0% 2px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 240ms ease;
}

.underline-sweep:hover,
.underline-sweep:focus-visible {
  background-size: 100% 2px;
}

.nav-link.is-current {
  opacity: 1;
  background-size: 100% 2px;
}

/* Icon pop on hover/focus (add .card-icon-pop to a card, and data-icon-pop on the icon wrapper) */
@keyframes icon-pop {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  45% {
    transform: translate3d(0, -2px, 0) scale(1.06);
  }
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
}

.card-icon-pop [data-icon-pop] {
  transform-origin: 50% 50%;
}

.card-icon-pop:hover [data-icon-pop],
.card-icon-pop:focus-within [data-icon-pop] {
  animation: icon-pop 520ms cubic-bezier(0.2, 0.75, 0.3, 1);
}

/* Site gallery / portfolio thumbnails */
.site-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
.gallery-thumb {
  width: 100%;
  height: 12rem;
  object-fit: cover;
  border-radius: 0.75rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.07);
  transition:
    transform 220ms ease,
    box-shadow 220ms ease;
}
.gallery-thumb:hover,
.gallery-thumb:focus {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
}
.portfolio-hero {
  height: 20rem;
  object-fit: cover;
  border-radius: 0.9rem;
}

@media (max-width: 768px) {
  .site-gallery {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }
  .gallery-thumb {
    height: 10.5rem;
  }
}

/* Hero background softening (applied to hero image elements) */
.hero-bg-soft {
  display: block;
  /* Do not set transform or position to avoid creating a new stacking context */
  filter: blur(4px) saturate(0.97) brightness(0.92);
  transition: filter 320ms ease;
  will-change: filter;
}

@media (min-width: 1024px) {
  .hero-bg-soft {
    /* slightly lighter blur on larger screens for a balanced look */
    filter: blur(3px) saturate(0.98) brightness(0.96);
  }
}

/* Stronger hero overlay for text contrast */
.hero-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* stronger, left-weighted gradient to improve contrast for left-aligned headings */
  background: linear-gradient(
    90deg,
    rgba(2, 6, 23, 0.92) 0%,
    rgba(2, 6, 23, 0.78) 30%,
    rgba(2, 6, 23, 0.6) 60%,
    rgba(255, 255, 255, 0.02) 100%
  );
  z-index: 1;
  mix-blend-mode: normal;
}

/* Helper to ensure hero content sits above overlays */
.hero-content {
  position: relative;
  z-index: 20;
}

/* Improve readability of hero text */
.hero-content h1,
.hero-content h2 {
  text-shadow: 0 12px 30px rgba(2, 6, 23, 0.65);
}

.hero-content p {
  text-shadow: 0 8px 18px rgba(2, 6, 23, 0.45);
}

.hero-content .btn-glow {
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.35);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 70;
}

.lightbox.is-open {
  display: flex;
}

/* Accordion icon micro-interaction */
[data-accordion-trigger] .accordion-icon {
  transition: transform 200ms ease;
}

[data-accordion-trigger][aria-expanded="true"] .accordion-icon {
  transform: rotate(45deg);
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
