/*
Theme Name: DamIA Digital
Theme URI: https://damiadigital.com
Author: Alberto Pérez
Author URI: https://damiadigital.com
Description: Tema personalizado para DamIA Digital — Consultor de soluciones digitales en A Coruña.
Version: 1.0.0
License: GNU General Public License v2 or later
Text Domain: damia-digital
*/

/* === VARIABLES === */
:root {
  --violet: #a855f7;
  --violet-dark: #9333ea;
  --teal: #14b8a6;
  --dark: #020617;
  --dark2: #0a0f1e;
  --dark3: #111827;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: rgba(255,255,255,0.07);
  --border-input: rgba(255,255,255,0.11);
  --font: 'Plus Jakarta Sans', sans-serif;
  --r: 14px;
  --t: 0.28s ease;
  --max: 1100px;
  --pad: clamp(80px, 9vw, 120px);
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--dark); color: var(--text); overflow-x: hidden; line-height: 1.6; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; height: auto; display: block; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* === LAYOUT === */
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 clamp(20px, 5vw, 48px); }
section { padding: var(--pad) 0; }

/* === ANIMATIONS === */
@keyframes fadeUp { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(20,184,166,0.5); } 50% { box-shadow: 0 0 0 6px rgba(20,184,166,0); } }
@keyframes shimmer { from { background-position: -600px 0; } to { background-position: 600px 0; } }

.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.on { opacity: 1; transform: translateY(0); }
.d1 { transition-delay: 0.1s; }
.d2 { transition-delay: 0.18s; }
.d3 { transition-delay: 0.26s; }

/* === LABELS === */
.s-label { display: inline-block; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--violet); margin-bottom: 12px; }
.s-title { font-size: clamp(1.7rem, 3.2vw, 2.4rem); font-weight: 800; color: var(--text); line-height: 1.2; letter-spacing: -0.02em; margin-bottom: 16px; }
.s-title em { font-style: normal; background: linear-gradient(135deg, var(--violet), var(--teal)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

/* === HEADER === */
header { position: fixed; top: 0; left: 0; right: 0; z-index: 100; padding: 16px 0; transition: background 0.4s, box-shadow 0.4s; }
header.scrolled { background: rgba(2,6,23,0.92); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: 0 1px 0 var(--border); }
.nav { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.nav-logo img { height: 34px; width: auto; display: block; }
.nav-links { display: flex; align-items: center; gap: 2px; }
.nav-links a { padding: 7px 14px; border-radius: 8px; font-size: 0.88rem; font-weight: 500; color: var(--muted); transition: color var(--t), background var(--t); }
.nav-links a:hover, .nav-links a.active { color: var(--text); background: rgba(255,255,255,0.06); }
.btn-nav { padding: 8px 20px; border-radius: 8px; background: var(--violet); color: #fff; font-size: 0.88rem; font-weight: 700; font-family: var(--font); border: none; cursor: pointer; transition: background var(--t), transform var(--t); display: inline-block; }
.btn-nav:hover { background: var(--violet-dark); transform: translateY(-1px); color: #fff; }
.hamburger { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 4px; }
.hamburger span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; transition: var(--t); }

/* === BUTTONS === */
.btn-primary { display: inline-flex; align-items: center; gap: 8px; background: var(--violet); color: #fff; padding: 13px 28px; border-radius: var(--r); font-weight: 700; font-size: 0.95rem; font-family: var(--font); border: none; cursor: pointer; box-shadow: 0 4px 24px rgba(168,85,247,0.28); transition: background var(--t), transform var(--t), box-shadow var(--t); }
.btn-primary:hover { background: var(--violet-dark); transform: translateY(-2px); box-shadow: 0 8px 32px rgba(168,85,247,0.36); color: #fff; }
.btn-ghost { display: inline-flex; align-items: center; gap: 8px; background: transparent; color: var(--text); padding: 13px 28px; border-radius: var(--r); border: 1px solid rgba(255,255,255,0.11); font-weight: 600; font-size: 0.95rem; transition: border-color var(--t), background var(--t), transform var(--t); }
.btn-ghost:hover { border-color: rgba(255,255,255,0.22); background: rgba(255,255,255,0.04); transform: translateY(-2px); color: var(--text); }

/* === PAGE HERO === */
.page-hero { padding-top: 130px; padding-bottom: var(--pad); position: relative; overflow: hidden; }
.page-hero-bg { position: absolute; inset: 0; z-index: 0; background: radial-gradient(ellipse 55% 50% at 90% 20%, rgba(168,85,247,0.09) 0%, transparent 60%), radial-gradient(ellipse 40% 35% at 15% 75%, rgba(20,184,166,0.05) 0%, transparent 55%); }
.page-hero .wrap { position: relative; z-index: 1; }
.page-hero h1 { font-size: clamp(2.2rem, 4.5vw, 3.4rem); font-weight: 800; line-height: 1.13; letter-spacing: -0.03em; color: var(--text); max-width: 680px; margin-bottom: 20px; animation: fadeUp 0.6s ease both; }
.page-hero h1 em { font-style: normal; background: linear-gradient(135deg, var(--violet), var(--teal)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.page-hero p { font-size: 1.05rem; color: var(--muted); max-width: 520px; line-height: 1.78; animation: fadeUp 0.6s ease 0.12s both; }
.page-hero-center .page-hero h1 { margin-left: auto; margin-right: auto; text-align: center; }
.page-hero-center .page-hero p { margin-left: auto; margin-right: auto; text-align: center; }

/* === FOOTER === */
footer { border-top: 1px solid var(--border); padding: 40px 0; background: var(--dark2); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 20px; }
.footer-logo img { height: 28px; width: auto; opacity: 0.8; }
.footer-links { display: flex; gap: 24px; flex-wrap: wrap; }
.footer-links a { font-size: 0.83rem; color: var(--muted); transition: color var(--t); }
.footer-links a:hover { color: var(--violet); }
.footer-copy { font-size: 0.78rem; color: var(--muted); }
.footer-copy a { color: var(--violet); }

/* === DAMI AI WIDGET === */
#n8n-chat { display: none !important; }
.dami-widget { position: fixed !important; bottom: 28px !important; right: 28px !important; z-index: 99999 !important; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; font-family: var(--font); }
.dami-pill { display: flex; align-items: center; gap: 10px; background: var(--dark2); border: 1px solid rgba(168,85,247,0.3); border-radius: 100px; padding: 10px 18px 10px 10px; cursor: pointer; box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 20px rgba(168,85,247,0.08); transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.28s ease, border-color 0.28s ease, opacity 0.3s ease; user-select: none; white-space: nowrap; }
.dami-pill:hover { transform: scale(1.05) translateY(-2px); box-shadow: 0 12px 48px rgba(0,0,0,0.6), 0 0 24px rgba(168,85,247,0.18); border-color: rgba(168,85,247,0.55); }
.dami-pill.hidden { opacity: 0; pointer-events: none; transform: scale(0.85) translateY(10px); }
.dami-pill span { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.dami-orb { width: 32px; height: 32px; border-radius: 50%; position: relative; overflow: hidden; flex-shrink: 0; pointer-events: none; }
.dami-orb::before { content: ''; position: absolute; inset: -40%; background: conic-gradient(from 0deg at 30% 70%, #a855f7 0%, transparent 25%, transparent 75%, #a855f7 100%), conic-gradient(from 120deg at 70% 25%, #14b8a6 0%, transparent 30%, transparent 70%, #14b8a6 100%), conic-gradient(from 240deg at 50% 50%, #7c3aed 0%, transparent 40%, transparent 60%, #7c3aed 100%); filter: blur(4px) contrast(2); animation: orb-spin 5s linear infinite; }
.dami-orb::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 40% 40%, rgba(255,255,255,0.18), transparent 60%); }
@keyframes orb-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dami-orb::before { animation: none; } }
.dami-orb-sm { width: 38px; height: 38px; }
.dami-panel { position: absolute; bottom: calc(100% + 12px); right: 0; width: 340px; background: var(--dark2); border: 1px solid rgba(168,85,247,0.18); border-radius: 20px; overflow: hidden; box-shadow: 0 24px 64px rgba(0,0,0,0.65), 0 0 0 1px rgba(168,85,247,0.06); opacity: 0; transform: scale(0.88) translateY(24px); transform-origin: bottom right; pointer-events: none; transition: opacity 0.42s cubic-bezier(0.34,1.56,0.64,1), transform 0.42s cubic-bezier(0.34,1.56,0.64,1); }
.dami-panel.open { opacity: 1; transform: scale(1) translateY(0); pointer-events: auto; }
.dami-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 12px; border-bottom: 1px solid var(--border); background: linear-gradient(135deg, rgba(168,85,247,0.07), rgba(20,184,166,0.03)); }
.dami-head-left { display: flex; align-items: center; gap: 11px; }
.dami-name { font-size: 0.92rem; font-weight: 700; color: var(--text); }
.dami-online { display: flex; align-items: center; gap: 5px; font-size: 0.72rem; color: var(--teal); font-weight: 500; }
.dami-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); animation: pulse 2s ease-in-out infinite; flex-shrink: 0; }
.dami-close-btn { background: none; border: none; color: var(--muted); font-size: 1rem; cursor: pointer; padding: 4px 8px; border-radius: 6px; transition: color 0.2s, background 0.2s; line-height: 1; }
.dami-close-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.dami-msgs { height: 280px; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.dami-msgs::-webkit-scrollbar { width: 4px; } .dami-msgs::-webkit-scrollbar-track { background: transparent; } .dami-msgs::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }
.dami-msg { display: flex; max-width: 88%; }
.dami-msg span { padding: 10px 14px; border-radius: 14px; font-size: 0.85rem; line-height: 1.65; word-break: break-word; }
.dami-msg-bot { align-self: flex-start; } .dami-msg-bot span { background: var(--dark3); color: var(--text); border-bottom-left-radius: 4px; }
.dami-msg-user { align-self: flex-end; margin-left: auto; } .dami-msg-user span { background: var(--violet); color: #fff; border-bottom-right-radius: 4px; }
.dami-typing span { background: var(--dark3); color: var(--muted); font-style: italic; }
.dami-form { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); }
.dami-input { flex: 1; background: var(--dark3); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-family: var(--font); font-size: 16px; color: var(--text); outline: none; transition: border-color 0.2s, box-shadow 0.2s; }
.dami-input::placeholder { color: var(--muted); } .dami-input:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(168,85,247,0.1); }
.dami-send { width: 36px; height: 36px; border-radius: 10px; background: var(--violet); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; transition: background 0.2s, transform 0.2s; }
.dami-send:hover { background: var(--violet-dark); transform: scale(1.08); } .dami-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
@media (max-width: 480px) { .dami-panel { width: calc(100vw - 32px); } .dami-widget { bottom: 20px; right: 16px; } }

/* === N8N CHAT WIDGET === */
#n8n-chat {
  --chat--color-primary: #a855f7;
  --chat--color-primary-shade-50: #9333ea;
  --chat--color-secondary: #14b8a6;
  --chat--color-white: #e2e8f0;
  --chat--color-light: #94a3b8;
  --chat--color-light-shade-50: #64748b;
  --chat--color-dark: #020617;
  --chat--border-radius: 18px;
  --chat--toggle--background: #a855f7;
  --chat--toggle--hover--background: #9333ea;
  --chat--toggle--size: 52px;
  --chat--header--background: #020617;
  --chat--header--color: #e2e8f0;
  --chat--message--bot--background: #0a0f1e;
  --chat--message--bot--color: #e2e8f0;
  --chat--message--user--background: #a855f7;
  --chat--message--user--color: #ffffff;
  --chat--color-background: #020617;
  --chat--input--background: #111827;
  --chat--input--border-color: rgba(255,255,255,0.08);
  --chat--font-family: 'Plus Jakarta Sans', sans-serif;
  --chat--window--width: 380px;
  --chat--window--height: 520px;
}

/* === MOBILE MENU === */
body.menu-open { overflow: hidden; }
body.nav-open { overflow: hidden; }
header.nav-active { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; background: #020617 !important; box-shadow: none !important; z-index: 9999999 !important; }

/* ---- Tablet ≤1024px ---- */
@media (max-width: 1024px) {
  .hero { padding-top: 100px; padding-bottom: 50px; }
  .services-grid { grid-template-columns: repeat(2, 1fr); }
  .projects-grid { grid-template-columns: repeat(2, 1fr); }
  .cta-section { padding: 60px 0; }
}

/* ---- Tablet only 769–1024px ---- */
@media (min-width: 769px) and (max-width: 1024px) {
  .who-inner { grid-template-columns: 1fr; gap: 40px; }
  .contact-grid { grid-template-columns: 1fr; gap: 40px; }
  .about-grid { gap: 48px; }
  .why-grid { grid-template-columns: repeat(2, 1fr); }
  .trust-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .valores-grid { grid-template-columns: repeat(2, 1fr); }
  .proyectos-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Mobile ≤768px ---- */
@media (max-width: 768px) {
  /* Menú móvil */
  .nav-links {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #020617;
    padding: 96px 24px 40px;
    gap: 4px;
    z-index: 999999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
    overflow-y: auto;
  }
  .nav-links.open { opacity: 1; pointer-events: auto; }
  .nav-links a {
    position: relative;
    z-index: 1;
    font-size: 1.35rem;
    padding: 16px 20px;
    border-radius: 14px;
    font-weight: 700;
    color: var(--muted);
    transition: color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: none;
  }
  .nav-links a::after {
    content: '→';
    font-size: 0.95rem;
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.2s, transform 0.2s;
    color: var(--violet);
  }
  .nav-links a:hover { color: var(--text); background: rgba(168,85,247,0.07); }
  .nav-links a:hover::after { opacity: 1; transform: translateX(0); }
  .nav-links a.active { color: var(--violet); background: rgba(168,85,247,0.08); }
  .nav-links a.active::after { opacity: 1; transform: translateX(0); }

  /* CTA dentro del menú móvil */
  .nav-mobile-cta {
    position: relative;
    z-index: 1;
    margin-top: 16px;
    display: block;
    text-align: center;
    padding: 15px 20px;
    border-radius: 14px;
    background: var(--violet);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
  }

  .btn-nav { display: none; }
  .hamburger { display: flex; z-index: 9999999; position: relative; }
  body.nav-open .dami-widget { display: none !important; }
  .hamburger span { transition: transform 0.3s ease, opacity 0.3s ease; }
  .hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .hamburger.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
  .hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* Variables */
  :root { --pad: clamp(48px, 8vw, 80px); }

  /* Hero */
  .hero { padding-top: 80px; padding-bottom: 40px; min-height: auto; }
  .hero h1 { font-size: clamp(1.75rem, 7vw, 2.4rem); }
  .hero p { font-size: 0.93rem; }
  .hero-btns { flex-direction: column; }
  .hero-tag { font-size: 0.78rem; }

  /* Botones */
  .btn-primary, .btn-ghost { justify-content: center; text-align: center; }

  /* Tipografía */
  .s-title { font-size: clamp(1.35rem, 5vw, 1.8rem); }
  .s-label { font-size: 0.72rem; }
  .page-hero h1 { font-size: clamp(1.65rem, 6vw, 2.2rem); }
  .page-hero p { font-size: 0.92rem; }

  /* Layouts 1 columna */
  .who-inner { grid-template-columns: 1fr; gap: 36px; }
  .about-grid { grid-template-columns: 1fr; gap: 40px; }
  .about-photo { aspect-ratio: 4/3; }
  .contact-grid { grid-template-columns: 1fr; gap: 36px; }
  .form-row { grid-template-columns: 1fr; }

  /* Grids 1 columna en móvil (sobreescriben las reglas de 1024px) */
  .services-grid { grid-template-columns: 1fr; gap: 10px; }
  .projects-grid { grid-template-columns: 1fr; gap: 14px; }
  .why-grid { grid-template-columns: 1fr; }
  .trust-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .valores-grid { grid-template-columns: 1fr; }
  .proyectos-grid { grid-template-columns: 1fr; }

  /* Secciones */
  .who-section, .services-section, .projects-section,
  .why-section, .cta-section, .formacion-section,
  .valores-section, .proyectos-section, .trust-section { padding: 48px 0; }

  /* Cards */
  .svc-card { padding: 20px; }

  /* Footer */
  footer .footer-inner { flex-direction: column; align-items: flex-start; gap: 16px; }
  .footer-links { gap: 14px; }

  /* CTA */
  .cta-section { text-align: center; }

  /* Chatbot panel en móvil — position fixed para que no salga del viewport */
  .dami-widget { bottom: 20px; right: 16px; }
  .dami-panel {
    position: fixed;
    bottom: 80px;
    right: 16px;
    left: 16px;
    width: auto;
    max-height: calc(100svh - 120px);
    transform-origin: bottom center;
    border-radius: 16px;
  }
  .dami-msgs { height: 200px; }
}

/* ---- Small mobile ≤480px ---- */
@media (max-width: 480px) {
  :root { --pad: clamp(40px, 7vw, 64px); }
  .hero h1 { font-size: clamp(1.55rem, 8vw, 1.9rem); }
  .hero-btns { gap: 10px; }
  .svc-card, .why-card, .form-card, .valor-card, .trust-card { padding: 18px; }
  .who-card { padding: 14px; }
  .btn-primary, .btn-ghost { padding: 12px 20px; font-size: 0.93rem; }
  .footer-links { gap: 10px; flex-wrap: wrap; }
  .page-hero { padding-top: 110px; }
}
