/* Panels ("second window") — layer, transitions, close control.
   Panel-specific styles live in panel-<id>.css. The layer is only created on the first open (panels.js);
   enter / leave run as Web Animations on .pn and .pn-sweep (compositor-only: opacity + transform). */

.pn-layer { position: fixed; inset: 0; z-index: 35; pointer-events: none; }
.pn {
  position: absolute; inset: 0; z-index: 1; pointer-events: auto;
  background: var(--bg);
  color: var(--text);
  --pn-top: calc(var(--top) + 58px);   /* panel content starts here: below the header and the close pill */
}
.pn.is-top { z-index: 2; }              /* the incoming panel of a switch sits on top of the old one */
.pn.is-pre { opacity: 0; pointer-events: none; }   /* mounting (first open only) */
.pn[hidden] { display: none; }
.pn-scroll {
  position: absolute; inset: 0;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.pn-scroll::-webkit-scrollbar { display: none; width: 0; height: 0; }
.pn-scroll:focus, .pn-scroll:focus-visible { outline: none; }

/* shade behind the header once panel content scrolls under it (header stays readable) */
.pn-layer::before {
  content: ""; position: absolute; z-index: 3; left: 0; right: 0; top: 0;
  height: calc(var(--top) + 44px + 28px); pointer-events: none;   /* solid down to the close pill, then a short fade */
  background: linear-gradient(180deg, var(--bg) 0%, rgba(5, 7, 11, .97) calc(100% - 30px), rgba(5, 7, 11, 0) 100%);
  opacity: 0; transition: opacity .25s;
}
.pn-layer.is-scrolled::before { opacity: 1; }

/* close control: top-left, directly under the header, above the panel content */
.pn-back, .pn-wait {
  position: absolute; z-index: 4; left: var(--gl); top: var(--top);
  display: inline-flex; align-items: center; gap: 12px;
  min-height: 44px; max-width: min(230px, calc(100vw - var(--gl) - var(--gr)));
  padding: 0 18px 0 15px; border-radius: 999px;
  border: 1px solid rgba(233, 212, 170, .5);
  background: rgba(8, 12, 20, .82);
  box-shadow: inset 0 0 0 1px rgba(233, 212, 170, .05), 0 0 20px -8px rgba(214, 176, 106, .55);
  color: var(--text); font-size: var(--fs-s); letter-spacing: .1em; line-height: 1.2; white-space: nowrap;
}
.pn-back {
  pointer-events: auto;
  transition: color .2s, border-color .2s, box-shadow .2s, transform .25s var(--ease);
}
.pn-back > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.pn-back:hover { color: var(--gold-b); border-color: var(--gold); box-shadow: 0 0 24px -6px rgba(214, 176, 106, .7); transform: translateX(-2px); }
.pn-back:hover .arr { color: var(--gold-b); }
.pn-back:focus-visible { outline-offset: 2px; border-radius: 999px; }

/* "opening" state (only when loading takes > 150 ms) */
.pn-wait { pointer-events: none; color: var(--muted); }
.pn-wait i {
  position: relative; width: 22px; height: 1px; background: var(--line); overflow: hidden; flex: none;
}
.pn-wait i::after {
  content: ""; position: absolute; inset: 0; width: 45%;
  background: var(--gold-b); box-shadow: 0 0 8px var(--gold);
  animation: pn-wait 0.9s cubic-bezier(.6, 0, .3, 1) infinite;
}
@keyframes pn-wait { from { transform: translateX(-110%); } to { transform: translateX(240%); } }

/* thin gold line that sweeps across under the header on enter (left -> right) and leave (right -> left) */
.pn-sweep {
  position: absolute; z-index: 5; left: 0; right: 0; height: 1px;
  top: calc(var(--sat) + var(--hd-pad) + var(--pill-h) + 6px);
  background: linear-gradient(90deg, rgba(214, 176, 106, 0), var(--gold) 18%, var(--gold-b) 50%, var(--gold) 82%, rgba(214, 176, 106, 0));
  box-shadow: 0 0 10px rgba(214, 176, 106, .8);
  opacity: 0; transform: scaleX(0); transform-origin: 0 50%; pointer-events: none;
}

/* the world while a panel is open: indicator hidden (it is also inert, like <main>) */
body.pn-open .ind { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  .pn-wait i::after { animation: none; transform: translateX(60%); }
}
