/* ═══════════════════════════════════════════════════════════════════
   collaboratives.css — стили для списка и детальной страницы совместников.
   Паттерн: gallery-additions.css + shared-detail.css (profile hero).
   Темы: light (default) + dark (html[data-theme="dark"]).
   ═══════════════════════════════════════════════════════════════════ */

/* ──────────────────────────────────────────
   1. LIST PAGE — Hero
   ────────────────────────────────────────── */

.collab-hero {
  text-align: center;
  padding: 40px 20px 24px;
}

.collab-hero__inner {
  max-width: 640px;
  margin: 0 auto;
}

.collab-hero__title {
  font-family: "Lora", serif;
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 6px;
  line-height: 1.2;
}

.collab-hero__subtitle {
  font-size: 0.92rem;
  color: var(--text-3);
  margin: 0;
  line-height: 1.5;
}

/* ──────────────────────────────────────────
   2. LIST PAGE — Toolbar (фильтры + сортировка)
   ────────────────────────────────────────── */

.collab-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  transition: box-shadow 0.2s;
}

.collab-toolbar__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ── Filter chips ── */

.collab-chips {
  display: flex;
  gap: 8px;
}

.collab-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-3);
  background: var(--bg-subtle);
  border: 1px solid transparent;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
}

.collab-chip:hover {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text);
}

.collab-chip--active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-light);
}

.collab-chip--active:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.collab-chip svg {
  flex-shrink: 0;
}

/* ── Sort ── */

.collab-sort {
  display: flex;
  align-items: center;
  gap: 8px;
}

.collab-sort__label {
  font-size: 0.78rem;
  color: var(--text-4);
  white-space: nowrap;
}

.collab-sort__options {
  display: flex;
  gap: 4px;
}

.collab-sort__btn {
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-3);
  background: transparent;
  transition: all 0.15s;
  white-space: nowrap;
}

.collab-sort__btn:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.collab-sort__btn--active {
  background: var(--bg-subtle);
  color: var(--text);
  font-weight: 600;
}

/* ──────────────────────────────────────────
   3. LIST PAGE — Grid
   ────────────────────────────────────────── */

.collab-list {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.collab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

/* ──────────────────────────────────────────
   4. LIST PAGE — Card (_CollaborativeCard)
   ────────────────────────────────────────── */

.collab-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition:
    transform 0.25s var(--ease),
    box-shadow 0.25s var(--ease),
    border-color 0.25s;
}

.collab-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-hover, var(--border));
}

/* Cover */
.collab-card__cover {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-subtle);
}

.collab-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s var(--ease);
}

.collab-card:hover .collab-card__img {
  transform: scale(1.03);
}

.collab-card__img--ph {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
}

.collab-card__gradient {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.15));
  pointer-events: none;
}

/* Badge */
.collab-card__badge {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  z-index: 2;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.collab-card__badge--plenty {
  background: rgba(52, 199, 89, 0.88);
}
.collab-card__badge--warning {
  background: rgba(255, 149, 0, 0.88);
}
.collab-card__badge--urgent {
  background: rgba(255, 59, 48, 0.88);
}
.collab-card__badge--inactive {
  background: rgba(142, 142, 147, 0.8);
}

.collab-card__badge svg {
  flex-shrink: 0;
}

/* Body */
.collab-card__body {
  padding: 14px 16px 16px;
}

.collab-card__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.collab-card__desc {
  font-size: 0.82rem;
  color: var(--text-3);
  margin: 0 0 10px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Meta (book · author) */
.collab-card__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.collab-card__book-thumb {
  width: 16px;
  height: 22px;
  border-radius: 2px;
  object-fit: cover;
  flex-shrink: 0;
}

.collab-card__meta-text {
  font-size: 0.78rem;
  color: var(--text-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Footer */
.collab-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.collab-card__creator {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-shrink: 1;
}

.collab-card__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid var(--border);
}

.collab-card__avatar--ph {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-3);
}

.collab-card__creator-name {
  font-size: 0.8rem;
  color: var(--text-3);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Stats */
.collab-card__stats {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.collab-card__stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-4);
  font-weight: 500;
}

.collab-card__stat svg {
  color: var(--text-4);
  flex-shrink: 0;
}

/* ──────────────────────────────────────────
   5. LIST PAGE — Empty state
   ────────────────────────────────────────── */

.collab-empty {
  text-align: center;
  padding: 80px 20px;
}

.collab-empty__icon {
  margin-bottom: 20px;
}

.collab-empty__title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}

.collab-empty__text {
  font-size: 0.9rem;
  color: var(--text-3);
  max-width: 360px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════════════
   6. DETAIL PAGE — Hero
   ══════════════════════════════════════════════════════════════════ */

.cd-hero {
  position: relative;
  min-height: 340px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.cd-hero__bg {
  position: absolute;
  inset: 0;
}

.cd-hero__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cd-hero__img--ph {
  background: var(--bg-subtle);
}

.cd-hero__gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.1) 0%,
    transparent 20%,
    transparent 35%,
    rgba(0, 0, 0, 0.5) 65%,
    rgba(0, 0, 0, 0.88) 100%
  );
}

.cd-hero__content {
  position: relative;
  z-index: 2;
  max-width: 800px;
  padding: 60px 24px 28px;
}

.cd-hero__badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 14px;
}

.cd-hero__badge--plenty {
  background: #34c759;
}
.cd-hero__badge--warning {
  background: #ff9500;
}
.cd-hero__badge--urgent {
  background: #ff3b30;
}
.cd-hero__badge--inactive {
  background: #8e8e93;
}

.cd-hero__title {
  font-family: "Lora", serif;
  font-size: 2rem;
  font-weight: 600;
  color: #fff;
  margin: 0 0 16px;
  line-height: 1.2;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}

/* Creator */
.cd-hero__meta {
  display: flex;
  align-items: center;
}

.cd-hero__creator {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
  transition: opacity 0.2s;
}

.cd-hero__creator:hover {
  opacity: 0.85;
}

.cd-hero__avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.cd-hero__avatar--ph {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  font-size: 1.1rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

.cd-hero__creator-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cd-hero__creator-name {
  font-size: 0.95rem;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.cd-hero__dates {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ──────────────────────────────────────────
   7. DETAIL PAGE — Body & Sections
   ────────────────────────────────────────── */

.cd-body {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

.cd-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.cd-section:last-child {
  border-bottom: none;
}

.cd-section__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 14px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.cd-section__title--sm {
  font-size: 0.9rem;
}

.cd-section__count {
  font-size: 0.9em;
  color: var(--text-4);
  font-weight: 400;
}

/* ── Description (expandable) ── */

.cd-description__text {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-line;
}

.cd-description__text.is-clamped {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cd-description__toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 0;
  border: none;
  background: none;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.cd-description__toggle:hover {
  opacity: 0.75;
}

.cd-description__toggle svg {
  transition: transform 0.3s var(--ease);
}

.cd-description__toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

/* ── Rules ── */

.cd-rules {
  border-radius: 10px;
  overflow: hidden;
}

.cd-rules__summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--primary);
  list-style: none;
  transition: opacity 0.15s;
}

.cd-rules__summary::-webkit-details-marker {
  display: none;
}
.cd-rules__summary::marker {
  content: "";
}

.cd-rules__summary:hover {
  opacity: 0.75;
}

.cd-rules__content {
  padding: 0 0 8px;
}

.cd-rules__content p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-2, var(--text));
  margin: 0;
  white-space: pre-line;
}

/* ── Attachments ── */

.cd-attachments {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.cd-attachments::-webkit-scrollbar {
  display: none;
}

.cd-att {
  flex-shrink: 0;
  width: 140px;
  text-decoration: none;
  color: inherit;
  scroll-snap-align: start;
}

.cd-att__img-wrap {
  width: 140px;
  height: 140px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-subtle);
}

.cd-att__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s var(--ease);
}

.cd-att:hover .cd-att__img {
  transform: scale(1.05);
}

.cd-att__caption {
  display: block;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-3);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Book card ── */

.cd-book {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.cd-book__cover {
  width: 50px;
  height: 72px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.cd-book__info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  justify-content: center;
}

.cd-book__title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.cd-book__author {
  font-size: 0.82rem;
  color: var(--text-3);
}

.cd-book__page {
  font-size: 0.78rem;
  color: var(--text-4);
}

/* ── Entries grid ── */

.cd-entries {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.cd-entries--completed {
  grid-template-columns: repeat(2, 1fr);
}

.cd-entry {
  text-decoration: none;
  color: inherit;
}

.cd-entry__img-wrap {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-subtle);
}

.cd-entry__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s var(--ease);
}

.cd-entry:hover .cd-entry__img {
  transform: scale(1.04);
}

/* Likes badge */
.cd-entry__likes {
  position: absolute;
  top: 6px;
  right: 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
}

.cd-entry__likes svg {
  width: 11px;
  height: 11px;
  fill: #ff6b6b;
  stroke: none;
}

/* Name overlay */
.cd-entry__overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 8px 7px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
}

.cd-entry__name {
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* "+N more" card */
.cd-entry--more {
  cursor: default;
}

.cd-entry__more-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  border: 2px dashed var(--border);
}

.cd-entry__more-text {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-3);
}

/* ── Waiters ── */

.cd-waiters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cd-waiter {
  text-decoration: none;
}

.cd-waiter__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  transition:
    transform 0.15s,
    border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cd-waiter:hover .cd-waiter__avatar {
  transform: scale(1.1);
  border-color: var(--primary);
}

.cd-waiter__avatar--ph {
  background: var(--bg-subtle);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-3);
}

.cd-waiter__avatar--count {
  background: var(--bg-subtle);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-3);
  border-style: dashed;
}

/* ── Stats ── */

.cd-stats {
  display: flex;
  gap: 32px;
  justify-content: center;
}

.cd-stat {
  text-align: center;
}

.cd-stat__value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.cd-stat__label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-4);
  margin-top: 4px;
}

/* ── CTA App ── */

.cd-cta-app {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 24px;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.cd-cta-app__text {
  flex: 1;
  min-width: 0;
}

.cd-cta-app__title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
}

.cd-cta-app__desc {
  font-size: 0.82rem;
  color: var(--text-3);
  margin: 0;
  line-height: 1.4;
}

.cd-cta-app__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background 0.2s,
    transform 0.15s;
  flex-shrink: 0;
}

.cd-cta-app__btn:hover {
  background: var(--primary-hover, var(--primary));
  transform: translateY(-1px);
}

/* ══════════════════════════════════════════════════════════════════
   DARK THEME
   ══════════════════════════════════════════════════════════════════ */

html[data-theme="dark"] .collab-chip {
  background: #2c2520;
  color: #a09488;
}

html[data-theme="dark"] .collab-chip:hover {
  background: #3a3330;
  border-color: #4a423d;
  color: #d4ccc4;
}

html[data-theme="dark"] .collab-chip--active {
  background: rgba(196, 69, 54, 0.15);
  color: #e8584a;
  border-color: rgba(196, 69, 54, 0.2);
}

html[data-theme="dark"] .collab-sort__btn:hover {
  background: #2c2520;
}

html[data-theme="dark"] .collab-sort__btn--active {
  background: #2c2520;
  color: #d4ccc4;
}

html[data-theme="dark"] .collab-card {
  background: #1e1a16;
  border-color: #3a3330;
}

html[data-theme="dark"] .collab-card:hover {
  border-color: #4a423d;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] .collab-card__img--ph {
  background: #2c2520;
}

html[data-theme="dark"] .collab-card__avatar--ph {
  background: #2c2520;
  color: #8b7e74;
}

html[data-theme="dark"] .cd-hero__img--ph {
  background: #2c2520;
}

html[data-theme="dark"] .cd-book {
  background: #1e1a16;
  border-color: #3a3330;
}

html[data-theme="dark"] .cd-entry__more-wrap {
  background: #2c2520;
  border-color: #4a423d;
}

html[data-theme="dark"] .cd-waiter__avatar {
  border-color: #3a3330;
}

html[data-theme="dark"] .cd-waiter__avatar--ph {
  background: #2c2520;
  color: #8b7e74;
}

html[data-theme="dark"] .cd-waiter__avatar--count {
  background: #2c2520;
  color: #8b7e74;
}

html[data-theme="dark"] .cd-cta-app {
  background: #2c2520;
  border-color: #3a3330;
}

html[data-theme="dark"] .cd-rules__content p {
  color: #a09488;
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE (≤640px)
   ══════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  .collab-hero {
    padding: 28px 16px 16px;
  }

  .collab-hero__title {
    font-size: 1.4rem;
  }

  .collab-toolbar__inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 16px;
  }

  .collab-sort {
    justify-content: space-between;
  }

  .collab-list {
    padding: 16px 16px 40px;
  }

  .collab-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Detail hero */
  .cd-hero {
    min-height: 280px;
  }

  .cd-hero__title {
    font-size: 1.5rem;
  }

  .cd-hero__content {
    padding: 40px 16px 20px;
  }

  .cd-hero__avatar {
    width: 40px;
    height: 40px;
  }

  .cd-body {
    padding: 0 16px 40px;
  }

  .cd-entries {
    grid-template-columns: repeat(2, 1fr);
  }

  .cd-entries--completed {
    grid-template-columns: repeat(2, 1fr);
  }

  .cd-stats {
    gap: 20px;
  }

  .cd-cta-app {
    flex-direction: column;
    text-align: center;
    gap: 14px;
  }

  .cd-cta-app__btn {
    width: 100%;
    justify-content: center;
  }
}

/* ── Tablet (641–900px) ── */
@media (min-width: 641px) and (max-width: 900px) {
  .collab-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .cd-entries {
    grid-template-columns: repeat(3, 1fr);
  }
}
