/* The Shelf — viewer for Ella's original Readymag homepage */
:root {
  --blue: #4b46e6;
  --ink: #1c1940;
  --peach: #ffe0cc;
  --cursor: url("assets/cursor.png") 23 24, auto;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--peach);
  color: var(--ink);
  font: 400 15px/1.4 "Space Grotesk", system-ui, sans-serif;
  cursor: var(--cursor);
  overflow-x: hidden;
}
body.lb-open { overflow: hidden; }

/* ---------- top bar ---------- */
.bar {
  position: fixed; top: 10px; left: 50%; translate: -50% 0; z-index: 100;
  display: flex; align-items: center; gap: 18px;
  padding: 6px 6px 6px 8px; border-radius: 999px;
  background: rgb(255 247 241 / .72);
  backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: 0 4px 24px rgb(28 25 64 / .12), inset 0 0 0 1px rgb(255 255 255 / .6);
  white-space: nowrap;
}
.bar-back { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 14px; }
.bar-back::before { content: "←"; color: var(--blue); }
.bar-hint { margin: 0; font-size: 13px; color: #6b6890; }
.bar-btn {
  font: 500 13px "Space Grotesk", sans-serif; color: #fff; background: var(--blue);
  border: 0; border-radius: 999px; padding: 7px 12px; cursor: var(--cursor);
}
.bar-btn kbd { font: inherit; opacity: .6; margin-left: 4px; }
@media (max-width: 640px) {
  .bar-hint { display: none; }
  .bar-btn kbd { display: none; }
}

/* ---------- stage ---------- */
#stage { position: relative; overflow: hidden; }
#page { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#fixed {
  position: fixed; left: 50%; top: 50%; width: 0; height: 0; z-index: 50;
  transform-origin: 0 0; pointer-events: none;
}

.w {
  position: absolute;
  transition-property: opacity, scale;
  transition-timing-function: ease;
}
#fixed .w { pointer-events: auto; }
.w.off { visibility: hidden; pointer-events: none !important; transition-property: opacity, scale, visibility; }
.w.hit { cursor: var(--cursor); }
.w.hit:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; border-radius: 4px; }

.w-picture img { width: 100%; height: 100%; display: block; object-fit: fill; user-select: none; -webkit-user-drag: none; }
.w-text p { margin: 0; white-space: pre-wrap; overflow-wrap: break-word; }
.w-text a { color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
.w-shape i { position: absolute; left: 0; width: 100%; display: block; }

/* slideshow */
.w-slideshow .ss-frame { position: absolute; inset: 0; }
.w-slideshow img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; cursor: zoom-in; }
.w-slideshow.fill img { width: 100%; height: 100%; object-fit: cover; }
.w-slideshow button {
  position: absolute; top: 50%; translate: 0 -50%;
  width: 32px; height: 48px; border: 0; background: none; padding: 0;
  font: 400 40px/1 system-ui, sans-serif; color: var(--ctl, #fff); cursor: var(--cursor);
  text-shadow: 0 1px 6px rgb(0 0 0 / .35);
}
.w-slideshow .ss-prev { left: -4px; }
.w-slideshow .ss-next { right: -4px; }
.w-slideshow .ss-count {
  position: absolute; right: 6px; bottom: 6px;
  font: 500 10px/1 "Space Grotesk", sans-serif; color: #fff;
  background: rgb(0 0 0 / .45); padding: 3px 6px; border-radius: 99px;
}
.w-slideshow .ss-count:empty { display: none; }

/* button + form swap */
.w-button { display: grid; place-items: center; text-decoration: none; transition: background .2s; }
.w-button:hover { background: var(--hover) !important; }
.w-form {
  display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 16px;
  border-radius: 24px; background: var(--fbg); color: var(--ffg);
  font: 500 14px "Space Grotesk", sans-serif; text-align: center;
}
.w-form p { margin: 0; }
.w-form a {
  display: block; padding: 10px; border-radius: 999px; text-decoration: none;
  background: var(--fbtn); color: #fff;
}

/* lightbox */
#lightbox {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  background: rgb(19 19 78 / .92);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
#lightbox[hidden] { display: none; }
#lightbox img { max-width: calc(100vw - 120px); max-height: calc(100vh - 80px); object-fit: contain; box-shadow: 0 20px 60px rgb(0 0 0 / .4); }
#lightbox button {
  position: absolute; border: 0; background: none; color: #fff; cursor: var(--cursor);
  font: 300 52px/1 system-ui, sans-serif; padding: 8px 16px;
}
.lb-close { top: 8px; right: 12px; }
.lb-prev { left: 8px; top: 50%; translate: 0 -50%; }
.lb-next { right: 8px; top: 50%; translate: 0 -50%; }
.lb-count { position: absolute; bottom: 16px; left: 50%; translate: -50% 0; color: #fff; font-size: 13px; opacity: .8; }
@media (max-width: 640px) {
  #lightbox img { max-width: 100vw; max-height: calc(100vh - 120px); }
  .lb-prev, .lb-next { top: auto !important; bottom: 4px; translate: none !important; }
}

@media (prefers-reduced-motion: reduce) { .w { transition-duration: 0s !important; } }
