/* ==========================================================================
   Castock · Tema "Tech Blue"                                    v1 · 2026-07
   --------------------------------------------------------------------------
   Capa 100% ADITIVA. No redeclara layout, no usa !important salvo donde el
   propio catalog-v1.css ya lo hace (preferencia de movimiento reducido),
   y sólo toma control de un elemento si está dentro de:

     html[data-catalog-theme="tech-blue"]   → tema activo explícito
     html:not([data-catalog-theme])         → valor por defecto sin JS

   Así, cuando mañana sumen más temas (ver catalog-personalizer-v1.js),
   cada uno vive en su propio bloque "html[data-catalog-theme='...']" y
   nunca choca con éste. Cargar SIEMPRE después de catalog-v1.css y de
   las demás capas (search/contrast/categories/ratings/dark/demo).
   ========================================================================== */

html[data-catalog-theme="tech-blue"],
html:not([data-catalog-theme]) {

  /* ---------- 1. Tipografía de marca del tema -------------------------- */
  --tb-font-body: "Hanken Grotesk", Inter, ui-sans-serif, system-ui, sans-serif;
  --tb-font-display: "Space Grotesk", "Hanken Grotesk", Inter, sans-serif;
  --tb-font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;

  /* ---------- 2. Paleta (sobrescribe las variables del catálogo) ------- */
  --primary: #2547e0;
  --primary-2: #0b1e63;
  --accent: #17d9f0;
  --surface: #f3f6ff;
  --card: #ffffff;
  --on-primary: #ffffff;
  --ink: #0b1330;
  --muted: #5b6a8c;
  --line: rgba(37, 71, 224, .14);
  --shadow: 0 22px 60px rgba(18, 40, 120, .16);

  /* ---------- 3. Tokens propios del tema -------------------------------- */
  --tb-glow: rgba(23, 217, 240, .45);
  --tb-glow-soft: rgba(37, 71, 224, .16);
  --tb-grid-line: rgba(37, 71, 224, .075);
  --tb-grid-major: rgba(37, 71, 224, .12);
  --tb-orbit-highlight: #dffcff;
  --tb-orbit-mid: #6f86ff;
  --tb-motion: 1;
  --tb-glow-size: 1;

  font-family: var(--tb-font-body);
  color: var(--ink);
  background: var(--surface);
  accent-color: var(--primary);

  /* ---------- 4. El ambiente ancho nunca debe crear scroll lateral ------ */
  &,
  & body { overflow-x: clip; }

  /* ---------- 5. Selección de texto -------------------------------------- */
  & ::selection { background: var(--accent); color: #04122b; }

  /* ---------- 6. Variante oscura (usa el atributo existente data-surface) */
  &[data-surface="dark"] {
    --surface: #060b1f;
    --card: #0e1a3d;
    --ink: #eaf1ff;
    --muted: #8ca0d6;
    --line: rgba(140, 160, 214, .16);
    --shadow: 0 26px 70px rgba(0, 0, 0, .55);
    --tb-grid-line: rgba(234, 241, 255, .075);
    --tb-grid-major: rgba(255, 255, 255, .13);
    --tb-orbit-highlight: #ffffff;
    --tb-orbit-mid: #a9bdff;
    --tb-glow-soft: rgba(23, 217, 240, .10);
  }

  /* ---------- 7. Encabezado: línea de "señal" animada ------------------- */
  & .catalog-header {
    border-bottom-color: var(--line);
    background: color-mix(in srgb, var(--surface) 80%, transparent);
  }
  & .catalog-header::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary) 20%, var(--accent) 50%, var(--primary) 80%, transparent);
    background-size: 220% 100%;
    animation: tb-signal calc(7s / var(--tb-motion)) linear infinite;
    opacity: .8;
  }
  & .icon-button { border-color: var(--line); }
  & .cart-button {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 10px 26px color-mix(in srgb, var(--primary) 35%, transparent);
  }
  & .cart-button .cart-icon { color: #fff; }

  /* ---------- 8. Avatar: anillo en órbita + latido "en vivo" ------------ */
  & .profile-wrap {
    isolation: isolate;
    position: relative;
  }
  & .profile-avatar {
    position: relative;
    z-index: 2;
    border-color: color-mix(in srgb, var(--primary) 14%, white);
    box-shadow:
      0 18px 42px color-mix(in srgb, var(--primary) 24%, transparent),
      0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
  }
  & .profile-wrap::before,
  & .profile-wrap::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    will-change: transform;
  }
  & .profile-wrap::before {
    inset: -10px;
    z-index: 0;
    padding: 2px;
    background: conic-gradient(from 0deg,
      var(--tb-orbit-highlight), var(--accent) 18%, var(--tb-orbit-mid) 45%,
      var(--primary) 68%, color-mix(in srgb, var(--accent) 72%, white) 86%,
      var(--tb-orbit-highlight));
    filter: drop-shadow(0 0 7px color-mix(in srgb, var(--accent) 26%, transparent));
    animation: tb-orbit calc(15s / var(--tb-motion)) linear infinite;
  }
  & .profile-wrap::after {
    inset: -18px;
    z-index: 1;
    padding: 1px;
    background: conic-gradient(from 25deg,
      color-mix(in srgb, var(--primary) 15%, transparent) 0 64%,
      color-mix(in srgb, var(--accent) 22%, transparent) 70%,
      var(--accent) 78%, var(--tb-orbit-highlight) 82%,
      color-mix(in srgb, var(--accent) 56%, transparent) 87%,
      color-mix(in srgb, var(--primary) 15%, transparent) 94% 100%);
    filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 34%, transparent));
    animation: tb-orbit-reverse calc(8.5s / var(--tb-motion)) linear infinite;
  }
  & .live-dot {
    background: var(--accent);
    box-shadow: 0 0 0 0 var(--tb-glow);
    animation: tb-ping calc(2.4s / var(--tb-motion)) ease-out infinite;
  }

  /* ---------- 9. Botón de compartir / redes ------------------------------ */
  & .profile-share { color: var(--primary); }
  & .catalog-socials a:hover { box-shadow: 0 0 0 3px var(--tb-glow-soft); }

  /* ---------- 10. Copy del héroe + halo detrás del título --------------- */
  & .store-hero {
    overflow: visible;
    isolation: isolate;
  }
  & .store-hero::before {
    z-index: -2;
    left: 50%;
    top: 0;
    width: 100vw;
    height: 100%;
    border-radius: 0;
    background-image:
      linear-gradient(var(--tb-grid-major) 1px, transparent 1px),
      linear-gradient(90deg, var(--tb-grid-major) 1px, transparent 1px),
      linear-gradient(var(--tb-grid-line) 1px, transparent 1px),
      linear-gradient(90deg, var(--tb-grid-line) 1px, transparent 1px);
    background-position: center top;
    background-size: 144px 144px, 144px 144px, 36px 36px, 36px 36px;
    background-color: transparent;
    -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgba(0,0,0,.9) 34%, rgba(0,0,0,.42) 68%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 0%, rgba(0,0,0,.9) 34%, rgba(0,0,0,.42) 68%, transparent 100%);
    opacity: .78;
    filter: none;
    transform: translateX(-50%);
    pointer-events: none;
  }
  & .store-hero::after {
    z-index: -1;
    border-color: var(--tb-glow-soft);
    animation: tb-float calc(10s / var(--tb-motion)) ease-in-out infinite;
  }
  & .hero-copy h1,
  & .section-heading h2,
  & .cart-sheet h2,
  & .product-detail-copy h2,
  & .rating-header h2 {
    font-family: var(--tb-font-display);
    letter-spacing: -.03em;
  }
  & .eyebrow,
  & .store-mini small {
    font-family: var(--tb-font-mono);
    letter-spacing: .14em;
  }
  & .whatsapp-link {
    border-color: color-mix(in srgb, var(--primary) 24%, transparent);
    background: var(--card);
    box-shadow: 0 12px 30px var(--tb-glow-soft);
    transition: transform .18s ease, box-shadow .18s ease;
  }
  & .whatsapp-link:hover { transform: translateY(-2px); box-shadow: 0 16px 36px var(--tb-glow-soft); }

  /* ---------- 11. Buscador + categorías ---------------------------------- */
  & .search-field {
    border-color: var(--line);
    box-shadow: 0 10px 30px var(--tb-glow-soft);
  }
  & .search-field:focus-within {
    border-color: color-mix(in srgb, var(--primary) 45%, var(--line));
    box-shadow: 0 0 0 4px var(--tb-glow-soft);
  }
  & .category-strip button,
  & .category-menu-trigger {
    border-color: transparent;
  }
  & .category-strip button.active,
  & .collection-filter-strip button.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 30%, transparent);
  }

  /* ---------- 12. Tarjetas de producto: glow + barrido en hover ---------- */
  & .product-card {
    border-color: var(--line);
    transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
  }
  & .product-card:hover {
    border-color: color-mix(in srgb, var(--primary) 30%, var(--line));
    box-shadow: 0 20px 46px var(--tb-glow-soft), var(--shadow);
  }
  & .product-card::before {
    content: "";
    position: absolute;
    z-index: 3;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: conic-gradient(from var(--tb-frame-angle),
      transparent 0 55%, color-mix(in srgb, var(--primary) 24%, transparent) 62%,
      var(--primary) 70%, var(--accent) 77%, var(--tb-orbit-highlight) 80%,
      var(--accent) 83%, color-mix(in srgb, var(--primary) 32%, transparent) 91%,
      transparent 97% 100%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    pointer-events: none;
    filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent) 18%, transparent));
    transition: opacity .32s ease, filter .32s ease;
  }
  & .product-card:is(:hover, :focus-within)::before {
    opacity: .82;
    filter: drop-shadow(0 0 7px color-mix(in srgb, var(--accent) 24%, transparent));
    animation: tb-frame-flow calc(3.4s / var(--tb-motion)) linear infinite;
  }
  & .product-placeholder {
    background: radial-gradient(circle at 70% 20%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 45%),
                linear-gradient(150deg, color-mix(in srgb, var(--primary) 8%, var(--surface)), color-mix(in srgb, var(--primary) 18%, var(--surface)));
    color: color-mix(in srgb, var(--primary) 82%, black);
  }
  & .stock-dot { box-shadow: 0 0 0 2px color-mix(in srgb, var(--card) 90%, transparent), 0 2px 10px var(--tb-glow); }
  & .price-wrap strong {
    font-family: var(--tb-font-mono);
    letter-spacing: -.01em;
    text-shadow: 0 0 16px color-mix(in srgb, var(--primary) 30%, transparent);
  }
  & .price-wrap small,
  & .product-category { font-family: var(--tb-font-mono); }
  & .add-button {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 10px 22px color-mix(in srgb, var(--primary) 34%, transparent);
    transition: transform .16s ease, box-shadow .16s ease;
  }
  & .add-button:hover:not(:disabled) {
    transform: scale(1.07);
    box-shadow: 0 0 0 8px var(--tb-glow-soft), 0 10px 22px color-mix(in srgb, var(--primary) 34%, transparent);
  }

  /* ---------- 13. Ofertas: el degradé pasa de naranja a cian ------------- */
  & .offer-label {
    background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 78%, #6df3ff), var(--accent));
    box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 45%, transparent), inset 0 1px 0 rgba(255, 255, 255, .3);
    color: #04122b;
  }
  & .price-wrap.offer-price strong,
  & .offer-highlight b,
  & .detail-offer-banner b,
  & .variant-offer-price b { color: #04122b; background: var(--accent); }
  & .price-wrap.offer-price strong { background: none; color: color-mix(in srgb, var(--accent) 70%, var(--ink)); }

  /* ---------- 14. Skeletons: shimmer en tono azul ------------------------ */
  & .skeleton-card > * {
    background: linear-gradient(90deg, color-mix(in srgb, var(--primary) 10%, white), color-mix(in srgb, var(--primary) 3%, white), color-mix(in srgb, var(--primary) 10%, white));
    background-size: 200% 100%;
  }

  /* ---------- 15. Paneles (carrito / producto / ratings) ----------------- */
  & .sheet-dialog { background: rgba(6, 14, 40, .45); backdrop-filter: blur(6px); }
  & .sheet-card,
  & .rating-card {
    border-left: 1px solid var(--line);
    box-shadow: -24px 0 70px rgba(9, 22, 60, .22);
  }
  & .sheet-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
  }
  & .sheet-close { color: var(--ink); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
  & .variant-option:has(input:checked) {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 7%, var(--card));
    box-shadow: 0 0 0 3px var(--tb-glow-soft);
  }
  & .detail-add,
  & .checkout-button {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 14px 30px color-mix(in srgb, var(--primary) 30%, transparent);
  }
  & .qty-control { border-color: var(--line); }

  /* ---------- 16. Calificaciones: estrellas con brillo ------------------- */
  & .rating-overview-star,
  & .rating-star-picker button.is-active,
  & .rating-star-picker button[aria-pressed="true"] {
    color: var(--accent);
    filter: drop-shadow(0 0 6px var(--tb-glow));
  }
  & .rating-submit { background: linear-gradient(135deg, var(--primary), var(--primary-2)); }

  /* ---------- 17. Toast --------------------------------------------------- */
  & .toast {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 18px 40px color-mix(in srgb, var(--primary) 35%, transparent);
  }

  /* ---------- 18. Foco de teclado, accesible y visible ------------------- */
  & :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
}

/* ============================ Keyframes ================================= */
@keyframes tb-signal { to { background-position: -220% 0; } }
@property --tb-frame-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}
@keyframes tb-orbit { to { transform: rotate(1turn); } }
@keyframes tb-orbit-reverse { to { transform: rotate(-1turn); } }
@keyframes tb-frame-flow { to { --tb-frame-angle: 360deg; } }
@keyframes tb-ping {
  0% { box-shadow: 0 0 0 0 var(--tb-glow); }
  70% { box-shadow: 0 0 0 10px rgba(23, 217, 240, 0); }
  100% { box-shadow: 0 0 0 0 rgba(23, 217, 240, 0); }
}
@keyframes tb-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* ===================== Preferencias de movimiento ======================== */
/* Respeta el switch propio del panel de personalización (data-motion). */
html[data-motion="subtle"] {
  & .catalog-header::after,
  & .profile-wrap::before,
  & .profile-wrap::after,
  & .live-dot,
  & .store-hero::after,
  & .product-card::before { animation: none !important; }
}
html[data-motion="vivid"] {
  --tb-glow: rgba(23, 217, 240, .65);
  --tb-glow-soft: rgba(37, 71, 224, .24);
}

/* El sistema operativo manda: si el usuario pidió menos movimiento, se respeta
   igual que ya hace catalog-v1.css con prefers-reduced-motion. */
@media (prefers-reduced-motion: reduce) {
  html[data-catalog-theme="tech-blue"] *,
  html:not([data-catalog-theme]) * {
    animation: none !important;
  }
}

/* Professional polish: precise motion, cleaner neon and stronger CTA contrast. */
html[data-catalog-theme="tech-blue"] :is(.live-dot, .profile-share) {
  z-index: 3;
}

html[data-catalog-theme="tech-blue"] .product-card {
  transform: translateZ(0);
  transition: transform .32s cubic-bezier(.22, 1, .36, 1), box-shadow .32s ease, border-color .24s ease;
}

html[data-catalog-theme="tech-blue"] .product-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 18px 42px color-mix(in srgb, var(--primary) 13%, transparent), 0 4px 16px color-mix(in srgb, var(--ink) 8%, transparent);
}

html[data-catalog-theme="tech-blue"] .product-card:focus-within {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line));
  box-shadow: 0 16px 38px color-mix(in srgb, var(--primary) 12%, transparent), 0 4px 14px color-mix(in srgb, var(--ink) 7%, transparent);
}

html[data-catalog-theme="tech-blue"] .product-media:focus-visible {
  outline: none;
}

html[data-catalog-theme="tech-blue"] .product-card:hover .product-media img {
  transform: scale(1.04);
  transition-duration: .55s;
}

html[data-catalog-theme="tech-blue"] .price-wrap strong {
  text-shadow: 0 1px 0 color-mix(in srgb, var(--card) 78%, transparent), 0 0 12px color-mix(in srgb, var(--primary) 18%, transparent);
}

html[data-catalog-theme="tech-blue"] .add-button {
  transition: transform .3s cubic-bezier(.22, 1.35, .36, 1), box-shadow .3s ease, filter .2s ease;
}

html[data-catalog-theme="tech-blue"] .add-button:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.06) rotate(3deg);
  box-shadow: 0 9px 20px color-mix(in srgb, var(--primary) 27%, transparent);
}

html[data-catalog-theme="tech-blue"] .add-button:active:not(:disabled) {
  transform: translateY(0) scale(.92);
  transition-duration: .1s;
}

html[data-catalog-theme="tech-blue"] .checkout-button,
html[data-catalog-theme="tech-blue"] .checkout-button span {
  color: #ffffff;
  -webkit-text-fill-color: #ffffff;
  text-shadow: none;
}

html[data-catalog-theme="tech-blue"] .checkout-button b {
  color: #0b0b0d;
  -webkit-text-fill-color: #0b0b0d;
  background: #fff;
}
