/* ==========================================================================
   Journal Exercise — frontend styles
   Uses CSS custom properties set inline by the PHP template.
   ========================================================================== */

.je-container {
    --je-primary:    #4a90a4;
    --je-accent:     #2d7a8e;
    --je-bg:         #f9f6f1;
    --je-text:       #3a3a3a;
    --je-border:     #e5e0d8;
    --je-card-bg:    #ffffff;
    --je-radius:     10px;
    --je-radius-sm:  6px;

    max-width: 680px;
    margin: 0 auto;
    padding: 2.5rem;
    background-color: var(--je-bg);
    border-radius: var(--je-radius);
    font-family: Georgia, 'Times New Roman', serif;
    color: var(--je-text);
    box-sizing: border-box;
    line-height: 1.6;
}

/* ==========================================================================
   Stage visibility
   ========================================================================== */

.je-stage {
    display: none;
}

.je-stage.active {
    display: block;
    animation: je-fade-in 0.35s ease both;
}

@keyframes je-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0);    }
}

/* ==========================================================================
   Stage 1 — Prompt selection
   ========================================================================== */

.je-intro {
    font-size: 0.95rem;
    line-height: 1.75;
    color: #777;
    font-style: italic;
    margin: 0 0 2rem;
}

.je-prompts-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2.25rem;
}

.je-prompt-card {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    align-items: start;
    gap: 0.875rem;
    background: var(--je-card-bg);
    border: 1.5px solid var(--je-border);
    border-radius: var(--je-radius);
    padding: 1.1rem 1.25rem;
    transition: border-color 0.2s;
}

.je-prompt-card.je-swapped {
    border-color: var(--je-primary);
    background: color-mix(in srgb, var(--je-primary) 4%, white);
}

.je-prompt-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--je-primary) 12%, transparent);
    color: var(--je-primary);
    font-size: 0.8rem;
    font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    flex-shrink: 0;
    margin-top: 2px;
}

.je-prompt-text {
    margin: 0;
    font-size: 1rem;
    line-height: 1.65;
    color: var(--je-text);
    align-self: center;
}

.je-swap-btn {
    background: none;
    border: none;
    color: var(--je-primary);
    font-size: 0.78rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    cursor: pointer;
    padding: 0.2rem 0;
    text-decoration: underline;
    text-underline-offset: 2px;
    white-space: nowrap;
    transition: color 0.15s, opacity 0.15s;
    align-self: flex-start;
    margin-top: 3px;
}

.je-swap-btn:hover:not(:disabled) {
    color: var(--je-accent);
}

.je-swap-btn:disabled,
.je-swap-btn.je-swap-used {
    opacity: 0.3;
    text-decoration: none;
    cursor: not-allowed;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.je-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 2rem;
    border: 2px solid transparent;
    border-radius: var(--je-radius-sm);
    font-size: 0.95rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background-color 0.18s, color 0.18s, transform 0.1s;
    line-height: 1;
}

.je-btn:active {
    transform: translateY(1px);
}

.je-btn-primary {
    background-color: var(--je-primary);
    color: #fff;
    border-color: var(--je-primary);
    width: 100%;
}

.je-btn-primary:hover {
    background-color: var(--je-accent);
    border-color: var(--je-accent);
}

.je-btn-secondary {
    background-color: transparent;
    color: var(--je-primary);
    border-color: var(--je-primary);
}

.je-btn-secondary:hover {
    background-color: var(--je-primary);
    color: #fff;
}

/* ==========================================================================
   Stage 2 — Journaling
   ========================================================================== */

.je-journal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
}

.je-progress-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #999;
}

.je-timer-wrap {
    text-align: right;
}

.je-timer-display {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.9rem;
    font-weight: 300;
    color: var(--je-primary);
    line-height: 1;
    margin-bottom: 6px;
    transition: color 0.4s;
}

.je-timer-display.je-timer-done {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.78rem;
    font-weight: 400;
    color: #bbb;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.je-timer-bar {
    width: 120px;
    height: 3px;
    background: var(--je-border);
    border-radius: 2px;
    overflow: hidden;
    margin-left: auto;
}

.je-timer-fill {
    height: 100%;
    width: 100%;
    background: var(--je-primary);
    border-radius: 2px;
    transition: width 1s linear;
    transform-origin: right;
}

.je-journal-prompt {
    font-size: 1.25rem;
    line-height: 1.7;
    color: var(--je-text);
    margin: 0 0 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--je-border);
    min-height: 2.5em;
}

.je-journal-textarea {
    display: block;
    width: 100%;
    min-height: 260px;
    padding: 1.15rem 1.25rem;
    border: 1.5px solid var(--je-border);
    border-radius: var(--je-radius);
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1rem;
    line-height: 1.85;
    color: var(--je-text);
    background: var(--je-card-bg);
    resize: vertical;
    outline: none;
    box-sizing: border-box;
    margin-bottom: 1.5rem;
    transition: border-color 0.2s;
}

.je-journal-textarea:focus,
.je-followup-textarea:focus {
    border-color: var(--je-primary);
}

.je-journal-textarea::placeholder,
.je-followup-textarea::placeholder {
    color: #c5bfb5;
    font-style: italic;
}

.je-followup-textarea {
    display: block;
    width: 100%;
    min-height: 200px;
    padding: 1.15rem 1.25rem;
    border: 1.5px solid var(--je-border);
    border-radius: var(--je-radius);
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1rem;
    line-height: 1.85;
    color: var(--je-text);
    background: var(--je-card-bg);
    resize: vertical;
    outline: none;
    box-sizing: border-box;
    margin-top: 1.25rem;
    margin-bottom: 1.5rem;
    transition: border-color 0.2s;
}

/* ==========================================================================
   Stage 3 — Loading
   ========================================================================== */

.je-stage-loading {
    text-align: center;
    padding: 5rem 2rem;
}

.je-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--je-border);
    border-top-color: var(--je-primary);
    border-radius: 50%;
    animation: je-spin 0.75s linear infinite;
    margin: 0 auto 1.5rem;
}

@keyframes je-spin {
    to { transform: rotate(360deg); }
}

.je-stage-loading p {
    font-style: italic;
    color: #999;
    font-size: 0.95rem;
    margin: 0;
}

/* ==========================================================================
   Stage 4 — Results
   ========================================================================== */

.je-results-heading {
    font-size: 1.45rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: var(--je-text);
    margin: 0 0 1.5rem;
}

.je-commentary {
    font-size: 1.05rem;
    line-height: 1.9;
    color: var(--je-text);
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--je-border);
    white-space: pre-line;
}

.je-follow-up-wrap {
    background: var(--je-card-bg);
    border: 1px solid var(--je-border);
    border-left: 3px solid var(--je-primary);
    border-radius: 0 var(--je-radius) var(--je-radius) 0;
    padding: 1.4rem 1.5rem;
    margin-bottom: 2.5rem;
}

.je-follow-up-label {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #aaa;
    margin: 0 0 0.6rem;
}

.je-follow-up-question {
    font-size: 1.1rem;
    line-height: 1.7;
    font-style: italic;
    color: var(--je-text);
    margin: 0;
}

/* ==========================================================================
   Stage 3 — Reflect (simple mode)
   ========================================================================== */

.je-reflect-intro {
    font-size: 0.9rem;
    color: #888;
    margin: 0 0 0.875rem;
    font-style: italic;
}

.je-reflect-questions {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
    counter-reset: reflect-counter;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.je-reflect-questions li {
    counter-increment: reflect-counter;
    display: grid;
    grid-template-columns: 28px 1fr;
    align-items: baseline;
    gap: 0.75rem;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--je-text);
    background: var(--je-card-bg);
    border: 1px solid var(--je-border);
    border-radius: var(--je-radius-sm);
    padding: 0.875rem 1rem;
}

.je-reflect-questions li::before {
    content: counter(reflect-counter);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--je-primary) 12%, transparent);
    color: var(--je-primary);
    font-size: 0.75rem;
    font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    flex-shrink: 0;
}

.je-reflect-cta {
    font-size: 1.15rem;
    line-height: 1.7;
    color: var(--je-text);
    margin: 0 0 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--je-border);
    font-style: italic;
}

.je-reflect-textarea {
    display: block;
    width: 100%;
    min-height: 260px;
    padding: 1.15rem 1.25rem;
    border: 1.5px solid var(--je-border);
    border-radius: var(--je-radius);
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1rem;
    line-height: 1.85;
    color: var(--je-text);
    background: var(--je-card-bg);
    resize: vertical;
    outline: none;
    box-sizing: border-box;
    margin-bottom: 1.5rem;
    transition: border-color 0.2s;
}

.je-reflect-textarea:focus {
    border-color: var(--je-primary);
}

.je-reflect-textarea::placeholder {
    color: #c5bfb5;
    font-style: italic;
}

/* ==========================================================================
   Stage 5 — Complete (simple mode)
   ========================================================================== */

.je-complete-message {
    font-size: 1.05rem;
    line-height: 1.8;
    color: #666;
    font-style: italic;
    margin: 0 0 2rem;
}

/* ==========================================================================
   Session actions (shared by results + complete stages)
   ========================================================================== */

.je-session-actions {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    margin-bottom: 1rem;
}

.je-session-actions .je-btn {
    width: 100%;
}

.je-pdf-notice {
    font-size: 0.85rem;
    color: #c0392b;
    margin: 0.5rem 0 0;
    text-align: center;
}

/* ==========================================================================
   Stage 6 — Error
   ========================================================================== */

.je-stage-error {
    text-align: center;
    padding: 3.5rem 2rem;
}

.je-error-icon {
    font-size: 2.5rem;
    color: #d9534f;
    margin: 0 0 1rem;
}

.je-error-message {
    color: #555;
    font-size: 1rem;
    margin: 0 0 1.75rem;
    line-height: 1.65;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 600px) {
    .je-container {
        padding: 1.5rem 1.1rem;
        border-radius: var(--je-radius-sm);
    }

    .je-prompt-card {
        grid-template-columns: 28px 1fr;
    }

    .je-swap-btn {
        grid-column: 2;
        text-align: left;
    }

    .je-journal-prompt {
        font-size: 1.1rem;
    }

    .je-timer-display {
        font-size: 1.5rem;
    }

    .je-timer-bar {
        width: 80px;
    }
}

/* ==========================================================================
   Elementor editor — keep widget visible at a sensible size
   ========================================================================== */

.elementor-editor-active .je-container {
    min-height: 200px;
}
