/* ===================================================================
   Visual editor chrome.

   Only ever applied inside .cms-canvas, which the live editor wraps the page in. Nothing here
   can reach the public site, and the page inside the canvas keeps its own styling — the point of
   editing in place is that what you edit still looks like what a visitor sees.
   =================================================================== */

/* ---- Editor shell ------------------------------------------------ */

.cms-editor__bar {
    position: sticky;
    top: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 52px;
    padding: 0 16px;
    background: #14213D;
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}

.cms-editor__back {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 18px;
    text-decoration: none;
}

.cms-editor__back:hover { background: rgba(255, 255, 255, .24); }

.cms-editor__title { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.cms-editor__title strong { font-size: .92rem; }
.cms-editor__title span { font-size: .72rem; opacity: .6; }

.cms-editor__lang { display: flex; gap: 4px; margin-inline-start: auto; }

.cms-editor__lang button {
    min-width: 38px;
    height: 30px;
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 4px;
    background: transparent;
    color: #fff;
    font-size: .76rem;
    font-weight: 700;
    cursor: pointer;
}

.cms-editor__lang button.is-active { background: #0FA3C4; border-color: #0FA3C4; }

.cms-editor__actions { display: flex; gap: 14px; }

.cms-editor__actions a { color: #fff; font-size: .78rem; font-weight: 600; text-decoration: none; opacity: .85; }
.cms-editor__actions a:hover { opacity: 1; text-decoration: underline; }

.cms-editor__loading { padding: 80px 24px; text-align: center; color: #5B6567; }

/* ---- Image picker ------------------------------------------------ */

.cms-picker {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: grid;
    place-items: center;
    background: rgba(6, 46, 58, .55);
}

.cms-picker__panel {
    width: min(460px, calc(100vw - 40px));
    padding: 24px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .6);
}

.cms-picker__panel h3 { margin: 0 0 18px; font-size: 1.1rem; color: #14213D; }

.cms-picker__panel label {
    display: block;
    margin-bottom: 16px;
    font-size: .78rem;
    font-weight: 600;
    color: #4A5568;
}

.cms-picker__panel input[type="text"] {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid #D3DCE1;
    border-radius: 4px;
    font: inherit;
}

.cms-picker__error { margin: 0 0 12px; color: #C0392B; font-size: .8rem; }

.cms-picker__actions { display: flex; justify-content: flex-end; gap: 8px; }

.cms-picker__actions button {
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 4px;
    font: inherit;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
}

.cms-picker__actions .is-ghost { border-color: #D3DCE1; background: #fff; color: #4A5568; }
.cms-picker__actions .is-danger { background: #FDECEA; color: #C0392B; }
.cms-picker__actions .is-primary { background: #0FA3C4; color: #fff; }

.cms-canvas { position: relative; }

/* ---- Editable text ---------------------------------------------- */

.cms-canvas .cms-editable {
    outline: 1px dashed transparent;
    outline-offset: 3px;
    border-radius: 2px;
    transition: outline-color .15s ease, background-color .15s ease;
    cursor: text;
}

.cms-canvas .cms-editable:hover { outline-color: rgba(15, 163, 196, .55); }

.cms-canvas .cms-editable:focus {
    outline: 2px solid #0FA3C4;
    background: rgba(15, 163, 196, .06);
}

/* An empty field has no height of its own, so it needs the placeholder to be clickable at all. */
.cms-canvas .cms-editable--empty::before {
    content: attr(data-placeholder);
    color: #9AA5AD;
    font-style: italic;
}

.cms-canvas .cms-editable--empty:focus::before { content: none; }

.cms-canvas .cms-editable--html { min-height: 1.6em; }

/* ---- Rich-text toolbar ------------------------------------------- */

.cms-canvas .cms-rte-bar {
    position: sticky;
    bottom: 12px;
    z-index: 30;
    display: inline-flex;
    gap: 2px;
    padding: 4px;
    margin-top: 6px;
    background: #14213D;
    border-radius: 6px;
    box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .5);
}

.cms-canvas .cms-rte-bar button {
    min-width: 30px;
    height: 28px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
}

.cms-canvas .cms-rte-bar button:hover { background: rgba(255, 255, 255, .18); }

/* ---- Editable images --------------------------------------------- */

.cms-canvas .cms-image { position: relative; display: block; cursor: pointer; }

.cms-canvas .cms-image img { display: block; }

.cms-canvas .cms-image__badge {
    position: absolute;
    inset-inline-end: 8px;
    inset-block-start: 8px;
    padding: 4px 10px;
    border-radius: 3px;
    background: rgba(20, 33, 61, .88);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity .15s ease;
    pointer-events: none;
}

.cms-canvas .cms-image:hover .cms-image__badge { opacity: 1; }

.cms-canvas .cms-image:hover img { filter: brightness(.82); }

.cms-canvas .cms-image--empty {
    display: grid;
    place-items: center;
    min-height: 160px;
    border: 2px dashed rgba(15, 163, 196, .5);
    border-radius: 6px;
    background: rgba(15, 163, 196, .05);
}

.cms-canvas .cms-image__hint { color: #0FA3C4; font-weight: 600; font-size: .86rem; }

/* ---- Block chrome ------------------------------------------------ */

.cms-block { position: relative; }

.cms-block::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    outline: 2px solid transparent;
    outline-offset: -2px;
    transition: outline-color .15s ease;
}

.cms-block:hover::after { outline-color: rgba(15, 163, 196, .45); }

.cms-block.is-selected::after { outline-color: #0FA3C4; }

/* Dropped opacity while a block is mid-drag, so the gap it will leave is readable. */
.cms-block.is-dragging { opacity: .4; }

.cms-block.is-drop-target::after { outline: 3px dashed #FFD41D; outline-offset: -3px; }

.cms-block__bar {
    position: absolute;
    top: 8px;
    inset-inline-start: 8px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border-radius: 6px;
    background: rgba(20, 33, 61, .94);
    box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .6);
    opacity: 0;
    transition: opacity .15s ease;
}

.cms-block:hover .cms-block__bar,
.cms-block.is-selected .cms-block__bar { opacity: 1; }

.cms-block__bar button {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
}

.cms-block__bar button:hover { background: rgba(255, 255, 255, .18); }

.cms-block__bar button.is-danger:hover { background: #C0392B; }

.cms-block__bar .cms-block__name {
    padding: 0 10px 0 6px;
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.cms-block__bar .cms-block__grip { cursor: grab; }

/* A hidden block still has to be reachable in the editor, so it is dimmed rather than removed. */
.cms-block.is-hidden { opacity: .45; }

.cms-block.is-hidden::before {
    content: "Hidden from the live site";
    position: absolute;
    top: 8px;
    inset-inline-end: 8px;
    z-index: 20;
    padding: 4px 10px;
    border-radius: 3px;
    background: #B7791F;
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
}

/* ---- Repeater items ---------------------------------------------- */

.cms-canvas .cms-item { position: relative; }

.cms-canvas .cms-item.is-dragging { opacity: .4; }

.cms-canvas .cms-item.is-drop-target { outline: 3px dashed #FFD41D; outline-offset: 2px; }

/* The solution band's grid.
   EditableItem renders nothing of its own on the public site, so .sols lays out the
   .sol-card elements directly and their grid-column rules place them: three across,
   then two centred underneath. In the editor the wrapper exists and becomes the grid
   item instead, so those rules address an element that is no longer being placed —
   five wrappers fall into six auto-sized columns and the band comes out ragged.
   The wrapper takes the placement here, and passes the height back to the card. */
.cms-canvas .sols > .cms-item { grid-column: span 2; display: flex; }
.cms-canvas .sols > .cms-item:nth-child(4) { grid-column: 2 / span 2; }
.cms-canvas .sols > .cms-item:nth-child(5) { grid-column: 4 / span 2; }
.cms-canvas .sols > .cms-item > .sol-card { flex: 1; }

.cms-canvas .cms-item__grip {
    position: absolute;
    top: 4px;
    inset-inline-start: 4px;
    z-index: 15;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 4px;
    background: rgba(20, 33, 61, .9);
    color: #fff;
    cursor: grab;
    opacity: 0;
    transition: opacity .15s ease;
}

.cms-canvas .cms-item:hover .cms-item__grip { opacity: 1; }

.cms-canvas .cms-item__remove {
    position: absolute;
    top: 4px;
    inset-inline-end: 4px;
    z-index: 15;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 4px;
    background: rgba(192, 57, 43, .92);
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s ease;
}

.cms-canvas .cms-item:hover .cms-item__remove { opacity: 1; }

/* ---- Save indicator ---------------------------------------------- */

.cms-status {
    position: fixed;
    inset-block-end: 20px;
    inset-inline-end: 20px;
    z-index: 1400;
    padding: 10px 18px;
    border-radius: 4px;
    font-size: .82rem;
    font-weight: 600;
    color: #fff;
    box-shadow: 0 14px 30px -14px rgba(0, 0, 0, .6);
}

.cms-status--saving { background: #14213D; }
.cms-status--saved { background: #2F855A; }
.cms-status--error { background: #C0392B; }

/* Amber rather than green or red: work that is held is neither finished nor wrong. */
.cms-status--pending { background: #B7791F; }

/* ---- Save and discard ---------------------------------------------

   Nothing an editor does reaches the server until Save, which makes this the most consequential
   control on the screen and the reason it is the loudest. It goes quiet — flat, and disabled —
   the moment there is nothing held, so that "Saved" and "Save (3)" cannot be mistaken for each
   other at a glance. */

.cms-editor__save {
    font: inherit;
    font-weight: 700;
    padding: 6px 16px;
    border: 0;
    border-radius: 4px;
    background: #B7791F;
    color: #fff;
    cursor: pointer;
}

.cms-editor__save:disabled {
    background: transparent;
    color: rgba(255, 255, 255, .55);
    cursor: default;
}

.cms-editor__discard {
    font: inherit;
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 4px;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

.cms-editor__discard:hover { border-color: #fff; }

/* The step after saving: what is stored becomes what visitors see. */
.cms-editor__publish {
    font: inherit;
    font-weight: 700;
    padding: 6px 16px;
    border: 0;
    border-radius: 4px;
    background: var(--teal, #0A89AA);
    color: #fff;
    cursor: pointer;
}
.cms-editor__publish:disabled { opacity: .6; cursor: default; }

/* ---- Touch and small screens -------------------------------------

   The block bar is revealed on hover, which does not exist on a touch device: every control on
   it — reorder, hide, add item, change the image — was simply unreachable from a phone. Anywhere the
   pointer cannot hover, the bar is always shown instead. */

@media (hover: none) {
    .cms-block__bar { opacity: 1; }
}

@media (max-width: 720px) {
    /* Two rows rather than one cramped line, and no fixed height to squeeze them into. */
    .cms-editor__bar {
        height: auto;
        flex-wrap: wrap;
        gap: 8px 12px;
        padding: 8px 12px;
    }

    .cms-editor__lang { margin-inline-start: 0; order: 3; }
    .cms-editor__actions { order: 4; flex-wrap: wrap; gap: 10px; width: 100%; }
    .cms-editor__title strong { font-size: .84rem; }

    /* Above the block rather than floating over its first line, where it covered the heading it
       was meant to be labelling. */
    .cms-block__bar {
        position: static;
        opacity: 1;
        flex-wrap: wrap;
        margin: 0 0 8px;
        border-radius: 0 0 6px 6px;
    }

    .cms-block__bar .cms-block__name {
        flex: 1 0 100%;
        padding: 2px 6px;
        white-space: normal;
    }

    /* Comfortably tappable: 28px is under the ~44px a finger needs. */
    .cms-block__bar button {
        width: 40px;
        height: 40px;
        font-size: 17px;
    }

    .cms-status { inset-inline: 12px; text-align: center; }
}

/* ---- Backdrop images ----------------------------------------------

   The hero, sub-page header and call-to-action band all lay copy over a photograph. The picture
   fills the band, a gradient scrim covers the picture, and the text column covers both — so a
   click aimed at the photograph lands on whatever is stacked above it and the image could not be
   changed at all. Two things fix it: the scrim stops taking clicks (it is pure decoration), and
   the button below floats above everything. */

.cms-canvas .hero-bg::after,
.cms-canvas .subhero-bg::after,
.cms-canvas .cta-bg::after { pointer-events: none; }

.cms-image__overlay {
    position: absolute;
    top: 12px;
    inset-inline-end: 12px;
    z-index: 30;
    padding: 8px 14px;
    border: 0;
    border-radius: 6px;
    background: rgba(20, 33, 61, .94);
    color: #fff;
    font: inherit;
    font-size: .78rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .6);
}

.cms-image__overlay:hover { background: #0FA3C4; }

/* The band has to be a positioning context, or the button escapes to the page. */
.cms-canvas .hero,
.cms-canvas .subhero,
.cms-canvas .cta { position: relative; }

@media (max-width: 720px) {
    .cms-image__overlay { top: 8px; inset-inline-end: 8px; padding: 10px 12px; }
}

/* Status and version, on the block bar. */
.cms-block__bar .cms-block__state,
.cms-block__bar .cms-block__versions {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .64rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.cms-block__state--p { background: rgba(46, 160, 67, .28); color: #9BE7AE; }
.cms-block__state--d { background: rgba(255, 212, 29, .22); color: #FFD41D; }
.cms-block__state--pending { background: #FFD41D; color: #14213D; }
.cms-block__state--hidden { background: rgba(255, 255, 255, .82); color: #14213D; }
.cms-block__versions { background: rgba(255, 255, 255, .14); color: #fff; }

/* Let the backdrop bands stop trapping their own contents.

   .hero-bg and friends are positioned with z-index:0, which makes each a stacking context: every
   descendant is then confined below whatever the band's own layer sits under, no matter how high
   its z-index. That is why an overlay button rendered inside the image stayed buried under the
   text column. z-index:auto keeps a positioned element out of that trap while leaving the paint
   order alone, because these bands still come before the copy in the markup. */

.cms-canvas .hero-bg,
.cms-canvas .subhero-bg,
.cms-canvas .cta-bg { z-index: auto; }

/* The page's versions, in the editor bar. A native select for the same reason the bar's other
   controls are plain elements: this editor has to keep working when popover rendering does not. */
.cms-editor__versions {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.cms-editor__vlabel {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.7;
}

.cms-editor__vselect {
    max-width: 240px;
    padding: 5px 8px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.12);
    color: inherit;
    font: inherit;
    font-size: 0.8rem;
}

/* The list is painted by the operating system on its own surface — without this the options are
   white on white. */
.cms-editor__vselect option { color: #2A2E30; background: #FFFFFF; }

.cms-editor__vselect:focus-visible { outline: 2px solid #FFD41D; outline-offset: 1px; }

@media (max-width: 900px) {
    .cms-editor__vlabel { display: none; }

    .cms-editor__vselect { max-width: 150px; }
}

/* Activate and Add version, beside the picker. Plain buttons in the bar's own ink, like every
   other control here. */
.cms-editor__vbtn {
    flex: none;
    padding: 5px 10px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.12);
    color: inherit;
    font: inherit;
    font-size: 0.78rem;
    white-space: nowrap;
    cursor: pointer;
}

.cms-editor__vbtn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.24); }

.cms-editor__vbtn:disabled { opacity: 0.55; cursor: default; }

/* The one that changes the page carries the weight; the other two are ordinary. */
.cms-editor__vbtn--go {
    border-color: #FFD41D;
    background: #FFD41D;
    color: #2A2E30;
    font-weight: 700;
}

.cms-editor__vbtn--go:hover:not(:disabled) { background: #FFE05C; }

.cms-editor__vbtn:focus-visible { outline: 2px solid #FFD41D; outline-offset: 1px; }

.cms-editor__vname {
    width: 180px;
    padding: 5px 8px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 6px;
    background: #FFFFFF;
    color: #2A2E30;
    font: inherit;
    font-size: 0.8rem;
}

.cms-editor__vname:focus-visible { outline: 2px solid #FFD41D; outline-offset: 1px; }

@media (max-width: 900px) {
    .cms-editor__vname { width: 130px; }
}

/* ---- Restore points in the editor -------------------------------------
   The panel itself is styled in app.css, shared with the structure screen. These two rules are
   only about how the editor hosts it: a button in the bar, and a wider panel than the image
   picker because a diff needs the room. */

.cms-editor__hist {
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.cms-editor__hist:hover { background: rgba(255, 255, 255, .12); }

.cms-picker__panel--wide { width: min(720px, calc(100vw - 40px)); }
