/* ==========================================================================
   css/conversacion.css
   Екранні та друковані стилі для Conversación
   ========================================================================== */

/* ==========================================================================
   0. Центрування контейнера
   ========================================================================== */
.conversacion-single {
  display: flex;
  justify-content: center;
}
.conversacion-single .container {
  flex: 0 1 auto;
  width: 90%;
  max-width: 1200px;
  margin: 2rem 0;
  background: #fff;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  box-sizing: border-box;
}

/* ==========================================================================
   1. ЕКРАННІ СТИЛІ
   ========================================================================== */

/* 1.1. Заголовок теми */
.conversacion-title {
  font-size: 2rem;
  font-weight: 700;
  color: #5a0f1b;
  margin: 0 0 0.5rem;
  text-align: center;
  position: relative;
}
.conversacion-title::after {
  content: "";
  display: block;
  width: 60px;
  height: 4px;
  background: #5a0f1b;
  margin: 0.25rem auto 0;
  border-radius: 2px;
}

/* 1.2. Кнопки друку */
.print-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 1.5rem 0;
}
.print-buttons button {
  background: #5a0f1b;
  color: #fff;
  border: none;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background .2s ease;
}
.print-buttons button:hover {
  background: #7a1f30;
}

/* 1.3. Адаптивна сітка карток */
.conversacion-grid {
  display: grid;
  gap: 1.5rem;
  /* від 1 до 4 колонок, мінімальна ширина картки 240px */
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* додатковий контроль */
@media (min-width: 1024px) {
  .conversacion-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (min-width: 1440px) {
  .conversacion-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* 1.4. Оформлення карток */
.topic-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem;
  text-align: center;
  transition: transform .2s ease, box-shadow .2s ease;
  /* дозвольте картці розтягуватись у сітці */
  width: 100%;
  max-width: none;
}
.topic-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}

/* 1.5. Іконка у картці */
.topic-card__icon {
  width: 40px;
  height: 40px;
  margin-bottom: 0.75rem;
}
.topic-card__icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 100;
}

/* 1.6. Текст питання */
.topic-card__body {
  flex: 1;
}
.topic-card__body p {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.4;
  color: #333;
}

/* ==========================================================================
   2. ДРУКОВАНІ СТИЛІ
   ========================================================================== */
@media print {
  /* 2.0. Приховання непотрібного */
  header, footer, .print-buttons, .no-print {
    display: none !important;
  }
  body {
    margin: 0;
    padding: 0.5cm;
    background: #fff !important;
    -webkit-print-color-adjust: exact;
  }
  .conversacion-single .container {
    padding: 0;
    box-shadow: none;
    background: transparent;
  }

  /* 2.1. Логотип зверху */
  .conversacion-single::before {
    content: "";
    display: block;
    width: 40px;
    height: 40px;
    margin: 0 auto 0.5cm;
    background: url('/wp-content/themes/astra-child/images/logo.png') center/contain no-repeat;
  }

  /* 2.2. Назва теми */
  .conversacion-title {
    font-size: 18pt;
    text-align: center;
    margin: 0 0 0.5cm;
    color: #5a0f1b;
  }
  .conversacion-title::after {
    display: none;
  }

  /* 2.3. СПИСОК (body.print-list) */
  body.print-list .conversacion-grid {
    counter-reset: question;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75cm;
    margin: 0;
    padding: 0;
  }
  body.print-list .topic-card {
    counter-increment: question;
    display: flex;
    align-items: flex-start;
    background: #fafafa;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.75cm;
    page-break-inside: avoid;
    position: relative;
  }
  body.print-list .topic-card__icon {
    display: none;
  }
  body.print-list .topic-card__body {
    flex: 1;
    padding-left: 1.5em;
    position: relative;
  }
  body.print-list .topic-card__body::before {
    content: counter(question) ".";
    position: absolute;
    left: 0;
    top: 0;
    font-weight: 700;
    color: #5a0f1b;
  }
  body.print-list .topic-card__body p {
    margin: 0;
    font-size: 12pt;
    line-height: 1.4;
    color: #333;
    text-align: left;
  }

  /* 2.4. КАРТКИ (body.print-cards) */
  @page {
    size: A4 landscape;
    margin: 1cm;
  }
  body.print-cards .conversacion-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75cm;
  }
  body.print-cards .topic-card {
    background: #fafafa;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 0.75cm;
    box-shadow: none;
    page-break-inside: avoid;
    aspect-ratio: 4 / 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  body.print-cards .topic-card__icon {
    width: 48px;
    height: 48px;
    margin-bottom: 0.5rem;
  }
  body.print-cards .topic-card__icon img {
    width: 100%;
    height: 100%;
    opacity: 100;
  }
  body.print-cards .topic-card__body p {
    font-size: 12pt;
    text-align: center;
    margin: 0;
  }

  /* 2.5. Футер і номер сторінки */
  body::after {
    content: "espamilka.com  |  " counter(page) " / " counter(pages);
    position: fixed;
    bottom: 0.5cm;
    width: 100%;
    text-align: center;
    font-size: 9pt;
    color: #999;
  }
}
