/*
 * Medical Citation — front-end styles.
 * Design language extracted from hairtec.nl ("Hoe we dit artikel hebben
 * beoordeeld" component): #eeeff2 rounded container, navy #0a184a accents,
 * tab bar with 2px active underline, vertical timeline for history.
 */

.medcit-box,
.medcit-box * {
	box-sizing: border-box;
}

.medcit-box {
	background: var(--medcit-bg, #eeeff2);
	color: var(--medcit-text, #231f20);
	padding: 10px 30px 30px;
	border-radius: var(--medcit-radius, 20px);
	margin: 40px 0;
	font-size: 16px;
	line-height: 1.5;
}

.medcit-box-title {
	font-size: 20px;
	font-weight: 700;
	color: var(--medcit-heading, #223558);
	margin: 20px 0;
	line-height: 1.3;
}

/* --- Tabs --- */

.medcit-tabs {
	display: flex;
	gap: 20px;
	margin-bottom: 20px;
	border-bottom: 1px solid #e0e0e0;
}

.medcit-tab {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 0;
	margin: 0;
	background: none;
	border: 0;
	border-bottom: 2px solid transparent;
	border-radius: 0;
	color: #666;
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	line-height: 1.4;
	cursor: pointer;
	box-shadow: none;
	transition: color 0.15s ease, border-color 0.15s ease;
}

.medcit-tab:hover,
.medcit-tab:focus {
	color: var(--medcit-primary, #0a184a);
	background: none;
	outline: none;
}

.medcit-tab:focus-visible {
	outline: 2px solid var(--medcit-primary, #0a184a);
	outline-offset: 2px;
}

.medcit-tab.is-active {
	color: var(--medcit-primary, #0a184a);
	border-bottom-color: var(--medcit-primary, #0a184a);
}

.medcit-tab svg {
	flex: 0 0 auto;
	display: block;
}

/* --- Panels / description --- */

.medcit-panel[hidden] {
	display: none;
}

.medcit-desc {
	font-size: 16px;
	line-height: 1.5;
	color: var(--medcit-muted, #5c5c5c);
	margin: 0 0 30px;
}

.medcit-desc a {
	color: var(--medcit-primary, #0a184a);
	text-decoration: underline;
}

/* --- Sources list --- */

.medcit-sources {
	list-style: none;
	margin: 0;
	padding: 0 15px;
}

.medcit-sources li {
	margin: 0 0 25px;
	overflow-wrap: anywhere;
	word-break: break-word;
	border-radius: 8px;
	transition: background-color 0.4s ease;
}

.medcit-sources li:last-child {
	margin-bottom: 0;
}

.medcit-src-num {
	color: var(--medcit-primary, #0a184a);
	font-weight: 700;
	margin-right: 6px;
}

.medcit-src-label {
	color: var(--medcit-text, #231f20);
}

.medcit-sources li a {
	display: block;
	margin-top: 5px;
	color: var(--medcit-primary, #0a184a);
	text-decoration: underline;
	overflow-wrap: anywhere;
	word-break: break-word;
	hyphens: auto;
	max-width: 100%;
}

/* #hsm-panel-sources: Schema Manager 3.1.0+ paneli — marker tıklaması oraya
   atladığında da aynı vurgu uygulansın. */
.medcit-sources li.medcit-highlight,
#hsm-panel-sources li.medcit-highlight {
	background-color: rgba(10, 24, 74, 0.08);
	box-shadow: 0 0 0 8px rgba(10, 24, 74, 0.08);
}

/* --- History timeline --- */

.medcit-timeline {
	position: relative;
	padding-left: 30px;
}

.medcit-timeline::before {
	content: "";
	position: absolute;
	left: 0;
	top: 15px;
	bottom: 0;
	width: 2px;
	background: #e0e0e0;
}

.medcit-timeline-item {
	position: relative;
	margin-bottom: 30px;
}

.medcit-timeline-item:last-child {
	margin-bottom: 0;
}

.medcit-timeline-dot {
	position: absolute;
	left: -36px;
	top: 5px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #fff;
	border: 2px solid var(--medcit-primary, #0a184a);
}

.medcit-timeline-dot.is-current {
	background: var(--medcit-primary, #0a184a);
}

.medcit-timeline-date {
	font-weight: 700;
	color: var(--medcit-text, #231f20);
	line-height: 1.4;
}

.medcit-tl-label {
	font-size: 17px;
	line-height: 26px;
	color: var(--medcit-text, #231f20);
	margin-top: 12px;
	margin-bottom: 4px;
}

.medcit-tl-value {
	font-size: 14px;
	line-height: 20px;
	color: #767674;
	margin-bottom: 4px;
}

/* --- Drawer style (Healthline-like pills + slide-over panel) --- */

.medcit-box--drawer {
	background: none;
	padding: 0;
	border-radius: 0;
	margin: 40px 0;
}

.medcit-box--drawer .medcit-box-title {
	margin: 0 0 14px;
}

.medcit-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
}

.medcit-pill {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: var(--medcit-bg, #eeeff2);
	color: var(--medcit-heading, #223558);
	border: 0;
	border-radius: 1000px;
	padding: 8px 16px;
	margin: 0;
	font-family: inherit;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.4;
	cursor: pointer;
	box-shadow: none;
	text-transform: none;
	transition: background-color 0.15s ease;
}

.medcit-pill:hover,
.medcit-pill:focus {
	background: #e2e4ea;
	color: var(--medcit-primary, #0a184a);
	outline: none;
}

.medcit-pill:focus-visible {
	outline: 2px solid var(--medcit-primary, #0a184a);
	outline-offset: 2px;
}

.medcit-pill svg {
	flex: 0 0 auto;
	display: block;
}

.medcit-overlay {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	background: rgba(10, 24, 74, 0.3);
	z-index: 99990;
	opacity: 0;
	transition: opacity 0.25s ease;
}

.medcit-overlay.is-open {
	opacity: 1;
}

.medcit-drawer {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: min(634px, 100vw);
	background: #fff;
	z-index: 99995;
	border-left: 1px solid #eef0f4;
	box-shadow: 0 0 28px rgba(10, 24, 74, 0.12);
	padding: 20px 20px 40px;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	transform: translateX(105%);
	visibility: hidden;
	transition: transform 0.3s ease, visibility 0.3s;
}

.medcit-drawer.is-open {
	transform: translateX(0);
	visibility: visible;
}

.medcit-drawer-title {
	text-align: center;
	font-size: 18px;
	font-weight: 700;
	color: var(--medcit-heading, #223558);
	margin: 8px 0 20px;
}

.medcit-drawer-close {
	position: absolute;
	top: 18px;
	right: 18px;
	background: none;
	border: 0;
	padding: 4px;
	margin: 0;
	color: var(--medcit-heading, #223558);
	cursor: pointer;
	line-height: 0;
	box-shadow: none;
}

.medcit-drawer-close:hover,
.medcit-drawer-close:focus {
	background: none;
	color: #000;
}

.medcit-drawer .medcit-desc {
	font-size: 17px;
	line-height: 1.45;
	color: var(--medcit-muted, #5c5c5c);
	margin: 0 0 12px;
}

.medcit-sources--drawer {
	list-style: none;
	margin: 0;
	padding: 0;
}

.medcit-sources--drawer li {
	display: flex;
	align-items: center;
	gap: 14px;
	border-top: 1px solid #e0e0e0;
	padding: 16px 0;
	margin: 0;
}

.medcit-sources--drawer .medcit-src-label {
	flex: 1;
	color: var(--medcit-text, #231f20);
	font-size: 16px;
	line-height: 1.45;
	overflow-wrap: anywhere;
}

.medcit-sources--drawer .medcit-src-num {
	margin-right: 2px;
}

/* Higher specificity than the inline-style ".medcit-sources li a" rule. */
.medcit-src-open,
.medcit-sources--drawer li a.medcit-src-open {
	flex: 0 0 48px;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: var(--medcit-bg, #eeeff2);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--medcit-primary, #0a184a);
	text-decoration: none;
	margin: 0;
	transition: box-shadow 0.15s ease, background-color 0.15s ease;
}

.medcit-src-open:hover,
.medcit-src-open:focus {
	color: var(--medcit-primary, #0a184a);
	background: #e2e4ea;
	box-shadow: none;
}

.medcit-drawer .medcit-timeline {
	margin-top: 8px;
}

body.medcit-drawer-open {
	overflow: hidden;
}

@media (max-width: 640px) {
	.medcit-drawer {
		top: auto;
		left: 0;
		width: 100%;
		max-height: 82vh;
		border-radius: 24px 24px 0 0;
		transform: translateY(105%);
	}

	.medcit-drawer.is-open {
		transform: translateY(0);
	}
}

/* --- Inline citation marker --- */

.medcit-ref {
	position: relative;
	display: inline-block;
}

/* Superscript mode (optional, off by default). */
sup.medcit-ref.is-sup {
	line-height: 0;
	vertical-align: super;
	font-size: 0.75em;
}

/* Default: marker sits on the text baseline, slightly smaller and
   semi-bold so it stands out without floating above the line. */
.medcit-ref.is-inline {
	vertical-align: baseline;
	font-size: 0.85em;
	line-height: inherit;
}

.medcit-ref-link {
	color: var(--medcit-primary, #0a184a);
	font-weight: 600;
	text-decoration: none;
	padding: 0 1px;
	white-space: nowrap;
}

.medcit-ref.is-bold .medcit-ref-link {
	font-weight: 700;
}

/* Plain (non-link) markers show the help cursor when a tooltip exists. */
span.medcit-ref-link[tabindex] {
	cursor: help;
}

a.medcit-ref-link:hover,
a.medcit-ref-link:focus {
	color: var(--medcit-primary, #0a184a);
	text-decoration: underline;
}

/* --- Tooltip --- */

.medcit-tip {
	position: absolute;
	bottom: calc(100% + 10px);
	left: 50%;
	transform: translateX(-50%) translateY(4px);
	width: 280px;
	max-width: min(280px, 82vw);
	background: #fff;
	color: var(--medcit-text, #231f20);
	border-radius: 14px;
	box-shadow: 0 10px 34px rgba(10, 24, 74, 0.18);
	padding: 14px 16px;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.45;
	text-align: start;
	text-transform: none;
	letter-spacing: normal;
	white-space: normal;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
	z-index: 99999;
}

.medcit-tip::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	border: 7px solid transparent;
	border-top-color: #fff;
}

/* Invisible bridge so slow pointer movement can reach the card. */
.medcit-tip::before {
	content: "";
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	height: 14px;
}

.medcit-ref .medcit-tip.is-below::before {
	top: auto;
	bottom: 100%;
}

/* Escape pressed: force-hide until pointer/focus leaves (WCAG 1.4.13). */
.medcit-ref.is-dismissed .medcit-tip {
	opacity: 0 !important;
	visibility: hidden !important;
	pointer-events: none !important;
}

.medcit-ref:hover .medcit-tip,
.medcit-ref:focus-within .medcit-tip,
.medcit-ref.is-open .medcit-tip {
	opacity: 1;
	visibility: visible;
	transform: translateX(-50%) translateY(0);
	pointer-events: auto;
}

/* Flipped below the marker when there is no room above. */
.medcit-ref .medcit-tip.is-below {
	bottom: auto;
	top: calc(100% + 12px);
}

.medcit-ref .medcit-tip.is-below::after {
	top: auto;
	bottom: 100%;
	border-top-color: transparent;
	border-bottom-color: #fff;
}

/* Edge-shifted variants keep the card on screen; arrow stays on the marker. */
.medcit-ref .medcit-tip.is-left {
	left: 0;
	transform: translateX(-12px) translateY(4px);
}

.medcit-ref:hover .medcit-tip.is-left,
.medcit-ref:focus-within .medcit-tip.is-left,
.medcit-ref.is-open .medcit-tip.is-left {
	transform: translateX(-12px) translateY(0);
}

.medcit-ref .medcit-tip.is-left::after {
	left: 18px;
}

.medcit-ref .medcit-tip.is-right {
	left: auto;
	right: 0;
	transform: translateX(12px) translateY(4px);
}

.medcit-ref:hover .medcit-tip.is-right,
.medcit-ref:focus-within .medcit-tip.is-right,
.medcit-ref.is-open .medcit-tip.is-right {
	transform: translateX(12px) translateY(0);
}

.medcit-ref .medcit-tip.is-right::after {
	left: auto;
	right: 18px;
	transform: none;
}

.medcit-tip-title {
	display: block;
	font-weight: 700;
	color: var(--medcit-heading, #223558);
	margin-bottom: 4px;
}

.medcit-tip-host {
	display: block;
	color: #767674;
	font-size: 12px;
	margin-bottom: 8px;
}

.medcit-tip-link {
	display: inline-block;
	color: var(--medcit-primary, #0a184a);
	font-weight: 700;
	text-decoration: underline;
}

/* --- Responsive --- */

@media (max-width: 640px) {
	.medcit-box {
		padding: 6px 20px 24px;
	}

	.medcit-tabs {
		gap: 14px;
	}

	.medcit-sources {
		padding: 0 5px;
	}
}

/* --- RTL --- */

body.rtl .medcit-timeline,
[dir="rtl"] .medcit-timeline {
	padding-left: 0;
	padding-right: 30px;
}

body.rtl .medcit-timeline::before,
[dir="rtl"] .medcit-timeline::before {
	left: auto;
	right: 0;
}

body.rtl .medcit-timeline-dot,
[dir="rtl"] .medcit-timeline-dot {
	left: auto;
	right: -36px;
}

body.rtl .medcit-src-num,
[dir="rtl"] .medcit-src-num {
	margin-right: 0;
	margin-left: 6px;
}

/* --- Print --- */

@media print {
	.medcit-tip {
		display: none !important;
	}

	.medcit-panel[hidden] {
		display: block !important;
	}

	.medcit-box {
		break-inside: avoid;
	}

	.medcit-overlay,
	.medcit-pills {
		display: none !important;
	}

	.medcit-drawer {
		position: static;
		transform: none;
		visibility: visible;
		box-shadow: none;
		width: auto;
		background: none;
	}
}
