/* ============================================================
   The Stacks — a library at night, lit by a brass banker's lamp
   ============================================================ */

:root {
  --ink:        #0a0d12;
  --ink-2:      #0d1219;
  --panel:      rgba(22, 29, 38, 0.55);
  --panel-solid:#141a22;
  --brd:        rgba(255, 255, 255, 0.09);
  --brd-strong: rgba(255, 255, 255, 0.16);

  --paper:      #f3ede0;
  --text:       #e9e5db;
  --muted:      #9aa2ac;
  --faint:      #656d78;

  --brass:      #e0b25a;
  --brass-2:    #c8963a;
  --emerald:    #37d3a6;
  --emerald-2:  #1f8f74;
  --leather:    #a24141;
  --danger:     #ff7a7a;

  --r:          16px;
  --r-sm:       10px;
  --shadow:     0 24px 60px -24px rgba(0,0,0,0.75);
  --glow-brass: 0 0 40px -8px rgba(224,178,90,0.45);
  --glow-emrld: 0 0 34px -8px rgba(55,211,166,0.5);

  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body:    "Inter", system-ui, -apple-system, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Ambient night: banker's-lamp glow + drifting aurora blobs */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -2;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
}
body::before {
  width: 60vw; height: 60vw;
  top: -22vw; left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(224,178,90,0.20), transparent 65%);
  animation: drift-a 22s ease-in-out infinite alternate;
}
body::after {
  width: 46vw; height: 46vw;
  bottom: -18vw; right: -8vw;
  background: radial-gradient(circle, rgba(55,211,166,0.14), transparent 65%);
  animation: drift-b 26s ease-in-out infinite alternate;
}
@keyframes drift-a { to { transform: translateX(-50%) translateY(4vw) scale(1.1); } }
@keyframes drift-b { to { transform: translateY(-5vw) scale(1.15); } }

/* faint dust canvas sits behind everything */
#dust {
  position: fixed; inset: 0;
  z-index: -1;
  pointer-events: none;
}

.container { max-width: 1000px; margin: 0 auto; padding: 28px 24px 80px; }

/* ---------- Typography ---------- */
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0;
}

/* ============================================================
   Sign-in scene
   ============================================================ */
.scene {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px 24px;
  text-align: center;
}
.hero { max-width: 760px; width: 100%; }

.stage {
  perspective: 1400px;
  height: 264px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
}

/* --- the 3D book (pure CSS cuboid) --- */
.book {
  position: relative;
  width: 160px; height: 220px;
  transform-style: preserve-3d;
  transform: rotateX(-14deg) rotateY(0deg);
  animation: spin 18s linear infinite, bob 6s ease-in-out infinite;
}
.book__face { position: absolute; top: 50%; left: 50%; }

.book__cover, .book__back {
  width: 160px; height: 220px; margin: -110px 0 0 -80px;
  border-radius: 3px 8px 8px 3px;
  background:
    linear-gradient(135deg, #b24d4d 0%, #7c2d2d 55%, #5e2020 100%);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.06),
              inset 0 0 40px rgba(0,0,0,0.35);
}
.book__cover { transform: translateZ(23px); padding: 26px 22px; }
.book__back  { transform: rotateY(180deg) translateZ(23px); }

.book__cover .title {
  font-family: var(--font-display);
  font-size: 1.15rem; line-height: 1.15;
  color: var(--brass);
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
  text-align: left;
}
.book__cover .flourish {
  margin-top: 14px; width: 42px; height: 2px;
  background: linear-gradient(90deg, var(--brass), transparent);
}
.book__cover .mono {
  position: absolute; left: 22px; bottom: 22px;
  font-family: var(--font-mono); font-size: 0.6rem;
  letter-spacing: 0.2em; color: rgba(224,178,90,0.7);
}

/* spine (left) + fore-edge (right) show pages */
.book__spine { width: 46px; height: 220px; margin: -110px 0 0 -23px;
  transform: rotateY(-90deg) translateZ(80px);
  background: linear-gradient(90deg, #5e2020, #7c2d2d);
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.3);
}
.book__spine span {
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-family: var(--font-display); font-size: 0.7rem;
  letter-spacing: 0.12em; color: var(--brass);
}
.book__fore { width: 46px; height: 220px; margin: -110px 0 0 -23px;
  transform: rotateY(90deg) translateZ(80px);
  background: repeating-linear-gradient(90deg, #efe7d4 0 1.5px, #d9cfb8 1.5px 3px);
  border-radius: 0 2px 2px 0;
}
.book__top, .book__bottom { width: 160px; height: 46px; margin: -23px 0 0 -80px;
  background: repeating-linear-gradient(90deg, #efe7d4 0 1.5px, #d3c8b0 1.5px 3px);
}
.book__top    { transform: rotateX(90deg)  translateZ(110px); }
.book__bottom { transform: rotateX(-90deg) translateZ(110px); }

@keyframes spin { to { transform: rotateX(-14deg) rotateY(360deg); } }
@keyframes bob  { 0%,100% { margin-top: 0; } 50% { margin-top: -18px; } }

.wordmark {
  font-size: clamp(2.6rem, 8vw, 4.4rem);
  margin: 4px 0 0;
  color: var(--paper);
  font-weight: 600;
}
.wordmark em { font-style: italic; color: var(--brass); }
.lede { color: var(--muted); margin: 10px 0 34px; font-size: 1.05rem; }

/* --- member "library cards" --- */
.card-rack {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  max-width: 820px; margin: 0 auto;
}
@media (max-width: 560px) {
  .card-rack { grid-template-columns: repeat(2, 1fr); }
}
.member-card {
  position: relative;
  padding: 22px 20px;
  border-radius: var(--r);
  border: 1px solid var(--brd);
  background: var(--panel);
  backdrop-filter: blur(14px);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  transform-style: preserve-3d;
  transition: border-color .3s, box-shadow .3s;
  font-family: var(--font-body);
}
.member-card::after { /* glare */
  content:""; position:absolute; inset:0;
  background: radial-gradient(circle at var(--mx,50%) var(--my,0%), rgba(255,255,255,0.14), transparent 45%);
  opacity: 0; transition: opacity .3s; pointer-events: none;
}
.member-card:hover { border-color: var(--brd-strong); box-shadow: var(--shadow); }
.member-card:hover::after { opacity: 1; }
.member-card:focus-visible { outline: 2px solid var(--emerald); outline-offset: 3px; }
.member-card .avatar {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 1.4rem; font-weight: 700;
  background: rgba(55,211,166,0.12); color: var(--emerald);
  border: 1px solid rgba(55,211,166,0.3);
  margin-bottom: 14px;
}
.member-card .name { font-family: var(--font-display); font-size: 1.15rem; }
.member-card .role {
  font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted); margin-top: 4px;
}
.member-card.admin { border-color: rgba(224,178,90,0.4); }
.member-card.admin .avatar {
  background: rgba(224,178,90,0.12); color: var(--brass);
  border-color: rgba(224,178,90,0.35);
}
.member-card.admin:hover { box-shadow: var(--glow-brass), var(--shadow); }

/* ============================================================
   Dashboards
   ============================================================ */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; margin-bottom: 8px;
  padding-bottom: 20px; border-bottom: 1px solid var(--brd);
}
.topbar h1 { font-size: 1.9rem; margin: 0; color: var(--paper); }
.topbar h1 em { font-style: italic; color: var(--brass); }
.topbar .who { display: flex; align-items: center; gap: 14px; }
.chip {
  font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
  padding: 6px 12px; border: 1px solid var(--brd); border-radius: 999px;
}
.link { color: var(--emerald); text-decoration: none; font-size: 0.9rem; font-weight: 500; }
.link:hover { text-decoration: underline; }

.panel {
  position: relative;
  margin-top: 26px;
  padding: 22px 24px 26px;
  border: 1px solid var(--brd);
  border-radius: var(--r);
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  animation: rise .6s cubic-bezier(.2,.7,.2,1) both;
}
.panel::before { /* book-spine accent on the left edge */
  content:""; position:absolute; left:0; top:14px; bottom:14px; width:3px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--brass), transparent);
}
.panel h2 {
  font-size: 1.15rem; margin: 0 0 4px; color: var(--paper);
}
.panel .sub { color: var(--faint); font-size: 0.82rem; margin: 0 0 16px; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
thead th {
  font-family: var(--font-mono);
  font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--faint); text-align: left; font-weight: 500;
  padding: 8px 12px; border-bottom: 1px solid var(--brd);
}
tbody td {
  padding: 13px 12px; font-size: 0.92rem; color: var(--text);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  vertical-align: middle;
}
tbody tr { transition: background .2s; animation: rowIn .45s ease both; }
tbody tr:hover { background: rgba(55,211,166,0.05); }
@keyframes rowIn { from { opacity: 0; transform: translateY(6px); } }

/* numeric / date cells read as data */
td.num, .mono-cell { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* fine pills */
.fine { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 500; }
.fine.zero { color: var(--emerald); }
.fine.due  { color: var(--brass); }
.fine.high { color: var(--danger); }

/* overdue badge */
.od { font-family: var(--font-mono); font-size: 0.8rem; }
.od.warn { color: var(--danger); }

/* ---------- Forms ---------- */
.row-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
input, select {
  font-family: var(--font-body); font-size: 0.9rem;
  padding: 10px 13px; color: var(--text);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--brd); border-radius: var(--r-sm);
  transition: border-color .2s, box-shadow .2s;
}
input::placeholder { color: var(--faint); }
input:focus, select:focus {
  outline: none; border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(224,178,90,0.15);
}
select option { background: var(--panel-solid); color: var(--text); }

/* ---------- Buttons ---------- */
button {
  font-family: var(--font-body); font-size: 0.85rem; font-weight: 500;
  padding: 9px 16px; color: var(--text);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--brd); border-radius: var(--r-sm);
  cursor: pointer; margin-right: 6px;
  transition: transform .12s, border-color .2s, background .2s, box-shadow .2s;
}
button:hover { border-color: var(--brd-strong); background: rgba(255,255,255,0.08); }
button:active { transform: translateY(1px) scale(0.98); }
button:focus-visible { outline: 2px solid var(--emerald); outline-offset: 2px; }

button.primary {
  background: linear-gradient(135deg, var(--emerald), var(--emerald-2));
  border-color: transparent; color: #06231c; font-weight: 600;
}
button.primary:hover { box-shadow: var(--glow-emrld); }
button.danger { color: var(--danger); border-color: rgba(255,122,122,0.3); background: rgba(255,122,122,0.06); }
button.danger:hover { background: rgba(255,122,122,0.12); }
button.ghost { padding: 7px 12px; font-size: 0.8rem; }

.total { margin-top: 14px; font-size: 0.95rem; color: var(--muted); }
.total strong { font-family: var(--font-mono); color: var(--paper); font-size: 1.1rem; }

.empty { color: var(--faint); font-size: 0.9rem; padding: 18px 12px; font-style: italic; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .panel { padding: 18px 16px 20px; overflow-x: auto; }
  table { min-width: 520px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .book { animation: none; }
  #dust { display: none; }
  body::before, body::after { animation: none; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
