/* ============================================================
   EnergiaBarata.eu — Premium Design Layer (2026)

   REVERSIBLE: Remove this file + premium.js from HTML to revert.
   This file ONLY adds/overrides — never removes existing styles.
   ============================================================ */

/* === Premium Typography === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400&display=swap');

:root {
  /* Brand colors (preserved) */
  --c-primary: #00A651;
  --c-primary-dark: #008C42;
  --c-primary-light: #00D966;
  --c-accent: #fdc814;
  --c-dark: #004D2C;

  /* Premium additions */
  --c-surface: #ffffff;
  --c-surface-raised: #f8faf9;
  --c-text: #1a1a2e;
  --c-text-muted: #6b7280;
  --c-border: #e5e7eb;
  --c-glow: rgba(0, 166, 81, 0.15);

  /* Typography */
  --font-heading: 'Inter', system-ui, -apple-system, sans-serif;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;

  /* Spacing rhythm */
  --space-section: clamp(4rem, 8vw, 7rem);

  /* Transitions */
  --ease-premium: cubic-bezier(0.22, 1, 0.36, 1);
  --duration-fast: 200ms;
  --duration-normal: 350ms;
  --duration-slow: 600ms;
}

/* === Base Typography Upgrade === */
body {
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6,
.font-bold, .font-extrabold, .font-black {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
}

/* Improved reading experience for body text */
article p,
.prose p,
main section p {
  font-size: 1.0625rem;
  line-height: 1.75;
}

/* === Reading Progress Bar === */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--c-primary), var(--c-primary-light), var(--c-accent));
  z-index: 9999;
  transition: width 100ms linear;
  border-radius: 0 2px 2px 0;
}

/* === Sticky Navbar with Glassmorphism === */
header nav,
nav[aria-label="Navegacion principal"] {
  transition: all var(--duration-normal) var(--ease-premium);
}

header.scrolled nav,
.nav-scrolled {
  background: rgba(255, 255, 255, 0.85) !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 8px 24px rgba(0, 0, 0, 0.04);
  border-bottom: 1px solid rgba(229, 231, 235, 0.5);
}

header {
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: all var(--duration-normal) var(--ease-premium);
}

/* === Scroll Reveal Animations === */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity var(--duration-slow) var(--ease-premium),
              transform var(--duration-slow) var(--ease-premium);
}

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

.reveal-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity var(--duration-slow) var(--ease-premium),
              transform var(--duration-slow) var(--ease-premium);
}

.reveal-left.visible {
  opacity: 1;
  transform: translateX(0);
}

.reveal-right {
  opacity: 0;
  transform: translateX(30px);
  transition: opacity var(--duration-slow) var(--ease-premium),
              transform var(--duration-slow) var(--ease-premium);
}

.reveal-right.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Staggered children animation */
.stagger-children > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 400ms var(--ease-premium),
              transform 400ms var(--ease-premium);
}

.stagger-children.visible > *:nth-child(1) { transition-delay: 0ms; }
.stagger-children.visible > *:nth-child(2) { transition-delay: 80ms; }
.stagger-children.visible > *:nth-child(3) { transition-delay: 160ms; }
.stagger-children.visible > *:nth-child(4) { transition-delay: 240ms; }
.stagger-children.visible > *:nth-child(5) { transition-delay: 320ms; }
.stagger-children.visible > *:nth-child(6) { transition-delay: 400ms; }
.stagger-children.visible > *:nth-child(7) { transition-delay: 480ms; }
.stagger-children.visible > *:nth-child(8) { transition-delay: 560ms; }

.stagger-children.visible > * {
  opacity: 1;
  transform: translateY(0);
}

/* === Premium Card Effects === */
.card-hover {
  transition: all var(--duration-normal) var(--ease-premium);
  border: 1px solid var(--c-border);
}

.card-hover:hover {
  transform: translateY(-6px);
  box-shadow:
    0 4px 6px -1px rgba(0, 166, 81, 0.06),
    0 20px 40px -8px rgba(0, 166, 81, 0.12);
  border-color: rgba(0, 166, 81, 0.3);
}

.card-hover::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-premium);
  background: linear-gradient(135deg, rgba(0, 166, 81, 0.03), transparent);
  pointer-events: none;
}

.card-hover:hover::after {
  opacity: 1;
}

/* === Premium Button Styles === */
.btn-premium {
  position: relative;
  overflow: hidden;
  transition: all var(--duration-normal) var(--ease-premium);
}

.btn-premium::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 500ms var(--ease-premium), height 500ms var(--ease-premium);
}

.btn-premium:hover::before {
  width: 300px;
  height: 300px;
}

/* CTA glow effect */
.btn-glow {
  box-shadow: 0 0 0 0 rgba(0, 166, 81, 0.4);
  animation: btn-pulse 2.5s ease-in-out infinite;
}

@keyframes btn-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 166, 81, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(0, 166, 81, 0); }
}

/* === Improved Hero Section === */
.hero-gradient {
  position: relative;
}

.hero-gradient::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(to top, rgba(0, 77, 44, 0.3), transparent);
  pointer-events: none;
}

/* Hero stats counter animation */
.stat-number {
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

/* === Section Spacing Improvement === */
main > section {
  scroll-margin-top: 80px;
}

/* === Improved Silo Cards === */
.silo-card {
  position: relative;
  overflow: hidden;
  transition: all var(--duration-normal) var(--ease-premium);
  border-radius: 1rem;
}

.silo-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--c-primary), var(--c-primary-light));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--duration-normal) var(--ease-premium);
}

.silo-card:hover::before {
  transform: scaleX(1);
}

.silo-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px -12px rgba(0, 166, 81, 0.15);
}

/* === FAQ Premium Enhancement === */
.faq-answer {
  transition: max-height 500ms var(--ease-premium),
              padding 500ms var(--ease-premium),
              opacity 300ms ease;
}

/* === Trust Badges Improvement === */
.trust-badge {
  transition: all var(--duration-normal) var(--ease-premium);
  border-radius: 1rem;
}

.trust-badge:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.1);
}

/* === Gradient Borders (Premium Detail) === */
.gradient-border {
  position: relative;
  border: none !important;
}

.gradient-border::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-light), var(--c-accent));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* === Smooth Scroll Shadows (for tables, overflow) === */
.scroll-shadow {
  background:
    linear-gradient(90deg, white 30%, rgba(255, 255, 255, 0)),
    linear-gradient(90deg, rgba(255, 255, 255, 0), white 70%) 100% 0,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.08), transparent),
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.08), transparent) 100% 0;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}

/* === Core Web Vitals: Content Visibility === */
main > section:not(:first-child) {
  content-visibility: auto;
  contain-intrinsic-size: auto 600px;
}

/* === Improved Footer === */
footer {
  position: relative;
}

footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--c-primary), transparent);
}

/* === Mobile Improvements === */
@media (max-width: 768px) {
  /* Larger touch targets */
  .mobile-menu a {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 12px 16px;
  }

  /* Better mobile card spacing */
  .card-hover:hover {
    transform: none;
  }

  /* Disable hover effects on touch */
  @media (hover: none) {
    .card-hover:hover,
    .silo-card:hover,
    .trust-badge:hover {
      transform: none;
      box-shadow: none;
    }
  }
}

/* === Dark Mode Ready (opt-in via class) === */
@media (prefers-color-scheme: dark) {
  /* Only activates if .dark-mode class is on <html> */
  html.dark-mode {
    --c-surface: #0f1419;
    --c-surface-raised: #1a1f26;
    --c-text: #e4e8ec;
    --c-text-muted: #9ca3af;
    --c-border: #2d3640;
  }
}

/* === Print Styles === */
@media print {
  .reading-progress,
  .skip-nav,
  header,
  footer,
  .mobile-menu,
  .btn-glow {
    display: none !important;
  }

  body {
    font-size: 12pt;
    line-height: 1.6;
    color: #000;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
}

/* === Subtle Background Texture === */
.bg-texture {
  background-image:
    radial-gradient(circle at 25% 25%, rgba(0, 166, 81, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(253, 200, 20, 0.02) 0%, transparent 50%);
}

/* === Number Counter Animation === */
@keyframes countUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.count-up {
  animation: countUp 600ms var(--ease-premium) forwards;
}

/* === Tooltip Enhancement === */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--c-dark);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all var(--duration-fast) var(--ease-premium);
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
