/* Titan Feed for Instagram
 * Every visual property reads from a CSS variable with an "inherit" fallback,
 * so the feed takes on the theme's fonts and colours unless told otherwise.
 */

.titan-feed {
	--tf-cols: 3;
	--tf-cols-tablet: 3;
	--tf-cols-mobile: 2;
	--tf-gap: 8px;
	--tf-radius: 0px;
	--tf-bg: transparent;
	--tf-text: inherit;
	--tf-accent: currentColor;
	--tf-overlay: rgba(0, 0, 0, 0.55);
	--tf-button: transparent;
	--tf-button-text: inherit;
	--tf-font: inherit;
	--tf-size: 0.9em;
	--tf-header-size: 1.1em;

	box-sizing: border-box;
	background: var(--tf-bg);
	color: var(--tf-text);
	font-family: var(--tf-font);
	line-height: 1.45;
	max-width: 100%;
}
.titan-feed *,
.titan-feed *::before,
.titan-feed *::after {
	box-sizing: inherit;
}
.titan-feed img {
	display: block;
	max-width: 100%;
	height: auto;
	border: 0;
}
.titan-feed a {
	text-decoration: none;
	color: inherit;
}

/* Header ------------------------------------------------------------- */
.titan-feed__header {
	margin-bottom: calc(var(--tf-gap) * 2);
}
.titan-feed__profile {
	display: inline-flex;
	align-items: center;
	gap: 14px;
}
.titan-feed__avatar {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	object-fit: cover;
	flex: none;
}
.titan-feed__avatar--icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid currentColor;
	opacity: 0.7;
}
.titan-feed__avatar--icon svg {
	width: 26px;
	height: 26px;
}
.titan-feed__meta {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}
.titan-feed__name {
	font-size: var(--tf-header-size);
	font-weight: 600;
}
.titan-feed__handle {
	font-size: var(--tf-size);
	opacity: 0.7;
}
.titan-feed__counts {
	display: flex;
	gap: 14px;
	font-size: calc(var(--tf-size) * 0.95);
	opacity: 0.85;
}

/* Items --------------------------------------------------------------- */
.titan-feed__items {
	display: grid;
	gap: var(--tf-gap);
	grid-template-columns: repeat(var(--tf-cols), minmax(0, 1fr));
}
.titan-feed__item {
	display: block;
	position: relative;
	min-width: 0;
	color: inherit;
}
.titan-feed__media {
	display: block;
	position: relative;
	overflow: hidden;
	border-radius: var(--tf-radius);
	background: rgba(127, 127, 127, 0.08);
}
.titan-feed__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.titan-feed--aspect-square .titan-feed__media { aspect-ratio: 1 / 1; }
.titan-feed--aspect-portrait .titan-feed__media { aspect-ratio: 4 / 5; }
.titan-feed--aspect-landscape .titan-feed__media { aspect-ratio: 16 / 9; }
.titan-feed--aspect-original .titan-feed__media img { height: auto; }

.titan-feed__badge {
	position: absolute;
	top: 8px;
	right: 8px;
	display: inline-flex;
	color: #fff;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
	pointer-events: none;
}

/* Hover */
.titan-feed--hover-zoom .titan-feed__item:hover .titan-feed__media img,
.titan-feed--hover-zoom .titan-feed__item:focus-visible .titan-feed__media img {
	transform: scale(1.05);
}
.titan-feed__overlay {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 12px;
	text-align: center;
	color: #fff;
	background: var(--tf-overlay);
	opacity: 0;
	transition: opacity 0.25s ease;
}
.titan-feed__overlay .titan-feed__icon {
	width: 26px;
	height: 26px;
}
.titan-feed__overlay-text {
	font-size: var(--tf-size);
	line-height: 1.35;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.titan-feed__item:hover .titan-feed__overlay,
.titan-feed__item:focus-visible .titan-feed__overlay {
	opacity: 1;
}
.titan-feed__item:focus-visible {
	outline: 2px solid var(--tf-accent);
	outline-offset: 2px;
}

/* Captions */
.titan-feed__caption {
	display: block;
	margin-top: 8px;
	font-size: var(--tf-size);
}
.titan-feed__date {
	display: block;
	margin-top: 4px;
	opacity: 0.6;
	font-size: 0.85em;
}

/* Masonry ------------------------------------------------------------- */
.titan-feed--masonry .titan-feed__items {
	display: block;
	column-count: var(--tf-cols);
	column-gap: var(--tf-gap);
}
.titan-feed--masonry .titan-feed__item {
	break-inside: avoid;
	margin-bottom: var(--tf-gap);
}
.titan-feed--masonry .titan-feed__media {
	aspect-ratio: auto;
}
.titan-feed--masonry .titan-feed__media img {
	height: auto;
}

/* List ---------------------------------------------------------------- */
.titan-feed--list .titan-feed__items {
	grid-template-columns: 1fr;
	gap: calc(var(--tf-gap) * 2);
}
.titan-feed--list .titan-feed__item {
	display: grid;
	grid-template-columns: minmax(120px, 30%) 1fr;
	gap: calc(var(--tf-gap) * 2);
	align-items: start;
}
.titan-feed--list .titan-feed__caption {
	margin-top: 0;
	white-space: pre-line;
}

/* Highlight ----------------------------------------------------------- */
.titan-feed--highlight .titan-feed__items {
	grid-template-columns: repeat(var(--tf-cols), minmax(0, 1fr));
}
.titan-feed--highlight .titan-feed__item--featured {
	grid-column: 1 / -1;
}
.titan-feed--highlight .titan-feed__item--featured .titan-feed__media {
	aspect-ratio: 16 / 9;
}

/* Carousel ------------------------------------------------------------ */
.titan-feed__carousel {
	position: relative;
}
.titan-feed__track {
	display: flex;
	gap: var(--tf-gap);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}
.titan-feed__track::-webkit-scrollbar {
	display: none;
}
.titan-feed__track .titan-feed__item {
	flex: 0 0 calc((100% - (var(--tf-cols) - 1) * var(--tf-gap)) / var(--tf-cols));
	scroll-snap-align: start;
}
.titan-feed__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: 0;
	background: rgba(255, 255, 255, 0.92);
	color: #111;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 0 3px;
	z-index: 2;
	transition: opacity 0.2s;
}
.titan-feed__nav--prev { left: -12px; }
.titan-feed__nav--next { right: -12px; }
.titan-feed__nav[disabled] {
	opacity: 0;
	pointer-events: none;
}

/* Footer -------------------------------------------------------------- */
.titan-feed__footer {
	margin-top: calc(var(--tf-gap) * 2);
	text-align: center;
}
.titan-feed__follow {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 0.65em 1.4em;
	border: 1px solid currentColor;
	border-radius: var(--tf-radius);
	background: var(--tf-button);
	color: var(--tf-button-text);
	font-size: var(--tf-size);
	font-weight: 500;
	transition: opacity 0.2s;
}
.titan-feed__follow:hover {
	opacity: 0.8;
}
.titan-feed__follow .titan-feed__icon {
	color: var(--tf-accent);
}

/* Notice (admins only) ------------------------------------------------ */
.titan-feed--notice {
	padding: 12px 16px;
	border-left: 3px solid #d63638;
	background: rgba(214, 54, 56, 0.06);
	font-size: 0.9em;
}

/* Responsive ---------------------------------------------------------- */
@media (max-width: 1024px) {
	.titan-feed { --tf-cols: var(--tf-cols-tablet); }
}
@media (max-width: 640px) {
	.titan-feed { --tf-cols: var(--tf-cols-mobile); }
	.titan-feed--list .titan-feed__item {
		grid-template-columns: 1fr;
	}
	.titan-feed__nav--prev { left: 4px; }
	.titan-feed__nav--next { right: 4px; }
}

/* Lightbox ------------------------------------------------------------ */
.titan-lightbox {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(0, 0, 0, 0.88);
	opacity: 0;
	transition: opacity 0.2s ease;
}
.titan-lightbox.is-open {
	opacity: 1;
}
.titan-lightbox__dialog {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 340px;
	max-width: 1100px;
	width: 100%;
	max-height: 90vh;
	background: #fff;
	color: #111;
	border-radius: 6px;
	overflow: hidden;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.titan-lightbox__media {
	position: relative;
	background: #000;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 320px;
}
.titan-lightbox__media img,
.titan-lightbox__media video {
	max-width: 100%;
	max-height: 90vh;
	width: auto;
	height: auto;
	display: block;
}
.titan-lightbox__side {
	display: flex;
	flex-direction: column;
	padding: 20px;
	overflow-y: auto;
	font-size: 14px;
	line-height: 1.5;
}
.titan-lightbox__caption {
	white-space: pre-line;
	word-wrap: break-word;
	flex: 1;
}
.titan-lightbox__date {
	margin-top: 12px;
	color: #777;
	font-size: 12px;
}
.titan-lightbox__link {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin-top: 16px;
	font-weight: 600;
	color: #111;
	text-decoration: none;
}
.titan-lightbox__btn {
	position: absolute;
	border: 0;
	background: rgba(255, 255, 255, 0.9);
	color: #111;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	cursor: pointer;
	font-size: 24px;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 2;
}
.titan-lightbox__close {
	top: 16px;
	right: 16px;
	position: fixed;
}
.titan-lightbox__prev,
.titan-lightbox__next {
	top: 50%;
	transform: translateY(-50%);
	padding-bottom: 3px;
}
.titan-lightbox__prev { left: 12px; }
.titan-lightbox__next { right: 12px; }
.titan-lightbox__btn[disabled] {
	opacity: 0.25;
	pointer-events: none;
}
.titan-lightbox__dots {
	position: absolute;
	bottom: 12px;
	left: 0;
	right: 0;
	display: flex;
	justify-content: center;
	gap: 6px;
}
.titan-lightbox__dots i {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.5);
}
.titan-lightbox__dots i.is-active {
	background: #fff;
}
@media (max-width: 800px) {
	.titan-lightbox {
		padding: 0;
	}
	.titan-lightbox__dialog {
		grid-template-columns: 1fr;
		grid-template-rows: auto minmax(0, 1fr);
		max-height: 100vh;
		height: 100vh;
		border-radius: 0;
	}
	.titan-lightbox__media img,
	.titan-lightbox__media video {
		max-height: 60vh;
	}
}
@media (prefers-reduced-motion: reduce) {
	.titan-feed *,
	.titan-lightbox {
		transition: none !important;
	}
}
