/* Click-to-edit CMS overlay (webroot/js/inline-edit.js). Loaded everywhere
   but inert until .cms-edit-mode is toggled on for a signed-in admin/staff user. */

/* Admin editing bar across the top of the page. It sits above the sticky
   site header, which is pushed down by the same height. */
.cms-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: var(--space-4);
    height: 56px;
    padding: 0 var(--space-5);
    background: var(--color-primary-dark);
    color: var(--color-white);
    font-size: var(--text-sm);
}

.cms-bar-on body { padding-top: 56px; }
.cms-bar-on .site-header { top: 56px; }
/* The phone menu is fixed to the viewport, so it needs the same push. */
.cms-bar-on .nav-links { top: calc(var(--header-h) + 56px); }

.cms-bar__page {
    overflow: hidden;
    color: rgba(255, 255, 255, 0.75);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cms-bar__page strong {
    font-weight: 600;
    color: var(--color-white);
}

.cms-bar__status {
    flex: 1;
    min-width: 0;
    color: rgba(255, 255, 255, 0.75);
}

.cms-bar__status--busy,
.cms-bar__status--ok { color: var(--color-white); }
.cms-bar__status--error { color: #FFD4CE; }

.cms-bar__actions {
    display: flex;
    flex-shrink: 0;
    gap: var(--space-2);
}

.cms-bar__btn {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 var(--space-4);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 999px;
    color: var(--color-white);
    font-size: var(--text-sm);
    font-weight: 600;
    transition: background-color var(--transition-fast);
}

.cms-bar__btn:hover { background: rgba(255, 255, 255, 0.14); }

.cms-bar__btn--primary {
    border-color: transparent;
    background: var(--color-white);
    color: var(--color-primary-dark);
}

.cms-bar__btn--primary:hover { background: rgba(255, 255, 255, 0.86); }

@media (max-width: 640px) {
    .cms-bar {
        gap: var(--space-3);
        padding: 0 var(--space-4);
    }

    .cms-bar__page { display: none; }
}

.cms-edit-mode [data-cms-key] {
    cursor: pointer;
    outline: 1.5px dashed transparent;
    outline-offset: 5px;
    border-radius: var(--radius);
    transition: outline-color var(--transition-fast);
}
/* Outline on hover only, so text on dark sections and photos stays readable. */
.cms-edit-mode [data-cms-key]:hover {
    outline-style: solid;
    outline-color: var(--color-primary);
}
/* Inside the photo, so a cropping parent cannot clip it away. */
.cms-edit-mode img[data-cms-key] { outline-offset: -4px; }

.cms-hint {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1002;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--color-primary-dark);
    color: var(--color-white);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.6;
    text-transform: none;
    white-space: nowrap;
    pointer-events: none;
}

.cms-edit-field--active {
    outline: 2px solid var(--color-primary-dark) !important;
    background-color: var(--color-white) !important;
    box-shadow: 0 2px 14px rgba(20, 38, 28, 0.25);
    padding: 2px 6px;
}
/* Dark-section/photo-hero text is normally light-on-dark; force it dark
   while actively editing so it stays legible against the white field. */
.cms-edit-field--active,
.cms-edit-field--active * {
    color: var(--color-text) !important;
}

.cms-edit-field--saving { opacity: 0.5; }

.cms-edit-toast {
    position: fixed;
    left: 50%;
    bottom: var(--space-5);
    transform: translate(-50%, 12px);
    z-index: 1001;
    background: var(--color-text);
    color: var(--color-white);
    font-size: var(--text-sm);
    padding: 10px 18px;
    border-radius: 999px;
    box-shadow: var(--shadow-soft);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.cms-edit-toast--visible {
    opacity: 1;
    transform: translate(-50%, 0);
}
.cms-edit-toast--error { background: var(--color-error); }

.cms-edit-toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.cms-edit-toast--visible { pointer-events: auto; }

.cms-edit-toast__undo {
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    color: var(--color-white);
    font-size: var(--text-sm);
    font-weight: 600;
}

.cms-edit-toast__undo:hover { background: rgba(255, 255, 255, 0.3); }



.cms-color-panel {
    display: none;
    position: fixed;
    top: calc(56px + var(--space-2));
    right: var(--space-5);
    z-index: 1000;
    flex-direction: column;
    padding: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: 18px;
    background: var(--color-white);
    box-shadow: var(--shadow-lift);
    width: min(340px, calc(100vw - 2 * var(--space-5)));
    max-height: calc(100vh - 56px - 2 * var(--space-5));
    overflow-y: auto;
}
.cms-color-panel--open { display: flex; }

.cms-color-panel__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 10px 10px 8px;
}

.cms-color-panel__heading {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cms-color-panel__label {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--color-text);
}

.cms-color-panel__sub {
    font-size: var(--text-xs);
    color: var(--color-text-soft);
}

.cms-color-panel__close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--color-text-soft);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}
.cms-color-panel__close:hover {
    background: var(--color-soft);
    color: var(--color-text);
}

.cms-color-panel__row {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 28px;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 10px;
    transition: background-color var(--transition-fast);
}
.cms-color-panel__row:hover { background: var(--color-soft); }

.cms-color-panel__swatch {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(20, 38, 28, 0.14);
    transition: box-shadow var(--transition-fast);
}
.cms-color-panel__swatch:focus-within {
    box-shadow: inset 0 0 0 1px rgba(20, 38, 28, 0.14), 0 0 0 3px var(--color-white), 0 0 0 5px var(--color-primary);
}

/* Invisible native input over the swatch opens the system picker. */
.cms-color-panel__input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    opacity: 0;
    cursor: pointer;
}

.cms-color-panel__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    cursor: pointer;
}

.cms-color-panel__line {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
}

.cms-color-panel__name {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text);
}

.cms-color-panel__hex {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    color: var(--color-text-soft);
}

.cms-color-panel__hint {
    font-size: var(--text-xs);
    line-height: 1.35;
    color: var(--color-text-soft);
}

.cms-color-panel__reset {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--color-text-soft);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}
.cms-color-panel__reset:hover {
    background: var(--color-white);
    color: var(--color-text);
}

.cms-color-panel__reset-all {
    margin: 4px 10px 6px;
    padding: 10px 0 2px;
    border: 0;
    border-top: 1px solid var(--color-border);
    background: none;
    color: var(--color-text-soft);
    font-size: var(--text-xs);
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: color var(--transition-fast);
}
.cms-color-panel__reset-all:hover { color: var(--color-primary-dark); }

/* The display rules above would otherwise override the hidden attribute. */
.cms-color-panel__reset[hidden],
.cms-color-panel__reset-all[hidden] { display: none; }

.cms-color-panel__close:focus-visible,
.cms-color-panel__reset:focus-visible,
.cms-color-panel__reset-all:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

.cms-color-panel__warning {
    margin: 0 var(--space-3) var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius);
    background: rgba(179, 59, 59, 0.10);
    font-size: var(--text-sm);
    color: var(--color-error);
}
