/* Thermii Spark — presentation-only guide prototype
   ------------------------------------------------------------------
   This isolated layer animates the existing sidebar avatar, acknowledges
   confirmed choices and reveals authored, contextual journey guidance. It does not own
   or write calculator state, inputs, validation, pricing, recommendations
   or navigation. */

@media screen {
  .thermii-guide-status {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    border: 0;
    white-space: nowrap;
  }

  .thermii-side-avatar {
    transform-origin: center;
  }

  .thermii-side-avatar::before {
    display: none;
  }

  .thermii-side-time .thermii-side-time-icon {
    display: grid;
    place-items: center;
  }

  .thermii-side-time-icon svg {
    display: block;
  }

  .thermii-guide-blink {
    position: absolute;
    z-index: 2;
    top: 55%;
    left: 50%;
    width: 39%;
    height: 13%;
    transform: translate(-50%, -50%);
    pointer-events: none;
  }

  .thermii-guide-blink i {
    position: absolute;
    top: 0;
    width: 30%;
    height: 100%;
    border-bottom: 2px solid #7650dc;
    border-radius: 0 0 999px 999px;
    background: #fff;
    opacity: 0;
    transform: scaleY(.25);
    transform-origin: center bottom;
  }

  .thermii-guide-blink i:first-child {
    left: 4%;
  }

  .thermii-guide-blink i:last-child {
    right: 4%;
  }

  .thermii-insight {
    display: none;
    margin: 0 0 24px;
    border: 1px solid rgba(113, 56, 237, .14);
    border-radius: 16px;
    background:
      linear-gradient(145deg, rgba(255, 255, 255, .96), rgba(247, 245, 255, .9));
    box-shadow:
      0 1px 0 rgba(255, 255, 255, .95) inset,
      0 12px 30px rgba(45, 39, 94, .06);
    color: var(--thermii-navy);
    overflow: hidden;
  }

  body.thermii-has-insight .thermii-insight {
    display: block;
  }

  body.thermii-has-insight .thermii-side-help {
    display: none;
  }

  .thermii-insight-toggle {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 18px;
    gap: 10px;
    align-items: center;
    min-height: 68px;
    width: 100%;
    padding: 12px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    list-style: none;
    text-align: left;
    cursor: pointer;
  }

  .thermii-insight-toggle:hover {
    background: rgba(113, 56, 237, .035);
  }

  .thermii-insight-toggle:focus-visible {
    outline: 3px solid rgba(20, 157, 232, .36);
    outline-offset: -3px;
  }

  .thermii-insight-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(113, 56, 237, .14);
    border-radius: 50%;
    background: linear-gradient(
      135deg,
      rgba(20, 157, 232, .12),
      rgba(113, 56, 237, .11),
      rgba(212, 20, 196, .09)
    );
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, .72),
      0 5px 14px rgba(89, 45, 210, .08);
    overflow: hidden;
  }

  .thermii-insight-icon img {
    display: block;
    width: 23px;
    height: 23px;
    margin: 0;
    object-fit: contain;
    object-position: 50% 50%;
    filter: drop-shadow(0 2px 3px rgba(82, 48, 174, .10));
  }

  .thermii-insight-heading,
  .thermii-insight-heading strong,
  .thermii-insight-heading span {
    display: block;
  }

  .thermii-insight-heading strong {
    color: #4d1bed;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: -.01em;
  }

  .thermii-insight-heading span {
    margin-top: 3px;
    color: #596584;
    font-size: 10.5px;
    line-height: 1.35;
  }

  .thermii-insight-chevron {
    color: #5d21f5;
    font-size: 18px;
    transform: translateY(-2px);
    transition: transform 220ms cubic-bezier(.22, 1, .36, 1);
  }

  .thermii-insight.is-open .thermii-insight-chevron {
    transform: rotate(180deg) translateY(2px);
  }

  .thermii-insight-panel {
    padding: 0 14px 15px;
    color: #525d7e;
    font-size: 10.5px;
    line-height: 1.55;
    animation: thermii-insight-reveal 280ms cubic-bezier(.22, 1, .36, 1) both;
  }

  .thermii-insight-panel[hidden] {
    display: none;
  }

  .thermii-insight-panel::before {
    content: "";
    display: block;
    height: 1px;
    margin: 0 0 12px;
    background: linear-gradient(90deg, transparent, rgba(113, 56, 237, .2), transparent);
  }

  .thermii-insight-panel p {
    margin: 0 0 9px;
  }

  .thermii-insight-panel ul {
    display: grid;
    gap: 7px;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* Secondary guidance mirrored from the screen's own expandable tooltip
     (neoHub, subfloor detail, levelling compound). Set apart from the main tip
     so it reads as further detail rather than a second headline. */
  .thermii-insight-extra {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed rgba(113, 56, 237, .22);
  }

  .thermii-insight-extra p:last-child {
    margin-bottom: 0;
  }

  .thermii-insight-extra strong {
    display: block;
    margin-top: 7px;
    color: var(--thermii-navy, #101735);
    font-weight: 600;
  }

  .thermii-insight-extra p:first-child strong {
    margin-top: 0;
  }

  .thermii-insight-panel li {
    position: relative;
    padding-left: 12px;
  }

  .thermii-insight-panel li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #6b32f0;
  }

  .thermii-insight-panel strong {
    color: var(--thermii-navy);
    font-weight: 600;
  }

  .thermii-insight-panel a {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    margin-top: 12px;
    color: #531ff0;
    font-size: 10.5px;
    font-weight: 600;
    text-decoration: none;
  }

  .thermii-insight-panel a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  body .thermii-side-avatar {
    animation: thermii-guide-idle 9s ease-in-out infinite;
  }

  body .thermii-side-spark {
    animation: thermii-guide-twinkle 7s ease-in-out infinite;
  }

  body .thermii-side-spark:last-of-type {
    animation-delay: -3.2s;
  }

  body .thermii-guide-blink i {
    animation: thermii-guide-blink 7.8s steps(1, end) infinite;
  }

  body .thermii-side-avatar.is-listening {
    animation: thermii-guide-listen 480ms cubic-bezier(.22, 1, .36, 1) both;
  }

  body .thermii-side-avatar.is-explaining {
    animation: none;
    transform: translateY(-3px) rotate(-3deg) scale(1.045);
    transition: transform 280ms cubic-bezier(.22, 1, .36, 1);
  }

  body .thermii-side-avatar.is-responding {
    animation: thermii-guide-respond 620ms cubic-bezier(.22, 1, .36, 1) both;
  }

  body .thermii-side-avatar.is-recommending {
    animation: thermii-guide-recommend 820ms cubic-bezier(.22, 1, .36, 1) both;
  }

  body .thermii-side-avatar.is-celebrating {
    animation: thermii-guide-celebrate 920ms cubic-bezier(.22, 1, .36, 1) both;
  }

  body .thermii-side-avatar.is-triumphing {
    animation: thermii-guide-triumph 1240ms cubic-bezier(.22, 1, .36, 1) both;
  }

  .thermii-side-avatar.is-responding .thermii-guide-blink i {
    animation: thermii-guide-response-blink 620ms steps(1, end) both;
  }

  .thermii-side-avatar.is-recommending .thermii-guide-blink i {
    animation: thermii-guide-recommend-blink 820ms steps(1, end) both;
  }

  .thermii-side-avatar.is-recommending .thermii-side-spark {
    animation: thermii-guide-star-pop 720ms cubic-bezier(.22, 1, .36, 1) both;
  }

  .thermii-side-avatar.is-recommending .thermii-side-spark:last-of-type {
    animation-delay: 60ms;
  }

  .thermii-side-avatar.is-celebrating .thermii-side-spark {
    animation: thermii-guide-star-pop 760ms cubic-bezier(.22, 1, .36, 1) both;
  }

  .thermii-side-avatar.is-celebrating .thermii-side-spark:last-of-type {
    animation-delay: 70ms;
  }

  .thermii-side-avatar.is-celebrating .thermii-guide-blink i {
    animation: thermii-guide-celebration-blink 920ms steps(1, end) both;
  }

  .thermii-side-avatar.is-triumphing .thermii-side-spark {
    animation: thermii-guide-triumph-star 1120ms cubic-bezier(.22, 1, .36, 1) both;
  }

  .thermii-side-avatar.is-triumphing .thermii-side-spark:last-of-type {
    animation-delay: 90ms;
  }

  .thermii-side-avatar.is-triumphing .thermii-guide-blink i {
    animation: thermii-guide-triumph-blink 1240ms steps(1, end) both;
  }

  .thermii-insight.is-responding .thermii-insight-icon img {
    animation: thermii-guide-respond 620ms cubic-bezier(.22, 1, .36, 1) both;
  }

  .thermii-insight.is-recommending .thermii-insight-icon img {
    animation: thermii-guide-recommend 820ms cubic-bezier(.22, 1, .36, 1) both;
  }

  .thermii-insight.is-celebrating .thermii-insight-icon img {
    animation: thermii-guide-celebrate 920ms cubic-bezier(.22, 1, .36, 1) both;
  }

  .thermii-insight.is-triumphing .thermii-insight-icon img {
    animation: thermii-guide-triumph 1240ms cubic-bezier(.22, 1, .36, 1) both;
  }

  body.thermii-spark-recommending .thermii-insight-icon {
    border-color: rgba(117, 191, 50, .3);
    background: linear-gradient(
      135deg,
      rgba(117, 191, 50, .14),
      rgba(20, 157, 232, .11),
      rgba(113, 56, 237, .10)
    );
  }

  body.thermii-spark-celebrating .thermii-stage-progress span {
    position: relative;
    overflow: hidden;
  }

  body.thermii-spark-celebrating .thermii-stage-progress span::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 8%, rgba(255, 255, 255, .75) 50%, transparent 92%);
    transform: translateX(-140%);
    animation: thermii-guide-progress-glide 720ms cubic-bezier(.22, 1, .36, 1) 80ms both;
  }

  body.thermii-spark-celebrating .thermii-step.thermii-spark-stage-pulse .thermii-step-orb {
    animation: thermii-guide-step-complete 620ms cubic-bezier(.22, 1, .36, 1) both;
  }

  body.thermii-spark-triumphing .thermii-stage-progress span::after {
    animation-duration: 920ms;
  }

  @keyframes thermii-guide-idle {
    0%, 68%, 100% {
      transform: translateY(0) rotate(0deg) scale(1);
    }
    72% {
      transform: translateY(-2px) rotate(-3deg) scale(1.035);
    }
    76% {
      transform: translateY(0) rotate(2.5deg) scale(.995);
    }
    80% {
      transform: translateY(-1px) rotate(-1deg) scale(1.02);
    }
    84% {
      transform: translateY(0) rotate(0deg) scale(1);
    }
  }

  @keyframes thermii-guide-twinkle {
    0%, 38%, 48%, 100% {
      opacity: .56;
      transform: scale(.82) rotate(0deg);
    }
    42% {
      opacity: 1;
      transform: scale(1.16) rotate(12deg);
    }
  }

  @keyframes thermii-guide-blink {
    0%, 40%, 41.8%, 43.8%, 100% {
      opacity: 0;
      transform: scaleY(.18);
    }
    40.2%, 41.2%, 42.2%, 43.2% {
      opacity: 1;
      transform: scaleY(1);
    }
  }

  @keyframes thermii-guide-listen {
    0% {
      transform: translateY(0) scale(1);
    }
    55% {
      transform: translateY(-4px) rotate(-3deg) scale(1.055);
    }
    100% {
      transform: translateY(0) scale(1);
    }
  }

  @keyframes thermii-guide-respond {
    0%, 100% {
      transform: translateY(0) rotate(0deg) scale(1);
    }
    42% {
      transform: translateY(-5px) rotate(-2.5deg) scale(1.07);
    }
    68% {
      transform: translateY(1px) rotate(1.5deg) scale(.99);
    }
  }

  @keyframes thermii-guide-recommend {
    0%, 100% {
      transform: translateY(0) rotate(0deg) scale(1);
    }
    32% {
      transform: translateY(-5px) rotate(-7deg) scale(1.075);
    }
    58% {
      transform: translateY(-7px) rotate(5deg) scale(1.11);
    }
    78% {
      transform: translateY(1px) rotate(-1.5deg) scale(.99);
    }
  }

  @keyframes thermii-guide-celebrate {
    0% {
      transform: translateY(0) rotate(0deg) scale(1);
    }
    30% {
      transform: translateY(-4px) rotate(180deg) scale(.94);
    }
    58% {
      transform: translateY(-8px) rotate(360deg) scale(1.1);
    }
    78% {
      transform: translateY(1px) rotate(366deg) scale(.985);
    }
    100% {
      transform: translateY(0) rotate(360deg) scale(1);
    }
  }

  @keyframes thermii-guide-triumph {
    0% {
      transform: translateY(0) rotate(0deg) scale(1);
    }
    24% {
      transform: translateY(-5px) rotate(180deg) scale(.92);
    }
    50% {
      transform: translateY(-10px) rotate(420deg) scale(1.14);
    }
    72% {
      transform: translateY(-5px) rotate(690deg) scale(1.06);
    }
    86% {
      transform: translateY(1px) rotate(728deg) scale(.985);
    }
    100% {
      transform: translateY(0) rotate(720deg) scale(1);
    }
  }

  @keyframes thermii-guide-response-blink {
    0%, 24%, 40%, 58%, 100% {
      opacity: 0;
      transform: scaleY(.18);
    }
    27%, 36%, 43%, 55% {
      opacity: 1;
      transform: scaleY(1);
    }
  }

  @keyframes thermii-guide-recommend-blink {
    0%, 54%, 72%, 100% {
      opacity: 0;
      transform: scaleY(.18);
    }
    57%, 69% {
      opacity: 1;
      transform: scaleY(1);
    }
  }

  @keyframes thermii-guide-celebration-blink {
    0%, 68%, 82%, 100% {
      opacity: 0;
      transform: scaleY(.18);
    }
    70%, 80% {
      opacity: 1;
      transform: scaleY(1);
    }
  }

  @keyframes thermii-guide-triumph-blink {
    0%, 34%, 45%, 72%, 84%, 100% {
      opacity: 0;
      transform: scaleY(.18);
    }
    36%, 43%, 74%, 82% {
      opacity: 1;
      transform: scaleY(1);
    }
  }

  @keyframes thermii-guide-star-pop {
    0% {
      opacity: .2;
      transform: scale(.35) rotate(-16deg);
    }
    48% {
      opacity: 1;
      transform: scale(1.4) rotate(16deg);
    }
    100% {
      opacity: .68;
      transform: scale(1) rotate(0);
    }
  }

  @keyframes thermii-guide-triumph-star {
    0% {
      opacity: .12;
      transform: scale(.25) rotate(-22deg);
    }
    32% {
      opacity: 1;
      transform: scale(1.62) rotate(24deg);
    }
    62% {
      opacity: .42;
      transform: scale(.78) rotate(-8deg);
    }
    82% {
      opacity: 1;
      transform: scale(1.34) rotate(15deg);
    }
    100% {
      opacity: .68;
      transform: scale(1) rotate(0);
    }
  }

  @keyframes thermii-guide-progress-glide {
    to {
      transform: translateX(140%);
    }
  }

  @keyframes thermii-guide-step-complete {
    0% {
      transform: scale(.88);
      box-shadow: 0 0 0 0 rgba(113, 56, 237, .22);
    }
    55% {
      transform: scale(1.1);
      box-shadow: 0 0 0 8px rgba(113, 56, 237, 0);
    }
    100% {
      transform: scale(1);
      box-shadow: none;
    }
  }

  @keyframes thermii-insight-reveal {
    from {
      opacity: 0;
      transform: translateY(-7px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

@media screen and (max-width: 820px) {
  body.thermii-has-insight .thermii-sidebar {
    align-items: start;
  }

  body .thermii-side-spark {
    display: block;
    font-size: 13px;
  }

  body .thermii-side-spark:first-of-type {
    top: 7px;
    left: -2px;
  }

  body .thermii-side-spark:last-of-type {
    right: -2px;
    bottom: 5px;
  }

  .thermii-insight {
    position: relative;
    grid-column: 1 / -1;
    width: 100%;
    max-width: none;
    margin: 2px 0 0;
    border-color: rgba(113, 56, 237, .2);
    background:
      linear-gradient(145deg, rgba(255, 255, 255, .98), rgba(246, 244, 255, .96));
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 1) inset,
      0 20px 54px rgba(32, 29, 78, .18);
    backdrop-filter: blur(18px) saturate(120%);
    -webkit-backdrop-filter: blur(18px) saturate(120%);
  }

  body.thermii-spark-responding .thermii-insight,
  body.thermii-spark-recommending .thermii-insight,
  body.thermii-spark-celebrating .thermii-insight,
  body.thermii-spark-triumphing .thermii-insight {
    display: block;
    position: fixed;
    z-index: 1200;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    left: max(14px, env(safe-area-inset-left));
    width: auto;
    max-width: 430px;
    margin: 0 auto;
  }

  .thermii-insight-toggle {
    min-height: 58px;
    padding: 9px 11px;
  }

  .thermii-insight-panel {
    max-height: min(52vh, 360px);
    padding-right: 13px;
    padding-left: 13px;
    padding-bottom: 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .thermii-insight.is-reacting .thermii-insight-toggle {
    pointer-events: none;
  }

  .thermii-insight.is-reacting .thermii-insight-chevron {
    visibility: hidden;
  }
}

@media screen and (max-width: 520px) {
  .thermii-insight-toggle {
    grid-template-columns: 34px minmax(0, 1fr) 18px;
  }

  .thermii-insight-icon {
    width: 34px;
    height: 34px;
  }

  .thermii-insight-icon img {
    width: 22px;
    height: 22px;
  }

  .thermii-insight-heading strong {
    font-size: 11.5px;
  }

  .thermii-insight-heading span,
  .thermii-insight-panel {
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body .thermii-side-avatar,
  body .thermii-side-spark,
  body .thermii-guide-blink i,
  .thermii-side-avatar.is-listening,
  .thermii-side-avatar.is-responding,
  .thermii-side-avatar.is-recommending,
  .thermii-side-avatar.is-celebrating,
  .thermii-side-avatar.is-triumphing,
  .thermii-side-avatar.is-responding .thermii-guide-blink i,
  .thermii-side-avatar.is-recommending .thermii-side-spark,
  .thermii-side-avatar.is-recommending .thermii-guide-blink i,
  .thermii-side-avatar.is-celebrating .thermii-side-spark,
  .thermii-side-avatar.is-celebrating .thermii-guide-blink i,
  .thermii-side-avatar.is-triumphing .thermii-side-spark,
  .thermii-side-avatar.is-triumphing .thermii-guide-blink i,
  .thermii-insight.is-responding .thermii-insight-icon img,
  .thermii-insight.is-recommending .thermii-insight-icon img,
  .thermii-insight.is-celebrating .thermii-insight-icon img,
  .thermii-insight.is-triumphing .thermii-insight-icon img,
  body.thermii-spark-celebrating .thermii-stage-progress span::after,
  body.thermii-spark-celebrating .thermii-step.thermii-spark-stage-pulse .thermii-step-orb,
  .thermii-insight-panel {
    animation: none !important;
  }

  body .thermii-guide-blink i {
    opacity: 0;
  }

  .thermii-insight-chevron,
  .thermii-side-avatar.is-explaining {
    transition: none !important;
  }

  .thermii-side-avatar.is-explaining {
    transform: none !important;
  }

  .thermii-side-avatar.is-listening,
  .thermii-side-avatar.is-responding,
  .thermii-side-avatar.is-recommending,
  .thermii-side-avatar.is-celebrating,
  .thermii-side-avatar.is-triumphing {
    transform: none !important;
  }
}

@media print {
  .thermii-guide-blink,
  .thermii-insight,
  .thermii-guide-status {
    display: none !important;
  }
}
