/* ══════════════════════════════════════════════════════════════════
   PRINTABLE LIBRARY — Phase 4 styles.
   Every rule is scoped to .pl-* (plus the one header entry class),
   uses the existing Universe tokens from styles.css (:root), and
   changes nothing that already exists. Delete this file to remove.
══════════════════════════════════════════════════════════════════ */

.pl-overlay {
  position: fixed; inset: 0; z-index: 350;
  background: linear-gradient(160deg, #1a1145 0%, #0c0a24 55%, #080612 100%);
  color: var(--white-soft);
  font-family: var(--font-body);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: plIn 280ms var(--ease-out);
}
.pl-overlay[hidden] { display: none; }
@keyframes plIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.pl-shell {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px 48px;
  box-sizing: border-box;
}

/* top bar: back on the left, close on the right — always visible.
   Full-width (outside .pl-shell) so its fade has no visible edges. */
.pl-bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px max(24px, calc((100% - 1040px) / 2 + 24px)) 16px;
  background: linear-gradient(180deg, rgba(16,11,44,0.94) 65%, rgba(16,11,44,0));
}
.pl-bar-left { min-height: 44px; display: flex; align-items: center; }

.pl-back, .pl-close {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--white-soft);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  padding: 10px 16px;
  min-height: 44px;
  cursor: pointer;
  transition: background 200ms, border-color 200ms;
}
.pl-back:hover, .pl-close:hover { background: rgba(196,181,253,0.12); border-color: rgba(196,181,253,0.35); }
.pl-back:focus-visible, .pl-close:focus-visible,
.pl-btn:focus-visible, .pl-month:focus-visible, .pl-link:focus-visible {
  outline: 2px solid var(--lavender); outline-offset: 2px;
}

.pl-error {
  font-size: 0.88rem;
  color: #fecaca;
}
.pl-error:not(:empty) {
  background: rgba(248,113,113,0.12);
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

.pl-title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: clamp(1.5rem, 3.2vw, 2.1rem);
  margin: 6px 0 6px;
  outline: none;
}
.pl-intro {
  color: var(--white-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0 0 22px;
}

/* ── home: two categories + full journal ── */
.pl-cats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
.pl-cat, .pl-full {
  position: relative;
  overflow: hidden;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  padding: 24px 22px 22px;
  display: flex; flex-direction: column; gap: 10px;
}
.pl-cat::before, .pl-full::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: currentColor; opacity: 0.75;
}
.pl-cat-journal  { color: var(--c-daily); }
.pl-cat-practice { color: var(--c-nova); }
.pl-full         { color: var(--lavender); margin-top: 18px; flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.pl-full-text { flex: 1 1 320px; }

.pl-cat-title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--white-soft);
  margin: 0;
}
.pl-cat-copy {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--white-muted);
  margin: 0;
  flex: 1;
}

/* ── buttons ── */
.pl-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 4px; }
.pl-btn {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  border-radius: 999px;
  padding: 11px 20px;
  min-height: 44px;
  border: 1px solid transparent;
  cursor: pointer;
  align-self: flex-start;
  transition: transform 200ms var(--ease-spring), background 200ms;
}
.pl-btn-primary { background: var(--purple-mid); color: #fff; border-color: rgba(196,181,253,0.4); }
.pl-btn-primary:hover { background: var(--purple-glow); transform: translateY(-1px); }
.pl-btn-member { background: rgba(196,181,253,0.16); color: var(--lavender); border-color: rgba(196,181,253,0.4); }
.pl-btn-member:hover { background: rgba(196,181,253,0.26); }
.pl-btn-disabled, .pl-btn[disabled] {
  background: rgba(255,255,255,0.06);
  color: var(--white-muted);
  border-color: rgba(255,255,255,0.12);
  cursor: not-allowed;
  transform: none;
}
.pl-link {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--lavender);
  background: none; border: none; padding: 6px 2px;
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}

/* ── months grid ── */
.pl-months {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}
.pl-month {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  text-align: left;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 18px 16px;
  min-height: 92px;
  color: var(--white-soft);
  cursor: pointer;
  transition: transform 220ms var(--ease-spring), border-color 220ms, background 220ms;
}
.pl-month:hover { transform: translateY(-2px); border-color: rgba(52,211,153,0.5); background: rgba(52,211,153,0.07); }
.pl-month-name { font-family: var(--font-title); font-weight: 600; font-size: 1.02rem; }
.pl-month-note { font-size: 0.78rem; color: var(--white-muted); }

/* ── month / practice: page cards ── */
.pl-pages {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.pl-page {
  display: flex; flex-direction: column;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  overflow: hidden;
}
.pl-thumb {
  aspect-ratio: 8.5 / 11;
  max-height: 260px;
  background: #f7f5ff;
  display: grid; place-items: center;
  overflow: hidden;
}
.pl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pl-thumb-empty {
  background:
    repeating-linear-gradient(180deg, transparent 0 22px, rgba(85,48,160,0.08) 22px 23px),
    #f7f5ff;
}
.pl-thumb-empty span {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--purple-mid);
}
.pl-page-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pl-page-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pl-page-title { font-family: var(--font-title); font-weight: 700; font-size: 1rem; margin: 0; }
.pl-page-name { font-size: 0.9rem; color: var(--white-soft); margin: 0; }
.pl-page-desc { font-size: 0.82rem; color: var(--white-muted); line-height: 1.45; margin: 0; }
.pl-page .pl-actions { margin-top: auto; padding-top: 6px; }

.pl-badge {
  font-family: var(--font-title);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: var(--white-muted);
  white-space: nowrap;
}
.pl-badge-member { background: rgba(196,181,253,0.16); color: var(--lavender); }

.pl-all { margin-top: 18px; }

/* ── header entry on tablet / small laptop (641–1120px) ──
   The existing header nav already wraps at these widths; one more item
   in the row pushed "Create Free Account" off the edge (and made the
   row wrap up to ~1100px, measured). So here, and
   only here, the Printable Library link leaves the row and sits as a
   small pill just under the header's right end. The existing nav row
   renders exactly as it did before Phase 4. Desktop (>1120px) and the
   phone menu (≤640px) are unaffected. */
@media (min-width: 641px) and (max-width: 1120px) {
  .rgk-header .rgk-nav a[data-printable-library] {
    position: absolute;
    top: 100%;
    right: 24px;
    margin-top: -6px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(196,181,253,0.22);
    border-radius: 999px;
    padding: 5px 12px;
    white-space: nowrap;
  }
}

/* ── tablet ── */
@media (max-width: 1024px) {
  .pl-months { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 760px) {
  .pl-cats { grid-template-columns: 1fr; }
  .pl-months { grid-template-columns: repeat(3, 1fr); }
}

/* ── phone: three pages fit without much scrolling ── */
@media (max-width: 640px) {
  .pl-shell { padding: 0 16px 32px; }
  .pl-bar { padding: 10px 16px 12px; }
  .pl-close span { display: none; }
  .pl-close::after { content: 'Close'; }
  .pl-intro { margin-bottom: 16px; font-size: 0.9rem; }
  .pl-months { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .pl-month { min-height: 72px; padding: 14px; }
  .pl-pages { grid-template-columns: 1fr; gap: 10px; }
  .pl-page { flex-direction: row; }
  .pl-thumb { width: 78px; flex: 0 0 78px; aspect-ratio: auto; max-height: none; }
  .pl-thumb-empty span { font-size: 0.62rem; writing-mode: vertical-rl; transform: rotate(180deg); }
  .pl-page-body { padding: 12px 14px; }
  .pl-btn { padding: 10px 16px; font-size: 0.86rem; }
  .pl-full { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .pl-overlay { animation: none; }
  .pl-btn, .pl-month { transition: none; }
}

/* the panel never prints itself — the PDFs are what get printed */
@media print {
  .pl-overlay { display: none !important; }
}
