/**
 * Dynamic UI layer — motion, depth, and responsive polish.
 * Loaded after style.css. Respects prefers-reduced-motion.
 */

:root {
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --shadow-float: 0 12px 40px rgba(0, 0, 0, 0.35);
  --shadow-glow-accent: 0 0 48px rgba(61, 139, 253, 0.14);
  --radius-dynamic: 14px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Ambient mesh behind content */
body {
  position: relative;
  isolation: isolate;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 85% 55% at 15% -5%, rgba(61, 139, 253, 0.2), transparent 50%),
    radial-gradient(ellipse 70% 45% at 95% 5%, rgba(52, 199, 89, 0.12), transparent 42%),
    radial-gradient(ellipse 55% 50% at 50% 100%, rgba(142, 68, 255, 0.1), transparent 45%);
  animation: ambient-drift 24s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes ambient-drift {
  0% {
    opacity: 1;
    transform: scale(1) translate(0, 0);
  }
  100% {
    opacity: 0.88;
    transform: scale(1.06) translate(1.5%, -1%);
  }
}

/* Header */
.site-header {
  transition:
    box-shadow 0.4s var(--ease-out),
    border-color 0.3s ease,
    backdrop-filter 0.3s ease;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.18);
}

@media (hover: hover) and (pointer: fine) {
  .site-header:hover {
    box-shadow: 0 8px 44px rgba(0, 0, 0, 0.28), var(--shadow-glow-accent);
    border-color: rgba(61, 139, 253, 0.22);
  }
}

@supports (-webkit-background-clip: text) or (background-clip: text) {
  .brand {
    background: linear-gradient(115deg, #f5f8fc 0%, #7eb8ff 42%, #9ee9b4 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    transition: filter 0.35s var(--ease-out);
  }

  .brand:hover {
    filter: brightness(1.1) saturate(1.05);
    color: transparent;
  }
}

.nav a {
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  transition:
    color 0.22s ease,
    background 0.28s var(--ease-out),
    transform 0.22s var(--ease-spring);
}

@media (hover: hover) and (pointer: fine) {
  .nav a:hover {
    text-decoration: none;
    background: rgba(61, 139, 253, 0.16);
    color: var(--text);
    transform: translateY(-2px);
  }

  .nav a:active {
    transform: translateY(0);
  }
}

/* Main reveal — sits above ambient layer */
.main {
  position: relative;
  z-index: 1;
  animation: content-rise 0.55s var(--ease-out) both;
}

@keyframes content-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@supports (-webkit-background-clip: text) or (background-clip: text) {
  .page-head h1 {
    background: linear-gradient(100deg, #eef3f9 0%, #9dc4ff 40%, #e8edf4 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
}

/* Cards & panels */
.panel,
.stat-card,
.auth-card,
.form-aside .aside-card,
.form-main .card-section,
.property-block,
.nepal-address-card {
  border-radius: var(--radius-dynamic);
  transition:
    transform 0.3s var(--ease-out),
    box-shadow 0.4s var(--ease-out),
    border-color 0.28s ease;
}

@media (hover: hover) and (pointer: fine) {
  .panel:hover,
  .form-main .card-section:hover,
  .form-aside .aside-card:hover,
  .property-block:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-float), 0 0 0 1px rgba(61, 139, 253, 0.1);
    border-color: rgba(61, 139, 253, 0.28);
  }

  .stat-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-float), var(--shadow-glow-accent);
    border-color: rgba(61, 139, 253, 0.35);
  }
}

.stat-value {
  transition:
    transform 0.25s var(--ease-spring),
    filter 0.25s ease;
}

@media (hover: hover) and (pointer: fine) {
  .stat-card:hover .stat-value {
    transform: scale(1.06);
    filter: drop-shadow(0 0 12px rgba(61, 139, 253, 0.35));
  }
}

/* Buttons */
.btn {
  transition:
    transform 0.22s var(--ease-spring),
    box-shadow 0.3s var(--ease-out),
    background 0.22s ease,
    border-color 0.22s ease;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.2);
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(61, 139, 253, 0.32);
  }

  .btn:active:not(:disabled) {
    transform: translateY(0);
  }

  .btn-ghost:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  }
}

/* Flash messages */
.flash {
  animation: flash-slide 0.5s var(--ease-out) both;
}

@keyframes flash-slide {
  from {
    opacity: 0;
    transform: translateX(-16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Tables */
.data-table tbody tr {
  transition: background 0.18s ease;
}

/* Form controls */
.form input,
.form select,
.form textarea {
  transition:
    border-color 0.22s ease,
    box-shadow 0.22s ease,
    background 0.22s ease;
}

@media (hover: hover) and (pointer: fine) {
  .form input:hover,
  .form select:hover,
  .form textarea:hover {
    border-color: rgba(139, 156, 179, 0.5);
    background: rgba(15, 20, 25, 0.65);
  }
}

/* Tenant cards */
.tenant-card {
  transition:
    transform 0.3s var(--ease-out),
    box-shadow 0.4s var(--ease-out),
    border-color 0.28s ease;
}

@media (hover: hover) and (pointer: fine) {
  .tenant-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-float), 0 0 0 1px rgba(61, 139, 253, 0.12);
    border-color: rgba(61, 139, 253, 0.35);
  }
}

.tenant-card-photo img {
  transition: transform 0.45s var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .tenant-card:hover .tenant-card-photo img {
    transform: scale(1.04);
  }
}

/* Read-only banner subtle pulse border */
.read-only-banner {
  animation: banner-soft 4s ease-in-out infinite;
}

@keyframes banner-soft {
  0%,
  100% {
    border-color: rgba(255, 176, 32, 0.35);
  }
  50% {
    border-color: rgba(255, 176, 32, 0.55);
  }
}

/* Stagger panels in grid-two (first paint) */
.grid-two > .panel:nth-child(1) {
  animation: stagger-in 0.45s var(--ease-out) 0.05s both;
}

.grid-two > .panel:nth-child(2) {
  animation: stagger-in 0.45s var(--ease-out) 0.12s both;
}

@keyframes stagger-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Nested tables in properties */
.nested-units-table tbody tr {
  transition: background 0.15s ease;
}

/* Focus visible for keyboard users */
.nav a:focus-visible,
.btn:focus-visible,
.form input:focus-visible,
.form select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.header-end {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  justify-content: flex-end;
}

.header-lang {
  display: flex;
  align-items: center;
  margin: 0;
}

.lang-select {
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--surface2, #2a3344);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  min-width: 8.5rem;
}

.lang-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
