/**
 * Story rail and portalled fullscreen viewer.
 */

body.story-modal-open {
	overflow: hidden;
}

.portal-stories {
	padding: clamp(14px, 2vw, 18px);
	border-radius: 18px;
	box-shadow: var(--portal-shadow);
}

.portal-stories-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 14px;
}

.story-kicker {
	color: var(--portal-blue);
	font-size: .67rem;
	font-weight: 800;
	letter-spacing: .12em;
	text-transform: uppercase;
}

.portal-stories-header h2 {
	margin: 2px 0 0;
	color: var(--portal-ink);
	font-size: 1.05rem;
}

.story-rail-buttons {
	display: none;
	gap: 6px;
}

.story-rail-buttons button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 35px;
	height: 35px;
	background: #f1f6ff;
	border: 1px solid #e1eafa;
	border-radius: 50%;
	color: var(--portal-blue);
	font-size: 1.45rem;
}

.portal-story-rail {
	display: flex;
	gap: clamp(13px, 2.4vw, 24px);
	overflow-x: auto;
	padding: 2px 2px 5px;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
}

.portal-story-rail::-webkit-scrollbar {
	display: none;
}

.portal-story-tile {
	flex: 0 0 78px;
	min-width: 0;
	padding: 0;
	background: transparent;
	border: 0;
	color: #142440;
	text-align: center;
	scroll-snap-align: start;
}

.portal-story-ring {
	position: relative;
	display: block;
	width: 70px;
	height: 70px;
	margin: 0 auto 8px;
	padding: 3px;
	background: linear-gradient(145deg, #155eef 0%, #6b42ff 50%, #f97316 100%);
	border-radius: 50%;
	box-shadow: 0 5px 13px rgba(21, 94, 239, .2);
}

.portal-story-ring img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border: 2px solid #fff;
	border-radius: 50%;
}

.story-category-icon {
	position: absolute;
	right: 1px;
	bottom: 1px;
	display: grid;
	place-items: center;
	width: 18px;
	height: 18px;
	background: var(--portal-blue);
	border: 2px solid #fff;
	border-radius: 50%;
	color: #fff;
	font-size: .5rem;
}

.portal-story-tile strong {
	display: -webkit-box;
	overflow: hidden;
	font-size: .71rem;
	line-height: 1.3;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}

.portal-story-modal {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 18px;
	background: rgba(2, 8, 20, .84);
	backdrop-filter: blur(16px);
}

.portal-story-modal[hidden] {
	display: none;
}

.portal-story-viewer {
	position: relative;
	overflow: hidden;
	width: min(420px, calc(100vw - 36px));
	height: min(746px, calc(100dvh - 36px));
	aspect-ratio: 9 / 16;
	background: #071124;
	border-radius: 22px;
	box-shadow: 0 28px 80px rgba(0, 0, 0, .45);
}

.portal-story-progress {
	position: absolute;
	top: max(15px, env(safe-area-inset-top));
	right: 15px;
	left: 15px;
	z-index: 5;
	display: flex;
	gap: 4px;
}

.portal-story-progress span {
	flex: 1;
	height: 3px;
	overflow: hidden;
	background: rgba(255, 255, 255, .35);
	border-radius: 4px;
}

.portal-story-progress i {
	display: block;
	width: 0;
	height: 100%;
	background: #fff;
}

.portal-story-progress .is-complete i {
	width: 100%;
}

.portal-story-progress .is-active i {
	animation: portal-story-timer var(--story-duration, 6000ms) linear forwards;
}

@keyframes portal-story-timer {
	to { width: 100%; }
}

.portal-story-close {
	position: absolute;
	top: max(29px, calc(env(safe-area-inset-top) + 13px));
	right: 16px;
	z-index: 7;
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	background: rgba(7, 17, 36, .48);
	border: 1px solid rgba(255, 255, 255, .2);
	border-radius: 50%;
	color: #fff;
	font-size: 1.55rem;
}

.portal-story-frame,
.portal-story-photo,
.portal-story-photo img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

.portal-story-photo img {
	object-fit: cover;
}

.portal-story-frame::after {
	position: absolute;
	inset: 24% 0 0;
	background: linear-gradient(transparent, rgba(3, 9, 22, .93));
	content: "";
}

.portal-story-copy {
	position: absolute;
	right: 24px;
	bottom: max(26px, env(safe-area-inset-bottom));
	left: 24px;
	z-index: 4;
	color: #fff;
}

.portal-story-copy h3 {
	margin: 10px 0 8px;
	color: #fff;
	font-size: clamp(1.32rem, 4vw, 1.62rem);
	line-height: 1.2;
}

.portal-story-copy p {
	margin: 0 0 17px;
	color: rgba(255, 255, 255, .82);
	font-size: .87rem;
	line-height: 1.5;
}

.portal-story-copy a {
	display: inline-flex;
	padding: 11px 17px;
	background: #fff;
	border-radius: 10px;
	color: var(--portal-blue-deep);
	font-weight: 700;
}

.portal-story-zone {
	position: absolute;
	top: 80px;
	bottom: 100px;
	z-index: 3;
	width: 30%;
	background: transparent;
	border: 0;
}

.portal-story-zone-prev {
	left: 0;
}

.portal-story-zone-next {
	right: 0;
}

@media (min-width: 760px) {
	.story-rail-buttons {
		display: flex;
	}
}

@media (max-width: 559px) {
	.portal-story-modal {
		padding: 0;
	}

	.portal-story-viewer {
		width: 100vw;
		height: 100dvh;
		max-height: none;
		border-radius: 0;
	}
}

.atlas-dark .portal-stories-header h2,
.atlas-dark .portal-story-tile {
	color: #eef4ff;
}
