/* Pustak Bookstore — book page and author page.
 * Uses the same design tokens as the storefront (pustak.css), so every Storefront look applies here too.
 * --pk-hue comes from the book title; --pk-tint is replaced by the cover photo's own colour when there is one.
 */

.pk-book, .pk-authorpage {
	--pk-tint: hsl(var(--pk-hue, 160) 45% 50%);
	--pk-wrap: 1160px;
	display: block; margin: 0; padding: 0; font-size: 16px; line-height: 1.55;
}
.pustak.pkd-boxed.pk-book, .pustak.pkd-boxed.pk-authorpage { background: var(--pk-surface); color: var(--pk-ink); }
.pk-book-wrap {
	max-width: var(--pk-wrap); margin: 0 auto; container: pkbook / inline-size;
	padding-block: clamp(20px, 3vw, 36px) clamp(48px, 6vw, 88px);
	padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.pustak .pk-muted { color: var(--pk-muted); }

/* Breadcrumb */
.pk-crumbs { display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 0 0 clamp(18px, 3vw, 30px); font-size: .86rem; color: var(--pk-muted); }
.pustak .pk-crumbs a { color: inherit; text-decoration: none; }
.pustak .pk-crumbs a:hover { color: var(--pk-accent); text-decoration: underline; text-underline-offset: 3px; }
.pk-crumbs [aria-current] { color: inherit; opacity: .8; max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Hero: book on a stage, details beside it ---------- */

.pk-hero-book { display: grid; grid-template-columns: minmax(0, 470px) minmax(0, 1fr); gap: clamp(28px, 5vw, 72px); align-items: start; }
@container pkbook (max-width: 820px) { .pk-hero-book { grid-template-columns: 1fr; } }

.pk-stage {
	position: relative; display: grid; place-items: center; min-height: 0;
	padding: clamp(40px, 6vw, 64px) 20px 84px; border-radius: 28px; overflow: hidden;
	background: rgba(128, 128, 128, .1);
	background:
		radial-gradient(70% 55% at 50% 38%, color-mix(in srgb, var(--pk-tint) 30%, var(--pk-surface)), transparent 75%),
		color-mix(in srgb, var(--pk-tint) 12%, var(--pk-surface));
	transition: background .6s ease;
}
.pk-floor {
	position: absolute; left: 50%; bottom: 62px; width: min(260px, 60%); height: 26px; transform: translateX(-50%);
	background: radial-gradient(closest-side, rgba(0, 0, 0, .34), transparent); filter: blur(4px); pointer-events: none;
}
.pustak .pk-flip {
	position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
	display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 7px 14px; min-height: 0;
	font: inherit; font-size: .85rem; font-weight: 600; line-height: 1.2; letter-spacing: 0; text-transform: none;
	color: var(--pk-ink); background: var(--pk-surface); background: color-mix(in srgb, var(--pk-surface) 82%, transparent);
	border: 1px solid color-mix(in srgb, var(--pk-ink) 14%, transparent); border-radius: 999px; cursor: pointer; box-shadow: none;
	backdrop-filter: blur(6px);
}
.pustak .pk-flip:hover { border-color: var(--pk-accent); color: var(--pk-accent); }
.pk-flip svg { width: 16px; height: 16px; }

/* The 3D book. Its thickness follows the page count (--pk-thick). */
.pk-book3d {
	--w: min(250px, 58vw); --t: var(--pk-thick, 24px);
	position: relative; z-index: 1; width: var(--w); aspect-ratio: 2 / 3; perspective: 1700px; cursor: pointer;
}
.pk-b3 {
	position: relative; width: 100%; height: 100%; transform-style: preserve-3d;
	transform: rotateX(var(--rx, 4deg)) rotateY(var(--ry, 24deg));
	transition: transform .9s cubic-bezier(.2, .8, .2, 1);
}
.pk-book3d.is-tilting .pk-b3 { transition: transform .25s ease-out; }
.pk-book3d.is-flipped .pk-b3 { transform: rotateX(var(--rx, 4deg)) rotateY(calc(var(--ry, 24deg) + 180deg)); transition: transform .9s cubic-bezier(.2, .8, .2, 1); }
.pk-b3 > div { position: absolute; backface-visibility: hidden; -webkit-backface-visibility: hidden; }

.pk-b-front { inset: 0; transform: translateZ(calc(var(--t) / 2)); }
.pk-b-front .pk-cover { height: 100%; aspect-ratio: auto; border-radius: 2px 5px 5px 2px; box-shadow: none; transition: none; }
.pk-b-front .pk-cover-gen .pk-cover-title { font-size: clamp(1.1rem, 9cqw, 1.7rem); }
.pk-b-front .pk-cover-gen .pk-cover-author { font-size: .7rem; }
.pk-b-front::after {
	content: ""; position: absolute; inset: 0; border-radius: 2px 5px 5px 2px; pointer-events: none;
	background: linear-gradient(105deg, rgba(255, 255, 255, .22), transparent 28%, transparent 70%, rgba(0, 0, 0, .12));
}
.pk-b-spine {
	top: 0; bottom: 0; left: calc(50% - var(--t) / 2); width: var(--t);
	transform: rotateY(-90deg) translateZ(calc(var(--w) / 2));
	display: grid; place-items: center; overflow: hidden; border-radius: 2px;
	background-color: #2a2621;
	background-color: var(--pk-tint);
	background-image: linear-gradient(90deg, rgba(0, 0, 0, .35), rgba(255, 255, 255, .08) 45%, rgba(0, 0, 0, .3)), linear-gradient(rgba(14, 12, 9, .5), rgba(14, 12, 9, .5));
	color: rgba(255, 255, 255, .88);
}
.pk-b-spine span {
	writing-mode: vertical-rl; transform: rotate(180deg); max-height: 92%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
	font-family: var(--pk-title-font); font-size: clamp(.55rem, calc(var(--t) * .42), .9rem); font-weight: 600; letter-spacing: .04em;
}
.pk-b-pages {
	top: 4px; bottom: 4px; left: calc(50% - var(--t) / 2); width: var(--t);
	transform: rotateY(90deg) translateZ(calc(var(--w) / 2 - 4px));
	background: repeating-linear-gradient(90deg, #f7f2e7 0 1.5px, #e2dacb 1.5px 2.5px);
	box-shadow: inset 0 0 6px rgba(0, 0, 0, .18);
}
.pk-b-back {
	inset: 0; transform: rotateY(180deg) translateZ(calc(var(--t) / 2));
	display: flex; flex-direction: column; gap: 10px; padding: 9% 9% 8%; border-radius: 5px 2px 2px 5px; overflow: hidden;
	/* No colour-mixing here: some browsers and CSS optimisers drop it, which left the back see-through. */
	background-color: #1f1c18;
	background-color: var(--pk-tint);
	color: #fff; container-type: inline-size; isolation: isolate;
	text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
/* Photo covers: the artwork wraps round to the back, blurred and darkened. */
.pk-b-back.has-photo::before {
	content: ""; position: absolute; inset: -14%; z-index: -2;
	background: var(--pk-back-photo) center / cover no-repeat;
	filter: blur(14px) saturate(1.15); transform: scaleX(-1);
}
.pk-b-back::after {
	content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
	background: linear-gradient(160deg, rgba(255, 255, 255, .08), transparent 42%), linear-gradient(rgba(14, 12, 9, .62), rgba(14, 12, 9, .7));
}
.pustak .pk-b-back p { margin: 0; }
.pustak .pk-b-back-title { font-family: var(--pk-title-font); font-weight: 600; font-size: 7.4cqw; line-height: 1.15; }
.pustak .pk-b-blurb { font-size: 5.1cqw; line-height: 1.5; opacity: .9; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 11; overflow: hidden; }
.pk-b-back-foot { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.pustak .pk-b-mrp { font-size: 5.4cqw; font-weight: 700; line-height: 1.25; }
.pk-b-mrp small { display: block; font-size: 3.8cqw; font-weight: 400; opacity: .8; }
.pk-b-barcode { flex: none; width: 50%; padding: 4% 4% 2%; background: #fff; border-radius: 2px; }
.pustak svg.pk-barcode { display: block; width: 100%; height: auto; }
.pk-barcode text { fill: #111; }

/* Details beside the book */
.pk-book-info { min-width: 0; padding-top: clamp(0px, 2vw, 18px); }
.pustak .pk-eyebrow { margin: 0 0 10px; font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--pk-muted); }
.pustak .pk-eyebrow a { color: var(--pk-accent); text-decoration: none; }
.pustak .pk-book-title {
	margin: 0 0 10px; font-family: var(--pk-title-font); font-weight: var(--pk-w-head, 600); color: var(--pk-c-head, inherit);
	font-size: calc(clamp(2.1rem, 4.6vw, 3.6rem) * var(--pk-h-scale, 1)); line-height: 1.04; letter-spacing: -.015em; text-wrap: balance;
}
.pustak .pk-book-by { margin: 0 0 16px; font-size: 1.15rem; color: var(--pk-muted); }
.pustak .pk-book-by a { font-weight: 600; color: var(--pk-c-author, var(--pk-ink)); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--pk-accent) 55%, transparent); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.pk-book.pustak:not(.pkd-boxed) .pk-book-by a { color: var(--pk-c-author, inherit); }
.pustak .pk-book-by a:hover { text-decoration-color: var(--pk-accent); }

.pk-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; }
.pk-tags:empty { display: none; }
.pk-tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; font-size: .8rem; font-weight: 600; border-radius: 999px; background: var(--pk-soft); color: var(--pk-ink); }
.pk-tag-pick { background: color-mix(in srgb, var(--pk-accent) 14%, var(--pk-surface)); color: var(--pk-ink); }
.pk-tag-pick::before { content: ""; width: 8px; height: 12px; background: var(--pk-accent); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 74%, 0 100%); }
.pk-tag-new { background: var(--pk-accent); color: var(--pk-on-accent); }

/* Buying panel */
.pk-buy { padding: clamp(18px, 2.4vw, 24px); border: 1px solid var(--pk-line); border-radius: 18px; background: var(--pk-surface); color: var(--pk-ink); }
.pustak .pk-price-xl { margin: 0 0 4px; gap: 4px 10px; }
.pk-price-xl .pk-price { font-size: calc(var(--pk-t-price, 1.05rem) * 2); line-height: 1.1; letter-spacing: -.01em; }
.pk-price-xl .pk-mrp { font-size: calc(var(--pk-t-price, 1.05rem) * 1); }
.pk-price-xl .pk-off { font-size: 1rem; padding: 2px 8px; border-radius: 6px; background: color-mix(in srgb, var(--pk-good) 14%, var(--pk-surface)); }
.pustak .pk-stockline { margin: 0 0 16px; font-size: .9rem; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.pk-stockline::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pk-stockline.is-in { color: var(--pk-good); }
.pk-stockline.is-low { color: var(--pk-warn); }
.pk-stockline.is-out { color: var(--pk-bad); }
.pk-buy .pk-buy-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pk-buy .pk-buy-actions .pk-btn { min-height: 50px; font-size: 1rem; }
.pk-buy .pk-buy-actions .pk-btn:only-child { grid-column: 1 / -1; }
.pustak.pkd-hide-buynow .pk-buy .pk-buy-actions .pk-add { grid-column: 1 / -1; }
.pustak .pk-perks { list-style: none; margin: 18px 0 0; padding: 16px 0 0; border-top: 1px solid var(--pk-line); display: grid; gap: 9px; }
.pk-perks li { display: flex; align-items: flex-start; gap: 10px; margin: 0; font-size: .92rem; line-height: 1.4; }
.pustak svg.pk-ic { width: 20px; height: 20px; fill: none; stroke: var(--pk-accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; margin-top: -1px; }

.pk-pincheck { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--pk-line); }
.pustak .pk-pincheck label { display: block; margin: 0 0 6px; font-size: .86rem; font-weight: 600; }
.pk-pincheck-row { display: flex; gap: 8px; }
.pustak .pk-pincheck-row input:not([type=radio]):not([type=checkbox]) { flex: 1; min-width: 0; min-height: 42px; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.pk-pincheck-row .pk-btn { flex: none; min-height: 42px; }
.pustak .pk-pin-out { margin: 8px 0 0; font-size: .86rem; font-weight: 500; }
.pk-pin-out:empty { display: none; }
.pk-pin-out.is-good { color: var(--pk-good); }
.pk-pin-out.is-warn { color: var(--pk-warn); }
.pk-pin-out.is-bad { color: var(--pk-bad); }

.pustak .pk-share { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 14px 4px 0; font-size: .9rem; }
.pustak .pk-share a { color: var(--pk-accent); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- About + facts ---------- */

.pk-book-details { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: clamp(28px, 5vw, 64px); margin-top: clamp(44px, 6vw, 80px); align-items: start; }
@container pkbook (max-width: 820px) { .pk-book-details { grid-template-columns: 1fr; } }
.pustak .pk-section-title { margin: 0 0 16px; font-family: var(--pk-title-font); font-size: calc(clamp(1.4rem, 2.4vw, 1.75rem) * var(--pk-h-scale, 1)); line-height: 1.2; font-weight: var(--pk-w-head, 600); color: var(--pk-c-head, inherit); }
.pk-about-body { max-width: 66ch; font-size: var(--pk-t-body, 1.06rem); line-height: var(--pk-lh-body, 1.75); color: var(--pk-c-body, inherit); }
.pustak .pk-about-body > p { margin: 0 0 1.1em; }
.pk-about-body > p:first-of-type::first-letter {
	float: left; margin: .06em .12em 0 0; font-family: var(--pk-title-font); font-size: 3.5em; line-height: .82; font-weight: 600; color: var(--pk-accent);
}
.pk-facts { padding: 6px 20px; border-radius: 16px; background: var(--pk-soft); color: var(--pk-ink); }
.pustak .pk-facts dl { margin: 0; }
.pk-facts dl > div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--pk-line); }
.pk-facts dl > div:last-child { border-bottom: 0; }
.pustak .pk-facts dt { margin: 0; font-size: .86rem; color: var(--pk-muted); }
.pustak .pk-facts dd { margin: 0; font-size: .92rem; font-weight: 600; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.pustak .pk-facts a { color: inherit; text-decoration: underline; text-decoration-color: var(--pk-line); text-underline-offset: 3px; }
.pustak .pk-facts a:hover { text-decoration-color: var(--pk-accent); }

/* ---------- Author ---------- */

.pk-avatar { display: grid; place-items: center; flex: none; width: 64px; aspect-ratio: 1; max-width: 100%; border-radius: 50%; overflow: hidden; background: var(--pk-soft); }
.pk-avatar img { width: 100%; height: 100%; object-fit: cover; margin: 0; }
.pk-avatar-mono {
	background: radial-gradient(80% 80% at 30% 20%, rgba(255, 255, 255, .16), transparent 60%), hsl(var(--pk-hue, 160) 34% 32%);
	color: hsl(var(--pk-hue, 160) 45% 92%); font-family: var(--pk-title-font); font-weight: 600; letter-spacing: .02em;
}
.pk-avatar-lg { width: 132px; font-size: 2.6rem; }
.pk-avatar-xl { width: clamp(132px, 18vw, 200px); font-size: clamp(2.6rem, 4vw, 4rem); }

.pk-author-card {
	display: grid; grid-template-columns: auto minmax(0, 1fr); gap: clamp(18px, 3vw, 32px); align-items: start;
	margin-top: clamp(44px, 6vw, 72px); padding: clamp(20px, 3vw, 32px);
	border-radius: 22px; background: rgba(128, 128, 128, .08); background: color-mix(in srgb, var(--pk-tint) 9%, var(--pk-surface)); color: var(--pk-ink);
}
.pustak.pkd-hide-authorbox .pk-author-card { display: none; }
@container pkbook (max-width: 520px) { .pk-author-card { grid-template-columns: 1fr; } .pk-avatar-lg { width: 96px; font-size: 2rem; } }
.pk-author-photo { display: block; text-decoration: none; }
.pustak .pk-author-name { margin: 2px 0 4px; font-family: var(--pk-title-font); font-size: calc(clamp(1.4rem, 2.6vw, 1.9rem) * var(--pk-h-scale, 1)); line-height: 1.15; font-weight: var(--pk-w-head, 600); color: var(--pk-c-head, inherit); }
.pustak .pk-author-name a { color: inherit; text-decoration: none; }
.pustak .pk-author-name a:hover { text-decoration: underline; text-underline-offset: 4px; }
.pustak .pk-author-meta { margin: 0 0 12px; font-size: .9rem; color: var(--pk-muted); }
.pustak .pk-author-bio { margin: 0 0 12px; max-width: 70ch; font-size: var(--pk-t-body, 1rem); line-height: var(--pk-lh-body, 1.7); color: var(--pk-c-body, inherit); }
.pustak .pk-author-bio p { margin: 0 0 .9em; }
.pustak .pk-author-known { margin: 0 0 14px; font-size: .95rem; }
.pk-author-known span { margin-right: 6px; font-size: .74rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--pk-muted); }
.pustak .pk-more-link { display: inline-flex; gap: 6px; font-weight: 600; color: var(--pk-accent); text-decoration: none; }
.pustak .pk-more-link:hover span { transform: translateX(3px); }
.pk-more-link span { transition: transform .15s; }

/* Rows below the book */
.pk-book .pk-shelf { margin-top: clamp(40px, 5vw, 64px); }
.pustak.pkd-hide-similar .pk-similar { display: none; }

/* ---------- Sticky buy bar ---------- */

.pk-buybar {
	position: fixed; z-index: 99980; left: 0; right: 0; bottom: 0;
	padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
	background: var(--pk-surface); background: color-mix(in srgb, var(--pk-surface) 94%, transparent); color: var(--pk-ink);
	border-top: 1px solid var(--pk-line); box-shadow: 0 -10px 30px -18px rgba(0, 0, 0, .35); backdrop-filter: blur(10px);
	transform: translateY(110%); transition: transform .3s ease;
}
.pk-buybar.is-on { transform: none; }
.pk-buybar-in { display: flex; align-items: center; gap: 12px; max-width: var(--pk-wrap); margin: 0 auto; }
.pk-buybar-cover { width: 34px; flex: none; }
.pk-buybar-cover .pk-cover::before { display: none; }
.pk-buybar-cover .pk-cover-gen > * { display: none; }
.pk-buybar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.pk-buybar-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--pk-title-font); }
.pk-buybar-text span { font-weight: 700; font-variant-numeric: tabular-nums; }
.pk-buybar .pk-btn { flex: none; padding-inline: 1.6em; }
html.pk-buybar-on .pustak .pk-fab { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
html.pk-buybar-on .pk-toast { bottom: calc(150px + env(safe-area-inset-bottom, 0px)); }

/* ---------- Author page ---------- */

.pk-author-hero {
	display: grid; grid-template-columns: auto minmax(0, 1fr); gap: clamp(22px, 4vw, 48px); align-items: center;
	padding: clamp(24px, 4vw, 48px); border-radius: 28px;
	background: rgba(128, 128, 128, .08);
	background: radial-gradient(60% 90% at 0% 0%, color-mix(in srgb, var(--pk-tint) 20%, var(--pk-surface)), transparent 70%), color-mix(in srgb, var(--pk-tint) 8%, var(--pk-surface));
	color: var(--pk-ink);
}
@container pkbook (max-width: 600px) { .pk-author-hero { grid-template-columns: 1fr; } }
.pk-author-hero .pk-book-title { margin-bottom: 6px; }
.pk-author-books { margin-top: clamp(40px, 5vw, 64px); }
.pk-count { display: inline-grid; place-items: center; min-width: 1.7em; height: 1.7em; margin-left: 8px; padding: 0 .4em; border-radius: 999px; background: var(--pk-soft); font-family: inherit; font-size: .55em; font-weight: 700; vertical-align: middle; color: var(--pk-muted); }


@media (prefers-reduced-motion: reduce) {
	.pk-b3, .pk-book3d.is-flipped .pk-b3, .pk-buybar { transition: none; }
}

/* Browsers without container queries: fall back to screen width */
@supports not (container-type: inline-size) {
	@media (max-width: 860px) { .pk-hero-book, .pk-book-details { grid-template-columns: 1fr; } }
	@media (max-width: 560px) { .pk-author-card { grid-template-columns: 1fr; } .pk-avatar-lg { width: 96px; font-size: 2rem; } }
	@media (max-width: 640px) { .pk-author-hero { grid-template-columns: 1fr; } }
}

/* Direct sales: "Sold directly by" on the buying panel */
.pustak .pk-soldby { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; padding: 0 0 14px; border-bottom: 1px solid var(--pk-line); }
.pk-soldby > span:last-child { display: flex; flex-direction: column; line-height: 1.25; }
.pk-soldby .pk-kicker { font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--pk-muted); }
.pk-soldby strong { font-size: 1.05rem; }
.pk-avatar-sm { width: 40px; font-size: .95rem; }
.pustak .pk-perks a { color: var(--pk-accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
