/* =============================================================================
   AMPLIFIED ESTATES — Design System Enhancements
   enhancements.css — Supplementary styles linked after main inline styles
   =============================================================================
   Table of Contents:
   1.  Design Tokens (CSS Custom Properties)
   2.  Utility Classes
   3.  Micro-Animations & Keyframes
   4.  Modal Styles
   5.  Toast Notifications
   6.  Responsive Enhancements
   7.  Print Styles
   ============================================================================= */


/* =============================================================================
   1. DESIGN TOKENS
   ============================================================================= */

:root {

  /* --- Palette --- */
  --ae-bg:           #39454D;
  --ae-bg-deep:      #2a3339;
  --ae-bg-card:      rgba(255, 255, 255, 0.05);
  --ae-white:        #FFFFFF;
  --ae-gray:         #C2C2C2;
  --ae-black:        #000000;
  --ae-green:        #A3E97D;
  --ae-green-dk:     #92B079;
  --ae-green-glow:   rgba(163, 233, 125, 0.2);
  --ae-green-subtle: rgba(163, 233, 125, 0.08);
  --ae-gold:         #C9A86C;
  --ae-red:          #E97D7D;

  /* --- Typography --- */
  --ae-font-serif:  'Cormorant Garamond', Georgia, serif;
  --ae-font-sans:   'DM Sans', system-ui, sans-serif;
  --ae-font-italic: 'Spectral', Georgia, serif;

  /* --- Spacing Scale (4px base) --- */
  --ae-space-1:  4px;
  --ae-space-2:  8px;
  --ae-space-3:  12px;
  --ae-space-4:  16px;
  --ae-space-5:  20px;
  --ae-space-6:  24px;
  --ae-space-7:  28px;
  --ae-space-8:  32px;
  --ae-space-10: 40px;
  --ae-space-12: 48px;
  --ae-space-14: 56px;
  --ae-space-16: 64px;

  /* --- Border Radius --- */
  --ae-radius-sm:   6px;
  --ae-radius-md:   12px;
  --ae-radius-lg:   18px;
  --ae-radius-xl:   24px;
  --ae-radius-pill: 100px;

  /* --- Shadows --- */
  --ae-shadow-card:     0 4px 24px rgba(0, 0, 0, 0.25);
  --ae-shadow-hover:    0 16px 48px rgba(0, 0, 0, 0.4);
  --ae-shadow-green:    0 8px 32px rgba(163, 233, 125, 0.3);
  --ae-shadow-green-lg: 0 16px 48px rgba(163, 233, 125, 0.4);

  /* --- Transitions --- */
  --ae-transition-fast: 0.18s ease;
  --ae-transition-base: 0.25s ease;
  --ae-transition-slow: 0.4s ease;
}


/* =============================================================================
   2. UTILITY CLASSES
   ============================================================================= */

/* --- Gradient Text --- */
.text-gradient {
  background: linear-gradient(135deg, var(--ae-green) 0%, var(--ae-green-dk) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

/* --- Glass Morphism Card --- */
.glass-card {
  background: var(--ae-bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--ae-radius-lg);
  box-shadow: var(--ae-shadow-card);
}

/* --- Green Glow --- */
.glow-green {
  box-shadow: var(--ae-shadow-green);
}

.glow-green:hover {
  box-shadow: var(--ae-shadow-green-lg);
}

/* --- Noise Texture Overlay --- */
.noise-overlay {
  position: relative;
}

.noise-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px 200px;
}

/* --- Section Divider --- */
.section-divider {
  display: block;
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  margin: var(--ae-space-8) 0;
}

/* --- Badge Variants --- */
.badge-new,
.badge-featured,
.badge-hot,
.badge-ai,
.badge-beta {
  display: inline-flex;
  align-items: center;
  gap: var(--ae-space-1);
  padding: var(--ae-space-1) var(--ae-space-3);
  border-radius: var(--ae-radius-pill);
  font-family: var(--ae-font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}

.badge-new {
  background: rgba(163, 233, 125, 0.15);
  color: var(--ae-green);
  border: 1px solid rgba(163, 233, 125, 0.3);
}

.badge-featured {
  background: rgba(201, 168, 108, 0.15);
  color: var(--ae-gold);
  border: 1px solid rgba(201, 168, 108, 0.3);
}

.badge-hot {
  background: rgba(233, 125, 125, 0.15);
  color: var(--ae-red);
  border: 1px solid rgba(233, 125, 125, 0.3);
}

.badge-ai {
  background: rgba(163, 233, 125, 0.1);
  color: var(--ae-green);
  border: 1px solid rgba(163, 233, 125, 0.25);
  background-image: linear-gradient(
    135deg,
    rgba(163, 233, 125, 0.12) 0%,
    rgba(201, 168, 108, 0.08) 100%
  );
}

.badge-beta {
  background: rgba(194, 194, 194, 0.1);
  color: var(--ae-gray);
  border: 1px solid rgba(194, 194, 194, 0.2);
}

/* --- Button Base Reset --- */
.btn-reset {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  line-height: 1;
  text-align: left;
  text-decoration: none;
  outline: none;
  border-radius: 0;
  box-shadow: none;
}

.btn-reset:focus-visible {
  outline: 2px solid var(--ae-green);
  outline-offset: 2px;
  border-radius: var(--ae-radius-sm);
}

/* --- Aspect Ratio Utilities --- */
.aspect-video {
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
}

.aspect-square {
  aspect-ratio: 1 / 1;
  width: 100%;
  overflow: hidden;
}

.aspect-property {
  aspect-ratio: 4 / 3;
  width: 100%;
  overflow: hidden;
}

/* --- Text Truncation --- */
.truncate-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* =============================================================================
   3. MICRO-ANIMATIONS & KEYFRAMES
   ============================================================================= */

/* --- Float (hero elements) --- */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

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

/* --- Shimmer / Skeleton Loading --- */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--ae-radius-md);
  color: transparent;
  pointer-events: none;
  user-select: none;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.06) 40%,
    rgba(255, 255, 255, 0.12) 50%,
    rgba(255, 255, 255, 0.06) 60%,
    transparent 100%
  );
  background-size: 600px 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}

/* --- Pulse Ring (active / focus states) --- */
@keyframes pulseRing {
  0%   { transform: scale(1);    opacity: 0.6; }
  70%  { transform: scale(1.35); opacity: 0;   }
  100% { transform: scale(1.35); opacity: 0;   }
}

.pulse-ring {
  position: relative;
}

.pulse-ring::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid var(--ae-green);
  animation: pulseRing 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  pointer-events: none;
}

/* --- Number Tick (counter / stat animations) --- */
@keyframes tickUp {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.tick-up {
  animation: tickUp 0.35s var(--ae-transition-fast) both;
}

/* --- Border Glow Animation (featured cards) --- */
@keyframes borderGlow {
  0%, 100% {
    border-color: rgba(163, 233, 125, 0.25);
    box-shadow: 0 0 0 0 rgba(163, 233, 125, 0);
  }
  50% {
    border-color: rgba(163, 233, 125, 0.6);
    box-shadow: 0 0 18px 2px rgba(163, 233, 125, 0.2);
  }
}

.border-glow-animated {
  border: 1px solid rgba(163, 233, 125, 0.25);
  animation: borderGlow 3s ease-in-out infinite;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .float,
  .skeleton::after,
  .pulse-ring::after,
  .tick-up,
  .border-glow-animated {
    animation: none;
  }

  .skeleton::after {
    background: rgba(255, 255, 255, 0.06);
  }
}


/* =============================================================================
   4. MODAL STYLES
   ============================================================================= */

/* --- Overlay --- */
.ae-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ae-space-4);
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--ae-transition-base),
    visibility var(--ae-transition-base);
}

.ae-modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

/* --- Modal Container --- */
.ae-modal {
  position: relative;
  width: 100%;
  max-width: 540px;
  max-height: calc(100dvh - var(--ae-space-8));
  overflow-y: auto;
  background: var(--ae-bg-deep);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  box-shadow: var(--ae-shadow-hover);
  transform: translateY(12px) scale(0.98);
  transition:
    transform var(--ae-transition-base),
    opacity var(--ae-transition-base);
  opacity: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.ae-modal-overlay.is-open .ae-modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* --- Modal Sections --- */
.ae-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ae-space-4);
  padding: var(--ae-space-6) var(--ae-space-6) var(--ae-space-4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.ae-modal-header h2,
.ae-modal-header h3 {
  font-family: var(--ae-font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ae-white);
  margin: 0;
  line-height: 1.2;
}

.ae-modal-close {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  border-radius: var(--ae-radius-sm);
  color: var(--ae-gray);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition:
    background var(--ae-transition-fast),
    color var(--ae-transition-fast);
}

.ae-modal-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ae-white);
}

.ae-modal-body {
  padding: var(--ae-space-6);
}

.ae-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--ae-space-3);
  padding: var(--ae-space-4) var(--ae-space-6) var(--ae-space-6);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

/* --- Form Elements --- */
.ae-form-group {
  display: flex;
  flex-direction: column;
  gap: var(--ae-space-2);
  margin-bottom: var(--ae-space-5);
}

.ae-form-group:last-child {
  margin-bottom: 0;
}

.ae-form-label {
  font-family: var(--ae-font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ae-gray);
  letter-spacing: 0.02em;
}

.ae-form-input,
.ae-form-select {
  width: 100%;
  padding: var(--ae-space-3) var(--ae-space-4);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--ae-radius-md);
  font-family: var(--ae-font-sans);
  font-size: 15px;
  color: var(--ae-white);
  outline: none;
  transition:
    border-color var(--ae-transition-fast),
    box-shadow var(--ae-transition-fast),
    background var(--ae-transition-fast);
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
}

.ae-form-input::placeholder {
  color: rgba(194, 194, 194, 0.45);
}

.ae-form-input:hover,
.ae-form-select:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.3);
}

.ae-form-input:focus,
.ae-form-select:focus {
  border-color: var(--ae-green);
  box-shadow: 0 0 0 3px var(--ae-green-subtle);
  background: rgba(0, 0, 0, 0.3);
}

.ae-form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23C2C2C2' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--ae-space-4) center;
  padding-right: var(--ae-space-10);
  cursor: pointer;
}

.ae-form-select option {
  background: var(--ae-bg-deep);
  color: var(--ae-white);
}

/* --- Modal Success State --- */
@keyframes successCheck {
  0%   { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1);   opacity: 1; }
}

.ae-modal-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--ae-space-12) var(--ae-space-8);
  gap: var(--ae-space-4);
}

.ae-modal-success__icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--ae-green-subtle);
  border: 2px solid var(--ae-green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--ae-green);
  animation: successCheck 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.ae-modal-success__title {
  font-family: var(--ae-font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ae-white);
  margin: 0;
}

.ae-modal-success__body {
  font-family: var(--ae-font-sans);
  font-size: 15px;
  color: var(--ae-gray);
  line-height: 1.6;
  margin: 0;
  max-width: 320px;
}


/* =============================================================================
   5. TOAST NOTIFICATIONS
   ============================================================================= */

@keyframes toastSlideUp {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes toastSlideDown {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(16px);
    opacity: 0;
  }
}

/* --- Toast Container --- */
#ae-toast-container {
  position: fixed;
  bottom: var(--ae-space-6);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ae-space-2);
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - var(--ae-space-8));
}

/* --- Individual Toast --- */
.ae-toast {
  display: inline-flex;
  align-items: center;
  gap: var(--ae-space-3);
  padding: var(--ae-space-3) var(--ae-space-5);
  min-width: 240px;
  max-width: 420px;
  background: var(--ae-bg-deep);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--ae-radius-pill);
  box-shadow: var(--ae-shadow-hover);
  font-family: var(--ae-font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--ae-white);
  line-height: 1.4;
  pointer-events: auto;
  border-left: 3px solid rgba(255, 255, 255, 0.15);
}

.ae-toast__icon {
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1;
}

.ae-toast__message {
  flex: 1;
}

/* --- Toast Variants --- */
.ae-toast.success {
  border-left-color: var(--ae-green);
}

.ae-toast.success .ae-toast__icon {
  color: var(--ae-green);
}

.ae-toast.error {
  border-left-color: var(--ae-red);
}

.ae-toast.error .ae-toast__icon {
  color: var(--ae-red);
}

/* --- Toast Transition States --- */
.ae-toast.entering {
  animation: toastSlideUp 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.ae-toast.leaving {
  animation: toastSlideDown 0.22s ease-in both;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .ae-toast.entering,
  .ae-toast.leaving {
    animation: none;
  }
}


/* =============================================================================
   6. RESPONSIVE ENHANCEMENTS
   ============================================================================= */

/* --- Large desktop: tighten padding --- */
@media (max-width: 1200px) {
  .ae-modal {
    max-width: 480px;
  }

  .ae-modal-body,
  .ae-modal-header {
    padding-left: var(--ae-space-5);
    padding-right: var(--ae-space-5);
  }

  .ae-modal-footer {
    padding-left: var(--ae-space-5);
    padding-right: var(--ae-space-5);
  }

  /* Reduce section spacing on mid-size screens */
  .section-divider {
    margin: var(--ae-space-6) 0;
  }
}

/* --- Tablet / Two-column to single-column breakpoint --- */
@media (max-width: 900px) {
  /* Stack any two-column grid to single column */
  .ae-grid-2,
  .ae-grid-3 {
    grid-template-columns: 1fr;
  }

  /* Reduce modal size */
  .ae-modal {
    max-width: 100%;
    border-radius: var(--ae-radius-lg);
  }

  /* Modal footer stacks vertically */
  .ae-modal-footer {
    flex-direction: column-reverse;
    gap: var(--ae-space-2);
  }

  .ae-modal-footer > * {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  /* Toast container becomes full-width */
  #ae-toast-container {
    width: calc(100vw - var(--ae-space-8));
  }

  .ae-toast {
    width: 100%;
    max-width: 100%;
    border-radius: var(--ae-radius-lg);
  }
}

/* --- Mobile-first adjustments --- */
@media (max-width: 600px) {
  /* Modal fills the bottom of the screen (sheet style) */
  .ae-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .ae-modal {
    max-height: 92dvh;
    border-radius: var(--ae-radius-xl) var(--ae-radius-xl) 0 0;
  }

  .ae-modal-header {
    padding: var(--ae-space-5) var(--ae-space-4) var(--ae-space-3);
  }

  .ae-modal-body {
    padding: var(--ae-space-4);
  }

  .ae-modal-footer {
    padding: var(--ae-space-3) var(--ae-space-4) var(--ae-space-5);
  }

  /* Larger tap targets for form elements */
  .ae-form-input,
  .ae-form-select {
    padding: var(--ae-space-4);
    font-size: 16px; /* prevents iOS zoom on focus */
    min-height: 48px;
  }

  /* Badges slightly larger for readability */
  .badge-new,
  .badge-featured,
  .badge-hot,
  .badge-ai,
  .badge-beta {
    font-size: 10px;
    padding: var(--ae-space-1) var(--ae-space-2);
  }

  /* Toast pinned to bottom edge */
  #ae-toast-container {
    bottom: var(--ae-space-4);
  }

  /* Simplify glass card on mobile — reduce blur cost */
  .glass-card {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  /* Reduce float animation range on mobile */
  @keyframes float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-4px); }
  }
}


/* =============================================================================
   7. PRINT STYLES
   ============================================================================= */

@media print {
  /* Reset page background */
  *,
  *::before,
  *::after {
    background: #fff !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Hide interactive / decorative elements */
  nav,
  header nav,
  .ae-modal-overlay,
  #ae-toast-container,
  .float,
  .skeleton,
  .pulse-ring::after,
  .border-glow-animated,
  .noise-overlay::before,
  button:not([data-print]),
  [aria-label="close"],
  .ae-modal-close {
    display: none !important;
  }

  /* Ensure readable typography */
  body {
    font-family: Georgia, serif;
    font-size: 12pt;
    line-height: 1.6;
  }

  /* Kill animations entirely */
  * {
    animation: none !important;
    transition: none !important;
  }

  /* Remove gradient text — fallback to black */
  .text-gradient {
    -webkit-text-fill-color: #000 !important;
    background: none !important;
    color: #000 !important;
  }

  /* Glass cards become simple bordered boxes */
  .glass-card {
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    backdrop-filter: none !important;
  }

  /* Sensible page break behaviour */
  h1, h2, h3 {
    page-break-after: avoid;
  }

  img, figure {
    page-break-inside: avoid;
    max-width: 100%;
  }

  /* Show full URLs for links */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 10pt;
    color: #555 !important;
  }

  a[href^="#"]::after,
  a[href^="javascript"]::after {
    content: "";
  }
}
