/* css/grid/grid.css — Grid app testbed (Step 1) */

.grid-testbed {
    max-width: 100%;
    margin: 0 auto;
    padding: 24px 16px;
    text-align: center;
}

.grid-title {
    margin: 0 0 4px;
    font-size: 1.5rem;
}

.grid-meta {
    margin: 0 0 4px;
    color: #888;
    font-size: 0.9rem;
}

.grid-limits {
    margin: 0 0 4px;
    color: #555;
    font-size: 0.9rem;
    font-weight: 600;
}

.grid-remaining {
    margin: 0 0 16px;
    color: #2563eb;
    font-size: 0.95rem;
    font-weight: 700;
}

.grid-controls {
    display: none;                 /* hidden from view; ?w=&h= in the URL still works */
    gap: 12px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin: 0 0 16px;
    font-size: 0.9rem;
}

.grid-controls input {
    width: 64px;
    padding: 4px 6px;
    margin-left: 4px;
}

.grid-controls button {
    padding: 5px 14px;
    cursor: pointer;
}

.grid-board {
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    grid-template-rows: repeat(var(--rows), 1fr);
    gap: 2px;
    width: 100vw;
    aspect-ratio: var(--cols) / var(--rows);
    margin-left: calc(50% - 50vw);   /* full-bleed: escape the centered .container */
    background: transparent;
}

/* Big screens: stop the board going full-bleed — cap it and centre it.
   Stays square via the aspect-ratio above; small screens keep full-bleed. */
@media (min-width: 768px) {
    .grid-board {
        width: min(768px, 100%);
        margin-left: auto;
        margin-right: auto;
    }
}

.grid-cell {
    background: #dbe1e8;            /* darker than page so each cell reads clearly */
    border: 1px solid #8593a5;     /* per-cell border, like Lazy Snake */
    border-radius: 3px;
    cursor: pointer;
}

.grid-cell[data-color="red"]    { background: #e74c3c; border-color: #c0392b; }
.grid-cell[data-color="orange"] { background: #e67e22; border-color: #d35400; }
.grid-cell[data-color="yellow"] { background: #f1c40f; border-color: #d4ac0d; }
.grid-cell[data-color="green"]  { background: #2ecc71; border-color: #27ae60; }
.grid-cell[data-color="teal"]   { background: #1abc9c; border-color: #16a085; }
.grid-cell[data-color="blue"]   { background: #3498db; border-color: #2980b9; }
.grid-cell[data-color="purple"] { background: #9b59b6; border-color: #8e44ad; }
.grid-cell[data-color="pink"]   { background: #e84393; border-color: #c2287a; }
.grid-cell[data-color="black"]  { background: #2c3e50; border-color: #1a252f; }

.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin: 0 0 16px;
}

.color-btn {
    width: 84px;                   /* fixed width so every button is identical */
    padding: 6px 0;
    border: none;
    border-radius: 6px;
    color: #fff;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
}

.color-btn.red    { background: #e74c3c; }
.color-btn.orange { background: #e67e22; }
.color-btn.yellow { background: #f1c40f; color: #333; }
.color-btn.green  { background: #2ecc71; }
.color-btn.teal   { background: #1abc9c; }
.color-btn.blue   { background: #3498db; }
.color-btn.purple { background: #9b59b6; }
.color-btn.pink   { background: #e84393; }
.color-btn.black  { background: #2c3e50; }

.color-btn.active {
    box-shadow: 0 0 0 3px #1f2937;
}

@media (max-width: 480px) {
    .grid-testbed {
        padding: 12px 4px;        /* minimum padding on small screens */
    }
    .grid-title  { font-size: 1.2rem; }
    .grid-limits { font-size: 0.8rem; }
    .grid-remaining { font-size: 0.85rem; }
    .grid-board { gap: 1px; }
    .color-picker { gap: 6px; }
    .color-btn {
        width: 74px;
        padding: 5px 0;
        font-size: 0.85rem;
    }
}

/* Live presence badge — ink pill, palette-green pulsing dot.
   Hidden by default; JS adds .is-live when 2+ people are on the board. */
.grid-presence {
    display: none;
    margin: 0 0 10px;
}

.grid-presence.is-live {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 13px;
    border-radius: 999px;
    background: #1f2937;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.presence-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc71;            /* same green as the paint palette */
    animation: presence-pulse 2s ease-out infinite;
}

@keyframes presence-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.55); }
    70%  { box-shadow: 0 0 0 7px rgba(46, 204, 113, 0); }
    100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
}

@media (max-width: 480px) {
    .grid-presence.is-live {
        font-size: 0.8rem;
        padding: 3px 11px;
    }
}

.grid-watch,
.grid-faction,
.grid-countdown {
    margin: 0 0 8px;
    font-weight: 600;
    color: #555;
}

.grid-countdown {
    color: #b91c1c;
}

.war-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 6px;
    vertical-align: middle;
}

.grid-ownership {
    max-width: 420px;
    margin: 20px auto 0;
}

.grid-ownership table {
    width: 100%;
    border-collapse: collapse;
}

.grid-ownership th,
.grid-ownership td {
    padding: 4px 8px;
    border-bottom: 1px solid #ddd;
    text-align: left;
}
