/* board-app/public/style.css */
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }  /* author CSS must never defeat the hidden attribute */

:root {
  --rows: 5;                 /* overwritten by board.js fitRows() */
  --tile-h: 150px;            /* overwritten by board.js fitRows() */
  --gap: 10px;
  /* overshoot-and-settle spring (linear() approximation, ~1.10 peak at 18%) */
  --spring: linear(0, 0.218 2.1%, 0.693 6.4%, 0.914 9%, 1.027 11.4%, 1.08 13.7%,
    1.097 15.5%, 1.099 17.6%, 1.071 21.4%, 0.986 28.7%, 0.967 32.1%, 0.967 36.4%,
    1.001 47%, 1.007 52.8%, 0.998 71.7%, 1);
  --c-RED: #c0392b; --c-BLUE: #2e6da4; --c-GREEN: #3f7d44;
  --c-YELLOW: #c9a227; --c-ORANGE: #d07030; --c-UNGROUPED: #8a8378;
}

html, body { height: 100%; }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #33291c, #241d13);  /* the desk */
  color: #eee;
  overflow: hidden;
}

.screen { height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; }
.screen h1 { text-align: center; }
#login-form { display: flex; flex-direction: column; gap: 10px; width: 260px; }
#login-form input, #login-form button { font-size: 16px; padding: 10px; border-radius: 8px; border: none; }
#login-form button { background: #c9a227; font-weight: 700; cursor: pointer; }
.error { color: #ff9d9d; }

#screen-board { display: block; }
#board {
  height: 100dvh;
  display: flex; gap: 28px; align-items: stretch;
  overflow-x: auto; overflow-y: hidden;
  /* headroom so a scale(2)-hovered tile never clips: >= tileH/2 vertical, >= tileW/2 horizontal
     (with the sheet's own 14px padding). Keep in sync with fitRows() in board.js. */
  padding: 88px 48px;
}

.sheet {
  flex: none; display: flex; flex-direction: column;
  background: #f6f2ea; color: #222;
  border-radius: 10px; padding: 10px 14px 14px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
  border-top: 6px solid var(--sheet-c, #999);
}
.sheet[data-group="RED"]      { --sheet-c: var(--c-RED); }
.sheet[data-group="BLUE"]     { --sheet-c: var(--c-BLUE); }
.sheet[data-group="GREEN"]    { --sheet-c: var(--c-GREEN); }
.sheet[data-group="YELLOW"]   { --sheet-c: var(--c-YELLOW); }
.sheet[data-group="ORANGE"]   { --sheet-c: var(--c-ORANGE); }
.sheet[data-group="UNGROUPED"]{ --sheet-c: var(--c-UNGROUPED); }
.sheet > header {
  display: flex; align-items: center; gap: 8px; padding: 2px 0 8px;
  font-weight: 700; letter-spacing: 0.06em; font-size: 14px;
}
.sheet > header .swatch { width: 14px; height: 14px; border-radius: 3px; background: var(--sheet-c); }
.sheet > header .count { color: #877; font-weight: 400; }

.grid {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-rows: repeat(var(--rows), var(--tile-h));
  grid-auto-flow: column;
  grid-auto-columns: calc(var(--tile-h) * 2 / 3);
  gap: var(--gap);
}

.tile {
  position: relative;
  height: var(--tile-h); width: calc(var(--tile-h) * 2 / 3);
  border-radius: 6px; overflow: hidden;
  background: #cfc9bd;
  cursor: grab; user-select: none; -webkit-user-select: none;
  z-index: 0;
  transition: transform 0.55s var(--spring), box-shadow 0.55s var(--spring),
    z-index 0s 0.25s;  /* z drops back only after the shrink is mostly done */
}
.tile:hover {
  transform: scale(2);
  z-index: 20; transition-delay: 0s, 0s, 0s;  /* z pops instantly on the way up */
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
.tile img {
  width: 100%; height: 100%; object-fit: contain; display: block;
  pointer-events: none;  /* clicks and drags belong to the tile */
}
.tile .caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: 9px; line-height: 1.25; padding: 2px 4px;
  background: rgba(255, 255, 255, 0.88); color: #222;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile.placeholder {
  display: flex; align-items: center; justify-content: center;
  background: #beb6a6; color: #665c48; font-weight: 700; font-size: 20px;
}

/* drag states (Task 8) — springs off mid-drag so Sortable's own animation rules */
.sortable-ghost { opacity: 0.35; }
body.dragging .tile { transition: none; }
body.dragging .tile:hover { transform: none; z-index: 0; box-shadow: none; }

dialog#person-modal {
  margin: auto; border: none; border-radius: 14px; padding: 0;
  max-width: min(880px, 92vw); max-height: 88dvh; overflow: hidden;
}
dialog#person-modal::backdrop { background: rgba(0, 0, 0, 0.55); }
#modal-close {
  position: absolute; top: 8px; right: 10px; z-index: 2;
  border: none; background: rgba(255, 255, 255, 0.85); border-radius: 999px;
  width: 30px; height: 30px; cursor: pointer; font-size: 14px;
}
#modal-body { display: flex; }
.modal-photo { position: relative; background: #1c1710; }
.modal-photo img { display: block; max-height: 88dvh; max-width: 60vw; object-fit: contain; }
.modal-photo .pager {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; align-items: center;
  background: rgba(0, 0, 0, 0.55); color: #fff; border-radius: 999px; padding: 4px 10px;
}
.modal-photo .pager button { border: none; background: none; color: #fff; font-size: 18px; cursor: pointer; }
.modal-info { padding: 22px 24px; min-width: 240px; background: #f6f2ea; color: #222; flex: 1; }
.modal-info h2 { margin-bottom: 8px; }
.chips { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.chip { padding: 2px 10px; border-radius: 999px; background: #ddd; font-size: 13px; }
.chip.group { color: #fff; }
.rating { margin: 6px 0; }
.stale { color: #96700a; margin-top: 10px; font-size: 13px; }

#toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: #111; color: #fff; padding: 10px 16px; border-radius: 8px;
  z-index: 99; max-width: 80vw;
}
#pending-badge {
  position: fixed; top: 10px; right: 12px; z-index: 98;
  background: #b45309; color: #fff; padding: 3px 10px;
  border-radius: 999px; font-size: 12px;
}
#notice-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 97;
  background: #7a4a00; color: #fff; padding: 6px 12px;
  font-size: 13px; text-align: center;
}

/* drop dock: fixed left-edge UNGROUPED target, visible only while dragging a coloured person
   (board.js toggles body.dragging / body.drag-from-ungrouped) */
#ungroup-dock {
  display: none;
  position: fixed; left: 10px; top: 50%; transform: translateY(-50%);
  z-index: 40;
  width: 120px; height: 60dvh;
  flex-direction: column; align-items: center; gap: 8px;
  padding: 12px 8px;
  background: rgba(138, 131, 120, 0.3);
  border: 2px dashed var(--c-UNGROUPED);
  border-radius: 12px;
  backdrop-filter: blur(3px);
}
body.dragging:not(.drag-from-ungrouped) #ungroup-dock { display: flex; }
#ungroup-dock .dock-label {
  color: #f6f2ea; font-weight: 700; font-size: 12px; letter-spacing: 0.06em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
#dock-grid { flex: 1; width: 100%; }
