/* static/custom/css/card.css */

/* =========================
   SOCpedia — unified card + pills + avatars + divider
   CLEAN edition (books + posts)
   ========================= */

:root{
  --sp-primary: var(--ar-primary, #448c74);
}

/* =========================
   CARD (books + posts)
   ========================= */

.sp-book-card,
.sp-post-card{
  position: relative;
  height: 100%;
  border-radius: 20px;
  overflow: hidden;

  /* чтобы футер прижимался вниз */
  display: flex;
  flex-direction: column;

  background: #fff;
  border: 1px solid rgba(0,0,0,.10);
  box-shadow: 0 12px 30px rgba(0,0,0,.08);

  transition: transform .18s ease,
              box-shadow .18s ease,
              border-color .18s ease,
              background-color .18s ease;
}

.sp-book-card:hover,
.sp-post-card:hover{
  transform: translateY(-3px);
  border-color: rgba(68,140,116,.55);
  box-shadow: 0 18px 44px rgba(0,0,0,.12);
}

/* верхняя “SOCpedia” линия */
.sp-book-card::before,
.sp-post-card::before{
  content:"";
  position:absolute;
  inset:0 0 auto 0;
  height:2px;
  background: linear-gradient(90deg, transparent, var(--sp-primary), transparent);
  opacity:.55;
  pointer-events:none;
}

/* стабилизация внутренних блоков */
.sp-book-card > *,
.sp-post-card > *{
  flex: 0 0 auto;
}

/* footer wrapper pinned */
.sp-card-footer{
  margin-top: auto;
}

/* мягкая подсветка верхней зоны (используется JS в books) */
.sp-book-card.is-top-zone,
.sp-post-card.is-top-zone{
  outline: 1px solid rgba(68,140,116,.22);
  outline-offset: 2px;
}

/* =========================
   TEXT (books)
   ========================= */

.sp-meta{
  color: rgba(0,0,0,.55);
  font-size: .9rem;
}

.sp-book-title{
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
  margin:0;
  color: rgba(0,0,0,.88);
}

.sp-book-short{
  display:-webkit-box;
  -webkit-line-clamp:3;
  -webkit-box-orient:vertical;
  overflow:hidden;
  word-break:break-word;
  overflow-wrap:anywhere;
  color: rgba(0,0,0,.62);
}

/* =========================
   DIVIDER (stable)
   ========================= */
/* 2px + scaleY(.5) => визуально 1px, рендер стабильный */
.sp-divider{
  position: relative;
  margin: .75rem 1.25rem;
  height: 2px;
  background: transparent;
  z-index: 1;
}

.sp-divider::after{
  content:"";
  position:absolute;
  inset:0;
  background: var(--sp-primary);
  opacity: .65;
  transform: scaleY(.5);
  transform-origin: center;
  border-radius: 2px;
}

/* =========================
   PILLS (unified)
   ========================= */

.sp-badges{
  display:flex;
  flex-wrap:wrap;
  gap:.4rem;
  align-items:center;
}

.sp-ai-badges{
  display:inline-flex;
  align-items:center;
  gap:.25rem;
  vertical-align:middle;
}

.sp-ai-badge{
  position:relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:.15rem;
  min-width:1.55rem;
  height:1.35rem;
  padding:0 .28rem;
  border-radius:999px;
  border:1px solid rgba(68,140,116,.48);
  background:rgba(68,140,116,.10);
  color:rgba(18,60,50,.95);
  font-size:.68rem;
  font-weight:700;
  line-height:1;
  cursor:help;
  overflow:visible;
}

.sp-ai-badge--translated{
  border-color:rgba(13,110,253,.48);
  background:rgba(13,110,253,.10);
  color:rgba(8,68,140,.95);
}

.sp-ai-badge i{
  font-size:.78rem;
}

.sp-ai-badge-label{
  font-size:.56rem;
  letter-spacing:0;
}

.sp-ai-badge::before,
.sp-ai-badge::after{
  position:absolute;
  left:50%;
  z-index:1080;
  pointer-events:none;
  opacity:0;
  visibility:hidden;
  transition:opacity .15s ease, transform .15s ease, visibility .15s ease;
}

.sp-ai-badge::before{
  content:attr(data-ai-hint);
  bottom:calc(100% + .55rem);
  width:max-content;
  max-width:min(24rem, 80vw);
  padding:.65rem .8rem;
  transform:translate(-50%, .2rem);
  border:1px solid rgba(255,255,255,.12);
  border-radius:.45rem;
  background:rgba(18,22,28,.97);
  box-shadow:0 .45rem 1rem rgba(0,0,0,.22);
  color:#fff;
  font-size:.72rem;
  font-weight:600;
  line-height:1.35;
  text-align:left;
  white-space:normal;
}

.sp-ai-badge::after{
  content:"";
  bottom:calc(100% + .2rem);
  transform:translate(-50%, .2rem);
  border:.36rem solid transparent;
  border-top-color:rgba(18,22,28,.97);
}

.sp-ai-badge:hover::before,
.sp-ai-badge:hover::after,
.sp-ai-badge:focus-visible::before,
.sp-ai-badge:focus-visible::after{
  opacity:1;
  visibility:visible;
  transform:translate(-50%, 0);
}

.tooltip,
.socpedia-tooltip {
  --ar-tooltip-max-width: 24rem;
  --ar-tooltip-bg: rgba(18, 22, 28, .97);
  --ar-tooltip-color: #fff;
  --ar-tooltip-opacity: 1;
  --ar-tooltip-padding-x: .8rem;
  --ar-tooltip-padding-y: .65rem;
  --ar-tooltip-border-radius: .45rem;
  --bs-tooltip-max-width: 24rem;
  --bs-tooltip-bg: rgba(18, 22, 28, .97);
  --bs-tooltip-color: #fff;
  --bs-tooltip-opacity: 1;
}

.tooltip .tooltip-inner,
.socpedia-tooltip .tooltip-inner {
  background-color: rgba(18, 22, 28, .97);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: .45rem;
  color: #fff;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  box-shadow: 0 .45rem 1rem rgba(0, 0, 0, .22);
}

/* base pill */
.sp-pill{
  display:inline-flex;
  align-items:center;
  gap:.35rem;

  padding:.28rem .62rem;
  border-radius:999px;

  font-size:.78rem;
  font-weight:600;
  line-height:1;

  white-space:nowrap;
  text-decoration:none;

  border:1px solid rgba(68,140,116,.35);
  background: rgba(68,140,116,.06);
  color: rgba(0,0,0,.72);

  transition:
    background-color .15s ease,
    border-color .15s ease,
    color .15s ease,
    box-shadow .15s ease,
    transform .12s ease,
    filter .12s ease;
}

/* icons inside pill */
.sp-pill .sp-ico{
  line-height: 1;
  opacity: .85;
  font-size: .95em;
}

/* clickable pills */
a.sp-pill,
button.sp-pill{
  cursor: pointer;
  text-decoration: none;
}

/* soft + primary variants */
.sp-pill--soft{
  border-color: rgba(68,140,116,.35);
  background: rgba(68,140,116,.06);
  color: rgba(0,0,0,.70);
}

.sp-pill--primary{
  border-color: rgba(68,140,116,.65);
  background: rgba(68,140,116,.18);
  color: rgba(18,60,50,.95);
}

/* hover (НЕ для активных) */
a.sp-pill:not(.sp-pill--active):not(.is-active):hover,
button.sp-pill:not(.sp-pill--active):not(.is-active):hover{
  border-color: rgba(68,140,116,.60);
  background: rgba(68,140,116,.12);
  color: rgba(18,60,50,.92);
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px rgba(68,140,116,.12);
}

/* ACTIVE (filter applied) — full primary
   поддержка: .sp-pill--active (старое) и .is-active (текущее в posts) */
a.sp-pill--active,
button.sp-pill--active,
a.sp-pill.is-active,
button.sp-pill.is-active{
  background: var(--ar-primary, #448c74);
  border-color: var(--ar-primary, #448c74);
  color: #fff !important;
  box-shadow: none;
}

/* active hover */
a.sp-pill--active:hover,
button.sp-pill--active:hover,
a.sp-pill.is-active:hover,
button.sp-pill.is-active:hover{
  filter: brightness(1.04);
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px rgba(68,140,116,.22);
}

/* =========================
   AVATARS + TOOLTIP (SOCpedia style)
   ========================= */

.sp-author{
  display:flex;
  align-items:center;
  gap:.55rem;
  min-width:0;
  max-width:100%;
}

.sp-avatar-btn{
  border: 0;
  padding: 0;
  background: transparent;
  line-height: 0;
  cursor: pointer;
}

/* avatar pill */
.sp-avatar{
  position: relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;

  width:40px;
  height:40px;
  padding:2px;
  border-radius:999px;

  border:1px solid rgba(68,140,116,.40);
  background: rgba(68,140,116,.06);

  transition:border-color .15s ease,
             box-shadow .15s ease,
             transform .15s ease;
}

.sp-avatar img{
  width:100%;
  height:100%;
  border-radius:999px;
  object-fit:cover;
  border:1px solid rgba(0,0,0,.08);
  background:#fff;
}

.sp-avatar:hover{
  border-color: rgba(68,140,116,.75);
  box-shadow: 0 0 0 3px rgba(68,140,116,.22);
  transform: translateY(-1px);
  z-index:5;
}

.sp-coauthors{
  display:flex;
  margin-left:.15rem;
}

.sp-avatar--stacked{
  margin-left:-10px;
  z-index:1;
}

.sp-avatar--stacked:hover{
  z-index:6;
}

/* =========================
   AVATAR TOOLTIP — inside card, no overflow
   ========================= */

.sp-avatar[data-tooltip]::after,
.sp-avatars[data-tooltip]::after{
  content: attr(data-tooltip);
  position:absolute;

  left: 0;
  bottom: calc(100% + 8px);

  padding: .32rem .65rem;
  border-radius: 10px;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.2;

  width: max-content;
  max-width: min(12rem, calc(100vw - 2rem));
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: left;
  pointer-events: none;

  color: rgba(255,255,255,.92);
  background: rgba(20,23,27,.92);
  border: 1px solid rgba(68,140,116,.35);
  box-shadow: 0 10px 26px rgba(0,0,0,.35);

  opacity: 0;
  transform: translateY(6px);
  transition: opacity .15s ease, transform .15s ease;
  z-index: 20;
}

.sp-avatar:hover::after,
.sp-avatars:hover::after{
  opacity: 1;
  transform: translateY(0);
}

/* Dark theme tweak (чуть сильнее тень для читаемости) */
[data-bs-theme="dark"] .sp-avatar[data-tooltip]::after,
[data-bs-theme="dark"] .sp-avatars[data-tooltip]::after,
[data-theme="dark"] .sp-avatar[data-tooltip]::after,
[data-theme="dark"] .sp-avatars[data-tooltip]::after{
  box-shadow:
    0 8px 22px rgba(0,0,0,.45),
    0 0 0 2px rgba(68,140,116,.35);
}

/* =========================
   AUTHORS LIST (large avatars)
   ========================= */

.sp-authors__list{
  display:flex;
  flex-wrap:wrap;
  gap:14px;
}

.sp-authors{
  display:flex;
  align-items:center;
  gap:.55rem;
  min-width:0;
  max-width:100%;
}

.sp-authors__name{
  display:block;
  min-width:0;
  max-width:min(18rem, 100%);
  overflow:hidden;
  font-size:14px;
  line-height:1.2;
  white-space:nowrap;
  text-overflow:ellipsis;
}

.sp-author > .sp-authors__name{
  max-width:min(22rem, calc(100% - 4.5rem));
}

.sp-avatars-btn{
  border:0;
  padding:0;
  background:transparent;
  line-height:0;
  cursor:pointer;
}

.sp-avatars{
  position: relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;

  width:64px;
  height:64px;
  padding:2px;
  border-radius:999px;

  border:1px solid rgba(68,140,116,.40);
  background: rgba(68,140,116,.06);

  transition:border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.sp-avatars img{
  width:100%;
  height:100%;
  border-radius:999px;
  object-fit:cover;
  border:1px solid rgba(0,0,0,.08);
  background:#fff;
}

.sp-avatars:hover{
  border-color: rgba(68,140,116,.75);
  box-shadow: 0 0 0 3px rgba(68,140,116,.22);
  transform: translateY(-1px);
  z-index:5;
}

/* size variants */
.sp-avatars--lg{
  width:104px;
  height:104px;
  padding:3px;
}

.sp-avatars--stacked{ margin-left:-10px; z-index:1; }
.sp-avatars--stacked:hover{ z-index:6; }

/* =========================
   POSTS: image + footer alignment
   ========================= */

/* body растягивается -> footer всегда внизу */
.sp-post-body{
  flex: 1 1 auto;
  min-height: 0;
}

/* картинка не должна иметь собственный радиус/рамку — card режет её сама */
.sp-post-img,
.sp-book-card .card-img-top{
  border-radius: 0 !important;
  display: block;
  width: 100%;
  height: auto;
}

/* убрать дефолтную серую линию bootstrap footer */
.sp-book-card .card-footer,
.sp-post-card .card-footer{
  border-top: 0 !important;
  background: transparent;
}

/* =========================
   DARK THEME
   ========================= */

[data-bs-theme="dark"] .sp-book-card,
[data-theme="dark"] .sp-book-card,
[data-bs-theme="dark"] .sp-post-card,
[data-theme="dark"] .sp-post-card{
  background: rgba(20,23,27,.92);
  border-color: rgba(255,255,255,.10);
  box-shadow: 0 18px 44px rgba(0,0,0,.45);
}

[data-bs-theme="dark"] .sp-meta,
[data-theme="dark"] .sp-meta{
  color: rgba(255,255,255,.60);
}

[data-bs-theme="dark"] .sp-book-title,
[data-theme="dark"] .sp-book-title{
  color: rgba(255,255,255,.92);
}

[data-bs-theme="dark"] .sp-book-short,
[data-theme="dark"] .sp-book-short{
  color: rgba(255,255,255,.68);
}

[data-bs-theme="dark"] .sp-divider::after,
[data-theme="dark"] .sp-divider::after{
  opacity: .85;
}

.sp-reset-badge{
  --bs-badge-color: #1f2933;
  border: 1px solid rgba(108,117,125,.35);
  background-color: rgba(108,117,125,.18);
  color: var(--bs-badge-color);
}

a.sp-reset-badge:hover{
  --bs-badge-color: #111417;
  border-color: rgba(108,117,125,.55);
  background-color: rgba(108,117,125,.28);
  color: var(--bs-badge-color);
}

[data-bs-theme="dark"] .sp-reset-badge,
[data-theme="dark"] .sp-reset-badge{
  --bs-badge-color: rgba(255,255,255,.88);
  border-color: rgba(255,255,255,.26);
  background-color: rgba(255,255,255,.10);
  color: var(--bs-badge-color);
}

[data-bs-theme="dark"] a.sp-reset-badge:hover,
[data-theme="dark"] a.sp-reset-badge:hover{
  --bs-badge-color: #fff;
  border-color: rgba(255,255,255,.42);
  background-color: rgba(255,255,255,.16);
  color: var(--bs-badge-color);
}

/* pills in dark: keep primary-ish border + white text (FIX) */
[data-bs-theme="dark"] .sp-pill,
[data-theme="dark"] .sp-pill{
  color: rgba(255,255,255,.88);
  border-color: rgba(68,140,116,.45);
  background: rgba(68,140,116,.10);
}

[data-bs-theme="dark"] a.sp-pill:not(.sp-pill--active):not(.is-active):hover,
[data-theme="dark"] a.sp-pill:not(.sp-pill--active):not(.is-active):hover{
  background: rgba(68,140,116,.18);
  border-color: rgba(68,140,116,.75);
  color: rgba(255,255,255,.96);
  box-shadow: 0 0 0 2px rgba(68,140,116,.18);
}

[data-bs-theme="dark"] .sp-pill--primary,
[data-theme="dark"] .sp-pill--primary{
  border-color: rgba(68,140,116,.70);
  background: rgba(68,140,116,.20);
  color: rgba(255,255,255,.92);
}

[data-bs-theme="dark"] .sp-ai-badge,
[data-theme="dark"] .sp-ai-badge{
  border-color:rgba(69,210,158,.48);
  background:rgba(69,210,158,.12);
  color:rgba(238,255,249,.95);
}

[data-bs-theme="dark"] .sp-ai-badge--translated,
[data-theme="dark"] .sp-ai-badge--translated{
  border-color:rgba(111,168,255,.55);
  background:rgba(111,168,255,.13);
  color:rgba(236,244,255,.96);
}

[data-bs-theme="dark"] .sp-avatar img,
[data-theme="dark"] .sp-avatar img,
[data-bs-theme="dark"] .sp-avatars img,
[data-theme="dark"] .sp-avatars img{
  border-color: rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
}
