/* style_table.css */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* BlockWorld layout. Colors, type and control sizes come from the shared
   --bgf-* tokens (static/css/blockgraf-ui.css); only BlockWorld geometry
   lives here. */
:root {
    --chrome-size: 32px;          /* left/right frame borders */
    --bw-bar-h: 48px;             /* top and bottom chrome bars */
    --bw-bottom-h: var(--bw-bar-h);
    --bw-control-h: var(--bgf-control-h);
    --cell-width: 250px;
    --cell-height: 150px;
    --surface-dark: #151515;
    --bgf-toast-bottom: calc(var(--bw-bottom-h) + var(--bgf-space-3));
}

#container {
    z-index: 1;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden; /* No barras de scroll en el navegador */
    font-family: 'Inter', sans-serif;
    background-color: #000; /* Fondo negro */
    display: flex;
    justify-content: center; /* Centra horizontalmente */
    align-items: center; /* Centra verticalmente */
    position: relative;
    height: 100dvh; /* Toda la ventana */
    width: 100vw; /* Todo el ancho */
    min-width: 0;
    touch-action: none;
    /* Holding a finger on a card picks it up (touchHold.js): no iOS callout */
    -webkit-touch-callout: none;
}

.border-container {
    position: fixed;  /* Modificado aquí */
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: black;
    z-index: 2;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.blockworld-name-input {
    margin: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: white;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    text-align: center;
    padding: 2px 8px;
    outline: none;
    min-width: 100px;
    max-width: 300px;
    transition: border-color 0.2s ease;
}

.blockworld-name-input:hover {
    border-color: rgba(255,255,255,0.2);
}

.blockworld-name-input:focus {
    border-color: var(--bgf-accent);
    background: rgba(255,255,255,0.05);
}

/* ── GRID FRAME & EXPAND BUTTONS ─────────────────────── */

.grid-frame {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: max-content;
    height: max-content;
}

.grid-row-area {
    display: flex;
    align-items: stretch;
}

/* Shared expand button base */
.grid-expand-btn {
    background: transparent;
    border: 1px dashed rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.78);
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.65;
    transition: opacity 0.2s ease, border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
    user-select: none;
}

@media (hover: hover) and (pointer: fine) {
    .grid-expand-btn {
        opacity: 0;
    }

    /* Show on hover of the frame */
    .grid-frame:hover .grid-expand-btn {
        opacity: 1;
    }
}

.grid-expand-btn:hover {
    border-color: var(--bgf-accent-hover);
    color: var(--bgf-accent-hover);
    background-color: rgba(0, 89, 179, 0.06);
}

.grid-expand-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    pointer-events: none;
}

/* Right-side group: add / remove column */
.grid-expand-group-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-self: stretch;
    margin-left: 10px;
}

.grid-expand-col {
    width: 32px;
    flex: 1;
}

/* Bottom group: add / remove row */
.grid-expand-group-row {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.grid-expand-row {
    height: 32px;
    flex: 1;
}

@keyframes pulse-save {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ══ Chrome bars ════════════════════════════════════════════════════════════
   Fixed slots in every mode: start | title-or-center | end. caps decides
   which slots are filled, never where a control lives (BlockWorld.html). */
.border-container.top,
.border-container.bottom {
    left: 0;
    width: 100%;
}

.border-container.top {
    top: 0;
    height: var(--bw-bar-h);
}

.border-container.bottom {
    bottom: 0;
    height: var(--bw-bottom-h);
}

.border-container.left,
.border-container.right {
    top: var(--bw-bar-h);
    width: var(--chrome-size);
    height: calc(100% - var(--bw-bar-h) - var(--bw-bottom-h));
}

.border-container.left {
    left: 0;
}

.border-container.right {
    right: 0;
}

.bw-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-areas: "start middle end";
    align-items: center;
    gap: var(--bgf-space-3);
    padding: 0 var(--bgf-space-4);
    box-sizing: border-box;
    background-color: var(--bgf-bg);
    color: var(--bgf-text);
    font-family: var(--bgf-font);
    font-size: var(--bgf-text-sm);
}

.bw-slot {
    display: flex;
    align-items: center;
    gap: var(--bgf-space-2);
    min-width: 0;
}

.bw-slot--start {
    grid-area: start;
    justify-self: start;
}

.bw-slot--title,
.bw-slot--center {
    grid-area: middle;
    justify-self: center;
}

.bw-slot--end {
    grid-area: end;
    justify-self: end;
}

/* Bottom bar: the actions on the right always get their full width, so they
   never run over the search. With room to spare both sides are equal and the
   search sits in the middle; when it is tight the left side gives way first. */
.border-container.bottom.bw-bar {
    grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(max-content, 1fr);
}

.border-container.bottom .coord-display {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* The search fills its track and centers its content in it, so it is the
   track (not the search's preferred width) that decides how wide it gets. */
.border-container.bottom .bw-slot--center {
    justify-self: stretch;
    justify-content: center;
}

/* Identity, title and meta */
.logo-link {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    min-height: var(--bw-control-h);
    border-radius: var(--bgf-radius-sm);
}

.logo {
    height: 20px;
    width: auto;
}

.dim-display,
.blockset-counter,
.zoom-indicator,
.coord-display {
    color: var(--bgf-text-muted);
    font-size: var(--bgf-text-xs);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.dim-display {
    display: flex;
    align-items: center;
    gap: var(--bgf-space-3);
    margin-left: var(--bgf-space-2);
    user-select: none;
}

.dim-display .dim-item {
    display: flex;
    align-items: center;
    gap: var(--bgf-space-1);
}

.dim-display .dim-axis {
    font-weight: 600;
    color: var(--bgf-text);
    text-transform: uppercase;
}

.dim-display .dim-val {
    font-weight: 500;
}

.blockworld-name {
    color: var(--bgf-text);
    font-size: var(--bgf-text-md);
}

.blockworld-name-input {
    min-width: 100px;
    max-width: 320px;
    padding: var(--bgf-space-1) var(--bgf-space-2);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--bgf-radius-sm);
    color: var(--bgf-text);
    font: 600 var(--bgf-text-md) var(--bgf-font);
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    outline: none;
    transition: border-color var(--bgf-duration);
}

.blockworld-name-input:hover {
    border-color: var(--bgf-border);
}

.blockworld-name-input:focus {
    border-color: var(--bgf-accent);
    background: var(--bgf-surface-2);
}

/* Buttons of the chrome bars: one component, three looks */
.bw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--bgf-space-2);
    min-width: var(--bw-control-h);
    height: var(--bw-control-h);
    padding: 0 var(--bgf-space-3);
    box-sizing: border-box;
    background: var(--bgf-surface-2);
    border: 1px solid var(--bgf-border);
    border-radius: var(--bgf-radius-sm);
    color: var(--bgf-text);
    font: 500 var(--bgf-text-sm) var(--bgf-font);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--bgf-duration), border-color var(--bgf-duration);
}

.bw-btn:hover {
    background: var(--bgf-border);
    border-color: var(--bgf-border-strong);
}

.bw-btn--icon {
    width: var(--bw-control-h);
    padding: 0;
}

.bw-btn--primary {
    background: var(--bgf-accent);
    border-color: var(--bgf-accent);
    color: var(--bgf-on-accent);
}

.bw-btn--primary:hover {
    background: var(--bgf-accent-hover);
    border-color: var(--bgf-accent-hover);
}

.bw-btn--danger i {
    color: var(--bgf-danger);
}

.bw-btn--danger:hover {
    background: var(--bgf-danger-soft);
    border-color: var(--bgf-danger);
}

.bw-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.bw-btn[hidden] {
    display: none;
}

.bw-btn:focus-visible,
.logo-link:focus-visible,
.grid-expand-btn:focus-visible,
.blockworld-name-input:focus-visible,
.search-nav-btn:focus-visible {
    outline: var(--bgf-focus-ring);
    outline-offset: var(--bgf-focus-offset);
}

/* Save with pending changes */
#copy-button.has-changes {
    background: var(--bgf-accent);
    border-color: var(--bgf-accent);
    color: var(--bgf-on-accent);
    animation: pulse-save 2s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    #copy-button.has-changes {
        animation: none;
    }
}

#bw-auto-size[aria-pressed="true"],
#bw-public-filter[aria-pressed="true"],
#zone-create-btn.zone-create-active,
#zone-filter-btn.zone-filter-btn-active {
    border-color: var(--bgf-accent);
    color: var(--bgf-accent);
}

/* Secondary tools: inline on wide screens, a "More" popover below 900px */
.bw-tools {
    display: flex;
    align-items: center;
    gap: var(--bgf-space-2);
}

.bw-more,
.bw-tools__label {
    display: none;
}

/* Search: one pill, same place in every mode */
.blockset-search {
    display: flex;
    align-items: center;
    gap: var(--bgf-space-1);
    min-width: 0;
    width: clamp(240px, 28vw, 360px);
    height: var(--bw-control-h);
    padding: 0 var(--bgf-space-1) 0 var(--bgf-space-3);
    box-sizing: border-box;
    background: var(--bgf-surface-2);
    border: 1px solid var(--bgf-border-strong);
    border-radius: 999px;
    transition: border-color var(--bgf-duration), box-shadow var(--bgf-duration);
}

.blockset-search:focus-within {
    border-color: var(--bgf-accent);
    box-shadow: 0 0 0 3px var(--bgf-accent-soft);
}

.blockset-search-icon {
    color: var(--bgf-text-muted);
    font-size: var(--bgf-text-xs);
}

.blockset-search-input {
    flex: 1;
    width: 0; /* let flex size it; a search input's intrinsic width would overflow the pill */
    min-width: 60px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--bgf-text);
    font: var(--bgf-text-sm) var(--bgf-font);
}

/* The pill has its own clear button: no second one from the browser. */
.blockset-search-input::-webkit-search-cancel-button {
    display: none;
}

.blockset-search-input::placeholder {
    color: var(--bgf-text-placeholder);
}

.blockset-search-input.no-results {
    color: var(--bgf-danger);
}

.search-result-count:empty {
    display: none;
}

.search-result-count {
    min-width: 40px;
    color: var(--bgf-text-muted);
    font-size: var(--bgf-text-xs);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.search-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 999px;
    color: var(--bgf-text-muted);
    font-size: var(--bgf-text-xs);
    cursor: pointer;
}

.search-nav-btn:hover {
    background: var(--bgf-border);
    color: var(--bgf-text);
}

.search-clear-btn:hover {
    background: var(--bgf-danger-soft);
}

.search-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Zone filter (next to the search) */
.zone-filter {
    display: flex;
    align-items: center;
}

#zone-filter-menu .zone-filter-item-active {
    background: var(--bgf-accent-soft);
    color: var(--bgf-text);
}

/* Help dialog (viewTools.js) */
.bw-help__title {
    margin: var(--bgf-space-4) 0 var(--bgf-space-2);
    color: var(--bgf-text-muted);
    font-size: var(--bgf-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.bw-help__title:first-child {
    margin-top: 0;
}

.bw-help__list {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: var(--bgf-space-2) var(--bgf-space-4);
    margin: 0;
    font-size: var(--bgf-text-sm);
    line-height: 1.4;
}

.bw-help__list dt {
    color: var(--bgf-text);
}

.bw-help__list dd {
    margin: 0;
    color: var(--bgf-text-muted);
}

/* ── Medium screens ───────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
    :root {
        --chrome-size: 26px;
        --cell-width: 190px;
        --cell-height: 120px;
    }

    .blockworld-name-input {
        max-width: 34vw;
    }

    .blockset-search {
        width: clamp(260px, 36vw, 320px);
    }
}

/* ── Narrow screens: secondary tools collapse into "More" ─────────────────── */
@media (max-width: 900px) {
    .bw-more {
        display: inline-flex;
    }

    .bw-tools {
        position: fixed;
        z-index: 3100;
        right: var(--bgf-space-2);
        display: none;
        flex-direction: column;
        align-items: stretch;
        min-width: 200px;
        padding: var(--bgf-space-2);
        background: var(--bgf-surface);
        border: 1px solid var(--bgf-border-strong);
        border-radius: var(--bgf-radius);
        box-shadow: var(--bgf-shadow);
    }

    .bw-tools.is-open {
        display: flex;
    }

    #bw-top-tools {
        top: calc(var(--bw-bar-h) + var(--bgf-space-1));
    }

    #bw-bottom-tools {
        bottom: calc(var(--bw-bottom-h) + var(--bgf-space-1));
    }

    .bw-tools .bw-btn {
        justify-content: flex-start;
        width: 100%;
        padding: 0 var(--bgf-space-3);
    }

    .bw-tools .bw-tools__label {
        display: inline;
    }

    .dim-display {
        display: none;
    }
}

/* ── Phones: touch-size controls, search on its own row ──────────────────── */
@media (max-width: 640px) {
    :root {
        --chrome-size: 14px;
        --bw-control-h: var(--bgf-control-h-touch);
        --bw-bar-h: 56px;
        --bw-bottom-h: calc(var(--bw-control-h) * 2 + var(--bgf-space-2) * 3);
        --cell-width: 150px;
        --cell-height: 96px;
    }

    .bw-bar {
        gap: var(--bgf-space-2);
        padding: 0 var(--bgf-space-2);
    }

    .border-container.bottom.bw-bar {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "middle middle"
            "start end";
        align-content: space-evenly;
    }

    .bw-slot--center {
        justify-self: stretch;
    }

    .blockset-search {
        flex: 1;
        width: auto;
    }

    .search-nav-btn {
        width: 36px;
        height: 36px;
    }

    .search-result-count {
        min-width: 32px;
    }

    .blockworld-name-input {
        min-width: 72px;
        max-width: 40vw;
    }

    .blockset-counter {
        display: none;
    }

    /* Viewers have no edit actions: the bottom bar keeps only the search row. */
    :root:not(:has(.border-container.bottom .bw-slot--end .bw-btn)) {
        --bw-bottom-h: calc(var(--bw-control-h) + var(--bgf-space-2) * 2);
    }

    .border-container.bottom.bw-bar:not(:has(.bw-slot--end .bw-btn)) {
        grid-template-areas: "middle middle";
    }

    .border-container.bottom.bw-bar:not(:has(.bw-slot--end .bw-btn)) .bw-slot--start {
        display: none;
    }
}

html, body {
    height: 100%;
    overflow: hidden; /* a full-screen app: the grid pans, the page never scrolls */
}

.grid-container {
    width: 100%; /* Ocupa todo el ancho disponible */
    height: 100%; /* Ocupa toda la ventana */
    position: absolute; /* Para permitir el movimiento */
    transform-origin: top left; /* Escala desde la esquina superior izquierda */
    overflow: visible; /* Evita barras de scroll */
    cursor: grab; /* the canvas pans on drag */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: none;
}

/* While the camera moves (viewport.js sets body.is-moving) the grid is kept as
   one GPU layer that is scaled, not drawn again at every zoom step; it is
   drawn sharp once the movement stops. Text can look soft mid-zoom. */
body.is-moving .grid-container {
    will-change: transform;
}

.grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* Ajusta el número de columnas */
    gap: 10px; /* Espaciado entre celdas */
    transform: scale(1); /* Escala inicial */
    width: max-content; /* Tamaño dinámico según contenido */
    height: max-content; /* Tamaño dinámico según contenido */
}

.cell {
    border: 1px solid rgba(255,255,255,0.08);
    height: var(--cell-height);
    border-radius: 10px; /* Esquinas redondeadas */
    background-color: var(--surface-dark);
    transition: border-color 0.2s ease;
}

/* Highlight valid (empty) cells during drag: classes on the grid
   (blocksetDrag.js), not one per cell. The highlight is instant: fading the
   border of every free cell ran one transition per cell on each drag. */
.grid.is-dragging > .cell {
    transition: none;
}

.grid.show-drop-cells > .cell:empty {
    border-color: rgba(0,89,179,0.5);
    background-color: rgba(0,89,179,0.05);
}

.selected {
    /* Algún estilo para indicar selección, por ejemplo, un borde o color de fondo */
    border: 2px solid var(--bgf-accent);
}

.blockset {
    border: 1px solid rgba(255,255,255,0.08);
    height: var(--cell-height);
    border-radius: 10px; /* Esquinas redondeadas */
    background-color: #0072e6;
    z-index: 1; /* above zone rects, below zone labels */
    align-items: center; /* Centrar verticalmente */
    text-align: center;
    font-weight: bold;
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    transform-origin: center center;
    display: flex;
    justify-content: center;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
}

.blockset-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.92);
    font-size: var(--bgf-text-xs);
    font-weight: 600;
    font-family: var(--bgf-font);
    padding: 2px 8px 2px 6px;
    border-radius: 20px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.blockset-badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: #2ecc71;
    flex-shrink: 0;
    box-shadow: 0 0 5px rgba(46, 204, 113, 0.85);
    animation: badge-pulse 2.5s ease-in-out infinite;
}

/* The pulse still ticks on the main thread, so it rests while the camera
   moves (viewport.js sets body.is-moving). */
body.is-moving .blockset-badge::before {
    animation-play-state: paused;
}

.blockset-badge-type {
    right: auto;
    left: 8px;
    background: rgba(15, 21, 32, 0.55);
}

.blockset-badge-type::before {
    display: none;
}

.blockset-text {
    background: linear-gradient(135deg, #19bc85 0%, #13986b 100%);
}

:where(body:not(.is-moving)) .blockset-text:hover {
    box-shadow: 0 4px 16px rgba(25, 188, 133, 0.35);
}

.blockset-html {
    background: linear-gradient(135deg, #e8930c 0%, #c26e06 100%);
}

:where(body:not(.is-moving)) .blockset-html:hover {
    box-shadow: 0 4px 16px rgba(232, 147, 12, 0.35);
}

.blockset-map {
    background: linear-gradient(135deg, #8068ff 0%, #5b3fd1 100%);
    color: #fff;
}

.blockset-map p {
    color: #fff;
    text-shadow: 0 1px 2px rgba(35, 20, 92, 0.24);
}

.blockset-video {
    background: linear-gradient(135deg, var(--bgf-type-video) 0%, var(--bgf-type-video-strong) 100%);
    color: var(--bgf-on-accent);
}

.blockset-video p {
    color: var(--bgf-on-accent);
}

:where(body:not(.is-moving)) .blockset-video:hover {
    box-shadow: 0 4px 16px color-mix(in srgb, var(--bgf-type-video) 35%, transparent);
}

:where(body:not(.is-moving)) .blockset-map:hover {
    box-shadow: 0 4px 18px rgba(114, 92, 255, 0.42);
}

/* Large per-type icon watermark, clipped to the card's rounded corners */
.blockset {
    overflow: hidden;
}

.blockset::after {
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    right: -8px;
    bottom: -14px;
    font-size: 72px;
    line-height: 1;
    opacity: 0.10;
    color: #fff;
    pointer-events: none;
}

.blockset-canvas::after { content: '\f5cb'; } /* fa-vector-square */
.blockset-text::after   { content: '\f15c'; } /* fa-file-alt */
.blockset-html::after   { content: '\f121'; } /* fa-code */
.blockset-map::after    { content: '\f542'; } /* fa-project-diagram */
.blockset-video::after  { content: '\f008'; } /* fa-film */

/* ── ZONES ──────────────────────────────────────────────────────────────────── */

.grid {
    position: relative;
}

#zone-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.zone-rect {
    position: absolute;
    box-sizing: border-box; /* keep the border inside the measured cell span */
    border: 3px solid;
    border-radius: 12px;
    pointer-events: none;
    /* z-index stays auto: no stacking context, so the rect paints below
       blocksets (z-index 1) while the label (z-index 6) stays above them. */
    transition: background-color 0.2s ease;
}

/* Where a dragged zone would land when the drop is refused (zones.js) */
.zone-rect.zone-preview.zone-preview-invalid {
    border-color: var(--bgf-danger);
    background-color: color-mix(in srgb, var(--bgf-danger) 12%, transparent);
}

/* A zone name that can be dragged to move the zone */
.zone-label--movable {
    cursor: grab;
}

.zone-rect.zone-preview {
    border-style: dashed;
    border-color: rgba(255, 255, 255, 0.6);
    background-color: rgba(255, 255, 255, 0.05);
}

.zone-label {
    position: absolute;
    top: -12px;
    left: 12px;
    padding: 2px 10px;
    border-radius: 20px;
    color: #fff;
    font-family: var(--bgf-font);
    font-size: var(--bgf-text-xs);
    font-weight: 700;
    letter-spacing: 0.4px;
    white-space: nowrap;
    pointer-events: auto;
    z-index: 6; /* above blocksets so it stays clickable */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    user-select: none;
}

body.zone-create-mode .grid-container,
body.zone-create-mode .grid-container * {
    cursor: crosshair !important;
}

#zone-create-btn.zone-create-active {
    color: #0072e6;
}

/* Zone create/edit modal form bits */
.zone-swatch-row {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.zone-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    transition: transform 0.1s ease, border-color 0.1s ease;
}

.zone-swatch:hover {
    transform: scale(1.1);
}

.zone-swatch-selected {
    border-color: #fff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}

/* Zone filter dimming, and the "Public" filter of the bottom bar (stats.js),
   which is this one rule: a card that changes visibility follows it by itself */
body.filter-public .cell > .blockset:not([data-visibility="public"]),
.blockset.zone-dimmed {
    opacity: 0.25;
    filter: saturate(0.4);
}

.zone-filter-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Many zones must not push the menu off-screen: cap the height and scroll. */
#zone-filter-menu {
    max-height: min(60vh, 480px);
    overflow-y: auto;
}

#zone-filter-menu .context-menu-item {
    display: flex;
    align-items: center;
}

/* Opacity only: it animates on the compositor. Animating the glow as well
   recalculated the style of every badge on every frame, even at rest. */
@keyframes badge-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.65; }
}

/* The hover effects wait while the camera moves (viewport.js sets
   body.is-moving): each one repaints a card inside the single grid layer.
   :where() keeps the specificity these rules always had. */
:where(body:not(.is-moving)) .blockset:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0,114,230,0.3);
}

/* Ctrl+B search (search.js). While there are matches (body.bw-searching) the
   rest steps back as the zone and "Public" filters do: the cards and zones
   that do not match are dimmed, and that contrast is the mark of a match. No
   ring of its own: yellow read as the BlockWorld color or an HTML card, and a
   light ring is how a selected card looks. The current match (a card or a
   zone name) pulses its brightness. A zone holding a match stays lit in its
   own color, and the blocksets of a zone whose name matched stay visible. */
body.bw-searching .cell > .blockset:not(.search-match):not(.search-in-zone) {
    opacity: 0.25;
    filter: saturate(0.4);
}

body.bw-searching .zone-rect:not(.search-match):not(.search-holds) {
    opacity: 0.3;
}

.blockset.search-current,
.zone-rect.search-current .zone-label {
    animation: search-current-pulse 1.4s ease-in-out infinite;
}

.blockset.search-current {
    z-index: 2; /* above the neighbours while it pulses */
}

@keyframes search-current-pulse {
    0%, 100% { filter: brightness(1); }
    50%       { filter: brightness(1.35); }
}

@media (prefers-reduced-motion: reduce) {
    .blockset.search-current,
    .zone-rect.search-current .zone-label {
        animation: none;
        filter: brightness(1.25);
    }
}

.zone-rect:is(.search-match, .search-holds) {
    box-shadow:
        0 0 24px color-mix(in srgb, var(--zone-color) 60%, transparent),
        inset 0 0 0 999px color-mix(in srgb, var(--zone-color) 8%, transparent);
}

/* While panning, every element shows the grabbing cursor */
body.is-panning,
body.is-panning * {
    cursor: grabbing !important;
}

/* Dragging state */
.blockset.dragging {
    opacity: 0.7;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    z-index: 1000;
    pointer-events: none;
    position: fixed !important;
}

.blockset-content {
    width: 100%;
    height: 100%;
    overflow: hidden; /* Para prevenir el desbordamiento de contenido */
}

.cell, .blockset {
    width: var(--cell-width);
    height: var(--cell-height);
    /* ... otros estilos ... */
}

/* Entry highlight: the blockset the user came from blinks a bright white
   ring a few times — white contrasts against every block color and the dark
   board, unlike the old accent-blue ring on blue blocksets. The class is
   removed by JS after the animation;
 the z-index bump keeps the glow above
   neighboring cells while it plays. */
.highlight-blockset {
    animation: entry-highlight-blink 2.4s ease-in-out;
    z-index: 5;
}

@keyframes entry-highlight-blink {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
    10%, 35%, 60%, 85% { box-shadow: 0 0 0 4px #ffffff, 0 0 34px rgba(255, 255, 255, 0.9); }
    22%, 47%, 72% { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25), 0 0 6px rgba(255, 255, 255, 0.2); }
}

.context-menu {
    position: fixed;
    z-index: 3200;
    min-width: 150px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(18,18,18,0.96);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    padding: 6px;
}

.context-menu-item {
    width: 100%;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.9);
    text-align: left;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.context-menu-item:hover {
    background: rgba(0,89,179,0.38);
    color: #fff;
}

.context-zone-list {
    max-height: min(48vh, 360px);
    overflow-y: auto;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: 4px;
    padding-top: 4px;
}

.context-zone-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.context-zone-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.context-zone-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── MULTIPLE SELECTION ─────────────────────────────────────────────────────── */

/* A selected card lifts off the grid inside a light ring. The ring is not the
   accent: most cards are accent blue and the old blue outline vanished on
   them. Placed after the hover and search rules so it wins over both. */
.blockset.selected {
    outline: 2px solid var(--bgf-text);
    outline-offset: 3px;
    box-shadow:
        0 0 0 7px color-mix(in srgb, var(--bgf-accent-text) 45%, transparent),
        0 10px 24px color-mix(in srgb, var(--bgf-bg) 70%, transparent);
    transform: scale(1.03);
    z-index: 2; /* its ring paints over the neighbours */
}

/* Cells added to a grid that is already on screen (grid.js resizeGrid) come
   in instead of popping: it is how the room offered during a drag, and the
   rows and columns added by hand, say "this is new space". */
.cell-enter {
    animation: cell-enter 0.24s ease-out both;
}

@keyframes cell-enter {
    from { opacity: 0; transform: scale(0.86); }
    to   { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .cell-enter { animation: none; }
}

/* Shift held (selection.js): the pointer says a rectangle can be drawn */
body.bw-selecting .grid-container,
body.bw-selecting .grid-container * {
    cursor: crosshair !important;
}

/* The picture that follows the pointer during a drag (blocksetDrag.js): one
   card, or every card of the group in its place */
.drag-ghost {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    pointer-events: none;
}

/* Shift + drag rectangle (marquee.js), snapped to whole cells */
.marquee-rect {
    position: absolute;
    box-sizing: border-box;
    border: 1px dashed var(--bgf-accent-text);
    border-radius: var(--bgf-radius);
    background: color-mix(in srgb, var(--bgf-accent) 14%, transparent);
    pointer-events: none;
    z-index: 5; /* above the cards, below the zone labels */
}

/* Where a dragged group would land (blocksetDrag.js): all the cells, in the
   accent when the drop is possible and in the danger color when it is not */
.grid > .cell.drop-target {
    border-color: var(--bgf-accent-text);
    background-color: color-mix(in srgb, var(--bgf-accent) 26%, transparent);
}

.grid > .cell.drop-invalid {
    border-color: var(--bgf-danger);
    background-color: color-mix(in srgb, var(--bgf-danger) 16%, transparent);
}

/* How many cards travel with the one under the pointer */
.drag-count {
    position: absolute;
    left: var(--bgf-space-2);
    bottom: var(--bgf-space-2);
    min-width: 24px;
    height: 24px;
    padding: 0 var(--bgf-space-2);
    border-radius: var(--bgf-radius);
    background: var(--bgf-bg);
    border: 1px solid var(--bgf-border-strong);
    color: var(--bgf-text);
    font-family: var(--bgf-font);
    font-size: var(--bgf-text-xs);
    font-weight: 700;
    line-height: 22px;
    text-align: center;
}

/* "Move to another BlockWorld" dialog */
.bw-world-list {
    display: flex;
    flex-direction: column;
    gap: var(--bgf-space-1);
    max-height: min(50vh, 360px);
    overflow-y: auto;
    margin-top: var(--bgf-space-3);
}

/* "Stats" dialog (stats.js): the help list with figures on the right */
.bw-stats .bw-help__list dd {
    color: var(--bgf-text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}
