/* ─── In Space Universe — CMS inline editor styles ───
   Loaded only when the editor.js detects an active admin session.
   Public visitors never see any of this. */

/* Floating editor bar at the BOTTOM of the page when admin is active */
.isu-cms-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 44px;
    background: #1f2f26;
    color: #f1ede4;
    z-index: 99999;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
    font-size: 13px;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s;
}
.isu-cms-bar.is-hidden { transform: translateY(100%); }

.isu-cms-bar-brand {
    font-weight: 600;
    letter-spacing: 0.05em;
}
.isu-cms-bar-brand::before {
    content: "●";
    color: #f5c98e;
    margin-right: 8px;
    font-size: 14px;
}

.isu-cms-bar-status {
    color: #b8c5b8;
    flex: 1;
}

.isu-cms-bar-button {
    background: transparent;
    border: 1px solid rgba(241, 237, 228, 0.25);
    color: #f1ede4;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-family: inherit;
}
.isu-cms-bar-button:hover {
    background: rgba(241, 237, 228, 0.1);
    border-color: rgba(241, 237, 228, 0.45);
}
.isu-cms-bar-button.primary {
    background: #f5c98e;
    color: #1f2f26;
    border-color: #f5c98e;
    font-weight: 600;
}
.isu-cms-bar-button.primary:hover {
    background: #f0bd75;
}
.isu-cms-bar-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.isu-cms-bar-badge {
    background: #f5c98e;
    color: #1f2f26;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 4px;
}
.isu-cms-bar-badge[data-count="0"] { display: none; }

/* Push the page content up to make room for the bottom editor bar */
body.isu-cms-active { padding-bottom: 44px !important; }

/* Push the storefront's floating cart trigger up above the editor bar
 * so it doesn't get hidden behind it. Also nudges Preston (bottom-right
 * via plugins/astro.css) — both buttons clear the bar by 12px. */
body.isu-cms-active .store-cart-trigger { bottom: calc(28px + 44px) !important; }
@media (max-width: 700px) {
    body.isu-cms-active .store-cart-trigger { bottom: calc(20px + 44px) !important; }
}

/* Subtle outline on every editable block (only when editor is active) */
body.isu-cms-active [data-cms-id] {
    outline: 1px dashed rgba(124, 196, 240, 0);
    outline-offset: 4px;
    border-radius: 2px;
    transition: outline-color 0.15s, background 0.15s;
    cursor: text;
    position: relative;
}
body.isu-cms-active [data-cms-id]:hover {
    outline-color: rgba(124, 196, 240, 0.7);
    background: rgba(124, 196, 240, 0.05);
}
body.isu-cms-active [data-cms-id][data-cms-editing="true"] {
    outline: 2px solid #7cc4f0;
    outline-offset: 4px;
    background: rgba(124, 196, 240, 0.08);
    cursor: text;
}
body.isu-cms-active [data-cms-id][data-cms-dirty="true"] {
    outline-color: #f5c98e;
}
body.isu-cms-active [data-cms-id][data-cms-saving="true"] {
    outline-color: #b8c5b8;
}
body.isu-cms-active [data-cms-id][data-cms-saved="true"] {
    outline-color: rgba(124, 196, 240, 0.4);
    transition: outline-color 1.2s ease-out;
}

/* Floating per-block label that shows the cms-id on hover/focus */
body.isu-cms-active [data-cms-id]:hover::before,
body.isu-cms-active [data-cms-id][data-cms-editing="true"]::before {
    content: attr(data-cms-id);
    position: absolute;
    top: -18px;
    left: 0;
    background: #1f2f26;
    color: #f1ede4;
    font-size: 10px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 99998;
    letter-spacing: 0.02em;
}

/* Toast for save confirmations / errors — at top so it clears the bottom bar */
.isu-cms-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-12px);
    background: #1f2f26;
    color: #f1ede4;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
    z-index: 99999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.isu-cms-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.isu-cms-toast.is-error { background: #8a3a3a; }

/* ─────────────────────────────────────────────────────────────
   RICH TEXT TOOLBAR — sits above the CMS bar at the bottom.
   Visible only when an editable block is focused.
   ───────────────────────────────────────────────────────────── */
.isu-cms-toolbar {
    position: fixed;
    bottom: 44px;  /* above the CMS bar */
    left: 0;
    right: 0;
    background: #2a3d31;
    border-top: 1px solid #1f2f26;
    border-bottom: 1px solid rgba(241, 237, 228, 0.08);
    z-index: 99998;
    display: none;
    align-items: center;
    padding: 0 12px;
    gap: 4px;
    height: 44px;
    font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.12);
    overflow: visible;
}
.isu-cms-toolbar.is-visible { display: flex; }

/* Bump the body padding when toolbar is showing */
body.isu-cms-active:has(.isu-cms-toolbar.is-visible) { padding-bottom: 88px !important; }
body.isu-cms-active:has(.isu-cms-toolbar.is-visible) .store-cart-trigger {
    bottom: calc(28px + 88px) !important;
}
@media (max-width: 700px) {
    body.isu-cms-active:has(.isu-cms-toolbar.is-visible) .store-cart-trigger {
        bottom: calc(20px + 88px) !important;
    }
}

.isu-tb-group { display: flex; gap: 2px; }
.isu-tb-divider { width: 1px; height: 22px; background: rgba(241, 237, 228, 0.15); margin: 0 6px; }
.isu-tb-spacer { flex: 1; }

.isu-tb-btn {
    background: transparent;
    border: none;
    color: #f1ede4;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s;
    padding: 0;
}
.isu-tb-btn:hover { background: rgba(241, 237, 228, 0.12); }
.isu-tb-btn.is-active { background: #f5c98e; color: #1f2f26; }
.isu-tb-btn b, .isu-tb-btn i, .isu-tb-btn u, .isu-tb-btn s { display: inline-block; }
.isu-tb-popover-btn { width: auto; padding: 0 8px; }
.isu-tb-caret { font-size: 9px; margin-left: 2px; opacity: 0.7; }
.isu-tb-color-icon {
    text-decoration: underline;
    text-decoration-color: #f5c98e;
    text-decoration-thickness: 3px;
    text-underline-offset: 2px;
}

.isu-tb-select {
    background: transparent;
    border: 1px solid rgba(241, 237, 228, 0.18);
    color: #f1ede4;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    height: 28px;
}
.isu-tb-select:focus { outline: 1px solid #f5c98e; outline-offset: 1px; }
.isu-tb-select option { background: #1f2f26; color: #f1ede4; }

.isu-tb-done {
    background: #f5c98e;
    color: #1f2f26;
    border: none;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.12s;
}
.isu-tb-done:hover { background: #f0bd75; }

/* Popovers — anchored above the toolbar.
   Use position:fixed (not absolute) to avoid any containing-block weirdness
   from the flex toolbar. CMS bar (44px) + toolbar (44px) + 8px gap = 96px. */
.isu-tb-popover {
    position: fixed;
    bottom: 96px;
    left: 50%;
    transform: translateX(-50%);
    background: #2a3d31;
    border: 1px solid rgba(241, 237, 228, 0.15);
    border-radius: 6px;
    padding: 12px;
    min-width: 260px;
    max-width: calc(100vw - 24px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    display: none;
    z-index: 99999;
}
.isu-tb-popover.is-open { display: block; }
.isu-tb-popover-title {
    color: #b8c5b8;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}
.isu-tb-popover-divider {
    height: 1px;
    background: rgba(241, 237, 228, 0.1);
    margin: 12px 0;
}
.isu-tb-list { display: flex; flex-direction: column; gap: 2px; }
.isu-tb-font-option {
    background: transparent;
    border: none;
    color: #f1ede4;
    text-align: left;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}
.isu-tb-font-option:hover { background: rgba(241, 237, 228, 0.08); }

.isu-tb-swatch-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}
.isu-tb-color-swatch {
    width: 32px;
    height: 32px;
    border: 2px solid rgba(241, 237, 228, 0.15);
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    transition: transform 0.1s, border-color 0.12s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.isu-tb-color-swatch:hover { transform: scale(1.08); border-color: #f5c98e; }
.isu-tb-custom-color-row { display: flex; align-items: center; gap: 8px; }
.isu-tb-custom-color {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
}
.isu-tb-custom-color-row label { color: #b8c5b8; font-size: 12px; }
.isu-tb-custom-input {
    width: 100%;
    background: rgba(241, 237, 228, 0.05);
    border: 1px solid rgba(241, 237, 228, 0.15);
    border-radius: 4px;
    padding: 6px 10px;
    color: #f1ede4;
    font-family: inherit;
    font-size: 13px;
    box-sizing: border-box;
}
.isu-tb-custom-input:focus {
    outline: none;
    border-color: #f5c98e;
}
.isu-tb-hint { color: #7a8a82; font-size: 11px; margin-top: 4px; }

/* Table picker — 8x8 grid of cells, drag-to-size */
.isu-tb-table-grid {
    display: grid;
    grid-template-columns: repeat(8, 18px);
    grid-auto-rows: 18px;
    gap: 2px;
}
.isu-tb-table-cell {
    background: rgba(241, 237, 228, 0.08);
    border: 1px solid rgba(241, 237, 228, 0.15);
    cursor: pointer;
    transition: background 0.08s;
}
.isu-tb-table-cell.hover {
    background: #f5c98e;
    border-color: #f5c98e;
}
.isu-tb-table-size {
    color: #b8c5b8;
    font-size: 12px;
    margin-top: 8px;
    text-align: center;
}

/* ─── Editable content styles — applied to whatever lands inside [data-cms-id] ─── */
[data-cms-id] .isu-cms-table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
}
[data-cms-id] .isu-cms-table td {
    border: 1px solid rgba(31, 47, 38, 0.2);
    padding: 8px 10px;
    min-width: 60px;
    vertical-align: top;
}
[data-cms-id] img {
    max-width: 100%;
    height: auto;
    display: inline-block;
    border-radius: 4px;
}
[data-cms-id] a {
    color: #2f5d7a;
    text-decoration: underline;
}
[data-cms-id] ul, [data-cms-id] ol {
    padding-left: 24px;
    margin: 8px 0;
}
[data-cms-id] blockquote {
    border-left: 3px solid #f5c98e;
    padding-left: 14px;
    margin: 12px 0;
    color: #4a5d52;
    font-style: italic;
}
