.home-automation {
  --case-line: #b6a8ff40;
  --case-muted: #d1d3e9;
  background:
    radial-gradient(ellipse at right top, #3a315c, transparent 59%),
    linear-gradient(140deg, var(--navy-soft), var(--navy) 76%);
}

.home-automation h2,
.home-automation h3 {
  color: var(--white);
}

.home-automation .home-section-heading > p,
.ai-case-tools {
  color: var(--case-muted);
}

.ai-case-tools {
  margin-top: 1rem;
}

#cas-concrets,
.ai-case-panel {
  scroll-margin-top: 6rem;
}

.ai-case-tabs {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.3rem;
  max-width: 100%;
  margin-bottom: 1.2rem;
  padding: 0.3rem;
  border: 1px solid var(--case-line);
  border-radius: 11px;
  background: #0d132bb0;
}

.ai-case-tabs a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 2.75rem;
  padding: 0.32rem clamp(0.5rem, 1.8vw, 1.15rem);
  border: 1px solid transparent;
  border-radius: 7px;
  color: #f6f3ff;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  line-height: 1.3;
}

.ai-case-tabs a:hover {
  border-color: #c5bbff66;
}

.ai-case-tabs a[aria-selected="true"] {
  background: var(--lavender);
  color: #211a3c;
}

.ai-case-tabs svg {
  flex: none;
  width: 1rem;
  height: 1rem;
}

.ai-case-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

.ai-case-panel {
  min-width: 0;
  padding: clamp(1.1rem, 3.1vw, 2.5rem);
  border: 1px solid var(--case-line);
  border-radius: 17px;
  background: #11172ec9;
}

.ai-case-content .ai-case-panel[hidden] {
  display: none;
}

.ai-case-panel > h3 {
  font-size: clamp(1.45rem, 2.55vw, 2.2rem);
  line-height: 1.17;
  text-wrap: balance;
}

.case-workflow {
  --case-gap: clamp(0.85rem, 2.2vw, 1.65rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.33fr);
  gap: var(--case-gap);
  margin: clamp(1.05rem, 2.4vw, 1.75rem) 0 0;
  padding: 0;
  list-style: none;
}

.case-step {
  position: relative;
  min-width: 0;
  padding: clamp(0.85rem, 1.65vw, 1.5rem);
  border: 1px solid var(--case-line);
  border-radius: 12px;
  background: linear-gradient(145deg, #222947, #1a213e);
}

.case-step::after {
  position: absolute;
  inset-block-start: clamp(1.95rem, 3.2vw, 2.75rem);
  inset-inline-start: 100%;
  width: var(--case-gap);
  height: 2px;
  background: linear-gradient(90deg, var(--lavender), #a99ff76b);
  transform-origin: left center;
  content: "";
  pointer-events: none;
}

.case-step:last-child::after {
  content: none;
}

.case-step-output {
  border-color: #9ae6d65c;
  background: linear-gradient(145deg, #273451, #242c49 75%);
}

.case-step-icon {
  box-sizing: content-box;
  width: 1.2rem;
  height: 1.2rem;
  margin-bottom: 0.9rem;
  padding: 0.6rem;
  border: 1px solid #c5bbff40;
  border-radius: 9px;
  background: #ada1f21f;
  color: var(--lavender);
}

.case-step-output .case-step-icon {
  border-color: #9ae6d650;
  background: #9ae6d617;
  color: var(--mint);
}

.case-step .case-step-label {
  color: var(--lavender);
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.case-step-output .case-step-label {
  color: var(--mint);
}

.case-step h4 {
  margin: 0.25rem 0 0.4rem;
  color: var(--white);
  font-size: clamp(1.04rem, 1.5vw, 1.23rem);
  line-height: 1.28;
}

.case-step :is(p, blockquote),
.case-review > p {
  color: var(--case-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.case-record {
  margin: 0.8rem 0 0;
  font-size: 0.875rem;
  line-height: 1.5;
}

.case-record > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.12rem 0.7rem;
  padding-block: 0.35rem;
  border-top: 1px solid #b6a8ff38;
}

.case-record dt {
  color: var(--case-muted);
}

.case-record dd {
  margin: 0;
  color: #fff;
  font-weight: 700;
}

.case-record .case-record-note {
  color: #ded4ff;
}

.case-record .case-record-warning {
  color: #ffdcab;
}

.case-step blockquote {
  margin: 0.7rem 0 0;
  padding-inline-start: 0.7rem;
  border-inline-start: 2px solid #9ae6d67a;
  font-size: 0.83rem;
}

.case-review {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1.3rem;
  margin-top: clamp(1rem, 2.4vw, 1.65rem);
  padding-top: 1rem;
  border-top: 1px solid var(--case-line);
}

.case-review strong {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--white);
}

@media (max-width: 760px) {
  .case-workflow,
  .case-review {
    grid-template-columns: minmax(0, 1fr);
  }

  .case-step::after {
    inset-block-start: 100%;
    inset-inline-start: 2rem;
    width: 2px;
    height: var(--case-gap);
    background: linear-gradient(var(--lavender), #a99ff76b);
    transform-origin: center top;
  }
}

@media (max-width: 470px) {
  .ai-case-tabs {
    display: grid;
  }

  .ai-case-tabs a {
    flex-direction: column;
    gap: 0.35rem;
    min-height: 3.5rem;
    padding: 0.4rem 0.2rem;
    font-size: 0.875rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .ai-case-tabs a {
    transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
  }

  .ai-case-content[data-home-entrance].has-entered {
    animation: none;
  }

  @keyframes case-step-arrives {
    from { opacity: 0.35; translate: 0 8px; }
    to { opacity: 1; translate: 0 0; }
  }

  @media (width > 760px) {
    .ai-case-content.has-entered .ai-case-panel[role="tabpanel"] .case-step {
      animation: case-step-arrives 400ms cubic-bezier(.22, .8, .22, 1) var(--case-step-delay, 0ms) backwards;
    }

    .ai-case-content.has-entered .ai-case-panel[role="tabpanel"] .case-step::after {
      animation: case-connector-extends 320ms ease-out var(--case-line-delay, 160ms) backwards;
    }

    .case-step:nth-child(2) {
      --case-step-delay: 290ms;
      --case-line-delay: 460ms;
    }

    .case-step-output {
      --case-step-delay: 570ms;
    }

    .ai-case-content.has-entered .ai-case-panel[role="tabpanel"] .case-record {
      animation: case-step-arrives 330ms ease-out 790ms backwards;
    }

    @keyframes case-connector-extends {
      from { opacity: 0; scale: 0 1; }
      to { opacity: 1; scale: 1; }
    }
  }

  @media (max-width: 760px) {
    .ai-case-panel[role="tabpanel"] .case-step.has-entered {
      animation: case-step-arrives 400ms cubic-bezier(.22, .8, .22, 1) backwards;
    }

    .ai-case-panel[role="tabpanel"] .case-step.has-entered::after {
      animation: case-connector-descends 300ms ease-out 120ms backwards;
    }

    .ai-case-panel[role="tabpanel"] .case-step.has-entered .case-record {
      animation: case-step-arrives 300ms ease-out 170ms backwards;
    }

    @keyframes case-connector-descends {
      from { opacity: 0; scale: 1 0; }
      to { opacity: 1; scale: 1; }
    }
  }
}
