/* Social canvas editor fonts are registered at runtime (SC_<family> aliases) from the font endpoint
   via the Font Loading API - see LoadFonts in Editor.razor and socialCanvas.loadFont. There are no
   static @font-face rules here: the same DB-served bytes back both the editor and the PNG renderer. */

.social-canvas-viewport {
    overflow: auto;
    background: #4a4f55;
    padding: 24px;
    outline: none; /* focusable for keyboard shortcuts, but no focus ring on the big grey area */
    flex: 1 1 auto;
    min-height: 0;
}

.social-canvas-editor {
    display: flex;
    gap: 12px;
    align-items: stretch;
    height: calc(100vh - 200px);
    min-height: 500px;
}

.social-canvas-swatch {
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 1px solid #999;
    border-radius: 3px;
    cursor: pointer;
    margin-right: 4px;
    vertical-align: middle;
}

.social-canvas-toolbar {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    padding: 6px 0;
}

.social-canvas-toolbar .button {
    margin-bottom: 0;
}

/* ---- Full-screen editor shell (Canva-style layout) --------------------------------------- */
.sc-editor {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #f0f1f3;
}

.sc-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 54px;
    flex: 0 0 54px;
    padding: 0 14px;
    background: #fff;
    border-bottom: 1px solid #e3e3e6;
    z-index: 30;
}

.sc-burger {
    font-size: 20px;
    color: #333;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
}

.sc-burger:hover {
    background: #f2f2f4;
}

.sc-name {
    border: 1px solid transparent !important;
    background: transparent !important;
    box-shadow: none !important;
    font-weight: 600;
    font-size: 16px;
    width: 260px;
    margin: 0 !important;
    height: 38px;
    padding: 0 8px !important;
}

.sc-name:hover,
.sc-name:focus {
    border-color: #e3e3e6 !important;
}

.sc-topbar .spacer {
    flex: 1 1 auto;
}

.sc-body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
}

/* Reserved contextual bar under the top bar - always present, so selecting never shifts the canvas. */
.sc-context-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 52px;
    flex: 0 0 52px;
    padding: 0 14px;
    background: #fff;
    border-bottom: 1px solid #e3e3e6;
    z-index: 25;
    overflow-x: auto;
}

.sc-context-hint {
    color: #9aa3ad;
    font-size: 13px;
}

.sc-ctl {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    border: 1px solid #e3e3e6;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    white-space: nowrap;
}

.sc-ctl:hover {
    background: #f2f2f4;
}

.sc-ctl.active {
    background: #efe9ff;
    border-color: #b9a3ff;
    color: #5b3ee0;
}

.sc-ctl-wide {
    min-width: 130px;
    justify-content: space-between;
}

.sc-colour-chip {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid #ccc;
    display: inline-block;
}

/* Left-docked options panel: overlays the stage's left edge (right of the rail) rather than taking layout
   space, so the centered canvas never shifts. On a portrait canvas it sits in the empty left margin. */
.sc-panel {
    position: absolute;
    left: 88px; /* == .sc-rail width */
    top: 0;
    bottom: 0;
    width: 300px;
    background: #fff;
    border-right: 1px solid #e3e3e6;
    box-shadow: 2px 0 14px rgba(0, 0, 0, .14);
    display: flex;
    flex-direction: column;
    z-index: 30;
    min-height: 0;
}

.sc-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    font-weight: 600;
    font-size: 14px;
}

.sc-panel-body {
    padding: 12px;
    overflow-y: auto;
    flex: 1 1 auto;
}

.sc-panel-body > label {
    display: block;
    font-size: 12px;
    color: #666;
    margin: 12px 0 4px;
}

.sc-panel-body > label:first-child {
    margin-top: 0;
}

.sc-btn-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

/* Align / distribute controls (Position panel, multi-selection) */
.sc-align-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin: 4px 0 10px;
}

.sc-align-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-start;
    padding: 8px 10px;
    border: 1px solid #e3e3e6;
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
    color: #1d1d1f;
    cursor: pointer;
    text-align: left;
}

.sc-align-btn:hover:not(:disabled) {
    background: #f2f2f4;
    border-color: #c9c9cf;
}

.sc-align-btn:disabled {
    opacity: .4;
    cursor: default;
}

.sc-align-btn i {
    width: 16px;
    text-align: center;
    color: #6b6b70;
}

.sc-font-list {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 8px;
}

.sc-font-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border: none;
    border-bottom: 1px solid #f2f2f4;
    background: #fff;
    cursor: pointer;
    font-size: 15px;
}

.sc-font-item:hover {
    background: #f7f7f9;
}

.sc-font-item.active {
    background: #efe9ff;
    color: #5b3ee0;
}

/* Colour picker: hex input + circular swatch grids (Canva-style). */
.sc-hex-input {
    width: 100%;
    margin: 0;
}

.sc-swatch-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}

.sc-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid #ddd;
    padding: 0;
    cursor: pointer;
    position: relative;
    box-sizing: border-box;
}

.sc-swatch:hover {
    transform: scale(1.06);
}

.sc-swatch.active {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #5b3ee0;
}

.sc-swatch-custom {
    background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.sc-swatch-custom i {
    background: #fff;
    color: #333;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.sc-swatch-custom input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.sc-swatch-tool {
    background: #fff;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sc-rail {
    flex: 0 0 88px;
    background: #fff;
    border-right: 1px solid #e3e3e6;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 0;
    z-index: 20;
}

.sc-rail button {
    width: 68px;
    height: 66px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    color: #444;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.sc-rail button:hover {
    background: #f2f2f4;
}

.sc-rail button i {
    font-size: 20px;
}

.sc-stage {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    background: #4a4f55;
    outline: none;
}

.sc-stage-scroll {
    position: absolute;
    inset: 0;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    transition: padding-left .15s ease;
}

/* When the panel would cover the canvas, offset the centring so the canvas sits in the space beside the
   panel (348 = 300 panel width + the 48 base margin). */
.sc-stage-scroll.sc-shifted {
    padding-left: 348px;
}

/* Floating contextual toolbar - sits over the canvas near the top, Canva-style. */
.sc-floating-toolbar {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    max-width: calc(100% - 32px);
}

/* Bottom-right zoom control with a slider and fit-to-screen. */
.sc-zoom {
    position: absolute;
    right: 16px;
    bottom: 16px;
    z-index: 25;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid #e3e3e6;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
    padding: 6px 12px;
}

.sc-zoom input[type="range"] {
    width: 130px;
    margin: 0;
}

.sc-zoom .sc-zoom-value {
    font-size: 13px;
    color: #333;
    width: 42px;
    text-align: right;
}

.sc-zoom button {
    border: 1px solid #e3e3e6;
    background: #fff;
    border-radius: 8px;
    height: 32px;
    padding: 0 10px;
    font-size: 13px;
    cursor: pointer;
    color: #333;
}

.sc-zoom button:hover {
    background: #f2f2f4;
}

/* Bottom-left page navigator for multi-page (carousel) canvases. */
.sc-pagebar {
    position: absolute;
    left: 16px;
    bottom: 16px;
    z-index: 25;
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: calc(100% - 260px);
    overflow-x: auto;
    background: #fff;
    border: 1px solid #e3e3e6;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
    padding: 6px 8px;
}

.sc-pagebar button {
    border: 1px solid #e3e3e6;
    background: #fff;
    border-radius: 8px;
    height: 30px;
    min-width: 30px;
    padding: 0 8px;
    font-size: 13px;
    cursor: pointer;
    color: #333;
    flex: 0 0 auto;
}

.sc-pagebar button:hover {
    background: #f2f2f4;
}

.sc-pagebar button:disabled {
    opacity: .4;
    cursor: default;
}

.sc-pagebar .sc-page.active {
    background: #00B0FF;
    border-color: #00B0FF;
    color: #fff;
    font-weight: 600;
}

.sc-pagebar-sep {
    width: 1px;
    height: 20px;
    background: #e3e3e6;
    margin: 0 2px;
    flex: 0 0 auto;
}

/* Top-centre bar shown while inline-editing text, for highlighting a selected run. */
.sc-highlight-bar {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #e3e3e6;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
    padding: 6px 12px;
}

.sc-highlight-bar .sc-highlight-label {
    font-size: 13px;
    color: #333;
    font-weight: 600;
}

.sc-highlight-bar .social-canvas-swatch.active {
    outline: 2px solid #00B0FF;
    outline-offset: 1px;
}

/* Popover for canvas background / image replace, anchored off the left rail. */
.sc-popover {
    position: absolute;
    left: 96px;
    top: 12px;
    z-index: 30;
    width: 280px;
    background: #fff;
    border: 1px solid #e3e3e6;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
    padding: 14px;
}

.sc-popover h4 {
    font-size: 14px;
    margin: 0 0 8px;
}

/* Canva-style contextual text toolbar - a rounded pill of the controls the renderer can honour.
   Deliberately excludes italic/underline/strike: the ImageSharp renderer supports bold only, and a
   button that changed the editor but not the exported PNG would break WYSIWYG. */
.social-canvas-textbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background: #fff;
    border: 1px solid #e3e3e6;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
    padding: 8px 12px;
    margin: 8px 0;
}

.social-canvas-textbar select,
.social-canvas-textbar .textbar-size-value {
    height: 40px;
    border: 1px solid #e3e3e6;
    border-radius: 8px;
    background: #fff;
    font-size: 15px;
    padding: 0 12px;
}

.social-canvas-textbar select {
    min-width: 150px;
}

.social-canvas-size {
    display: flex;
    align-items: center;
    border: 1px solid #e3e3e6;
    border-radius: 8px;
    overflow: hidden;
    height: 40px;
}

.social-canvas-size button {
    width: 38px;
    height: 40px;
    border: none;
    background: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: #333;
}

.social-canvas-size button:hover {
    background: #f2f2f4;
}

.social-canvas-size input {
    width: 56px;
    height: 40px;
    border: none;
    border-left: 1px solid #e3e3e6;
    border-right: 1px solid #e3e3e6;
    text-align: center;
    font-size: 15px;
    margin: 0;
}

.social-canvas-iconbtn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e3e3e6;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 17px;
    color: #333;
}

.social-canvas-iconbtn:hover {
    background: #f2f2f4;
}

.social-canvas-iconbtn.active {
    background: #e9e2ff;
    border-color: #8b5cf6;
    color: #6d28d9;
}

.social-canvas-textbar .textbar-colour {
    width: 40px;
    height: 40px;
    padding: 2px;
    border: 1px solid #e3e3e6;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.social-canvas-textbar .textbar-divider {
    width: 1px;
    align-self: stretch;
    background: #e3e3e6;
    margin: 2px 2px;
}

/* ---- Right-hand layers rail -------------------------------------------------------------
   A flex sibling of .sc-stage (not an overlay like .sc-panel), so it narrows the canvas rather
   than covering it and can stay open while a left-docked options panel is in use. */
.sc-layers {
    flex: 0 0 262px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fff;
    border-left: 1px solid #e3e3e6;
    font-size: 13px;
}

.sc-layers-head {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 8px 10px 12px;
    border-bottom: 1px solid #eee;
    font-weight: 600;
    font-size: 14px;
}

.sc-layers-head .spacer {
    flex: 1 1 auto;
}

.sc-layers-list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 4px 0 12px;
}

.sc-layers-foot {
    border-top: 1px solid #eee;
    padding: 8px 12px 10px;
}

.sc-layers-foot label {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.sc-layers-foot select {
    margin: 0;
    height: 32px;
    font-size: 13px;
}

/* Floating re-open button when the rail is hidden. */
.sc-layers-show {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 40;
    background: #fff;
    border: 1px solid #e3e3e6;
    border-right: 0;
    border-radius: 8px 0 0 8px;
    box-shadow: -2px 0 10px rgba(0, 0, 0, .12);
    padding: 12px 10px;
    cursor: pointer;
    color: #444;
}

.sc-layer-row,
.sc-layer-el {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 5px 8px 5px 6px;
    cursor: pointer;
    border: 1px solid transparent;
    user-select: none;
}

.sc-layer-row {
    background: #f6f7f9;
    border-top: 1px solid #ececef;
    border-bottom: 1px solid #ececef;
    font-weight: 600;
}

.sc-layer-row.active {
    background: #e8f5fd;
    box-shadow: inset 3px 0 0 #00b0ff;
}

.sc-layer-row:hover,
.sc-layer-el:hover {
    background: #eef0f3;
}

.sc-layer-row.droptarget,
.sc-layer-el.droptarget {
    border-color: #00b0ff;
    background: #e8f5fd;
}

.sc-layer-el {
    padding-left: 26px;
}

.sc-layer-el.selected {
    background: #dff1fb;
    box-shadow: inset 3px 0 0 #00b0ff;
}

.sc-layer-el-icon {
    color: #8b939c;
    width: 16px;
    text-align: center;
    flex: 0 0 auto;
}

.sc-layer-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 4px;
}

/* Hidden things read as greyed-out everywhere they appear. */
.sc-layer-name.off {
    color: #a8adb3;
    text-decoration: line-through;
}

.sc-layer-count {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 400;
    color: #8b939c;
    padding: 0 4px;
}

.sc-layer-twist {
    flex: 0 0 auto;
    width: 18px;
    background: none;
    border: 0;
    color: #6b7178;
    cursor: pointer;
    padding: 0;
}

.sc-layer-icon {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    background: none;
    border: 0;
    border-radius: 4px;
    color: #6b7178;
    cursor: pointer;
    padding: 0;
    font-size: 12px;
}

.sc-layer-icon:hover:not(:disabled) {
    background: #dfe3e8;
    color: #111;
}

.sc-layer-icon:disabled {
    opacity: .3;
    cursor: default;
}

.sc-layer-icon.off {
    color: #c2c7cd;
}

.sc-layer-icon.on {
    color: #e4002b;
}

.sc-layer-icon.danger:hover:not(:disabled) {
    background: #fde7ea;
    color: #e4002b;
}

.sc-layer-rename {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0 !important;
    height: 24px !important;
    font-size: 13px !important;
    padding: 0 6px !important;
}

.sc-layer-empty {
    padding: 6px 8px 6px 26px;
    color: #a8adb3;
    font-style: italic;
    font-size: 12px;
}

/* ---- Canvas image gallery (Uploads panel) ------------------------------------------------- */
.sc-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.sc-gallery-item {
    position: relative;
    aspect-ratio: 1 / 1;
    border: 1px solid #e3e3e6;
    border-radius: 6px;
    overflow: hidden;
    background: repeating-conic-gradient(#f4f4f6 0% 25%, #fff 0% 50%) 50% / 12px 12px;
    cursor: grab;
}

.sc-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none; /* the whole tile is the drag handle, not the <img> */
}

.sc-gallery-item:hover {
    border-color: #00b0ff;
}

.sc-gallery-badge {
    position: absolute;
    top: 3px;
    left: 3px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #00b0ff;
    color: #fff;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
}

.sc-gallery-actions {
    position: absolute;
    inset: auto 0 0 0;
    display: none;
    justify-content: flex-end;
    gap: 2px;
    padding: 2px;
    background: rgba(255, 255, 255, .92);
}

.sc-gallery-item:hover .sc-gallery-actions {
    display: flex;
}

.sc-gallery-actions button {
    background: none;
    border: 0;
    color: #444;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 11px;
    border-radius: 3px;
}

.sc-gallery-actions button:hover {
    background: #e3e3e6;
}

.sc-gallery-actions button.danger:hover {
    background: #fde7ea;
    color: #e4002b;
}

/* Dragging a gallery image over the stage. */
.sc-stage.sc-droppable {
    outline: 2px dashed #00b0ff;
    outline-offset: -6px;
}

/* ---- On-page story editing ---- */

/* Caret blink: step animation so it snaps on/off like a native caret. */
.sc-caret {
    animation: sc-caret-blink 1.1s steps(1) infinite;
}

@keyframes sc-caret-blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* The invisible input-capture textarea riding at the caret: it must be focusable (so keystrokes,
   clipboard and IME reach it) but never visible and never receive its own caret rendering. */
.sc-story-input {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: none;
    outline: none;
    resize: none;
    opacity: 0;
    background: transparent;
    caret-color: transparent;
    overflow: hidden;
}

/* WYSIWYG honesty: browsers synthesize a faux bold/italic when a font-face has no real 700/italic
   face - but ImageSharp (PNG) and PDFsharp never do, so the editor would show styling the exports
   silently drop. Disabling synthesis makes a missing face VISIBLE in the editor (text stays
   regular), matching the renderers exactly. Covers canvas SVG text and the inline edit textarea. */
.sc-editor svg text,
.sc-editor .social-canvas-inline-edit,
.sc-editor textarea {
    font-synthesis: none;
}

/* ---- Canvas list ------------------------------------------------------------------------ */

/* Tab strip and search share one bar: .horz-tabs paints its own #f5f5f5 strip, so the bar
   matches it and the search sits flush on the right of the same band. */
.sc-list-toolbar {
    display: flex;
    align-items: stretch;
    background: #f5f5f5;
    margin-bottom: 10px;
}

.sc-list-toolbar .sc-list-tabs {
    flex: 1 1 auto;
    margin-bottom: 0;
}

/* The count riding beside each tab name. Muted, so the name still reads first. */
.sc-list-tabs .sc-list-count {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px;
    border-radius: 9px;
    background: #e0e0e0;
    color: #616161;
    font-size: 0.72rem;
    line-height: 1.2;
    vertical-align: middle;
}

.sc-list-tabs .title.is-active .sc-list-count {
    background: #d32f2f;
    color: #fff;
}

.sc-list-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    padding: 0 12px;
    color: #757575;
}

.sc-list-search input {
    width: 240px;
    margin: 0;
}

/* .data-table's row rule makes every span a full-width block with vertical padding and no side
   padding (components/_data-table.scss), which flattens Foundation's .label out of its pill shape
   and stacks two labels vertically. Put the pill back inside this list. */
.sc-list .row span.label {
    display: inline-block;
    width: auto;
    padding: 0.33333rem 0.5rem;
    margin-right: 4px;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    vertical-align: middle;
}

/* Pixel dimensions sit where the Print badge would be, as quiet text rather than a badge. */
.sc-list .row span.sc-list-dims {
    display: inline-block;
    padding: 0.33333rem 0;
    color: #9e9e9e;
    font-size: 0.78rem;
    vertical-align: middle;
}

.sc-list-empty {
    padding: 28px 0;
    color: #9e9e9e;
    text-align: center;
}
