/* ============================================================
   IT-RANKS Publications — immersive reader
   Full-viewport dark stage. The publication is the only subject.
   ============================================================ */

.itr-pub-reader-body {
	margin: 0;
	padding: 0;
	overflow: hidden;
	background: #01060f;
	-webkit-font-smoothing: antialiased;
}

/* WordPress admin bar would break the fixed layout — offset for it. */
.itr-pub-reader-body.admin-bar .itr-reader {
	top: 32px;
	height: calc(100dvh - 32px);
}

@media screen and (max-width: 782px) {
	.itr-pub-reader-body.admin-bar .itr-reader {
		top: 46px;
		height: calc(100dvh - 46px);
	}
}

.itr-reader {
	--bar-h:      64px;
	--tool-h:     60px;
	--ink:        #01060f;
	--ink-2:      #061024;
	--blue:       #3884f5;
	--cyan:       #38c8e2;
	--text:       #e8eefb;
	--text-dim:   rgba(232, 238, 251, .58);
	--glass:      rgba(255, 255, 255, .07);
	--glass-line: rgba(255, 255, 255, .12);
	--ease:       cubic-bezier(.16, 1, .3, 1);

	position: fixed;
	inset: 0;
	display: flex;
	flex-direction: column;
	height: 100dvh;
	color: var(--text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	background:
		radial-gradient(80% 60% at 50% 0%,   rgba(56, 132, 245, .13), transparent 68%),
		radial-gradient(70% 60% at 50% 100%, rgba(56, 200, 226, .07), transparent 70%),
		linear-gradient(180deg, #061024 0%, #01060f 62%, #01060f 100%);
}

/* ── Brand bar ─────────────────────────────────────────────── */

.itr-reader__bar {
	flex: 0 0 var(--bar-h);
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 16px;
	padding-inline: clamp(12px, 2.4vw, 26px);
	border-bottom: 1px solid rgba(255, 255, 255, .07);
	background: rgba(1, 6, 15, .72);
	backdrop-filter: blur(14px) saturate(140%);
	-webkit-backdrop-filter: blur(14px) saturate(140%);
	z-index: 30;
}

.itr-reader__back {
	justify-self: start;
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 8px 14px 8px 9px;
	border-radius: 100px;
	color: var(--text-dim);
	text-decoration: none;
	font: 500 13.5px/1 inherit;
	border: 1px solid transparent;
	transition: color .2s var(--ease), background .2s var(--ease), border-color .2s var(--ease);
}

.itr-reader__back svg {
	width: 17px;
	height: 17px;
}

.itr-reader__back:hover {
	color: var(--text);
	background: var(--glass);
	border-color: var(--glass-line);
}

.itr-reader__identity {
	text-align: center;
	min-width: 0;
}

/* One line: "EVENT: Publication title".
   font-family is forced because this is an <h1> and the theme would
   otherwise impose its large monospace display face. */
.itr-reader__title {
	margin: 0;
	font-family: plex-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	font-size: 13.5px;
	font-weight: 500;
	line-height: 1.35;
	letter-spacing: 0;
	text-transform: none;
	color: var(--text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: min(64vw, 900px);
}

.itr-reader__event {
	font-weight: 600;
	letter-spacing: .1em;
	text-transform: uppercase;
	font-size: 11.5px;
	color: var(--blue);
	margin-right: 5px;
}

.itr-reader__name { color: var(--text); }

.itr-reader__bar-actions {
	justify-self: end;
	display: flex;
	align-items: center;
	gap: 4px;
}

.itr-reader__iconbtn {
	display: inline-grid;
	place-items: center;
	width: 38px;
	height: 38px;
	border: 1px solid transparent;
	border-radius: 9px;
	background: none;
	color: var(--text-dim);
	cursor: pointer;
	text-decoration: none;
	transition: color .18s var(--ease), background .18s var(--ease), border-color .18s var(--ease);
}

.itr-reader__iconbtn svg {
	width: 18px;
	height: 18px;
}

.itr-reader__iconbtn:hover {
	color: var(--text);
	background: var(--glass);
	border-color: var(--glass-line);
}

/* ── Stage ─────────────────────────────────────────────────── */

/* Padding is kept to just what the side arrows need (46px button +
   a small gutter). Anything more is viewport the magazine could be
   using — the spread should fill the screen. */
.itr-reader__stage {
	position: relative;
	flex: 1 1 auto;
	display: grid;
	place-items: center;
	min-height: 0;
	padding: 10px 60px;
	overflow: hidden;

	/* Every touch on the stage is the reader's: page turns, pinch, pan. Left to
	   the browser, a pinch would zoom the whole document and a double-tap would
	   trigger its own zoom, both fighting the gestures below. The stage never
	   scrolls, so nothing is given up by claiming them. */
	touch-action: none;
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
	-webkit-tap-highlight-color: transparent;
}

.itr-reader__book-wrap {
	position: relative;
	display: grid;
	place-items: center;
	width: 100%;
	height: 100%;
	transform-origin: center center;
	will-change: transform;
	/* Button and keyboard zooms glide. A pinch must not — the page would trail
	   a frame behind the fingers — so the gesture layer adds .is-zooming to the
	   stage for the duration of a live gesture. */
	transition: transform .26s var(--ease);
}

.itr-reader__stage.is-zooming .itr-reader__book-wrap { transition: none; }

/* Zoomed in, the page is a thing you push around rather than turn. */
.itr-reader__stage.is-zoomed { cursor: grab; }
.itr-reader__stage.is-grabbing { cursor: grabbing; }
.itr-reader__stage.is-zoomed .itr-reader__book { cursor: inherit; }

.itr-reader__book {
	position: relative;
	filter: drop-shadow(0 34px 60px rgba(0, 0, 0, .62));
	transition: transform .42s var(--ease);
}

/* A lone cover renders in the right half of the spread and a lone back cover
   in the left half. Shift by half a page so single pages sit centred instead
   of stranded beside an empty half. */
.itr-reader__book.is-cover-only { transform: translateX(-25%); }
.itr-reader__book.is-back-only  { transform: translateX(25%); }

/* StPageFlip page surfaces */
.itr-reader__book .stf__item,
.itr-reader__page {
	background: #fff;
	overflow: hidden;
}

.itr-reader__page {
	position: relative;
	display: grid;
	place-items: center;
	width: 100%;
	height: 100%;
	background: #0d1526;
}

.itr-reader__page canvas {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

/* Per-page loading shimmer */
.itr-reader__page--pending::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(100deg, #0d1526 30%, #16223b 50%, #0d1526 70%);
	background-size: 220% 100%;
	animation: itr-shimmer 1.3s linear infinite;
}

@keyframes itr-shimmer {
	from { background-position: 140% 0; }
	to   { background-position: -40% 0; }
}

/* Inner-gutter shading so the spread reads like a bound magazine */
.itr-reader__book .stf__item.--left  .itr-reader__page::before,
.itr-reader__book .stf__item.--right .itr-reader__page::before {
	content: "";
	position: absolute;
	inset-block: 0;
	width: 34px;
	pointer-events: none;
	z-index: 2;
}

.itr-reader__book .stf__item.--left .itr-reader__page::before {
	right: 0;
	background: linear-gradient(to right, transparent, rgba(0, 0, 0, .19));
}

.itr-reader__book .stf__item.--right .itr-reader__page::before {
	left: 0;
	background: linear-gradient(to left, transparent, rgba(0, 0, 0, .19));
}

/* ── Side navigation ───────────────────────────────────────── */

.itr-reader__nav {
	position: absolute;
	top: 50%;
	translate: 0 -50%;
	display: grid;
	place-items: center;
	width: 46px;
	height: 46px;
	border: 1px solid var(--glass-line);
	border-radius: 50%;
	background: rgba(6, 16, 36, .6);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	color: var(--text-dim);
	cursor: pointer;
	z-index: 20;
	transition: color .2s var(--ease), background .2s var(--ease),
	            transform .2s var(--ease), opacity .2s var(--ease);
}

.itr-reader__nav svg {
	width: 21px;
	height: 21px;
}

.itr-reader__nav:hover:not(:disabled) {
	color: #fff;
	background: rgba(56, 132, 245, .3);
	border-color: rgba(56, 132, 245, .5);
}

.itr-reader__nav:disabled {
	opacity: .22;
	cursor: default;
}

.itr-reader__nav--prev { left: 7px; }
.itr-reader__nav--next { right: 7px; }

/* Keep the nudge on `translate`, the same property the base rule centres with.
   `translate` and `transform` are separate properties that compose, so a
   translateY(-50%) here would stack on the base -50% and jump the button up by
   its own height on hover. */
.itr-reader__nav--prev:hover:not(:disabled) { translate: -2px -50%; }
.itr-reader__nav--next:hover:not(:disabled) { translate: 2px -50%; }

/* ── Loading ───────────────────────────────────────────────── */

.itr-reader__loading {
	position: absolute;
	inset: 0;
	display: grid;
	place-content: center;
	justify-items: center;
	gap: 20px;
	background: inherit;
	z-index: 25;
	transition: opacity .45s var(--ease), visibility .45s var(--ease);
}

.itr-reader__loading.is-done {
	opacity: 0;
	visibility: hidden;
}

.itr-reader__spinner {
	display: flex;
	gap: 6px;
}

.itr-reader__spinner span {
	width: 8px;
	height: 26px;
	border-radius: 2px;
	background: linear-gradient(180deg, var(--blue), var(--cyan));
	animation: itr-bars 1s var(--ease) infinite;
}

.itr-reader__spinner span:nth-child(2) { animation-delay: .12s; }
.itr-reader__spinner span:nth-child(3) { animation-delay: .24s; }

@keyframes itr-bars {
	0%, 100% { transform: scaleY(.45); opacity: .45; }
	50%      { transform: scaleY(1);   opacity: 1; }
}

.itr-reader__loadtext {
	margin: 0;
	font: 500 13.5px/1 inherit;
	letter-spacing: .02em;
	color: var(--text-dim);
}

.itr-reader__pct { margin-left: 6px; color: var(--text); }

.itr-reader__error {
	text-align: center;
	color: var(--text-dim);
}

.itr-reader__error h2 {
	color: var(--text);
	font: 600 20px/1.3 inherit;
	margin: 0 0 8px;
}

/* ── Toolbar ───────────────────────────────────────────────── */

.itr-reader__toolbar {
	flex: 0 0 var(--tool-h);
	display: flex;
	align-items: center;
	justify-content: center;
	gap: clamp(10px, 2.4vw, 30px);
	padding-inline: 16px;
	border-top: 1px solid rgba(255, 255, 255, .07);
	background: rgba(1, 6, 15, .78);
	backdrop-filter: blur(14px) saturate(140%);
	-webkit-backdrop-filter: blur(14px) saturate(140%);
	z-index: 30;
}

.itr-reader__tool {
	display: inline-grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border: 1px solid transparent;
	border-radius: 8px;
	background: none;
	color: var(--text-dim);
	cursor: pointer;
	transition: color .18s var(--ease), background .18s var(--ease), border-color .18s var(--ease);
}

.itr-reader__tool svg { width: 18px; height: 18px; }

.itr-reader__tool:hover:not(:disabled) {
	color: var(--text);
	background: var(--glass);
	border-color: var(--glass-line);
}

.itr-reader__tool:disabled { opacity: .25; cursor: default; }

.itr-reader__tool.is-active {
	color: #fff;
	background: rgba(56, 132, 245, .24);
	border-color: rgba(56, 132, 245, .42);
}

.itr-reader__pager,
.itr-reader__zoom {
	display: flex;
	align-items: center;
	gap: 4px;
}

.itr-reader__count {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding-inline: 8px;
	font: 500 13px/1 inherit;
	color: var(--text-dim);
	font-variant-numeric: tabular-nums;
}

.itr-reader__page-input {
	width: 42px;
	padding: 6px 4px;
	border: 1px solid var(--glass-line);
	border-radius: 6px;
	background: rgba(255, 255, 255, .05);
	color: var(--text);
	font: 500 13px/1 inherit;
	text-align: center;
	font-variant-numeric: tabular-nums;
	transition: border-color .18s var(--ease), background .18s var(--ease);
}

.itr-reader__page-input:focus {
	outline: none;
	border-color: rgba(56, 132, 245, .6);
	background: rgba(56, 132, 245, .12);
}

.itr-reader__of { opacity: .45; }

/* A <button> now — clicking the percentage resets to fit. Kept visually
   identical to the label it replaced; tabular-nums stops the number jittering
   as it counts through a pinch. */
.itr-reader__zoomlevel {
	min-width: 46px;
	text-align: center;
	font: 500 12.5px/1 inherit;
	color: var(--text-dim);
	font-variant-numeric: tabular-nums;
	border: 0;
	background: none;
	padding: 4px 2px;
	cursor: pointer;
}

.itr-reader__zoomlevel:hover { color: var(--text); }

/* ── Thumbnail drawer ──────────────────────────────────────── */

.itr-reader__thumbs {
	position: absolute;
	top: var(--bar-h);
	bottom: var(--tool-h);
	left: 0;
	width: min(230px, 76vw);
	display: flex;
	flex-direction: column;
	background: rgba(3, 10, 23, .93);
	backdrop-filter: blur(18px);
	-webkit-backdrop-filter: blur(18px);
	border-right: 1px solid rgba(255, 255, 255, .09);
	transform: translateX(-101%);
	transition: transform .38s var(--ease);
	z-index: 28;
}

.itr-reader__thumbs.is-open { transform: translateX(0); }

.itr-reader__thumbs-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 12px 14px 18px;
	border-bottom: 1px solid rgba(255, 255, 255, .07);
	font: 600 11px/1 inherit;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: var(--text-dim);
}

.itr-reader__thumbs-list {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 14px;
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 10px;
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, .18) transparent;
}

.itr-reader__thumbs-list::-webkit-scrollbar { width: 8px; }
.itr-reader__thumbs-list::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, .16);
	border-radius: 4px;
}

.itr-reader__thumb {
	position: relative;
	aspect-ratio: 3 / 4;
	border: 1.5px solid transparent;
	border-radius: 4px;
	overflow: hidden;
	background: #0d1526;
	cursor: pointer;
	padding: 0;
	transition: border-color .18s var(--ease), transform .18s var(--ease);
}

.itr-reader__thumb:hover { transform: translateY(-2px); }

.itr-reader__thumb.is-current {
	border-color: var(--blue);
	box-shadow: 0 0 0 2px rgba(56, 132, 245, .26);
}

.itr-reader__thumb canvas {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.itr-reader__thumb-num {
	position: absolute;
	bottom: 3px;
	right: 4px;
	padding: 1px 5px;
	border-radius: 3px;
	background: rgba(1, 6, 15, .82);
	font: 500 10px/1.5 inherit;
	color: var(--text-dim);
	font-variant-numeric: tabular-nums;
}

/* ── Toast ─────────────────────────────────────────────────── */

.itr-reader__toast {
	position: absolute;
	bottom: calc(var(--tool-h) + 18px);
	left: 50%;
	translate: -50% 0;
	padding: 10px 18px;
	border: 1px solid var(--glass-line);
	border-radius: 100px;
	background: rgba(6, 16, 36, .94);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	font: 500 13px/1 inherit;
	color: var(--text);
	opacity: 0;
	visibility: hidden;
	transform: translateY(8px);
	transition: opacity .26s var(--ease), transform .26s var(--ease), visibility .26s;
	z-index: 40;
	pointer-events: none;
}

.itr-reader__toast.is-visible {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

/* ── Mobile ────────────────────────────────────────────────── */

/* ── Single / two-up toggle ────────────────────────────────────
   The button shows what you are looking at now: one sheet in single view, two
   in spread. Only one of the two icons is ever rendered. */

.itr-reader__view .itr-reader__view-spread { display: none; }
.itr-reader__view.is-spread .itr-reader__view-single { display: none; }
.itr-reader__view.is-spread .itr-reader__view-spread { display: block; }
.itr-reader__view.is-spread { color: var(--blue); }

/* ── Reset-to-fit pill ─────────────────────────────────────────
   Only exists while zoomed. On a phone the zoom cluster is hidden, so without
   this there is no way back to a fitted page except pinching all the way down.
   Sits above the toolbar and clear of the home indicator. */

.itr-reader__zoom-reset {
	position: absolute;
	left: 50%;
	bottom: calc(var(--tool-h) + 14px + env(safe-area-inset-bottom, 0px));
	translate: -50% 0;
	z-index: 30;

	display: none;
	align-items: center;
	gap: 7px;
	padding: 9px 15px 9px 12px;

	font: 600 12.5px/1 plex-sans, "IBM Plex Sans", system-ui, sans-serif;
	letter-spacing: .04em;
	color: var(--text);
	background: rgba(6, 16, 36, .82);
	border: 1px solid var(--glass-line);
	border-radius: 999px;
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	box-shadow: 0 8px 26px rgba(0, 0, 0, .45);
	cursor: pointer;
	animation: itr-pill-in .22s var(--ease) both;
}

/* The stage is an earlier sibling of the pill, so its state drives it. */
.itr-reader__stage.is-zoomed ~ .itr-reader__zoom-reset { display: flex; }

.itr-reader__zoom-reset svg { width: 15px; height: 15px; }

@keyframes itr-pill-in {
	from { opacity: 0; translate: -50% 8px; }
	to   { opacity: 1; translate: -50% 0; }
}

@media (max-width: 768px) {
	.itr-reader {
		--bar-h: 56px;
		--tool-h: 56px;
	}

	.itr-reader__stage {
		padding: 6px 8px;
	}

	.itr-reader__back span { display: none; }
	.itr-reader__back { padding: 8px; }

	.itr-reader__title {
		font-size: 13.5px;
		max-width: 46vw;
	}

	/* On-screen arrows get in the way of swiping — hide them */
	.itr-reader__nav { display: none; }

	.itr-reader__toolbar { gap: 8px; }

	/* The zoom cluster costs more width than it earns on a phone: pinch and
	   double-tap do the zooming, and the Fit pill does the resetting. */
	.itr-reader__zoom { display: none; }

	.itr-reader__thumbs-list { grid-template-columns: repeat(3, 1fr); }

	/* Notches and home indicators — keep the chrome out from under them. */
	.itr-reader__bar {
		padding-left:  max(12px, env(safe-area-inset-left));
		padding-right: max(12px, env(safe-area-inset-right));
	}

	.itr-reader__toolbar {
		padding-bottom: env(safe-area-inset-bottom, 0px);
		height: calc(var(--tool-h) + env(safe-area-inset-bottom, 0px));
	}

	/* Give the page itself as much of the screen as possible — on a phone the
	   magazine is the whole point and every pixel of margin is wasted. */
	.itr-reader__stage { padding: 4px 4px; }

	/* Touch targets: 44px is the floor for a comfortable tap. */
	.itr-reader__tool,
	.itr-reader__iconbtn {
		min-width: 44px;
		min-height: 44px;
	}

	.itr-reader__zoom-reset {
		bottom: calc(var(--tool-h) + 12px + env(safe-area-inset-bottom, 0px));
		padding: 10px 17px 10px 14px;
		font-size: 13px;
	}
}

/* Landscape phones are all width and no height — the toolbar and bar eat the
   page, so tighten them and let the spread breathe. */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 480px) {
	.itr-reader {
		--bar-h: 44px;
		--tool-h: 46px;
	}
	.itr-reader__stage { padding: 2px 4px; }
	.itr-reader__title { max-width: 40vw; font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
	.itr-reader *,
	.itr-reader *::before,
	.itr-reader *::after {
		animation-duration: .01ms !important;
		transition-duration: .01ms !important;
	}
}
