/* ─── Archive: a chest of small drawers ─────────────────────────────────────
   Structure:  .archive-desk > .drawer-chest (.drawer-chest__grid > .drawer…) + .archive-desk__out (.pulled-disk…)
   Every archived server sleeps in a small, shut drawer with a note taped to its front. Hovering one slides
   it out; picking it brings its floppy (the index's .floppy) out beside the chest with its info and actions. Colours
   come from the same .tint-* / .painted classes as the index's floppies.
──────────────────────────────────────────────────────────────────────────── */

@layer components {

/* Servers and Archive: plain links in the top bar, right after the brand; the current one is underlined */
.topbar .brand { flex-grow: 0; }
.topnav { display: flex; align-items: center; gap: 4px; margin-left: 12px; margin-right: auto; }
.topnav__link {
  position: relative; display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 12px; border-radius: 12px;
  font-weight: 800; font-size: 15px; color: var(--muted); text-decoration: none; transition: color .2s ease, background .2s ease;
}
.topnav__link svg { flex-shrink: 0; }
.topnav__link:hover { color: var(--ink); background: var(--chip); }
.topnav__link[aria-current="page"] { color: var(--ink); }
.topnav__link[aria-current="page"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 3px; height: 3px; border-radius: 3px; background: var(--accent);
}
.topnav__link:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

/* ── The desk: chest on the left, the floppy taken out on the right ── */
.archive-desk { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 32px; align-items: start; }
.archive-desk__out { position: sticky; top: 20px; }

/* ── The chest ── */
.drawer-chest {
  padding: 12px 14px 18px; border-radius: 28px;
  background: color-mix(in srgb, var(--accent) 16%, var(--tile));
  box-shadow: 0 22px 30px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .5), inset 0 -8px 0 color-mix(in srgb, var(--accent) 26%, var(--tile));
}
.drawer-chest__top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 2px 6px 12px; }
.drawer-chest__brand { font-family: var(--font-display, inherit); font-weight: 700; font-size: 18px; color: color-mix(in srgb, var(--accent) 70%, var(--ink)); }
.drawer-chest__tally { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--muted); text-align: right; }
/* Rows leave room for an open drawer to slide out over the gap. */
.drawer-chest__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 26px 12px; }

/* ── A drawer: the button is the dark hollow, its front slides out ── */
.drawer {
  --tilt: calc((mod(var(--i, 1), 3) - 1) * 1.6deg);
  position: relative; display: block; height: 132px; padding: 0; border: 0; border-radius: 14px; cursor: pointer;
  background: repeating-linear-gradient(90deg, #1B1930 0 18px, #23203D 18px 20px);
  box-shadow: inset 0 10px 14px rgba(0, 0, 0, .45);
}
.drawer__front {
  position: absolute; inset: 3px; box-sizing: border-box; border-radius: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 10px 9px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 5%, var(--tile)), color-mix(in srgb, var(--ink) 7%, var(--tile)));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), inset 0 -4px 0 color-mix(in srgb, var(--ink) 10%, transparent), 0 2px 3px color-mix(in srgb, var(--ink) 14%, transparent);
  transition: transform .55s var(--spring), box-shadow .3s ease;
}
/* Drawers stay shut; one slides out while the pointer (or keyboard focus) is on it, and the one whose floppy is out stays open. */
button.drawer:hover, .drawer:focus-visible, .drawer[aria-selected="true"] { z-index: 1; }
button.drawer:hover .drawer__front, .drawer:focus-visible .drawer__front, .drawer[aria-selected="true"] .drawer__front {
  transform: translateY(24px) scale(1.07);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), inset 0 -4px 0 color-mix(in srgb, var(--ink) 10%, transparent), 0 16px 22px var(--shadow);
}
.drawer:focus-visible { outline: none; }
.drawer:focus-visible .drawer__front { outline: 3px solid var(--accent); outline-offset: 2px; }

/* The note taped to the front */
.drawer__note {
  position: relative; box-sizing: border-box; width: 100%; padding: 8px 9px 7px; border-top: 4px solid var(--gb); border-radius: 3px;
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  background: var(--paper); color: var(--paper-ink); transform: rotate(var(--tilt));
  box-shadow: 0 2px 4px rgba(27, 26, 46, .14);
}
.drawer__note::before {
  content: ""; position: absolute; top: -11px; left: 50%; width: 36px; height: 13px; margin-left: -18px; transform: rotate(-3deg);
  background: rgba(245, 196, 81, .6); border-radius: 2px;
}
.drawer__note-head { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--paper-muted); }
.drawer__note-name { font-size: 13px; font-weight: 800; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.drawer__note-size { font-size: 11px; font-weight: 700; color: var(--paper-muted); }
.drawer__pull {
  width: 42%; height: 8px; margin-top: auto; flex-shrink: 0; border-radius: 999px;
  background: #FFFFFF; box-shadow: 0 2px 2px rgba(27, 26, 46, .25);
}

.drawer-chest--empty .drawer { cursor: default; }

/* The archive panel in a server's Settings: its floppy half in a small open drawer */
.archive-drawer { position: relative; flex-shrink: 0; width: 60px; height: 56px; }
.archive-drawer .mini-floppy { position: absolute; left: 13px; top: 0; transform: rotate(-8deg); transition: transform .55s var(--spring); }
.panel:hover .archive-drawer .mini-floppy { transform: translateY(-5px) rotate(-4deg); }
.archive-drawer__front {
  position: absolute; left: 0; right: 0; bottom: 0; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 22%, var(--tile)), color-mix(in srgb, var(--accent) 34%, var(--tile)));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 4px 8px var(--shadow);
}
.archive-drawer__pull { width: 22px; height: 6px; border-radius: 999px; background: linear-gradient(180deg, #F1F3F8, #B9BFCE); box-shadow: 0 1px 2px rgba(27, 26, 46, .25); }

/* ── The floppy out of the open drawer (reuses .floppy from floppy.css) ── */
.pulled-disk[hidden] { display: none; }
.pulled-disk { animation: disk-out .6s var(--spring); }
@keyframes disk-out { from { opacity: 0; transform: translate(-48px, 24px) rotate(-8deg) scale(.88); } }
.pulled-disk__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 14px; }
.pulled-disk__actions form { margin: 0; }
.pulled-disk__actions .btn--ghost { color: var(--paper-ink); border-color: var(--paper-line); }
.pulled-disk__actions .btn--danger { color: #C2334A; border-color: color-mix(in srgb, #C2334A 40%, transparent); }
.pulled-disk__delete { margin-left: auto; }

.pulled-empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 24px; text-align: center;
  border: 2px dashed var(--line); border-radius: 26px;
}

@media (prefers-reduced-motion: reduce) {
  .drawer__front, .pulled-disk { transition: none; animation: none; }
}

/* Narrow screens: the floppy comes out below the chest, drawers two by two. */
@media (max-width: 900px) {
  .archive-desk { grid-template-columns: minmax(0, 1fr); }
  .archive-desk__out { position: static; }
  @keyframes disk-out { from { opacity: 0; transform: translateY(-36px) rotate(-4deg) scale(.9); } }
}
@media (max-width: 640px) {
  /* Phones: the logo alone names the app, so the switch fits beside the balance */
  .topbar .brand__name { display: none; }
  .topnav { margin-left: 4px; gap: 0; }
  .topnav__link { padding: 0 9px; }
  .topnav__link[aria-current="page"]::after { left: 9px; right: 9px; }
  .topnav__label { display: none; }
  .drawer-chest { padding: 10px 10px 14px; border-radius: 22px; }
  .drawer-chest__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 10px; }
  .drawer { height: 120px; }
}

}
