/* ================================================================
   GRID - right panel: loading overlay, fieldset sections,
          tint cells, name labels
   Edit this file to change: cell size, section border style,
   label appearance, loading indicator
   ================================================================ */

/* ── Right panel container ── */
.right {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 28px;
  position: relative;
}

/* ── Loading overlay ── */
.loading {
  position: absolute; inset: 0;
  background: rgba(0,8,18,.92);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--ice);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  z-index: 20;
}

.loading.on { display: flex; }

@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  width: 20px; height: 20px;
  border: 1.5px solid rgba(128,238,192,.10);
  border-top-color: var(--ice);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

/* ── Grid sections - fieldset style ──────────────────────────────
   The label appears to "float" in a gap cut through the dashed border.
   This is the key design feature borrowed from indie web aesthetics.
   The .sect-head uses background: var(--ink) to mask the border behind it.
   ---------------------------------------------------------------- */
.sect {
  border: 1px dashed rgba(128,238,192,.14);
  border-radius: 8px;
  padding: 14px 10px 10px;
  position: relative;
  margin-top: 24px;
}

.sect:first-child { margin-top: 0; }

.sect-head {
  position: absolute;
  top: -9px;
  left: 12px;
  right: 12px;
  /* Must match the background behind this element to mask the border */
  background: var(--ink);
  padding: 0 7px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: -.01em;
  text-transform: none;
  color: rgba(216,216,236,.38);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Collage save button inside section header */
.btn-collage {
  background: none;
  border: 1px solid rgba(128,238,192,.18);
  border-radius: 3px;
  color: var(--ice2);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: .10em;
  text-transform: uppercase;
  padding: 2px 7px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}

.btn-collage:hover:not(:disabled) {
  border-color: var(--ice);
  color: var(--ice);
}

.btn-collage:disabled {
  opacity: .3;
  cursor: default;
}

/* ── Tint grid ── */
.tgrid {
  display: grid;
  /* minmax(60px, 1fr) - cells are at least 60px, fill remaining space */
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 6px 5px;
}

/* ── Individual tint cell ── */
.tcell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}

.tcell-inner {
  aspect-ratio: 1;
  border-radius: 5px;
  overflow: hidden;
  border: 1.5px solid transparent;
  /* Checkered bg shows transparency in the tinted image */
  background: repeating-conic-gradient(#030c14 0% 25%, #051018 0% 50%) 0 0 / 10px 10px;
  transition: border-color .1s, transform .12s ease-out;
}

.tcell:hover .tcell-inner { border-color: rgba(128,238,192,.4); transform: scale(1.05); }
.tcell.sel   .tcell-inner {
  border-color: var(--ice);
}

.tcell-inner canvas { display: block; width: 100%; height: 100%; }

/* Tint name label beneath each cell */
.tcell-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 400;
  letter-spacing: -.02em;
  text-transform: none;
  color: rgba(128,238,192,.38);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1;
  transition: color .1s;
}

.tcell:hover .tcell-label { color: rgba(128,238,192,.7); }
.tcell.sel   .tcell-label { color: var(--ice); }

/* ── Search bar ── */
.tint-search-wrap {
  position: relative;
  margin-bottom: 14px;
}

.tint-search {
  width: 100%;
  box-sizing: border-box;
  background: rgba(128,238,192,.04);
  border: 1px solid rgba(128,238,192,.14);
  border-radius: 5px;
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  padding: 7px 30px 7px 11px;
  outline: none;
  transition: border-color .15s, background .15s;
}

.tint-search::placeholder { color: var(--muted); }

.tint-search:focus {
  border-color: rgba(128,238,192,.35);
  background: rgba(128,238,192,.07);
}

.tint-search-clear {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 9px;
  color: var(--muted);
  cursor: pointer;
  display: none;
  user-select: none;
  line-height: 1;
  transition: color .15s;
}

.tint-search-clear:hover { color: var(--ice); }

/* Section hidden by search filter */
.sect.search-hidden { display: none; }

/* ── Empty state (before image is uploaded) ── */
.grid-hint {
  display: none;
  font-size: 12px;
  font-weight: 500;
  color: rgba(128,238,192,.28);
  text-align: center;
  padding: 50px 20px;
  line-height: 1.8;
}
