/*
 * The shelf (wishlists/_shelf): Minhas listas and a friend's page. A warm
 * wall with two planks of three spots; each list on display is a drawn gift
 * box in its colour (list-color-*, --c), with a pattern, as tall as what's
 * inside (fill-0 to fill-12), a paper label and a little tag for who sees it.
 * A free spot is just plank. Beside it, the band's cards. Below, the lists
 * off the shelf, three rows at a time (show_more_controller.js).
 */
.app {
  .shelf-band { grid-template-columns: minmax(0, 1fr) 400px; align-items: center; gap: 36px; padding: 28px 32px;
    background: var(--wall); background-image: repeating-linear-gradient(90deg, var(--wall-line) 0 2px, transparent 2px 46px); }
  .shelf-side { display: grid; gap: 10px; min-width: 0; --spot: 112px; --box: 104px; --row-h: 168px; --base: 100px; --step: 4px; }
  .shelf-side .crumb { justify-self: start; }
  .shelf-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 6px 20px; }
  .shelf-head h1 { font-size: clamp(30px, 3.6vw, 40px); font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
  .shelf-head .shelf-count { font-family: var(--sans); font-size: 15px; font-weight: 700; color: var(--muted); letter-spacing: 0; }
  .friend-title { display: flex; align-items: center; gap: 12px; }
  .friend-title .avatar { width: 46px; height: 46px; }
  .shelf-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; font-weight: 600; color: var(--muted); }
  .shelf-stats > span { display: inline-flex; gap: 6px; align-items: center; }
  .shelf-stats b { color: var(--ink); font-variant-numeric: tabular-nums; }
  .shelf-stats svg.icon { width: 15px; height: 15px; color: var(--wood-dark); }
  .shelf-empty { padding: 26px 0; max-width: 40ch; color: var(--muted); }
  .shelf-empty b { color: var(--ink); }
  .shelf-actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 16px; }

  /* Two planks of three spots */
  .shelf { display: grid; gap: 6px; }
  .shelf-row { position: relative; }
  .shelf-row::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -10px; height: 10px; background: radial-gradient(ellipse at 50% 0, rgba(0, 0, 0, .12), transparent 70%); }
  .shelf-spots { display: grid; grid-template-columns: repeat(3, var(--spot)); justify-content: space-around; align-items: end; min-height: var(--row-h); padding: 18px 12px 0; }
  .plank { height: 16px; border-radius: 3px; background: linear-gradient(var(--wood-edge) 0 3px, var(--wood) 3px 11px, var(--wood-dark) 11px); box-shadow: 0 10px 14px -10px rgba(0, 0, 0, .45); }
  .shelf-spot { position: relative; display: grid; justify-items: center; width: var(--spot); }

  /* A list: a drawn box */
  .shelf-box { position: relative; display: grid; justify-items: center; color: var(--ink); text-decoration: none; --n: 0; }
  .shelf-box:hover { text-decoration: none; }
  .shelf-box .gbox { position: relative; width: var(--box); height: calc(var(--base) + var(--n) * var(--step)); transform-origin: 50% 100%; transition: transform .45s cubic-bezier(.3, 1.35, .5, 1); }
  .shelf-box .body { position: absolute; inset: 18px 4px 0; border-radius: 4px 4px 2px 2px; background: var(--c); box-shadow: inset -12px 0 0 rgba(0, 0, 0, .09); }
  .shelf-box.pattern-dots .body { background-image: radial-gradient(circle, rgba(255, 255, 255, .28) 2px, transparent 2.6px); background-size: 12px 12px; }
  .shelf-box.pattern-stripes .body { background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, .18) 0 4px, transparent 4px 10px); }
  .shelf-box .rib { position: absolute; left: 50%; top: 18px; bottom: 0; width: 13px; translate: -50% 0; background: var(--ribbon); }
  .shelf-box .lid { position: absolute; left: 0; right: 0; top: 9px; height: 15px; border-radius: 4px; background: color-mix(in srgb, var(--c) 82%, #000000); transition: transform .45s cubic-bezier(.3, 1.35, .5, 1); }
  .shelf-box .lid::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 13px; translate: -50% 0; background: var(--ribbon); }
  .shelf-box .bow { position: absolute; left: 50%; top: 10px; width: 46px; height: 26px; translate: -50% -72%; fill: var(--ribbon); transition: transform .45s cubic-bezier(.3, 1.35, .5, 1); }
  .shelf-box .bow .shade { fill: rgba(0, 0, 0, .18); }
  .shelf-box .label { position: absolute; z-index: 1; left: 10px; right: 10px; bottom: 12px; display: grid; gap: 1px; padding: 6px 5px 5px; border-radius: 4px; background: var(--paper); box-shadow: 0 1px 0 rgba(0, 0, 0, .12); text-align: center; }
  .shelf-box .label b { font-size: 12px; line-height: 1.2; overflow-wrap: break-word; hyphens: auto; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .shelf-box .label small { font-size: 10.5px; font-weight: 700; color: var(--muted); }
  /* Who sees it: a little tag on the box */
  .shelf-box .hang { position: absolute; z-index: 2; top: 22px; right: -9px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--paper); color: var(--ink);
    box-shadow: 0 0 0 1.5px var(--line), 0 3px 6px -3px rgba(0, 0, 0, .35); transform-origin: 50% 0; }
  .shelf-box .hang svg.icon { width: 13px; height: 13px; }
  .shelf-box .hang.audience-friends { color: var(--second); }
  .shelf-box .hang.audience-link { color: var(--accent); }
  .shelf-box:is(:hover, :focus-visible) .gbox { transform: translateY(-6px) rotate(-1.5deg); }
  .shelf-box:is(:hover, :focus-visible) :is(.lid, .bow) { transform: translateY(-5px) rotate(-3deg); }
  .shelf-box:hover .hang { animation: shelf-swing .9s ease; }
  .shelf-box:focus-visible { outline: none; }
  .shelf-box:focus-visible .label { outline: 3px solid var(--accent); outline-offset: 2px; }
  .fill-1 { --n: 1; } .fill-2 { --n: 2; } .fill-3 { --n: 3; } .fill-4 { --n: 4; } .fill-5 { --n: 5; } .fill-6 { --n: 6; }
  .fill-7 { --n: 7; } .fill-8 { --n: 8; } .fill-9 { --n: 9; } .fill-10 { --n: 10; } .fill-11 { --n: 11; } .fill-12 { --n: 12; }

  /* The owner's controls, on the plank under the box */
  .shelf-controls { position: absolute; z-index: 3; bottom: -20px; left: 50%; translate: -50% 0; display: flex; gap: 4px; opacity: 0; transition: opacity .2s; }
  .shelf-spot:is(:hover, :focus-within) .shelf-controls { opacity: 1; }
  .shelf-controls .button_to { display: contents; }
  .shelf-controls .mini-btn { width: 26px; height: 26px; }
  .shelf-controls .mini-btn svg.icon { width: 13px; height: 13px; }
  .shelf-controls .take-off:hover { color: var(--danger); box-shadow: 0 0 0 1.5px var(--danger); }

  /* The lists off the shelf: the shelf button sits beside the name, over nothing */
  .off-shelf .list-card .body { grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; }
  .off-shelf .list-card .body > :not(.card-actions) { grid-column: 1; }
  .off-shelf .list-card .card-actions { grid-column: 2; grid-row: 1 / span 4; align-self: center; position: static; opacity: 1; margin: 0; }
  .off-shelf .shelf-btn { width: 34px; height: 34px; }
  .off-shelf .shelf-btn svg.icon { width: 17px; height: 17px; }
  .off-shelf .shelf-btn:disabled { opacity: .5; cursor: not-allowed; }
  :is(.off-shelf, .friend-lists, .followed) .list-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
  .show-more { justify-self: center; margin-top: 4px; }

  /* The cards beside the shelf */
  .shelf-band .tag-card .mini-gifts { display: flex; gap: 6px; }
  .shelf-band .tag-card .mini-gifts .gift-picture { width: 52px; height: 60px; aspect-ratio: auto; border-radius: 10px; }

  /* The shelf modal: which lists go on display */
  .shelf-pick { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 12px 8px 8px; border-radius: var(--radius-sm);
    background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--line); cursor: pointer; font-weight: 400; }
  .shelf-pick:has(:checked) { box-shadow: inset 0 0 0 2px var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--paper)); }
  .shelf-pick:has(:disabled) { opacity: .5; cursor: not-allowed; }
  .shelf-pick:has(:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
  .shelf-pick .pick-box { width: 44px; height: 44px; border-radius: 8px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 18%, var(--paper)); }
  .shelf-pick .pick-box::after { content: ""; width: 20px; height: 18px; border-radius: 3px; background: var(--c); box-shadow: inset 0 4px 0 color-mix(in srgb, var(--c) 80%, #000000); }
  .shelf-pick .pick-text { display: grid; gap: 2px; min-width: 0; }
  .shelf-pick b { font-size: 15px; overflow-wrap: anywhere; }
  .shelf-pick small { font-size: 12px; font-weight: 600; color: var(--muted); }
  .shelf-pick .tick { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; box-shadow: inset 0 0 0 1.5px var(--line); color: var(--on-accent); }
  .shelf-pick:has(:checked) .tick { background: var(--accent); box-shadow: none; }
  .shelf-pick .tick svg.icon { width: 14px; height: 14px; opacity: 0; }
  .shelf-pick:has(:checked) .tick svg.icon { opacity: 1; }
  .shelf-counter { margin-right: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
}

@media (max-width: 900px) {
  .app .shelf-band { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .app {
    .shelf-band { padding: 18px 16px 20px; gap: 18px; }
    .shelf-side { --spot: 98px; --box: 90px; --row-h: 146px; --base: 92px; --step: 4px; }
    .shelf-head h1 { font-size: 28px; }
    .shelf-stats > span:nth-child(n+2) { display: none; }
    .shelf-spots { padding: 14px 0 0; }
    .shelf-box .label { left: 7px; right: 7px; }
    .shelf-box .label b { font-size: 10.5px; letter-spacing: -.01em; }
    .shelf-box .label small { font-size: 9.5px; }
    .shelf-box .bow { width: 38px; height: 22px; }
    .shelf-controls { opacity: 1; }
    .shelf-actions { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }
    .shelf-actions .btn { flex-direction: column; gap: 4px; padding: 9px 4px; font-size: 12.5px; line-height: 1.2; white-space: normal; text-align: center; }
    /* Bigger rows for the lists below */
    :is(.off-shelf, .friend-lists, .followed) .list-card { grid-template-columns: 80px minmax(0, 1fr) auto; column-gap: 14px; padding: 10px 14px 10px 10px; }
    :is(.off-shelf, .friend-lists, .followed) .list-card .shelf-area { width: 80px; height: 80px; }
    .page :is(.off-shelf, .friend-lists, .followed) .list-card .shelf .gift-picture { width: 30px; height: 30px; }
    :is(.off-shelf, .friend-lists, .followed) .list-card .title { font-size: 18px; }
    .off-shelf .list-card::after { content: none; }
  }
}

@keyframes shelf-swing { 25% { transform: rotate(14deg); } 60% { transform: rotate(-8deg); } }

@media (prefers-reduced-motion: reduce) {
  .app :is(.shelf-box .gbox, .shelf-box .lid, .shelf-box .bow) { transition: none; }
  .app .shelf-box:hover .hang { animation: none; }
}
