/* Chaos layer — dark patterns that fade with understanding */

.chaos-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  opacity: calc(var(--chaos) * 1);
  transition: opacity 0.45s ease;
}

.chaos-layer.is-gone {
  opacity: 0;
  visibility: hidden;
}

.chaos-layer > * {
  pointer-events: auto;
}

/* ——— Top urgency strip ——— */
.chaos-urgency {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, #c0392b, #e74c3c);
  color: white;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
  padding: 0.5rem 2rem;
  z-index: 95;
  letter-spacing: 0.02em;
  animation: chaos-pulse-bg 2s ease-in-out infinite;
}

.chaos-urgency strong {
  font-variant-numeric: tabular-nums;
}

@keyframes chaos-pulse-bg {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.08); }
}

/* ——— Social proof toast ——— */
.chaos-social {
  position: fixed;
  top: 2.75rem;
  left: 1rem;
  max-width: 16rem;
  background: white;
  border: 2px solid #27ae60;
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  z-index: 94;
  pointer-events: none;
  animation: chaos-slide-in 0.6s ease-out, chaos-wiggle 4s ease-in-out 1s infinite;
}

.chaos-social__dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #27ae60;
  border-radius: 50%;
  margin-right: 0.35rem;
  animation: chaos-blink 1.2s infinite;
}

.chaos-social__num {
  font-weight: 700;
  color: #27ae60;
}

@keyframes chaos-slide-in {
  from { transform: translateX(-120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes chaos-wiggle {
  0%, 90%, 100% { transform: translateX(0); }
  92% { transform: translateX(-3px); }
  94% { transform: translateX(3px); }
  96% { transform: translateX(-2px); }
}

@keyframes chaos-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ——— Cookie banner ——— */
.chaos-cookie {
  position: fixed;
  bottom: 5.5rem;
  left: 1rem;
  right: 1rem;
  max-width: 22rem;
  background: #2c3e50;
  color: #ecf0f1;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  padding: 1rem;
  border-radius: 8px;
  z-index: 93;
  line-height: 1.45;
  box-shadow: 0 -2px 24px rgba(0,0,0,0.2);
}

.chaos-cookie p { margin-bottom: 0.75rem; }

.chaos-cookie__btns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  position: relative;
}

.chaos-cookie__accept,
.chaos-cookie__reject {
  will-change: transform;
}

.chaos-cookie button {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.chaos-cookie__accept {
  background: #27ae60;
  color: white;
  flex: 1;
}

.chaos-cookie__reject {
  background: transparent;
  color: #95a5a6;
  text-decoration: underline;
  font-weight: 400;
}

.chaos-cookie__meta {
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.45;
  color: #bdc3c7;
  font-style: italic;
}

.chaos-cookie--surrendered {
  border: 1px solid #27ae60;
}

/* ——— Newsletter intercept ——— */
.chaos-newsletter-wrap {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 92;
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: flex-start;
  max-width: calc(100vw - 1rem);
}

.chaos-newsletter-wrap .chaos-newsletter {
  position: static;
  transform: none;
  flex: 0 0 auto;
  align-self: flex-start;
}

.chaos-newsletter-panel {
  flex: 0 1 auto;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: 0.35rem;
  background: #8e44ad;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.62rem;
  line-height: 1.3;
  padding: 0;
  border-radius: 0;
  overflow: hidden;
  max-width: 0;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: max-width 0.4s ease, max-height 0.4s ease, opacity 0.3s ease, padding 0.4s ease;
}

.chaos-newsletter-wrap.is-open .chaos-newsletter-panel {
  max-width: 18rem;
  opacity: 1;
  padding: 0.4rem 0.5rem;
  pointer-events: auto;
}

.chaos-newsletter__intro {
  margin: 0;
  font-size: 0.56rem;
  line-height: 1.3;
}

.chaos-newsletter__intro strong {
  font-weight: 700;
}

.chaos-newsletter__quote-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.chaos-newsletter-wrap.is-open .chaos-newsletter {
  border-radius: 0;
}

.chaos-newsletter__platitude {
  margin: 0;
  flex: 1;
  font-style: italic;
}

.chaos-newsletter__prev,
.chaos-newsletter__next {
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

/* ——— Newsletter tab (legacy selector; positioning on wrap) ——— */
.chaos-newsletter {
  background: #8e44ad;
  color: white;
  font-family: var(--font-sans);
  font-size: 0.55rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.04em;
  padding: 0.5rem 0.35rem;
  margin: 0;
  border: none;
  border-radius: 8px 0 0 8px;
  z-index: 92;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  white-space: nowrap;
  width: auto;
  min-width: 0;
  min-height: 0;
  height: auto;
  display: inline-block;
  box-sizing: border-box;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

/* ——— Chatbot ——— */
.chaos-chat {
  position: fixed;
  bottom: 6.5rem;
  right: 1.25rem;
  width: 17rem;
  z-index: 96;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  animation: chaos-chat-bob 2.5s ease-in-out infinite;
}

@keyframes chaos-chat-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.chaos-chat__bubble {
  background: white;
  border: 2px solid #3498db;
  border-radius: 8px;
  padding: 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  line-height: 1.4;
  box-shadow: 0 4px 16px rgba(52, 152, 219, 0.25);
  margin-bottom: 0.5rem;
  width: 100%;
}

.chaos-chat__name {
  font-weight: 700;
  color: #3498db;
  font-size: 0.65rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.chaos-chat__typing {
  display: inline-flex;
  gap: 3px;
}

.chaos-chat__typing span {
  width: 5px;
  height: 5px;
  background: #3498db;
  border-radius: 50%;
  animation: chaos-typing 1.2s infinite;
}

.chaos-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.chaos-chat__typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chaos-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chaos-chat__bubble p#chat-message {
  transition: opacity 0.3s ease;
}

.chaos-chat__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-left: auto;
  border-radius: 50%;
  background: #3498db;
  border: 2px solid white;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: white;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  animation: chaos-chat-pulse 1.8s ease-in-out infinite;
}

@keyframes chaos-chat-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(52, 152, 219, 0.4); }
  50% { box-shadow: 0 4px 28px rgba(52, 152, 219, 0.7); }
}

.chaos-chat--open {
  width: 17.5rem;
  animation: none;
}

.chaos-chat__panel {
  width: 100%;
  background: #fff;
  border: 2px solid #3498db;
  border-radius: 8px;
  padding: 0.65rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 4px 16px rgba(52, 152, 219, 0.25);
  box-sizing: border-box;
}

.chaos-chat__panel-title {
  margin: 0 0 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 700;
  color: #3498db;
}

.chaos-chat__log {
  max-height: 7rem;
  overflow-y: auto;
  margin-bottom: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.68rem;
  line-height: 1.4;
}

.chaos-chat__msg {
  margin: 0 0 0.45rem;
}

.chaos-chat__msg--user {
  text-align: right;
  color: #2c3e50;
}

.chaos-chat__msg--bot {
  color: #34495e;
}

.chaos-chat__input-row {
  display: flex;
  gap: 0.35rem;
}

.chaos-chat__input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-sans);
  font-size: 0.65rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
}

.chaos-chat__send {
  font-family: var(--font-sans);
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.35rem 0.55rem;
  border: none;
  border-radius: 4px;
  background: #3498db;
  color: #fff;
  cursor: pointer;
}

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

/* ——— FAB: Call for quote ——— */
.chaos-fab-quote {
  position: fixed;
  bottom: 6.5rem;
  left: 1.25rem;
  background: #e67e22;
  color: white;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.85rem 1.1rem;
  border-radius: 999px;
  border: none;
  box-shadow: 0 4px 20px rgba(230, 126, 34, 0.5);
  cursor: pointer;
  z-index: 96;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  animation: none;
}

@keyframes chaos-fab-bounce {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.05); }
  30% { transform: scale(1); }
  45% { transform: scale(1.03); }
}

.chaos-fab-quote.is-queue {
  max-width: 14rem;
  text-transform: none;
  font-weight: 500;
  font-size: 0.62rem;
  line-height: 1.4;
  letter-spacing: 0;
  text-align: left;
  animation: none;
  cursor: default;
  white-space: normal;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.chaos-fab-quote.is-queue strong {
  font-weight: 700;
  color: #fff3e0;
}

.chaos-fab-quote__connect {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.58rem;
}

.chaos-fab-quote__phone {
  display: inline-block;
  animation: chaos-phone-quiver 0.55s ease-in-out infinite;
}

@keyframes chaos-phone-quiver {
  0%, 100% { transform: rotate(-8deg) translateY(0); }
  25% { transform: rotate(6deg) translateY(-1px); }
  50% { transform: rotate(-4deg) translateY(0); }
  75% { transform: rotate(8deg) translateY(-1px); }
}

.chaos-fab-quote__dots {
  opacity: 0.95;
  animation: chaos-connect-pulse 1s ease-in-out infinite;
}

@keyframes chaos-connect-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.chaos-fab-quote__queue-text {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

/* ——— Mystery ? button ——— */
.chaos-mystery {
  position: fixed;
  bottom: 11rem;
  right: 1.25rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: #9b59b6;
  color: white;
  border: 2px solid white;
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: help;
  z-index: 95;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  animation: chaos-mystery-spin 8s linear infinite;
}

@keyframes chaos-mystery-spin {
  0%, 85%, 100% { transform: rotate(0deg); }
  88% { transform: rotate(15deg); }
  91% { transform: rotate(-10deg); }
  94% { transform: rotate(5deg); }
}

/* ——— Trust badges strip ——— */
.chaos-trust {
  position: fixed;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 90vw;
  z-index: 91;
  font-family: var(--font-sans);
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.chaos-trust span {
  background: white;
  border: 1px solid #bdc3c7;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  color: #7f8c8d;
}

/* ——— Parody label (always slightly visible early) ——— */
.chaos-parody-hint {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: calc(var(--chaos) * 0.12);
  pointer-events: none;
  z-index: 1;
  white-space: nowrap;
  border: 2px dashed var(--accent);
  padding: 0.5rem 1rem;
  transform: translate(-50%, -50%) rotate(-8deg);
}

/* Push page content below urgency bar in chaos mode */
body.chaos-mode {
  padding-top: calc(var(--chaos) * 2.25rem);
}

body.chaos-mode .clarity-control {
  z-index: 200;
}

body.chaos-mode .hero__hint--parody {
  font-weight: 600;
  color: #c0392b;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  border: 1px dashed #c0392b;
  padding: 0.5rem 0.75rem;
  background: rgba(192, 57, 43, 0.06);
  margin-top: 1rem;
  opacity: calc(0.5 + var(--chaos) * 0.5);
}

/* Extra dense content in chaos mode */
.chaos-content-bloat {
  opacity: var(--chaos);
  transition: opacity 0.4s ease;
  margin: 1.5rem 0;
  padding: 1rem;
  border: 2px dashed #e74c3c;
  background: rgba(231, 76, 60, 0.04);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.chaos-content-bloat h3 {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #e74c3c;
  margin-bottom: 0.5rem;
}

.chaos-bloat-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.chaos-bloat-tags span {
  background: #ecf0f1;
  padding: 0.2rem 0.45rem;
  border-radius: 3px;
  font-size: 0.6rem;
}

@media (max-width: 640px) {
  .chaos-chat { width: 14rem; right: 0.75rem; }
  .chaos-fab-quote { font-size: 0.6rem; padding: 0.7rem 0.9rem; }
  .chaos-cookie { max-width: none; }
  .chaos-newsletter-wrap { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .chaos-layer * { animation: none !important; }
}
