/**
 * @file
 * SMA Editorial Recommendation Card Styles.
 * Supports:
 * - Variant 1: In-content Color Swatches with Ladder Tiles & Multi-Image Carousel.
 * - Variant 2: Floating Bottom Sheet (Висувна шторка) with 2x2 Photo Grid & Translucent Specs Widget.
 */

/* =========================================================
   Reset & Scope Isolation
   ========================================================= */

.cs-card,
.cs-card *,
.sheet-container,
.sheet-container * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.cs-card a,
.cs-card a:hover,
.cs-card a:focus,
.cs-card a:visited,
.sheet-container a,
.sheet-container a:hover,
.sheet-container a:focus,
.sheet-container a:visited {
  text-decoration: none !important;
  border-bottom: none !important;
  box-shadow: none !important;
  outline: none !important;
}

.cs-card p,
.sheet-container p {
  margin: 0 auto;
  padding: 0;
}

/* ==========================================================================
   ВАРІАНТ 1: ДРАБИНКА ТАЙЛІВ + КАРУСЕЛЬ (Вбудований у текст)
   ========================================================================== */

.sma-card-wrapper {
  position: relative;
  width: 100%;
  /*max-width: 680px;*/
  margin: 2.5rem 0;
  clear: both;
  opacity: 0;
  max-height: 0;
  transform: translateY(18px);
  transition:
    opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
    max-height 0.6s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
    margin 0.45s ease;
}

.sma-card-wrapper.sma-card--visible {
  opacity: 1;
  max-height: 1800px;
  transform: translateY(0);
}

.cs-card {
  position: relative;
  width: 100%;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 28px;
  padding: 38px 38px 0 38px;
  box-shadow: 
    0 20px 50px -12px rgba(15, 23, 42, 0.08),
    0 2px 6px rgba(15, 23, 42, 0.02);
  overflow: hidden;
}

.cs-header {
  margin-bottom: 22px;
}

.cs-title {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.25;
  color: #0f172a;
  margin-bottom: 10px;
  margin-left: auto;
  margin-right: auto;
  width: 90%;
}

.cs-title a {
  color: #0f172a !important;
  transition: color 0.2s ease;
}

.cs-title a:hover {
  color: #2563eb !important;
}

.cs-title-brand {
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline;
}

.cs-desc {
  font-size: 0.94rem;
  line-height: 1.6;
  color: #64748b;
  max-width: 90%;
}

.cs-stage {
  position: relative;
  width: 100%;
  height: 390px;
}

/* Ліва колонка плиток */
.cs-tiles-stack {
  position: absolute;
  top: 10px;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 5;
  pointer-events: none;
}

.cs-tile {
  pointer-events: auto;
  background: #ffffff;
  border: 1px solid #eef2f6;
  box-shadow: 
    0 12px 28px -4px rgba(15, 23, 42, 0.08),
    0 2px 6px rgba(15, 23, 42, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cs-tile:hover {
  transform: translateX(3px) scale(1.02);
  box-shadow: 0 16px 32px -4px rgba(15, 23, 42, 0.12);
}

.cs-tile--1 {
  width: 100px;
  height: 100px;
  border-radius: 22px;
  margin-left: 8px;
}

.cs-tile-val--1 {
  font-size: 1.95rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(135deg, #00f2fe 0%, #0072ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.cs-tile-val--1 span {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.cs-tile--2 {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  margin-left: 44px;
  flex-direction: column;
}

.cs-tile-val--2 {
  font-size: 1.65rem;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, #f72585 0%, #b5179e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.cs-tile-sub {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  color: #94a3b8;
  margin-top: 2px;
  letter-spacing: 0.05em;
}

.cs-tile--3 {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  margin-left: 18px;
}

.cs-tile-val--3 {
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.cs-circle-btn {
  pointer-events: auto;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #0f172a;
  color: #ffffff !important;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  margin-right: auto;
  box-shadow: 0 10px 22px -4px rgba(15, 23, 42, 0.28), 0 2px 6px rgba(15, 23, 42, 0.08);
  transition: background-color 0.25s ease, transform 0.2s ease;
  cursor: pointer;
}

.cs-circle-btn:hover {
  background: #2563eb !important;
  transform: translateX(2px);
}

.cs-circle-btn svg {
  width: 20px;
  height: 20px;
  stroke: #ffffff;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* Правий фрейм з каруселлю */
.cs-photo-frame {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 70%;
  height: 390px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-bottom: none;
  border-radius: 26px 26px 0 0;
  padding: 14px 14px 0 14px;
  box-shadow: 0 16px 36px -8px rgba(15, 23, 42, 0.06);
  z-index: 2;
}

.cs-photo-canvas {
  width: 100%;
  height: 100%;
  background: #ffffff;
  border-radius: 18px 18px 0 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.cs-carousel-track {
  position: relative;
  width: 100%;
  height: 100%;
}

.cs-photo-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.cs-photo-img.cs-slide--active {
  opacity: 1;
}

.cs-carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 8;
  opacity: 0;
  transition: all 0.2s;
  color: #0f172a;
}

.cs-carousel-arrow svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

.cs-carousel-prev { left: 8px; }
.cs-carousel-next { right: 8px; }

.cs-photo-frame:hover .cs-carousel-arrow {
  opacity: 1;
}

.cs-carousel-dots {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 5px;
  z-index: 8;
  background: rgba(15, 23, 42, 0.4);
  padding: 3px 8px;
  border-radius: 12px;
}

.cs-carousel-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
}

.cs-carousel-dot.active {
  background: #ffffff;
  transform: scale(1.3);
}

.cs-price-pill {
  position: absolute;
  top: 24px;
  right: -16px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 8px 18px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  gap: 9px;
  box-shadow: 0 12px 26px -4px rgba(15, 23, 42, 0.1);
  z-index: 10;
}

.cs-status-dot {
  width: 9px;
  height: 9px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.cs-price-text {
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.cs-iso-widget {
  position: absolute;
  bottom: 22px;
  left: -36px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 10px 16px 12px;
  border-radius: 18px;
  box-shadow: 0 16px 36px -6px rgba(15, 23, 42, 0.12);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.cs-iso-title {
  font-size: 11px;
  font-weight: 800;
  color: #334155;
}

.cs-iso-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cs-iso-opt {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  padding: 3px 6px;
  border-radius: 6px;
}

.cs-iso-opt--active {
  color: #ffffff;
  background: #0f172a;
  font-weight: 800;
}

/* ==========================================================================
   ВАРІАНТ 2: ВИСУВНА НИЖНЯ ШТОРКА (BOTTOM SHEET / FLOATING WIDGET)
   ========================================================================== */

/* Затемнення фону (Backdrop) */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.sheet-backdrop.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* Контейнер шторки (Bottom Sheet Container) */
.sheet-container {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(calc(100% - 68px));
  width: 100%;
  max-width: 640px;
  height: 90vh;
  max-height: 880px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  box-shadow: 
    0 -12px 36px rgba(15, 23, 42, 0.14),
    0 -2px 6px rgba(15, 23, 42, 0.04);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.sheet-container.sheet--ready {
  opacity: 1;
  pointer-events: auto;
}

/* Відкритий стан шторки */
.sheet-container.is-open {
  transform: translateX(-50%) translateY(0);
}

/* Шапка шторки (тизер у згорнутому / панель у розгорнутому) */
.sheet-header-bar {
  width: 100%;
  height: 68px;
  flex-shrink: 0;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  cursor: pointer;
  position: relative;
  user-select: none;
}

/* Смужка-індикатор для свайпу/витягування */
.sheet-drag-pill {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 38px;
  height: 4px;
  background: #cbd5e1;
  border-radius: 9999px;
}

/* Тизер у згорнутому стані */
.sheet-teaser {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 4px;
}

.sheet-teaser-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  margin-right: 12px;
  overflow: hidden;
}

.sheet-dot-green {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 0 2.5px rgba(16, 185, 129, 0.25);
  flex-shrink: 0;
}

.sheet-teaser-title {
  font-size: 13.5px;
  font-weight: 800;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
  max-width: 55%;
}

.sheet-teaser-badge {
  background: #ede9fe;
  color: #6366f1;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  flex-shrink: 1;
}

.sheet-teaser-action {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sheet-teaser-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #0f172a;
  color: #ffffff !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
  transition: background 0.2s, transform 0.2s;
}

.sheet-header-bar:hover .sheet-teaser-btn {
  background: #2563eb !important;
  transform: translateY(-2px);
}

/* Кнопка закриття ✕ (видима тільки у відкритому стані) */
.sheet-close-btn {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #475569;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sheet-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.sheet-container.is-open .sheet-teaser {
  display: none;
}

.sheet-container.is-open .sheet-close-btn {
  display: flex;
  margin-left: auto;
  margin-top: 4px;
}

/* Тіло шторки зі скролом */
.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px 36px 24px;
  -webkit-overflow-scrolling: touch;
}

/* Сцена всередині шторки */
.fuji-stage {
  position: relative;
  width: 100%;
  min-height: 420px;
  margin-bottom: 24px;
}

/* Ліва сітка фотографій 2x2 */
.fuji-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 56%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  z-index: 1;
}

.fuji-grid-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  overflow: hidden;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.05);
}

.fuji-grid-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Правий плаваючий віджет характеристик */
.fuji-widget {
  position: absolute;
  top: 0;
  right: 0;
  width: 54%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  padding: 20px 18px;
  box-shadow: 
    0 16px 36px -6px rgba(15, 23, 42, 0.1),
    0 2px 8px rgba(15, 23, 42, 0.04);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.fuji-widget-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
}

.fuji-badge-primary {
  background: #ede9fe;
  color: #6366f1;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  border-radius: 8px;
  line-height: 1.3;
}

.fuji-badge-secondary {
  background: #f1f5f9;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.fuji-sec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.fuji-sec-title {
  font-size: 12px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.fuji-sec-arrow {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 700;
}

.fuji-slider-sub {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 4px;
}

.fuji-slider-track {
  position: relative;
  width: 100%;
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  margin: 9px 0 7px;
}

.fuji-slider-fill {
  position: absolute;
  left: 20%;
  right: 25%;
  top: 0;
  bottom: 0;
  background: #00c6ff;
  border-radius: 2px;
}

.fuji-slider-handle {
  position: absolute;
  top: 50%;
  width: 11px;
  height: 11px;
  background: #00c6ff;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 198, 255, 0.5);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.fuji-handle--1 { left: 20%; }
.fuji-handle--2 { left: 75%; }

.fuji-slider-val {
  font-size: 11.5px;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  justify-content: space-between;
}

.fuji-slider-val span {
  color: #0284c7;
}

.fuji-divider {
  height: 1px;
  background: #f1f5f9;
}

.fuji-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.fuji-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: #475569;
}

.fuji-item-label {
  flex-shrink: 0;
  font-weight: 500;
}

.fuji-spec-badge {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #334155;
  text-align: right;
  line-height: 1.25;
}

.fuji-widget-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}

.fuji-price-val {
  font-size: 1.3rem;
  font-weight: 900;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.fuji-btn-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: #0f172a;
  color: #ffffff !important;
  border-radius: 50%;
  text-decoration: none !important;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
  transition: all 0.2s ease;
}

.fuji-btn-circle:hover {
  background: #2563eb !important;
  transform: translateX(2px);
}

.fuji-btn-circle svg {
  width: 16px;
  height: 16px;
  stroke: #ffffff;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.fuji-footer {
  margin-top: 4px;
}

.fuji-title {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.2;
  margin-bottom: 10px;
}

.fuji-title a {
  text-decoration: none !important;
  color: inherit !important;
}

.fuji-title-1 {
  background: linear-gradient(135deg, #00c6ff 0%, #0072ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-right: 6px;
}

.fuji-title-2 {
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-right: 6px;
}

.fuji-title-3 {
  background: linear-gradient(135deg, #f72585 0%, #b5179e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.fuji-desc {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #64748b;
  max-width: 90%;
}

/* ==========================================================================
   МОБІЛЬНА АДАПТАЦІЯ ДЛЯ ШТОРКИ ТА ВАРІАНТУ 1
   ========================================================================== */
@media (max-width: 640px) {
  /* Варіант 1 */
  .cs-card { padding: 26px 16px 0 16px; border-radius: 22px; }
  .cs-title { font-size: 1.45rem; }
  .cs-desc { font-size: 0.88rem; max-width: 100%; }
  .cs-stage { height: 330px; }
  .cs-photo-frame { width: 75%; height: 330px; padding: 8px 8px 0 8px; }
  .cs-tiles-stack { top: 6px; gap: 10px; }
  .cs-tile--1 { width: 70px; height: 70px; border-radius: 16px; margin-left: 2px; }
  .cs-tile-val--1 { font-size: 1.35rem; }
  .cs-tile--2 { width: 54px; height: 54px; border-radius: 14px; margin-left: 20px; }
  .cs-tile-val--2 { font-size: 1.2rem; }
  .cs-tile--3 { width: 44px; height: 44px; border-radius: 12px; margin-left: 6px; }
  .cs-tile-val--3 { font-size: 1.05rem; }
  .cs-circle-btn { width: 42px; height: 42px; margin-left: auto; margin-right: auto; }
  .cs-circle-btn svg { width: 17px; height: 17px; }
  .cs-price-pill { top: 14px; right: -10px; padding: 6px 12px; }
  .cs-price-text { font-size: 13px; }
  .cs-iso-widget { left: -22px; bottom: 16px; padding: 8px 10px; }

  /* Варіант 2 у шторці */
  .sheet-container {
    height: 92vh;
    max-height: 92vh;
    border-radius: 24px 24px 0 0;
  }

  .sheet-body {
    padding: 18px 16px 28px 16px;
  }

  .sheet-teaser-title {
    max-width: 50%;
    font-size: 12.5px;
  }

  .sheet-teaser-badge {
    max-width: 140px;
    font-size: 9.5px;
  }

  .fuji-stage {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: unset;
    margin-bottom: 20px;
  }

  .fuji-grid {
    position: relative;
    width: 100%;
    gap: 10px;
  }

  .fuji-grid-tile {
    border-radius: 14px;
  }

  .fuji-widget {
    position: relative;
    width: 100%;
    margin-top: -26px;
    padding: 18px 16px;
    border-radius: 20px;
  }

  .fuji-title {
    font-size: 1.65rem;
    line-height: 1.25;
  }

  .fuji-desc {
    font-size: 0.9rem;
    max-width: 100%;
  }
}

@media (max-width: 440px) {
  .sheet-teaser-title {
    max-width: 60%;
  }
  .sheet-teaser-badge {
    display: none; /* Приховуємо бейдж, якщо екран занадто вузький */
  }
}
