/* ==========================================================================
   Nexus Publications – Single Page  (70 / 30 layout)
   ========================================================================== */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
.npub-single {
	--npub-primary:      #1e40af;
	--npub-primary-dark: #1e3a8a;
	--npub-accent:       #3b82f6;
	--npub-text:         #0f172a;
	--npub-text-muted:   #64748b;
	--npub-text-light:   #94a3b8;
	--npub-bg:           #f1f5f9;
	--npub-card-bg:      #ffffff;
	--npub-border:       #e2e8f0;
	--npub-radius:       12px;
	--npub-radius-sm:    8px;
	--npub-shadow:       0 2px 8px rgba(0,0,0,.08), 0 8px 32px rgba(0,0,0,.08);
	--npub-transition:   0.2s ease;

	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	color: var(--npub-text);

	/* Break out of theme's narrow content container and use 80vw */
	width: 80vw;
	max-width: 80vw;
	margin-left:  calc(50% - 40vw);
	margin-right: calc(50% - 40vw);
	padding: 32px 0 64px;
}

@media (max-width: 1024px) {
	.npub-single {
		width: 94vw;
		max-width: 94vw;
		margin-left:  calc(50% - 47vw);
		margin-right: calc(50% - 47vw);
	}
}

@media (max-width: 600px) {
	.npub-single {
		width: 100%;
		max-width: 100%;
		margin-left: 0;
		margin-right: 0;
		padding: 0 0 48px;
	}
}

/* ══════════════════════════════════════════════════════════════════════════
   TWO-COLUMN LAYOUT  (70 left / 30 right)
   ══════════════════════════════════════════════════════════════════════════ */

.npub-layout {
	display: grid;
	grid-template-columns: 7fr 3fr;
	align-items: start;
	border: 1px solid var(--npub-border);
	border-radius: var(--npub-radius);
	overflow: hidden;
	box-shadow: var(--npub-shadow);
	/* explicit height so the viewer iframe chain works */
	height: calc(100vh - 120px);
	min-height: 600px;
	max-height: 960px;
}

/* Tablet: stack columns */
@media (max-width: 768px) {
	.npub-layout {
		grid-template-columns: 1fr;
		height: auto;
		max-height: none;
	}
}

/* ══════════════════════════════════════════════════════════════════════════
   LEFT COLUMN — PDF viewer
   ══════════════════════════════════════════════════════════════════════════ */

.npub-viewer-col {
	display: flex;
	flex-direction: column;
	height: 100%;   /* fills the grid row height */
	background: #0f172a;
	overflow: hidden;
}

/* Viewer wrap fills the left col */
.npub-viewer-wrap {
	display: flex;
	flex-direction: column;
	height: 100%;
}

.npub-viewer-frame {
	flex: 1;
	min-height: 0;  /* required: allows flex child to shrink below content size */
	position: relative;
	background: #0f172a;
}

/* Loading overlay */
.npub-viewer-loading {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	color: #94a3b8;
	z-index: 5;
	font-size: 0.84rem;
}

.npub-spinner {
	width: 34px;
	height: 34px;
	border: 3px solid rgba(255,255,255,.1);
	border-top-color: #3b82f6;
	border-radius: 50%;
	animation: npub-spin .8s linear infinite;
}

@keyframes npub-spin { to { transform: rotate(360deg); } }

/* iframe fills its parent frame div completely */
.npub-pdf-iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: none;
	display: block;
	opacity: 0;
	transition: opacity 0.3s;
}

/* Floating action bar — thin bar at the bottom of the viewer */
.npub-viewer-floatbar {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
	padding: 8px 14px;
	background: rgba(15,23,42,.9);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	border-top: 1px solid rgba(255,255,255,.07);
}

.npub-float-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 12px;
	background: rgba(255,255,255,.1);
	border: 1px solid rgba(255,255,255,.18);
	border-radius: 6px;
	color: #e2e8f0;
	font-size: 0.78rem;
	font-weight: 600;
	cursor: pointer;
	transition: background var(--npub-transition);
	font-family: inherit;
	white-space: nowrap;
}

.npub-float-btn:hover { background: rgba(255,255,255,.2); }

/* No PDF fallback */
.npub-no-pdf {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	color: #475569;
	background: var(--npub-bg);
	text-align: center;
	padding: 40px;
	font-size: 0.93rem;
}

@media (max-width: 768px) {
	.npub-viewer-col  { height: 70vw; min-height: 420px; }
}

/* ══════════════════════════════════════════════════════════════════════════
   RIGHT COLUMN — detail panel
   ══════════════════════════════════════════════════════════════════════════ */

.npub-detail-col {
	background: var(--npub-card-bg);
	border-left: 1px solid var(--npub-border);
	display: flex;
	flex-direction: column;
	/* scroll inside the column independently */
	height: 100%;
	overflow-y: auto;
	overflow-x: hidden;
	/* custom scrollbar */
	scrollbar-width: thin;
	scrollbar-color: var(--npub-border) transparent;
}

.npub-detail-col::-webkit-scrollbar         { width: 5px; }
.npub-detail-col::-webkit-scrollbar-track   { background: transparent; }
.npub-detail-col::-webkit-scrollbar-thumb   { background: var(--npub-border); border-radius: 3px; }

@media (max-width: 768px) {
	.npub-detail-col {
		border-left: none;
		border-top: 1px solid var(--npub-border);
		height: auto;
		overflow-y: visible;
	}
}

/* Cover thumbnail — banner crop at top of panel */
.npub-detail-cover {
	width: 100%;
	aspect-ratio: 16 / 7;
	overflow: hidden;
	background: #dbeafe;
	flex-shrink: 0;
}

.npub-detail-cover img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* Type badge */
.npub-detail-type-badge {
	display: inline-flex;
	align-self: flex-start;
	margin: 16px 18px 0;
	padding: 3px 10px;
	border-radius: 20px;
	font-size: 0.7rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.07em;
	background: #dbeafe;
	color: #1e40af;
}

.npub-detail-type-badge--journal     { background: #dbeafe; color: #1e40af; }
.npub-detail-type-badge--magazine    { background: #ede9fe; color: #5b21b6; }
.npub-detail-type-badge--newsletter  { background: #d1fae5; color: #065f46; }
.npub-detail-type-badge--research    { background: #ffedd5; color: #9a3412; }
.npub-detail-type-badge--official    { background: #ccfbf1; color: #134e4a; }
.npub-detail-type-badge--guideline   { background: #cffafe; color: #155e75; }
.npub-detail-type-badge--case_report { background: #ffe4e6; color: #9f1239; }

/* Title */
.npub-detail-title {
	font-size: 1rem;
	font-weight: 800;
	line-height: 1.35;
	color: var(--npub-text);
	margin: 10px 18px 0;
	letter-spacing: -0.01em;
}

/* Horizontal rule */
.npub-detail-divider {
	height: 1px;
	background: var(--npub-border);
	margin: 14px 0;
	flex-shrink: 0;
}

/* Section container */
.npub-detail-section {
	padding: 0 18px;
	flex-shrink: 0;
}

.npub-detail-section-label {
	font-size: 0.66rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: var(--npub-text-light);
	margin: 0 0 8px;
}

/* Key / value rows */
.npub-detail-row {
	display: flex;
	align-items: baseline;
	gap: 6px;
	padding: 6px 0;
	border-bottom: 1px solid var(--npub-border);
}

.npub-detail-row:last-child { border-bottom: none; }

.npub-detail-row-key {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 0.74rem;
	font-weight: 600;
	color: var(--npub-text-muted);
	white-space: nowrap;
	flex-shrink: 0;
	min-width: 68px;
}

.npub-detail-row-val {
	font-size: 0.78rem;
	color: var(--npub-text);
	line-height: 1.4;
	word-break: break-word;
}

.npub-detail-row-val--mono {
	font-family: "SF Mono", "Fira Code", ui-monospace, monospace;
	font-size: 0.72rem;
}

/* Author strip */
.npub-detail-author {
	display: flex;
	align-items: flex-start;
	gap: 10px;
}

.npub-detail-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
	border: 2px solid var(--npub-border);
}

.npub-detail-avatar-ph {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: var(--npub-bg);
	border: 2px solid var(--npub-border);
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--npub-text-light);
	flex-shrink: 0;
}

.npub-detail-author-name {
	font-size: 0.85rem;
	font-weight: 700;
	color: var(--npub-text);
	display: block;
}

.npub-detail-author-inst {
	font-size: 0.75rem;
	color: var(--npub-text-muted);
	display: block;
	margin-top: 1px;
}

.npub-detail-author-bio {
	font-size: 0.75rem;
	color: var(--npub-text-muted);
	line-height: 1.55;
	margin: 6px 0 0;
}

/* Abstract */
.npub-detail-abstract {
	font-size: 0.8rem;
	line-height: 1.65;
	color: var(--npub-text-muted);
	margin: 0;
}

/* Related publications — stacked list */
.npub-detail-related {
	display: flex;
	flex-direction: column;
	padding-bottom: 16px;
}

.npub-detail-related-item {
	display: flex;
	gap: 10px;
	align-items: center;
	padding: 8px 0;
	border-bottom: 1px solid var(--npub-border);
	text-decoration: none;
	color: inherit;
	transition: background var(--npub-transition);
	border-radius: 4px;
}

.npub-detail-related-item:last-child { border-bottom: none; }

.npub-detail-related-item:hover { background: var(--npub-bg); }

.npub-detail-related-cover {
	width: 32px;
	height: 42px;
	flex-shrink: 0;
	border-radius: 3px;
	overflow: hidden;
	background: #dbeafe;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #93b4ef;
}

.npub-detail-related-cover img { width: 100%; height: 100%; object-fit: cover; }

.npub-detail-related-info {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.npub-detail-related-type {
	font-size: 0.63rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--npub-accent);
}

.npub-detail-related-title {
	font-size: 0.78rem;
	font-weight: 700;
	color: var(--npub-text);
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.npub-detail-related-author {
	font-size: 0.7rem;
	color: var(--npub-text-muted);
}

/* ══════════════════════════════════════════════════════════════════════════
   ACCESS WALL  (fills the left column)
   ══════════════════════════════════════════════════════════════════════════ */

.npub-access-wall {
	position: relative;
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

/* Blurred background */
.npub-access-bg {
	position: absolute;
	inset: 0;
	background-size: cover;
	background-position: center;
	background-color: #1e293b;
	filter: blur(20px) brightness(.4);
	-webkit-filter: blur(20px) brightness(.4);
	transform: scale(1.12);
}

.npub-access-overlay {
	position: absolute;
	inset: 0;
	background: rgba(10,15,30,.5);
}

/* CTA card */
.npub-access-cta {
	position: relative;
	z-index: 2;
	background: rgba(255,255,255,.97);
	border-radius: var(--npub-radius);
	padding: 36px 32px;
	max-width: 380px;
	width: calc(100% - 48px);
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	box-shadow: 0 24px 64px rgba(0,0,0,.4);
}

.npub-access-lock {
	width: 60px;
	height: 60px;
	background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
	border: 2px solid #bfdbfe;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--npub-primary);
}

.npub-access-cta h3 {
	font-size: 1.15rem;
	font-weight: 800;
	color: var(--npub-text);
	margin: 0;
}

.npub-access-cta p {
	font-size: 0.85rem;
	color: var(--npub-text-muted);
	line-height: 1.6;
	margin: 0;
}

.npub-access-btns {
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: 100%;
	margin-top: 4px;
}

.npub-access-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 10px 20px;
	border-radius: var(--npub-radius-sm);
	font-size: 0.87rem;
	font-weight: 700;
	text-decoration: none;
	transition: all var(--npub-transition);
}

.npub-access-btn--primary {
	background: var(--npub-primary);
	color: #fff;
}

.npub-access-btn--primary:hover {
	background: var(--npub-primary-dark);
	color: #fff;
	transform: translateY(-1px);
}

.npub-access-btn--outline {
	background: transparent;
	color: var(--npub-primary);
	border: 2px solid var(--npub-primary);
}

.npub-access-btn--outline:hover {
	background: var(--npub-primary);
	color: #fff;
}

.npub-access-tag {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 14px;
	border-radius: 20px;
	font-size: 0.8rem;
	font-weight: 600;
}

.npub-access-tag--pending {
	background: #fef9c3;
	color: #a16207;
	border: 1px solid #fde047;
}

.npub-access-small {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 0.72rem;
	color: var(--npub-text-light);
}

/* ── Error state ──────────────────────────────────────────────────────── */
.npub-error-state {
	text-align: center;
	padding: 60px 24px;
	color: var(--npub-text-muted);
	font-size: 0.95rem;
}

/* ══════════════════════════════════════════════════════════════════════════
   MEMBERSHIP GATE WALL
   Shown instead of the full layout when visitor is not a member.

   .npub-single--gated        – gated variant of the page wrapper
   .npub-gate-header          – top preview strip (cover + title + meta)
   .npub-gate-cover           – small cover image column
   .npub-gate-pub-info        – type badge + title + meta text
   .npub-gate-title           – <h1> publication title
   .npub-gate-meta            – author · date row
   .npub-gate-meta-sep        – · separator
   .npub-gate-wall            – main alert card
   .npub-gate-wall--pending   – pending-approval variant (amber tones)
   .npub-gate-icon            – lock/clock icon circle
   .npub-gate-icon--pending   – amber tint for pending state
   .npub-gate-heading         – <h2> main alert message
   .npub-gate-sub             – supporting paragraph
   .npub-gate-actions         – button row
   .npub-gate-btn             – base button style
   .npub-gate-btn--primary    – "Get Membership" (teal filled)
   .npub-gate-btn--login      – "Already a member? Login" (outline)
   .npub-gate-pending-badge   – "Pending Approval" amber status chip
   .npub-gate-secure          – lock icon + "Protected content" note
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Publication preview header ─────────────────────────────────────── */

.npub-gate-header {
	display: flex;
	align-items: center;
	gap: 20px;
	padding: 24px 28px;
	background: var(--npub-card-bg);
	border: 1px solid var(--npub-border);
	border-radius: var(--npub-radius);
	box-shadow: var(--npub-shadow);
	margin-bottom: 16px;
}

.npub-gate-cover {
	flex-shrink: 0;
	width: 80px;
	height: 110px;
	border-radius: 6px;
	overflow: hidden;
	background: #dbeafe;
	box-shadow: 0 2px 8px rgba(0,0,0,.12);
}

.npub-gate-cover img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.npub-gate-pub-info {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

/* reuse .npub-detail-type-badge from above — no additional rule needed */

.npub-gate-title {
	font-size: 1.15rem;
	font-weight: 800;
	line-height: 1.3;
	color: var(--npub-text);
	margin: 0;
	letter-spacing: -0.01em;
}

.npub-gate-meta {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px;
	row-gap: 3px;
	font-size: 0.82rem;
	color: var(--npub-text-muted);
	margin: 0;
}

.npub-gate-meta span {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

.npub-gate-meta-sep {
	color: var(--npub-border);
}

/* ── Main alert card ─────────────────────────────────────────────────── */

.npub-gate-wall {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 18px;
	padding: 48px 40px 40px;
	background: var(--npub-card-bg);
	border: 1px solid var(--npub-border);
	border-top: 4px solid var(--npub-primary);
	border-radius: var(--npub-radius);
	box-shadow: var(--npub-shadow);
}

.npub-gate-wall--pending {
	border-top-color: #d97706;
}

/* Icon circle */
.npub-gate-icon {
	width: 72px;
	height: 72px;
	border-radius: 50%;
	background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
	border: 2px solid #bfdbfe;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--npub-primary);
	flex-shrink: 0;
}

.npub-gate-icon--pending {
	background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
	border-color: #fde68a;
	color: #d97706;
}

/* Heading */
.npub-gate-heading {
	font-size: 1.35rem;
	font-weight: 800;
	color: var(--npub-text);
	line-height: 1.3;
	margin: 0;
	max-width: 520px;
}

/* Supporting text */
.npub-gate-sub {
	font-size: 0.93rem;
	color: var(--npub-text-muted);
	line-height: 1.65;
	margin: 0;
	max-width: 480px;
}

/* Button row */
.npub-gate-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	justify-content: center;
	margin-top: 6px;
}

.npub-gate-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 26px;
	border-radius: var(--npub-radius-sm);
	font-size: 0.92rem;
	font-weight: 700;
	text-decoration: none;
	transition: all var(--npub-transition);
	white-space: nowrap;
}

.npub-gate-btn--primary {
	background: var(--npub-primary);
	color: #fff;
	border: 2px solid var(--npub-primary);
}
.npub-gate-btn--primary:hover {
	background: var(--npub-primary-dark);
	border-color: var(--npub-primary-dark);
	color: #fff;
	transform: translateY(-2px);
	box-shadow: 0 6px 18px rgba(30,64,175,.3);
}

.npub-gate-btn--login {
	background: transparent;
	color: var(--npub-primary);
	border: 2px solid var(--npub-primary);
}
.npub-gate-btn--login:hover {
	background: var(--npub-primary);
	color: #fff;
	transform: translateY(-2px);
}

/* Pending badge */
.npub-gate-pending-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 7px 16px;
	background: #fef9c3;
	color: #a16207;
	border: 1px solid #fde047;
	border-radius: 20px;
	font-size: 0.82rem;
	font-weight: 700;
}

/* Footer note */
.npub-gate-secure {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-size: 0.75rem;
	color: var(--npub-text-light);
	margin: 0;
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 600px) {
	.npub-gate-header  { flex-direction: column; align-items: flex-start; gap: 14px; padding: 18px; }
	.npub-gate-cover   { width: 60px; height: 82px; }
	.npub-gate-wall    { padding: 32px 20px 28px; }
	.npub-gate-heading { font-size: 1.1rem; }
	.npub-gate-btn     { width: 100%; justify-content: center; }
	.npub-gate-actions { flex-direction: column; }
}
