/* Hakaya flip-book ----------------------------------------------------------
   The company profile as a page-turning book on a night-indigo stage. */

.hk-band--flip { padding-block: 0; }
.hk-band--flip > .hk-flip { margin-inline: auto; }

.hk-flip {
	--hk-flip-stage: radial-gradient(120% 90% at 50% 18%, #26287a 0%, var(--hk-night) 62%, #0a0b26 100%);
	--hk-flip-bar: rgba(10, 11, 38, 0.86);
	position: relative;
	display: flex;
	flex-direction: column;
	color: #fff;
	background: var(--hk-flip-stage);
	outline: none;
	-webkit-tap-highlight-color: transparent;
}

/* ---- stage + book ---- */
.hk-flip__stage {
	position: relative;
	height: clamp(440px, 76vh, 860px);
	padding: clamp(18px, 3vw, 40px) clamp(12px, 3vw, 40px) 18px;
	display: grid;
	place-items: center;
	overflow: hidden;
	perspective: 2400px;
	touch-action: pan-y;
}
.hk-flip__book {
	position: relative;
	width: calc(var(--pw, 360px) * 2);
	height: var(--ph, 510px);
	transform: translateX(var(--shift, 0px));
	transform-style: preserve-3d;
	user-select: none;
	-webkit-user-select: none;
	cursor: grab;
}
.hk-flip.is-single .hk-flip__book { width: var(--pw, 360px); }
.hk-flip__book:active { cursor: grabbing; }

/* the static cover the server sends, replaced once the script runs */
.hk-flip__cover { position: absolute; inset-block: 0; inset-inline-start: 50%; height: 100%; width: auto; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.7); }
.hk-flip:not(.is-ready) .hk-flip__book { width: auto; height: clamp(400px, 66vh, 760px); aspect-ratio: 0.7064; }
.hk-flip:not(.is-ready) .hk-flip__cover { position: static; display: block; height: 100%; }
.hk-flip:not(.is-ready) .hk-flip__bar { visibility: hidden; }

.hk-flip__page {
	position: absolute;
	top: 0;
	width: var(--pw);
	height: var(--ph);
	background: #f6f6fb;
	overflow: hidden;
}
.hk-flip__page--l { left: 0; }
.hk-flip__page--r { left: var(--pw); }
.hk-flip.is-single .hk-flip__page--r { left: 0; }
.hk-flip.is-single .hk-flip__page--l { display: none; }
.hk-flip__page.is-blank { background: none; }
.hk-flip__page:not(.is-blank) { box-shadow: 0 34px 60px -26px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.04); }
.hk-flip__page img, .hk-flip__face img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }

/* the fold: a soft shadow where the two pages meet the spine */
.hk-flip.is-spread .hk-flip__page--l:not(.is-blank)::after,
.hk-flip.is-spread .hk-flip__page--r:not(.is-blank)::after { content: ""; position: absolute; inset-block: 0; width: 9%; pointer-events: none; }
.hk-flip.is-spread .hk-flip__page--l::after { right: 0; background: linear-gradient(to left, rgba(17, 18, 58, 0.22), transparent); }
.hk-flip.is-spread .hk-flip__page--r::after { left: 0; background: linear-gradient(to right, rgba(17, 18, 58, 0.22), transparent); }

/* ---- the turning leaf ---- */
.hk-flip__leaf {
	position: absolute;
	top: 0;
	width: var(--pw);
	height: var(--ph);
	transform-style: preserve-3d;
	will-change: transform;
	z-index: 3;
	pointer-events: none;
}
.hk-flip__leaf.is-right { left: var(--pw); transform-origin: 0 50%; }
.hk-flip__leaf.is-left { left: 0; transform-origin: 100% 50%; }
.hk-flip__leaf.is-single { left: 0; transform-origin: 0 50%; }
.hk-flip__face {
	position: absolute;
	inset: 0;
	background: #f6f6fb;
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
	overflow: hidden;
	box-shadow: 0 30px 60px -24px rgba(0, 0, 0, calc(0.35 + var(--shade, 0) * 0.35));
}
.hk-flip__face--back { transform: rotateY(180deg); }
/* paper darkens as it stands up, lightest when flat */
.hk-flip__face::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: var(--shade, 0); }
.hk-flip__leaf.is-right .hk-flip__face--front::after,
.hk-flip__leaf.is-single .hk-flip__face--front::after { background: linear-gradient(to right, rgba(17, 18, 58, 0.34), rgba(17, 18, 58, 0.08) 45%, rgba(255, 255, 255, 0.12)); }
.hk-flip__leaf.is-right .hk-flip__face--back::after,
.hk-flip__leaf.is-single .hk-flip__face--back::after { background: linear-gradient(to left, rgba(17, 18, 58, 0.34), rgba(17, 18, 58, 0.06) 50%, transparent); }
.hk-flip__leaf.is-left .hk-flip__face--front::after { background: linear-gradient(to left, rgba(17, 18, 58, 0.34), rgba(17, 18, 58, 0.08) 45%, rgba(255, 255, 255, 0.12)); }
.hk-flip__leaf.is-left .hk-flip__face--back::after { background: linear-gradient(to right, rgba(17, 18, 58, 0.34), rgba(17, 18, 58, 0.06) 50%, transparent); }

/* jumping several pages at once: a quick settle instead of a flip per page */
.hk-flip__book.is-jump .hk-flip__page { animation: hk-flip-in 260ms ease-out; }
@keyframes hk-flip-in { from { opacity: 0.35; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* a hint the page can be turned, on pointers that hover */
@media (hover: hover) {
	.hk-flip.is-ready .hk-flip__page--r:not(.is-blank)::before {
		content: ""; position: absolute; right: 0; bottom: 0; width: 0; height: 0; z-index: 2;
		background: linear-gradient(135deg, transparent 50%, rgba(17, 18, 58, 0.18) 50%, #fff 62%);
		transition: width 0.18s ease, height 0.18s ease;
	}
	.hk-flip.is-ready .hk-flip__book:hover .hk-flip__page--r:not(.is-blank)::before { width: 34px; height: 34px; }
}

.hk-flip__hint {
	position: absolute; inset-inline: 0; bottom: 4px; margin: 0; text-align: center;
	font-size: 0.78rem; letter-spacing: 0.04em; color: rgba(255, 255, 255, 0.55);
	pointer-events: none;
}

/* ---- toolbar ---- */
.hk-flip__bar {
	position: relative;
	z-index: 5;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 6px 14px;
	padding: 8px clamp(10px, 2vw, 22px);
	background: var(--hk-flip-bar);
	border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.hk-flip__group { display: flex; align-items: center; gap: 2px; min-width: 0; }
.hk-flip__group:first-child { flex: 1 1 340px; }
.hk-flip__btn {
	display: inline-grid;
	place-items: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: #fff;
	cursor: pointer;
	text-decoration: none;
	flex: none;
}
.hk-flip__btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); }
.hk-flip__btn:focus-visible { outline: 2px solid var(--hk-red); outline-offset: 1px; }
.hk-flip__btn:disabled { opacity: 0.32; cursor: default; }
.hk-flip__btn[aria-pressed="true"], .hk-flip__btn[aria-expanded="true"] { background: rgba(255, 255, 255, 0.16); }
.hk-flip__ico { display: inline-grid; place-items: center; grid-area: 1 / 1; }
.hk-flip__ico--alt { display: none; }
.hk-flip__btn[aria-pressed="true"] .hk-flip__ico:not(.hk-flip__ico--alt),
.hk-flip__btn.is-off .hk-flip__ico:not(.hk-flip__ico--alt) { display: none; }
.hk-flip__btn[aria-pressed="true"] .hk-flip__ico--alt,
.hk-flip__btn.is-off .hk-flip__ico--alt { display: inline-grid; }

.hk-flip__seek { flex: 1 1 auto; display: flex; align-items: center; min-width: 80px; padding-inline: 8px; }
.hk-flip__seek input { width: 100%; accent-color: var(--hk-red); cursor: pointer; }
.hk-flip__count {
	font-family: var(--hk-display); font-weight: 600; font-size: 0.95rem; letter-spacing: 0.04em;
	min-width: 5.6em; text-align: center; font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, 0.9);
}

/* ---- contents panel ---- */
.hk-flip__panel {
	position: absolute;
	z-index: 6;
	inset-block: 0 61px;
	right: 0;
	width: min(360px, 100%);
	display: flex;
	flex-direction: column;
	background: #fff;
	color: var(--hk-ink);
	box-shadow: -24px 0 50px -24px rgba(0, 0, 0, 0.6);
}
.hk-flip__panel[hidden] { display: none; }
.hk-flip__panel-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--hk-line); }
.hk-flip__tabs { display: flex; gap: 4px; }
.hk-flip__tabs button {
	display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px;
	border: 0; border-radius: 6px; background: none; color: var(--hk-ink2); font: inherit; font-weight: 600; cursor: pointer;
}
.hk-flip__tabs button[aria-selected="true"] { background: var(--hk-wash); color: var(--hk-indigo); }
.hk-flip__close { width: 44px; height: 44px; border: 0; border-radius: 6px; background: none; color: var(--hk-ink); cursor: pointer; display: grid; place-items: center; }
.hk-flip__panel-body { overflow-y: auto; padding: 8px 12px 16px; flex: 1; }
.hk-flip__chapters { list-style: none; margin: 0; padding: 0; }
.hk-flip__chapters li { border-bottom: 1px solid var(--hk-line); }
.hk-flip__chapter {
	display: grid; grid-template-columns: 2.2em 1fr auto; align-items: baseline; gap: 8px; width: 100%;
	padding: 12px 6px 4px; border: 0; background: none; color: var(--hk-ink); font: inherit; text-align: start; cursor: pointer;
}
.hk-flip__chapter .n { font-family: var(--hk-display); font-weight: 700; color: var(--hk-red); }
.hk-flip__chapter .t { font-weight: 600; }
.hk-flip__chapter .p { color: var(--hk-ink2); font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.hk-flip__chapter[aria-current="page"] .t { color: var(--hk-indigo); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }
.hk-flip__read { display: inline-block; margin: 0 0 10px calc(2.2em + 14px); font-size: 0.85rem; color: var(--hk-ink2); }
[dir="rtl"] .hk-flip__read { margin: 0 calc(2.2em + 14px) 10px 0; }
.hk-flip__thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 12px; padding-top: 6px; }
.hk-flip__thumb { display: grid; gap: 4px; padding: 0; border: 2px solid transparent; border-radius: 4px; background: none; cursor: pointer; color: var(--hk-ink2); font: inherit; font-size: 0.8rem; }
.hk-flip__thumb img { width: 100%; height: auto; display: block; box-shadow: 0 4px 12px -6px rgba(17, 18, 58, 0.45); }
.hk-flip__thumb[aria-current="page"] { border-color: var(--hk-red); color: var(--hk-ink); font-weight: 700; }

/* ---- toast ---- */
.hk-flip__toast {
	position: absolute; z-index: 7; left: 50%; bottom: 76px; margin: 0; padding: 8px 14px;
	border-radius: 6px; background: #fff; color: var(--hk-ink); font-weight: 600; font-size: 0.9rem;
	transform: translate(-50%, 8px); opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease;
}
.hk-flip__toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---- zoom ---- */
.hk-flip.is-zoomed .hk-flip__stage { overflow: auto; place-items: start center; cursor: move; touch-action: none; }
.hk-flip.is-zoomed .hk-flip__book { cursor: move; }

/* ---- full screen (native, or the iPhone stand-in) ---- */
.hk-flip.is-fullscreen, .hk-flip.is-pseudo-fs { width: 100%; height: 100%; }
.hk-flip.is-fullscreen .hk-flip__stage, .hk-flip.is-pseudo-fs .hk-flip__stage { height: auto; flex: 1; }
.hk-flip.is-pseudo-fs { position: fixed; inset: 0; z-index: 9999; }
html.hk-flip-lock, html.hk-flip-lock body { overflow: hidden; }

/* ---- narrow screens ---- */
@media (max-width: 640px) {
	.hk-flip__stage { height: clamp(420px, 72vh, 760px); padding-inline: 10px; }
	.hk-flip .is-wide-only { display: none; }
	.hk-flip__group:first-child { flex-basis: 100%; }
	.hk-flip__bar { justify-content: center; }
	.hk-flip__panel { inset-block: 0 104px; width: 100%; }
	.hk-flip__toast { bottom: 118px; }
}

@media (prefers-reduced-motion: reduce) {
	.hk-flip__book.is-jump .hk-flip__page { animation: none; }
	.hk-flip__toast { transition: none; }
}

/* ---- the readable companion: each chapter on this website ---- */
.hk-chapters { list-style: none; margin: 1.5rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 2rem; }
.hk-chapters li { border-bottom: 1px solid var(--hk-line); }
.hk-chapters a { display: grid; grid-template-columns: 2.4em 1fr auto; align-items: baseline; gap: 8px; padding: 14px 2px; min-height: 44px; color: var(--hk-ink); text-decoration: none; }
.hk-chapters a:hover .hk-chapters__t { color: var(--hk-indigo); text-decoration: underline; text-underline-offset: 4px; }
.hk-chapters__n { font-family: var(--hk-display); font-weight: 700; color: var(--hk-red); }
.hk-chapters__t { font-weight: 600; }
.hk-chapters__p { font-size: 0.85rem; color: var(--hk-ink2); white-space: nowrap; }
