@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;600&family=Trirong:ital,wght@0,400;0,600;1,400&display=swap');

/* ── Write button ────────────────────────────────────────────────── */
.fhj-write-btn {
	display: inline-block;
	background: transparent;
	color: var(--brass, #c9a257);
	border: 1px solid var(--brass, #c9a257);
	padding: 0.5rem 1.25rem;
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	text-decoration: none;
	border-radius: 2px;
	margin-bottom: 1rem;
	transition: background 0.2s, color 0.2s;
}
.fhj-write-btn:hover {
	background: var(--brass, #c9a257);
	color: var(--charcoal, #1a1a1a);
}

.fhj-from-label {
	color: var(--brass, #c9a257);
	text-transform: uppercase;
	letter-spacing: 0.12em;
	font-size: 0.75rem;
	font-weight: 700;
	margin: 0.75rem 0 0.5rem;
}

.fhj-no-entries {
	color: #888;
	font-style: italic;
	font-size: 0.85rem;
	margin: 0;
}

/* ── Entry trigger buttons ───────────────────────────────────────── */
.fhj-entries {
	display: flex;
	flex-wrap: wrap;
	gap: 0.85rem;
	margin: 1.5rem 0;
}

.fhj-entry-trigger {
	background: #f5e6c8;
	border: 1px solid rgba(139, 90, 43, 0.28);
	border-radius: 3px;
	padding: 0.85rem 1.25rem;
	cursor: pointer;
	text-align: left;
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
	box-shadow: 1px 2px 6px rgba(0, 0, 0, 0.1);
	transition: transform 0.18s ease, box-shadow 0.18s ease;
	max-width: 220px;
	font-family: 'Caveat', cursive;
}

.fhj-entry-trigger:hover,
.fhj-entry-trigger:focus-visible {
	transform: translateY(-2px) rotate(-0.4deg);
	box-shadow: 2px 5px 14px rgba(0, 0, 0, 0.16);
	outline: none;
}

.fhj-trigger-guest {
	font-size: 1.1rem;
	font-weight: 600;
	color: #2a1a0a;
}

.fhj-trigger-label {
	font-size: 0.88rem;
	color: #8b5a2b;
}

.fhj-trigger-date {
	font-size: 0.82rem;
	color: #8b5a2b;
	opacity: 0.7;
}

.fhj-trigger-excerpt {
	font-size: 0.92rem;
	color: #3a2a1a;
	opacity: 0.75;
	font-style: italic;
	margin-top: 0.2rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 190px;
}

/* ── Overlay ─────────────────────────────────────────────────────── */
.fhj-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.82);
	z-index: 9990;
	cursor: pointer;
}

.fhj-overlay[hidden] { display: none; }

/* ── Popup shell ─────────────────────────────────────────────────── */
.fhj-popup[hidden] { display: none; }

.fhj-popup {
	position: fixed;
	inset: 0;
	z-index: 9995;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1.5rem;
	pointer-events: none;
}

.fhj-popup:not([hidden]) {
	pointer-events: auto;
}

/* ── Book scene (perspective wrapper) ────────────────────────────── */
.fhj-book-scene {
	perspective: 2800px;
	perspective-origin: center center;
	width: 100%;
	max-width: 660px;
	max-height: 90vh;
}

/* ── Book container ──────────────────────────────────────────────── */
.fhj-book {
	position: relative;
	width: 100%;
	transform-style: preserve-3d;
	/* Subtle drop shadow for depth */
	filter: drop-shadow(0 20px 60px rgba(0, 0, 0, 0.7));
}

/* Spine illusion on left edge */
.fhj-book::before {
	content: '';
	position: absolute;
	left: -10px;
	top: 6px;
	bottom: 6px;
	width: 14px;
	background: linear-gradient(to right, #0a0502, #1c0d05 60%, #2a1208);
	border-radius: 3px 0 0 3px;
	z-index: 1;
	box-shadow: -3px 0 10px rgba(0, 0, 0, 0.5);
}

/* ── Cover (3D flip element) ─────────────────────────────────────── */
.fhj-cover {
	position: absolute;
	inset: 0;
	transform-origin: left center;
	transform-style: preserve-3d;
	transform: rotateY(0deg);
	transition: transform 0.95s cubic-bezier(0.4, 0.0, 0.2, 1.0);
	z-index: 3;
	border-radius: 2px 4px 4px 2px;
}

.fhj-cover.is-open {
	transform: rotateY(-180deg);
	pointer-events: none;
}

/* Front face of cover */
.fhj-cover-front,
.fhj-cover-back {
	position: absolute;
	inset: 0;
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
	border-radius: 2px 4px 4px 2px;
}

.fhj-cover-front {
	background: #1a0d05;
	background-image:
		radial-gradient(ellipse at 25% 15%, rgba(90, 45, 10, 0.5) 0%, transparent 55%),
		radial-gradient(ellipse at 75% 85%, rgba(50, 18, 4, 0.4) 0%, transparent 50%),
		repeating-linear-gradient(
			145deg,
			transparent,
			transparent 3px,
			rgba(255, 255, 255, 0.012) 3px,
			rgba(255, 255, 255, 0.012) 4px
		);
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: inset -4px 0 12px rgba(0, 0, 0, 0.4);
}

/* Gold border decoration on cover */
.fhj-cover-deco {
	border: 1px solid rgba(201, 162, 87, 0.55);
	box-shadow:
		inset 0 0 0 5px rgba(201, 162, 87, 0.08),
		inset 0 0 0 6px rgba(201, 162, 87, 0.35);
	padding: 2.2rem 2rem;
	margin: 1.75rem;
	text-align: center;
	flex: 1;
}

.fhj-cover-inn {
	font-family: 'Trirong', serif;
	color: rgba(201, 162, 87, 0.75);
	text-transform: uppercase;
	letter-spacing: 0.2em;
	font-size: 0.65rem;
	margin: 0 0 0.9rem;
}

.fhj-cover-rule {
	width: 40px;
	height: 1px;
	background: rgba(201, 162, 87, 0.45);
	margin: 0.75rem auto;
}

.fhj-cover-title {
	font-family: 'Trirong', serif;
	color: rgba(201, 162, 87, 0.9);
	font-size: clamp(1.4rem, 3vw, 2rem);
	font-weight: 600;
	margin: 0;
	letter-spacing: 0.06em;
}

.fhj-cover-sub {
	font-family: 'Trirong', serif;
	color: rgba(201, 162, 87, 0.55);
	font-size: 0.65rem;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	margin: 0.9rem 0 0;
}

/* Back face of cover (inside cover, visible when fully open) */
.fhj-cover-back {
	transform: rotateY(180deg);
	background: #e8d5ae;
	background-image:
		radial-gradient(ellipse at 50% 0%, rgba(139, 90, 43, 0.08) 0%, transparent 70%);
	box-shadow: inset 4px 0 16px rgba(139, 90, 43, 0.12);
}

/* ── Page (parchment content, always beneath cover) ──────────────── */
.fhj-page {
	position: relative;
	background: #f5e6c8;
	background-image:
		repeating-linear-gradient(
			transparent,
			transparent 31px,
			rgba(139, 90, 43, 0.1) 31px,
			rgba(139, 90, 43, 0.1) 32px
		);
	background-position: 0 3rem;
	padding: 3rem 2.75rem 2rem 4rem;
	font-family: 'Caveat', cursive;
	color: #2a1a0a;
	max-height: 85vh;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	border-radius: 0 4px 4px 0;
}

/* Left margin line */
.fhj-page::before {
	content: '';
	position: absolute;
	left: 3rem;
	top: 0;
	bottom: 0;
	width: 1px;
	background: rgba(200, 90, 90, 0.28);
	pointer-events: none;
}

/* Close button */
.fhj-popup-close {
	position: absolute;
	top: 0.6rem;
	right: 0.8rem;
	background: none;
	border: none;
	font-size: 2rem;
	color: #3a2a1a;
	cursor: pointer;
	opacity: 0.4;
	z-index: 2;
	line-height: 1;
	padding: 0.2rem 0.4rem;
	transition: opacity 0.15s;
	font-family: sans-serif;
}

.fhj-popup-close:hover { opacity: 0.9; }

/* Page content fades in after cover opens */
.fhj-page-content {
	opacity: 0;
	transition: opacity 0.35s ease 0.65s;
}

.fhj-cover.is-open ~ .fhj-page .fhj-page-content {
	opacity: 1;
}

/* ── Scrapbook photos ────────────────────────────────────────────── */
.fhj-photos {
	display: flex;
	flex-wrap: wrap;
	gap: 1.1rem;
	margin-bottom: 1.75rem;
}

.fhj-photo {
	background: #fff;
	padding: 0.5rem 0.5rem 2rem;
	box-shadow: 2px 3px 10px rgba(0, 0, 0, 0.22);
	display: inline-block;
	line-height: 0;
}

.fhj-photo img {
	width: 155px;
	height: 115px;
	object-fit: cover;
	display: block;
}

.fhj-photo-1 { transform: rotate(-2.8deg); }
.fhj-photo-2 { transform: rotate(1.6deg); }
.fhj-photo-3 { transform: rotate(-1.1deg); }

/* ── Entry text ──────────────────────────────────────────────────── */
.fhj-entry-body {
	padding-left: 0.25rem;
}

.fhj-entry-text {
	font-size: 1.35rem;
	line-height: 2rem;
	color: #1e1208;
	margin: 0 0 2rem;
	white-space: pre-wrap;
}

/* ── Photo lightbox ──────────────────────────────────────────────── */
.fhj-photo-lightbox {
	position: fixed;
	inset: 0;
	z-index: 10000;
	background: rgba(0, 0, 0, 0.92);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: zoom-out;
	padding: 1.5rem;
}

.fhj-photo-lightbox[hidden] { display: none; }

.fhj-photo-lightbox img {
	max-width: 100%;
	max-height: 90vh;
	max-height: 90dvh;
	object-fit: contain;
	border: 3px solid rgba(255, 255, 255, 0.06);
	box-shadow: 0 8px 60px rgba(0, 0, 0, 0.7);
}

/* Make journal photos show as clickable */
.fhj-photo img {
	cursor: zoom-in;
}

/* ── Page entry content area ─────────────────────────────────────── */
.fhj-page-entry {
	transition: opacity 0.2s ease;
}

.fhj-page-entry.fhj-fading {
	opacity: 0;
}

/* ── Prev / Next navigation ──────────────────────────────────────── */
.fhj-page-nav {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-top: 1.5rem;
	padding-top: 1rem;
	border-top: 1px solid rgba(139, 90, 43, 0.18);
}

.fhj-nav-prev,
.fhj-nav-next {
	background: transparent;
	border: 1px solid rgba(90, 48, 16, 0.35);
	color: #5a3010;
	padding: 0.35rem 0.85rem;
	font-family: 'Trirong', serif;
	font-size: 0.8rem;
	letter-spacing: 0.06em;
	cursor: pointer;
	border-radius: 2px;
	transition: background 0.15s;
}

.fhj-nav-prev:hover,
.fhj-nav-next:hover {
	background: rgba(90, 48, 16, 0.08);
}

.fhj-nav-prev.fhj-nav-hidden,
.fhj-nav-next.fhj-nav-hidden {
	visibility: hidden;
	pointer-events: none;
}

.fhj-nav-count {
	font-family: 'Trirong', serif;
	font-size: 0.8rem;
	color: rgba(42, 26, 10, 0.55);
	letter-spacing: 0.05em;
}

/* ── Signature ───────────────────────────────────────────────────── */
.fhj-entry-sig {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0 0.6rem;
	border-top: 1px solid rgba(139, 90, 43, 0.22);
	padding-top: 0.75rem;
	font-size: 1rem;
	color: #6b3e1a;
}

.fhj-sig-name {
	font-weight: 600;
	font-size: 1.1rem;
}

.fhj-sig-date::before,
.fhj-sig-label::before {
	content: '\00b7\0020';
}

.fhj-sig-date,
.fhj-sig-label {
	opacity: 0.72;
	font-size: 0.95rem;
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 600px) {
	/* Centered modal on mobile — not full-screen, fits the viewport */
	.fhj-popup {
		padding: 1rem;
		align-items: center;
	}

	.fhj-book-scene {
		perspective: none;
		max-width: 100%;
		width: 100%;
		max-height: 88vh;
		max-height: 88dvh;
	}

	.fhj-book {
		filter: none;
	}

	/* Hide spine and 3D cover flip — not practical on small screens */
	.fhj-book::before {
		display: none;
	}

	.fhj-cover {
		display: none;
	}

	/* Page constrained to viewport, scrolls internally */
	.fhj-page {
		max-height: 88vh;
		max-height: 88dvh;
		padding: 3rem 1.25rem 1.5rem 1.75rem;
		border-radius: 4px;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		overscroll-behavior: contain;
		background-position: 0 3rem;
	}

	.fhj-page::before {
		left: 1.25rem;
	}

	.fhj-photo img {
		width: 110px;
		height: 82px;
	}

	.fhj-entry-text {
		font-size: 1.1rem;
		line-height: 1.85rem;
	}

	.fhj-entry-trigger {
		max-width: 100%;
	}

	.fhj-trigger-excerpt {
		max-width: 100%;
	}
}
