/* The Shelf, the boy-or-girl picker and the Name sheet for the 3D studio (WP8b).
   Built on the site's pastel storybook tokens (public/assets/style.css). Every class starts with
   `dl-` so nothing here collides with the studio's own inline styles. Touch targets are 56 px or
   more, nothing needs reading, and reduced motion turns the wiggles off. */

/* ---- the sheet: a scrim plus a panel that slides up from the bottom ---- */
.dl-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(91, 74, 99, .32); display: flex; align-items: flex-end;
  justify-content: center; animation: dl-fade .2s ease-out; touch-action: manipulation; }
.dl-scrim.dl-closing { animation: dl-fade-out .18s ease-in forwards; }
.dl-sheet { position: relative; width: min(100%, 760px); max-height: min(82dvh, 660px); display: flex; flex-direction: column;
  border-radius: 30px 30px 0 0; border: 4px solid #fff; border-bottom: none; color: var(--ink);
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -14px 40px var(--shadow-strong);
  /* felt: a soft blush with a fine woven dot, and a stitched edge just inside the border */
  background: radial-gradient(rgba(255, 255, 255, .38) 1px, transparent 1.6px) 0 0 / 7px 7px, linear-gradient(180deg, #fff3f7, #fde6ef);
  animation: dl-up .28s cubic-bezier(.25, 1.3, .5, 1); }
.dl-sheet::before { content: ""; position: absolute; inset: 7px 7px 0; border: 2px dashed rgba(255, 255, 255, .95); border-bottom: none;
  border-radius: 24px 24px 0 0; pointer-events: none; }
.dl-closing .dl-sheet { animation: dl-down .18s ease-in forwards; }
.dl-grab { width: 54px; height: 6px; border-radius: 6px; background: rgba(168, 126, 232, .35); margin: 2px auto 6px; flex: 0 0 auto; }
.dl-head { display: flex; align-items: center; gap: 10px; padding: 2px 4px 8px; flex: 0 0 auto; min-width: 0; }
.dl-title { font-family: var(--display); font-weight: 600; font-size: 1.35rem; margin: 0; flex: 1 1 auto; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-sheet button { font-family: var(--display); color: var(--ink); touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.dl-sheet button:focus-visible { outline: 4px solid #7a4fc9; outline-offset: 3px; }
.dl-round { flex: 0 0 auto; width: 56px; height: 56px; border-radius: 50%; border: 3px solid #fff; background: #fff; font-size: 1.45rem;
  line-height: 1; display: grid; place-items: center; cursor: pointer; padding: 0; box-shadow: 0 5px 12px var(--shadow);
  transition: transform .1s ease; }
.dl-round:active { transform: scale(.9); }
.dl-round:disabled { opacity: .38; cursor: default; box-shadow: none; }
.dl-body { min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; flex: 1 1 auto; scrollbar-width: thin; }
.dl-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* a speech bubble for things she hears (the words are there for grown-ups) */
.dl-bubble { position: absolute; left: 50%; top: -14px; transform: translate(-50%, -100%); z-index: 3; pointer-events: none;
  background: #fff; color: var(--ink); font-family: var(--display); font-size: 1.05rem; text-align: center; padding: 10px 16px;
  border-radius: 20px; border: 3px solid var(--lavender); box-shadow: 0 10px 24px var(--shadow-strong); width: max-content;
  max-width: min(92vw, 440px); opacity: 0; transition: opacity .2s ease; }
.dl-bubble.dl-show { opacity: 1; }

/* ---- the Shelf ---- */
.dl-shelf { --row: 152px; }
.dl-count[hidden] { display: none; }
.dl-count { font-family: var(--display); font-size: .95rem; color: var(--ink); background: rgba(255, 255, 255, .8); border-radius: 999px;
  padding: 4px 10px; flex: 0 0 auto; }
/* Rows of tiles sit on lavender felt planks: one plank per grid row, drawn behind the grid. */
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); grid-auto-rows: var(--row); column-gap: 8px;
  padding: 0 6px; justify-items: center;
  background: linear-gradient(180deg, transparent calc(100% - 20px), rgba(255, 255, 255, .8) calc(100% - 20px), rgba(255, 255, 255, .8) calc(100% - 18px),
    #d9c6f5 calc(100% - 18px), #c9b0f0 calc(100% - 6px), rgba(120, 90, 140, .16) calc(100% - 6px), transparent 100%) 0 0 / 100% var(--row); }
.dl-tile { position: relative; width: 104px; align-self: end; margin-bottom: 16px; display: flex; flex-direction: column; align-items: center; }
.dl-doll, .dl-add { position: relative; width: 104px; padding: 0; border: none; background: none; cursor: pointer; display: flex;
  flex-direction: column; align-items: center; gap: 3px; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  touch-action: pan-y; }
.dl-pic { position: relative; width: 96px; height: 96px; border-radius: 50%; background: #fff; border: 4px solid #fff; overflow: hidden;
  display: grid; place-items: center; box-shadow: 0 6px 14px var(--shadow); transition: transform .12s ease, box-shadow .15s ease; }
.dl-pic img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; -webkit-user-drag: none; }
.dl-ph { font-size: 2.4rem; opacity: .4; animation: dl-wob 1.4s ease-in-out infinite; }
.dl-doll:active .dl-pic, .dl-add:active .dl-pic { transform: scale(.94); }
/* keyboard focus rings the round portrait, not the whole tile */
.dl-sheet .dl-doll:focus-visible, .dl-sheet .dl-add:focus-visible { outline: none; }
.dl-doll:focus-visible .dl-pic, .dl-add:focus-visible .dl-pic { outline: 4px solid #7a4fc9; outline-offset: 4px; }
.dl-name { font-family: var(--display); font-size: 1rem; line-height: 1.15; max-width: 104px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; background: rgba(255, 255, 255, .85); padding: 1px 8px; border-radius: 999px; }
.dl-doll.dl-on .dl-pic { border-color: var(--pink); box-shadow: 0 0 0 4px var(--pink), 0 8px 16px var(--shadow); background: var(--blush); }
.dl-doll.dl-on::after { content: "✓"; position: absolute; top: -4px; right: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--pink-deep);
  color: #fff; border: 3px solid #fff; font: 700 15px/24px var(--body); text-align: center; }
/* the hold ring: fills round the portrait while a finger stays down */
.dl-ring { position: absolute; left: 50%; top: -6px; width: 108px; height: 108px; transform: translateX(-50%) rotate(-90deg); pointer-events: none; overflow: visible; }
.dl-ring circle { fill: none; stroke: var(--lavender-deep); stroke-width: 7; stroke-linecap: round; stroke-dasharray: 327; stroke-dashoffset: 327;
  opacity: 0; transition: stroke-dashoffset .2s ease, opacity .2s ease; }
.dl-holding .dl-ring circle { stroke-dashoffset: 0; opacity: 1; transition: stroke-dashoffset 1s linear, opacity .1s ease; }
.dl-holding .dl-pic { transform: scale(.95); }
/* 🏠: she lives in the dollhouse (a button when the studio can move her in from here) */
/* (a round 56 px hit area pushed out on the tile's corner, so it barely touches the portrait's own
   tap area – a round button only takes taps inside its circle) */
.dl-house { position: absolute; left: -18px; top: -20px; width: 56px; height: 56px; border-radius: 50%; padding: 0; border: none; background: none;
  cursor: pointer; display: grid; place-items: center; z-index: 2; }
.dl-house span { width: 36px; height: 36px; border-radius: 50%; background: #fff; border: 3px solid #fff; font-size: 1.1rem; line-height: 30px;
  text-align: center; box-shadow: 0 4px 10px var(--shadow); }
.dl-house.dl-lives span { background: var(--mint); }
.dl-house.dl-not span { opacity: .5; filter: grayscale(.6); border-style: dashed; border-color: var(--lavender); }
.dl-house:active span { transform: scale(.9); }
span.dl-house { pointer-events: none; }
/* ＋ and the full shelf */
.dl-add .dl-pic { background: rgba(255, 255, 255, .7); border: 4px dashed var(--pink); font-size: 3rem; color: var(--pink-deep); font-weight: 600; }
.dl-add.dl-full .dl-pic { border: 4px solid #fff; background: #fff4c9; font-size: 1.5rem; line-height: 1; }
.dl-full-shelf { display: grid; grid-template-columns: repeat(3, auto); gap: 0 1px; padding-bottom: 4px; border-bottom: 4px solid #c9b0f0; }
/* goodbye: she waves and floats away; undo pops her back */
.dl-tile.dl-leaving { animation: dl-float 0.9s ease-in forwards; pointer-events: none; }
.dl-tile.dl-leaving .dl-pic::after { content: "👋"; position: absolute; right: -2px; bottom: -2px; font-size: 2rem; animation: dl-wave .3s ease-in-out infinite alternate; }
.dl-tile.dl-back, .dl-tile.dl-new { animation: dl-popin .45s cubic-bezier(.3, 1.6, .5, 1); }

/* the ↩️ after a goodbye, with an 8 s ring running down */
.dl-undo { position: relative; flex: 0 0 auto; width: 60px; height: 60px; border-radius: 50%;
  border: none; padding: 0; cursor: pointer; font-size: 1.7rem; display: grid; place-items: center; box-shadow: 0 8px 18px var(--shadow-strong);
  background: conic-gradient(var(--lavender-deep) calc(var(--left, 1) * 360deg), #fff 0); animation: dl-popin .3s cubic-bezier(.3, 1.6, .5, 1); }
.dl-undo span { width: 48px; height: 48px; border-radius: 50%; background: #fff; display: grid; place-items: center; }
.dl-undo[hidden] { display: none; }

/* ---- the goodbye card ---- */
/* It covers the whole screen, not just the sheet: a shelf with one row of dolls is shorter than the card,
   which then ran off the bottom and hid 👋 Goodbye. */
.dl-confirm-bg { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(255, 243, 247, .82);
  animation: dl-fade .15s ease-out; padding: 12px; overflow-y: auto; overscroll-behavior: contain; }
.dl-confirm { background: #fff; border: 4px solid #fff; border-radius: 28px; box-shadow: 0 18px 40px var(--shadow-strong); padding: 18px 18px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(100%, 340px); animation: dl-popin .3s cubic-bezier(.3, 1.5, .5, 1); }
.dl-confirm .dl-pic { width: 112px; height: 112px; }
.dl-q { font-family: var(--display); font-size: 1.35rem; text-align: center; margin: 0; line-height: 1.2; }
.dl-keep { width: 100%; min-height: 72px; font-size: 1.45rem !important; border: none; border-radius: 999px; cursor: pointer; color: #1f5039 !important;
  background: linear-gradient(180deg, var(--mint), var(--mint-deep)); box-shadow: 0 8px 0 0 #4caa7d, 0 12px 18px var(--shadow); }
.dl-keep:active { transform: translateY(5px); box-shadow: 0 3px 0 0 #4caa7d; }
.dl-bye { position: relative; min-height: 56px; min-width: 170px; padding: 0 20px; font-size: 1.05rem !important; border-radius: 999px; cursor: pointer;
  border: 3px solid #f3e6fb; background: #fff; overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.dl-bye .dl-fill { position: absolute; inset: 0; background: var(--blush); transform: scaleX(0); transform-origin: left; transition: transform .2s ease; }
.dl-bye.dl-holding .dl-fill { transform: scaleX(1); transition: transform 1s linear; }
.dl-bye .dl-lbl { position: relative; }
.dl-hint-hold { font-size: .85rem; color: var(--ink); margin: -6px 0 0; }

/* ---- boy or girl ---- */
.dl-kinds { display: flex; gap: 14px; justify-content: center; padding: 6px 4px 8px; flex-wrap: wrap; }
.dl-kind { position: relative; flex: 1 1 150px; max-width: 230px; min-height: 220px; border-radius: 28px; border: 4px solid #fff; cursor: pointer; padding: 10px 8px 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; box-shadow: 0 10px 22px var(--shadow);
  transition: transform .12s ease; }
.dl-kind:active { transform: scale(.95); }
.dl-kind.dl-girl { background: linear-gradient(180deg, #ffe3ee, #ffd0e2); }
.dl-kind.dl-boy { background: linear-gradient(180deg, #e2f1ff, #cbe6ff); }
.dl-kind .dl-full-pic { width: 100%; flex: 1 1 auto; min-height: 150px; display: grid; place-items: center; }
.dl-kind .dl-full-pic img { max-width: 100%; max-height: 180px; object-fit: contain; display: block; pointer-events: none; }
.dl-kind .dl-em { position: absolute; top: -12px; right: -8px; width: 62px; height: 62px; border-radius: 50%; background: #fff; border: 3px solid #fff;
  display: grid; place-items: center; font-size: 2.2rem; box-shadow: 0 6px 12px var(--shadow); }
.dl-kind .dl-lbl { font-size: 1.2rem; background: rgba(255, 255, 255, .85); border-radius: 999px; padding: 2px 14px; }

/* ---- the Name sheet ---- */
.dl-namesheet { max-height: min(70dvh, 460px); }
.dl-tag { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 22px; padding: 4px 6px 4px 12px;
  box-shadow: inset 0 0 0 3px #f6e8fb, 0 4px 10px var(--shadow); min-height: 64px; overflow: hidden; }
.dl-tag-em { font-size: 1.9rem; flex: 0 0 auto; line-height: 1; }
.dl-tag-name { font-family: var(--display); font-weight: 600; font-size: 1.75rem; line-height: 1.1; min-width: 0; flex: 1 1 auto; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.dl-tag .dl-round { width: 56px; height: 56px; box-shadow: none; background: #f3eafc; }
.dl-tag.dl-sparkle { animation: dl-tagpop .5s cubic-bezier(.3, 1.6, .5, 1); }
.dl-tag.dl-rolling .dl-tag-name, .dl-tag.dl-rolling .dl-tag-em { animation: dl-reel .09s linear infinite; }
.dl-done { flex: 0 0 auto; width: 72px; height: 64px; border-radius: 22px; border: 3px solid #fff; cursor: pointer; font-size: 1.9rem; padding: 0;
  background: linear-gradient(180deg, var(--mint), var(--mint-deep)); box-shadow: 0 6px 0 0 #4caa7d, 0 10px 16px var(--shadow); color: #1f5039 !important; }
.dl-done:active { transform: translateY(4px); box-shadow: 0 2px 0 0 #4caa7d; }
.dl-namebody { display: flex; gap: 10px; min-height: 0; align-items: stretch; }
.dl-tools { display: flex; flex-direction: column; gap: 10px; justify-content: center; flex: 0 0 auto; padding: 4px 0; }
.dl-tools .dl-round { width: 60px; height: 60px; font-size: 1.7rem; }
.dl-names { flex: 1 1 auto; min-width: 0; display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, 94px); grid-auto-columns: 88px;
  gap: 10px; overflow-x: auto; overflow-y: hidden; padding: 8px 6px 10px; scroll-snap-type: x proximity; overscroll-behavior: contain;
  scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
.dl-names::-webkit-scrollbar { display: none; }
.dl-card { position: relative; width: 88px; height: 94px; border-radius: 22px; border: 3px solid #fff; background: #fff; cursor: pointer; padding: 4px 2px 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; box-shadow: 0 5px 12px var(--shadow);
  scroll-snap-align: start; transition: transform .1s ease, opacity .2s ease; }
.dl-card:active { transform: scale(.92); }
.dl-card .dl-em { font-size: 2.3rem; line-height: 1.05; }
.dl-card .dl-lbl { font-size: .98rem; max-width: 82px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* used by another doll: a faded card, but the name keeps full contrast (it can still be tapped) */
.dl-card.dl-used { background: #f3eefa; border-color: #f3eefa; box-shadow: none; }
.dl-card.dl-used .dl-em { opacity: .5; }
.dl-card.dl-on { border-color: var(--pink); background: var(--blush); box-shadow: 0 0 0 3px var(--pink), 0 6px 14px var(--shadow); opacity: 1; }
.dl-card.dl-me { background: linear-gradient(180deg, #fff8d6, var(--butter)); }
.dl-card.dl-me.dl-on { background: var(--blush); }
.dl-card.dl-pen { background: #f3eafc; }
.dl-card.dl-landed { animation: dl-tagpop .5s cubic-bezier(.3, 1.6, .5, 1); }
.dl-names.dl-spin .dl-card { animation: dl-spin .16s linear infinite; }
.dl-spark { position: absolute; pointer-events: none; font-size: 1.1rem; animation: dl-spark .6s ease-out forwards; z-index: 3; }
.dl-type { display: flex; gap: 8px; align-items: center; padding: 0 4px 8px; }
.dl-type[hidden] { display: none; }
.dl-type input { flex: 1 1 auto; min-width: 0; height: 56px; font-family: var(--display); font-size: 1.25rem; padding: 0 14px; border: 3px solid #fff;
  border-radius: 18px; background: #fff; color: var(--ink); box-shadow: inset 0 2px 6px rgba(120, 90, 140, .08); }
.dl-type input:focus-visible { outline: 4px solid #7a4fc9; outline-offset: 2px; }
.dl-type .dl-ok { min-width: 72px; height: 56px; border-radius: 18px; border: 3px solid #fff; background: var(--lavender); font-size: 1.1rem; cursor: pointer; }

/* ---- wide screens (the studio puts the tray beside the stage): the Name sheet sits over the tray ---- */
@media (min-aspect-ratio: 5/4) {
  .dl-scrim.dl-side { justify-content: flex-end; background: rgba(91, 74, 99, .16); }
  .dl-side .dl-sheet { width: clamp(300px, 36vw, 460px); max-height: min(86dvh, 640px); border-radius: 30px 0 0 0; border-right: none; }
  .dl-side .dl-names { grid-auto-flow: row; grid-template-rows: none; grid-template-columns: repeat(auto-fill, 88px); grid-auto-rows: 94px; overflow-x: hidden;
    overflow-y: auto; max-height: 320px; -webkit-mask-image: none; mask-image: none; justify-content: center; }
  .dl-side .dl-namebody { flex-direction: column; flex: 1 1 auto; }
  /* a short screen (a laptop at 200 %): the cards shrink to the room there is and scroll inside,
     rather than running out of the sheet */
  .dl-side .dl-namesheet .dl-body { display: flex; flex-direction: column; overflow: hidden; }
  .dl-side .dl-names { flex: 1 1 auto; min-height: 0; }
  .dl-side .dl-tools { flex-direction: row; justify-content: flex-start; padding: 0 4px; }
}
/* short landscape phones: sheets use the full height */
@media (max-height: 520px) {
  .dl-sheet { max-height: 96dvh; }
  .dl-shelf { --row: 146px; }
  .dl-kind { min-height: 170px; }
  .dl-kind .dl-full-pic { min-height: 110px; }
  .dl-kind .dl-full-pic img { max-height: 120px; }
  .dl-confirm { gap: 8px; padding: 12px 16px 10px; }
  .dl-confirm .dl-pic { width: 76px; height: 76px; }
  .dl-q { font-size: 1.2rem; }
  .dl-keep { min-height: 60px; }
}
@media (max-width: 380px) {
  .dl-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); column-gap: 4px; padding: 0 2px; }
  .dl-tag-name { font-size: 1.45rem; }
}

@keyframes dl-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dl-fade-out { to { opacity: 0; } }
@keyframes dl-up { from { transform: translateY(40%); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes dl-down { to { transform: translateY(50%); opacity: 0; } }
@keyframes dl-popin { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes dl-wob { 0%, 100% { transform: rotate(-10deg); } 50% { transform: rotate(10deg) scale(1.08); } }
@keyframes dl-float { 0% { transform: none; opacity: 1; } 25% { transform: rotate(-6deg) translateY(-6px); } 50% { transform: rotate(6deg) translateY(-24px); opacity: .9; }
  100% { transform: rotate(-4deg) translateY(-120px) scale(.7); opacity: 0; } }
@keyframes dl-wave { from { transform: rotate(-18deg); } to { transform: rotate(18deg); } }
@keyframes dl-tagpop { 0% { transform: scale(1); } 40% { transform: scale(1.08) rotate(-2deg); } 100% { transform: scale(1); } }
@keyframes dl-reel { 0% { transform: translateY(-40%); opacity: .2; } 50% { opacity: 1; } 100% { transform: translateY(40%); opacity: .2; } }
@keyframes dl-spin { 0% { transform: translateY(-6px); } 50% { transform: translateY(6px); } 100% { transform: translateY(-6px); } }
@keyframes dl-spark { from { transform: translate(0, 0) scale(.6); opacity: 1; } to { transform: translate(var(--dx, 0), var(--dy, -30px)) scale(1.2); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .dl-scrim, .dl-sheet, .dl-confirm, .dl-confirm-bg, .dl-undo, .dl-tile.dl-back, .dl-tile.dl-new { animation: none; }
  .dl-closing .dl-sheet, .dl-scrim.dl-closing { animation: dl-fade-out .12s linear forwards; }
  .dl-ph, .dl-tag.dl-sparkle, .dl-card.dl-landed, .dl-names.dl-spin .dl-card, .dl-tag.dl-rolling .dl-tag-name, .dl-tag.dl-rolling .dl-tag-em { animation: none; }
  .dl-tile.dl-leaving { animation: dl-fade-out .4s linear forwards; }
  .dl-tile.dl-leaving .dl-pic::after { animation: none; }
  .dl-spark { display: none; }
}
