/* Embeds: the pages other sites frame (`embed::embed_frame`, `embed_profile`, `embed_post`) and the
   embed-code dialog (`embed::embed_dialog`). Colours come from tokens.css only; the root of an embed
   sets its own data-theme and data-ink, so every token below follows the author's ink. */

/* An embed document is only its card, which fills the frame edge to edge. The document is painted
   with the paper too: a browser paints an opaque backdrop behind a frame whose colour scheme differs
   from the host page's, and the frame's height is whole pixels, so a transparent document would show
   that backdrop as a hairline under the card. The embed code rounds the iframe itself with the
   card's radius, which clips the corners. */
html:has([data-c='embed-frame']),
html:has([data-c='embed-frame']) body {
	background: var(--paper);
	min-height: 0;
}

@scope ([data-c='embed-frame']) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
		gap: var(--s3);
		padding: var(--s4);
		border: 1px solid var(--line);
		border-radius: var(--r-card);
		background: var(--paper);
		color: var(--ink);
		overflow: hidden;
	}

	:scope[data-kind='full'] {
		padding-top: 0;
	}

	.foot {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: var(--s3);
		padding-top: var(--s3);
		border-top: 1px solid var(--line);
		font-size: var(--t-sm);
	}

	.open {
		display: inline-flex;
		align-items: center;
		gap: var(--s1);
		color: var(--ink);
		font-weight: 500;
		text-decoration: none;
	}

	.open:hover,
	.open:focus-visible {
		text-decoration: underline;
	}

	.home {
		display: inline-flex;
		color: var(--ink-dim);
		text-decoration: none;
	}

	.home:hover,
	.home:focus-visible {
		color: var(--ink);
	}
}

@scope ([data-c='embed-profile']) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
		gap: var(--s3);
		min-width: 0;
	}

	.banner {
		position: relative;
		height: 120px;
		margin: 0 calc(var(--s4) * -1) calc(var(--s6) * -1);
		overflow: hidden;
		background: var(--surface);
		border-bottom: 1px solid var(--line);
	}

	.banner img {
		display: block;
		width: 100%;
		height: 100%;
		object-fit: cover;
	}

	.person {
		position: relative;
		display: flex;
		align-items: center;
		gap: var(--s3);
		min-width: 0;
	}

	.face {
		flex: none;
		display: inline-flex;
		padding: var(--s1);
		background: var(--paper);
	}

	.who {
		display: flex;
		flex-direction: column;
		min-width: 0;
		color: var(--ink);
		text-decoration: none;
		font-size: var(--t-lg);
		font-weight: 600;
		line-height: 1.2;
	}

	.who:hover .handle,
	.who:focus-visible .handle {
		text-decoration: underline;
	}

	.handle {
		overflow: hidden;
		color: var(--ink-dim);
		font-family: var(--font-mono);
		font-size: var(--t-sm);
		font-weight: 400;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.bio {
		overflow-wrap: anywhere;
		white-space: pre-line;
	}

	.facts {
		display: flex;
		flex-wrap: wrap;
		gap: var(--s2) var(--s4);
		color: var(--ink-dim);
		font-size: var(--t-sm);
	}

	.item {
		display: inline-flex;
		align-items: center;
		gap: var(--s1);
		min-width: 0;
	}

	.item a {
		color: var(--ink);
	}

	.counts {
		display: flex;
		flex-wrap: wrap;
		gap: var(--s2) var(--s4);
		color: var(--ink-dim);
		font-size: var(--t-sm);
	}

	.counts a {
		color: inherit;
		text-decoration: none;
	}

	.counts a:hover,
	.counts a:focus-visible {
		text-decoration: underline;
	}

	.counts b {
		color: var(--ink);
		font-weight: 600;
	}

	.posts {
		display: flex;
		flex-direction: column;
		border-top: 1px solid var(--line);
	}

	.posts > [role='listitem'] {
		padding: var(--s3) 0;
		border-bottom: 1px solid var(--line);
	}

	.posts > [role='listitem']:last-child {
		border-bottom: 0;
	}

	.empty {
		padding: var(--s4) 0;
		border-top: 1px solid var(--line);
		color: var(--ink-dim);
		text-align: center;
	}
}

@scope ([data-c='embed-post']) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
		gap: var(--s2);
		min-width: 0;
	}

	.context,
	.reply-to {
		display: flex;
		align-items: center;
		gap: var(--s1);
		color: var(--ink-dim);
		font-size: var(--t-sm);
	}

	.context a {
		color: inherit;
		text-decoration: none;
	}

	header {
		display: flex;
		align-items: center;
		gap: var(--s3);
		min-width: 0;
	}

	.face {
		flex: none;
		display: inline-flex;
	}

	.who {
		display: flex;
		flex-direction: column;
		min-width: 0;
		color: var(--ink);
		font-weight: 600;
		line-height: 1.25;
		text-decoration: none;
	}

	.who:hover .handle,
	.who:focus-visible .handle {
		text-decoration: underline;
	}

	.handle {
		overflow: hidden;
		color: var(--ink-dim);
		font-family: var(--font-mono);
		font-size: var(--t-sm);
		font-weight: 400;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.body {
		display: flex;
		flex-direction: column;
		gap: var(--s3);
	}

	.text {
		font-size: var(--t-lg);
		line-height: 1.45;
		overflow-wrap: anywhere;
		white-space: pre-line;
	}

	:scope.entry .text {
		font-size: var(--t-md);
	}

	.meta {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		justify-content: space-between;
		gap: var(--s2) var(--s4);
		color: var(--ink-dim);
		font-size: var(--t-sm);
	}

	.time {
		color: inherit;
		text-decoration: none;
	}

	.time:hover,
	.time:focus-visible {
		color: var(--ink);
		text-decoration: underline;
	}

	.counts {
		display: inline-flex;
		gap: var(--s4);
	}

	.count {
		display: inline-flex;
		align-items: center;
		gap: var(--s1);
		font-variant-numeric: tabular-nums;
	}
}

@scope ([data-c='embed-dialog']) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
		gap: var(--s4);
	}

	.lead {
		color: var(--ink-dim);
	}

	.choice {
		display: flex;
		flex-wrap: wrap;
		gap: var(--s2);
		border: 0;
	}

	.choice[hidden] {
		display: none;
	}

	legend {
		width: 100%;
		margin-bottom: var(--s2);
		font-weight: 600;
	}

	.choice label {
		display: inline-flex;
		align-items: center;
		gap: var(--s2);
		min-height: 36px;
		padding: 0 var(--s3);
		border: 1px solid var(--line);
		border-radius: var(--r-pill);
		cursor: pointer;
	}

	.choice label:has(:checked) {
		border-color: var(--ink);
		background: var(--ink);
		color: var(--paper-on-ink);
	}

	.choice input {
		accent-color: var(--ink);
	}

	.choice label:has(:checked) input {
		accent-color: var(--paper-on-ink);
	}

	.choice label:has(:focus-visible) {
		outline: 2px solid var(--ink);
		outline-offset: 2px;
	}

	.preview {
		padding: var(--s3);
		border: 1px solid var(--line);
		border-radius: var(--r-card);
		background: var(--surface);
		overflow: auto;
		max-height: 50vh;
	}

	/* Rounded like the iframe of the embed code (`embed.js` `snippet`), so it shows what a site gets. */
	.preview iframe {
		display: block;
		width: 100%;
		height: 360px;
		border: 0;
		border-radius: var(--r-card);
	}

	.code {
		display: flex;
		flex-direction: column;
		gap: var(--s2);
		font-weight: 600;
	}

	textarea {
		width: 100%;
		padding: var(--s3);
		border: 1px solid var(--line);
		border-radius: var(--r-ctl);
		background: var(--surface);
		color: var(--ink);
		font-family: var(--font-mono);
		font-size: var(--t-xs);
		font-weight: 400;
		resize: vertical;
	}

	textarea:focus-visible {
		outline: 2px solid var(--ink);
		outline-offset: 1px;
	}
}
