/*
 * MAGICDUEL - the Influences card.
 *
 * The card that opens over an influence of the Influences panel (top right corner; the Triggers box
 * until 2026-10-04). Behaviour: js/md_influences.js. Data: core/Influences/Influences.php card().
 * Linked from templates/layout-<skin>/layoutHead.php with ?r=<filemtime>, because css/ is cached.
 *
 * It lives in the TOP document, not in the panel's 330x220 iframe, so it is never clipped by it.
 * Two shapes: a hover card beside the panel (mouse), and a pinned card with a close button (a click
 * or a tap). Below 641px, and on a touch screen with no hover, the pinned card is a sheet at the
 * bottom of the screen over a dimmed game.
 *
 * Colour = the influence's tone (harm, boon, guard, world, quest, mark). The tone is also written as
 * a word in the foot, so the colour is never the only sign.
 */

.mdinf-card {
	--tone: #7a6b55;
	--tone-soft: rgba(122, 107, 85, .13);
	--ink: #2f2414;
	--ink-soft: #6b5a3e;
	--ink-faint: #93805f;
	--paper: #f8f1e0;
	--paper-2: #f1e6cc;
	--line: rgba(110, 82, 40, .22);

	position: fixed;
	z-index: 10050;
	box-sizing: border-box;
	width: 300px;
	max-width: calc(100vw - 16px);
	color: var(--ink);
	background: linear-gradient(180deg, #fbf6ea 0%, var(--paper) 55%, var(--paper-2) 100%);
	border: 1px solid var(--line);
	border-radius: 10px;
	box-shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 12px 28px -8px rgba(40, 24, 6, .45), 0 2px 6px rgba(40, 24, 6, .18);
	overflow: hidden;
	font-family: Georgia, 'Times New Roman', serif;
	font-size: 13px;
	font-weight: normal;
	text-align: left;
	opacity: 0;
	transform: translateY(4px);
	transition: opacity .14s ease, transform .14s ease;
	pointer-events: none;
}
.mdinf-card *, .mdinf-card *::before, .mdinf-card *::after { box-sizing: border-box; }
/* The game's own stylesheet sets a font on EVERY div, td and p (css.default.ui-general.css:
   "body, div, td, p { font-family: 'Jost'; font-size: 13px }") and Bootstrap bolds every dt, so the
   card's elements would not inherit its own font. :where() keeps this reset at one class of
   specificity, so every rule below still wins by coming later. */
.mdinf-card :where(div, span, p, dl, dt, dd, button) { font-family: inherit; font-size: inherit; font-weight: inherit; }
.mdinf-card.mdinf-on { opacity: 1; transform: none; }
.mdinf-card.mdinf-pinned { pointer-events: auto; }

.mdinf-t-harm  { --tone: #a8382a; --tone-soft: rgba(168, 56, 42, .12); }
.mdinf-t-boon  { --tone: #4b7d29; --tone-soft: rgba(75, 125, 41, .13); }
.mdinf-t-guard { --tone: #2a688a; --tone-soft: rgba(42, 104, 138, .12); }
.mdinf-t-world { --tone: #a86f12; --tone-soft: rgba(168, 111, 18, .14); }
.mdinf-t-quest { --tone: #6f4c9c; --tone-soft: rgba(111, 76, 156, .13); }
.mdinf-t-mark  { --tone: #7a6b55; --tone-soft: rgba(122, 107, 85, .13); }

/* the tone's edge along the top */
.mdinf-card::before {
	content: '';
	display: block;
	height: 3px;
	background: linear-gradient(90deg, var(--tone), rgba(255, 255, 255, 0) 92%);
}

/* ------------------------------------------------------------------ head */

.mdinf-head {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 10px 12px 6px;
}
.mdinf-ico {
	flex: 0 0 30px;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--tone);
	background: var(--tone-soft);
	box-shadow: 0 0 0 1px var(--tone-soft) inset;
}
.mdinf-ico svg { width: 17px; height: 17px; display: block; }
.mdinf-ttl { flex: 1 1 auto; min-width: 0; padding-top: 1px; }
.mdinf-name {
	display: block;
	font-size: 15px;
	line-height: 1.2;
	font-weight: bold;
	color: var(--ink);
	overflow-wrap: anywhere;
}
.mdinf-code {
	display: inline-block;
	margin-top: 2px;
	font-family: Consolas, 'Courier New', monospace;
	font-size: 10.5px;
	color: var(--ink-faint);
	overflow-wrap: anywhere;
}
.mdinf-close {
	display: none;
	flex: 0 0 28px;
	width: 28px;
	height: 28px;
	margin: -3px -5px 0 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--ink-soft);
	font: 20px/28px Georgia, serif;
	cursor: pointer;
}
.mdinf-close:hover, .mdinf-close:focus-visible { background: rgba(110, 82, 40, .12); color: var(--ink); outline: none; }
.mdinf-pinned .mdinf-close { display: block; }

/* ------------------------------------------------------------------ time */

.mdinf-time {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0 12px 8px 52px;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 11px;
	color: var(--ink-soft);
}
.mdinf-left { font-weight: bold; color: var(--tone); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mdinf-bar {
	flex: 1 1 auto;
	height: 4px;
	border-radius: 2px;
	background: rgba(110, 82, 40, .14);
	overflow: hidden;
}
.mdinf-bar i { display: block; height: 100%; width: 0; background: var(--tone); border-radius: 2px; transition: width .4s linear; }
.mdinf-count {
	white-space: nowrap;
	padding: 1px 6px;
	border-radius: 8px;
	background: var(--tone-soft);
	color: var(--tone);
	font-weight: bold;
}

/* ------------------------------------------------------------------ what it does */

.mdinf-text {
	margin: 0 12px 8px;
	padding: 7px 10px;
	border-left: 2px solid var(--tone);
	background: rgba(255, 255, 255, .45);
	border-radius: 0 6px 6px 0;
	font-size: 12.5px;
	line-height: 1.42;
	font-style: italic;
	color: #3b2d18;
	overflow-wrap: anywhere;
}
.mdinf-text.mdinf-none { font-style: normal; color: var(--ink-faint); font-size: 11.5px; }

.mdinf-fx {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin: 0 12px 8px;
}
.mdinf-fx span {
	--fx: #7a6b55;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10.5px;
	line-height: 1;
	padding: 4px 7px;
	border-radius: 9px;
	color: var(--fx);
	background: #fff8e8;
	border: 1px solid currentColor;
	border-color: color-mix(in srgb, var(--fx) 35%, transparent);
	white-space: nowrap;
}
.mdinf-fx .mdinf-fx-harm  { --fx: #a8382a; }
.mdinf-fx .mdinf-fx-boon  { --fx: #4b7d29; }
.mdinf-fx .mdinf-fx-guard { --fx: #2a688a; }
.mdinf-fx .mdinf-fx-world { --fx: #a86f12; }
.mdinf-fx .mdinf-fx-quest { --fx: #6f4c9c; }

/* ------------------------------------------------------------------ who */

.mdinf-facts {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	column-gap: 10px;
	row-gap: 3px;
	margin: 0;
	padding: 7px 12px 8px;
	border-top: 1px solid var(--line);
	font-size: 12px;
}
.mdinf-facts dt {
	margin: 0;
	padding-top: 2px;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 9.5px;
	letter-spacing: .07em;
	text-transform: uppercase;
	color: var(--ink-faint);
	white-space: nowrap;
}
.mdinf-facts dd { margin: 0; min-width: 0; color: var(--ink); overflow-wrap: anywhere; }
.mdinf-facts .mdinf-id {
	font-family: Consolas, 'Courier New', monospace;
	font-size: 11.5px;
	color: var(--ink-soft);
}
.mdinf-facts .mdinf-quiet { color: var(--ink-faint); font-style: italic; }
.mdinf-facts .mdinf-self { color: var(--ink-faint); font-size: 11px; }

/* ------------------------------------------------------------------ foot */

.mdinf-foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 8px;
	padding: 6px 12px 8px;
	background: rgba(110, 82, 40, .06);
	border-top: 1px solid var(--line);
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10.5px;
	color: var(--ink-soft);
}
.mdinf-src {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-weight: bold;
	color: var(--ink-soft);
}
.mdinf-src svg { width: 12px; height: 12px; }
.mdinf-tone { color: var(--tone); font-weight: bold; }
.mdinf-hint { flex: 1 0 100%; color: var(--ink-faint); font-size: 10px; }

/* ------------------------------------------------------------------ the sheet (phone, touch) */

.mdinf-backdrop {
	position: fixed;
	inset: 0;
	z-index: 10040;
	background: rgba(20, 12, 4, .42);
	opacity: 0;
	transition: opacity .16s ease;
}
.mdinf-backdrop.mdinf-on { opacity: 1; }

/* left, top, width and max-height are set by the script from window.visualViewport: the game's page
   is often WIDER than the phone (a 360px phone lays out 423px, more when something overflows), so
   bottom:0 of the layout viewport can sit below the visible screen. */
.mdinf-card.mdinf-sheet {
	max-width: none;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	transform: translateY(14px);
	border-radius: 14px;
}
.mdinf-card.mdinf-sheet.mdinf-on { transform: none; }
.mdinf-sheet .mdinf-close { flex-basis: 38px; width: 38px; height: 38px; font-size: 24px; line-height: 38px; margin: -6px -6px 0 0; }
.mdinf-sheet .mdinf-name { font-size: 17px; }
.mdinf-sheet .mdinf-text { font-size: 14px; }
.mdinf-sheet .mdinf-facts { font-size: 13.5px; row-gap: 5px; }
.mdinf-sheet .mdinf-facts dt { font-size: 10.5px; }
.mdinf-sheet .mdinf-fx span { font-size: 12px; padding: 5px 8px; }
.mdinf-sheet .mdinf-foot { font-size: 12px; }
.mdinf-sheet .mdinf-time { font-size: 12.5px; }

@media (prefers-reduced-motion: reduce) {
	.mdinf-card, .mdinf-backdrop, .mdinf-bar i { transition: none; }
	.mdinf-card, .mdinf-card.mdinf-sheet { transform: none; }
}
