/* ==========================================================================
   MCCF Organizational Chart — v2.2
   Desktop & tablet: natural-size chart, scaled by JS to fit the width,
   connectors drawn in SVG. Mobile (< 768px): carousel or compressed list.
   ========================================================================== */

.mccf-oc {
	--oc-ink: #1f2937;          /* text */
	--oc-line: #374151;         /* connector lines */
	--oc-accent: #0f5c99;       /* names, active states */
	--oc-border: #1f2937;
	--oc-card-bg: #fff;
	--oc-side-bg: #f8fafc;
	--oc-card-w: 150px;
	--oc-lead-w: 210px;
	--oc-side-w: 190px;
	--oc-gap-x: 14px;           /* between cards in a row */
	--oc-gap-y: 50px;           /* between levels */
	width: 100%;
	max-width: 100%;
	color: var(--oc-ink);
	box-sizing: border-box;
}
.mccf-oc *, .mccf-oc *::before, .mccf-oc *::after { box-sizing: border-box; }
.mccf-oc .oc-chart-title {
	text-align: center; font-size: 1.25em; font-weight: 800; letter-spacing: .02em;
	text-transform: uppercase; margin: 0 0 12px;
}

/* ---------- Card ---------- */
.mccf-oc .oc-card {
	position: relative;
	z-index: 1;
	width: var(--oc-card-w);
	min-height: 58px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	background: var(--oc-card-bg);
	border: 1.5px solid var(--oc-border);
	border-radius: 6px;
	padding: 9px 8px;
	box-shadow: 0 1px 2px rgba(0,0,0,.06);
	overflow-wrap: anywhere;
	line-height: 1.25;
}
.mccf-oc .oc-card.oc-lead { width: var(--oc-lead-w); }
.mccf-oc .oc-card.oc-side { width: var(--oc-side-w); background: var(--oc-side-bg); }
.mccf-oc .oc-text { display: flex; flex-direction: column; gap: 2px; }
.mccf-oc .oc-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .01em; }
.mccf-oc .oc-sub   { font-size: 11px; font-weight: 700; text-transform: uppercase; opacity: .8; }
.mccf-oc .oc-name  { font-size: 12px; font-weight: 500; color: var(--oc-accent); margin-top: 2px; }
.mccf-oc .oc-photo { margin-bottom: 6px; }
.mccf-oc .oc-photo img,
.mccf-oc .oc-avatar {
	width: 56px; height: 56px; border-radius: 50%; object-fit: cover; display: block;
	border: 2px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.18); background-color: #e5e7eb;
}
.mccf-oc .oc-card.oc-lead .oc-photo img,
.mccf-oc .oc-card.oc-lead .oc-avatar { width: 64px; height: 64px; }
/* neutral silhouette for positions without a photo yet */
.mccf-oc .oc-avatar {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Ccircle cx='32' cy='24' r='12' fill='%239ca3af'/%3E%3Cpath d='M10 58c2-12 11-19 22-19s20 7 22 19' fill='%239ca3af'/%3E%3C/svg%3E");
	background-size: 100% 100%;
}

/* ==========================================================================
   DESKTOP / TABLET
   ========================================================================== */
.mccf-oc .oc-toolbar { display: flex; gap: 4px; justify-content: flex-end; margin-bottom: 4px; }
.mccf-oc .oc-toolbar button {
	min-width: 32px; height: 28px; padding: 0 9px; border: 1px solid #d1d5db; background: #fff;
	color: var(--oc-ink); border-radius: 6px; cursor: pointer; font: 600 13px/1 inherit;
}
.mccf-oc .oc-toolbar button:hover { border-color: var(--oc-accent); color: var(--oc-accent); }

.mccf-oc .oc-viewport {
	width: 100%;
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	text-align: center;           /* centres the chart when narrower than the page */
	scrollbar-width: thin;
}
.mccf-oc .oc-viewport.is-draggable { cursor: grab; }
.mccf-oc .oc-viewport.is-dragging  { cursor: grabbing; user-select: none; }
.mccf-oc .oc-stage {
	display: inline-block;        /* natural size; JS applies zoom to fit */
	position: relative;
	text-align: left;
	padding: 6px 28px 10px;       /* room for connectors that route around rows */
}
.mccf-oc .oc-lines {
	position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; z-index: 0;
	color: var(--oc-line);
}
.mccf-oc .oc-roots { display: flex; gap: 60px; justify-content: center; align-items: flex-start; width: max-content; }

.mccf-oc .oc-block { display: flex; flex-direction: column; align-items: center; }
.mccf-oc .oc-team  { margin-top: var(--oc-gap-y); }
.mccf-oc .oc-row   { display: flex; align-items: flex-start; justify-content: center; gap: var(--oc-gap-x); }
.mccf-oc .oc-stack { display: flex; flex-direction: column; align-items: center; gap: 26px; }
.mccf-oc .oc-tier  { display: flex; flex-direction: column; align-items: center; gap: var(--oc-gap-y); }
.mccf-oc .oc-tier > .oc-tier-row > .oc-team { margin-top: 0; }
.mccf-oc .oc-tier-heads {
	display: flex; justify-content: space-between; align-items: flex-start; gap: 120px; width: 100%;
}

/* Side branches: fixed equal columns either side of the trunk */
.mccf-oc .oc-sides { display: flex; margin-top: 26px; }
.mccf-oc .oc-side-col {
	width: calc(var(--oc-side-w) + 70px);
	display: flex; flex-direction: column; gap: 14px;
}
.mccf-oc .oc-side-left  { align-items: flex-end;   padding-right: 70px; }
.mccf-oc .oc-side-right { align-items: flex-start; padding-left: 70px; }

/* ==========================================================================
   MOBILE
   ========================================================================== */
.mccf-oc .oc-mobile { display: none; }

/* ---------- Phones, default "swipe": same chart, slide left/right ---------- */
.mccf-oc .oc-desktop { position: relative; }
.mccf-oc .oc-swipe-hint { display: none; }
@media (max-width: 767px) {
	.mccf-oc .oc-toolbar { margin-bottom: 6px; }
	.mccf-oc .oc-viewport { touch-action: pan-x pan-y pinch-zoom; overscroll-behavior-x: contain; }
	/* soft fade on the edge that has more chart beyond it */
	.mccf-oc .oc-desktop::before,
	.mccf-oc .oc-desktop::after {
		content: ''; position: absolute; top: 34px; bottom: 0; width: 26px; z-index: 3; pointer-events: none;
		opacity: 0; transition: opacity .2s;
	}
	.mccf-oc .oc-desktop::before { left: 0;  background: linear-gradient(to right, rgba(255,255,255,.95), rgba(255,255,255,0)); }
	.mccf-oc .oc-desktop::after  { right: 0; background: linear-gradient(to left,  rgba(255,255,255,.95), rgba(255,255,255,0)); }
	.mccf-oc .oc-desktop.can-left::before,
	.mccf-oc .oc-desktop.can-right::after { opacity: 1; }
	/* hint shown until the visitor first slides the chart */
	.mccf-oc .oc-desktop.is-scrollable .oc-swipe-hint {
		display: flex; align-items: center; justify-content: center; gap: 8px; margin: 8px auto 0; width: max-content;
		padding: 6px 14px; border-radius: 999px; background: #1f2937; color: #fff; font: 600 12px/1.2 inherit;
		transition: opacity .4s;
	}
	.mccf-oc .oc-desktop.has-swiped .oc-swipe-hint { opacity: 0; }
	.mccf-oc .oc-swipe-arrows { letter-spacing: 2px; animation: mccf-oc-nudge 1.6s ease-in-out infinite; }
	@keyframes mccf-oc-nudge { 0%,100% { transform: translateX(-3px); } 50% { transform: translateX(3px); } }
}

/* ---------- Phones, alternative layouts: mobile="stack" or mobile="carousel" ---------- */
@media (max-width: 767px) {
	.mccf-oc.oc-mobile-stack .oc-desktop,
	.mccf-oc.oc-mobile-carousel .oc-desktop { display: none; }
	.mccf-oc .oc-mobile  { display: block; }
	.mccf-oc .oc-card { box-shadow: none; }

	/* Spine: Board → Chairman → Deputy, with a line between steps */
	.mccf-oc .oc-m-spine { display: flex; flex-direction: column; align-items: center; }
	.mccf-oc .oc-m-step  { display: flex; flex-direction: column; align-items: center; width: 100%; position: relative; }
	.mccf-oc .oc-m-step + .oc-m-step { padding-top: 22px; }
	.mccf-oc .oc-m-step + .oc-m-step::before,
	.mccf-oc .oc-m-spine + .oc-m-nav::before,
	.mccf-oc .oc-m-spine + .oc-m-track::before {
		content: ''; position: absolute; top: 0; left: 50%; height: 22px; border-left: 1.5px solid var(--oc-line);
	}
	.mccf-oc .oc-card.oc-m-main { width: min(260px, 82%); }
	.mccf-oc .oc-card.oc-m-small { width: 100%; min-height: 50px; padding: 7px 6px; }
	.mccf-oc .oc-m-small .oc-title { font-size: 11px; }
	.mccf-oc .oc-m-small .oc-sub   { font-size: 10px; }
	.mccf-oc .oc-m-small .oc-photo img,
	.mccf-oc .oc-m-small .oc-avatar { width: 40px; height: 40px; }

	.mccf-oc .oc-m-sides {
		display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
		width: min(320px, 100%); margin-top: 10px;
	}
	.mccf-oc .oc-m-sides > .oc-card:only-child { grid-column: 1 / -1; justify-self: center; width: 70%; }
	.mccf-oc .oc-m-step .oc-m-sides { position: relative; }
	.mccf-oc .oc-m-step .oc-m-sides::before {
		content: ''; position: absolute; left: 50%; top: -10px; height: 10px; border-left: 1.5px solid var(--oc-line);
	}

	/* Tabs + arrows */
	.mccf-oc .oc-m-nav { position: relative; display: flex; align-items: center; gap: 6px; margin-top: 22px; padding-top: 0; }
	.mccf-oc .oc-m-nav::before { top: -22px !important; }
	.mccf-oc .oc-m-nav > button {
		flex: 0 0 34px; height: 34px; border-radius: 50%; border: 1px solid #d1d5db; background: #fff;
		font-size: 22px; line-height: 1; color: var(--oc-accent); cursor: pointer; padding: 0; display: grid; place-items: center;
	}
	.mccf-oc .oc-m-nav > button:disabled { opacity: .3; cursor: default; }
	.mccf-oc .oc-m-tabs {
		flex: 1; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; justify-content: safe center;
	}
	.mccf-oc .oc-m-tabs::-webkit-scrollbar { display: none; }
	.mccf-oc .oc-m-tabs button {
		flex: 0 0 auto; border: 1px solid #d1d5db; background: #fff; color: var(--oc-ink); border-radius: 999px;
		padding: 7px 12px; font: 700 11px/1 inherit; text-transform: uppercase; cursor: pointer; white-space: nowrap;
	}
	.mccf-oc .oc-m-tabs button.is-active { background: var(--oc-accent); border-color: var(--oc-accent); color: #fff; }

	/* Slides */
	.mccf-oc .oc-m-track { position: relative; margin-top: 12px; }
	.mccf-oc .oc-m-spine + .oc-m-track { margin-top: 22px; overflow-y: visible; }
	.mccf-oc .oc-m-spine + .oc-m-track::before { top: -22px; }
	.mccf-oc .oc-m-carousel .oc-m-track {
		display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory;
		-webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; scrollbar-width: none;
		padding: 0 0 4px; outline: none; align-items: flex-start;
	}
	/* edge spacers (padding at the end of a scroll container isn't reliable) so first/last slides can centre */
	.mccf-oc .oc-m-nav + .oc-m-track::before,
	.mccf-oc .oc-m-carousel .oc-m-track::after { content: ''; flex: 0 0 calc(6% - 10px); }
	.mccf-oc .oc-m-carousel .oc-m-track::-webkit-scrollbar { display: none; }
	.mccf-oc .oc-m-carousel .oc-m-slide { flex: 0 0 88%; scroll-snap-align: center; scroll-snap-stop: always; }
	/* ---- Stack mode (default): groups one under another, joined by a rail on the left ---- */
	.mccf-oc .oc-m-stack .oc-m-track { display: flex; flex-direction: column; gap: 14px; padding-left: 18px; }
	.mccf-oc .oc-m-stack .oc-m-spine + .oc-m-track::after {   /* elbow from the centre line to the rail */
		content: ''; position: absolute; top: 0; left: 7px; right: 50%; border-top: 1.5px solid var(--oc-line);
	}
	.mccf-oc .oc-m-stack .oc-m-slide { position: relative; }
	.mccf-oc .oc-m-stack .oc-m-slide::before {               /* rail */
		content: ''; position: absolute; left: -11px; top: -14px; height: calc(100% + 14px); border-left: 1.5px solid var(--oc-line);
	}
	.mccf-oc .oc-m-stack .oc-m-slide:first-child::before { top: 0; height: 100%; }
	.mccf-oc .oc-m-stack .oc-m-slide:last-child::before  { height: 46px; }
	.mccf-oc .oc-m-stack .oc-m-slide:first-child:last-child::before { height: 32px; }
	.mccf-oc .oc-m-stack .oc-m-slide::after {                /* tick into each group */
		content: ''; position: absolute; left: -11px; top: 32px; width: 11px; border-top: 1.5px solid var(--oc-line);
	}

	/* Collapsible group header */
	.mccf-oc details.oc-m-slide > summary {
		list-style: none; cursor: pointer; width: 100%; display: flex; flex-direction: column; align-items: center;
		-webkit-tap-highlight-color: transparent;
	}
	.mccf-oc details.oc-m-slide > summary::-webkit-details-marker { display: none; }
	.mccf-oc .oc-m-meta {
		display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 5px 12px; border-radius: 999px;
		background: #fff; border: 1px solid #d1d5db; font: 600 12px/1 inherit; color: var(--oc-accent);
	}
	.mccf-oc .oc-m-chev {
		width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
		transform: translateY(1px) rotate(-135deg); transition: transform .2s;
	}
	.mccf-oc details.oc-m-slide:not([open]) .oc-m-chev { transform: translateY(-2px) rotate(45deg); }
	.mccf-oc details.oc-m-slide:not([open]) { padding-bottom: 14px; }

	.mccf-oc .oc-m-slide {
		background: #f3f6f9; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px 10px 12px;
		display: flex; flex-direction: column; align-items: center;
	}
	.mccf-oc .oc-m-grid {
		display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; margin-top: 12px;
		padding-top: 12px; border-top: 1.5px solid var(--oc-line); position: relative;
	}
	.mccf-oc .oc-m-grid::before {
		content: ''; position: absolute; left: 50%; top: -13px; height: 12px; border-left: 1.5px solid var(--oc-line);
	}
	.mccf-oc .oc-m-grid > .oc-card:last-child:nth-child(odd) { grid-column: 1 / -1; justify-self: center; width: calc(50% - 4px); }

	.mccf-oc .oc-m-groups { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 12px; }
	.mccf-oc .oc-m-group { background: #fff; border-radius: 10px; padding: 10px; border: 1px solid #e2e8f0; display: flex; flex-direction: column; align-items: center; }
	.mccf-oc .oc-card.oc-m-lead { width: 80%; }

	.mccf-oc .oc-m-dots { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }
	.mccf-oc .oc-m-dots button {
		width: 8px; height: 8px; border-radius: 4px; border: 0; padding: 0; background: #cbd5e1; cursor: pointer; transition: width .2s;
	}
	.mccf-oc .oc-m-dots button.is-active { width: 22px; background: var(--oc-accent); }
}

@media (prefers-reduced-motion: reduce) {
	.mccf-oc .oc-m-dots button { transition: none; }
	.mccf-oc .oc-swipe-arrows { animation: none; }
}
@media print {
	.mccf-oc .oc-toolbar { display: none; }
	.mccf-oc .oc-viewport { overflow: visible; }
}
