/* urlr/multilingual-image block — frontend figure + editor canvas/sidebar. */

.wp-block-urlr-multilingual-image {
    margin-left: 0;
    margin-right: 0;
    /* Grid/flex items default to min-width: auto, so the media's intrinsic
       width would drive the track and overflow the column (the max-width:
       100% on the media cannot cap it while the track is being sized).
       min-width: 0 lets the figure shrink to the actual track width. */
    min-width: 0;
    max-width: 100%;
}

/* The figure's own min-width: 0 is not enough on its own: every flex/grid
   ancestor between the track and the media also defaults to min-width:
   auto, so the media's min-content still sizes the track and the media
   overflows its column (e.g. the hero grid video spilling off-screen).
   Let any flex or grid container holding the block shrink to the actual
   track width instead. */
:is(.is-layout-flex, .is-layout-grid):has(.wp-block-urlr-multilingual-image) {
    min-width: 0;
}

.wp-block-urlr-multilingual-image img,
.wp-block-urlr-multilingual-image video {
    display: block;
    /* Natural width by default, never wider than the figure; the block's
       maxWidth setting caps it further via an inline max-width. */
    max-width: 100%;
    height: auto;
    /* Inherit the border radius set via the block's Styles tab, so the
       media itself is rounded, not just the figure wrapper. */
    border-radius: inherit;
}

.wp-block-urlr-multilingual-image video {
    /* The rendered <video> carries width/height attributes, so the browser
       derives its natural aspect-ratio and reserves a matching box (no
       subpixel gap under the media). Where a container constrains both
       dimensions, cover crops to fill instead of letterboxing a white
       edge. */
    object-fit: cover;
}

/* When the figure is itself a flex item, its width comes from the flex
   algorithm, so a percentage max-width on the media can fail to resolve
   against it and the media overflows the figure (e.g. the hero video).
   A definite width: 100% caps the media to the figure's used width there;
   everywhere else the media keeps its natural width. The .urlr-steps-panel
   exception: that panel carries the is-layout-flex class but the theme
   forces display: block on it on the frontend, so its media is a block
   child and must keep its natural (centered) width. */
:where(.is-layout-flex):not(.urlr-steps-panel) > .wp-block-urlr-multilingual-image img,
:where(.is-layout-flex):not(.urlr-steps-panel) > .wp-block-urlr-multilingual-image video {
    width: 100%;
}

/* Editor canvas */
.editor-styles-wrapper .urlr-ml-image-canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.editor-styles-wrapper .urlr-ml-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 24px;
    border: 1px dashed #ccc;
    border-radius: 4px;
}

.editor-styles-wrapper .urlr-ml-image-placeholder-hint {
    font-size: 12px;
    color: #757575;
}

.editor-styles-wrapper .urlr-ml-image-meta {
    margin-top: 8px;
}

.editor-styles-wrapper .urlr-ml-image-preview-label {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    color: #757575;
}

.editor-styles-wrapper .urlr-ml-image-locales {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.editor-styles-wrapper .urlr-ml-image-chip {
    padding: 1px 8px;
    border: 1px solid #ddd;
    border-radius: 999px;
    background: #f0f0f0;
    color: #1e1e1e;
    font-size: 11px;
    line-height: 1.6;
}

/* Shared translated image: blue. Per-locale override: green. */
.editor-styles-wrapper .urlr-ml-image-chip.is-shared {
    border-color: #a8c8f0;
    background: #e5f0ff;
}

.editor-styles-wrapper .urlr-ml-image-chip.is-locale {
    border-color: #a3d6a3;
    background: #e6f4e6;
}

/* Sidebar fields */
.urlr-ml-image-field {
    margin-bottom: 16px;
}

.urlr-ml-image-field-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.urlr-ml-image-thumb {
    display: block;
    max-width: 100%;
    max-height: 120px;
    height: auto;
    margin-bottom: 6px;
    border: 1px solid #ddd;
    border-radius: 2px;
}

.urlr-ml-image-remove {
    margin-top: 4px;
}

.urlr-ml-image-hint {
    color: #757575;
    font-size: 12px;
}
