/* Data repository: the catalogue on /data (src/features/data/drawers.js).
   A clean catalogue in purple and white: one card per dataset with its
   catalogue entry and downloads; "Details" opens a panel under the card
   (preview, catalogue card, citation) across the full width.
   Prefix dw-. Motion: public/assets/js/data-drawers.js. */

.dw-wall { position: relative; margin-top: var(--s-2); }

.dw-shelf.dr-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  grid-auto-flow: row dense;
  gap: clamp(1rem, 2vw, 1.5rem);
  border: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---------------------------------------------------------------- Card */

.dw-box { position: relative; min-width: 0; }
.dw-unit { height: 100%; display: flex; flex-direction: column; border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 4px; background: var(--paper); transition: border-color 0.2s, box-shadow 0.2s; }
.dw-box:hover .dw-unit, .dw-box:focus-within .dw-unit { border-color: var(--accent-soft); border-top-color: var(--accent); box-shadow: 0 12px 26px -20px rgba(42, 27, 69, 0.45); }

.dw-front { position: relative; flex: 1; display: flex; flex-direction: column; gap: 0.75rem; padding: 1rem 1.1rem 0.9rem; color: var(--text); }
.dw-kind { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin: 0; }
.dw-no { font: 600 0.72rem/1 var(--font); letter-spacing: 0.06em; color: var(--muted); font-variant-numeric: tabular-nums; }

.dw-holder { position: relative; }
.dw-title { margin: 0 0 0.6rem; font-family: var(--font-serif); font-weight: 560; font-size: 1.22rem; line-height: 1.22; letter-spacing: -0.01em; }
.dw-title a { color: var(--ink); text-decoration: none; }
.dw-title a:hover { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 3px; }
.dw-label { display: grid; gap: 0.25rem; margin: 0; font-size: 0.82rem; line-height: 1.4; }
.dw-label div { display: grid; grid-template-columns: 4.8rem minmax(0, 1fr); gap: 0.5rem; padding-top: 0.25rem; border-top: 1px solid var(--line); }
.dw-label dt { font-weight: 600; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding-top: 0.12rem; }
.dw-label dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }

.dw-front .dr-dls { justify-content: flex-start; margin-top: auto; }

/* ------------------------------------------------------ Details panel */

.dw-drawer { position: relative; }
.dw-pull {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  list-style: none; padding: 0.65rem 1.1rem; border-top: 1px solid var(--line);
  cursor: pointer; font: 600 0.84rem/1 var(--font); color: var(--accent-dark); user-select: none;
}
.dw-pull::-webkit-details-marker { display: none; }
.dw-pull:hover { background: var(--mist); }
.dw-pull:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.dw-grip { order: 2; width: 0.55rem; height: 0.55rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translate(-2px, -2px); transition: transform 0.25s; }
.dw-drawer[open] .dw-grip { transform: rotate(-135deg) translate(-2px, -2px); }
.dw-pull-close { display: none; }
.dw-drawer[open] .dw-pull-open { display: none; }
.dw-drawer[open] .dw-pull-close { display: inline; }

/* An open card takes the whole row. */
.dw-box:has(.dw-drawer[open]) { grid-column: 1 / -1; }
.dw-box:has(.dw-drawer[open]) .dw-front { flex-direction: row; flex-wrap: wrap; align-items: flex-start; }
.dw-box:has(.dw-drawer[open]) .dw-kind { flex: 1 0 100%; }
.dw-box:has(.dw-drawer[open]) .dw-holder { flex: 1 1 26rem; }
.dw-box:has(.dw-drawer[open]) .dw-front .dr-dls { flex: 0 1 auto; margin-top: 0; align-self: center; }

.dw-tray {
  position: relative; display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr) minmax(0, 0.9fr); gap: 1rem;
  padding: 1.1rem; border-top: 1px solid var(--line); background: var(--mist); color: var(--text);
}
.dw-drawer[open] .dw-tray { animation: dw-out 0.35s cubic-bezier(.2, .8, .2, 1) both; }
.dw-drawer.is-closing .dw-tray { animation: dw-in 0.2s ease-in both; }
@keyframes dw-out { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes dw-in { from { opacity: 1; } to { opacity: 0; transform: translateY(-6px); } }
.dw-sec { min-width: 0; padding: 0.9rem; border: 1px solid var(--line); border-radius: 3px; background: var(--paper); }

.dw-h { margin: 0 0 0.6rem; font: 600 0.7rem/1 var(--font); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-dark); }

.dw-table-wrap { overflow-x: auto; max-width: 100%; }
.dw-table-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dw-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; line-height: 1.35; }
.dw-table caption { caption-side: bottom; text-align: left; padding-top: 0.5rem; font-size: 0.74rem; color: var(--muted); }
.dw-table th { text-align: left; font-weight: 600; color: var(--ink); border-bottom: 2px solid var(--ink); padding: 0.3rem 0.5rem 0.35rem 0; white-space: nowrap; }
.dw-table td { padding: 0.32rem 0.5rem 0.32rem 0; border-bottom: 1px solid var(--line); color: var(--text); vertical-align: top; }
.dw-table .dw-num { text-align: right; font-variant-numeric: tabular-nums; }
.dw-none { margin: 0; font-size: 0.86rem; color: var(--muted); }

.dw-card-list { margin: 0; display: grid; gap: 0.35rem; font-size: 0.82rem; }
.dw-card-list div { display: grid; grid-template-columns: 6.4rem minmax(0, 1fr); gap: 0.5rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--line); }
.dw-card-list div:last-child { border-bottom: 0; padding-bottom: 0; }
.dw-card-list dt { color: var(--muted); }
.dw-card-list dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.dw-card-list a { color: var(--accent-dark); }

.dw-slip { position: relative; align-self: start; }
.dw-cite { margin: 0 0 0.7rem; font-family: var(--font-serif); font-size: 0.92rem; line-height: 1.45; color: var(--text); overflow-wrap: anywhere; }
.dw-copy {
  display: inline-flex; align-items: center; padding: 0.4rem 0.8rem; margin: 0 0.6rem 0.6rem 0;
  border: 1px solid var(--accent); border-radius: 3px; background: transparent; color: var(--accent-dark);
  font: 600 0.8rem/1 var(--font); cursor: pointer;
}
.dw-copy:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.dw-more { display: inline-block; }

.dw-wall .dr-copy-status { color: var(--muted); margin: 0.8rem 0 0; min-height: 1.2em; font-size: 0.86rem; }

@media (max-width: 900px) { .dw-tray { grid-template-columns: minmax(0, 1fr); padding: 0.9rem; } }
@media (max-width: 560px) { .dw-label div { grid-template-columns: 4rem minmax(0, 1fr); } }
@media (prefers-reduced-motion: reduce) {
  .dw-grip, .dw-unit { transition: none; }
  .dw-drawer[open] .dw-tray, .dw-drawer.is-closing .dw-tray { animation: none; }
}
@media print {
  .dw-pull, .dw-copy { display: none; }
  .dw-unit { border-color: #999; }
}
