/*
 * Main styles for SDA redesigned landing page.
 *
 * Defines variables, typography, animations, utilities and component overrides.
 * Uses exclusive primary colors for icons, accents, buttons and themes.
 * Maintains Bootstrap harmony.
 */

:root {
  /* Primary colors - exclusive usage for icons, accents, CTAs */
  --color-primary-1: #b03851;
  --color-primary-2: #f17144;
  --color-primary-3: #f4b036;

  /* Surface neutrals */
  --surface-0: #ffffff;
  --surface-1: #f8f9fa;
  --surface-2: #f1f3f5;

  /* Text neutrals */
  --text-0: #0b0b0b;
  --text-1: #212529;
  --text-2: #495057;

  /* Typography */
  font-family: 'Inter', sans-serif;
  --bs-body-font-family: 'Inter', sans-serif;

  /* Animations */
  --anim-duration: 250ms;
  --anim-easing: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Spacing */
  --space-y: 2rem;
}

/* Dark theme overrides */
[data-bs-theme='dark'] {
  --surface-0: #1a1e26;
  --surface-1: #2a2f3e;
  --surface-2: #3a4155;
  --text-0: #e8e9ea;
  --text-1: #ffffff;
  --text-2: #adb5bd;
  --bs-body-bg: var(--surface-0);
  --bs-body-color: var(--text-1);
  --bs-tertiary-bg: var(--surface-1);
  --bs-border-color: rgba(255, 255, 255, 0.1);
}

/* Bootstrap overrides with primaries */
:root {
  --bs-primary: var(--color-primary-1);
  --bs-secondary: var(--color-primary-2);
  --bs-warning: var(--color-primary-3);
  --bs-link-color: var(--color-primary-1);
  --bs-link-hover-color: var(--color-primary-2);
  --bs-focus-ring-color: rgba(var(--color-primary-1), 0.25);
}

[data-bs-theme='dark'] {
  --bs-primary: var(--color-primary-1);
  --bs-secondary: var(--color-primary-2);
  --bs-warning: var(--color-primary-3);
  --bs-link-color: var(--color-primary-1);
  --bs-link-hover-color: var(--color-primary-2);
}

/* Typography scale */
.h1, h1 { font-size: clamp(2rem, 5vw, 4rem); font-weight: 700; line-height: 1.2; color: var(--text-0); }
.h2, h2 { font-size: clamp(1.5rem, 4vw, 3rem); font-weight: 600; line-height: 1.3; color: var(--text-1); }
.h3, h3 { font-size: clamp(1.25rem, 3vw, 2rem); font-weight: 600; line-height: 1.4; color: var(--text-1); }
.lead { font-size: clamp(1rem, 2vw, 1.25rem); font-weight: 400; line-height: 1.6; color: var(--text-2); }
body { font-size: 1rem; font-weight: 400; line-height: 1.6; color: var(--text-1); }

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html {
    scroll-behavior: auto;
  }
}

/* Focus visible accessible */
.btn:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-primary-1);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Cards */
.card {
  background: rgba(255, 255, 255, 0.8);
  border: none;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: transform var(--anim-duration) var(--anim-easing), box-shadow var(--anim-duration) var(--anim-easing);
  will-change: transform;
}

[data-bs-theme='dark'] .card {
  background: rgba(0, 0, 0, 0.7);
  box-shadow: 0 1px 3px rgba(255, 255, 255, 0.1);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

[data-bs-theme='dark'] .card:hover {
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.15);
}

.card-body {
  padding: var(--space-y);
}

/* Buttons */
.btn {
  border-radius: 0.5rem;
  font-weight: 500;
  transition: all var(--anim-duration) var(--anim-easing);
  will-change: background-color, border-color;
}

.btn-primary {
  background-color: var(--color-primary-1);
  border-color: var(--color-primary-1);
}

.btn-primary:hover {
  background-color: var(--color-primary-2);
  border-color: var(--color-primary-2);
}

.btn-secondary {
  background-color: transparent;
  border-color: var(--color-primary-1);
  color: var(--color-primary-1);
}

.btn-secondary:hover {
  background-color: var(--color-primary-1);
  color: var(--surface-0);
}

.btn-outline-primary {
  color: var(--color-primary-1);
  border-color: var(--color-primary-1);
}

.btn-outline-primary:hover {
  background-color: var(--color-primary-1);
  color: var(--surface-0);
}

/* Navbar */
.navbar-brand {
  transition: font-size var(--anim-duration) var(--anim-easing);
  will-change: font-size;
}

.navbar-shrink .navbar-brand {
  font-size: 1.25rem;
}

/* Sections spacing */
section {
  padding-top: calc(var(--space-y) * 1.5);
  padding-bottom: calc(var(--space-y) * 1.5);
}

/* Hero */
#hero {
  position: relative;
  min-height: clamp(60vh, 75vh, 90vh);
  padding-top: calc(var(--space-y) * 4);
  padding-bottom: calc(var(--space-y) * 4);
  overflow: hidden;
}

#hero .container {
  padding: 0;
}

#hero .col-lg-9 {
  background-color: rgba(255, 255, 255, 0.3);
  background-image:
    radial-gradient(circle at 18% 22%, rgba(176, 56, 81, 0.3), transparent 50%),
    radial-gradient(circle at 80% 75%, rgba(241, 113, 68, 0.2), transparent 60%),
    radial-gradient(circle at 50% 50%, rgba(244, 176, 54, 0.15), transparent 70%),
    linear-gradient(135deg, rgba(241, 113, 68, 0.15) 0%, rgba(244, 176, 54, 0.2) 45%, rgba(248, 249, 250, 0.9) 100%);
  background-blend-mode: normal;
  border-radius: 0.75rem;
  padding: var(--space-y);
  color: var(--text-0);
  transition: all var(--anim-duration) var(--anim-easing);
  will-change: transform, box-shadow;
}

#hero .col-lg-9:hover {
  background-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

[data-bs-theme='dark'] #hero .col-lg-9 {
  background-color: rgba(26, 30, 38, 0.5);
  background-image:
    radial-gradient(circle at 20% 20%, rgba(241, 113, 68, 0.32), transparent 58%),
    linear-gradient(135deg, rgba(176, 56, 81, 0.55) 0%, rgba(73, 80, 87, 0.75) 50%, rgba(26, 30, 38, 0.9) 100%);
  background-blend-mode: screen, normal;
  color: var(--text-1);
}

/* Descripcion section bigger */
#descripcion {
  padding-top: calc(var(--space-y) * 3.5);
  padding-bottom: calc(var(--space-y) * 3.5);
}

/* Collage of scattered photos */
.photo-table {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--surface-0) 0%, var(--surface-1) 100%);
}

[data-bs-theme='dark'] .photo-table {
  background: linear-gradient(180deg, var(--surface-0) 0%, rgba(26, 30, 38, 0.95) 100%);
}

.photo-table .container {
  position: relative;
  z-index: 1;
}

.photo-table__canvas {
  position: absolute;
  inset: -12% -14%;
  pointer-events: none;
  z-index: 0;
}

.photo-table__photo {
  position: absolute;
  width: clamp(140px, 18vw, 230px);
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 18px 35px rgba(0, 0, 0, 0.25);
  transform-origin: center;
  opacity: 0.9;
  transition: transform var(--anim-duration) var(--anim-easing), box-shadow var(--anim-duration) var(--anim-easing);
  pointer-events: none;
}

[data-bs-theme='dark'] .photo-table__photo {
  box-shadow: 0 18px 35px rgba(0, 0, 0, 0.45);
  opacity: 0.75;
}

.photo-table__photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-table__photo:nth-child(1) {
  top: 6%;
  left: 6%;
  transform: rotate(-8deg);
}

.photo-table__photo:nth-child(2) {
  top: 14%;
  right: 12%;
  transform: rotate(6deg);
}

.photo-table__photo:nth-child(3) {
  top: 46%;
  left: -2%;
  transform: rotate(15deg);
}

.photo-table__photo:nth-child(4) {
  top: 44%;
  right: 0%;
  transform: rotate(-10deg);
}

.photo-table__photo:nth-child(5) {
  bottom: -4%;
  left: 22%;
  transform: rotate(-16deg);
}

.photo-table__photo:nth-child(6) {
  bottom: -6%;
  right: 20%;
  transform: rotate(12deg);
}

/* Comparator */
#comparador {
  background-color: var(--surface-0);
}

.juxtapose {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.2);
}

.before-after__caption {
  margin-top: 1.5rem;
  color: var(--text-2);
}

/* Animations for scroll */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-on-scroll-fade-up {
  animation: fade-up 0.6s ease-out forwards;
}

.animate-on-scroll-slide-in {
  animation: slide-in 0.6s ease-out forwards;
}

.animate-on-scroll-scale-in {
  animation: scale-in 0.6s ease-out forwards;
}

.fade-out {
  opacity: 0;
}

.animate-in {
  opacity: 1;
}

/* Contact form */
#contact-form input,
#contact-form textarea {
  transition: border-color var(--anim-duration) var(--anim-easing);
}

#contact-form input:focus,
#contact-form textarea:focus {
  border-color: var(--color-primary-1);
  box-shadow: 0 0 0 0.2rem rgba(var(--color-primary-1), 0.25);
}

.form-error {
  border-color: #dc3545 !important;
}

.form-success {
  border-color: #198754 !important;
}

#form-message {
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* Theme toggle icon color */
.theme-toggle-btn svg {
  stroke: var(--color-primary-1);
}

[data-bs-theme='dark'] .theme-toggle-btn svg {
  stroke: var(--color-primary-3);
}

/* Nexus logo inversion in dark mode */
[data-bs-theme='dark'] .nexus-logo {
  filter: invert(1);
}

/* Utility classes */
.text-primary-1 { color: var(--color-primary-1) !important; }
.text-primary-2 { color: var(--color-primary-2) !important; }
.text-primary-3 { color: var(--color-primary-3) !important; }
.bg-primary-1 { background-color: var(--color-primary-1) !important; color: var(--surface-0) !important; }
.bg-primary-2 { background-color: var(--color-primary-2) !important; color: var(--surface-0) !important; }
.bg-primary-3 { background-color: var(--color-primary-3) !important; color: var(--surface-0) !important; }

/* --- Background scatter photos (floating) + slider tweaks --- */

/* Section breathing room */
#memorias.photo-table { padding: calc(var(--space-y) * 2) 0; }

/* Canvas sits behind content */
#memorias.photo-table .photo-table__canvas {
  position: absolute !important;
  inset: -12% -14% !important;
  pointer-events: none !important;
  z-index: 0 !important;
}

/* Scattered photos with subtle parallax via CSS vars */
#memorias.photo-table .photo-table__photo {
  position: absolute !important;
  width: clamp(140px, 18vw, 230px) !important;
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 18px 35px rgba(0, 0, 0, 0.25);
  transform: translate3d(var(--tx, 0px), var(--ty, 0px), 0) rotate(var(--rot, 0deg));
  will-change: transform;
  opacity: 0.9;
}

[data-bs-theme='dark'] #memorias.photo-table .photo-table__photo {
  box-shadow: 0 18px 35px rgba(0, 0, 0, 0.45);
  opacity: 0.75;
}

#memorias.photo-table .photo-table__photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Positions + base rotations */
#memorias.photo-table .photo-table__photo:nth-child(1) { top: 6%;  left: 6%;  --rot: -8deg; }
#memorias.photo-table .photo-table__photo:nth-child(2) { top: 14%; right: 12%; --rot: 6deg; }
#memorias.photo-table .photo-table__photo:nth-child(3) { top: 46%; left: -2%; --rot: 15deg; }
#memorias.photo-table .photo-table__photo:nth-child(4) { top: 44%; right: 0%;  --rot: -10deg; }
#memorias.photo-table .photo-table__photo:nth-child(5) { bottom: -4%; left: 22%; --rot: -16deg; }
#memorias.photo-table .photo-table__photo:nth-child(6) { bottom: -6%; right: 20%; --rot: 12deg; }

/* Responsive visibility: reduce clutter on small screens */
@media (max-width: 576px) {
  #memorias.photo-table .photo-table__photo:nth-child(n+4) { display: none; }
}
@media (min-width: 577px) and (max-width: 992px) {
  #memorias.photo-table .photo-table__photo:nth-child(n+7) { display: none; }
}

/* Reduced motion: disable parallax movement */
@media (prefers-reduced-motion: reduce) {
  #memorias.photo-table .photo-table__photo { transition: none; transform: rotate(var(--rot, 0deg)); }
}

/* Before/After slider: ensure images fill layers */
.before-after__layer img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Improve the before/after slider handle arrow (divisor) */
.before-after__handle::after { content: '\2194' !important; }

/* Fallback mode: no clip-path, toggle opacity */
.before-after--fallback .before-after__handle { display: none; }
.before-after--fallback .before-after__layer--after { clip-path: none !important; width: 100% !important; opacity: var(--after-visible, 0); transition: opacity 200ms ease; }

/* --- Global background scattered photos across the page --- */
.site-content { position: relative; z-index: 2; }

.bg-photos {
  position: fixed;
  inset: -10% -10% 0 -10%;
  z-index: 0;
  pointer-events: none;
}

/* Footer opacity */
footer {
  background: var(--surface-0) !important;
}

/* Sections backgrounds transparent to not hide background photos */
#memorias, #comparador { background: transparent !important; }

.bg-photo {
  position: absolute;
  width: clamp(200px, 25vw, 300px);
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 18px 35px rgba(0, 0, 0, 0.18);
  transform: translate3d(var(--tx, 0px), var(--ty, 0px), 0) rotate(var(--rot, 0deg));
  will-change: transform;
  opacity: 0.4;
}

[data-bs-theme='dark'] .bg-photo {
  box-shadow: 0 18px 35px rgba(0, 0, 0, 0.35);
  opacity: 0.5;
}

.bg-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Placeholders: positions and rotations */
.bg-photo:nth-child(1) { top: 5%;   left: 6%;   --rot: -10deg; }
.bg-photo:nth-child(2) { top: 12%;  right: 8%;  --rot: 7deg; }
.bg-photo:nth-child(3) { top: 42%;  left: -2%;  --rot: 14deg; }
.bg-photo:nth-child(4) { top: 55%;  right: 2%;  --rot: -12deg; }
.bg-photo:nth-child(5) { bottom: -4%; left: 22%; --rot: -16deg; }
.bg-photo:nth-child(6) { bottom: -6%; right: 18%; --rot: 11deg; }

@media (max-width: 576px) { .bg-photo:nth-child(n+4) { display: none; } }
@media (min-width: 577px) and (max-width: 992px) { .bg-photo:nth-child(n+7) { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .bg-photo { transition: none; transform: rotate(var(--rot, 0deg)); }
}

/* Hide section-scoped canvas to avoid duplication now that we have global bg */
#memorias .photo-table__canvas { display: none !important; }
