/* CADROLL widgets: cookie consent (§10) and CADROLL Agent (§11).
   Uses only the tokens defined in cadroll-glass.css. See DESIGN.md. */

.cr-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- glass recipes for the widgets (small / large) ---------- */
#cr-consent, #cr-agent-fab {
  background: rgb(var(--cr-surface-rgb) / var(--cr-glass-fill-small-b));
  box-shadow: var(--cr-glass-shadow-small), inset 0 1px 0 rgb(255 255 255 / .14), inset 0 0 0 1px rgb(255 255 255 / .08);
  color: var(--cr-on-surface);
}
.cr-sheet, #cr-agent {
  background: rgb(var(--cr-surface-rgb) / var(--cr-glass-fill-large-b));
  box-shadow: var(--cr-glass-shadow-large), inset 0 1px 0 rgb(255 255 255 / .14), inset 0 0 0 1px rgb(255 255 255 / .08);
  color: var(--cr-on-surface);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  #cr-consent, #cr-agent-fab {
    background: rgb(var(--cr-surface-rgb) / var(--cr-glass-fill-small));
    -webkit-backdrop-filter: blur(var(--cr-glass-blur-small)) saturate(1.6);
    backdrop-filter: blur(var(--cr-glass-blur-small)) saturate(1.6);
  }
  .cr-sheet, #cr-agent {
    background: rgb(var(--cr-surface-rgb) / var(--cr-glass-fill-large));
    -webkit-backdrop-filter: blur(var(--cr-glass-blur-large)) saturate(1.6);
    backdrop-filter: blur(var(--cr-glass-blur-large)) saturate(1.6);
  }
}

/* ========== 10. Cookie consent ========== */
#cr-consent {
  position: fixed; z-index: 60;
  left: var(--cr-inset); bottom: var(--cr-inset);
  width: min(560px, calc(100vw - 2 * var(--cr-inset)));
  padding: var(--space-5) var(--space-6);
  border-radius: var(--cr-radius-panel);
  font-size: 14px; line-height: 1.55;
  opacity: 0; translate: 0 12px; visibility: hidden;
  transition: opacity var(--dur-short) var(--ease-emphasized), translate var(--dur-short) var(--ease-emphasized), visibility 0s linear var(--dur-short);
}
#cr-consent.is-visible { opacity: 1; translate: 0 0; visibility: visible; transition-delay: 0s; }
#cr-consent h2, .cr-sheet h2 { font-size: 17px; font-weight: 600; margin: 0 0 6px; color: var(--cr-on-surface); }
#cr-consent p, .cr-sheet > p { margin: 0; color: var(--cr-on-surface-variant); font-size: 14px; line-height: 1.55; }
#cr-consent a, .cr-sheet a, #cr-agent a { color: var(--cr-primary); text-decoration: underline; text-underline-offset: 2px; }
.cr-consent__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); align-items: center; }
#cr-consent .cr-consent__actions { justify-content: flex-end; }
.cr-btn {
  min-height: 44px; padding: 0 var(--space-5);
  border-radius: var(--cr-radius-capsule);
  border: 1px solid rgb(var(--cr-on-surface-rgb) / .24);
  background: rgb(var(--cr-on-surface-rgb) / .08);
  color: var(--cr-on-surface);
  font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1; letter-spacing: .02em;
  cursor: pointer;
  transition: background-color var(--dur-micro) ease, border-color var(--dur-micro) ease, color var(--dur-micro) ease, scale var(--spring-release-ms) var(--spring-release);
}
.cr-btn:hover { background: rgb(var(--cr-on-surface-rgb) / .14); }
.cr-btn:active { scale: .96; transition-duration: var(--spring-press-ms); transition-timing-function: var(--spring-press); }
.cr-btn--primary { background: var(--cr-primary); border-color: var(--cr-primary); color: var(--cr-on-primary); }
.cr-btn--primary:hover { background: var(--cr-on-surface); border-color: var(--cr-on-surface); }
.cr-btn--text { background: none; border-color: transparent; text-decoration: underline; text-underline-offset: 3px; padding: 0 var(--space-3); margin-right: auto; }
.cr-btn--text:hover { background: rgb(var(--cr-on-surface-rgb) / .06); }
@media (max-width: 520px) {
  #cr-consent .cr-consent__actions .cr-btn:not(.cr-btn--text) { flex: 1 1 0; }
  .cr-btn--text { width: 100%; margin: 0; }
}

#cr-consent-modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: var(--cr-inset); visibility: hidden; transition: visibility 0s linear var(--dur-short); }
#cr-consent-modal.is-open { visibility: visible; transition-delay: 0s; }
#cr-consent-modal .cr-scrim {
  position: absolute; inset: 0; background: rgb(3 10 28 / .45);
  opacity: 0; transition: opacity var(--dur-short) var(--ease-emphasized);
}
#cr-consent-modal.is-open .cr-scrim { opacity: 1; }
.cr-sheet {
  position: relative; width: min(560px, 100%); max-height: calc(100svh - 32px); overflow: auto;
  padding: var(--space-6) var(--space-6) var(--space-5);
  border-radius: 32px;
  opacity: 0; scale: .92;
  transition: opacity var(--dur-short) var(--ease-emphasized), scale var(--spring-morph-ms) var(--spring-morph);
}
#cr-consent-modal.is-open .cr-sheet { opacity: 1; scale: 1; }
.cr-prefs { display: grid; gap: var(--space-2); margin-top: var(--space-4); }
.cr-pref {
  display: flex; gap: var(--space-4); align-items: flex-start; justify-content: space-between;
  padding: var(--space-4);
  border-radius: max(8px, calc(32px - var(--space-6))); /* concentric with the 32px sheet */
  background: rgb(var(--cr-on-surface-rgb) / .05);
}
.cr-pref h3 { font-size: 14px; font-weight: 600; margin: 0 0 4px; color: var(--cr-on-surface); }
.cr-pref p { font-size: 13px; line-height: 1.5; margin: 0; color: var(--cr-on-surface-variant); }
.cr-switch {
  flex: none; position: relative; width: 52px; height: 32px; margin-top: 2px;
  border-radius: var(--cr-radius-capsule); border: 0; cursor: pointer;
  background: rgb(var(--cr-on-surface-rgb) / .22);
  transition: background-color var(--dur-micro) ease;
}
.cr-switch span {
  position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--cr-on-surface); box-shadow: 0 1px 3px rgb(0 0 0 / .3);
  transition: translate var(--spring-select-ms) var(--spring-select), background-color var(--dur-micro) ease;
}
.cr-switch[aria-checked="true"] { background: var(--cr-primary); }
.cr-switch[aria-checked="true"] span { translate: 20px 0; background: var(--cr-on-primary); }
.cr-switch[disabled] { opacity: .55; cursor: not-allowed; }
.cr-sheet .cr-consent__actions { justify-content: flex-end; margin-top: var(--space-5); }
.cr-linkbtn { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; text-align: inherit; }

/* ========== 11. CADROLL Agent ========== */
#cr-agent-fab {
  position: fixed; z-index: 58;
  right: var(--cr-inset); bottom: calc(var(--cr-inset) + var(--cr-consent-h, 0px));
  display: inline-flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 22px 0 8px;
  border: 0; border-radius: var(--cr-radius-capsule);
  font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1; letter-spacing: .06em; text-transform: uppercase;
  cursor: pointer;
  transition: bottom var(--spring-morph-ms) var(--spring-morph), scale var(--spring-release-ms) var(--spring-release), opacity var(--dur-short) ease;
}
.cr-agent-fab__icon {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--cr-primary); color: var(--cr-on-primary); /* the single tinted element of this control */
}
#cr-agent-fab:hover { scale: 1.03; }
#cr-agent-fab:active { scale: .96; transition-duration: var(--spring-press-ms); transition-timing-function: var(--spring-press); }
@media (max-width: 520px) { #cr-agent-fab { padding: 0 8px; } .cr-agent-fab__label { display: none; } }
/* no glass on glass: the button leaves while the panel it opened is showing */
.cr-agent-open #cr-agent-fab { opacity: 0; scale: .6; pointer-events: none; }

#cr-agent {
  position: fixed; z-index: 59;
  right: var(--cr-inset); bottom: calc(var(--cr-inset) + var(--cr-consent-h, 0px));
  width: min(400px, calc(100vw - 2 * var(--cr-inset)));
  height: min(620px, calc(100svh - var(--cr-inset) * 2 - var(--cr-consent-h, 0px)));
  display: flex; flex-direction: column;
  border-radius: var(--cr-radius-panel);
  overflow: hidden;
  transform-origin: bottom right; /* morphs out of the button */
  opacity: 0; scale: .6; visibility: hidden;
  transition: opacity var(--dur-short) var(--ease-emphasized), scale var(--spring-morph-ms) var(--spring-morph), visibility 0s linear var(--spring-morph-ms);
}
#cr-agent.is-open { opacity: 1; scale: 1; visibility: visible; transition-delay: 0s; }
@media (max-width: 520px) {
  #cr-agent { right: 8px; left: 8px; bottom: 8px; width: auto; height: calc(100svh - 16px); }
}
.cr-agent__head {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-3) var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--cr-outline-variant);
}
.cr-agent__avatar {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: rgb(var(--cr-on-surface-rgb) / .08); box-shadow: inset 0 0 0 1px rgb(var(--cr-primary-rgb) / .35);
}
.cr-agent__title { flex: 1; min-width: 0; }
.cr-agent__title h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--cr-on-surface); letter-spacing: .01em; }
.cr-agent__title p { margin: 2px 0 0; font-size: 12px; color: var(--cr-on-surface-variant); display: flex; align-items: center; gap: 6px; }
.cr-dot { width: 7px; height: 7px; border-radius: 50%; background: #3DD68C; box-shadow: 0 0 0 3px rgb(61 214 140 / .2); }
.cr-agent__close {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: transparent; color: var(--cr-on-surface-variant); display: grid; place-items: center;
  transition: background-color var(--dur-micro) ease, color var(--dur-micro) ease;
}
.cr-agent__close:hover { background: rgb(var(--cr-on-surface-rgb) / .08); color: var(--cr-on-surface); }
.cr-agent__log {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3);
}
.cr-msg {
  max-width: 88%; padding: 10px 14px; font-size: 14px; line-height: 1.55;
  border-radius: 18px; overflow-wrap: anywhere;
  animation: cr-msg-in var(--dur-short) var(--ease-emphasized) both;
}
.cr-msg p { margin: 0 0 6px; } .cr-msg p:last-child { margin-bottom: 0; }
.cr-msg ul { margin: 4px 0 6px; padding-left: 18px; list-style: disc; } .cr-msg li { margin: 3px 0; }
.cr-msg strong { color: var(--cr-on-surface); font-weight: 600; }
.cr-msg--agent { align-self: flex-start; background: rgb(var(--cr-on-surface-rgb) / .07); color: var(--cr-on-surface-variant); border-bottom-left-radius: 6px; }
.cr-msg--user { align-self: flex-end; background: rgb(var(--cr-primary-rgb) / .18); color: var(--cr-on-surface); border-bottom-right-radius: 6px; white-space: pre-wrap; }
.cr-msg--error { box-shadow: inset 0 0 0 1px rgb(229 72 77 / .45); }
@keyframes cr-msg-in { from { opacity: 0; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }
.cr-typing { display: inline-flex; gap: 5px; padding: 14px 16px; }
.cr-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--cr-on-surface-variant); animation: cr-typing 1s ease-in-out infinite; }
.cr-typing span:nth-child(2) { animation-delay: .15s; }
.cr-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes cr-typing { 0%, 80%, 100% { opacity: .3; translate: 0 0; } 40% { opacity: 1; translate: 0 -3px; } }
.cr-agent__chips { display: flex; flex-wrap: wrap; gap: var(--space-2); padding: 0 var(--space-4) var(--space-3); }
.cr-agent__chips[hidden] { display: none; }
.cr-chip {
  min-height: 36px; padding: 0 14px; border-radius: var(--cr-radius-capsule); cursor: pointer;
  border: 1px solid rgb(var(--cr-primary-rgb) / .35); background: rgb(var(--cr-primary-rgb) / .08);
  color: var(--cr-primary); font-family: inherit; font-size: 13px; font-weight: 500; line-height: 1;
  transition: background-color var(--dur-micro) ease, scale var(--spring-release-ms) var(--spring-release);
}
.cr-chip:hover { background: rgb(var(--cr-primary-rgb) / .16); }
.cr-chip:active { scale: .96; }
.cr-agent__form {
  display: flex; align-items: flex-end; gap: var(--space-2);
  margin: 0 var(--space-3); padding: 6px 6px 6px 16px;
  border-radius: 26px; background: rgb(var(--cr-on-surface-rgb) / .07);
  box-shadow: inset 0 0 0 1px rgb(var(--cr-on-surface-rgb) / .12);
}
.cr-agent__form:focus-within { box-shadow: inset 0 0 0 1.5px rgb(var(--cr-primary-rgb) / .6); }
.cr-agent__form textarea {
  flex: 1; resize: none; border: 0; outline: 0; background: transparent;
  color: var(--cr-on-surface); font-family: inherit; font-size: 14px; line-height: 1.45;
  padding: 10px 0; max-height: 120px;
}
.cr-agent__form textarea::placeholder { color: rgb(var(--cr-on-surface-rgb) / .5); }
.cr-agent__send {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--cr-primary); color: var(--cr-on-primary); display: grid; place-items: center;
  transition: opacity var(--dur-micro) ease, scale var(--spring-release-ms) var(--spring-release);
}
.cr-agent__send:disabled { opacity: .45; cursor: wait; }
.cr-agent__send:active { scale: .92; }
.cr-agent__note { margin: 0; padding: var(--space-2) var(--space-4) var(--space-3); font-size: 11.5px; line-height: 1.45; color: rgb(var(--cr-on-surface-rgb) / .66); }

/* ---------- accessibility modes ---------- */
@media (prefers-reduced-transparency: reduce) {
  #cr-consent, #cr-agent-fab, .cr-sheet, #cr-agent { background: var(--cr-surface-container-high) !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; outline: 1px solid var(--cr-outline-variant); }
}
html[data-glass="off"] :is(#cr-consent, #cr-agent-fab, .cr-sheet, #cr-agent) { background: var(--cr-surface-container-high) !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; outline: 1px solid var(--cr-outline-variant); }
@media (prefers-contrast: more) {
  #cr-consent, #cr-agent-fab, .cr-sheet, #cr-agent { background: var(--cr-surface) !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; outline: 1.5px solid var(--cr-on-surface); }
  .cr-msg--agent { color: var(--cr-on-surface); }
}
html[data-contrast="more"] :is(#cr-consent, #cr-agent-fab, .cr-sheet, #cr-agent) { background: var(--cr-surface) !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; outline: 1.5px solid var(--cr-on-surface); }
html[data-contrast="more"] .cr-msg--agent { color: var(--cr-on-surface); }
@media (prefers-reduced-motion: reduce) {
  #cr-agent, .cr-sheet { scale: 1 !important; }
  #cr-consent { translate: none !important; }
  .cr-msg { animation: none; }
  .cr-typing span { animation: none; opacity: .7; }
}
html[data-motion="reduce"] :is(#cr-agent, .cr-sheet) { scale: 1 !important; }
html[data-motion="reduce"] #cr-consent { translate: none !important; }
html[data-motion="reduce"] .cr-msg { animation: none; }
html[data-motion="reduce"] .cr-typing span { animation: none; opacity: .7; }
@media (forced-colors: active) {
  #cr-consent, #cr-agent-fab, .cr-sheet, #cr-agent { background: Canvas !important; border: 1px solid CanvasText; backdrop-filter: none !important; }
}
@media print { #cr-consent, #cr-consent-modal, #cr-agent, #cr-agent-fab, #cr-cursor { display: none !important; } }
