/* Tarnside: what the theme cannot say. Unlayered, so each rule wins over
   Yeti without a specificity fight. Three kinds of rule live here: the
   card index's own furniture, the fit between Web Awesome's parts and this
   page, and what shows while Web Awesome has not loaded. */

/* The faces. Yeti ships no fonts and expects the page to load its own. */
@font-face {
	font-family: "Libre Franklin";
	src: url("/yeti/examples/webawesome/fonts/libre-franklin-latin.woff2") format("woff2");
	font-weight: 100 900;
	font-display: swap;
}
@font-face {
	font-family: "Courier Prime";
	src: url("/yeti/examples/webawesome/fonts/courier-prime-latin-400.woff2") format("woff2");
	font-weight: 400;
	font-display: swap;
}
@font-face {
	font-family: "Courier Prime";
	src: url("/yeti/examples/webawesome/fonts/courier-prime-latin-700.woff2") format("woff2");
	font-weight: 700;
	font-display: swap;
}

/* ---- The card index's own furniture ---- */

/* Whatever was typed onto a card. */
.typed {
	font-family: var(--yeti-font-mono);
}

/* The drawer front: the library's name on its label, a heavy rule under. */
body > header {
	background-color: var(--yeti-color-surface-sunken);
	border-block-end: 1px solid var(--yeti-color-border-strong);
}
h1 {
	font-size: var(--yeti-text-xl);
	font-weight: 800;
	letter-spacing: -0.01em;
}
/* Printed headings on the guides and the index. */
h2 {
	font-size: var(--yeti-text-md);
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}
#join-note,
body > footer p {
	font-size: var(--yeti-text-sm);
	color: var(--yeti-color-text-muted);
	max-inline-size: 70ch;
}
/* On a wide bar the note sits before the switch and keeps its place while
   hidden, so turning the join on moves nothing. On a narrow one it opens
   under the switch. */
@media (min-width: 64rem) {
	.join {
		flex-direction: row-reverse;
	}
	#join-note[hidden] {
		display: block;
		visibility: hidden;
	}
}
/* Narrower than that, the note takes a line of its own under the bar's
   row, so the switch that was just pressed stays where it was. */
@media not (min-width: 64rem) {
	.join {
		display: contents;
	}
	#join-note {
		flex-basis: 100%;
	}
}
/* Yeti draws the switch's thumb as a circle whatever the radius tokens
   say; here nothing is round, so the thumb is a square of the same size. */
.field input[type="checkbox"][role="switch"] {
	background-image: linear-gradient(var(--yeti-switch-thumb), var(--yeti-switch-thumb));
	background-size: 0.8em 0.8em;
	background-position: 0.2em 50%;
}
.field input[type="checkbox"][role="switch"]:checked {
	background-image: linear-gradient(var(--yeti-control-surface), var(--yeti-control-surface));
	background-position: calc(100% - 0.2em) 50%;
}
#index-count,
#index-empty {
	color: var(--yeti-color-text-muted);
}
#index-count {
	font-size: var(--yeti-text-sm);
}

/* The index: one ruled row per card. */
.index {
	border-block-start: 1px solid var(--yeti-color-border);
}
.index > li {
	max-inline-size: none;
	border-block-end: 1px solid var(--yeti-color-border);
}
.index a {
	display: grid;
	grid-template-columns: 4.5rem max-content minmax(0, 1fr) auto;
	gap: var(--yeti-space-sm);
	align-items: center;
	padding: var(--yeti-space-xs) var(--yeti-space-sm);
	color: inherit;
	text-decoration: none;
}
.index img {
	inline-size: 4.5rem;
	block-size: 3rem;
	object-fit: cover;
}
.index .typed {
	white-space: nowrap;
}
.index .typed::before {
	/* The guide's tab color, as the dot a filing clerk sticks on a card. */
	content: "";
	display: inline-block;
	inline-size: 0.6em;
	block-size: 0.6em;
	margin-inline-end: 0.45em;
	background-color: var(--tab);
}
.index a:hover {
	background-color: var(--yeti-color-surface-raised);
}
/* The pulled card's row is a filled tab. */
.index a[aria-current="true"] {
	background-color: var(--yeti-color-primary);
	color: var(--yeti-on-primary);
}
.index a[aria-current="true"] .typed {
	font-weight: 700;
}
.index a[aria-current="true"] .stamp {
	color: inherit;
}
/* Focus is a pair of printed brackets round the row. */
.index a:focus-visible {
	outline: none;
	background-image:
		linear-gradient(var(--yeti-color-focus), var(--yeti-color-focus)),
		linear-gradient(var(--yeti-color-focus), var(--yeti-color-focus)),
		linear-gradient(var(--yeti-color-focus), var(--yeti-color-focus)),
		linear-gradient(var(--yeti-color-focus), var(--yeti-color-focus)),
		linear-gradient(var(--yeti-color-focus), var(--yeti-color-focus)),
		linear-gradient(var(--yeti-color-focus), var(--yeti-color-focus));
	background-repeat: no-repeat;
	background-size: 3px 100%, 3px 100%, 0.7rem 3px, 0.7rem 3px, 0.7rem 3px, 0.7rem 3px;
	background-position: left, right, left top, left bottom, right top, right bottom;
}
.index a[aria-current="true"]:focus-visible {
	background-image:
		linear-gradient(var(--yeti-on-primary), var(--yeti-on-primary)),
		linear-gradient(var(--yeti-on-primary), var(--yeti-on-primary)),
		linear-gradient(var(--yeti-on-primary), var(--yeti-on-primary)),
		linear-gradient(var(--yeti-on-primary), var(--yeti-on-primary)),
		linear-gradient(var(--yeti-on-primary), var(--yeti-on-primary)),
		linear-gradient(var(--yeti-on-primary), var(--yeti-on-primary));
}
.index > li[data-void] .line {
	text-decoration: line-through;
}

/* A narrow index drops the stamp and stacks number over line. */
#desk > [slot="start"] {
	container-type: inline-size;
}
@container (inline-size < 27rem) {
	.index a {
		grid-template-columns: 3.5rem minmax(0, 1fr) auto;
		column-gap: var(--yeti-space-xs);
		row-gap: 0;
		padding-inline: var(--yeti-space-xs);
	}
	.index img {
		grid-area: 1 / 1 / 3 / 2;
		inline-size: 3.5rem;
		block-size: 2.75rem;
	}
	.index .typed {
		grid-area: 1 / 2;
	}
	.index .stamp {
		grid-area: 1 / 3;
		font-size: 0.625rem;
		letter-spacing: 0.08em;
		border-width: 2px;
		border-style: solid;
	}
	.index .line {
		grid-area: 2 / 2 / 3 / 4;
	}
}

/* Rubber stamps: tracked capitals in a double-ruled box, a few degrees
   off square. */
.stamp {
	display: inline-block;
	padding: 0.15em 0.5em;
	border: 3px double currentColor;
	font-family: var(--yeti-font-sans);
	font-size: var(--yeti-text-xs);
	font-weight: 800;
	letter-spacing: 0.12em;
	line-height: 1.2;
	text-transform: uppercase;
	white-space: nowrap;
	rotate: -3deg;
	color: var(--yeti-color-primary-text);
}
.stamp[data-ink="red"] {
	color: var(--yeti-color-alert-text);
	rotate: 2deg;
}
.stamp[data-ink="green"] {
	color: var(--yeti-color-success-text);
}
.stamps {
	display: inline-flex;
	gap: var(--yeti-space-xs);
}

/* The pulled card. Its guide tab stands above its top edge. */
#pulled {
	container-type: inline-size;
	padding-block-start: 0.7rem;
}
#pulled .card {
	position: relative;
	overflow: visible;
}
#pulled .card::before {
	content: "";
	position: absolute;
	inset-block-end: 100%;
	inset-inline-end: var(--yeti-space-lg);
	inline-size: 4rem;
	block-size: 0.7rem;
	background-color: var(--tab);
}
/* The print is shown whole, in a well, never cropped: Yeti's card crops
   its picture to a ratio, and a library must not. Then the red head rule. */
#pulled .card > figure {
	background-color: var(--yeti-color-surface-sunken);
	border-block-end: 3px solid var(--yeti-color-alert);
	position: relative;
	container-type: inline-size;
}
#pulled .card > figure > img {
	aspect-ratio: auto;
	inline-size: 100%;
	block-size: auto;
	object-fit: contain;
}
/* Side by side, the card fills its pane and the print takes whatever
   height the entries below leave it. Stacked, the print keeps its width. */
#desk:defined:not([data-stacked]) #pulled {
	display: flex;
	flex-direction: column;
}
#desk:defined:not([data-stacked]) #pulled .card {
	flex: 1 0 auto;
}
#desk:defined:not([data-stacked]) #pulled .card > figure {
	flex: 1 1 13rem;
	min-block-size: 13rem;
}
#desk:defined:not([data-stacked]) #pulled .card > figure > img {
	position: absolute;
	inset: 0;
	block-size: 100%;
}
/* The card's buttons stay at the foot of its pane while the card scrolls
   under them, so Edit and Withdraw are always to hand. */
#desk:defined:not([data-stacked]) #pulled .card > footer {
	position: sticky;
	inset-block-end: 0;
	padding-block: var(--yeti-space-sm);
	background-color: var(--yeti-card-surface);
}
#pulled .card h3 {
	font-size: var(--yeti-text-xl);
	font-weight: 700;
}
#pulled .card [data-caption] {
	max-inline-size: 62ch;
}

/* The card's printed boxes: a label in the corner, the entry typed in. */
.fields {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	border-block-start: 1px solid var(--yeti-color-border);
	border-inline-start: 1px solid var(--yeti-color-border);
}
.fields > div {
	margin: 0;
	padding: var(--yeti-space-xs) var(--yeti-space-sm);
	border-inline-end: 1px solid var(--yeti-color-border);
	border-block-end: 1px solid var(--yeti-color-border);
}
.fields > [data-half] {
	grid-column: 1 / -1;
}
.fields dt {
	font-size: var(--yeti-text-xs);
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--yeti-color-text-muted);
}
.fields dd {
	margin: 0;
}
/* A wide card sets its four short boxes in one row. */
@container (inline-size > 34rem) {
	.fields {
		grid-template-columns: 2fr 1.3fr 1.3fr 0.8fr;
	}
	.fields > [data-half] {
		grid-column: span 2;
	}
}

/* Withdrawn: nothing is deleted. The card takes a VOID stamp across its
   print and its caption is struck. */
#pulled .card[data-void] > figure::after {
	content: "Void";
	position: absolute;
	inset: 0;
	margin: auto;
	inline-size: fit-content;
	block-size: fit-content;
	padding: 0.05em 0.35em;
	border: 0.14em double currentColor;
	background-color: color-mix(in oklab, var(--yeti-color-surface-raised) 86%, transparent);
	color: var(--yeti-color-alert-text);
	font-family: var(--yeti-font-sans);
	font-size: clamp(2.5rem, 16cqi, 5rem);
	font-weight: 800;
	letter-spacing: 0.14em;
	line-height: 1;
	text-transform: uppercase;
	rotate: -11deg;
	animation: stamp 200ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
#pulled .card[data-void] [data-caption] {
	text-decoration: line-through;
	color: var(--yeti-color-text-muted);
}
@keyframes stamp {
	from {
		scale: 1.7;
		rotate: -3deg;
		opacity: 0;
	}
}
@media (prefers-reduced-motion: reduce) {
	#pulled .card[data-void] > figure::after {
		animation: none;
	}
}

/* ---- The fit between Web Awesome's parts and this page ---- */

/* The desk: index and card side by side, each scrolling in its own half,
   so the card never leaves when the index is long. */
#desk:defined:not([data-stacked]) {
	block-size: max(30rem, calc(100dvh - 16.25rem));
	--min: 15rem;
	--max: calc(100% - 20rem);
	--divider-width: 3px;
}
#desk:defined:not([data-stacked]) > [slot] {
	block-size: 100%;
	overflow: auto;
}
#desk:defined:not([data-stacked]) > [slot="end"] {
	padding-inline-start: var(--yeti-space-md);
}
#desk::part(divider) {
	background-color: var(--yeti-color-border-strong);
}
/* Too narrow for two halves: the split panel lets go and the index sits
   above the card. page.js sets data-stacked from the desk's own width. */
#desk[data-stacked] {
	display: block;
}
#desk[data-stacked]::part(divider) {
	display: none;
}
#desk[data-stacked] > [slot="end"] {
	margin-block-start: var(--yeti-space-md);
}

/* Guides: a thin indent rule, the tab color as a dot, the count typed. */
wa-tree {
	--indent-guide-width: 1px;
	--indent-guide-color: var(--yeti-color-border);
}
wa-tree-item .tab {
	display: inline-block;
	inline-size: 0.65em;
	block-size: 0.65em;
	margin-inline-end: 0.5em;
	background-color: var(--tab);
}
wa-tree-item .count {
	margin-inline-start: 0.5em;
	font-family: var(--yeti-font-mono);
	color: var(--yeti-color-text-muted);
}
/* The open guide is a filled tab, like the pulled card's row; Web
   Awesome marks it with a stripe down one side instead. */
wa-tree-item[selected]::part(item) {
	background-color: var(--yeti-color-primary);
	color: var(--yeti-on-primary);
	border-inline-start-color: transparent;
}
wa-tree-item[selected] > .count {
	color: inherit;
}

/* The edit drawer, and a label that matches Web Awesome's own. */
wa-drawer {
	--size: min(30rem, 100vw);
}
[data-label] {
	font-weight: var(--yeti-weight-strong);
}
/* The mark is made in the same ink as everything else on the card. */
wa-select {
	--tag-max-size: 26ch;
}
wa-rating {
	--symbol-color: var(--yeti-color-border);
	--symbol-color-active: var(--yeti-color-primary);
}

/* Show the join: every part Web Awesome draws takes a dashed outline. */
[data-join] :is(wa-tree, wa-tag-input, wa-select, wa-rating, wa-color-picker),
[data-join] wa-drawer::part(dialog) {
	outline: 2px dashed var(--yeti-color-primary);
	outline-offset: 3px;
}
/* The split panel draws only its divider, so the divider itself goes
   dashed and a little wider. */
[data-join] #desk {
	--divider-width: 7px;
}
[data-join] #desk::part(divider) {
	background-color: transparent;
	background-image: repeating-linear-gradient(to bottom, var(--yeti-color-primary) 0 8px, transparent 8px 14px);
}

/* ---- While Web Awesome has not loaded, or cannot ---- */

wa-drawer:not(:defined) {
	display: none;
}
body:has(wa-drawer:not(:defined)) [data-edit] {
	display: none;
}
wa-tree:not(:defined) wa-tree-item {
	display: block;
	padding-inline-start: var(--yeti-space-md);
}
wa-split-panel:not(:defined) {
	display: block;
}
wa-split-panel:not(:defined) > [slot="end"] {
	margin-block-start: var(--yeti-space-md);
}
