/* ================================================================
   Spiderpiggy / Lucid Lime - cBB Attachments
   A complete, style-specific replacement for all/theme/attachments.css
   phpBB 3.3.x | CaniDev Attachments | 12 November 2026

   Original CaniDev template structure and download links are retained.
   No template, PHP, JavaScript, or extension-core changes are required.
   ================================================================ */

/* ---- Fundamentals shared by all attachment formats --------------- */

.attachbox dd:has(.attachment-preview.bordered):not(:first-of-type) {
	border-top: 0;
}

.attachment-preview,
.attachment-preview * {
	box-sizing: border-box;
}

.attachment-preview {
	width: 100%;
	max-width: 100%;
	min-width: 0;
	margin: 0;
	padding: 8px;
	border-radius: 14px;
}

/* Avoid the original phpBB frame creating a box inside another box.
   This touches only attachments rendered by cBB Attachments. */
dl.attachbox:has(.attachment-preview) {
	width: 100%;
	max-width: 100%;
	float: none;
	margin: 16px 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
}

dl.attachbox:has(.attachment-preview) > dd {
	margin: 0;
	padding: 0;
	border-top: 0;
}

/* ---- One modern Spiderpiggy download card ------------------------ */

.attachment-preview.bordered {
	--sp-attach-accent: var(--lucid-sp-accent, #e66aa4);
	--sp-attach-bright: var(--lucid-sp-accent-bright, #ffb0d3);

	position: relative;
	isolation: isolate;
	min-width: 0;
	padding: 11px 12px;
	border: 1px solid color-mix(in srgb, var(--sp-attach-accent) 49%, #404653);
	border-radius: 16px;
	background:
		radial-gradient(ellipse at 5% 0%, color-mix(in srgb, var(--sp-attach-accent) 12%, transparent), transparent 50%),
		linear-gradient(125deg, #232630 0%, #1b2029 60%, #191d26 100%);
	color: #e3e8f0;
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, .045),
		0 6px 18px rgba(0, 0, 0, .17);
	transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.attachment-preview.bordered:hover {
	border-color: color-mix(in srgb, var(--sp-attach-accent) 70%, #656070);
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, .055),
		0 7px 20px rgba(0, 0, 0, .20),
		0 0 14px color-mix(in srgb, var(--sp-attach-accent) 9%, transparent);
}

/* A tiny highlight on the top edge, not a glaring double border. */
.attachment-preview.bordered::before {
	content: "";
	position: absolute;
	top: -1px;
	left: 15px;
	width: min(110px, 38%);
	height: 2px;
	border-radius: 999px;
	background: linear-gradient(90deg, var(--sp-attach-accent), transparent);
	pointer-events: none;
}

/* The subtle Spiderpiggy signature: purely decorative, no new markup. */
.attachment-preview.bordered::after {
	content: "🐷";
	position: absolute;
	z-index: 2;
	top: -12px;
	right: 17px;
	display: grid;
	place-items: center;
	width: 27px;
	height: 23px;
	border: 1px solid color-mix(in srgb, var(--sp-attach-accent) 50%, #343541);
	border-radius: 9px;
	background: #23202b;
	font: 14px/1 "Segoe UI Emoji", "Apple Color Emoji", sans-serif;
	box-shadow: 0 3px 7px rgba(0, 0, 0, .23);
	pointer-events: none;
}

/* File name, icon and download action: one balanced horizontal row. */
.attachment-preview .file-info {
	display: flex;
	align-items: center;
	gap: 13px;
	width: 100%;
	min-width: 0;
	margin: 0;
	padding: 8px;
	border: 1px solid rgba(255, 255, 255, .045);
	border-radius: 12px;
	background: rgba(255, 255, 255, .022);
	color: #e3e8f0;
	font-size: 13px;
	line-height: 1.4;
	text-align: start;
}

.attachment-preview .file-info:not(:last-child) {
	margin-bottom: 8px;
}

/* ZIP, RAR, PDF, image and audio preview tiles. */
.attachment-preview .picture {
	display: flex;
	flex: 0 0 64px;
	align-items: center;
	justify-content: center;
	width: 64px;
	height: 64px;
	min-width: 0;
	padding: 5px;
	border: 1px solid color-mix(in srgb, var(--lucid-sp-accent, #e66aa4) 31%, #3a3645);
	border-radius: 12px;
	background: linear-gradient(150deg, #32212e, #241e2a);
	overflow: hidden;
}

.attachment-preview .picture img {
	display: block;
	width: auto;
	max-width: 100%;
	height: auto;
	max-height: 100%;
	object-fit: contain;
}

.attachment-preview .picture.iconic img {
	width: auto;
	max-width: 100%;
	height: auto;
	max-height: 52px;
}

.attachment-preview .default-picture {
	width: 36px;
	height: 42px;
	border: 2px solid color-mix(in srgb, var(--lucid-sp-accent, #e66aa4) 62%, white);
	border-radius: 6px;
	background: linear-gradient(135deg, rgba(230, 106, 164, .20), rgba(230, 106, 164, .04));
}

.attachment-preview .id3-tags {
	flex: 1 1 auto;
	min-width: 0;
	max-width: 100%;
}

.attachment-preview .id3-title,
.attachment-preview .id3-title a {
	color: var(--lucid-sp-accent-bright, #ffb0d3);
	font-size: 15px;
	font-weight: 700;
	line-height: 1.35;
	text-decoration: none;
	text-shadow: none;
	white-space: normal;
	overflow-wrap: anywhere;
}

.attachment-preview .id3-title a:hover {
	color: #fff0f7;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.attachment-preview .id3-artist {
	margin-top: 2px;
	color: #cbd2df;
}

.attachment-preview .id3-info {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 3px 10px;
	margin-top: 6px;
	color: #acb6c5;
	font-size: 12px;
	line-height: 1.35;
}

.attachment-preview .id3-info span {
	display: inline;
	white-space: normal;
}

.attachment-preview .id3-info .fa {
	color: var(--lucid-sp-accent, #e66aa4);
	font-size: 1.1em;
}

/* Compact, unmistakable download control. */
.attachment-preview .download-button {
	flex: 0 0 auto;
	margin-left: auto;
	padding: 0;
	font-size: 19px;
}

.attachment-preview .download-button a,
.attachment-preview .download-button a:visited {
	display: grid;
	place-items: center;
	width: 43px;
	height: 43px;
	padding: 0;
	border: 1px solid color-mix(in srgb, var(--lucid-sp-accent, #e66aa4) 76%, #ffffff);
	border-radius: 13px;
	background: linear-gradient(145deg,
		color-mix(in srgb, var(--lucid-sp-accent, #e66aa4) 84%, #ffffff),
		var(--lucid-sp-accent, #e66aa4));
	color: #2a1924;
	font-size: 20px;
	line-height: 1;
	text-decoration: none;
	text-shadow: none;
	box-shadow: 0 3px 11px color-mix(in srgb, var(--lucid-sp-accent, #e66aa4) 13%, transparent);
	transition: transform .18s ease, filter .18s ease, box-shadow .18s ease;
}

.attachment-preview .download-button a:hover {
	transform: translateY(-2px);
	filter: brightness(1.08);
	box-shadow: 0 6px 16px color-mix(in srgb, var(--lucid-sp-accent, #e66aa4) 23%, transparent);
}

.attachment-preview .download-button a:focus-visible {
	outline: 2px solid var(--lucid-sp-accent-bright, #ffb0d3);
	outline-offset: 3px;
}

/* ---- Previews: audio, video, PDF, documents and inline images ----- */

.attachment-preview audio {
	display: block;
	width: 100%;
	height: 42px;
	margin-top: 6px;
	color-scheme: dark;
}

.attachment-preview video {
	display: block;
	width: 100%;
	max-width: 100%;
	height: auto;
	margin: 7px 0 0;
	border-radius: 10px;
	background: #11151d;
}

.attachment-preview embed,
.attachment-preview iframe {
	display: block;
	width: 100%;
	max-width: 100%;
	height: min(440px, 62vh);
	margin-top: 8px;
	border: 0;
	border-radius: 10px;
	background: #10141b;
}

.attachment-preview .attach-image,
.attachment-preview dl.file {
	max-width: 100%;
}

.attachment-preview .attach-image img {
	max-width: 100%;
	height: auto;
	border-radius: 9px;
}

.attachment-preview.document,
.attachment-preview.audio,
.attachment-preview.video {
	min-width: 0;
}

/* Inline attachments should still follow their post column width. */
.inline-attachment {
	max-width: 100%;
	margin: 8px 0;
}

.inline-attachment .attachment-preview {
	font-size: 1em;
}

.inline-attachment .attachment-preview.bordered {
	background:
		radial-gradient(ellipse at 5% 0%, color-mix(in srgb, var(--lucid-sp-accent, #e66aa4) 10%, transparent), transparent 50%),
		linear-gradient(125deg, #232630, #191d26);
}

/* ---- Small screens ------------------------------------------------ */

@media (max-width: 600px) {
	.attachment-preview.bordered {
		padding: 8px;
		border-radius: 13px;
	}

	.attachment-preview .file-info {
		gap: 10px;
		padding: 7px;
		border-radius: 10px;
	}

	.attachment-preview .picture {
		flex-basis: 54px;
		width: 54px;
		height: 54px;
		padding: 4px;
		border-radius: 10px;
	}

	.attachment-preview .picture.iconic img {
		max-height: 45px;
	}

	.attachment-preview .id3-title,
	.attachment-preview .id3-title a {
		font-size: 13px;
	}

	.attachment-preview .id3-info {
		font-size: 11px;
	}

	.attachment-preview .download-button a,
	.attachment-preview .download-button a:visited {
		width: 39px;
		height: 39px;
		border-radius: 11px;
	}
}

@media (max-width: 360px) {
	.attachment-preview .file-info { gap: 7px; }
	.attachment-preview .picture {
		flex-basis: 45px;
		width: 45px;
		height: 49px;
	}
	.attachment-preview .download-button a,
	.attachment-preview .download-button a:visited {
		width: 36px;
		height: 36px;
		font-size: 18px;
	}
	.attachment-preview.bordered::after {
		right: 9px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.attachment-preview.bordered,
	.attachment-preview .download-button a {
		transition: none;
	}
	.attachment-preview .download-button a:hover {
		transform: none;
	}
}
