/* =============================================
   services.css — Bento Grid Services Component
   Riparazioni Ricci — Component Library
   ============================================= */

/* ── Bento Grid ── */
.bento {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: minmax(200px, auto);
  gap: 14px;
  max-width: var(--container-max, 1100px);
  margin: 0 auto;
}

/* ── Tile base ── */
.tile {
  background: var(--color-background, #fff);
  border: 1px solid var(--surface-glass-border, rgba(0,0,0,0.06));
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  position: relative;
  overflow: hidden;
  transition: transform 300ms var(--ease-out),
              box-shadow 300ms ease,
              border-color 300ms ease;
}

.tile:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
}

/* ── Glow Border Effect ── */
@property --glow-angle {
  syntax: '<number>';
  initial-value: 0;
  inherits: false;
}

.tile .glow-effect {
  pointer-events: none;
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 2px;
  background: conic-gradient(
    from calc(var(--glow-angle) * 1deg),
    transparent 0%,
    #dd7bbb 5%,
    #d79f1e 10%,
    #5a922c 15%,
    #4c7894 20%,
    transparent 25%,
    transparent 100%
  );
  -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;
  opacity: 0;
  transition: opacity 300ms ease;
  z-index: 0;
}

/* ── Tile 1: Riparazione (grande, 2 col) ── */
.tile-main {
  grid-column: span 2;
  display: flex;
  align-items: center;
  gap: 32px;
  --tile-accent: var(--color-primary);
}

.tile-main:hover {
  border-color: rgba(var(--color-primary-rgb), 0.15);
}

.tile-text {
  flex: 1;
}

.tile-text h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-foreground);
  margin-bottom: 8px;
}

.tile-text p {
  font-size: 14px;
  color: var(--slate-500);
  line-height: 1.6;
  margin-bottom: 16px;
}

.tile-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary);
  text-decoration: none;
  transition: gap 250ms var(--ease-out);
}

.tile-link:hover {
  gap: 10px;
}

/* SVG wrench — animated */
.svg-wrench {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  color: var(--color-primary);
  opacity: 0.15;
  transition: transform 400ms var(--ease-out), opacity 300ms ease;
  animation: wrench-idle 4s ease-in-out infinite;
}

.tile-main:hover .svg-wrench {
  opacity: 0.25;
  animation: wrench-active 0.6s ease;
}

@keyframes wrench-idle {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(3deg); }
}

@keyframes wrench-active {
  0% { transform: rotate(0) scale(1); }
  25% { transform: rotate(15deg) scale(1.1); }
  50% { transform: rotate(-10deg) scale(1.05); }
  75% { transform: rotate(5deg) scale(1.02); }
  100% { transform: rotate(0) scale(1); }
}

/* ── Tile 2: A Domicilio (steps) ── */
.tile-domicilio {
  --tile-accent: var(--color-success);
  background: var(--surface-warm);
}

.tile-domicilio:hover {
  border-color: rgba(var(--color-success-rgb), 0.2);
}

.tile-domicilio h3 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.mini-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 300ms var(--ease-out), box-shadow 300ms ease;
}

.tile-domicilio:hover .mini-step:nth-child(1) .step-num {
  transition-delay: 0ms;
  transform: scale(1.1);
  box-shadow: 0 0 10px rgba(var(--color-primary-rgb), 0.3);
}

.tile-domicilio:hover .mini-step:nth-child(2) .step-num {
  transition-delay: 100ms;
  transform: scale(1.1);
  box-shadow: 0 0 10px rgba(var(--color-primary-rgb), 0.3);
}

.tile-domicilio:hover .mini-step:nth-child(3) .step-num {
  transition-delay: 200ms;
  transform: scale(1.1);
  box-shadow: 0 0 10px rgba(var(--color-primary-rgb), 0.3);
}

.step-label {
  font-size: 13px;
  color: var(--slate-600);
  font-weight: 500;
}

.step-connector {
  width: 26px;
  display: flex;
  justify-content: center;
  padding: 0;
}

.step-connector .line {
  width: 2px;
  height: 12px;
  background: rgba(var(--color-primary-rgb), 0.15);
  border-radius: 1px;
}

/* Truck icon */
.svg-truck {
  width: 32px;
  height: 32px;
  color: var(--color-success);
  opacity: 0.4;
  margin-top: 8px;
  transition: transform 500ms var(--ease-out), opacity 300ms ease;
}

.tile-domicilio:hover .svg-truck {
  transform: translateX(6px);
  opacity: 0.6;
}

/* ── Tile 3: Ricambi ── */
.tile-ricambi {
  --tile-accent: var(--color-accent);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.tile-ricambi:hover {
  border-color: rgba(var(--color-accent-rgb), 0.2);
}

.svg-package {
  width: 52px;
  height: 52px;
  color: var(--color-accent);
  opacity: 0.6;
  transition: transform 400ms var(--ease-out), opacity 300ms ease;
}

.tile-ricambi:hover .svg-package {
  opacity: 0.8;
  animation: unwrap 0.6s var(--ease-out);
}

@keyframes unwrap {
  0% { transform: scale(1) rotate(0); }
  30% { transform: scale(1.12) rotate(-5deg); }
  60% { transform: scale(1.05) rotate(3deg); }
  100% { transform: scale(1) rotate(0); }
}

.tile-ricambi h3 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 14px;
  background: rgba(var(--color-accent-rgb), 0.08);
  color: var(--color-accent);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  transition: box-shadow 300ms ease;
}

.tile-ricambi:hover .badge-pill {
  box-shadow: 0 0 12px rgba(var(--color-accent-rgb), 0.15);
}

/* ── Tile 4: Assistenza (chat bubble) ── */
.tile-assistenza {
  --tile-accent: var(--color-info);
}

.tile-assistenza:hover {
  border-color: rgba(6, 182, 212, 0.2);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.chat-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(6, 182, 212, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.chat-icon-wrap svg {
  width: 18px;
  height: 18px;
  color: var(--color-info);
}

.notif-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background: var(--color-success);
  border-radius: 50%;
  border: 2px solid var(--color-background, #fff);
  animation: notif-pulse 2s ease-in-out infinite;
}

@keyframes notif-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

.tile-assistenza h3 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
}

.chat-bubble {
  background: var(--surface-subtle);
  border-radius: 12px 12px 12px 4px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--slate-600);
  line-height: 1.55;
  transition: transform 300ms var(--ease-out);
}

.tile-assistenza:hover .chat-bubble {
  transform: translateY(-2px);
}

/* ── Tile 5: Stats accent (dark) ── */
.tile-stats {
  background: var(--color-foreground);
  color: #fff;
  border-color: rgba(255,255,255,0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  position: relative;
}

.tile-stats:hover {
  border-color: rgba(var(--color-primary-rgb), 0.2);
  background: var(--slate-800);
}

/* Gradient border animation */
@property --svc-border-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

.tile-stats::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1.5px;
  background: conic-gradient(
    from var(--svc-border-angle, 0deg),
    rgba(var(--color-primary-rgb), 0.08),
    rgba(var(--color-primary-rgb), 0.3),
    rgba(6, 182, 212, 0.2),
    rgba(var(--color-primary-rgb), 0.08)
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: svc-rotate-border 6s linear infinite;
  pointer-events: none;
}

@keyframes svc-rotate-border {
  to { --svc-border-angle: 360deg; }
}

.stat-row {
  display: flex;
  justify-content: space-around;
  gap: 16px;
}

.stat-item {
  text-align: center;
}

.stat-num {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 4vw, 2.2rem);
  font-weight: 800;
  line-height: 1;
  transition: color 300ms ease, text-shadow 300ms ease;
}

.tile-stats:hover .stat-num {
  color: rgba(96, 165, 250, 1);
  text-shadow: 0 0 20px rgba(var(--color-primary-rgb), 0.3);
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.4);
  margin-top: 6px;
  font-weight: 500;
}

.tile-stats h3 {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  text-align: center;
}

/* ── CTA inline sotto il bento ── */
.section-cta {
  text-align: center;
  margin-top: clamp(1.5rem, 3vw, 2.5rem);
}

.btn-cta svg {
  width: 18px;
  height: 18px;
}

/* ── Responsive ── */
@media (max-width: 1023px) {
  .bento {
    grid-template-columns: repeat(2, 1fr);
  }
  .tile-main {
    grid-column: span 2;
  }
  .tile-stats {
    grid-column: span 2;
  }
  .stat-row {
    gap: 8px;
  }
}

@media (max-width: 768px) {
  .bento {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* Main tile: full width, horizontal layout compatto */
  .tile-main {
    grid-column: span 2;
    flex-direction: row;
    gap: 14px;
    align-items: flex-start;
  }
  .tile-main .tile-text p { display: none; }
  .tile-main .tile-text h3 { font-size: 1rem; margin-bottom: 6px; }
  .svg-wrench {
    width: 36px;
    height: 36px;
  }

  /* Small tiles: 2 colonne affiancate */
  .tile-domicilio,
  .tile-ricambi,
  .tile-assistenza {
    grid-column: span 1;
  }

  /* Stats tile: full width, stat row compatto */
  .tile-stats {
    grid-column: span 2;
    padding: 20px 16px;
  }
  .stat-row {
    gap: 4px;
  }
  .stat-num {
    font-size: 1.4rem;
  }
  .stat-label {
    font-size: 10px;
  }
  .tile-stats h3 {
    font-size: 0.75rem;
  }

  /* Compattare tutte le tile */
  .tile {
    padding: 16px 14px;
  }

  /* Domicilio tile: nascondi connettori e step label, mostra solo numeri */
  .tile-domicilio h3 { font-size: 0.9rem; margin-bottom: 10px; }
  .step-connector { display: none; }
  .mini-steps { gap: 4px; }
  .mini-step { padding: 4px 0; gap: 8px; }
  .step-num { width: 22px; height: 22px; font-size: 10px; }
  .step-label { font-size: 12px; }
  .svg-truck { display: none; }

  /* Ricambi tile: compatto */
  .tile-ricambi { gap: 8px; }
  .svg-package { width: 36px; height: 36px; }
  .tile-ricambi h3 { font-size: 0.9rem; }
  .badge-pill { font-size: 11px; padding: 4px 10px; }

  /* Assistenza tile: compatto */
  .chat-header { margin-bottom: 8px; gap: 8px; }
  .chat-icon-wrap { width: 28px; height: 28px; border-radius: 8px; }
  .chat-icon-wrap svg { width: 14px; height: 14px; }
  .tile-assistenza h3 { font-size: 0.9rem; }
  .chat-bubble { font-size: 12px; padding: 10px 12px; }

  /* CTA */
  .section-cta .btn-cta {
    width: 100%;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .svg-wrench,
  .svg-truck,
  .svg-package {
    animation: none !important;
  }
  .notif-dot {
    animation: none;
  }
  .tile-stats::after {
    animation: none;
  }
}
