/*
  Apple-inspired interaction layer.
  This file intentionally sits after the existing visual styles: it improves
  motion and spatial hierarchy without changing the chat or product data flow.
*/
:root {
  --motion-spring: cubic-bezier(.22, 1.18, .36, 1);
  --motion-settle: cubic-bezier(.16, 1, .3, 1);
  --motion-quick: 180ms;
  --motion-standard: 360ms;
  --apple-glass: rgba(255, 255, 255, .72);
  --apple-glass-edge: rgba(255, 255, 255, .82);
  --apple-ambient: rgba(0, 113, 227, .14);
}

@keyframes apple-arrive {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes apple-breathe {
  0%, 100% { box-shadow: 0 18px 46px rgba(31, 53, 89, .11), 0 1px 0 var(--apple-glass-edge) inset; }
  50% { box-shadow: 0 24px 58px rgba(31, 53, 89, .16), 0 1px 0 var(--apple-glass-edge) inset; }
}

/* A quieter chrome and a clearer single task on the home page. */
.site-header {
  background: rgba(255, 255, 255, .78);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.site-header::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .75), transparent);
  bottom: -1px;
  content: "";
  height: 1px;
  left: 20%;
  position: absolute;
  right: 20%;
}

.site-header nav a,
.language-toggle,
.mobile-primary-link,
.home-suggestions button,
.home-support-links a,
.product-card,
.dialog-close,
.history-toggle,
.new-chat,
.filter,
.composer button,
.home-question-form button {
  transition-duration: var(--motion-quick);
  transition-timing-function: var(--motion-settle);
}

.site-header nav a {
  position: relative;
}

.site-header nav a::after {
  background: currentColor;
  border-radius: 999px;
  bottom: -8px;
  content: "";
  height: 1.5px;
  left: 50%;
  position: absolute;
  transform: translateX(-50%) scaleX(0);
  transform-origin: center;
  transition: transform var(--motion-standard) var(--motion-spring);
  width: 14px;
}

.site-header nav a.is-current::after,
.site-header nav a:hover::after {
  transform: translateX(-50%) scaleX(1);
}

.hero {
  background:
    radial-gradient(circle at 86% 18%, rgba(168, 215, 255, .58), transparent 27rem),
    radial-gradient(circle at 12% 86%, rgba(222, 238, 255, .88), transparent 28rem),
    var(--apple-gray);
  overflow: clip;
  position: relative;
}

.hero::before {
  background: linear-gradient(128deg, rgba(255, 255, 255, .72), transparent 42%);
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.hero-layout,
.home-support-links {
  position: relative;
  z-index: 1;
}

.hero-copy > * {
  animation: apple-arrive 620ms var(--motion-settle) both;
}

.hero-copy > :nth-child(1) { animation-delay: 40ms; }
.hero-copy > :nth-child(2) { animation-delay: 100ms; }
.hero-copy > :nth-child(3) { animation-delay: 165ms; }
.hero-copy > :nth-child(4) { animation-delay: 220ms; }
.hero-copy > :nth-child(5) { animation-delay: 260ms; }

.home-consult {
  background: linear-gradient(145deg, rgba(255, 255, 255, .96), rgba(249, 251, 255, .86));
  border: 1px solid var(--apple-glass-edge);
  box-shadow: 0 18px 46px rgba(31, 53, 89, .11), 0 1px 0 var(--apple-glass-edge) inset;
  isolation: isolate;
  transform: translateZ(0);
  transition: box-shadow var(--motion-standard) var(--motion-settle), transform var(--motion-standard) var(--motion-spring);
}

.home-consult::before {
  background: radial-gradient(circle at 100% 0, rgba(0, 113, 227, .12), transparent 42%);
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: -1;
}

.home-consult:hover,
.home-consult.is-engaged {
  box-shadow: 0 28px 64px rgba(31, 53, 89, .17), 0 1px 0 var(--apple-glass-edge) inset;
  transform: translateY(-5px);
}

.home-consult.is-engaged {
  animation: apple-breathe 2.4s ease-in-out infinite;
}

.home-question-form textarea {
  border: 1px solid transparent;
  transition: background-color var(--motion-standard) var(--motion-settle), border-color var(--motion-standard) var(--motion-settle), box-shadow var(--motion-standard) var(--motion-settle), transform var(--motion-standard) var(--motion-settle);
}

.home-question-form textarea:focus {
  border-color: rgba(0, 113, 227, .24);
  box-shadow: 0 10px 28px rgba(0, 113, 227, .11), 0 0 0 3px rgba(0, 113, 227, .14);
  transform: translateY(-1px);
}

.home-suggestions button {
  border-radius: 12px;
  margin-inline: -8px;
  padding-inline: 8px;
}

.home-suggestions button:hover,
.home-suggestions button:focus-visible {
  background: rgba(0, 113, 227, .07);
  color: var(--apple-blue);
  transform: translateX(3px);
}

.home-suggestions button:active,
.home-question-form button:active,
.composer button:active,
.product-card:active,
.home-support-links a:active {
  transform: scale(.985);
}

.home-support-links a {
  border-radius: 18px;
  margin-top: 8px;
  padding-inline: 18px;
}

.home-support-links a:hover {
  background: rgba(255, 255, 255, .54);
  box-shadow: 0 12px 30px rgba(31, 53, 89, .08);
  transform: translateY(-2px);
}

/* Keep the consultation task visually primary without hiding its operational controls. */
.chat-shell {
  box-shadow: 0 20px 50px rgba(26, 38, 62, .12), 0 1px 0 rgba(255, 255, 255, .88) inset;
}

.chat-header {
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.messages {
  background:
    radial-gradient(circle at 86% 0, rgba(227, 240, 255, .62), transparent 28rem),
    linear-gradient(180deg, #fbfcff, #f4f7fb);
}

.message {
  animation: apple-arrive 340ms var(--motion-settle) both;
}

.bot .bubble {
  border-color: rgba(29, 37, 51, .08);
  box-shadow: 0 8px 20px rgba(31, 53, 89, .05);
}

.composer {
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* Product browsing keeps movement tied to the object the user touched. */
.product-card:hover {
  box-shadow: 0 22px 44px rgba(31, 53, 89, .15);
  transform: translateY(-6px) scale(1.008);
}

.product-card:focus-visible {
  box-shadow: 0 0 0 4px rgba(0, 113, 227, .2), 0 22px 44px rgba(31, 53, 89, .15);
  outline: none;
}

.product-dialog {
  border-left: 1px solid rgba(255, 255, 255, .75);
}

.product-dialog.is-opening {
  animation-duration: 440ms;
  animation-timing-function: var(--motion-spring);
}

.dialog-close:hover {
  background: #e8f2ff;
  opacity: 1;
  transform: rotate(90deg) scale(1.04);
}

@media (min-width: 721px) {
  .hero-layout { align-items: center; }
  .home-consult { min-height: 518px; }
  .consult-section { background: linear-gradient(160deg, #f4f7fb, #edf3fb); }
  .product-section { background: linear-gradient(180deg, #f7f8fb, #fff); }
}

@media (max-width: 720px) {
  .site-header { background: rgba(255, 255, 255, .8); }
  .mobile-primary-nav {
    background: rgba(255, 255, 255, .8) !important;
    border-bottom-color: rgba(29, 29, 31, .06);
  }
  .mobile-primary-nav::before { background: rgba(118, 118, 128, .10); }
  .mobile-primary-link.is-primary,
  .mobile-primary-nav button.is-primary {
    background: var(--apple-blue) !important;
    box-shadow: 0 5px 13px rgba(0, 113, 227, .22) !important;
  }
  .hero {
    background:
      radial-gradient(circle at 100% 2%, rgba(171, 218, 255, .7), transparent 17rem),
      var(--apple-gray);
  }
  .hero-copy > * { animation-duration: 460ms; }
  .home-consult {
    box-shadow: 0 14px 34px rgba(31, 53, 89, .12), 0 1px 0 var(--apple-glass-edge) inset;
  }
  .home-consult:hover,
  .home-consult.is-engaged { transform: translateY(-2px); }
  .home-consult.is-engaged { animation: none; }
  .home-suggestions button { min-height: 47px; }
  .chat-shell { box-shadow: none; }
  .composer { border-top-color: rgba(29, 29, 31, .08); }
  .product-dialog {
    --sheet-drag-y: 0px;
    border-left: 0;
    transform: translateY(var(--sheet-drag-y));
    transition: transform 420ms var(--motion-spring);
    will-change: transform;
  }
  .product-dialog.is-dragging { transition: none; }
  .product-dialog::before { cursor: grab; touch-action: none; }
  .product-dialog.is-dragging::before { cursor: grabbing; }
  .product-dialog::backdrop { transition: opacity var(--motion-quick) ease; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-copy > *,
  .message,
  .home-consult.is-engaged {
    animation: none !important;
  }
}
