/**
 * Myco panel — overlays: modal (both the JS-built `.myco-modal > .myco-modal__box`
 * shape and the template-declared `.myco-modal > .myco-modal__backdrop +
 * .myco-modal__panel` shape), toast stack, and the skeleton/loading veil.
 * Tokens only.
 */

/* ---- Modal ---- */

.myco-modal {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px 16px;
	background: var( --myco-scrim );
	-webkit-backdrop-filter: blur( 4px );
	backdrop-filter: blur( 4px );
	animation: myco-fade-in 0.15s ease-out;
}

/* Template-declared shape: an explicit backdrop element sits under the panel. */
.myco-modal__backdrop {
	position: absolute;
	inset: 0;
}

.myco-modal__box,
.myco-modal__panel {
	position: relative;
	width: 100%;
	max-width: 480px;
	max-height: calc( 100vh - 48px );
	overflow: auto;
	background: var( --myco-card );
	color: var( --myco-text );
	border: 1px solid var( --myco-border );
	border-radius: var( --myco-radius-lg );
	box-shadow: var( --myco-shadow-modal );
	padding: var( --myco-modal-pad );
	display: flex;
	flex-direction: column;
	gap: 14px;
	animation: myco-pop-in 0.18s ease-out;
}

.myco-modal__box--wide,
.myco-modal__panel--wide {
	max-width: 820px;
}

.myco-modal__box--narrow {
	max-width: 440px;
}

.myco-modal__head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
}

.myco-modal__title {
	font-family: var( --myco-font-display );
	font-weight: var( --myco-display-weight );
	font-size: 20px;
	line-height: 1.25;
	margin: 0;
}

.myco-modal__subtitle {
	font-size: 13px;
	color: var( --myco-muted );
	margin-top: 4px;
}

.myco-modal__close {
	width: 32px;
	height: 32px;
	border: 0;
	border-radius: var( --myco-radius-xs );
	background: var( --myco-well );
	color: var( --myco-text-2 );
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	margin: -4px -6px 0 0;
}

.myco-modal__close:hover {
	background: var( --myco-active );
	color: var( --myco-ink );
}

.myco-modal__body {
	display: flex;
	flex-direction: column;
	gap: 14px;
	min-height: 0;
}

.myco-modal__text {
	font-size: 14px;
	line-height: 1.55;
	color: var( --myco-text );
}

.myco-modal__text--soft {
	color: var( --myco-text-2 );
	font-size: 13px;
}

/* Info rows with an icon (restore / cancel / delete modals). */
.myco-modal__fact {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	font-size: 13px;
	color: var( --myco-text-2 );
	line-height: 1.5;
}

.myco-modal__fact .myco-icon {
	font-size: 16px;
	color: var( --myco-text-2 );
	flex-shrink: 0;
	margin-top: 2px;
}

/* A stacked facts list: padded rows with dividers (cancel / restore / delete dialogs). */
.myco-modal__facts,
.myco-cancelmodal__facts {
	display: flex;
	flex-direction: column;
	gap: 0;
	padding: 0;
}

.myco-modal__facts .myco-modal__fact,
.myco-cancelmodal__facts .myco-modal__fact {
	padding: 11px 14px;
	border-top: 1px solid var( --myco-divider );
}

.myco-modal__facts .myco-modal__fact:first-child,
.myco-cancelmodal__facts .myco-modal__fact:first-child {
	border-top: 0;
}

.myco-modal__fact--warn .myco-icon { color: var( --myco-warn-ink ); }
.myco-modal__fact--danger .myco-icon { color: var( --myco-danger ); }

.myco-modal__name {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
}

.myco-modal__name code {
	flex: 1 1 auto;
	min-width: 0;
	overflow-wrap: anywhere;
	font-family: var( --myco-font-mono );
	font-size: 13px;
	background: var( --myco-well );
	padding: 8px 12px;
	border-radius: var( --myco-radius-sm );
}

.myco-modal__label {
	display: flex;
	flex-direction: column;
	gap: 6px;
	font-size: 13px;
	font-weight: 600;
}

.myco-modal__parts {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.myco-modal__parts .myco-checkbox {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 10px;
}

.myco-modal__mode {
	height: var( --myco-h-sm );
	font-size: 13px;
	width: auto;
	min-width: 200px;
}

.myco-modal__sublist {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.myco-modal__actions {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	flex-wrap: wrap;
	padding-top: 6px;
}

.myco-modal__actions--between {
	justify-content: space-between;
}

.myco-modal__foot {
	margin: 0 calc( -1 * 28px ) calc( -1 * 26px );
	padding: 16px 28px;
	background: var( --myco-tint );
	border-top: 1px solid var( --myco-divider );
	border-radius: 0 0 var( --myco-radius-lg ) var( --myco-radius-lg );
	display: flex;
	justify-content: flex-end;
	gap: 10px;
}

body.myco-modal-open {
	overflow: hidden;
}

@keyframes myco-fade-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes myco-pop-in {
	from { opacity: 0; transform: translateY( 8px ) scale( 0.98 ); }
	to { opacity: 1; transform: none; }
}

@media ( max-width: 560px ) {
	.myco-modal {
		align-items: flex-end;
		padding: 0;
	}

	.myco-modal__box,
	.myco-modal__panel {
		max-height: 92vh;
		border-radius: var( --myco-radius-lg ) var( --myco-radius-lg ) 0 0;
		padding: 22px 18px calc( 22px + env( safe-area-inset-bottom ) );
	}

	.myco-modal__foot {
		margin: 0 -18px calc( -22px - env( safe-area-inset-bottom ) );
		padding: 14px 18px calc( 14px + env( safe-area-inset-bottom ) );
	}
}

/* ---- Toasts (bottom-right stack, dark surface) ---- */

.myco-toasts {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 1100;
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-width: min( 420px, calc( 100vw - 32px ) );
	pointer-events: none;
}

.myco-toast {
	pointer-events: auto;
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 12px 14px;
	border-radius: var( --myco-radius-md );
	background: var( --myco-surface-dark );
	color: var( --myco-cream );
	font-size: 13px;
	line-height: 1.45;
	box-shadow: var( --myco-shadow-toast );
	animation: myco-toast-in 0.22s ease-out;
	border: 1px solid var( --myco-line-on-dark );
}

/* Legacy single toast (app.js flashShow) used to be fixed top-centre; keep it
   sane when it renders outside the stack container. */
.myco-toast:not( .myco-toasts .myco-toast ) {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 1100;
	max-width: min( 420px, calc( 100vw - 32px ) );
}

.myco-toast__icon {
	flex-shrink: 0;
	font-size: 16px;
	margin-top: 1px;
	color: var( --myco-cream );
}

.myco-toast.is-success .myco-toast__icon { color: var( --myco-accent ); }
.myco-toast.is-error .myco-toast__icon { color: var( --myco-danger-on-dark ); }
.myco-toast.is-warn .myco-toast__icon { color: var( --myco-warn ); }
.myco-toast.is-warn { border-color: var( --myco-warn-border ); }
.myco-toast.is-error { border-color: var( --myco-danger-border ); }
.myco-toast.is-info .myco-toast__icon { color: var( --myco-muted ); }

.myco-toast__text {
	flex: 1 1 auto;
	min-width: 0;
}

.myco-toast__action {
	background: none;
	border: 0;
	padding: 0;
	font: inherit;
	font-weight: 700;
	color: var( --myco-accent );
	cursor: pointer;
	white-space: nowrap;
	text-decoration: none;
}

.myco-toast__action:hover {
	text-decoration: underline;
	color: var( --myco-accent );
}

.myco-toast__close {
	background: none;
	border: 0;
	padding: 0 2px;
	font: inherit;
	font-size: 18px;
	line-height: 1;
	color: var( --myco-muted );
	cursor: pointer;
	flex-shrink: 0;
}

.myco-toast__close:hover {
	color: var( --myco-cream );
}

.myco-toast.is-leaving {
	opacity: 0;
	transform: translateY( 8px );
	transition: opacity 0.25s ease, transform 0.25s ease;
}

@keyframes myco-toast-in {
	from { opacity: 0; transform: translateY( 10px ); }
	to { opacity: 1; transform: none; }
}

@media ( max-width: 900px ) {
	.myco-toasts,
	.myco-toast:not( .myco-toasts .myco-toast ) {
		right: 12px;
		left: 12px;
		bottom: calc( var( --myco-mobile-nav-h ) + 12px );
		max-width: none;
	}
}

/* ---- Veil / skeleton ---- */

.myco-veil {
	position: absolute;
	inset: 0;
	background: var( --myco-scrim );
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: inherit;
	z-index: 5;
}

.myco-skeleton {
	background: linear-gradient( 90deg, var( --myco-track ) 25%, var( --myco-tint ) 37%, var( --myco-track ) 63% );
	background-size: 400% 100%;
	animation: myco-shimmer 1.4s ease infinite;
	border-radius: var( --myco-radius-xs );
}

@keyframes myco-shimmer {
	0% { background-position: 100% 50%; }
	100% { background-position: 0 50%; }
}
