/* ════════════════════════════════════════════════
   CORTEX CARD — Cortex Intellect promo card
   (markup and state logic: templates/includes/cortex_card.html,
   core animation: assets/js/cortex-plexus.js).
   A separate file with ?v= in the headers: /static/ is cached by
   browsers for 7 days and style.css has no version.
   .is-collapsed — card is hidden, the side tab "AI SOLUTIONS" is shown instead
   .is-animated  — state changes after user actions are animated (restored state on page load is not)
   .is-waiting   — first page of the session: hidden until the delay or the consent popups are closed
   .is-entering  — slide-in on the first appearance in the session
   Colors come from the site palette (:root in basic/header.html):
   --thirty_bg cards, --main_bg, the --gradient_* of .main-btn.
   ════════════════════════════════════════════════ */

@keyframes cortex-border-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes cortex-card-in {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
}

@keyframes cortex-tab-pulse {
  0%, 70%, 100% {
    box-shadow: 5px 5px 10px rgba(0, 0, 0, .25), 0 0 0 0 rgba(152, 93, 211, .5);
  }
  85% {
    box-shadow: 5px 5px 10px rgba(0, 0, 0, .25), 0 0 0 8px rgba(152, 93, 211, 0);
  }
}

.cortex-card {
  font-family: 'Montserrat', sans-serif;
  letter-spacing: -0.02em;
  box-sizing: border-box;
}

.cortex-card__panel {
  position: fixed;
  left: 24px;
  bottom: 24px;
  /* above the chat button (100) and the cookie popup (102), below the modals (230+) */
  z-index: 105;
  width: 390px;
  padding: 2px;
  border-radius: 14px;
  background: #2C2F40;
  box-shadow: -5px 5px 10px rgba(0, 0, 0, .25), 0 18px 48px rgba(12, 11, 14, .5), 0 0 36px rgba(109, 93, 211, .2);
  overflow: hidden;
  isolation: isolate;
}

/* Animated border: a big rotating conic gradient with a bright "comet",
   visible only through the 2px padding around the card content */
.cortex-card__panel::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: -1;
  width: 640px;
  height: 640px;
  margin: -320px 0 0 -320px;
  background: conic-gradient(
    transparent 0deg 190deg,
    rgba(109, 93, 211, .6) 230deg,
    var(--gradient_start, #6D5DD3) 270deg,
    var(--gradient_center, #985DD3) 305deg,
    var(--gradient-hover_end, #e26dff) 335deg,
    #fff 350deg,
    transparent 360deg
  );
  animation: cortex-border-spin 4s linear infinite;
}

.cortex-card__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 20px 20px 22px;
  border-radius: 12px;
  color: var(--text_color, #fff);
  text-decoration: none;
  background:
    radial-gradient(120% 140% at 100% 50%, rgba(109, 93, 211, .22) 0, transparent 55%),
    var(--thirty_bg, #252733);
  overflow: hidden;
}

.cortex-card__link:hover {
  color: var(--text_color, #fff);
}

.cortex-card__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
}

.cortex-card__eyebrow {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: .12em;
  color: #CAB1FF;
}

.cortex-card__title {
  margin-top: 6px;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.cortex-card__text {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: #8884A1;
}

/* CTA looks like .main-btn: the site gradient, the hover gradient fades in over it */
.cortex-card__cta {
  position: relative;
  z-index: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  /* one line in every language: the longest (uk) fits the text column at this size */
  white-space: nowrap;
  color: var(--text_color, #fff);
  background: linear-gradient(79.58deg, var(--gradient_start, #6D5DD3) 41.08%, var(--gradient_center, #985DD3) 74.67%, var(--gradient_end, #AD5DD3) 93.79%);
  box-shadow: -5px 5px 10px rgba(0, 0, 0, .25);
}

.cortex-card__cta::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(79.58deg, var(--gradient-hover_start, #624bf3) 41.08%, var(--gradient-hover_center, #ac5efa) 74.67%, var(--gradient-hover_end, #e26dff) 93.79%);
  opacity: 0;
  transition: opacity .6s;
}

.cortex-card__arrow {
  display: inline-block;
  transition: transform .2s ease;
}

.cortex-card__link:hover .cortex-card__cta::after {
  opacity: 1;
}

.cortex-card__link:focus-visible {
  outline: 3px solid #CAB1FF;
  outline-offset: 2px;
}

.cortex-card__link:hover .cortex-card__arrow {
  transform: translateX(3px);
}

/* Core: node network on a sphere drawn by cortex-plexus.js,
   a gradient ball until the script runs */
.cortex-card__core {
  position: relative;
  flex: none;
  width: 88px;
  aspect-ratio: 1;
  margin: 8px 8px 8px 0;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #CAB1FF, #985DD3 55%, #3b2f7a 100%);
  box-shadow: 0 0 0 10px rgba(109, 93, 211, .12), 0 0 30px rgba(152, 93, 211, .65);
}

/* the plexus took over: the ball fades into a soft glow under it */
.cortex-card__core.is-live {
  background: radial-gradient(circle, rgba(109, 93, 211, .4), rgba(109, 93, 211, 0) 70%);
  box-shadow: 0 0 40px rgba(109, 93, 211, .3);
}

/* a bit wider than the core so the near-side nodes are not clipped */
.cortex-card__plexus {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 120%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.cortex-card__plexus canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.cortex-card__close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid #2C2F40;
  border-radius: 50%;
  color: var(--text_color, #fff);
  background: var(--main_bg, #202028);
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease;
}

.cortex-card__close:hover {
  background: #2C2F40;
  border-color: var(--accent_color, #6D5DD3);
}

/* bigger hit area for touch */
.cortex-card__close::after {
  content: '';
  position: absolute;
  inset: -8px;
}

/* Collapsed state: vertical tab on the left edge of the screen */
.cortex-card__tab {
  position: fixed;
  left: 0;
  top: 50%;
  z-index: 105;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 36px;
  padding: 12px 0 16px;
  border-radius: 0 8px 8px 0;
  color: var(--text_color, #fff);
  text-decoration: none;
  background: linear-gradient(180deg, var(--gradient_start, #6D5DD3) 0%, var(--gradient_center, #985DD3) 60%, var(--gradient_end, #AD5DD3) 100%);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translate(-100%, -50%);
  animation: cortex-tab-pulse 4s ease-in-out infinite;
}

.cortex-card__tab:hover {
  width: 40px;
  color: var(--text_color, #fff);
  background: linear-gradient(180deg, var(--gradient-hover_start, #624bf3) 0%, var(--gradient-hover_center, #ac5efa) 60%, var(--gradient-hover_end, #e26dff) 100%);
}

.cortex-card__tab-orb {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, .9) 0, rgba(234, 222, 255, .5) 12%, transparent 32%),
    radial-gradient(circle at 50% 50%, #CAB1FF 0, #985DD3 45%, #3b2f7a 100%);
  box-shadow: 0 0 8px rgba(202, 177, 255, .8);
}

.cortex-card__tab-text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .14em;
  white-space: nowrap;
}

/* ── states ── */
.cortex-card.is-collapsed .cortex-card__panel {
  opacity: 0;
  visibility: hidden;
  transform: translateX(calc(-100% - 40px));
}

.cortex-card.is-collapsed .cortex-card__tab {
  opacity: 1;
  visibility: visible;
  transform: translate(0, -50%);
}

.cortex-card.is-animated .cortex-card__panel {
  transition: opacity .4s ease, transform .5s cubic-bezier(.2, .8, .2, 1), visibility .5s;
}

.cortex-card.is-animated .cortex-card__tab {
  transition: opacity .3s ease, transform .4s cubic-bezier(.2, .8, .2, 1), visibility .4s, width .2s ease;
}

.cortex-card.is-entering:not(.is-collapsed) .cortex-card__panel {
  animation: cortex-card-in .6s cubic-bezier(.2, .8, .2, 1) both;
}

.cortex-card.is-waiting .cortex-card__panel,
.cortex-card.is-waiting .cortex-card__tab {
  display: none;
}

/* the burger menu and the mobile filters are drawn under the card (header z-index 50),
   while they are open (body.block-scroll, app.js) the card steps aside */
.block-scroll .cortex-card {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .cortex-card__panel::before,
  .cortex-card__tab,
  .cortex-card.is-entering:not(.is-collapsed) .cortex-card__panel {
    animation: none;
  }

  .cortex-card.is-animated .cortex-card__panel,
  .cortex-card.is-animated .cortex-card__tab {
    transition: opacity .3s ease, visibility .3s;
  }
}

/* ════════════════════════════════════════════════
   CORTEX CARD — adaptive
   ════════════════════════════════════════════════ */

/* ── ≤768px: full-width card at the bottom, like a cookie consent ── */
@media (max-width: 768px) {
  .cortex-card__panel {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    width: auto;
    border-radius: 14px;
  }

  .cortex-card__link {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    grid-template-areas:
      "core eyebrow"
      "core title"
      "text text"
      "cta cta";
    column-gap: 14px;
    align-items: center;
    padding: 18px 16px 16px;
    border-radius: 12px;
  }

  .cortex-card__body {
    display: contents;
  }

  .cortex-card__eyebrow {
    grid-area: eyebrow;
    align-self: end;
    font-size: 10px;
  }

  .cortex-card__title {
    grid-area: title;
    align-self: start;
    margin-top: 4px;
    /* room for the close button */
    padding-right: 28px;
    font-size: 18px;
  }

  .cortex-card__text {
    grid-area: text;
    margin-top: 14px;
    font-size: 14px;
    line-height: 1.45;
  }

  .cortex-card__cta {
    grid-area: cta;
    justify-content: center;
    margin-top: 16px;
    padding: 13px 16px;
    font-size: 14px;
  }

  .cortex-card__core {
    grid-area: core;
    width: 56px;
    margin: 0;
  }

  .cortex-card__tab {
    width: 30px;
    padding: 10px 0 12px;
    gap: 8px;
  }

  .cortex-card__tab-orb {
    width: 14px;
    height: 14px;
  }

  .cortex-card__tab-text {
    font-size: 10px;
  }

  .cortex-card.is-collapsed .cortex-card__panel {
    transform: translateY(calc(100% + 24px));
  }

  /* the open card covers the chat button (right: 20px; bottom: 60px), so it moves above the card
     (--cortex-card-h and html.cortex-card-open are set by the card script) */
  .messengersPopup {
    transition: transform .3s ease, bottom .4s cubic-bezier(.2, .8, .2, 1);
  }

  .cortex-card-open .messengersPopup {
    bottom: calc(var(--cortex-card-h, 0px) + 24px + env(safe-area-inset-bottom, 0px));
  }
}
