/* Explain: Editor styles: hero, chapters, dropzone, stepper, live preview, category picker. */
/* Recipe editor page: hero, chapters, title input, photo dropzone, stepper, step timeline, live preview, progress, save bar and motion. */
@property --edit-progress {
    syntax: '<number>';
    inherits: false;
    initial-value: 0;
}

.edit-hero {
    background:
        radial-gradient(55rem 28rem at 100% 0%, color-mix(in srgb, var(--secondary-color) 55%, transparent), transparent 65%),
        radial-gradient(45rem 26rem at 0% 100%, color-mix(in srgb, var(--primary-color) 32%, transparent), transparent 65%),
        var(--surface-alt);
}

.edit-float {
    color: var(--primary-color);
    opacity: 0.16;
    pointer-events: none;
    animation: edit-float 8s ease-in-out infinite;
}

.edit-float-alt {
    color: var(--accent-color);
    animation-delay: -4s;
}

.edit-chapter-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    flex-shrink: 0;
    border-radius: 1rem;
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-hover), color-mix(in srgb, var(--primary-hover) 75%, var(--text-color)));
    box-shadow: 0 12px 24px -12px color-mix(in srgb, var(--primary-hover) 85%, transparent);
    transform: rotate(-6deg);
}

.edit-title-input {
    width: 100%;
    padding: 0.5rem 0 0.75rem;
    border: 0;
    border-bottom: 2px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    font-family: var(--font-heading);
    font-size: clamp(1.625rem, 3.2vw, 2.5rem);
    font-weight: 700;
    line-height: 1.3;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.edit-title-input::placeholder {
    color: var(--text-muted);
    opacity: 0.55;
    font-weight: 500;
}

.edit-title-input:focus {
    outline: none;
    border-bottom-color: var(--primary-color);
    box-shadow: 0 2px 0 0 var(--primary-color);
}

.edit-stepper,
.edit-soft-field {
    transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.edit-stepper:focus-within,
.edit-soft-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-color) 20%, transparent);
}

.edit-stepper-input {
    border: 0;
    outline: none;
    color: var(--text-color);
    -moz-appearance: textfield;
    appearance: textfield;
}

.edit-stepper-input::-webkit-outer-spin-button,
.edit-stepper-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.edit-soft-field {
    border: 1px solid transparent;
    border-radius: 0.875rem;
    background: color-mix(in srgb, var(--surface-alt) 45%, var(--surface-color));
    color: var(--text-color);
}

.edit-soft-field::placeholder { color: var(--text-muted); }
.edit-soft-field:hover { border-color: var(--border-color); }
.edit-soft-field:focus { background: var(--surface-color); }
.step-text.edit-soft-field { field-sizing: content; }

.edit-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 15rem;
    padding: 2rem 1.5rem;
    border: 2px dashed color-mix(in srgb, var(--primary-color) 50%, var(--border-color));
    border-radius: 1.5rem;
    background: color-mix(in srgb, var(--primary-color) 6%, var(--surface-color));
    text-align: center;
    cursor: pointer;
    transition: border-color 0.25s ease, background-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.edit-dropzone:hover,
.edit-dropzone.is-dragging {
    border-color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 13%, var(--surface-color));
}

.edit-dropzone.is-dragging,
.step-image-pick.is-dragging {
    transform: scale(1.02);
    box-shadow: 0 18px 40px -20px color-mix(in srgb, var(--primary-hover) 80%, transparent);
}

.step-image-pick.is-dragging {
    border-style: solid;
    border-color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 12%, var(--surface-color));
}

.edit-dropzone:focus-within {
    outline: 3px solid color-mix(in srgb, var(--primary-color) 50%, transparent);
    outline-offset: 3px;
}

.edit-dropzone-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.edit-dropzone-filled {
    display: none;
    align-items: center;
    gap: 0.5rem;
}

#recipeImageField:has(#recipeImagePreview:not([hidden])) .edit-dropzone {
    min-height: 0;
    padding: 0.75rem 1.25rem;
    border-radius: 9999px;
}

#recipeImageField:has(#recipeImagePreview:not([hidden])) .edit-dropzone-empty { display: none; }
#recipeImageField:has(#recipeImagePreview:not([hidden])) .edit-dropzone-filled { display: inline-flex; }

#recipeImageField[aria-busy="true"] .edit-dropzone {
    opacity: 0.65;
    cursor: wait;
    pointer-events: none;
}

.edit-empty {
    border: 1.5px dashed color-mix(in srgb, var(--primary-color) 30%, var(--border-color));
    background: color-mix(in srgb, var(--surface-alt) 55%, var(--surface-color));
}

.step-timeline::before {
    content: '';
    position: absolute;
    inset-inline-start: calc(1.25rem - 1px);
    top: 3rem;
    bottom: 0.5rem;
    width: 2px;
    border-radius: 2px;
    background: linear-gradient(to bottom, color-mix(in srgb, var(--primary-color) 60%, transparent), color-mix(in srgb, var(--primary-color) 8%, transparent));
}

.step-timeline:last-child::before { display: none; }

.edit-step-num {
    z-index: 1;
    border: 2px solid color-mix(in srgb, var(--primary-color) 60%, var(--surface-color));
    background: var(--surface-color);
    color: var(--primary-hover);
    box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--primary-hover) 80%, transparent);
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.3s ease;
}

.step-row:focus-within .edit-step-num {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
    color: #ffffff;
    transform: scale(1.08);
}

.edit-ring {
    position: relative;
    display: grid;
    place-items: center;
    border-radius: 9999px;
    background: conic-gradient(var(--primary-hover) calc(var(--edit-progress) * 1%), color-mix(in srgb, var(--primary-color) 16%, var(--surface-color)) 0);
    transition: --edit-progress 0.6s ease;
}

.edit-ring::before {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: inherit;
    background: var(--background-color);
}

.edit-check-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
    border: 2px solid var(--border-color);
    border-radius: 9999px;
    color: transparent;
    font-size: 0.65rem;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.edit-check.is-done {
    border-color: color-mix(in srgb, var(--primary-color) 60%, var(--border-color));
    background: color-mix(in srgb, var(--primary-color) 10%, var(--surface-color));
}

.edit-check.is-done .edit-check-icon {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
    color: #ffffff;
}

.edit-check.is-popping .edit-check-icon { animation: edit-pop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1); }
.is-placeholder { opacity: 0.55; }
.edit-count { display: inline-block; }
.edit-preview-img { animation: edit-fade 0.5s ease both; }

.edit-live-dot {
    position: relative;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 9999px;
    background: var(--primary-hover);
}

.edit-live-dot::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: inherit;
    animation: edit-ping 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.edit-progress-fill {
    background: linear-gradient(to left, var(--primary-hover), var(--secondary-color));
    transition: width 0.5s ease;
}

.edit-savebar {
    background: color-mix(in srgb, var(--surface-color) 90%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    box-shadow: 0 -10px 30px -14px color-mix(in srgb, var(--text-color) 35%, transparent);
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
}

#saveBtn.is-ready:not(:disabled) { animation: edit-ready 1.6s ease-out 2; }

.edit-press { transition: transform 0.15s ease, background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, color 0.25s ease; }
.edit-press:active:not(:disabled) { transform: scale(0.95); }

[data-ripple] {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.edit-ripple {
    position: absolute;
    z-index: -1;
    border-radius: 9999px;
    background: currentColor;
    opacity: 0.22;
    pointer-events: none;
    transform: scale(0);
    animation: edit-ripple 0.6s ease-out forwards;
}

.is-bumped { animation: edit-bump 0.4s ease; }

/* Category multi-select dropdown (global/category-picker.html + js/category-picker.js). */
.category-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    min-height: 3rem;
    padding: 0.625rem 1.125rem;
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    background: var(--surface-color);
    color: var(--text-color);
    font-weight: 500;
    text-align: start;
    cursor: pointer;
    box-shadow: 0 1px 2px color-mix(in srgb, var(--text-color) 8%, transparent);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.category-toggle:hover { border-color: var(--primary-color); }

.category-toggle:focus-visible,
.category-picker.is-open .category-toggle {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-color) 20%, transparent);
}

.category-summary.is-empty { color: var(--text-muted); font-weight: 400; }
.category-chevron { transition: transform 0.25s ease; }
.category-picker.is-open .category-chevron { transform: rotate(180deg); }
.category-picker.is-open { z-index: 40; }
.edit-rise:has(.category-picker.is-open) { position: relative; z-index: 35; }
.category-panel { animation: category-panel-in 0.18s ease-out both; }
.category-option { transition: background-color 0.2s ease; }
.category-option:hover { background: color-mix(in srgb, var(--surface-alt) 70%, var(--surface-color)); }

.category-option:has(:checked) {
    background: color-mix(in srgb, var(--primary-color) 14%, var(--surface-color));
    font-weight: 500;
}

.category-check {
    --input-color: var(--primary-hover);
    color: #ffffff;
}

@keyframes category-panel-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    .category-panel { animation: none; }
    .category-chevron { transition: none; }
}

.edit-rise { animation: edit-rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.edit-rise-2 { animation-delay: 0.1s; }
.edit-rise-3 { animation-delay: 0.2s; }
.edit-rise-4 { animation-delay: 0.3s; }

@media (min-width: 1024px) {
    .edit-aside {
        max-height: calc(100vh - 7rem);
        overflow-y: auto;
        overscroll-behavior: contain;
        margin-inline: -0.75rem;
        padding: 0.25rem 0.75rem 1.75rem;
        scrollbar-width: thin;
    }
}

@keyframes edit-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes edit-float { 0%, 100% { transform: translateY(0) rotate(-8deg); } 50% { transform: translateY(-12px) rotate(6deg); } }
@keyframes edit-pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes edit-bump { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.3); } }
@keyframes edit-ripple { to { transform: scale(1); opacity: 0; } }
@keyframes edit-fade { from { opacity: 0; transform: scale(1.04); } to { opacity: 1; transform: none; } }
@keyframes edit-ping { 75%, 100% { transform: scale(2.4); opacity: 0; } }
@keyframes edit-ready {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary-color) 55%, transparent); }
    100% { box-shadow: 0 0 0 14px color-mix(in srgb, var(--primary-color) 0%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
    .edit-rise,
    .edit-float,
    .edit-live-dot::after,
    .edit-preview-img,
    .is-bumped,
    .edit-check.is-popping .edit-check-icon,
    #saveBtn.is-ready:not(:disabled) {
        animation: none !important;
    }

    .edit-ring,
    .edit-progress-fill { transition: none; }

    .edit-press:active:not(:disabled),
    .edit-dropzone.is-dragging,
    .step-image-pick.is-dragging,
    .step-row:focus-within .edit-step-num { transform: none; }
}