/* =========================================
   BASE & RESET
   ========================================= */
.nl-quiz-widget {
    box-sizing: border-box;
    --nl-anim-speed: 0.3s;
    --nl-anim-ease: cubic-bezier(0.25, 0.8, 0.25, 1);
}

.nl-quiz-widget *,
.nl-quiz-widget *::before,
.nl-quiz-widget *::after {
    box-sizing: border-box;
}

.nl-quiz-container {
    position: relative;
    background: #fff; /* Default fallback */
    overflow: hidden; /* Contains child margins */
    transition: height 0.3s ease; /* Smooth height change if needed */
}

/* =========================================
   PROGRESS BAR
   ========================================= */
.nl-quiz-progress-bar-wrapper {
    margin-bottom: 30px;
    width: 100%; /* Default, overridden by control */
}

.nl-quiz-track {
    width: 100%;
    height: 8px;
    background-color: #eee;
    border-radius: 4px;
    overflow: hidden;
}

.nl-quiz-bar {
    height: 100%;
    background-color: #333;
    width: 0%;
    transition: width 0.5s var(--nl-anim-ease);
}

/* =========================================
   FOOTER AREA
   ========================================= */
.nl-quiz-footer {
    /* Margin and Gap set by Controls */
    display: flex;
    flex-direction: column;
    align-items: center; 
    justify-content: center;
}

.nl-quiz-progress-text {
    font-size: 14px;
    font-weight: 500;
    color: #666;
}

/* =========================================
   BACK BUTTON (CUSTOM DIV)
   ========================================= */
.nl-quiz-back-btn {
    /* Reset & Structure */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    outline: none;
    padding: 2px 0;
    position: relative;
    
    /* Typography */
    cursor: pointer;
    font-size: 14px;
    color: #888;
    user-select: none;
    transition: color 0.3s ease;
    
    /* Gap handled by Controls */
}

.nl-quiz-back-btn:hover {
    color: #333;
}

/* Focus State for Accessibility */
.nl-quiz-back-btn:focus-visible {
    outline: 1px dotted #333;
}

/* --- Underline Animation (Text Only) --- */

/* 1. Set context for the line */
.nl-back-text {
    position: relative;
    display: inline-block; /* Чтобы линия была ровно по ширине текста */
}

/* 2. The Line itself */
.nl-back-text::after {
    content: '';
    position: absolute;
    bottom: 0; /* Или -2px, если хочешь небольшой отступ от букв */
    left: 0;
    width: 100%;
    height: 1px; /* Default, overridden by Control */
    background-color: currentColor;
    
    transform-origin: right;
    transform: scaleX(1);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* 3. Trigger: Hover on BUTTON affects LINE inside */
.nl-quiz-back-btn:hover .nl-back-text::after {
    transform: scaleX(0);
    transform-origin: right; /* Исчезает вправо */
}

/* Удаляем старую линию с контейнера, если она там осталась в кеше/коде */
.nl-quiz-back-btn::after {
    display: none;
}

/* FIX: Ensure Icon has size */
.nl-quiz-back-btn i,
.nl-quiz-back-btn svg {
    width: 1.2em; /* Чуть больше текста для баланса */
    height: 1.2em;
    font-size: 1em; /* Для шрифтовых иконок */
    fill: currentColor; /* Чтобы цвет совпадал с текстом */
    display: inline-block;
    vertical-align: middle;
}

.nl-back-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* --- ICON ANIMATIONS --- */

.nl-back-icon {
    display: flex;
    align-items: center;
    transition: transform 0.3s ease;
}

/* Slide Left */
.nl-icon-anim-slide:hover .nl-back-icon {
    transform: translateX(-4px);
}

/* Scale */
.nl-icon-anim-scale:hover .nl-back-icon {
    transform: scale(1.2);
}

/* Fade */
.nl-icon-anim-fade:hover .nl-back-icon {
    opacity: 0.6;
}leX(0);
}

/* =========================================
   STEPS COMMON
   ========================================= */
.nl-quiz-step {
    width: 100%;
    /* Display is toggled via JS/Inline style */
}

/* Animation Classes (Used by JS) */
.nl-quiz-step.nl-fade-in {
    animation: nlFadeIn 0.4s var(--nl-anim-ease) forwards;
}

.nl-quiz-step.nl-fade-out {
    animation: nlFadeOut 0.3s var(--nl-anim-ease) forwards;
}

@keyframes nlFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes nlFadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-10px); }
}

.nl-quiz-question {
    margin: 0 0 10px 0;
    font-size: 24px;
    line-height: 1.3;
}

.nl-quiz-subtitle {
    margin: 0 0 25px 0;
    font-size: 16px;
    color: #666;
}

/* =========================================
   ANSWERS GRID
   ========================================= */
.nl-quiz-answers {
    display: grid;
    /* Columns and Gap set by Elementor Controls */
    width: 100%;
}

/* =========================================
   ANSWER CARD
   ========================================= */
.nl-quiz-answer {
    position: relative;
    display: flex;
    /* Flex-direction is controlled by icon position modifier */
    /* Alignment is controlled by align modifier */
    padding: 20px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--nl-anim-speed);
    height: 100%;
}

/* --- ICON POSITION MODIFIERS --- */

/* Icon Top (Default) */
.nl-icon-top .nl-quiz-answer {
    flex-direction: column;
}
/* Margins removed because we use GAP in parent */
.nl-icon-top .nl-quiz-icon {
    margin: 0;
}

/* Icon Left */
.nl-icon-left .nl-quiz-answer {
    flex-direction: row;
}
.nl-icon-left .nl-quiz-icon {
    margin: 0;
    flex-shrink: 0;
}

/* Icon Right */
.nl-icon-right .nl-quiz-answer {
    flex-direction: row-reverse;
}
.nl-icon-right .nl-quiz-icon {
    margin: 0;
    flex-shrink: 0;
}

/* --- TEXT ALIGNMENT MODIFIERS (The Fix for Issue #4) --- */

/* Align Left */
.nl-align-left .nl-quiz-answer {
    text-align: left;
}
/* If Icon Top -> align-items: flex-start */
.nl-align-left.nl-icon-top .nl-quiz-answer {
    align-items: flex-start;
}
/* If Icon Left/Right -> align-items: center (vertically) typically looks best, 
   but let's respect "Left" as vertical top if needed? 
   No, usually side icon implies vertical centering. Let's force vertical center for side icons. */
.nl-align-left.nl-icon-left .nl-quiz-answer,
.nl-align-left.nl-icon-right .nl-quiz-answer {
    align-items: center; 
    justify-content: flex-start;
}


/* Align Center */
.nl-align-center .nl-quiz-answer {
    text-align: center;
}
.nl-align-center.nl-icon-top .nl-quiz-answer {
    align-items: center;
}
.nl-align-center.nl-icon-left .nl-quiz-answer,
.nl-align-center.nl-icon-right .nl-quiz-answer {
    align-items: center;
    justify-content: center;
}


/* Align Right */
.nl-align-right .nl-quiz-answer {
    text-align: right;
}
.nl-align-right.nl-icon-top .nl-quiz-answer {
    align-items: flex-end;
}
.nl-align-right.nl-icon-left .nl-quiz-answer,
.nl-align-right.nl-icon-right .nl-quiz-answer {
    align-items: center;
    justify-content: flex-end;
}

/* --- STATES --- */

/* Hover State */
.nl-quiz-answer:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
}

/* Selected State */
.nl-quiz-answer.nl-selected {
    /* Border color handled by inline style from controls */
    background-color: #f9f9f9; /* Fallback */
}

/* Icon */
.nl-quiz-icon {
    font-size: 32px;
    color: #333;
    transition: color 0.3s;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nl-quiz-icon svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
}

/* Content */
.nl-quiz-content {
    flex: 1; /* Take remaining space */
}

.nl-quiz-answer-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.2;
    transition: color 0.3s;
}

.nl-quiz-answer-desc {
    margin: 5px 0 0 0;
    font-size: 13px;
    color: #777;
    line-height: 1.4;
    transition: color 0.3s;
}

/* =========================================
   INTRO SCREEN
   ========================================= */
.nl-quiz-intro {
    text-align: center;
    padding: 40px 20px;
}

.nl-quiz-intro-title {
    margin-bottom: 15px;
}

.nl-quiz-intro-text {
    margin-bottom: 30px;
    font-size: 16px;
    color: #555;
}

.nl-quiz-btn {
    display: inline-block;
    padding: 12px 30px;
    background-color: #333;
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: opacity 0.3s;
}

.nl-quiz-btn:hover {
    opacity: 0.9;
}

/* =========================================
   RESULT SCREEN
   ========================================= */
.nl-quiz-result-card {
    display: flex;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    width: 100%;
    position: relative;
    flex-direction: column; /* Default stack */
    /* Min-height set by controls */
}

/* Common Image Styles */
.nl-quiz-result-img {
    position: relative;
    overflow: hidden;
    /* Width/Height/Align set by Controls */
    flex-shrink: 0; 
}

.nl-quiz-result-img img {
    width: 100%;
    height: 100%;
    display: block;
    /* Object-fit/Position set by Controls */
}

/* Common Content Styles */
.nl-quiz-result-content {
    display: flex;
    flex-direction: column;
    /* Justify-content (Vertical) set by Controls */
    /* Align-items (Horizontal) set by Controls */
    flex-grow: 1; /* Fills remaining height */
    z-index: 1;
}

/* --- LAYOUT 1: TOP / BOTTOM (Default) --- */
.nl-res-layout-top .nl-quiz-result-card {
    /* flex-direction: column is default */
}

.nl-res-layout-top .nl-quiz-result-img {
    width: 100%; /* Default */
    /* Align-self set by controls */
}

.nl-res-layout-top .nl-quiz-result-content {
    width: 100%;
}

/* --- LAYOUT 2: BACKGROUND IMAGE --- */
.nl-res-layout-bg .nl-quiz-result-card {
    display: block; /* Stack context */
    position: relative;
}

.nl-res-layout-bg .nl-quiz-result-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* Overlay Pseudo-element (Controlled by PHP) */
.nl-res-layout-bg .nl-quiz-result-img::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.nl-res-layout-bg .nl-quiz-result-content {
    position: relative;
    z-index: 2;
    height: 100%; /* Fill container */
    background: transparent !important;
}

/* CTA Button Styles */
.nl-quiz-cta-btn {
    display: inline-block;
    text-align: center;
    padding: 15px 30px;
    text-decoration: none;
    font-weight: 600;
    border-radius: 5px;
    transition: all 0.3s;
    width: fit-content;
    margin-top: 20px;
}

.nl-quiz-cta-btn:hover {
    /* Opacity removed as requested */
}

/* CTA Button Styles (Kept generic) */
.nl-quiz-cta-btn {
    display: inline-block;
    text-align: center;
    padding: 15px 30px;
    text-decoration: none;
    font-weight: 600;
    border-radius: 5px;
    transition: all 0.3s;
    width: fit-content;
    margin-top: 20px;
}

.nl-quiz-cta-btn:hover {
    opacity: 1;
}