/* ==========================================================================
   CSS Base - Consultor SEO Castellón
   Tokens de Diseño de Google Stitch + Reset Básico + Layout Helpers
   ========================================================================== */

:root {
  /* Colors */
  --primary: #003ec7;
  --primary-hover: #0038b6;
  --secondary: #515f78;
  --secondary-hover: #39475f;
  --background: #fcf9f8;
  --surface: #ffffff;
  
  --text-main: #1c1b1b;
  --text-muted: #434656;
  --border-color: #c3c5d9;

  /* Typography */
  --font-heading: 'Poppins', system-ui, sans-serif;
  --font-body: 'Poppins', system-ui, sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 32px;
  --space-xl: 64px;
  --space-xxl: 120px;

  /* Borders */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-pill: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  
  /* Layout */
  --max-width: 1200px;
  --nav-height: 96px;
}

/* ==========================================================================
   Reset
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

body, h1, h2, h3, h4, p, figure, blockquote, dl, dd {
  margin: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  min-height: 100vh;
  text-rendering: optimizeSpeed;
  line-height: 1.6;
  font-family: var(--font-body);
  color: var(--text-main);
  background-color: var(--background);
  overflow-x: clip;
}

a {
  text-decoration: none;
  color: inherit;
  transition: color 0.2s ease;
}

a:not([class]) {
  text-decoration-skip-ink: auto;
  color: var(--primary);
  text-decoration: underline;
}

img, picture {
  max-width: 100%;
  display: block;
  height: auto;
}

ul[role="list"], ol[role="list"] {
  list-style: none;
  padding: 0;
  margin: 0;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 100%;
}

/* ==========================================================================
   Tipografía
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-md);
}

h1 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

h2 {
  font-size: clamp(2rem, 4vw, 3rem);
}

h3 {
  font-size: clamp(1.5rem, 3vw, 2rem);
}

p {
  margin-bottom: var(--space-md);
  color: var(--text-muted);
}

/* ==========================================================================
   Layout Helpers
   ========================================================================== */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--space-md);
}

.section {
  padding-block: var(--space-xl);
}

@media (min-width: 768px) {
  .section {
    padding-block: var(--space-xxl);
  }
}

.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }

@media (min-width: 768px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* ==========================================================================
   Botones
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  border: 1px solid transparent;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
  text-decoration: none;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  color: #fff;
  text-decoration: none;
}

.btn-secondary {
  background-color: var(--secondary);
  color: #fff;
  text-decoration: none;
}

.btn-secondary:hover {
  background-color: var(--secondary-hover);
  text-decoration: none;
}

.btn-outline {
  background-color: transparent;
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}

.btn-outline:hover {
  background-color: var(--primary);
  color: #fff;
  text-decoration: none;
}

/* ==========================================================================
   Header y Navegación (Mega Menú)
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--surface);
  box-shadow: var(--shadow-sm);
}

.topbar {
  background-color: var(--secondary);
  color: #fff;
  font-size: 0.875rem;
  padding-block: var(--space-xs);
  text-align: right;
}

.topbar a {
  color: #fff;
  margin-left: var(--space-md);
  text-decoration: none;
}

.topbar a:hover {
  text-decoration: underline;
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--nav-height);
  position: relative;
}

.logo {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--primary);
  text-decoration: none;
}

.nav-menu {
  display: none;
}

@media (min-width: 1024px) {
  .nav-menu {
    display: flex;
    gap: var(--space-lg);
    align-items: center;
  }
}

.nav-item {
  position: relative;
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--text-main);
  padding-block: var(--space-sm);
  text-decoration: none;
}

.nav-item:hover {
  color: var(--primary);
  text-decoration: none;
}

/* Mega Menú (Desktop) */
.has-dropdown:hover .mega-menu,
.has-dropdown:focus-within .mega-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.mega-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  width: max-content;
  max-width: 800px;
  background-color: var(--surface);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 101;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  border: 1px solid var(--border-color);
}

.mega-menu-item {
  display: flex;
  flex-direction: column;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  transition: background-color 0.2s;
  text-decoration: none;
}

.mega-menu-item:hover {
  background-color: var(--background);
  text-decoration: none;
}

.mega-menu-title {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.mega-menu-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

/* Menú Hamburguesa (Mobile) */
.mobile-toggle {
  display: block;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-sm);
  position: absolute;
  right: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
}

.mobile-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--text-main);
  margin-bottom: 5px;
  transition: all 0.3s;
}

@media (min-width: 1024px) {
  .mobile-toggle {
    display: none;
  }
}

/* Menú móvil desplegado */
.nav-menu.is-active {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background-color: var(--surface);
  padding: var(--space-md);
  box-shadow: var(--shadow-md);
  gap: var(--space-md);
}

.nav-menu.is-active .mega-menu {
  position: static;
  opacity: 1;
  visibility: visible;
  transform: none;
  box-shadow: none;
  border: none;
  grid-template-columns: 1fr;
  padding: var(--space-sm) 0 0 0;
  width: 100%;
}

/* ==========================================================================
   Cards & Componentes
   ========================================================================== */
.card {
  background-color: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid transparent;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

/* Form inputs */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-family: var(--font-heading);
  font-weight: 600;
  margin-bottom: var(--space-xs);
  color: var(--text-main);
}

.form-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 62, 199, 0.1);
}

/* Accordion (FAQ) */
.accordion-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-sm);
  background-color: var(--surface);
}

.accordion-header {
  width: 100%;
  text-align: left;
  padding: var(--space-md);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.accordion-header::after {
  content: '+';
  font-size: 1.5rem;
  color: var(--primary);
  transition: transform 0.2s;
}

.accordion-item.is-open .accordion-header::after {
  transform: rotate(45deg);
}

.accordion-content {
  padding: 0 var(--space-md);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out, padding 0.3s ease;
}

.accordion-item.is-open .accordion-content {
  padding-bottom: var(--space-md);
  max-height: 500px;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  background-color: var(--secondary);
  color: #fff;
  padding-top: var(--space-xl);
  padding-bottom: var(--space-md);
  margin-top: var(--space-xl);
}

.site-footer p {
  color: #dfe3e7;
}

.site-footer h3 {
  color: #fff;
  font-size: 1.2rem;
  margin-bottom: var(--space-md);
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.footer-links a {
  color: #dfe3e7;
  text-decoration: none;
}

.footer-links a:hover {
  color: #fff;
  text-decoration: underline;
}

.footer-bottom {
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  font-size: 0.875rem;
  color: #c3c7cb;
}

/* ==========================================================================
   Animaciones de Scroll (Optimizadas)
   ========================================================================== */
.js-enabled .animate-on-scroll {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.js-enabled .animate-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .js-enabled .animate-on-scroll {
    transition: none;
    opacity: 1;
    transform: none;
  }
}

/* ==========================================================================
   Efectos Hover en Titulares (Barra corta)
   ========================================================================== */
.section h2::after, .section h3::after {
  content: '';
  display: block;
  width: 0;
  height: 6px;
  background-color: var(--primary);
  border-radius: var(--radius-pill);
  margin-top: 10px;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.section h2:hover::after, .section h3:hover::after {
  width: 64px;
}

/* ==========================================================================
   Iconos de Tarjetas (CSS Masks - Zero Render Blocking)
   ========================================================================== */
a.card h3 {
  display: flex;
  align-items: center;
  gap: 12px;
}
a.card h3::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 24px;
  background-color: var(--primary);
  flex-shrink: 0;
}

/* SEO Local */
a.card[href*="seo-local"] h3::before {
  mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z'/%3E%3Ccircle cx='12' cy='10' r='3'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z'/%3E%3Ccircle cx='12' cy='10' r='3'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* SEO WordPress */
a.card[href*="wordpress"] h3::before {
  mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='18' height='18' x='3' y='3' rx='2' ry='2'/%3E%3Cpath d='M3 9h18'/%3E%3Cpath d='M9 21V9'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='18' height='18' x='3' y='3' rx='2' ry='2'/%3E%3Cpath d='M3 9h18'/%3E%3Cpath d='M9 21V9'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Diseño Web SEO */
a.card[href*="diseno-web"] h3::before {
  mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cpolyline points='8 13 10 15 8 17'/%3E%3Cpolyline points='16 13 14 15 16 17'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cpolyline points='8 13 10 15 8 17'/%3E%3Cpolyline points='16 13 14 15 16 17'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Redactor SEO */
a.card[href*="redactor"] h3::before {
  mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z'/%3E%3Cpath d='m15 5 4 4'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z'/%3E%3Cpath d='m15 5 4 4'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Consultoría SEO */
a.card[href*="consultoria"] h3::before {
  mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpolyline points='16 11 18 13 22 9'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpolyline points='16 11 18 13 22 9'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* SEO YouTube */
a.card[href*="youtube"] h3::before {
  mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22.54 6.42a2.78 2.78 0 0 0-1.94-2C18.88 4 12 4 12 4s-6.88 0-8.6.46a2.78 2.78 0 0 0-1.94 2A29 29 0 0 0 1 11.75a29 29 0 0 0 .46 5.33A2.78 2.78 0 0 0 3.4 19c1.72.46 8.6.46 8.6.46s6.88 0 8.6-.46a2.78 2.78 0 0 0 1.94-2 29 29 0 0 0 .46-5.25 29 29 0 0 0-.46-5.33z'/%3E%3Cpolygon points='9.75 15.02 15.5 11.75 9.75 8.48 9.75 15.02'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22.54 6.42a2.78 2.78 0 0 0-1.94-2C18.88 4 12 4 12 4s-6.88 0-8.6.46a2.78 2.78 0 0 0-1.94 2A29 29 0 0 0 1 11.75a29 29 0 0 0 .46 5.33A2.78 2.78 0 0 0 3.4 19c1.72.46 8.6.46 8.6.46s6.88 0 8.6-.46a2.78 2.78 0 0 0 1.94-2 29 29 0 0 0 .46-5.25 29 29 0 0 0-.46-5.33z'/%3E%3Cpolygon points='9.75 15.02 15.5 11.75 9.75 8.48 9.75 15.02'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ==========================================================================
   Micro-interacciones (Status Dot)
   ========================================================================== */
.status-dot {
  display: block;
  width: 8px;
  height: 8px;
  background-color: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

/* ==========================================================================
   Ajustes menú móvil compacto
   ========================================================================== */
@media (max-width: 1023px) {
  .nav-menu.is-active {
    padding: var(--space-sm);
    gap: 0;
  }
  .nav-item {
    font-size: 1.25rem;
    padding-block: 8px;
  }
  .mega-menu-item {
    padding: 8px;
  }
  .mega-menu-title {
    font-size: 1.15rem;
  }
  .mega-menu-desc {
    display: none;
  }
}
