/* ==========================================================================
   ChroniclePress Front-End Styles (Enhanced Mode)
   Version: 1.0.0
   Author: Lime & Ledger
   ========================================================================== */

/* ── Design Tokens ─────────────────────────────────────────────────────── */
:root {
	--cp-pub-green:       #2D5F3F;
	--cp-pub-green-mid:   #3d7a53;
	--cp-pub-green-light: #7FC49A;
	--cp-pub-green-pale:  #EBF5EE;
	--cp-pub-gold:        #C19A2E;
	--cp-pub-gold-pale:   #FDF8EC;
	--cp-pub-person:      #3B6FA8;
	--cp-pub-person-pale: #EAF0F8;
	--cp-pub-place:       #2D7D59;
	--cp-pub-place-pale:  #E8F5EF;
	--cp-pub-source:      #7a4210;
	--cp-pub-source-pale: #FDF0E8;
	--cp-pub-text:        #1d2327;
	--cp-pub-text-mid:    #50575E;
	--cp-pub-text-light:  #8C8F94;
	--cp-pub-border:      #dcdcde;
	--cp-pub-bg:          #f6f7f7;
	--cp-pub-white:       #ffffff;
	--cp-pub-radius:      8px;
	--cp-pub-radius-sm:   4px;
	--cp-pub-shadow:      0 2px 12px rgba(0,0,0,.08);
	--cp-pub-transition:  0.18s ease;
}

/* ── Entity Type Badge ─────────────────────────────────────────────────── */
.cp-entity-badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 4px 10px;
	border-radius: 20px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.6px;
	text-transform: uppercase;
	margin-bottom: 12px;
}
.cp-entity-badge--person { background: var(--cp-pub-person-pale); color: var(--cp-pub-person); }
.cp-entity-badge--place  { background: var(--cp-pub-place-pale);  color: var(--cp-pub-place); }
.cp-entity-badge--source { background: var(--cp-pub-source-pale); color: var(--cp-pub-source); }

/* ── Entity Header ─────────────────────────────────────────────────────── */
.cp-entity-header {
	margin-bottom: 2rem;
}
.cp-entity-header__inner {
	display: flex;
	gap: 24px;
	align-items: flex-start;
}
.cp-entity-header__portrait {
	width: 120px;
	height: 120px;
	border-radius: 50%;
	overflow: hidden;
	flex-shrink: 0;
	border: 3px solid var(--cp-pub-border);
	box-shadow: var(--cp-pub-shadow);
}
.cp-entity-header__portrait img { width: 100%; height: 100%; object-fit: cover; }
.cp-entity-header__portrait-placeholder {
	width: 100%; height: 100%;
	background: var(--cp-pub-bg);
	display: flex; align-items: center; justify-content: center;
	color: var(--cp-pub-text-light);
	font-size: 40px;
}
.cp-entity-header__meta { flex: 1; }
.cp-entity-header__title { margin: 0 0 6px; }
.cp-entity-header__dates { color: var(--cp-pub-text-mid); font-size: 15px; margin-bottom: 8px; }
.cp-entity-header__dates time { font-weight: 500; }
.cp-entity-header__location { color: var(--cp-pub-text-mid); font-size: 14px; margin-bottom: 10px; }
.cp-entity-header__excerpt { color: var(--cp-pub-text-mid); font-style: italic; margin-bottom: 10px; }

@media ( max-width: 600px ) {
	.cp-entity-header__inner { flex-direction: column; }
	.cp-entity-header__portrait { width: 80px; height: 80px; }
}

/* ── Entity Meta Table ─────────────────────────────────────────────────── */
.cp-entity-meta {
	margin: 1.5rem 0;
	border: 1px solid var(--cp-pub-border);
	border-radius: var(--cp-pub-radius);
	overflow: hidden;
	background: var(--cp-pub-white);
	box-shadow: var(--cp-pub-shadow);
}
.cp-entity-meta__table { width: 100%; border-collapse: collapse; }
.cp-entity-meta__table tr { border-bottom: 1px solid var(--cp-pub-border); }
.cp-entity-meta__table tr:last-child { border-bottom: none; }
.cp-entity-meta__table th {
	width: 160px;
	padding: 11px 16px;
	background: var(--cp-pub-bg);
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.4px;
	color: var(--cp-pub-text-mid);
	text-align: left;
	vertical-align: top;
}
.cp-entity-meta__table td {
	padding: 11px 16px;
	font-size: 14px;
	color: var(--cp-pub-text);
	vertical-align: top;
}
@media ( max-width: 500px ) {
	.cp-entity-meta__table,
	.cp-entity-meta__table thead,
	.cp-entity-meta__table tbody,
	.cp-entity-meta__table th,
	.cp-entity-meta__table td,
	.cp-entity-meta__table tr { display: block; }
	.cp-entity-meta__table th { width: auto; padding: 10px 14px 2px; border-bottom: none; }
	.cp-entity-meta__table td { padding: 2px 14px 10px; }
}

/* ── Era Badges ────────────────────────────────────────────────────────── */
.cp-era-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 0.75rem 0; }
.cp-era-badge {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 20px;
	background: var(--cp-pub-gold-pale);
	border: 1px solid rgba(193,154,46,.3);
	color: var(--cp-pub-gold);
	font-size: 12px;
	font-weight: 500;
	text-decoration: none;
	transition: background var(--cp-pub-transition);
}
.cp-era-badge:hover { background: #f7e9bb; text-decoration: none; }

/* ── External Links ────────────────────────────────────────────────────── */
.cp-external-links { margin: 1rem 0; display: flex; flex-wrap: wrap; gap: 8px; }
.cp-external-link {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 5px 12px;
	border: 1px solid var(--cp-pub-border);
	border-radius: 20px;
	font-size: 13px;
	color: var(--cp-pub-text-mid);
	text-decoration: none;
	transition: all var(--cp-pub-transition);
}
.cp-external-link:hover { border-color: var(--cp-pub-green); color: var(--cp-pub-green); text-decoration: none; }
.cp-external-link::before { content: "↗"; font-size: 11px; }

/* ── Related Content Panel ─────────────────────────────────────────────── */
.cp-related-content {
	margin: 2.5rem 0 1rem;
	clear: both;
}
.cp-related-content__section { margin-bottom: 2rem; }
.cp-related-content__heading {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 16px;
	font-weight: 700;
	color: var(--cp-pub-text);
	margin: 0 0 14px;
	padding-bottom: 8px;
	border-bottom: 2px solid var(--cp-pub-border);
}
.cp-related-content__heading-icon {
	display: inline-flex;
	width: 28px; height: 28px;
	border-radius: 50%;
	align-items: center; justify-content: center;
	flex-shrink: 0;
}
.cp-related-content__heading-icon--person { background: var(--cp-pub-person-pale); color: var(--cp-pub-person); }
.cp-related-content__heading-icon--place  { background: var(--cp-pub-place-pale);  color: var(--cp-pub-place); }
.cp-related-content__heading-icon--source { background: var(--cp-pub-source-pale); color: var(--cp-pub-source); }

/* ── Entity Cards Grid ─────────────────────────────────────────────────── */
.cp-entity-cards {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 180px, 1fr ) );
	gap: 14px;
}
.cp-entity-card {
	display: flex;
	flex-direction: column;
	border: 1px solid var(--cp-pub-border);
	border-radius: var(--cp-pub-radius);
	overflow: hidden;
	background: var(--cp-pub-white);
	text-decoration: none;
	color: inherit;
	transition: all var(--cp-pub-transition);
	box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.cp-entity-card:hover { transform: translateY(-2px); box-shadow: var(--cp-pub-shadow); text-decoration: none; border-color: var(--cp-pub-green-light); }
.cp-entity-card__thumb { aspect-ratio: 1; overflow: hidden; background: var(--cp-pub-bg); }
.cp-entity-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.cp-entity-card__thumb-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 32px; color: var(--cp-pub-text-light); }
.cp-entity-card__body { padding: 10px 12px; }
.cp-entity-card__title { font-size: 14px; font-weight: 600; color: var(--cp-pub-text); margin: 0 0 3px; line-height: 1.3; }
.cp-entity-card__subtitle { font-size: 12px; color: var(--cp-pub-text-light); }

/* ── Related Posts List ────────────────────────────────────────────────── */
.cp-related-posts { display: flex; flex-direction: column; gap: 12px; }
.cp-related-post {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	padding: 12px;
	border: 1px solid var(--cp-pub-border);
	border-radius: var(--cp-pub-radius);
	background: var(--cp-pub-white);
	text-decoration: none;
	color: inherit;
	transition: all var(--cp-pub-transition);
}
.cp-related-post:hover { border-color: var(--cp-pub-green-light); background: var(--cp-pub-green-pale); text-decoration: none; }
.cp-related-post__thumb { width: 64px; height: 64px; flex-shrink: 0; border-radius: var(--cp-pub-radius-sm); overflow: hidden; background: var(--cp-pub-bg); }
.cp-related-post__thumb img { width: 100%; height: 100%; object-fit: cover; }
.cp-related-post__info { flex: 1; min-width: 0; }
.cp-related-post__title { font-size: 15px; font-weight: 600; color: var(--cp-pub-text); margin: 0 0 4px; line-height: 1.3; }
.cp-related-post__date { font-size: 12px; color: var(--cp-pub-text-light); }
.cp-related-post__excerpt { font-size: 13px; color: var(--cp-pub-text-mid); margin-top: 4px; line-height: 1.4; }

/* ── Entity Hub Sections ───────────────────────────────────────────────── */
.cp-entity-hub { margin: 2.5rem 0 1rem; }
.cp-entity-hub__section { margin-bottom: 2.5rem; }
.cp-entity-hub__title {
	font-size: 18px;
	font-weight: 700;
	color: var(--cp-pub-text);
	margin: 0 0 16px;
	padding-bottom: 10px;
	border-bottom: 2px solid var(--cp-pub-border);
	display: flex; align-items: center; gap: 8px;
}

/* ── Auto-Link Styles ──────────────────────────────────────────────────── */
.cp-autolink {
	border-bottom: 1px dashed var(--cp-pub-green-light);
	text-decoration: none;
	color: inherit;
	transition: border-bottom-color var(--cp-pub-transition);
}
.cp-autolink:hover {
	border-bottom-color: var(--cp-pub-green);
	text-decoration: none;
}
.cp-entity-cp_person { border-bottom-color: rgba(59,111,168,.4); }
.cp-entity-cp_person:hover { border-bottom-color: var(--cp-pub-person); }
.cp-entity-cp_place  { border-bottom-color: rgba(45,125,89,.4); }
.cp-entity-cp_place:hover  { border-bottom-color: var(--cp-pub-place); }
.cp-entity-cp_source { border-bottom-color: rgba(122,66,16,.4); }
.cp-entity-cp_source:hover { border-bottom-color: var(--cp-pub-source); }

/* ── Single Entity Page Wrapper ────────────────────────────────────────── */
.cp-single-entity { max-width: 100%; }
.cp-entity-content { margin: 1.5rem 0; }
.cp-entity-divider { border: none; border-top: 1px solid var(--cp-pub-border); margin: 2rem 0; }

/* ── Source-Specific ───────────────────────────────────────────────────── */
.cp-source-url {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	background: var(--cp-pub-green-pale);
	border: 1px solid var(--cp-pub-green-light);
	border-radius: var(--cp-pub-radius-sm);
	color: var(--cp-pub-green);
	text-decoration: none;
	font-size: 13px;
	font-weight: 500;
	margin: 0.5rem 0;
	transition: background var(--cp-pub-transition);
}
.cp-source-url:hover { background: #d5edde; text-decoration: none; }

/* ── Inline field wrapper ─────────────────────────────────────────────────── */
.cp-field {
    display: inline;
}

.cp-field__label {
    font-weight: 600;
    margin-right: 0.25em;
    color: var( --cp-meta-label-color, #5a5a5a );
}

.cp-field__value {
    color: inherit;
}

/* ── When the field value is a URL auto-link ─────────────────────────────── */
.cp-field__value a {
    color: var( --cp-link-color, inherit );
    text-decoration: underline;
}

/* ── Error state (unknown field key) ─────────────────────────────────────── */
.cp-field--unknown {
    color: #b32d2e;
    font-style: italic;
    font-size: 0.875em;
}

