/*
 * Comic components: panel, caption, speech bubble, sound effect, burst, halftone, sunburst,
 * phone, chat, notification, sticker. Everything here is code; only the people are pictures.
 *
 * Panels are size containers, so text inside them scales with the panel (cqi units).
 */

/* ---------- Panel ---------- */

.jb-panel {
	--panel-bg: var(--jb-white);
	container-type: inline-size;
	position: relative;
	background: var(--panel-bg);
	border: var(--jb-border);
	box-shadow: var(--jb-shadow);
	overflow: hidden;
	isolation: isolate;
}
.jb-panel__art {
	position: relative;
	width: 100%;
	height: 100%;
	aspect-ratio: var(--ratio, auto);
}
.jb-panel__art img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: var(--pos, 50% 50%);
}

/* Newsprint: the "before" pages. Same pictures, faded and dotted. */
.is-news .jb-panel { --panel-bg: var(--jb-aged); }
.is-news .jb-panel__art img { filter: sepia(0.55) saturate(0.5) contrast(0.92) brightness(1.03); }
.is-news .jb-panel__art::after {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: radial-gradient(circle, rgba(58, 58, 58, 0.22) 0.9px, transparent 1.3px) 0 0 / 5px 5px;
	mix-blend-mode: multiply;
}

/* ---------- Caption box ---------- */

.jb-caption {
	position: absolute;
	z-index: 3;
	top: 0;
	left: 0;
	max-width: 62%;
	padding: 0.45em 0.75em;
	background: var(--jb-yellow);
	border-right: 3px solid var(--jb-ink);
	border-bottom: 3px solid var(--jb-ink);
	font-family: var(--jb-font-comic);
	font-weight: 700;
	font-size: clamp(0.875rem, 2.6cqi, 1.125rem);
	line-height: 1.2;
	text-transform: uppercase;
}
.is-news .jb-caption { background: var(--jb-aged); color: var(--jb-faded-ink); }
.jb-caption--bottom { top: auto; bottom: 0; left: auto; right: 0; border: 0; border-left: 3px solid var(--jb-ink); border-top: 3px solid var(--jb-ink); }
.jb-caption--static { position: static; display: inline-block; max-width: none; border: 3px solid var(--jb-ink); }

/* ---------- Speech bubble ---------- */

.jb-bubble {
	--tx: 28%;
	position: absolute;
	z-index: 4;
	max-width: var(--w, 46%);
	padding: 0.7em 1em;
	background: var(--jb-white);
	color: var(--jb-ink);
	border: 3px solid var(--jb-ink);
	border-radius: 1.4em;
	font-family: var(--jb-font-comic);
	font-weight: 700;
	font-size: clamp(0.95rem, 3.4cqi, 1.45rem);
	line-height: 1.15;
	text-transform: uppercase;
	text-align: center;
	text-wrap: balance;
}
/* Tail: an ink triangle with a white one inside */
.jb-bubble::before,
.jb-bubble::after {
	content: "";
	position: absolute;
	top: 100%;
	width: 0;
	height: 0;
	border-style: solid;
	border-color: var(--jb-ink) transparent transparent transparent;
}
.jb-bubble::before { left: var(--tx); border-width: 1.3em 0.9em 0 0; }
.jb-bubble::after { left: calc(var(--tx) + 3px); margin-top: -4px; border-width: 0.95em 0.62em 0 0; border-top-color: var(--jb-white); }
.jb-bubble--tail-right::before { left: auto; right: var(--tx); border-width: 1.3em 0 0 0.9em; }
.jb-bubble--tail-right::after { left: auto; right: calc(var(--tx) + 3px); border-width: 0.95em 0 0 0.62em; }
.jb-bubble--no-tail::before, .jb-bubble--no-tail::after { display: none; }
.jb-bubble--static { position: relative; display: inline-block; max-width: 100%; }

/* Text set inside a bubble already printed in the picture */
.jb-bubble--printed {
	background: none;
	border: 0;
	padding: 0;
	display: grid;
	place-items: center;
	font-size: clamp(0.85rem, 3.3cqi, 1.5rem);
}
.jb-bubble--printed::before, .jb-bubble--printed::after { display: none; }

/* ---------- Sound effect ---------- */

.jb-sfx {
	position: absolute;
	z-index: 5;
	font-family: var(--jb-font-sfx);
	font-size: var(--size, clamp(2.4rem, 11cqi, 6rem));
	line-height: 0.9;
	letter-spacing: 0.03em;
	color: var(--sfx, var(--jb-yellow));
	-webkit-text-stroke: 0.07em var(--jb-ink);
	paint-order: stroke fill;
	text-shadow: 0.06em 0.06em 0 var(--jb-ink);
	transform: rotate(var(--rot, -8deg));
	white-space: nowrap;
	pointer-events: none;
}
.jb-sfx--red { --sfx: var(--jb-red); }
.jb-sfx--pink { --sfx: var(--jb-pink); }
.jb-sfx--cyan { --sfx: var(--jb-cyan); }
.jb-sfx--white { --sfx: var(--jb-white); }

/* ---------- Burst (starburst with text) ---------- */

.jb-burst {
	position: relative;
	display: grid;
	place-items: center;
	width: var(--size, 9rem);
	aspect-ratio: 1;
	transform: rotate(var(--rot, -10deg));
	text-align: center;
}
.jb-burst svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.jb-burst polygon { fill: var(--burst, var(--jb-red)); stroke: var(--jb-ink); stroke-width: 3; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.jb-burst__text {
	position: relative;
	font-family: var(--jb-font-sfx);
	font-size: calc(var(--size, 9rem) * 0.22);
	max-width: 64%;
	line-height: 0.9;
	letter-spacing: 0.03em;
	color: var(--burst-text, var(--jb-white));
}
.jb-burst__text small { display: block; font-size: 0.6em; letter-spacing: 0.08em; }
.jb-burst--yellow { --burst: var(--jb-yellow); --burst-text: var(--jb-ink); }

/* ---------- Backgrounds ---------- */

.jb-halftone {
	background-image: radial-gradient(circle, var(--dot, rgba(17, 17, 17, 0.16)) 1.4px, transparent 1.9px);
	background-size: 12px 12px;
}
.jb-sunburst {
	background: repeating-conic-gradient(from 0deg at var(--sx, 50%) var(--sy, 50%), var(--ray-a, var(--jb-yellow)) 0deg 9deg, var(--ray-b, #FFE45C) 9deg 18deg);
}

/* ---------- Phone ---------- */

.jb-phone {
	--w: 230px;
	position: relative;
	width: var(--w);
	aspect-ratio: 9 / 18.5;
	padding: 7px;
	background: var(--jb-ink);
	border: 3px solid var(--jb-ink);
	border-radius: calc(var(--w) * 0.14);
	box-shadow: 5px 5px 0 rgba(17, 17, 17, 0.35);
}
.jb-phone::before {
	content: "";
	position: absolute;
	z-index: 2;
	top: 11px;
	left: 50%;
	width: 26%;
	height: 4.5%;
	transform: translateX(-50%);
	background: var(--jb-ink);
	border-radius: 999px;
}
.jb-phone__screen {
	container-type: inline-size;
	position: relative;
	height: 100%;
	overflow: hidden;
	background: var(--jb-white);
	border-radius: calc(var(--w) * 0.11);
}

/* "Not secure" warning laid over the old site */
.jb-warning {
	position: absolute;
	z-index: 3;
	inset: auto 6% 22% 6%;
	padding: 7cqi 6cqi;
	background: var(--jb-white);
	border: 2px solid var(--jb-ink);
	border-radius: 5cqi;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
	font-family: var(--jb-font-text);
	font-size: 6.4cqi;
	line-height: 1.3;
	text-align: center;
}
.jb-warning strong { display: block; margin-top: 2cqi; font-size: 8.5cqi; color: var(--jb-red); }
.jb-warning svg { width: 18cqi; margin: 0 auto; }

/* ---------- Chat (text messages) ---------- */

.jb-chat {
	display: flex;
	flex-direction: column;
	gap: 3cqi;
	height: 100%;
	padding: 27cqi 5cqi 6cqi;
	background: #F2F2F5;
	font-family: var(--jb-font-text);
	font-size: 6.2cqi;
	line-height: 1.3;
}
.jb-chat__head {
	position: absolute;
	top: 0; left: 0; right: 0;
	padding: 15cqi 4cqi 3cqi;
	background: rgba(255, 255, 255, 0.92);
	border-bottom: 1px solid rgba(17, 17, 17, 0.1);
	text-align: center;
	font-weight: 600;
	font-size: 5.6cqi;
}
.jb-chat__msg {
	max-width: 84%;
	padding: 3cqi 4.4cqi;
	border-radius: 5cqi;
	background: var(--jb-white);
	align-self: flex-start;
}
.jb-chat__msg--me { align-self: flex-end; background: #1D7BF2; color: var(--jb-white); }

/* ---------- Notification ---------- */

.jb-toast {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 0.15rem 0.6rem;
	align-items: center;
	width: min(100%, 17rem);
	padding: 0.6rem 0.8rem;
	background: rgba(255, 255, 255, 0.97);
	border: 3px solid var(--jb-ink);
	border-radius: 14px;
	box-shadow: 4px 4px 0 var(--jb-ink);
	font-size: clamp(0.8125rem, 2.4cqi, 0.9375rem);
	line-height: 1.25;
}
.jb-toast i {
	grid-row: span 2;
	width: 2rem;
	height: 2rem;
	border-radius: 8px;
	background: var(--jb-red);
	box-shadow: inset 0 -0.45rem 0 var(--jb-yellow);
}
.jb-toast b { font-weight: 700; }
.jb-toast span { color: var(--jb-muted); }

/* ---------- Sticker ---------- */

.jb-sticker {
	display: inline-block;
	padding: 0.25rem 0.6rem 0.15rem;
	background: var(--jb-red);
	color: var(--jb-white);
	border: 3px solid var(--jb-ink);
	font-family: var(--jb-font-sfx);
	font-size: 1.15rem;
	letter-spacing: 0.06em;
	line-height: 1;
	transform: rotate(var(--rot, -4deg));
}
.jb-sticker--yellow { background: var(--jb-yellow); color: var(--jb-ink); }

/* Section label in comic lettering, e.g. "PAGE 1 · THE WHISPER" */
.jb-label {
	display: inline-flex;
	align-items: center;
	gap: 0.6rem;
	font-family: var(--jb-font-sfx);
	font-size: clamp(1.1rem, 0.9rem + 0.8vw, 1.6rem);
	letter-spacing: 0.06em;
	line-height: 1;
}
.jb-label b {
	font-weight: 400;
	padding: 0.25rem 0.55rem 0.15rem;
	background: var(--jb-ink);
	color: var(--jb-yellow);
}
