/* ====== Обёртка ====== */
.taro-wrap {
    max-width: 860px;
    margin: 0 auto;
    padding: 20px 15px 60px;
    box-sizing: border-box;
    font-family: 'EB Garamond', Georgia, serif;
    color: #4a3828;
    -webkit-tap-highlight-color: transparent;
}

/* ====== Сцена с подложкой и слотами ====== */
.taro-stage {
    position: relative;
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
    text-align: center;
}
/* Узкие/высокие подложки на экранах шире мобильника сжимаются до 300px.
 * Мобильным считаем экран ≤440px — там подложка занимает почти всю ширину
 * и ужимать её не надо. Всё что шире — планшеты, десктоп — ужимаем.
 * Включается через 'narrow' => true в конфиге расклада. */
@media (min-width: 441px) {
    .taro-stage--narrow {
        max-width: 300px;
    }
}
.taro-stage__bg {
    display: block;
    width: 100%;
    height: auto;
}

/* Слоты для выпадающих карт. Координаты (left/top/width) приходят inline
 * из PHP-конфига расклада — они уникальны для каждого расклада. */
.taro-slot {
    position: absolute;
    aspect-ratio: 5 / 8.5;
    perspective: 1000px;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transform: translateY(-400px) scale(0.5) rotate(15deg);
}
.taro-slot.landed {
    opacity: 1 !important;
    transform: translateY(0) scale(1) rotate(0deg) !important;
    transition: all 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
.taro-slot.settled,
.taro-slot.settled .taro-slot__inner {
    transition: none !important;
}
.taro-slot__inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}
.taro-slot__inner.flipped {
    transform: rotateY(180deg);
}
.taro-slot__face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 6px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}
.taro-slot__front {
    transform: rotateY(180deg);
}

/* ====== Кнопка ====== */
.taro-knopka {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 235px;
    height: 65px;
    margin: 10px auto 0;
    background-color: #f1e7d4;
    background-image: url('../img/buttons/knopka.webp');
    background-size: cover;
    background-position: center;
    color: #4a3828;
    font-size: 17px;
    font-weight: 400;
    font-family: 'EB Garamond', 'Georgia', serif;
    border: none;
    border-radius: 0;
    padding: 0 0 4px 0;
    outline: none;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}
.taro-knopka:hover { transform: scale(1.03); }
.taro-knopka:active {
    background-image: url('../img/buttons/knopka-active.webp');
    transform: translateY(2px);
}

/* ====== Зарезервированная зона для формы → веера ======
 * Чтобы при смене формы на веер страница не прыгала. */
.taro-interaction {
    min-height: 300px;
    position: relative;
}
@media (min-width: 769px) {
    .taro-interaction { min-height: 250px; }
}
@media (max-width: 440px) {
    .taro-interaction { min-height: 240px; }
}

/* ====== Форма вопроса ====== */
.taro-question-block {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
    padding: 20px 0;
}
.taro-question-block__label {
    display: flex;
    align-items: center;
    gap: 1px;
    margin-bottom: 16px;
    font-size: 18px;
    font-style: italic;
}
.taro-question-block__label::before,
.taro-question-block__label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, #c9b99a, transparent);
}
.taro-question-block__label span {
    padding: 0 12px;
    white-space: nowrap;
}
.taro-question-block__input-wrap {
    width: 100%;
    margin-bottom: 20px;
}
.taro-question-block__input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid #c9b99a;
    border-radius: 0;
    outline: none;
    box-sizing: border-box;
    line-height: 1.5;
    font-size: 16px;
    font-family: inherit;
    padding: 8px 0;
    text-align: center;
    color: #4a3828;
    transition: border-color 0.3s;
    resize: none;
    overflow: hidden;
    min-height: 32px;
}
.taro-question-block__input:focus {
    border-bottom-color: #8b7355;
}
.taro-question-block__input::placeholder {
    color: #b8a88a;
}
@keyframes taroWobble {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-8px); }
    30% { transform: translateX(6px); }
    45% { transform: translateX(-4px); }
    60% { transform: translateX(2px); }
    75% { transform: translateX(-1px); }
}
.taro-question-block__input.wobble {
    animation: taroWobble 0.6s ease-in-out;
    border-bottom-color: #e67e22 !important;
}
.taro-question-block__hint {
    font-size: 14px;
    color: #a09080;
    margin-top: 8px;
    min-height: 20px;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.4s, transform 0.4s;
    font-style: italic;
    text-align: center;
}
.taro-question-block__hint.show {
    opacity: 1;
    transform: translateY(0);
}

/* ====== Веер ====== */
.taro-fan-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    position: relative;
    z-index: 5;
    padding-top: 20px;
    padding-bottom: 220px;
}
.taro-fan {
    position: relative;
    height: 10px;
    width: 0;
    margin-top: 10px;
}
.taro-fan-hint {
    text-align: center;
    font-size: 15px;
    color: #6b5540;
    font-style: italic;
    margin-top: 20px;
}
.taro-fan-counter {
    text-align: center;
    font-size: 15px;
    color: #4a3828;
    margin-top: 4px;
}
.taro-card {
    position: absolute;
    width: 78px;
    height: 128px;
    left: -39px;
    top: 0;
    transform-origin: center bottom;
    opacity: 0;
    transition: transform 0.6s ease, opacity 0.6s ease;
    cursor: pointer;
    perspective: 800px;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}
.taro-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.3s ease;
}
.taro-card:focus-visible .taro-card-inner {
    transform: translateY(-11px);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.5), 0 0 0 2px #8b7355;
}
@media (hover: hover) and (pointer: fine) {
    .taro-card:hover .taro-card-inner {
        transform: translateY(-11px);
        box-shadow: 0 12px 20px rgba(0, 0, 0, 0.5);
        transition: transform 0.3s ease, box-shadow 0.3s ease;
    }
}
@media (hover: none) and (pointer: coarse) {
    .taro-card:active .taro-card-inner {
        opacity: 0.9;
    }
}
.taro-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background-size: cover;
    background-repeat: no-repeat;
    border-radius: 7px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.taro-front {
    transform: rotateY(180deg);
}

@media (max-width: 768px) {
    .taro-card { width: 68px; height: 111px; left: -34px; }
}
@media (max-width: 390px) {
    .taro-card { width: 57px; height: 93px; left: -28.5px; }
}
@media (max-width: 320px) {
    .taro-card { width: 51px; height: 83px; left: -25.5px; }
}

/* ====== Результат гадания (4 блока: позиция + миниатюра + текст) ====== */
/* Контейнер всех блоков — на десктопе декоративная подложка-карточка. */
.taro-wrap .taro-answer {
    display: none;
    max-width: 820px;
    margin: 30px auto 0;
    padding: 0;
    color: #4a3828;
    background: none;
    border: none;
    border-left: none;
    box-shadow: none;
    quotes: none;
}
.taro-wrap .taro-answer::before,
.taro-wrap .taro-answer::after {
    content: none;
}
.taro-wrap .taro-answer.show { display: block; }

.taro-result-block {
    margin-bottom: 32px;
}
.taro-result-block:last-child {
    margin-bottom: 0;
}

/* Состояние ожидания пока LLM формирует трактовку (5-15 сек). */
.taro-result-loading {
    text-align: center;
    padding: 40px 20px;
    font-size: 19px;
    font-style: italic;
    color: #6b5540;
    animation: taroLoadingPulse 1.6s ease-in-out infinite;
}
@keyframes taroLoadingPulse {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 1; }
}

/* Сообщение об ошибке (LLM не ответил, сеть отвалилась, и т.п.). */
.taro-result-error {
    text-align: center;
    padding: 32px 20px;
    color: #8b3a1f;
}
.taro-result-error__title {
    font-size: 19px;
    font-weight: 600;
    margin-bottom: 8px;
}
.taro-result-error__detail {
    font-size: 15px;
    font-style: italic;
    color: #6b5540;
    word-break: break-word;
}

/* Заголовок позиции — линии слева/справа в стиле .taro-question-block__label */
.taro-result-position {
    display: flex;
    align-items: center;
    gap: 1px;
    margin-bottom: 16px;
    font-size: 21px;
    font-style: italic;
    color: #4a3828;
}
.taro-result-position::before,
.taro-result-position::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, #c9b99a, transparent);
}
.taro-result-position span {
    padding: 0 12px;
    white-space: nowrap;
}

/* Мобильный (по умолчанию): карта по центру, текст под ней */
.taro-result-block__body {
    text-align: center;
}
.taro-result-card__img {
    display: block;
    width: 110px;
    height: auto;
    margin: 0 auto 14px;
    border-radius: 11px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}
.taro-result-card__text {
    font-size: 18px;
    line-height: 1.4;
    color: #4a3828;
    max-width: 520px;
    margin: 0 auto;
}
.taro-result-card__name {
    font-weight: 700;
    font-style: normal;
    margin-right: 4px;
}
/* Номер позиции в начале текста — чуть крупнее, цвет основного текста */
.taro-result-card__num {
    font-size: 19px;
    font-weight: 700;
    font-style: normal;
    color: #4a3828;
    margin-right: 6px;
}

/* Разделитель перед итоговым абзацем расклада (в раскладах с блоком «итог»).
   Та же затухающая линия, что у названий позиций (.taro-result-position). */
.taro-result-hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, #c9b99a, transparent);
    margin: 16px 0;
}
/* Итоговый абзац после разделителя — отдельным блоком */
.taro-result-summary {
    display: block;
    margin-top: 4px;
}

@media (max-width: 440px) {
    .taro-result-position { font-size: 18px; }
    .taro-result-card__img { width: 90px; }
}

/* Планшет и десктоп: карта слева, текст справа двумя колонками */
@media (min-width: 769px) {
    .taro-result-block__body {
        display: flex;
        gap: 24px;
        align-items: flex-start;
        text-align: left;
    }
    .taro-result-card__img {
        flex-shrink: 0;
        width: 120px;
        margin: 0;
    }
    .taro-result-card__text {
        flex: 1;
        max-width: none;
        margin: 0;
    }
}

#taro-restart {
    display: none;
    margin-top: 30px;
}
#taro-restart.show { display: flex; }

@media (max-width: 440px) {
    .taro-wrap { padding: 20px 5px 60px; }
    .taro-question-block__label { font-size: 16px; }
    .taro-fan-block { padding-bottom: 150px; }
    .taro-answer { font-size: 17px; }
}
