/*
 * PureCSS.com
 * https://purecss.com/text-on-border/
 * A title sitting on a box's border line, built with a real fieldset and legend and with a heading whose ::before and ::after draw the line.
 */

.demo-text-on-border .tb {
	display: grid;
	gap: 1.25rem;
	width: 100%;
	max-width: 46rem;
}

/* the position picker: real radios, clipped so the label is the pill and the arrow keys still work */
.demo-text-on-border .tb-align {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .4rem;
	min-inline-size: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.demo-text-on-border .tb-align legend {
	width: 100%;
	margin-bottom: .45rem;
	padding: 0;
	font-family: var(--font-mono);
	font-size: .7rem;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--text-muted);
}

.demo-text-on-border .tb-opt {
	position: relative;
	padding: .4rem .8rem;
	border: 1px solid var(--border);
	border-radius: 99rem;
	font-size: .85rem;
	font-weight: 600;
	color: var(--text);
	background: var(--surface-2);
	cursor: pointer;
}

.demo-text-on-border .tb-opt input {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: 0;
	overflow: hidden;
	clip-path: inset(50%);
}

.demo-text-on-border .tb-opt:has(:checked) {
	border-color: var(--accent);
	color: var(--bg);
	background: var(--accent);
}

.demo-text-on-border .tb-opt:has(:focus-visible) {
	outline: 2px solid var(--text);
	outline-offset: 2px;
}

/* a soft gradient canvas, so it shows that nothing is painted behind either
   title (it was a dot grid; owner, 2026-11-13: too busy behind the text) */
.demo-text-on-border .tb-stage {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
	gap: 1.5rem;
	padding: 1.5rem;
	border-radius: 14px;
	background-color: var(--bg);
	background-image: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, var(--bg)), var(--bg) 55%, color-mix(in srgb, var(--sky) 16%, var(--bg)));
}

.demo-text-on-border .tb-build {
	display: flex;
	flex-direction: column;
	gap: .6rem;
	min-width: 0;
}

.demo-text-on-border .tb-cap {
	margin: 0;
	font-family: var(--font-mono);
	font-size: .72rem;
	color: var(--text-muted);
}

/* build one: a real fieldset. The browser cuts the border where the legend sits, on any background. */
.demo-text-on-border .tb-fieldset {
	flex: 1;
	/* a fieldset will not shrink below its content by default (min-inline-size: min-content) */
	min-inline-size: 0;
	margin: 0;
	padding: .35rem 1.25rem 1.25rem;
	border: 2px solid var(--accent);
	border-radius: 12px;
}

/* the border runs through the middle of the legend's box, and the gap is the legend's
   border box, so its padding is the space either side of the words */
.demo-text-on-border .tb-legend {
	padding: 0 .6rem;
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.75rem;
	color: var(--text);
}

.demo-text-on-border .tb-row {
	display: grid;
	gap: .3rem;
	margin-top: .75rem;
	font-size: .8rem;
	color: var(--text-muted);
}

.demo-text-on-border .tb-input {
	width: 100%;
	min-width: 0;
	padding: .55rem .7rem;
	border: 1px solid var(--border);
	border-radius: 8px;
	font: inherit;
	font-size: .9rem;
	color: var(--text);
	background: var(--surface-2);
}

.demo-text-on-border .tb-input:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}

.demo-text-on-border .tb-input::placeholder {
	color: var(--text-muted);
	opacity: 1;
}

/* build two: a card. The heading is a flex row; its ::before and ::after are the top line
   and the two top corners, and the body below draws the sides and the bottom. */
.demo-text-on-border .tb-card {
	--tb-before: 0 0 calc(1.25rem + 2px);
	--tb-after: 1 1 0;
	flex: 1;
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.demo-text-on-border .tb-title {
	display: flex;
	align-items: flex-end;
	gap: .6rem;
	margin: 0;
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.75rem;
	color: var(--text);
}

/* half the 1.75rem row plus half the 2px line, so the line runs through the middle of the words */
.demo-text-on-border .tb-title::before,
.demo-text-on-border .tb-title::after {
	content: "";
	min-width: 12px;
	height: calc(.875rem + 1px);
	border-top: 2px solid var(--accent);
}

.demo-text-on-border .tb-title::before {
	flex: var(--tb-before);
	border-left: 2px solid var(--accent);
	border-top-left-radius: 12px;
}

.demo-text-on-border .tb-title::after {
	flex: var(--tb-after);
	border-right: 2px solid var(--accent);
	border-top-right-radius: 12px;
}

.demo-text-on-border .tb-body {
	flex: 1;
	padding: .35rem 1.25rem 1.25rem;
	border: 2px solid var(--accent);
	border-top: 0;
	border-radius: 0 0 12px 12px;
}

.demo-text-on-border .tb-list {
	display: grid;
	gap: .55rem;
	margin: .4rem 0 0;
	font-size: .9rem;
}

.demo-text-on-border .tb-list div {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding-bottom: .55rem;
	border-bottom: 1px solid var(--border);
}

.demo-text-on-border .tb-list div:last-child {
	padding-bottom: 0;
	border-bottom: 0;
}

.demo-text-on-border .tb-list dt {
	color: var(--text-muted);
}

.demo-text-on-border .tb-list dd {
	margin: 0;
	font-weight: 600;
	color: var(--text);
}

/* the picker moves both titles: auto margins for the legend, the flex split for the card */
.demo-text-on-border .tb:has(.tb-center:checked) .tb-legend {
	margin-inline: auto;
}

.demo-text-on-border .tb:has(.tb-right:checked) .tb-legend {
	margin-inline-start: auto;
}

.demo-text-on-border .tb:has(.tb-center:checked) .tb-card {
	--tb-before: 1 1 0;
	--tb-after: 1 1 0;
}

.demo-text-on-border .tb:has(.tb-right:checked) .tb-card {
	--tb-before: 1 1 0;
	--tb-after: 0 0 calc(1.25rem + 2px);
}

/* the home card: one centered card on the dotted canvas */
.card-preview .demo-text-on-border .tb {
	width: auto;
}

.card-preview .demo-text-on-border .tb-mini {
	grid-template-columns: 15rem;
	padding: 1rem 1.1rem 1.2rem;
}

.card-preview .demo-text-on-border .tb-mini .tb-body {
	display: grid;
	gap: .5rem;
	padding: .5rem 1.25rem 1.1rem;
}

.demo-text-on-border .tb-bar {
	display: block;
	height: .5rem;
	border-radius: 99rem;
	background: var(--border);
}

.demo-text-on-border .tb-bar:nth-child(2) {
	width: 75%;
}

.demo-text-on-border .tb-bar:nth-child(3) {
	width: 55%;
}

/* ── Variant: the "or" divider ── */

.demo-text-on-border .tb-or-demo {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
	gap: 1.5rem;
	width: 100%;
	max-width: 40rem;
}

.demo-text-on-border .tb-signin {
	display: grid;
	gap: .9rem;
	padding: 1.25rem;
	border: 1px solid var(--border);
	border-radius: 12px;
	background: var(--surface-2);
}

.demo-text-on-border .tb-btn {
	padding: .65rem 1rem;
	border: 1px solid var(--border);
	border-radius: 8px;
	font: inherit;
	font-size: .9rem;
	font-weight: 600;
	color: var(--text);
	background: var(--surface);
	cursor: pointer;
}

.demo-text-on-border .tb-btn-main {
	border-color: var(--accent);
	color: var(--bg);
	background: var(--accent);
}

.demo-text-on-border .tb-btn:focus-visible {
	outline: 2px solid var(--text);
	outline-offset: 2px;
}

/* the divider: a flex row whose ::before and ::after grow to fill the space either side of the word */
.demo-text-on-border .tb-or {
	display: flex;
	align-items: center;
	gap: .75rem;
	margin: 0;
	font-size: .8rem;
	color: var(--text-muted);
}

.demo-text-on-border .tb-or::before,
.demo-text-on-border .tb-or::after {
	content: "";
	flex: 1;
	border-top: 1px solid var(--border);
}

.demo-text-on-border .tb-chat {
	display: grid;
	gap: .6rem;
	margin: 0;
	padding: 1.25rem;
	border: 1px solid var(--border);
	border-radius: 12px;
	list-style: none;
	background: var(--surface-2);
}

.demo-text-on-border .tb-msg {
	justify-self: start;
	max-width: 85%;
	padding: .5rem .75rem;
	border-radius: 12px 12px 12px 4px;
	font-size: .85rem;
	color: var(--text);
	background: var(--surface);
}

.demo-text-on-border .tb-msg-me {
	justify-self: end;
	border-radius: 12px 12px 4px 12px;
	color: var(--bg);
	background: var(--sky);
}

/* the same divider in a color, for unread messages */
.demo-text-on-border .tb-or-new {
	font-weight: 700;
	color: var(--coral);
}

.demo-text-on-border .tb-or-new::before,
.demo-text-on-border .tb-or-new::after {
	border-top-color: var(--coral);
}

/* ── Variant: a label in a notch ── */

.demo-text-on-border .tb-fields {
	display: grid;
	gap: 1.1rem;
	width: 100%;
	max-width: 22rem;
}

/* the same build as the card: the label row draws the top line and corners, the input draws the rest */
.demo-text-on-border .tb-field {
	--tb-w: 1px;
	--tb-c: var(--text-muted);
	display: flex;
	flex-direction: column;
}

.demo-text-on-border .tb-notch {
	display: flex;
	align-items: flex-end;
	gap: .35rem;
	font-size: .8rem;
	font-weight: 600;
	line-height: 1.25rem;
	color: var(--text-muted);
	cursor: pointer;
}

/* half the 1.25rem row plus half the line */
.demo-text-on-border .tb-notch::before,
.demo-text-on-border .tb-notch::after {
	content: "";
	height: calc(.625rem + var(--tb-w) / 2);
	border-top: var(--tb-w) solid var(--tb-c);
}

.demo-text-on-border .tb-notch::before {
	flex: 0 0 .65rem;
	border-left: var(--tb-w) solid var(--tb-c);
	border-top-left-radius: 8px;
}

.demo-text-on-border .tb-notch::after {
	flex: 1;
	border-right: var(--tb-w) solid var(--tb-c);
	border-top-right-radius: 8px;
}

.demo-text-on-border .tb-notch-input {
	width: 100%;
	min-width: 0;
	/* the padding gives back what the thicker focus line takes, so the text never moves */
	padding: .2rem calc(.9rem - var(--tb-w)) calc(.8rem - var(--tb-w));
	border: var(--tb-w) solid var(--tb-c);
	border-top: 0;
	border-radius: 0 0 8px 8px;
	font: inherit;
	font-size: .95rem;
	color: var(--text);
	background: transparent;
	outline: none;
}

.demo-text-on-border .tb-notch-input::placeholder {
	color: var(--text-muted);
	opacity: 1;
}

/* focus: every piece reads the same two variables, so the whole outline changes at once */
.demo-text-on-border .tb-field:focus-within {
	--tb-w: 2px;
	--tb-c: var(--accent);
}

.demo-text-on-border .tb-field:focus-within .tb-notch {
	color: var(--accent);
}

/* checked only after the reader has typed and left the field */
.demo-text-on-border .tb-field:has(:user-invalid) {
	--tb-c: var(--coral);
}

.demo-text-on-border .tb-field:has(:user-invalid) .tb-notch {
	color: var(--coral);
}

.demo-text-on-border .tb-hint {
	margin: .35rem 0 0 .9rem;
	font-size: .75rem;
	color: var(--text-muted);
}

.demo-text-on-border .tb-field:has(:user-invalid) .tb-hint {
	color: var(--coral);
}

/* ── Variant: on a gradient ── */

.demo-text-on-border .tb-photo {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
	gap: 1.5rem;
	width: 100%;
	max-width: 46rem;
	padding: 2rem 1.5rem 1.5rem;
	border-radius: 14px;
	background:
		radial-gradient(circle at 15% 20%, #d6336c 0, transparent 42%),
		radial-gradient(circle at 85% 30%, #0e7c7b 0, transparent 45%),
		radial-gradient(circle at 50% 100%, #b5560c 0, transparent 50%),
		linear-gradient(135deg, #4b1d8f, #1d3fa8);
	--accent: #ffffff;
	--text: #ffffff;
	--text-muted: #ffffff;
	--border: rgba(255, 255, 255, .45);
}

.demo-text-on-border .tb-photo .tb-build {
	gap: .5rem;
}

.demo-text-on-border .tb-photo .tb-cap {
	font-weight: 600;
	text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}

.demo-text-on-border .tb-photo .tb-legend,
.demo-text-on-border .tb-photo .tb-title,
.demo-text-on-border .tb-photo .tb-patch-title,
.demo-text-on-border .tb-photo .tb-text {
	text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
}

.demo-text-on-border .tb-text {
	margin: .4rem 0 0;
	font-size: .9rem;
	line-height: 1.5;
	color: var(--text);
}

/* the common shortcut: lift the heading onto the border and hide the line behind a solid patch.
   The patch only disappears when its color matches what is behind the box. */
.demo-text-on-border .tb-patch {
	position: relative;
	flex: 1;
	/* lines its border up with the other two, whose title row sits half above the line */
	margin-top: calc(.875rem - 1px);
	padding: 1.2rem 1.25rem 1.25rem;
	border: 2px solid var(--accent);
	border-radius: 12px;
}

.demo-text-on-border .tb-patch-title {
	position: absolute;
	/* the padding box starts inside the 2px border: -1px puts the middle of the title on the line */
	top: -1px;
	left: 1.25rem;
	translate: 0 -50%;
	margin: 0;
	padding: 0 .6rem;
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.75rem;
	color: var(--text);
	background: #141415;
}
