/* ============================================================
   SURAKSHITAM — Chat Assistant
   Matches the global design system: sharp edges, Playfair
   headings, uppercase letterspaced labels, gold/maroon accents.
   ============================================================ */

.sk-chat {
  --sk-maroon:      var(--clr-maroon, #6D1114);
  --sk-gold:        var(--clr-gold, #CC8D2A);
  --sk-gold-light:  var(--clr-gold-light, #E3C170);
  --sk-ivory:       var(--clr-ivory, #F2E8D8);
  --sk-ivory-dark:  var(--clr-ivory-dark, #E6D7C3);
  --sk-brown:       var(--clr-brown, #4A2418);
  --sk-slate:       var(--clr-slate, #4A2418);
  --sk-slate-mid:   var(--clr-slate-mid, #6E4A38);
  --sk-slate-light: var(--clr-slate-light, #8F6B55);
  --sk-rule:        var(--clr-rule, #D9C8B2);
  --sk-white:       var(--clr-white, #FFFFFF);
  --sk-ease:        var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
  --sk-launcher:    60px;

  position: fixed;
  left: clamp(1rem, 2.5vw, 1.75rem);
  bottom: clamp(1rem, 2.5vw, 1.75rem);
  z-index: 9990;
  font-family: var(--font-sans, Inter, system-ui, sans-serif);
}

/* ── Launcher ──────────────────────────────────────────── */

.sk-chat__toggle {
  position: relative;
  width: var(--sk-launcher);
  height: var(--sk-launcher);
  border: 1px solid var(--sk-maroon);
  border-radius: 50%;
  background: var(--sk-maroon);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(109, 17, 20, 0.28);
  transition: transform var(--dur-base, 350ms) var(--sk-ease),
              box-shadow var(--dur-base, 350ms) var(--sk-ease),
              background var(--dur-fast, 200ms) var(--sk-ease);
}

.sk-chat__toggle:hover {
  background: var(--sk-brown);
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(109, 17, 20, 0.34);
}

.sk-chat__toggle:focus-visible {
  outline: 2px solid var(--sk-gold);
  outline-offset: 3px;
}

/* Icon: chat glyph in, close glyph out — swapped on open. */
.sk-chat__toggle::before,
.sk-chat__toggle::after {
  grid-area: 1 / 1;
  transition: opacity var(--dur-fast, 200ms) var(--sk-ease),
              transform var(--dur-base, 350ms) var(--sk-ease);
}

.sk-chat__toggle::before {
  content: '';
  width: 26px;
  height: 26px;
  background: var(--sk-ivory);
  -webkit-mask: var(--sk-icon-chat) center / contain no-repeat;
  mask: var(--sk-icon-chat) center / contain no-repeat;
}

.sk-chat__toggle::after {
  content: '\00d7';
  font-size: 1.75rem;
  line-height: 1;
  color: var(--sk-ivory);
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

.sk-chat {
  --sk-icon-chat: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z'/%3E%3C/svg%3E");
}

.sk-chat.is-open .sk-chat__toggle::before {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

.sk-chat.is-open .sk-chat__toggle::after {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* Attention pulse — stops once the panel has been opened. */
.sk-chat__toggle span {
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1px solid var(--sk-gold);
  opacity: 0;
  animation: sk-pulse 2.8s var(--sk-ease) infinite;
  pointer-events: none;
}

.sk-chat.is-open .sk-chat__toggle span,
.sk-chat.has-opened .sk-chat__toggle span {
  animation: none;
  opacity: 0;
}

@keyframes sk-pulse {
  0%   { opacity: 0.85; transform: scale(1); }
  70%  { opacity: 0;    transform: scale(1.45); }
  100% { opacity: 0;    transform: scale(1.45); }
}

/* ── Panel ─────────────────────────────────────────────── */

.sk-chat__panel {
  position: absolute;
  left: 0;
  bottom: calc(var(--sk-launcher) + 0.9rem);
  width: min(370px, calc(100vw - 2rem));
  height: min(600px, calc(100vh - 7.5rem));
  display: flex;
  flex-direction: column;
  background: var(--sk-ivory);
  border: 1px solid var(--sk-rule);
  box-shadow: 0 24px 60px rgba(42, 26, 20, 0.22);
  overflow: hidden;

  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom left;
  transition: opacity var(--dur-base, 350ms) var(--sk-ease),
              transform var(--dur-base, 350ms) var(--sk-ease),
              visibility 0s linear var(--dur-base, 350ms);
}

.sk-chat.is-open .sk-chat__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition-delay: 0s;
}

/* ── Header ────────────────────────────────────────────── */

.sk-chat__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.1rem 1.15rem 1.35rem;
  background: var(--sk-maroon);
  color: var(--sk-ivory);
  border-bottom: 2px solid var(--sk-gold);
}

.sk-chat__title {
  margin: 0;
  font-family: var(--font-serif, Georgia, serif);
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--sk-ivory);
}

.sk-chat__subtitle {
  margin: 0.45rem 0 0;
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--sk-gold-light);
}

.sk-chat__close {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: 1px solid rgba(242, 232, 216, 0.22);
  background: transparent;
  color: rgba(242, 232, 216, 0.75);
  font-size: 1.25rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color var(--dur-fast, 200ms) var(--sk-ease),
              background var(--dur-fast, 200ms) var(--sk-ease),
              border-color var(--dur-fast, 200ms) var(--sk-ease);
}

.sk-chat__close:hover {
  color: var(--sk-maroon);
  background: var(--sk-ivory);
  border-color: var(--sk-ivory);
}

/* ── Messages ──────────────────────────────────────────── */

.sk-chat__messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.15rem 1.15rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  scrollbar-width: thin;
  scrollbar-color: var(--sk-rule) transparent;
}

.sk-chat__messages::-webkit-scrollbar { width: 6px; }
.sk-chat__messages::-webkit-scrollbar-thumb {
  background: var(--sk-rule);
}

.sk-chat__msg {
  max-width: 86%;
  padding: 0.8rem 1rem;
  font-size: 0.875rem;
  line-height: 1.65;
  animation: sk-msg-in var(--dur-base, 350ms) var(--sk-ease) both;
}

@keyframes sk-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sk-chat__msg--bot {
  align-self: flex-start;
  background: var(--sk-white);
  border: 1px solid var(--sk-rule);
  border-left: 2px solid var(--sk-gold);
  color: var(--sk-slate);
}

.sk-chat__msg--user {
  align-self: flex-end;
  background: var(--sk-maroon);
  color: var(--sk-ivory);
  border: 1px solid var(--sk-maroon);
}

.sk-chat__msg-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.7rem;
}

.sk-chat__msg-links a {
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--sk-gold);
  color: var(--sk-brown);
  background: transparent;
  text-decoration: none;
  transition: background var(--dur-fast, 200ms) var(--sk-ease),
              color var(--dur-fast, 200ms) var(--sk-ease);
}

.sk-chat__msg-links a:hover {
  background: var(--sk-gold);
  color: var(--sk-white);
}

/* Bulleted lines inside a reply. */
.sk-chat__bullet {
  display: inline-block;
  padding-left: 0.85rem;
  position: relative;
}

.sk-chat__bullet::before {
  content: '';
  position: absolute;
  left: 0.15rem;
  top: 0.62em;
  width: 4px;
  height: 4px;
  background: var(--sk-gold);
}

/* ── Tappable menu ─────────────────────────────────────── */

.sk-chat__options {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-self: stretch;
  margin-top: -0.15rem;
  animation: sk-msg-in var(--dur-base, 350ms) var(--sk-ease) both;
}

/* Separate a back-step from the choices above it. */
.sk-chat__option--back + .sk-chat__option--back {
  margin-top: -0.3rem;
}

a.sk-chat__option,
a.sk-chat__option:hover {
  text-decoration: none;
}

.sk-chat__option {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  width: 100%;
  text-align: left;
  font-family: inherit;
  padding: 0.6rem 0.85rem;
  background: var(--sk-white);
  border: 1px solid var(--sk-rule);
  color: var(--sk-slate);
  cursor: pointer;
  transition: border-color var(--dur-fast, 200ms) var(--sk-ease),
              background var(--dur-fast, 200ms) var(--sk-ease),
              color var(--dur-fast, 200ms) var(--sk-ease);
}

.sk-chat__option:hover:not(:disabled) {
  border-color: var(--sk-maroon);
  background: var(--sk-ivory);
}

.sk-chat__option:focus-visible {
  outline: 2px solid var(--sk-gold);
  outline-offset: 1px;
}

.sk-chat__option-label {
  font-size: 0.83rem;
  font-weight: 600;
  line-height: 1.35;
}

.sk-chat__option-desc {
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--sk-slate-light);
  /* Taglines vary a lot in length; cap them so every row in a long
     list stays the same height and more of the list fits on screen. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Primary — the enquiry route. */
.sk-chat__option--primary {
  background: var(--sk-maroon);
  border-color: var(--sk-maroon);
  color: var(--sk-ivory);
}

.sk-chat__option--primary .sk-chat__option-desc {
  color: var(--sk-gold-light);
}

.sk-chat__option--primary:hover:not(:disabled) {
  background: var(--sk-brown);
  border-color: var(--sk-brown);
}

/* Back — quieter than a forward step. */
.sk-chat__option--back {
  background: transparent;
  border-color: transparent;
  color: var(--sk-slate-mid);
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}

.sk-chat__option--back .sk-chat__option-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sk-chat__option--back .sk-chat__option-label::before {
  content: '\2190';
  margin-right: 0.4rem;
}

.sk-chat__option--back:hover:not(:disabled) {
  background: var(--sk-ivory-dark);
  border-color: transparent;
  color: var(--sk-brown);
}

/* Superseded menus stay legible but inert. */
.sk-chat__options.is-spent {
  opacity: 0.4;
  pointer-events: none;
}

.sk-chat__option:disabled {
  cursor: default;
}

/* Typing indicator */
.sk-chat__typing {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.75rem 1rem;
  background: var(--sk-white);
  border: 1px solid var(--sk-rule);
  font-size: 0;
}

.sk-chat__typing::before,
.sk-chat__typing::after,
.sk-chat__typing i {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sk-slate-light);
  animation: sk-dot 1.3s var(--sk-ease) infinite;
}

.sk-chat__typing::after  { animation-delay: 0.18s; }
.sk-chat__typing i       { animation-delay: 0.36s; }

@keyframes sk-dot {
  0%, 60%, 100% { opacity: 0.28; transform: translateY(0); }
  30%           { opacity: 1;    transform: translateY(-4px); }
}

/* ── Quick-reply chips ─────────────────────────────────── */

.sk-chat__chips {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1.15rem 0.8rem;
  background: var(--sk-white);
  border-top: 1px solid var(--sk-rule);
}

.sk-chat__chip {
  display: inline-block;
  text-decoration: none;
  font-family: inherit;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--sk-rule);
  background: var(--sk-white);
  color: var(--sk-slate-mid);
  cursor: pointer;
  transition: border-color var(--dur-fast, 200ms) var(--sk-ease),
              color var(--dur-fast, 200ms) var(--sk-ease),
              background var(--dur-fast, 200ms) var(--sk-ease);
}

.sk-chat__chip:hover {
  border-color: var(--sk-maroon);
  background: var(--sk-maroon);
  color: var(--sk-ivory);
}

.sk-chat__chip--primary {
  margin-left: auto;
  border-color: var(--sk-gold);
  background: var(--sk-gold);
  color: var(--sk-brown);
}

.sk-chat__chip--primary:hover {
  border-color: var(--sk-maroon);
  background: var(--sk-maroon);
  color: var(--sk-ivory);
}

/* ── Utilities ─────────────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Responsive ────────────────────────────────────────── */

/* Tablet and below: panel fills more of the viewport. */
@media (max-width: 600px) {
  .sk-chat { --sk-launcher: 54px; }

  .sk-chat__panel {
    width: calc(100vw - 1.6rem);
    height: min(78vh, calc(100vh - 6.5rem));
  }

  .sk-chat__msg { max-width: 90%; }
}

/* Small phones: full-bleed sheet anchored to the bottom. */
@media (max-width: 400px) {
  .sk-chat {
    left: 0.8rem;
    right: 0.8rem;
    bottom: 0.8rem;
  }

  .sk-chat__panel {
    width: 100%;
    height: min(80vh, calc(100vh - 5.75rem));
  }

  .sk-chat__header { padding: 1.05rem 0.9rem 1rem 1.1rem; }
  .sk-chat__title  { font-size: 1.05rem; }
  .sk-chat__messages { padding: 1rem 0.9rem 0.4rem; }
  .sk-chat__chips  { padding: 0.65rem 0.9rem 0.75rem; }
}

/* Short viewports (landscape phones): keep the panel on screen. The
   chips bar stays — it is the only persistent navigation. */
@media (max-height: 560px) {
  .sk-chat__panel { height: calc(100vh - 5.5rem); }
  .sk-chat__header { padding-top: 0.85rem; padding-bottom: 0.8rem; }
  .sk-chat__subtitle { display: none; }
}

/* Logged-in admin bar offset. */
body.admin-bar .sk-chat__panel {
  max-height: calc(100vh - 9.5rem);
}

@media (prefers-reduced-motion: reduce) {
  .sk-chat__panel,
  .sk-chat__toggle,
  .sk-chat__toggle::before,
  .sk-chat__toggle::after,
  .sk-chat__msg {
    transition-duration: 0.01ms;
    animation-duration: 0.01ms;
  }
  .sk-chat__toggle span { animation: none; }
}
