/**
 * WP Changelog — front-end styles.
 *
 * All selectors are scoped under .wpc-changelog so nothing leaks into the
 * surrounding theme. The palette tokens are overridable via the Settings page
 * (injected into wp_head).
 */

.wpc-changelog {
	/* Brand palette (Blue Vineyard defaults — overridable via Settings) */
	--wpc-primary:       #5859c0;
	--wpc-primary-dark:  #4344a0;
	--wpc-primary-50:    #eef0fc;
	--wpc-primary-100:   #dde0f7;
	--wpc-accent:        #7c7edb;

	--wpc-text:          #0f172a;
	--wpc-text-muted:    #64748b;
	--wpc-text-subtle:   #94a3b8;
	--wpc-border:        #e2e8f0;
	--wpc-bg:            #f8fafc;
	--wpc-card:          #ffffff;
	--wpc-warning:       #d97706;
	--wpc-warning-50:    #fef3c7;

	--wpc-radius:        14px;
	--wpc-radius-sm:     10px;
	--wpc-radius-xs:     6px;
	--wpc-shadow:        0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
	--wpc-shadow-md:     0 6px 18px rgba(15, 23, 42, 0.08);
	--wpc-transition:    0.18s ease;

	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
	color: var(--wpc-text);
	display: block;
	width: 100%;
	margin: 2em 0;
	line-height: 1.55;
}
.wpc-changelog *,
.wpc-changelog *::before,
.wpc-changelog *::after { box-sizing: border-box; }

.wpc-changelog__heading {
	margin: 0 0 1.25em;
	font-size: 24px;
	font-weight: 700;
	color: var(--wpc-text);
}

.wpc-changelog__list {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.wpc-changelog__empty {
	padding: 32px;
	text-align: center;
	color: var(--wpc-text-muted);
	background: var(--wpc-bg);
	border: 1px dashed var(--wpc-border);
	border-radius: var(--wpc-radius-sm);
}

/* ---------- Entry container ---------- */
.wpc-changelog__entry {
	background: var(--wpc-card);
	border: 1px solid var(--wpc-border);
	border-radius: var(--wpc-radius);
	padding: 24px 28px;
	box-shadow: var(--wpc-shadow);
	transition: box-shadow var(--wpc-transition), transform var(--wpc-transition);
}
.wpc-changelog__entry:hover {
	box-shadow: var(--wpc-shadow-md);
}
.wpc-changelog__entry.is-featured {
	border-color: var(--wpc-primary-100);
	background: linear-gradient(180deg, var(--wpc-primary-50) 0%, var(--wpc-card) 80px);
}

/* ---------- Header ---------- */
.wpc-changelog__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
	margin-bottom: 10px;
}
.wpc-changelog__header-left {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
	min-width: 0;
	flex: 1 1 auto;
}
.wpc-changelog__version {
	display: inline-flex;
	align-items: center;
	padding: 4px 12px;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.02em;
	background: var(--wpc-primary);
	color: #fff;
	border-radius: 999px;
	box-shadow: 0 2px 8px rgba(88, 89, 192, 0.25);
}
.wpc-changelog__star {
	color: #f59e0b;
	font-size: 18px;
	line-height: 1;
}
.wpc-changelog__title {
	margin: 0;
	font-size: 19px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--wpc-text);
}
.wpc-changelog__header-right { flex-shrink: 0; }
.wpc-changelog--cards .wpc-changelog__header-right { display: none; }
.wpc-changelog__date {
	width: 100%;
	margin-top: 2px;
	font-size: 13px;
	color: var(--wpc-text-muted);
	white-space: nowrap;
}

/* ---------- Badges ---------- */
.wpc-changelog__badges {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 12px;
}
.wpc-changelog__badge {
	display: inline-block;
	padding: 3px 10px;
	font-size: 11px;
	font-weight: 600;
	border-radius: 999px;
	letter-spacing: 0.02em;
}
.wpc-changelog__badge--type {
	background: var(--wpc-primary-50);
	color: var(--wpc-primary-dark);
	border: 1px solid var(--wpc-primary-100);
}
.wpc-changelog__badge--area {
	background: #f1f5f9;
	color: var(--wpc-text-muted);
	border: 1px solid var(--wpc-border);
}

/* ---------- Summary ---------- */
.wpc-changelog__summary {
	margin: 0 0 16px;
	font-size: 15px;
	color: var(--wpc-text-muted);
	line-height: 1.55;
}

.wpc-changelog__affected {
	margin: 0 0 14px;
	padding: 10px 14px;
	background: var(--wpc-warning-50);
	border: 1px solid #fcd34d;
	border-radius: var(--wpc-radius-xs);
	font-size: 13px;
	color: #92400e;
}
.wpc-changelog__affected strong { color: #78350f; }

/* ---------- Change-item groups ---------- */
.wpc-changelog__group {
	margin-top: 18px;
}
.wpc-changelog__group:first-of-type { margin-top: 4px; }

.wpc-changelog__group-title {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 10px;
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--wpc-text);
}
.wpc-changelog__group-icon {
	font-size: 16px;
	line-height: 1;
}

.wpc-changelog__items {
	margin: 0;
	padding-left: 22px;
	list-style: none;
}
.wpc-changelog__items li {
	position: relative;
	margin: 0 0 8px;
	padding-left: 4px;
	font-size: 14px;
	color: var(--wpc-text);
	line-height: 1.55;
}
.wpc-changelog__items li::before {
	content: '';
	position: absolute;
	left: -14px;
	top: 0.6em;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--wpc-primary);
}
.wpc-changelog__group--improvements .wpc-changelog__items li::before { background: #0ea5e9; }
.wpc-changelog__group--bug_fixes    .wpc-changelog__items li::before { background: #16a34a; }
.wpc-changelog__group--breaking     .wpc-changelog__items li::before { background: var(--wpc-warning); }

/* ---------- Narrative / post_content ---------- */
.wpc-changelog__narrative {
	margin-top: 18px;
	padding-top: 16px;
	border-top: 1px solid var(--wpc-border);
	font-size: 14px;
	color: var(--wpc-text-muted);
	line-height: 1.6;
}
.wpc-changelog__narrative > *:first-child { margin-top: 0; }
.wpc-changelog__narrative > *:last-child  { margin-bottom: 0; }

/* ---------- Accordion variant ---------- */
.wpc-changelog--accordion .wpc-changelog__entry {
	padding: 0;
	overflow: hidden;
}
.wpc-changelog--accordion .wpc-changelog__header {
	margin-bottom: 0;
	padding: 20px 24px;
	cursor: pointer;
	list-style: none;
	transition: background var(--wpc-transition);
	align-items: center;
	justify-content: flex-start;
	flex-wrap: nowrap;
}
.wpc-changelog--accordion .wpc-changelog__header-left {
	align-items: center;
	flex: 1 1 auto;
	min-width: 0;
}
.wpc-changelog--accordion .wpc-changelog__title {
	width: 100%;
}
.wpc-changelog--accordion .wpc-changelog__header-right {
	flex-shrink: 0;
}
.wpc-changelog--accordion .wpc-changelog__header::-webkit-details-marker { display: none; }
.wpc-changelog--accordion .wpc-changelog__header-right::after {
	content: '';
	display: inline-block;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background-color: var(--wpc-primary-50);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%234344a0' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: center;
	background-size: 18px 18px;
	transition: transform var(--wpc-transition), background-color var(--wpc-transition);
}
.wpc-changelog--accordion .wpc-changelog__entry[open] .wpc-changelog__header-right::after {
	transform: rotate(180deg);
	background-color: var(--wpc-primary-100);
}
.wpc-changelog--accordion .wpc-changelog__header:hover {
	background: var(--wpc-bg);
}
.wpc-changelog--accordion .wpc-changelog__header:hover .wpc-changelog__header-right::after {
	background-color: var(--wpc-primary-100);
}
.wpc-changelog--accordion .wpc-changelog__badges,
.wpc-changelog--accordion .wpc-changelog__summary,
.wpc-changelog--accordion .wpc-changelog__affected,
.wpc-changelog--accordion .wpc-changelog__group,
.wpc-changelog--accordion .wpc-changelog__narrative {
	padding-left: 24px;
	padding-right: 24px;
}
.wpc-changelog--accordion .wpc-changelog__badges { padding-top: 16px; }
.wpc-changelog--accordion .wpc-changelog__entry > *:last-child {
	padding-bottom: 20px;
}

/* ================================================================== */
/* Modal layout — tile grid + <dialog> details                          */
/* ================================================================== */

.wpc-changelog--modal .wpc-changelog__list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
	gap: 18px;
}

/* ---------- Tile (closed state) ---------- */
.wpc-changelog__tile {
	appearance: none;
	-webkit-appearance: none;
	display: flex;
	flex-direction: column;
	width: 100%;
	padding: 22px 22px 16px;
	background: var(--wpc-card);
	border: 1px solid var(--wpc-border);
	border-radius: var(--wpc-radius);
	box-shadow: var(--wpc-shadow);
	cursor: pointer;
	text-align: left;
	font-family: inherit;
	color: var(--wpc-text);
	transition: transform var(--wpc-transition), box-shadow var(--wpc-transition), border-color var(--wpc-transition);
}
.wpc-changelog__tile:hover {
	transform: translateY(-2px);
	box-shadow: var(--wpc-shadow-md);
	border-color: var(--wpc-primary-100);
}
.wpc-changelog__tile:focus-visible {
	outline: none;
	border-color: var(--wpc-primary);
	box-shadow: 0 0 0 3px rgba(88, 89, 192, 0.25);
}
.wpc-changelog__tile.is-featured {
	border-color: var(--wpc-primary-100);
	background: linear-gradient(180deg, var(--wpc-primary-50) 0%, var(--wpc-card) 70px);
}

.wpc-changelog__tile-top {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 12px;
}
.wpc-changelog__tile-top .wpc-changelog__version { margin: 0; }
.wpc-changelog__tile-date {
	font-size: 12px;
	color: var(--wpc-text-muted);
	margin-left: auto;
	white-space: nowrap;
}

.wpc-changelog__tile-title {
	margin: 0 0 8px;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.35;
	color: var(--wpc-text);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-overflow: ellipsis;
}

.wpc-changelog__tile-summary {
	margin: 0 0 14px;
	font-size: 13px;
	line-height: 1.55;
	color: var(--wpc-text-muted);
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-overflow: ellipsis;
}

.wpc-changelog__tile-badges {
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
	margin-bottom: 14px;
}
.wpc-changelog__tile-badges .wpc-changelog__badge {
	font-size: 10px;
	padding: 2px 8px;
}
.wpc-changelog__badge--more {
	background: var(--wpc-bg);
	color: var(--wpc-text-subtle);
	border: 1px solid var(--wpc-border);
}

.wpc-changelog__tile-footer {
	margin-top: auto;
	padding-top: 12px;
	border-top: 1px solid var(--wpc-border);
}
.wpc-changelog__tile-more {
	font-size: 13px;
	font-weight: 600;
	color: var(--wpc-primary);
	transition: color var(--wpc-transition);
}
.wpc-changelog__tile:hover .wpc-changelog__tile-more {
	color: var(--wpc-primary-dark);
}

/* ---------- <dialog> — centered (default) ---------- */
.wpc-changelog__modal {
	padding: 0;
	border: none;
	background: transparent;
	color: inherit;
	max-width: 720px;
	width: calc(100% - 32px);
	max-height: calc(100vh - 64px);
	border-radius: 16px;
	box-shadow: var(--wpc-shadow-lg);
	overflow: visible;
}
.wpc-changelog__modal:not([open]) { display: none; }

.wpc-changelog__modal::backdrop {
	background: rgba(15, 23, 42, 0.55);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
}

.wpc-changelog__modal-inner {
	position: relative;
	background: var(--wpc-card);
	border-radius: 16px;
	padding: 32px;
	max-height: calc(100vh - 64px);
	overflow-y: auto;
	box-shadow: var(--wpc-shadow-lg);
}
.wpc-changelog__modal-inner .wpc-changelog__entry {
	padding: 0;
	border: none;
	box-shadow: none;
	background: transparent;
}
.wpc-changelog__modal-inner .wpc-changelog__entry.is-featured {
	background: transparent;
	border: none;
}

.wpc-changelog__modal-close {
	position: absolute;
	top: 16px;
	right: 16px;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: var(--wpc-bg);
	border: 1px solid var(--wpc-border);
	cursor: pointer;
	font-size: 20px;
	line-height: 1;
	color: var(--wpc-text-muted);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: all var(--wpc-transition);
	z-index: 2;
	padding: 0;
	font-family: inherit;
}
.wpc-changelog__modal-close:hover {
	background: #fee2e2;
	border-color: #fca5a5;
	color: #dc2626;
}
.wpc-changelog__modal-close:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px rgba(88, 89, 192, 0.25);
}

/* Open animations (native <dialog>) */
.wpc-changelog__modal[open] {
	animation: wpcModalIn 0.22s ease;
}
.wpc-changelog__modal[open]::backdrop {
	animation: wpcBackdropIn 0.22s ease;
}
@keyframes wpcModalIn {
	from { opacity: 0; transform: translateY(16px) scale(0.97); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes wpcBackdropIn {
	from { opacity: 0; }
	to   { opacity: 1; }
}

/* ---------- Drawer variant (is-drawer modifier) ---------- */
.wpc-changelog--modal.is-drawer .wpc-changelog__modal {
	width: min(520px, 100%);
	max-width: 520px;
	height: 100vh;
	max-height: 100vh;
	margin: 0 0 0 auto;
	inset: 0 0 0 auto;
	border-radius: 0;
}
.wpc-changelog--modal.is-drawer .wpc-changelog__modal-inner {
	height: 100vh;
	max-height: 100vh;
	border-radius: 0;
	padding: 40px 36px 32px;
}
.wpc-changelog--modal.is-drawer .wpc-changelog__modal[open] {
	animation: wpcDrawerIn 0.26s ease;
}
@keyframes wpcDrawerIn {
	from { opacity: 0; transform: translateX(24px); }
	to   { opacity: 1; transform: translateX(0); }
}

/* Legacy fallback — no native <dialog> support */
.wpc-changelog__modal.is-fallback-open {
	display: block;
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	z-index: 99999;
	background: rgba(15, 23, 42, 0.55);
}

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
	.wpc-changelog__entry { padding: 20px 18px; }
	.wpc-changelog--accordion .wpc-changelog__header { padding: 16px 18px; }
	.wpc-changelog--accordion .wpc-changelog__badges,
	.wpc-changelog--accordion .wpc-changelog__summary,
	.wpc-changelog--accordion .wpc-changelog__affected,
	.wpc-changelog--accordion .wpc-changelog__group,
	.wpc-changelog--accordion .wpc-changelog__narrative {
		padding-left: 18px;
		padding-right: 18px;
	}
	.wpc-changelog__title { font-size: 17px; }
	.wpc-changelog__header { gap: 8px; }
	.wpc-changelog__header-right { width: 100%; }

	/* Modal: stack tiles to a single column */
	.wpc-changelog--modal .wpc-changelog__list { grid-template-columns: 1fr; }
	.wpc-changelog__modal { width: calc(100% - 16px); }
	.wpc-changelog__modal-inner { padding: 24px 20px; }

	/* Drawer: fill the viewport on mobile */
	.wpc-changelog--modal.is-drawer .wpc-changelog__modal {
		width: 100%;
		max-width: 100%;
	}
	.wpc-changelog--modal.is-drawer .wpc-changelog__modal-inner {
		padding: 28px 20px 24px;
	}
}
