/**
 * WP Download Timer Pro — front-end download card.
 *
 * Deliberately simple: a title, one line of countdown copy with the
 * duration highlighted as a pill, and a button that doubles as the
 * countdown's progress meter.
 *
 * THEME ISOLATION — read this before editing selectors below.
 * WordPress themes commonly style bare tags inside the content area,
 * e.g. `.entry-content p { color:...; font-family:...; }` — some themes
 * (Jannah's site-wide "content color" skin setting is a confirmed
 * example) apply this with !important. A selector like that (one class
 * + one tag = specificity 0,1,1) beats a plain single-class selector
 * like `.ds-file-title` (0,1,0) regardless of load order, which is what
 * caused this card to render in the theme's own color/font/italic style
 * instead of ours.
 *
 * Two layers of defense are used here:
 *  1. Every selector below is prefixed `.ds-container.ds-container.ds-container`
 *     (the same class stated three times). This still matches the one
 *     real element — it doesn't change what a selector targets — but
 *     each repetition adds one class to the specificity count, pushing
 *     every rule here comfortably above realistic theme selectors, even
 *     ones using !important. Don't "clean this up" to a single
 *     `.ds-container` — the duplication is load-bearing.
 *  2. For the plain text elements (title, countdown line, pill) that
 *     never change via JS, class-wpdt-shortcode.php ALSO writes inline
 *     `style="...!important"` attributes computed from the same colors.
 *     Inline !important out-ranks any external stylesheet from any
 *     theme, full stop — that's the actual guarantee; the CSS here is a
 *     fallback for the rare case something strips inline styles. The
 *     download button isn't handled that way, since its background
 *     legitimately changes between idle/counting/ready via JS-toggled
 *     classes, which an inline style would block.
 *
 * This file also neutralizes any ::before/::after content a theme might
 * inject on generic block/text elements (some themes add decorative
 * icon-font glyphs this way, which render as a stray "|" or tofu box if
 * the icon font isn't loaded in this context) — see the rule near the
 * bottom of this file.
 *
 * Colors come from CSS custom properties set on :root by the plugin's
 * Settings page (--ds-title-color, --ds-box-bg, --ds-button-color,
 * --ds-border-color); the fallbacks below are only used if those are
 * ever missing.
 *
 * Responsiveness: sized with container queries (the card reacts to the
 * width of whatever it's placed in — full content column, narrow
 * sidebar, mobile viewport) plus fluid clamp() sizing, with a viewport
 * @media fallback for the few browsers without container query support.
 */

.ds-container.ds-container.ds-container {
	--ds-track: rgba(0, 0, 0, .05);
	--ds-track: color-mix(in srgb, var(--ds-button-color, #1a9c53) 12%, transparent);
	--ds-pill-bg: rgba(26, 156, 83, .12);
	--ds-pill-bg: color-mix(in srgb, var(--ds-button-color, #1a9c53) 16%, transparent);
	--ds-button-end: #0f7a3d;
	--ds-button-end: color-mix(in srgb, var(--ds-button-color, #1a9c53) 70%, black 30%);
	--ds-ring: rgba(26, 156, 83, .35);
	--ds-ring: color-mix(in srgb, var(--ds-button-color, #1a9c53) 35%, transparent);

	display: block !important;
	width: 100%;
	max-width: 400px;
	margin: 1.5em auto !important;
	container-type: inline-size;
	container-name: ds-card;
}

/* Reset box model and typography for every element inside the card, so
   theme rules targeting bare tags (p, button, span...) can't leak in.
   white-space is included deliberately: if a theme or a page author
   nests the shortcode inside a <pre> or <code> block (which set
   white-space: pre), that value is INHERITED by every descendant unless
   something resets it — meaning any whitespace/indentation in the
   plugin's own HTML source would render as visible blank space. This
   line, plus compacting the HTML output itself (see class-wpdt-
   shortcode.php), is the fix for exactly that failure mode. */
.ds-container.ds-container.ds-container,
.ds-container.ds-container.ds-container * {
	box-sizing: border-box !important;
	min-width: 0; /* lets flex children shrink instead of overflowing the card */
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
	font-style: normal !important;
	white-space: normal !important;
	text-align: left;
	text-transform: none !important;
	text-shadow: none !important;
	letter-spacing: normal !important;
	list-style: none !important;
	float: none !important;
}

/* Suppress any decorative ::before/::after content a theme injects on
   generic elements (icon-font glyphs, quote marks, etc.) — this card
   doesn't use pseudo-element content itself, so it's safe to blank out
   entirely rather than try to guess and override each theme's version. */
.ds-container.ds-container.ds-container::before,
.ds-container.ds-container.ds-container::after,
.ds-container.ds-container.ds-container *::before,
.ds-container.ds-container.ds-container *::after {
	content: none !important;
	display: none !important;
}

.ds-container.ds-container.ds-container .ds-card {
	background: var(--ds-box-bg, #fff) !important;
	border: 1px solid var(--ds-border-color, #e5e7eb) !important;
	border-radius: 12px !important;
	padding: clamp(18px, 6cqw, 26px) clamp(16px, 5.5cqw, 22px);
	box-shadow: 0 1px 3px rgba(0, 0, 0, .06) !important;
}

.ds-container.ds-container.ds-container .ds-file-title {
	margin: 0 0 8px !important;
	font-size: clamp(15px, 4.6cqw, 18px) !important;
	font-weight: 700 !important;
	line-height: 1.35 !important;
	color: var(--ds-title-color, #1e293b) !important;
	text-align: center !important;
	overflow-wrap: anywhere;
}

.ds-container.ds-container.ds-container .ds-countdown-text {
	margin: 0 0 clamp(14px, 4.5cqw, 18px) !important;
	text-align: center !important;
	font-size: clamp(13px, 3.9cqw, 14.5px) !important;
	font-weight: 400 !important;
	line-height: 1.55 !important;
	color: var(--ds-title-color, #1e293b) !important;
}

.ds-container.ds-container.ds-container .ds-count-pill {
	display: inline-block;
	font-weight: 700 !important;
	color: var(--ds-button-color, #1a9c53) !important;
	background: var(--ds-pill-bg) !important;
	border-radius: 6px !important;
	padding: 1px 8px;
	margin: 0 1px;
	white-space: nowrap;
}

.ds-container.ds-container.ds-container .ds-download-btn {
	appearance: none !important;
	-webkit-appearance: none !important;
	display: block !important;
	position: relative;
	width: 100% !important;
	margin: 0 !important;
	padding: clamp(12px, 3.8cqw, 14px) clamp(16px, 5cqw, 20px) !important;
	border: none !important;
	border-radius: 999px !important;
	background: linear-gradient(180deg, var(--ds-button-color, #1a9c53), var(--ds-button-end)) !important;
	overflow: hidden;
	cursor: pointer !important;
	font-weight: 700 !important;
	font-size: clamp(13.5px, 4.1cqw, 15.5px) !important;
	line-height: 1.3 !important;
	color: #fff !important;
	text-decoration: none !important;
	box-shadow: 0 2px 6px var(--ds-ring) !important;
	transition: background-color .2s ease, box-shadow .2s ease;
}

.ds-container.ds-container.ds-container .ds-download-btn:hover,
.ds-container.ds-container.ds-container .ds-download-btn:focus,
.ds-container.ds-container.ds-container .ds-download-btn:active {
	color: #fff !important;
	text-decoration: none !important;
}

.ds-container.ds-container.ds-container .ds-download-btn:focus-visible {
	outline: 2px solid var(--ds-button-color, #1a9c53) !important;
	outline-offset: 3px;
}

/* Counting state: a light track with a growing bar along the bottom edge,
   so the label stays legible at every fill level regardless of accent color. */
.ds-container.ds-container.ds-container.is-counting .ds-download-btn {
	background: var(--ds-track) !important;
	color: var(--ds-title-color, #1e293b) !important;
	cursor: progress !important;
	box-shadow: none !important;
}

.ds-container.ds-container.ds-container .ds-btn-fill {
	position: absolute;
	left: 0;
	bottom: 0;
	height: 4px;
	width: 0%;
	background: var(--ds-button-color, #1a9c53) !important;
	transition: width 1s linear;
}

.ds-container.ds-container.ds-container.is-idle .ds-btn-fill,
.ds-container.ds-container.ds-container.is-ready .ds-btn-fill {
	width: 0%;
	transition: none;
}

.ds-container.ds-container.ds-container .ds-btn-content {
	position: relative;
	z-index: 1;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	gap: clamp(7px, 2.5cqw, 10px);
}

.ds-container.ds-container.ds-container .ds-btn-icon {
	flex: none;
	width: clamp(16px, 5cqw, 20px);
	height: clamp(16px, 5cqw, 20px);
	color: inherit !important;
}

.ds-container.ds-container.ds-container .ds-btn-icon,
.ds-container.ds-container.ds-container .ds-btn-icon path {
	stroke: currentColor !important;
	fill: none !important;
}

.ds-container.ds-container.ds-container .ds-btn-label {
	font-weight: inherit !important;
	font-size: inherit !important;
	color: inherit !important;
	white-space: nowrap;
}

/* ---------- Container-query breakpoint (primary responsive mechanism) ---------- */

@container ds-card (max-width: 260px) {
	.ds-container.ds-container.ds-container .ds-btn-label {
		white-space: normal; /* let a long/translated label wrap instead of overflowing */
	}
}

/* ---------- Viewport media-query fallback ----------
   Only matters for browsers without container query support (pre-2023). */
@supports not (container-type: inline-size) {
	@media (max-width: 340px) {
		.ds-container.ds-container.ds-container .ds-btn-label {
			white-space: normal;
		}
	}
}

@media (prefers-reduced-motion: reduce) {
	.ds-container.ds-container.ds-container .ds-btn-fill { transition: none; }
}
