/* Universal Connect — cartes des services (haut de page)
   Cadre traversé par un rayon de lumière, icône qui respire, lueur qui suit la souris.
   Chaque carte a sa couleur : --tone (vive) et --tone-light (claire), en composantes RVB. */

/* Angle animable du rayon (sans @property, le cadre reste fixe mais visible) */
@property --beam-angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

.services {
  --tone: 77 124 255; --tone-light: 165 190 255;   /* couleur par défaut (bleu électrique), héritée par les cartes */
  position: relative; z-index: 1; list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px;
}

/* Décalage des animations par carte (--i) : en CSS plutôt qu'en style="" dans le HTML, pour une CSP stricte */
.services > :nth-child(2) { --i: 1; }
.services > :nth-child(3) { --i: 2; }
.services > :nth-child(4) { --i: 3; }
.services > :nth-child(5) { --i: 4; }

/* Une couleur par service, choisie pour le fond bleu nuit du site */
.service--landing { --tone: 77 124 255; --tone-light: 165 190 255; }   /* bleu électrique */
.service--web     { --tone: 56 189 248; --tone-light: 125 211 252; }   /* bleu ciel */
.service--apps    { --tone: 167 139 250; --tone-light: 196 181 253; }  /* violet */
.service--repair  { --tone: 52 211 153; --tone-light: 110 231 183; }   /* vert émeraude */
.service--games   { --tone: 251 90 140; --tone-light: 253 164 192; }   /* rose framboise */

.service {
  --mx: 50%; --my: 0%;   /* position de la souris, mise à jour par effects/card-glow.js */
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; border-radius: var(--radius-m);
  border-color: transparent;   /* le cadre est dessiné par ::before */
  /* Fond presque noir et opaque : la carte se détache du fond orangé et de la Terre */
  background: linear-gradient(165deg, rgb(var(--tone) / 0.24) 0%, rgb(8 12 26 / 0.9) 48%, rgb(5 8 18 / 0.94) 100%);
  box-shadow: 0 14px 34px -14px rgb(0 0 0 / 0.85), 0 0 0 1px rgb(0 0 0 / 0.35);
  /* « translate » et non « transform » : GSAP anime transform à l'entrée, les deux ne se gênent pas */
  transition: translate 0.35s cubic-bezier(.2, .8, .2, 1), box-shadow 0.35s ease;
}

/* Cadre : fin trait de couleur + rayon de lumière qui en fait le tour */
.service::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; padding: 1px;
  background:
    conic-gradient(from var(--beam-angle), transparent 0 72%, rgb(var(--tone-light)) 86%, rgb(var(--tone)) 93%, transparent 100%),
    linear-gradient(160deg, rgb(var(--tone-light) / 0.75), rgb(var(--tone) / 0.18) 50%, rgb(var(--tone) / 0.45));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: service-beam 7s linear infinite;
  animation-delay: calc(var(--i, 0) * -1.4s);   /* chaque carte a son rayon décalé */
}
@keyframes service-beam { to { --beam-angle: 360deg; } }

/* Lueur qui suit la souris */
.service::after {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: radial-gradient(220px circle at var(--mx) var(--my), rgb(var(--tone) / 0.24), transparent 70%);
  opacity: 0; transition: opacity 0.35s ease;
}

.service:hover { translate: 0 -6px; box-shadow: 0 18px 40px -14px rgb(0 0 0 / 0.85), 0 10px 44px -10px rgb(var(--tone) / 0.6); }
.service:hover::after { opacity: 1; }

.service-icon {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px;
  color: rgb(var(--tone-light));
  background: radial-gradient(circle at 30% 25%, rgb(var(--tone-light) / 0.35), rgb(var(--tone) / 0.12) 70%);
  box-shadow: inset 0 0 0 1px rgb(var(--tone-light) / 0.35);
  animation: service-breathe 4s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * -0.8s);
  transition: transform 0.35s cubic-bezier(.2, .8, .2, 1), color 0.35s ease;
}
.service-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
@keyframes service-breathe {
  50% { box-shadow: inset 0 0 0 1px rgb(var(--tone-light) / 0.6), 0 0 22px rgb(var(--tone) / 0.45); }
}
.service:hover .service-icon { transform: scale(1.08) rotate(-6deg); color: #FFFFFF; }

.service-heading { margin: 0; display: flex; flex: 1; }
/* Toute la carte est un bouton : un clic ouvre le détail du service */
.service-btn {
  flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 14px;
  padding: 20px; border: 0; border-radius: inherit; background: none; color: inherit; cursor: pointer; text-align: left;
  font-family: var(--font-display); font-weight: 600; font-size: 18px; position: relative;
}
.service-btn:focus-visible { outline: 2px solid rgb(var(--tone-light)); outline-offset: -2px; }
/* Petit « + » en haut à droite qui devient « × » quand la carte est ouverte */
.service-plus { position: absolute; top: 18px; right: 18px; width: 22px; height: 22px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgb(var(--tone-light) / 0.4); transition: transform 0.35s cubic-bezier(.2, .8, .2, 1), background 0.35s ease; }
.service-plus::before, .service-plus::after { content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 1.6px;
  translate: -50% -50%; border-radius: 2px; background: rgb(var(--tone-light)); }
.service-plus::after { rotate: 90deg; }
.service-btn:hover .service-plus { background: rgb(var(--tone) / 0.25); }
.service-btn[aria-expanded="true"] .service-plus { transform: rotate(45deg); background: rgb(var(--tone) / 0.35); }
.service:has(.service-btn[aria-expanded="true"]) {
  translate: 0 -6px; box-shadow: 0 18px 40px -14px rgb(0 0 0 / 0.85), 0 10px 44px -10px rgb(var(--tone) / 0.7);
}

/* ---------- Détail d'un service (s'ouvre au clic, au-dessus des cartes sur ordinateur) ---------- */
.services-wrap { position: relative; z-index: 2; }
.service-panel {
  --arrow-x: 50%;
  position: absolute; left: 50%; bottom: calc(100% + 18px); translate: -50% 0; z-index: 3;
  width: min(640px, 100%); padding: 26px 28px 24px; border-radius: var(--radius-l);
  background: linear-gradient(160deg, rgb(var(--tone) / 0.28) 0%, rgb(8 12 26 / 0.96) 45%, rgb(5 8 18 / 0.97) 100%);
  box-shadow: 0 30px 70px -20px rgb(0 0 0 / 0.95), 0 0 0 1px rgb(var(--tone-light) / 0.35), 0 0 60px -18px rgb(var(--tone) / 0.7);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transform-origin: var(--arrow-x) 100%;
}
.service-panel:not([hidden]) { animation: panel-in 0.5s cubic-bezier(.2, .9, .25, 1.15) both; }
.service-panel.is-closing { animation: panel-out 0.22s ease-in both; }
@keyframes panel-in { from { opacity: 0; transform: translateY(18px) scale(0.92); filter: blur(6px); } }
@keyframes panel-out { to { opacity: 0; transform: translateY(10px) scale(0.96); } }
/* Petite flèche qui pointe vers la carte cliquée */
.service-panel::after {
  content: ""; position: absolute; bottom: -8px; left: var(--arrow-x); width: 16px; height: 16px; translate: -50% 0; rotate: 45deg;
  background: rgb(5 8 18); box-shadow: 1px 1px 0 0 rgb(var(--tone-light) / 0.35);
}
.service-panel-close {
  position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: rgb(255 255 255 / 0.06); color: var(--ink); cursor: pointer;
}
.service-panel-close:hover { background: rgb(255 255 255 / 0.14); }
.service-panel-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.service-detail { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.service-detail[hidden], .service-panel[hidden] { display: none; }
.service-detail > * { margin: 0; animation: detail-in 0.5s cubic-bezier(.2, .8, .2, 1) both; }
.service-detail > :nth-child(2) { animation-delay: 0.08s; }
.service-detail > :nth-child(3) { animation-delay: 0.16s; }
.service-detail > :nth-child(4) { animation-delay: 0.24s; }
@keyframes detail-in { from { opacity: 0; transform: translateY(10px); } }
.service-detail h3 { font-family: var(--font-display); font-weight: 600; font-size: 24px; padding-right: 40px; color: rgb(var(--tone-light)); }
.service-detail p { color: #DCE6F8; line-height: 1.6; }
.service-points { list-style: none; padding: 0; display: grid; gap: 8px; }
.service-points li { position: relative; padding-left: 22px; color: var(--ink-muted); }
.service-points li::before { content: ""; position: absolute; left: 0; top: 0.5em; width: 10px; height: 10px; border-radius: 50%;
  background: rgb(var(--tone)); box-shadow: 0 0 10px rgb(var(--tone) / 0.8); }

/* Tablette : 2 cartes par rangée */
@media (max-width: 1080px) {
  .services { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  /* Mobile : vrai espace entre le haut de page (titre, boutons) et les cartes */
  .services { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: clamp(56px, 12vw, 96px); }
}
@media (max-width: 760px) {
  /* Mobile : le détail s'ouvre sous les cartes, sur toute la largeur */
  .service-panel { position: relative; left: auto; bottom: auto; translate: none; width: 100%; margin-top: 18px; transform-origin: var(--arrow-x) 0; }
  .service-panel::after { bottom: auto; top: -8px; box-shadow: -1px -1px 0 0 rgb(var(--tone-light) / 0.35); background: rgb(14 22 44); }
}
@media (prefers-reduced-motion: reduce) {
  .service-panel, .service-panel.is-closing, .service-detail > * { animation: none; }
  .service, .service-icon { transition: none; animation: none; }
  .service::before { animation: none; }
  .service:hover { translate: none; }
}
