/* Раскраски — визуально в духе transport-category (отдельные классы coloring-*) */

.coloring-page {
  min-height: 100vh;
  background: linear-gradient(180deg, var(--warm-white, #f8f6f0) 0%, #eef3f9 100%);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  box-sizing: border-box;
}

.coloring-header {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
  gap: 8px;
  padding: 12px calc(14px + env(safe-area-inset-right)) 8px calc(14px + env(safe-area-inset-left));
  position: sticky;
  top: 0;
  z-index: 4;
  background: rgba(248, 246, 240, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(181, 111, 216, 0.15);
}

.coloring-header--tight {
  padding-top: 8px;
}

.coloring-header__btn {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 14px;
  background: #fff;
  font-size: 22px;
  line-height: 1;
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.06));
  cursor: pointer;
}

.coloring-header__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.01em;
  color: var(--text-strong, #2d2d2d);
}

.coloring-header__title--narrow {
  font-size: clamp(0.92rem, 3.8vw, 1.05rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.coloring-header__spacer {
  display: block;
  width: 48px;
  height: 48px;
}

.coloring-header__title-stack {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

/* Фото героя — главная экрана «Раскраски» */
.coloring-home__hero {
  max-width: 720px;
  margin: 10px auto 16px;
  padding: 12px 16px 14px;
  box-sizing: border-box;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 0 0 1px rgba(181, 111, 216, 0.12);
}

.coloring-home__hero-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 800;
  color: #4a1f6b;
  text-align: center;
}

.coloring-home__hero-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.coloring-home__hero-upload {
  min-height: 46px;
  padding: 10px 20px;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
  background: linear-gradient(135deg, rgba(232, 165, 255, 0.42), rgba(181, 111, 216, 0.28));
  color: #4a1f6b;
  box-shadow: 0 2px 10px rgba(155, 79, 196, 0.12);
  -webkit-tap-highlight-color: transparent;
}

.coloring-home__hero-upload:active {
  transform: scale(0.97);
}

.coloring-home__hero-preview {
  display: none;
  align-items: center;
  gap: 12px;
}

.coloring-home__hero-preview--visible {
  display: flex;
}

.coloring-home__hero-thumb-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

.coloring-home__hero-thumb {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 3px solid rgba(155, 79, 196, 0.35);
  background: #f0eaf8;
}

.coloring-home__hero-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(230, 60, 60, 0.95);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.coloring-home__hero-hint {
  margin: 12px 0 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted, #6b6b6b);
  text-align: center;
  line-height: 1.4;
  padding: 0 4px;
}

.coloring-home__chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 16px 12px;
  max-width: 900px;
  margin: 0 auto;
}

.coloring-chip {
  border: 2px solid rgba(181, 111, 216, 0.28);
  background: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.coloring-chip--on {
  background: rgba(181, 111, 216, 0.16);
  border-color: #9b4fc4;
  color: #4a1f6b;
}

.coloring-home__gallery {
  padding: 8px 12px 32px;
  max-width: 900px;
  margin: 0 auto;
}

.coloring-loading,
.coloring-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted, #6b6b6b);
  font-size: 0.95rem;
  line-height: 1.45;
}

.coloring-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

@media (orientation: landscape) and (min-width: 700px) {
  .coloring-gallery-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 380px) {
  .coloring-gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.coloring-gallery-tile {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  text-align: center;
}

.coloring-gallery-thumb-wrap {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: #ede6f5;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.coloring-gallery-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.coloring-gallery-thumb-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 2rem;
}

.coloring-tile-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 1rem;
  line-height: 1;
}

.coloring-gallery-caption {
  margin-top: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.28;
  color: #333;
  max-height: 2.56em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* Карточка одной раскраски */

.coloring-item .coloring-item__hero {
  margin: 12px auto 16px;
  padding: 0 14px;
  max-width: 720px;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow-md, 0 4px 16px rgba(0, 0, 0, 0.08));
}

.coloring-item__hero img {
  width: 100%;
  height: auto;
  display: block;
}

.coloring-desc-label {
  display: block;
  max-width: 720px;
  margin: 0 auto 6px;
  padding: 0 18px;
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--text-strong, #2d2d2d);
}

.coloring-desc-input {
  display: block;
  width: calc(100% - 36px);
  max-width: 684px;
  margin: 0 auto 16px;
  padding: 12px 14px;
  min-height: 96px;
  border-radius: 14px;
  border: 2px solid rgba(181, 111, 216, 0.2);
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
  box-sizing: border-box;
  background: #fff;
}

.coloring-item__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 0 16px 12px;
  max-width: 720px;
  margin: 0 auto;
}

.coloring-action-btn {
  flex: 1 1 auto;
  min-height: 48px;
  min-width: 140px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(232, 165, 255, 0.35), rgba(181, 111, 216, 0.25));
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(155, 79, 196, 0.15);
}

.coloring-action-btn--danger {
  background: rgba(242, 85, 85, 0.12);
  color: #c62828;
  box-shadow: none;
}

.coloring-action-btn--print {
  background: #10b981 !important;
  color: #fff !important;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

.coloring-action-btn--print:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  filter: saturate(0.65);
}

.coloring-orig-link {
  display: block;
  margin: 8px auto 24px;
  padding: 8px;
  border: none;
  background: none;
  color: var(--muted, #6b6b6b);
  text-decoration: underline;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
}

/* Галерея + FAB «Создать» */
.coloring-home__gallery-wrap {
  position: relative;
  padding-bottom: 96px;
}

.coloring-fab {
  position: fixed;
  z-index: 6;
  bottom: calc(20px + env(safe-area-inset-bottom));
  right: calc(14px + env(safe-area-inset-right));
  min-height: 48px;
  padding: 12px 18px;
  border: none;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
  font-family: inherit;
  background: linear-gradient(135deg, #e8a5ff 0%, #b56fd8 55%, #8f4fbb 100%);
  color: #fff;
  box-shadow: 0 6px 22px rgba(155, 79, 196, 0.35);
  -webkit-tap-highlight-color: transparent;
}

.coloring-fab:active {
  transform: scale(0.97);
}

.coloring-empty--hero {
  text-align: center;
  padding: 32px 18px 24px;
}

.coloring-empty__hero-title {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.4;
  margin: 0 0 18px;
  color: var(--text-strong, #2d2d2d);
}

.coloring-empty__cta {
  min-height: 52px;
  padding: 12px 22px;
  border: none;
  border-radius: 16px;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  background: rgba(181, 111, 216, 0.2);
  border: 2px solid rgba(155, 79, 196, 0.5);
  color: #4a1f6b;
}

/* ——— Печать раскраски (A5): только при body.is-printing (клик «Распечатать») ——— */

@page {
  size: A5;
  margin: 8mm;
}

@media print {
  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  html:has(body.is-printing),
  body.is-printing {
    background: #fff !important;
    background-image: none !important;
    min-height: 0 !important;
    height: auto !important;
  }

  /* Декоративный gradient в main.css (body::after) — не в #app; в PDF давал синюю полосу снизу */
  body.is-printing::after {
    display: none !important;
    content: none !important;
    visibility: hidden !important;
    height: 0 !important;
    background: none !important;
    background-image: none !important;
  }

  body.is-printing #status-bar,
  body.is-printing #quick-bar-container,
  body.is-printing #reward-root {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
  }

  /* Убрать фон приложения и градиент страницы (типичный источник «цветной полосы» в PDF). */
  body.is-printing #app,
  body.is-printing #app > *,
  body.is-printing .coloring-page,
  body.is-printing .coloring-item {
    background: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
  }

  body.is-printing #app {
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  body.is-printing .coloring-page {
    min-height: 0 !important;
    padding-bottom: 0 !important;
  }

  /*
   Не использовать «#app * { visibility:hidden } + .print-target visible» —
   Blink/WebKit при печати/PDF часто дают полностью пустую страницу.
   Достаточно скрыть блоки через display:none (герой уже отдельно).
  */

  body.is-printing .coloring-item > *:not(.coloring-item__hero) {
    display: none !important;
  }

  body.is-printing #coloring-pswp-root {
    display: none !important;
  }

  body.is-printing .coloring-item__hero {
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 auto !important;
    max-width: none !important;
    width: 100% !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  body.is-printing .print-target.printable-coloring {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    page-break-inside: avoid;
  }

  body.is-printing .print-target img {
    max-width: 100%;
    max-height: none;
    width: auto;
    height: auto;
    object-fit: contain;
    box-shadow: none !important;
    border: none !important;
    background: white !important;
  }
}
