/* El Cronista: el botó de baix a la dreta de tot el web, el seu xat i la pàgina /cronista. */

.cr { --cr-paper: #FDF9F0; font-size: .95rem; }

/* ------------------------------------------------------------ Botó flotant */

.cr--flotant {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  pointer-events: none;
}
.cr--flotant > * { pointer-events: auto; }

.cr-boto {
  display: flex; align-items: center; padding: 0; cursor: pointer;
  border: 2px solid var(--teal); border-radius: 2px; background: var(--cr-paper); color: var(--tinta);
  font: inherit; transition: border-color var(--tr), background var(--tr);
}
.cr-boto img { width: 64px; height: 64px; display: block; }
.cr-boto__text { padding: 0 14px 0 12px; font-weight: 500; font-size: .92rem; white-space: nowrap; line-height: 1.25; text-align: left; }
.cr-boto__text small { display: block; font-weight: 400; color: var(--tinta-suau); font-size: .78rem; }
.cr-boto:hover { border-color: var(--teal-fosc); background: #fff; }
.cr-boto:focus-visible { outline: 3px solid rgba(13, 179, 167, .45); outline-offset: 2px; }
/* Amb el xat obert, el botó no hi és: el panell ocupa el seu lloc (i en té prou amb la creu per tancar). */
.cr--flotant.cr--obert .cr-boto, .cr--flotant.cr--obert .cr-avis { display: none; }

/* La bafarada que saluda (una vegada al dia, i es pot tancar). */
.cr-avis {
  position: relative; max-width: 270px; margin: 0; padding: .75rem 2.2rem .75rem .9rem;
  background: #fff; border: 1px solid var(--vora-forta); border-left: 3px solid var(--teal); border-radius: 2px;
  color: var(--tinta); font-size: .9rem; line-height: 1.45; cursor: pointer;
  animation: cr-apareix .35s ease both;
}
.cr-avis[hidden] { display: none; }
.cr-avis__tanca {
  position: absolute; top: .3rem; right: .3rem; width: 26px; height: 26px; display: grid; place-items: center;
  border: 0; border-radius: 2px; background: none; color: var(--gris); cursor: pointer; font-size: 1.1rem; line-height: 1;
}
.cr-avis__tanca:hover { background: var(--fons); color: var(--tinta); }

/* ------------------------------------------------------------------ Panell */

.cr-panell {
  display: flex; flex-direction: column; overflow: hidden;
  background: #fff; border: 1px solid var(--vora-forta); border-radius: 2px;
}
.cr-panell[hidden] { display: none; }
.cr--flotant .cr-panell {
  position: fixed; right: 20px; bottom: 20px;
  width: min(350px, calc(100vw - 32px)); height: min(540px, calc(100vh - 40px));
  box-shadow: 0 14px 40px rgba(31, 42, 46, .16);
  animation: cr-apareix .22s ease both;
  font-size: .9rem;
}

.cr-cap {
  display: flex; align-items: center; gap: .6rem; padding: .5rem .5rem .5rem .7rem;
  background: var(--cr-paper); border-bottom: 1px solid var(--vora);
}
.cr-cap img { width: 36px; height: 36px; border-radius: 2px; border: 1px solid var(--vora-forta); flex-shrink: 0; }
.cr-cap__nom { flex: 1; min-width: 0; line-height: 1.3; }
.cr-cap__nom strong { display: block; font-size: 1rem; color: var(--tinta); }
.cr-cap__nom span { display: block; font-size: .8rem; color: var(--tinta-suau); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-accio {
  width: 34px; height: 34px; display: grid; place-items: center; flex-shrink: 0;
  border: 0; border-radius: 2px; background: none; color: var(--tinta-suau); cursor: pointer; text-decoration: none;
}
.cr-accio:hover { background: rgba(13, 179, 167, .12); color: var(--teal-fosc); text-decoration: none; }
.cr-accio svg { width: 18px; height: 18px; }
.cr-accio[hidden] { display: none; }

.cr-conversa { flex: 1; overflow-y: auto; padding: .8rem .7rem .4rem; background: var(--fons); scroll-behavior: smooth; overscroll-behavior: contain; }

/* Benvinguda: el retrat i el que diu segons la pàgina. */
.cr-hola { display: grid; grid-template-columns: 56px 1fr; gap: .6rem; align-items: start; margin-bottom: .8rem; }
.cr-hola img { width: 56px; height: 56px; border-radius: 2px; border: 1px solid var(--vora-forta); background: var(--cr-paper); }
.cr-hola .cr-text { background: #fff; border: 1px solid var(--vora); border-radius: 2px; padding: .6rem .75rem; }

/* Missatges */
.cr-msg { margin-bottom: .75rem; }
.cr-msg--usuari { display: flex; justify-content: flex-end; }
.cr-msg--usuari .cr-text { max-width: 85%; background: var(--teal-fosc); color: #fff; border-radius: 2px; padding: .5rem .75rem; }
.cr-msg--cronista { display: grid; grid-template-columns: 26px 1fr; gap: .45rem; align-items: start; }
.cr-msg--cronista > img { width: 26px; height: 26px; border-radius: 2px; border: 1px solid var(--vora-forta); background: var(--cr-paper); }
.cr-msg--cronista .cr-text { background: #fff; border: 1px solid var(--vora); border-radius: 2px; padding: .6rem .75rem; min-width: 0; overflow-wrap: anywhere; }
.cr-font { margin-top: .45rem !important; font-size: .78rem; color: var(--gris); }
.cr-font a { color: var(--tinta-suau) !important; font-weight: 400 !important; }
.cr-text p { margin: 0 0 .6rem; line-height: 1.55; }
.cr-text p:last-child { margin-bottom: 0; }
.cr-text ul { margin: .3rem 0 .6rem; padding-left: 1.15rem; }
.cr-text li { margin-bottom: .25rem; line-height: 1.5; }
.cr-text a { color: var(--teal-fosc); font-weight: 500; }
.cr-msg--usuari .cr-text a { color: #fff; }
.cr-text blockquote {
  margin: .45rem 0 .7rem; padding: .55rem .8rem; border-left: 3px solid var(--teal);
  background: rgba(13, 179, 167, .06); border-radius: 0 2px 2px 0; font-family: Georgia, 'Times New Roman', serif; font-size: .95rem; color: var(--tinta);
}
.cr-text blockquote p { line-height: 1.6; }
.cr-text em { color: var(--tinta-suau); font-size: .86rem; }

.cr-pensant { display: flex; gap: 5px; padding: .35rem 0; }
.cr-pensant span { width: 7px; height: 7px; border-radius: 2px; background: var(--teal); opacity: .35; animation: cr-pensa 1.1s infinite ease-in-out; }
.cr-pensant span:nth-child(2) { animation-delay: .18s; }
.cr-pensant span:nth-child(3) { animation-delay: .36s; }

.cr-sugg { display: flex; flex-wrap: wrap; gap: .35rem; margin: -.15rem 0 .8rem 32px; }
.cr-hola + .cr-sugg { margin-left: 0; }
.cr-sugg button {
  padding: .32rem .6rem; border: 1px solid var(--vora-forta); border-radius: 2px; background: #fff;
  color: var(--tinta); font: inherit; font-size: .8rem; cursor: pointer; text-align: left; line-height: 1.3;
}
.cr-sugg button:hover { border-color: var(--teal); color: var(--teal-fosc); }

.cr-valora { display: flex; align-items: center; gap: .3rem; margin-top: .55rem; padding-top: .45rem; border-top: 1px solid var(--vora); font-size: .78rem; color: var(--gris); }
.cr-valora button { border: 1px solid transparent; border-radius: 2px; background: none; padding: .1rem .35rem; cursor: pointer; font-size: .9rem; }
.cr-valora button:hover { border-color: var(--vora-forta); }

.cr-form { display: flex; gap: .4rem; padding: .55rem; border-top: 1px solid var(--vora); background: #fff; }
.cr-input {
  flex: 1; min-width: 0; padding: .55rem .7rem; border: 1px solid var(--vora-forta); border-radius: 2px;
  font: inherit; font-size: .92rem; background: var(--fons); color: var(--tinta);
}
.cr-input:focus { outline: none; border-color: var(--teal); background: #fff; }
.cr-input:disabled { opacity: .6; }
.cr-enviar {
  width: 40px; flex-shrink: 0; display: grid; place-items: center; border: 0; border-radius: 2px;
  background: var(--teal-fosc); color: #fff; cursor: pointer;
}
.cr-enviar:hover { background: var(--teal); }
.cr-enviar:disabled { opacity: .5; cursor: default; }
.cr-enviar svg { width: 20px; height: 20px; }
.cr-peu { margin: 0; padding: 0 .7rem .45rem; background: #fff; font-size: .7rem; color: var(--gris); text-align: center; }
.cr--flotant .cr-peu { display: none; }

/* ------------------------------------------------------- Pàgina /cronista */

.cr-pagina { padding: 2rem 0 3.5rem; }
.cr-presenta { display: grid; grid-template-columns: 180px 1fr; gap: 2rem; align-items: center; margin-bottom: 2rem; }
.cr-presenta img { width: 180px; height: 180px; border-radius: 2px; border: 1px solid var(--vora-forta); background: #FDF9F0; }
.cr-presenta h1 { font-size: clamp(1.6rem, 3.6vw, 2.2rem); margin-bottom: .5rem; }
.cr-presenta p { color: var(--tinta-suau); max-width: 64ch; margin: 0 0 .8rem; }
.cr-xifres { display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; margin: 0; padding: 0; list-style: none; font-size: .88rem; color: var(--tinta-suau); }
.cr-xifres strong { color: var(--teal-fosc); font-size: 1.05rem; }
.cr--pagina .cr-panell { height: min(70vh, 720px); min-height: 460px; }
.cr--pagina .cr-conversa { padding: 1.3rem 1.3rem .6rem; }
.cr--pagina .cr-msg--cronista .cr-text, .cr--pagina .cr-hola .cr-text { max-width: 760px; }

@media (max-width: 640px) {
  .cr--flotant { right: 12px; bottom: 12px; }
  body:has(.barra-edicio) .cr--flotant { bottom: 72px; }
  .cr-boto img { width: 56px; height: 56px; }
  .cr-boto__text { display: none; }
  .cr--flotant .cr-panell { inset: 0; width: 100%; height: 100%; height: 100dvh; border: 0; box-shadow: none; font-size: .95rem; }
  .cr-presenta { grid-template-columns: 1fr; gap: 1rem; }
  .cr-presenta img { width: 120px; height: 120px; }
  .cr--pagina .cr-panell { height: 75vh; min-height: 0; }
}
body.cr-bloqueja { overflow: hidden; }

@keyframes cr-apareix { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes cr-pensa { 0%, 60%, 100% { opacity: .35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .cr-avis, .cr--flotant .cr-panell { animation: none; } .cr-pensant span { animation: none; opacity: .7; } }
@media print { .cr--flotant { display: none !important; } }
