/* Storybook screen: the switch to Family History, choosing several memories at once,
   pinch to resize the grid, and years on the side scrubber. Loaded after app.css. */

/* ------------------------------------------------------------- header */
.sb-switch {
  border: 1px solid var(--line); background: var(--chip); color: var(--fg); border-radius: 999px;
  padding: 7px 14px; font: inherit; font-size: 13px; font-weight: 700; white-space: nowrap; flex: none;
}
.m-title h1 { min-width: 0; }
.m-title .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* phones: the title sits left so "Storybook", the switch, Search and Settings share one row */
@media (max-width: 520px) {
  .m-title { gap: 8px; }
  .m-title h1 { text-align: left; font-size: 19px; }
  .m-title .sub { text-align: left; }
  .m-title .m-actions { gap: 6px; }
  .m-title .cbtn { width: 36px; height: 36px; padding: 8px; }
  .m-title .sb-switch { padding: 7px 11px; }
  .m-title .sub-years { display: none; }   /* the count fits; the years show on the scrubber */
}
@media (max-width: 380px) {
  .m-title h1 { font-size: 17.5px; }
  .m-title .sb-switch { padding: 7px 9px; font-size: 12.5px; }
}
.backup-row { align-items: center; gap: 8px; }
.m-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
.m-tools .cbtn { width: 34px; height: 34px; padding: 7px; }
.m-select { padding: 7px 14px; }

/* while choosing, the title row gives way to the count (same height, so nothing jumps) */
#memories:not(.selecting) .m-selhead,
#memories.selecting .m-title:not(.m-selhead) { display: none; }
.m-selhead h1 { text-align: center; }
.m-selhead .sel-count { display: block; }
.m-selhead .sub { text-align: center; }
.m-selhead .sel-all { flex: none; padding: 7px 12px; font-size: 13px; }
#memories.selecting .m-tools { visibility: hidden; }

/* ------------------------------------------------------------- choosing memories */
#memories { touch-action: pan-x pan-y; }   /* two fingers resize the grid instead of zooming the page */
#memories .grid .tile { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
#memories.selecting .grid .tile::after {
  content: ""; position: absolute; right: 6px; top: 6px; z-index: 2; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #fff; background: rgba(0,0,0,.2) center / 14px no-repeat; box-shadow: 0 1px 4px rgba(0,0,0,.45);
}
#memories.selecting .grid .tile.picked::after {
  background-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23121214' stroke-width='3.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}
#memories.selecting .grid .tile.picked::before {
  content: ""; position: absolute; inset: 0; z-index: 1; border: 3px solid var(--accent); border-radius: 3px; pointer-events: none;
}
#memories.selecting .grid .tile.picked img { opacity: .8; }
#memories.selecting .grid .tile .fav { right: auto; left: 6px; }

.month-pick {
  display: none; margin-left: auto; border: 0; border-radius: 999px; background: var(--chip); color: var(--fg);
  font-weight: 800; font-size: 12.5px; padding: 5px 12px;
}
.month-pick[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }
#memories.selecting .month-pick { display: inline-block; }
#memories.selecting .month-play { display: none; }
#memories.selecting .m-foot { height: calc(var(--safe-b) + 120px); }

.sel-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 33; display: flex; justify-content: center; gap: 2px;
  padding: 6px 6px calc(var(--safe-b) + 6px); color: var(--fg);
  background: color-mix(in srgb, var(--bg) 92%, transparent); border-top: 1px solid var(--line);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  animation: rise .2s cubic-bezier(.2,.8,.2,1);
}
.sel-bar button {
  flex: 1; max-width: 96px; border: 0; background: none; color: inherit; border-radius: 12px; padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 700;
}
.sel-bar button:active:not(:disabled) { background: var(--chip); }
.sel-bar .ico { width: 24px; height: 24px; display: block; }
.sel-bar .ico svg { width: 100%; height: 100%; display: block; }
.sel-bar button:disabled { opacity: .35; cursor: default; }
.sel-bar button.on .ico { color: var(--heart); }
.sel-bar [data-act="delete"] { color: var(--heart); }
#memScrubber.selecting { bottom: calc(var(--safe-b) + 84px); }

/* ------------------------------------------------------------- pinch: 3 / 4 / 5 / 7 across */
#memories[data-cols="5"] .tile .badge { font-size: 10.5px; left: 4px; bottom: 3px; }
#memories[data-cols="7"] .tile { border-radius: 2px; }
#memories[data-cols="7"] .tile .badge { font-size: 0; left: 3px; bottom: 2px; }
#memories[data-cols="7"] .tile .badge svg { width: 10px; height: 10px; }
#memories[data-cols="7"] .tile .sync { display: none; }
#memories[data-cols="7"] .tile .fav { width: 12px; height: 12px; top: 3px; right: 3px; }
#memories[data-cols="7"].selecting .grid .tile .fav { left: 3px; }
#memories[data-cols="7"].selecting .grid .tile::after { width: 16px; height: 16px; right: 3px; top: 3px; border-width: 1.5px; background-size: 10px; }

/* ------------------------------------------------------------- scrubber: years while dragging */
.scrub-pill .py { font-weight: 900; }
#memScrubber.dragging .scrub-pill { right: 96px; }
#memScrubber.dragging .scrub-pill .py { font-size: 18px; }
.scrub-years { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .2s; }
#memScrubber.dragging .scrub-years { opacity: 1; }
.scrub-year {
  position: absolute; right: 38px; transform: translateY(-50%); padding: 2px 7px; border-radius: 999px;
  font-size: 11.5px; font-weight: 800; color: var(--muted); background: var(--bg); box-shadow: 0 1px 6px rgba(0,0,0,.14);
  font-variant-numeric: tabular-nums;
}
.scrub-year.on { color: var(--chip-on-fg); background: var(--chip-on); }

/* ------------------------------------------------------------- fingers and eyes */
/* the header's small buttons (34–36px on a phone) and a month's Select keep their look, but
   answer a 44px tap */
#memories .cbtn, .sb-switch, .month-pick, .m-select, .sel-all { position: relative; }
#memories .cbtn::after, .sb-switch::after, .month-pick::after, .m-select::after, .sel-all::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: 44px; transform: translate(-50%, -50%);
}
/* "Delete" under the chosen memories: the pink is too faint on white to read (3.5:1) */
.sel-bar [data-act="delete"] { color: #c8102e; }
@media (prefers-color-scheme: dark) { .sel-bar [data-act="delete"] { color: var(--heart); } }
