/* Casa Daniela assistant integration for the cinematic preview. */

.assistant-section {
  display: block;
  padding-block: clamp(68px, 9vw, 126px);
  border-block: 1px solid var(--line);
}

.assistant-section .assistant-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(320px, 1fr);
  align-items: center;
  gap: clamp(38px, 8vw, 132px);
}

.assistant-section h2 {
  max-width: 10ch;
  font-size: clamp(42px, 5vw, 72px);
}

.assistant-section .assistant-layout > :first-child .eyebrow,
.assistant-section > .eyebrow {
  margin-bottom: 26px;
  color: var(--muted);
}

.assistant-section .assistant-layout > :first-child > p:not(.eyebrow):not(.handwritten) {
  max-width: 38ch;
  margin-top: 22px;
  color: var(--muted);
  font-size: 13px;
}

.assistant-card {
  min-width: 0;
  padding: clamp(22px, 3.5vw, 42px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 62%, var(--paper));
  box-shadow: 0 22px 60px color-mix(in srgb, var(--ink) 7%, transparent);
}

.assistant-entry-form label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.assistant-entry-form > div {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.assistant-question-field,
.assistant-entry-form input {
  min-width: 0;
  min-height: 54px;
  flex: 1;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
}

.assistant-question-field {
  padding: 4px;
}

.assistant-entry-form input {
  border: 0;
  background: transparent;
}

.assistant-question-field::placeholder,
.assistant-entry-form input::placeholder {
  color: var(--muted);
  opacity: 0.82;
}

.assistant-entry-form button[type="submit"],
.assistant-entry-form .assistant-submit {
  display: inline-flex;
  width: 54px;
  min-width: 54px;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--blue);
  color: var(--paper);
  transition: transform 0.3s var(--ease), opacity 0.3s;
}

.assistant-entry-form button[type="submit"]:hover,
.assistant-entry-form .assistant-submit:hover {
  transform: translateY(-2px);
}

.assistant-entry-form button[type="submit"] .icon,
.assistant-entry-form .assistant-submit .icon {
  width: 19px;
  height: 19px;
}

.assistant-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.assistant-suggestions button {
  min-height: 44px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
  transition: background 0.25s, border-color 0.25s;
}

.assistant-suggestions button:hover {
  border-color: var(--blue);
  background: color-mix(in srgb, var(--blue) 8%, var(--paper));
}

.assistant-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

/* The preview owns the visible launcher; retain the widget's accessible panel. */
.cyb-widget {
  --cyb-accent: var(--blue);
  --cyb-ink: var(--ink);
  --cyb-muted: var(--muted);
  --cyb-surface: var(--paper);
  --cyb-border: var(--line);
  --cyb-header-surface: var(--surface);
  --cyb-notice-surface: var(--surface);
  --cyb-question-surface: color-mix(in srgb, var(--blue) 10%, var(--paper));
  --cyb-radius: 13px;
  --cyb-font: var(--sans);
  --cyb-heading-font: var(--serif);
  position: relative;
  z-index: 80;
  color: var(--ink);
  color-scheme: light;
}

html[data-theme="night"] .cyb-widget {
  color-scheme: dark;
}

.cyb-widget .cyb-launcher {
  display: none !important;
}

.cyb-widget .cyb-panel {
  position: fixed;
  inset: auto max(24px, env(safe-area-inset-right)) max(88px, calc(24px + env(safe-area-inset-bottom))) auto;
  display: flex;
  width: min(420px, calc(100vw - 48px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  max-width: none;
  height: min(720px, calc(var(--chat-viewport-height, 100dvh) - 120px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  min-height: 300px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 24px 80px color-mix(in srgb, var(--ink) 20%, transparent);
}

.cyb-widget .cyb-header {
  flex-shrink: 0;
  padding: 15px 17px;
  border-color: var(--line);
  background: var(--surface);
}

.cyb-widget .cyb-avatar {
  flex: 0 0 42px;
  border-color: var(--line);
  color: var(--blue);
}

.cyb-widget .cyb-header h2,
.cyb-widget .cyb-welcome h3,
.cyb-widget .cyb-answer-text h3,
.cyb-widget .cyb-answer-text h4,
.cyb-widget .cyb-notice strong,
.cyb-widget .cyb-answer-text strong {
  color: var(--ink);
}

.cyb-widget .cyb-close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  align-self: center;
  color: var(--ink);
}

.cyb-widget .cyb-close:hover {
  background: color-mix(in srgb, var(--ink) 8%, var(--surface));
}

.cyb-widget .cyb-scroll {
  min-height: 0;
  padding: 16px 18px;
  overscroll-behavior: contain;
  scrollbar-color: var(--line) transparent;
}

.cyb-widget .cyb-notice,
.cyb-widget .cyb-feedback,
.cyb-widget .cyb-delete-confirm {
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
}

.cyb-widget .cyb-welcome > span,
.cyb-widget .cyb-sources-toggle:after,
.cyb-widget .cyb-sources-toggle span,
.cyb-widget .cyb-source-title span,
.cyb-widget .cyb-answer-text li::marker {
  color: var(--blue);
}

.cyb-widget .cyb-question {
  background: var(--cyb-question-surface);
  color: var(--ink);
}

.cyb-widget .cyb-composer {
  flex-shrink: 0;
  margin: 10px 14px 0;
}

.cyb-widget .cyb-composer textarea,
.cyb-widget .cyb-feedback textarea,
.cyb-widget .cyb-feedback select {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

.cyb-widget .cyb-composer textarea {
  min-height: 62px;
  max-height: 120px;
  font-size: 16px;
}

.cyb-widget .cyb-composer button {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  top: 9px;
  right: 8px;
  background: var(--blue);
  color: var(--paper);
}

.cyb-widget .cyb-composer p,
.cyb-widget .cyb-footer,
.cyb-widget .cyb-system,
.cyb-widget .cyb-feedback p {
  color: var(--muted);
}

.cyb-widget .cyb-footer {
  flex-shrink: 0;
  gap: 6px 14px;
  padding: 8px 16px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

.cyb-widget .cyb-footer div {
  gap: 6px 12px;
}

.cyb-widget .cyb-answer-actions button,
.cyb-widget .cyb-footer a,
.cyb-widget .cyb-footer button,
.cyb-widget .cyb-feedback button,
.cyb-widget .cyb-delete-confirm button,
.cyb-widget .cyb-recover {
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.cyb-widget .cyb-footer a,
.cyb-widget .cyb-footer button {
  display: inline-flex;
}

.cyb-widget .cyb-feedback textarea,
.cyb-widget .cyb-feedback select {
  min-height: 44px;
  font-size: 16px;
}

.cinematic-chat-launcher {
  position: fixed;
  z-index: 79;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  display: inline-flex;
  min-width: 44px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 19px;
  border: 1px solid color-mix(in srgb, var(--paper) 38%, transparent);
  border-radius: 999px;
  background: var(--blue);
  color: var(--paper);
  box-shadow: 0 14px 38px color-mix(in srgb, var(--ink) 24%, transparent);
  font: 500 12px/1.4 var(--sans);
  letter-spacing: 0.01em;
  transition: transform 0.35s var(--ease), box-shadow 0.35s;
}

.cinematic-chat-launcher:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 44px color-mix(in srgb, var(--ink) 30%, transparent);
}

.cinematic-chat-launcher .icon {
  width: 18px;
  height: 18px;
}

.cinematic-chat-launcher.is-inline-visible,
body:has(dialog[open]) .cinematic-chat-launcher,
body:has(.cyb-widget[data-open="true"]) .cinematic-chat-launcher {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.chat-unavailable-dialog {
  position: fixed;
  inset: auto max(24px, env(safe-area-inset-right)) max(88px, calc(24px + env(safe-area-inset-bottom))) auto;
  display: none;
  width: min(410px, calc(100vw - 48px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  max-width: none;
  max-height: min(720px, calc(var(--chat-viewport-height, 100dvh) - 120px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  margin: 0;
  padding: 25px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 80px color-mix(in srgb, var(--ink) 20%, transparent);
  overscroll-behavior: contain;
}

.chat-unavailable-dialog[open] {
  display: flex;
  flex-direction: column;
}

.chat-unavailable-dialog::backdrop {
  background: transparent;
  backdrop-filter: none;
}

.chat-unavailable-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-shrink: 0;
  padding-bottom: 17px;
  border-bottom: 1px solid var(--line);
}

.chat-unavailable-header .eyebrow {
  color: var(--muted);
}

.chat-unavailable-header button {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.chat-unavailable-header button:hover {
  background: var(--surface);
}

.chat-unavailable-dialog h2 {
  margin-top: 22px;
  font-size: clamp(31px, 4vw, 42px);
  line-height: 1.13;
}

.chat-unavailable-content {
  min-height: 0;
  margin-top: 15px;
  overflow: auto;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

#chat-unavailable-question {
  max-height: min(160px, 25dvh);
  padding: 12px;
  overflow: auto;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  white-space: pre-wrap;
}

.chat-unavailable-dialog [role="status"] {
  margin-top: 17px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--warm);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.65;
}

.chat-unavailable-dialog .outline-pill {
  min-height: 46px;
  margin-top: 18px;
  border-color: var(--line);
  color: var(--ink);
  font-size: 11px;
}

.chat-unavailable-dialog footer {
  margin-top: 19px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.chat-unavailable-dialog footer a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 760px) {
  body:has(.cyb-widget[data-open="true"]) {
    overflow: hidden;
  }
  .assistant-section .assistant-layout {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 29px;
  }

  .assistant-section h2 {
    max-width: 13ch;
    font-size: clamp(40px, 10vw, 56px);
  }

  .assistant-section .assistant-layout > :first-child .eyebrow,
  .assistant-section > .eyebrow {
    margin-bottom: 22px;
  }

  .assistant-card {
    padding: clamp(19px, 5.5vw, 29px);
  }

  .cinematic-chat-launcher {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    min-height: 48px;
    padding-inline: 16px;
  }

  body:has(#mobile-stay.is-visible) .cinematic-chat-launcher {
    bottom: calc(82px + env(safe-area-inset-bottom));
  }

  .cyb-widget .cyb-panel {
    inset: var(--chat-viewport-top, 0px) 0 auto;
    width: 100%;
    max-width: none;
    height: var(--chat-viewport-height, 100dvh);
    max-height: none;
    min-height: 0;
    border-inline: 0;
    border-top: 0;
    border-bottom: 0;
    border-radius: 0;
  }

  .cyb-widget .cyb-header {
    padding: max(9px, env(safe-area-inset-top)) 14px 9px;
  }

  .cyb-widget .cyb-scroll {
    padding: 12px 15px;
  }

  .cyb-widget .cyb-composer {
    margin: 8px 12px 0;
  }

  .cyb-widget .cyb-composer textarea {
    min-height: 58px;
    max-height: 104px;
    padding: 10px 58px 10px 12px;
    font-size: 16px;
  }

  .cyb-widget .cyb-composer button {
    top: 7px;
  }

  .cyb-widget .cyb-footer {
    padding: 5px 13px max(10px, env(safe-area-inset-bottom));
  }

  .chat-unavailable-dialog {
    inset: var(--chat-viewport-top, 0px) 0 auto;
    width: 100%;
    max-width: none;
    height: var(--chat-viewport-height, 100dvh);
    max-height: var(--chat-viewport-height, 100dvh);
    padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    border: 0;
    border-radius: 0;
  }
}

@media (max-width: 370px) {
  .assistant-entry-form > div {
    gap: 6px;
  }

  .assistant-entry-form input {
    padding-inline: 11px;
  }

  .assistant-entry-form button[type="submit"],
  .assistant-entry-form .assistant-submit {
    width: 48px;
    min-width: 48px;
  }

  .assistant-suggestions {
    gap: 6px;
  }

  .assistant-suggestions button {
    padding-inline: 11px;
  }
}

html[data-theme="night"] .cyb-widget .cyb-avatar img {
  filter: brightness(0) invert(1);
}

@media (orientation: landscape) and (max-height: 500px) {
  .cyb-widget .cyb-panel {
    inset-block: var(--chat-viewport-top, 0px) auto;
    height: var(--chat-viewport-height, 100dvh);
    min-height: 0;
  }

  .cyb-widget .cyb-header {
    padding-block: 4px;
  }

  .cyb-widget .cyb-scroll {
    padding-block: 8px;
  }

  .cyb-widget .cyb-welcome {
    padding-block: 10px;
  }

  .cyb-widget .cyb-composer textarea {
    min-height: 50px;
    max-height: 72px;
  }

  .cyb-widget .cyb-footer {
    padding-block: 2px max(4px, env(safe-area-inset-bottom));
  }

  .chat-unavailable-dialog {
    inset-block: var(--chat-viewport-top, 0px) auto;
    height: var(--chat-viewport-height, 100dvh);
    max-height: none;
    padding-block: 10px;
  }

  .chat-unavailable-dialog h2 {
    margin-top: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cinematic-chat-launcher,
  .assistant-entry-form button[type="submit"],
  .assistant-entry-form .assistant-submit,
  .assistant-suggestions button {
    transition: none;
  }
}
