/*
 * Guides and stories: reading details on top of Midground's own styles (tables, code, notes,
 * prompts, the "On this page" links). Loaded only on those pages (Stories::reading_assets).
 */

/* Headings land below the sticky header, not under it. */
html {
	scroll-padding-top: 120px;
}

/* ---------- Running text */

.mgs-prose p,
.mgs-prose li {
	max-width: 68ch;
}

.mgs-prose ul,
.mgs-prose ol {
	padding-left: 1.3em;
}

.mgs-prose li + li {
	margin-top: 0.45em;
}

.mgs-prose a,
.mgs-tip a,
.mgs-table a,
.mgs-byline a,
.mgs-guide .mg-accordion a {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.18em;
}

.mgs-prose code,
.mgs-tip code,
.mgs-table code,
.mgs-guide .mg-accordion code {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
	font-size: 0.88em;
	padding: 0.08em 0.36em;
	border-radius: 5px;
	background: color-mix(in srgb, var(--mg-c-line) 55%, transparent);
	overflow-wrap: anywhere;
}

/* Code inside a link takes the link's colour on the page's own background (contrast). */
.mgs-prose a code,
.mgs-tip a code,
.mgs-table a code,
.mgs-guide .mg-accordion a code {
	padding: 0;
	background: none;
	color: inherit;
}

.mgs-prose kbd {
	font-family: inherit;
	font-size: 0.85em;
	padding: 0.05em 0.4em;
	border: 1px solid var(--mg-c-line);
	border-bottom-width: 2px;
	border-radius: 5px;
	background: var(--mg-c-white);
}

/* Screenshots open in full size. */
.mgs-shot a {
	display: block;
	border-radius: var(--mg-r-m);
}

.mgs-shot figcaption {
	margin-top: 0.6rem;
	font-size: 0.9rem;
	color: var(--mg-c-stone);
}

/* ---------- Code: wraps instead of scrolling, so nothing is hidden on a phone */

.mgs-code {
	margin: 0;
	padding: 1rem 1.25rem;
	border-radius: var(--mg-r-m);
	background: var(--mg-c-ink);
	color: #ece8e1;
	font: 0.875rem/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	tab-size: 2;
}

.mgs-code code {
	font: inherit;
	color: inherit;
	background: none;
	padding: 0;
}

/* ---------- Notes and prompts */

.mgs-tip {
	padding: 1rem 1.25rem;
	border-left: 3px solid var(--mg-c-depth);
	border-radius: 0 var(--mg-r-m) var(--mg-r-m) 0;
	background: color-mix(in srgb, var(--mg-c-depth) 8%, var(--mg-c-white));
}

.mgs-tip p {
	margin: 0;
	max-width: 68ch;
}

.mgs-prompt {
	position: relative;
	padding: 1rem 1.25rem 1.1rem;
	border: 1px solid var(--mg-c-line);
	border-radius: var(--mg-r-m);
	background: var(--mg-c-paper);
}

.mgs-prompt__label {
	margin: 0 0 0.5rem;
	padding-right: 6.5rem;
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--mg-c-stone);
}

.mgs-prompt__text {
	margin: 0;
	font: 0.92rem/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
	overflow-wrap: anywhere;
}

.mgs-copy {
	position: absolute;
	top: 0.7rem;
	right: 0.7rem;
	padding: 0.3rem 0.75rem;
	border: 1px solid var(--mg-c-line);
	border-radius: 999px;
	background: var(--mg-c-white);
	color: var(--mg-c-ink);
	font-family: inherit;
	font-size: 0.8rem;
	font-weight: 600;
	line-height: 1.4;
	cursor: pointer;
}

.mgs-copy:hover {
	border-color: var(--mg-c-ink);
}

.mgs-copy:focus-visible {
	outline: 2px solid var(--mg-c-accent);
	outline-offset: 2px;
}

/* ---------- Tables: rows become cards on phones */

.mgs-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.95rem;
	line-height: 1.5;
}

.mgs-table th {
	padding: 0.55rem 1rem 0.55rem 0;
	border-bottom: 2px solid var(--mg-c-ink);
	text-align: left;
	vertical-align: bottom;
	font-weight: 650;
}

.mgs-table td {
	padding: 0.65rem 1rem 0.65rem 0;
	border-bottom: 1px solid var(--mg-c-line);
	vertical-align: top;
}

.mgs-table td:first-child {
	font-weight: 600;
}

@media (max-width: 600px) {
	.mgs-table thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}

	.mgs-table,
	.mgs-table tbody,
	.mgs-table tr,
	.mgs-table td {
		display: block;
	}

	.mgs-table tr {
		padding: 0.7rem 0;
		border-bottom: 1px solid var(--mg-c-line);
	}

	.mgs-table td {
		padding: 0.15rem 0;
		border: 0;
	}

	.mgs-table td::before {
		content: attr(data-label);
		display: block;
		font-size: 0.72rem;
		font-weight: 700;
		letter-spacing: 0.06em;
		text-transform: uppercase;
		color: var(--mg-c-stone);
	}
}

/* ---------- On this page */

.mgs-toc nav {
	font-size: 0.95rem;
}

.mgs-toc__title {
	margin: 0 0 0.7rem;
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--mg-c-stone);
}

.mgs-toc ul {
	margin: 0;
	padding: 0;
	list-style: none;
	border-left: 1px solid var(--mg-c-line);
}

.mgs-toc li {
	margin: 0;
}

.mgs-toc a {
	display: block;
	margin-left: -1px;
	padding: 0.32rem 0 0.32rem 1rem;
	border-left: 2px solid transparent;
	color: var(--mg-c-stone);
	text-decoration: none;
}

.mgs-toc a:hover {
	color: var(--mg-c-ink);
}

.mgs-toc a[aria-current="true"] {
	border-left-color: var(--mg-c-accent);
	color: var(--mg-c-ink);
	font-weight: 600;
}

@media (max-width: 1199.98px) {
	.mgs-toc ul {
		display: flex;
		flex-wrap: wrap;
		gap: 0.5rem;
		border: 0;
	}

	.mgs-toc a,
	.mgs-toc a[aria-current="true"] {
		margin: 0;
		padding: 0.35rem 0.85rem;
		border: 1px solid var(--mg-c-line);
		border-radius: 999px;
		font-weight: 500;
	}
}

/* ---------- Heading of a guide */

.mgs-live strong {
	display: inline-flex;
	align-items: center;
	gap: 0.45em;
	margin-right: 0.5em;
	font-size: 0.75rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--mg-c-accent);
}

.mgs-live strong::before {
	content: "";
	width: 0.55em;
	height: 0.55em;
	border-radius: 50%;
	background: currentColor;
	box-shadow: 0 0 0 0.25em color-mix(in srgb, currentColor 22%, transparent);
}

/* Cards that link to a guide. */
.mgs-guide-card h3 a {
	text-decoration: none;
}

.mgs-guide-card h3 a:hover {
	text-decoration: underline;
	text-underline-offset: 0.18em;
}

.mgs-on-dark .mgs-guide-card p {
	color: var(--mg-c-mute);
}
