/* Place app — list, detail, my_places */

/* Board palette — one source for the cells and the legend swatches.
   Green is the owner role; red/blue/gold are the three attacker slots.
   Black is retired: kept only so pre-existing black slots still render. */
:root {
    --place-green: #4a9d4a;  --place-green-edge: #69b569;
    --place-red:   #c0392b;  --place-red-edge:   #d65548;
    --place-blue:  #2980b9;  --place-blue-edge:  #3fa0d0;
    --place-gold:  #d4a018;  --place-gold-edge:  #e8b840;
    --place-black: #111;     --place-black-edge: #444;
}

.place-wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 20px;
    color: #1a1a1a;
}

.place-header,
.place-detail-head {
    text-align: center;
    margin-bottom: 20px;
}

.place-title {
    margin: 0 0 6px;
    font-size: 1.8rem;
    color: #1a1a1a;
}

.place-subtitle {
    margin: 0 0 12px;
    color: #444;
    font-size: 0.95rem;
}

.place-cta,
.place-back {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 6px;
    background: #2a2a2a;
    color: #e8e8e8;
    text-decoration: none;
    font-size: 0.9rem;
    border: 1px solid #3a3a3a;
}

.place-cta:hover,
.place-back:hover {
    background: #3a3a3a;
}

.place-owner-line {
    color: #222;
    margin: 8px 0;
}

.place-budget {
    margin: 10px 0;
    color: #222;
}
.place-budget small {
    color: #555;
}

/* List */
.place-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.place-card {
    display: block;
    padding: 12px;
    background: var(--ink);
    border: 1px solid var(--text-main);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s;
}
.place-card:hover {
    border-color: var(--activity-dark);
}

.place-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.9rem;
}
.place-card-id { color: var(--ink-3); }
.place-card-owner { color: var(--surface-3); font-weight: 600; }

.place-card-meter {
    height: 6px;
    background: var(--text-main);
    border-radius: 3px;
    overflow: hidden;
}
.place-card-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-activity), var(--accent-activity));
}
.place-card-count {
    margin-top: 6px;
    font-size: 0.875rem;
    color: var(--ink-3);
    text-align: right;
}

/* Folded owner places: original card wears a "+N" button, extras unfold below */
.place-group { position: relative; }
.place-more-btn {
    position: absolute;
    left: 10px;
    bottom: 10px;
    padding: 2px 10px;
    background: var(--accent-activity);
    color: var(--ink);
    border: none;
    border-radius: 5px;
    font-size: 0.875rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}
.place-more-btn:hover { background: var(--activity-dark); }
.place-extras { display: grid; gap: 12px; margin-top: 12px; }
.place-extras[hidden] { display: none; }

.place-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: #555;
    padding: 32px;
}

/* Legend */
.place-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin: 12px 0;
    font-size: 0.875rem;
    color: #222;
}
.legend-swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 4px;
    border: 1px solid #000;
}
.legend-green  { background: var(--place-green); }
.legend-red    { background: var(--place-red); }
.legend-blue   { background: var(--place-blue); }
.legend-gold   { background: var(--place-gold); }
.legend-black  { background: var(--place-black); }

/* Grid */
.place-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 2px;
    max-width: 520px;
    margin: 16px auto;
    padding: 8px;
    background: #111;
    border: 1px solid #2c2c2c;
    border-radius: 8px;
    aspect-ratio: 1 / 1;
}

.place-cell {
    background: #242424;
    border: 1px solid #2f2f2f;
    border-radius: 2px;
    aspect-ratio: 1 / 1;
    padding: 0;
    cursor: pointer;
    transition: transform .05s, border-color .1s;
}
.place-cell:hover:not(:disabled) {
    border-color: #fff;
    transform: scale(1.08);
}
.place-cell:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.place-cell.color-green  { background: var(--place-green); border-color: var(--place-green-edge); }
.place-cell.color-red    { background: var(--place-red);   border-color: var(--place-red-edge); }
.place-cell.color-blue   { background: var(--place-blue);  border-color: var(--place-blue-edge); }
.place-cell.color-gold   { background: var(--place-gold);  border-color: var(--place-gold-edge); }
.place-cell.color-black  { background: var(--place-black); border-color: var(--place-black-edge); }

/* Superuser-only owner tooltip on hover (only cells with data-owner) */
.place-cell { position: relative; }
.place-cell[data-owner]:hover::before {
    content: attr(data-owner);
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 0.875rem;
    padding: 3px 6px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
}

/* Status */
.place-status {
    text-align: center;
    margin-top: 10px;
    min-height: 1.2em;
    font-size: 0.9rem;
}
.place-status.is-ok    { color: #2a7a2a; }
.place-status.is-error { color: var(--danger); }

/* Aggressive top-of-viewport banner when an error fires */
.place-status.is-error {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: var(--danger);
    color: var(--surface);
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    font-size: 1rem;
    font-weight: 600;
    max-width: 90vw;
    margin-top: 0;
}

/* Mobile — minimum padding at 480px */
@media (max-width: 480px) {
    .place-wrap {
        padding: 12px 4px;
    }
    .place-title {
        font-size: 1.4rem;
    }
    .place-grid {
        padding: 4px;
        gap: 1px;
        max-width: 100%;
    }
    .place-list {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .place-extras { gap: 8px; margin-top: 8px; }
    .place-more-btn { left: 6px; bottom: 6px; }
}
