/* Safety scenes for /features/credentials, on the shared `.pw` stage (`public/styles.css`). */

.feature-detail .secrets .pw {
	min-width: 0;
	max-width: 100%;
	--pw-sec-stop: light-dark(#8d2f2f, #f0c4c4);
	--pw-sec-on-stop: light-dark(#fff, #3b1414);
}

.feature-detail .secrets .pw .pw-wires {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
}

.feature-detail .secrets .pw p,
.feature-detail .secrets .pw small {
	max-width: none;
	margin: 0;
	line-height: 1.35;
}

/* Give each scene the wider grid column so the stage stays above the
   stacked breakpoint at desktop widths. */

@media (min-width: 801px) {
	.feature-detail .secrets .split,
	.feature-detail .secrets .ms-access-split {
		grid-template-columns: 0.85fr 1.15fr;
	}

	.feature-detail .secrets .ms-vault-split {
		grid-template-columns: 1.15fr 0.85fr;
	}

	.feature-detail .secrets .ms-drafts {
		grid-template-columns: 0.85fr 1.15fr;
	}
}

.feature-detail .secrets .ms-trip .controls {
	margin: 14px 0 0;
}

.feature-detail .secrets #secret-result {
	margin: 12px 0 0;
	padding: 10px 14px;
	border: 1px solid var(--border);
	border-radius: 12px;
	background: var(--surface);
	color: var(--text);
	font-size: 15px;
	font-weight: 650;
}

.feature-detail .secrets .ms-trip .smallprint {
	margin-top: 10px;
}

.pw.pw-scene-sec-trip,
.pw.pw-scene-sec-access,
.pw.pw-scene-sec-vault,
.pw.pw-scene-sec-draft {
	--sec-beat: 8s;
	--sec-send: 2.4s;
}

.pw.pw-secrets .pw-wire:not([data-on]) .pw-pulse {
	animation: none;
	opacity: 0;
}

.pw.pw-secrets[data-motion] .pw-wire[data-on] .pw-pulse {
	animation-duration: var(--sec-beat, 8s);
}

/* Shared product-card chrome. Cards sit by their top-left corner (or left
   edge, vertically centred) instead of `.pw-node`'s centre. */

.pw .pw-sec-card {
	translate: 0 -50%;
	flex-direction: column;
	align-items: stretch;
	gap: 0.32em;
	padding: 0.6em 0.7em 0.65em;
	font-size: 0.84em;
	line-height: 1.35;
	white-space: normal;
}

.pw .pw-sec-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.35em 0.4em;
	min-width: 0;
	padding-bottom: 0.35em;
	border-bottom: 1px solid var(--pw-line);
}

.pw .pw-sec-head strong {
	font-weight: 650;
	min-width: 0;
}

.pw .pw-sec-pill {
	align-self: flex-start;
	margin-left: auto;
	padding: 0.05em 0.45em;
	border: 1px solid var(--pw-line);
	border-radius: 99em;
	color: var(--pw-ink);
	font-size: 0.9em;
	font-weight: 650;
	white-space: nowrap;
}

.pw .pw-sec-k {
	color: var(--pw-muted);
	font-size: 0.9em;
}

.pw .pw-kicker {
	font-size: 0.9em;
}

.pw .pw-sec-card code {
	font-family: ui-monospace, monospace;
	font-size: 0.92em;
	white-space: nowrap;
}

.pw .pw-sec-ref {
	align-self: flex-start;
	padding: 0.2em 0.4em;
	border-radius: 0.35em;
	background: var(--pw-soft);
	color: var(--pw-ink);
	font-weight: 650;
}

.pw .pw-sec-mask {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.3em 0.5em;
}

.pw .pw-sec-mask code,
.pw .pw-sec-mask-code {
	letter-spacing: 0.04em;
	color: var(--pw-muted);
}

.pw .pw-sec-mask small {
	padding: 0 0.4em;
	border: 1px dashed var(--pw-line);
	border-radius: 0.3em;
}

.pw .pw-sec-mask small,
.pw .pw-sec-locked small,
.pw .pw-sec-you small,
.pw .pw-sec-source small {
	color: var(--pw-muted);
	font-size: 0.9em;
}

.pw .pw-sec-rule {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.4em;
	padding: 0.12em 0.4em;
	border-radius: 0.35em;
	font-family: ui-monospace, monospace;
	font-size: 0.92em;
}

.pw .pw-sec-rule b {
	flex: none;
	min-width: 1.2em;
	font-weight: 700;
	text-align: right;
}

.pw .pw-sec-rule[data-on],
.pw .pw-sec-row[data-on] {
	--sec-wash: var(--pw-soft);
	--sec-ink: var(--pw-accent);
	background: var(--sec-wash);
	box-shadow: inset 0.18em 0 var(--sec-ink);
}

.pw .pw-sec-rule[data-on][data-verdict='fail'],
.pw .pw-sec-row[data-on][data-verdict='fail'] {
	--sec-wash: color-mix(in oklab, var(--pw-sec-stop) 18%, var(--pw-surface));
	--sec-ink: var(--pw-sec-stop);
}

.pw .pw-sec-rule[data-verdict='fail'] b {
	color: var(--pw-sec-stop);
}

.pw .pw-sec-rule[data-verdict='pass'] b {
	color: var(--pw-ink);
}

/* Wire chips stay put between cards; motion only emphasises them. */

.pw .pw-sec-chip {
	position: absolute;
	z-index: 1;
	translate: -50% -50%;
	padding: 0.1em 0.5em;
	border: 1px solid var(--pw-accent);
	border-radius: 99em;
	background: var(--pw-soft);
	color: var(--pw-text);
	font:
		650 0.76em/1.35 ui-monospace,
		monospace;
	white-space: nowrap;
}

.pw .pw-sec-lane-key,
.pw .pw-sec-chip-key {
	border-color: var(--pw-ink);
}

.pw .pw-sec-flow {
	display: none;
}

.pw .pw-sec-stamp,
.pw .pw-sec-deny {
	display: grid;
	place-items: center;
	border-radius: 50%;
	background: var(--pw-sec-stop);
	color: var(--pw-sec-on-stop);
	font-weight: 800;
}

.pw .pw-sec-stamp {
	position: absolute;
	z-index: 2;
	translate: -50% -50%;
	width: 1.5em;
	height: 1.5em;
	font-size: 0.9em;
}

.pw .pw-sec-deny {
	width: 1.25em;
	height: 1.25em;
	font-size: 0.9em;
}

/* Hero: the reference reaches Kody's allowlist; the key leaves only after send. */

.pw-scene-sec-trip .pw-sec-card {
	translate: none;
	width: 43%;
}

.pw-scene-sec-trip .pw-sec-agent {
	height: 47%;
}

.pw-scene-sec-trip .pw-sec-kody {
	height: 43%;
}

.pw-scene-sec-trip .pw-sec-host {
	height: 100%;
}

.pw .pw-sec-ask {
	font-weight: 600;
}

.pw .pw-sec-host-name {
	color: var(--pw-text);
	font-weight: 650;
}

.pw .pw-sec-auth {
	font-weight: 600;
}

.pw .pw-sec-bearer {
	flex: none;
	height: 1.6em;
	padding-top: 0.2em;
	overflow: hidden;
	border-top: 1px dashed var(--pw-line);
	line-height: 1.35;
}

.pw .pw-sec-out {
	position: absolute;
	z-index: 2;
	display: grid;
	place-items: center;
	translate: -50% -50%;
}

.pw .pw-sec-out > .pw-sec-chip,
.pw .pw-sec-out > .pw-sec-stamp {
	position: static;
	translate: none;
}

.pw .pw-sec-out-idle {
	display: none;
}

.pw .pw-sec-http {
	display: flex;
	flex-direction: column;
	gap: 0.1em;
	flex: none;
	height: calc(3lh + 0.9em);
	margin-top: auto !important;
	padding: 0.35em 0.45em;
	border-radius: 0.4em;
	background: var(--pw-soft);
	font-family: ui-monospace, monospace;
	font-size: 0.92em;
}

.pw-scene-sec-trip .pw-run:not([data-sent]) .pw-sec-bearer,
.pw-scene-sec-trip .pw-run:not([data-sent]) .pw-sec-http {
	color: var(--pw-muted);
}

.pw-scene-sec-trip[data-motion] .pw-sec-chip-ref {
	animation: pw-sec-chip var(--sec-beat) var(--pw-ease) infinite;
}

.pw-scene-sec-trip[data-motion] .pw-sec-rule[data-on] {
	animation: pw-sec-flash var(--sec-beat) var(--pw-ease) infinite;
}

.pw-scene-sec-trip[data-motion] .pw-run[data-sent] .pw-sec-chip-ref {
	animation: pw-sec-chip-once var(--sec-send) var(--pw-ease) 1 both;
}

.pw-scene-sec-trip[data-motion] .pw-run[data-sent] .pw-sec-rule[data-on] {
	animation: pw-sec-flash-once var(--sec-send) var(--pw-ease) 1 both;
}

.pw-scene-sec-trip[data-motion] .pw-sec-lane-key,
.pw-scene-sec-trip[data-motion] .pw-sec-stamp {
	animation: pw-sec-pop var(--sec-send) var(--pw-ease) 1 both;
}

.pw-scene-sec-trip[data-motion] .pw-run[data-sent] .pw-sec-bearer,
.pw-scene-sec-trip[data-motion] .pw-run[data-sent] .pw-sec-http {
	animation: pw-sec-reveal var(--sec-send) var(--pw-ease) 1 both;
}

@keyframes pw-sec-chip {
	0%,
	6%,
	26%,
	100% {
		scale: 1;
		box-shadow: 0 0 0 0 transparent;
	}
	14% {
		scale: 1.08;
		box-shadow: 0 0 0 0.3em
			color-mix(in oklab, var(--pw-accent) 28%, transparent);
	}
}

@keyframes pw-sec-chip-once {
	0%,
	22%,
	100% {
		scale: 1;
		box-shadow: 0 0 0 0 transparent;
	}
	8% {
		scale: 1.08;
		box-shadow: 0 0 0 0.3em
			color-mix(in oklab, var(--pw-accent) 28%, transparent);
	}
}

@keyframes pw-sec-flash {
	0%,
	24%,
	48%,
	100% {
		box-shadow: inset 0.18em 0 var(--sec-ink);
	}
	32% {
		box-shadow:
			inset 0.18em 0 var(--sec-ink),
			0 0 0 0.22em color-mix(in oklab, var(--sec-ink) 30%, transparent);
	}
}

@keyframes pw-sec-flash-once {
	0%,
	10%,
	34%,
	100% {
		box-shadow: inset 0.18em 0 var(--sec-ink);
	}
	20% {
		box-shadow:
			inset 0.18em 0 var(--sec-ink),
			0 0 0 0.22em color-mix(in oklab, var(--sec-ink) 30%, transparent);
	}
}

@keyframes pw-sec-pop {
	0%,
	14% {
		opacity: 0;
		scale: 0.6;
	}
	24% {
		opacity: 1;
		scale: 1.12;
	}
	32%,
	100% {
		opacity: 1;
		scale: 1;
	}
}

@keyframes pw-sec-reveal {
	0%,
	24% {
		opacity: 0;
		transform: translateY(0.3em);
	}
	40%,
	100% {
		opacity: 1;
		transform: none;
	}
}

/* Approvals: the request arrives and the matching rule answers. */

.pw .pw-sec-request {
	width: 38%;
}

.pw .pw-sec-request strong {
	font-size: 1.05em;
	font-weight: 650;
}

.pw .pw-sec-note {
	padding-top: 0.3em;
	border-top: 1px dashed var(--pw-line);
	font-size: 0.9em;
}

.pw .pw-sec-sheet {
	width: 54%;
	gap: 0.4em;
}

.pw .pw-sec-row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	gap: 0.12em 0.4em;
	padding: 0.35em 0.5em;
	border-radius: 0.4em;
	white-space: nowrap;
}

.pw .pw-sec-row code {
	grid-column: 1 / -1;
	font-size: 0.92em;
}

.pw .pw-sec-row b {
	min-width: 4.4em;
	padding: 0.04em 0.5em;
	border-radius: 99em;
	font-size: 0.9em;
	text-align: center;
}

.pw .pw-sec-row[data-on] b {
	background: light-dark(
		color-mix(in oklab, var(--sec-ink) 85%, black),
		var(--sec-ink)
	);
	color: var(--pw-on-accent);
	font-weight: 700;
}

.pw .pw-sec-row[data-verdict='fail'][data-on] b {
	color: var(--pw-sec-on-stop);
}

.pw .pw-sec-row:not([data-on]) b {
	color: var(--pw-muted);
	font-weight: 500;
}

.pw-scene-sec-access[data-motion] .pw-sec-request {
	animation: pw-sec-nudge var(--sec-beat) var(--pw-ease) infinite;
}

.pw-scene-sec-access[data-motion] .pw-sec-row[data-on] {
	animation: pw-sec-flash var(--sec-beat) var(--pw-ease) infinite;
}

.pw-scene-sec-access[data-motion] .pw-sec-row[data-on] b {
	animation: pw-sec-badge var(--sec-beat) var(--pw-ease) infinite;
}

@keyframes pw-sec-nudge {
	0%,
	20%,
	100% {
		box-shadow:
			0 1px 1px var(--pw-shadow),
			0 0.2em 0.6em var(--pw-shadow);
	}
	10% {
		box-shadow:
			0 0 0 0.2em color-mix(in oklab, var(--pw-accent) 26%, transparent),
			0 0.2em 0.6em var(--pw-shadow);
	}
}

@keyframes pw-sec-badge {
	0%,
	30%,
	42%,
	100% {
		scale: 1;
	}
	36% {
		scale: 1.14;
	}
}

/* Vault: the model keeps a reference. The value is fetched at the boundary. */

.pw-scene-sec-vault .pw-sec-card {
	translate: none;
}

.pw .pw-sec-model,
.pw .pw-sec-source {
	width: 42%;
	height: 46%;
}

.pw .pw-sec-boundary {
	width: 44%;
	height: 50%;
	padding-left: 1.3em;
	justify-content: center;
}

.pw .pw-sec-api {
	width: 44%;
	height: 38%;
}

.pw .pw-sec-op {
	display: flex;
	align-items: center;
	gap: 0.4em;
	padding-bottom: 0.35em;
	border-bottom: 1px solid var(--pw-line);
}

.pw .pw-sec-op-mark {
	flex: none;
	width: 1.15em;
	height: 1.15em;
	border-radius: 0.3em;
	background:
		radial-gradient(
			circle at 50% 42%,
			var(--pw-surface) 0 0.18em,
			transparent 0.2em
		),
		linear-gradient(var(--pw-accent), var(--pw-accent));
	box-shadow: inset 0 -0.35em 0 var(--pw-ink);
}

.pw .pw-sec-item {
	align-self: flex-start;
	margin-left: -0.3em;
	padding: 0 0.3em;
	border-radius: 0.3em;
	font-weight: 650;
}

.pw .pw-sec-glass {
	position: absolute;
	top: 0.55em;
	bottom: 0.55em;
	left: 0.55em;
	width: 0.28em;
	border-radius: 99em;
	background: var(--pw-accent);
}

.pw .pw-sec-hop {
	display: flex;
	flex-direction: column;
	gap: 0.15em;
	padding-top: 0.3em;
	border-top: 1px dashed var(--pw-line);
	font-family: ui-monospace, monospace;
	font-size: 0.92em;
}

.pw-scene-sec-vault[data-motion] .pw-sec-chip-ref {
	animation: pw-sec-chip var(--sec-beat) var(--pw-ease) infinite;
}

.pw-scene-sec-vault[data-motion] .pw-sec-chip-fetch {
	animation: pw-sec-chip var(--sec-beat) var(--pw-ease) infinite;
	animation-delay: calc(var(--sec-beat) * 0.2);
}

.pw-scene-sec-vault[data-motion] .pw-sec-source .pw-sec-item {
	animation: pw-sec-pick var(--sec-beat) var(--pw-ease) infinite;
}

.pw-scene-sec-vault[data-motion] .pw-sec-glass {
	animation: pw-sec-glass var(--sec-beat) var(--pw-ease) infinite;
}

.pw-scene-sec-vault[data-motion] .pw-sec-chip-key {
	animation: pw-sec-chip var(--sec-beat) var(--pw-ease) infinite;
	animation-delay: calc(var(--sec-beat) * 0.45);
}

.pw-scene-sec-vault[data-motion] .pw-sec-api .pw-sec-bearer {
	animation: pw-sec-pick var(--sec-beat) var(--pw-ease) infinite;
	animation-delay: calc(var(--sec-beat) * 0.4);
}

@keyframes pw-sec-pick {
	0%,
	16%,
	44%,
	100% {
		background: transparent;
	}
	22%,
	38% {
		background: var(--pw-soft);
	}
}

@keyframes pw-sec-glass {
	0%,
	40%,
	60%,
	100% {
		opacity: 1;
	}
	50% {
		opacity: 0.35;
	}
}

/* Drafts: a reply lands in Gmail. Send stays locked on the agent's side. */

.pw .pw-sec-composer {
	width: 32%;
}

.pw .pw-sec-gmail {
	width: 54%;
}

.pw .pw-sec-gmail-mark {
	display: grid;
	place-items: center;
	width: 1.25em;
	height: 1.25em;
	border-radius: 0.3em;
	background: var(--pw-accent);
	color: var(--pw-on-accent);
	font-size: 0.9em;
	font-weight: 800;
}

.pw .pw-sec-mail {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 0.05em 0.4em;
	padding: 0.3em 0.25em;
	border-top: 1px solid var(--pw-line);
	border-radius: 0.3em;
}

.pw .pw-sec-gmail .pw-sec-head + .pw-sec-mail {
	border-top: 0;
}

.pw .pw-sec-mail strong,
.pw .pw-sec-mail p {
	grid-column: 1 / -1;
}

.pw .pw-sec-mail p {
	color: var(--pw-muted);
	font-size: 0.92em;
}

.pw .pw-sec-who {
	font-weight: 650;
}

.pw .pw-sec-sendbar {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.4em;
}

.pw .pw-sec-locked,
.pw .pw-sec-you {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.1em 0.35em;
	padding: 0.3em 0.45em;
	border-radius: 0.4em;
}

.pw .pw-sec-locked {
	border: 1px dashed var(--pw-sec-stop);
	background: color-mix(in oklab, var(--pw-sec-stop) 12%, var(--pw-surface));
}

.pw .pw-sec-locked .pw-lock {
	margin-top: 0.35em;
	background: var(--pw-sec-stop);
}

.pw .pw-sec-locked .pw-lock::before {
	border-color: var(--pw-sec-stop);
}

.pw .pw-sec-you {
	border: 1px solid var(--pw-accent);
	background: var(--pw-soft);
}

.pw .pw-sec-ready {
	color: var(--pw-muted);
	font-size: 0.9em;
}

.pw .pw-sec-composer p {
	font-size: 1em;
}

.pw-scene-sec-draft[data-motion] .pw-sec-chip-draft {
	animation: pw-sec-chip var(--sec-beat) var(--pw-ease) infinite;
}

.pw-scene-sec-draft[data-motion] .pw-sec-mail-new {
	animation: pw-sec-pick var(--sec-beat) var(--pw-ease) infinite;
}

.pw-scene-sec-draft[data-motion] .pw-sec-locked .pw-lock {
	animation: pw-sec-shake var(--sec-beat) var(--pw-ease) infinite;
}

@keyframes pw-sec-shake {
	0%,
	62%,
	82%,
	100% {
		transform: none;
	}
	66% {
		transform: rotate(-10deg);
	}
	70% {
		transform: rotate(8deg);
	}
	74% {
		transform: rotate(-4deg);
	}
}

/* Narrow stages: cards stack in reading order and wire chips become
   in-flow connectors between them. */

@container (max-width: 520px) {
	.pw .pw-stage[data-stack] .pw-run {
		gap: 0.5em;
	}

	.feature-detail .secrets .pw .pw-stage[data-stack] .pw-wires {
		display: none;
	}

	.pw .pw-stage[data-stack] .pw-sec-card {
		height: auto;
		font-size: 0.92em;
	}

	.pw .pw-stage[data-stack] .pw-sec-chip,
	.pw .pw-stage[data-stack] .pw-sec-out,
	.pw .pw-stage[data-stack] .pw-sec-flow {
		position: relative;
		left: auto !important;
		top: auto !important;
		translate: none;
		align-self: center;
	}

	.pw .pw-stage[data-stack] .pw-sec-chip {
		font-size: 0.84em;
	}

	.pw .pw-stage[data-stack] .pw-sec-out {
		height: 1.9em;
	}

	.pw .pw-stage[data-stack] .pw-sec-out-idle {
		display: block;
		color: var(--pw-muted);
		font-weight: 650;
	}

	.pw .pw-stage[data-stack] .pw-sec-chip::before,
	.pw .pw-stage[data-stack] .pw-sec-flow::before {
		content: '↓ ';
	}

	.pw .pw-stage[data-stack] .pw-sec-http {
		margin-top: 0.2em !important;
	}

	.pw-scene-sec-vault .pw-stage[data-stack] .pw-sec-chip-ref,
	.pw-scene-sec-vault .pw-stage[data-stack] .pw-sec-chip-fetch {
		display: none;
	}

	.pw .pw-stage[data-stack] .pw-sec-flow {
		display: block;
		color: var(--pw-muted);
		font-size: 0.84em;
		font-weight: 600;
	}

	.pw .pw-stage[data-stack] .pw-sec-boundary {
		min-height: 0;
	}
}
