/* ============================================================
   Home v4 — S4 Apps (.rc4-apps) "Apps built around how you work."
   The private database bar on top; under it the Budget app (left,
   the working one) and the four other apps (right), every app wired
   to the database by one rail; a return wire, "Plans back in", runs
   from the Budget app back up into the database. Phones and tablets:
   one column, the rail down the left edge.
   Markup is the final frame. assets/js/v4/apps.js (api.scene) adds
   .is-rc4-rewound to the figure while it is below the start line:
   only the new data waits (ports hollow, results ghosted, the return
   wire dashed). Packets ride the wires as each app is reached; .is-on
   (an app got its numbers), .is-back (the plan rides back) and
   .is-marked (the one yellow mark) carry the beats.
   One cut-corner object: the Budget app window. One filled button:
   Publish plan. Under the plan's table one result line redraws with the
   lever (and is what a screen reader hears): "Westside at +3%: $24,329 a
   week. Its market supports $31,500." The scene's one action is the
   quiet "Try the budget lever" link under the lead (to /apps/#budget).
   Glob order puts this file before hero.css (shared chip).
   ============================================================ */

/* The head: the H2 wraps balanced and the lead never ends on one word alone. */
.rc4-apps .rc-section__head h2 { text-wrap: balance; }
.rc4-apps .rc-section__head p { text-wrap: pretty; }

/* The scene's one action: a quiet text link under the lead (same as the Quick answers link). */
.rc4-apps .rc4-apps__link {
	display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-top: -10px;
	font: 500 15px/1.4 var(--rc-font-sans); color: var(--rc-purple-lt); text-decoration: none;
}
.rc4-apps .rc4-apps__link svg { flex: none; transition: transform .18s var(--rc-ease); }
.rc4-apps .rc4-apps__link:hover,
.rc4-apps .rc4-apps__link:focus-visible { color: #fff; }
.rc4-apps .rc4-apps__link:hover svg,
.rc4-apps .rc4-apps__link:focus-visible svg { transform: translateX(3px); }
.rc4-apps .rc4-apps__link:focus-visible { outline: 2px solid var(--rc-purple-lt); outline-offset: 4px; }

.rc4-apps {
	--rc4a-gap: 44px;   /* database bar -> apps: the room the return wire climbs */
	--rc4a-gut: 56px;   /* the rail runs down the middle of this gutter */
	--rc4a-py: 30px;    /* port centre, from the top of an app card */
	--rc4a-bpy: 66px;   /* the Budget app's port centre */
	--rc4a-rg: 14px;    /* row gap between the stacked apps */
}

.rc4-apps .rc4-apps__fig { position: relative; margin: 0; min-width: 0; }

/* ---------- Database bar ---------- */
.rc4-apps .rc4-apps__db {
	position: relative; z-index: 1;
	display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
	min-height: 56px; padding: 10px 14px 10px 16px;
	background: #1D1C33;          /* rgba(91,79,196,.12) over the page, opaque so wires meet it cleanly */
	border: 1px solid var(--rc-purple-lt);
}
.rc4-apps .rc4-apps__db-ico {
	width: 20px; height: 20px; flex: none; color: var(--rc-purple-lt);
	fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.rc4-apps .rc4-apps__db-name { font: 600 17px/1.2 var(--rc-font-display); letter-spacing: -0.005em; color: #fff; }
.rc4-apps .rc4-apps__db-sub { font: 500 12px/1.3 var(--rc-font-mono); letter-spacing: 0.04em; color: var(--rc-text-mute); }
.rc4-apps .rc4-apps__tag { margin-left: auto; }

/* ---------- Apps grid: Budget | rail | four apps ---------- */
.rc4-apps .rc4-apps__grid {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 7fr) var(--rc4a-gut) minmax(0, 5fr);
	row-gap: var(--rc4a-rg);
	margin-top: var(--rc4a-gap);
}
/* The rail: from the database bar down to the last app's port (into the last row by gap + port). */
.rc4-apps .rc4-apps__rail {
	grid-column: 2; grid-row: 1 / 4;
	justify-self: center; width: 2px;
	margin-top: calc(-1 * var(--rc4a-gap));
	margin-bottom: calc(-1 * (var(--rc4a-rg) + var(--rc4a-py) + 1px));
	background: var(--rc-line-bright);
}
/* The return wire: Budget app -> database, the page's way back in. */
.rc4-apps .rc4-apps__ret {
	position: absolute; z-index: 2;
	left: 64px; top: calc(-1 * var(--rc4a-gap)); height: var(--rc4a-gap);
	display: flex; align-items: center; gap: 10px;
	pointer-events: none;
}
.rc4-apps .rc4-apps__ret-line { position: relative; align-self: stretch; width: 2px; background: var(--rc-purple-lt); }
.rc4-apps .rc4-apps__ret-line::before {
	content: ""; position: absolute; left: 50%; top: 1px;
	width: 7px; height: 7px; margin-left: -3.5px; box-sizing: border-box;
	border-top: 2px solid var(--rc-purple-lt); border-left: 2px solid var(--rc-purple-lt);
	transform: rotate(45deg);
}
/* The scene's one yellow "look here": the underline under "Plans back in". */
.rc4-apps .rc4-apps__ret-lbl {
	padding-bottom: 3px;
	font: 500 12px/1.3 var(--rc-font-mono); letter-spacing: 0.04em; color: var(--rc-purple-lt); white-space: nowrap;
	background: linear-gradient(var(--rc-yellow), var(--rc-yellow)) 0 100% / 100% 2px no-repeat;
}

/* ---------- App cards ---------- */
.rc4-apps .rc4-apps__card {
	position: relative; min-width: 0; margin: 0;
	grid-column: 3;
	display: flex; flex-direction: column; gap: 7px;
	padding: 14px 18px;
	background: var(--rc-card);
	border: 1px solid var(--rc-line-strong);
}
.rc4-apps .rc4-apps__budget { grid-column: 1; grid-row: 1 / span 4; gap: 14px; padding: 20px; }
/* Custom: the dashed "not there yet" outline, the one app that is yours to name. */
.rc4-apps .rc4-apps__card--custom { background: transparent; border: 1px dashed var(--rc-line-bright); }

/* Port: an 8px square on the card edge; its stub runs to the rail. */
.rc4-apps .rc4-apps__port {
	position: absolute; z-index: 1;
	left: -5px; top: calc(var(--rc4a-py) - 5px);
	width: 8px; height: 8px; box-sizing: border-box;
	background: var(--rc-purple-lt); border: 1px solid var(--rc-purple-lt);
	transition: background-color .2s var(--rc-ease-out), border-color .2s var(--rc-ease-out);
}
.rc4-apps .rc4-apps__port::before {
	content: ""; position: absolute; top: 2px; height: 2px;
	right: 100%; width: calc(var(--rc4a-gut) / 2 - 3px);
	background: var(--rc-line-bright);
}
.rc4-apps .rc4-apps__budget .rc4-apps__port { left: auto; right: -5px; top: calc(var(--rc4a-bpy) - 5px); }
.rc4-apps .rc4-apps__budget .rc4-apps__port::before { right: auto; left: 100%; }

.rc4-apps .rc4-apps__name {
	display: flex; align-items: center; gap: 10px; margin: 0;
	font: 600 19px/1.2 var(--rc-font-display); letter-spacing: -0.01em; color: #fff;
}
.rc4-apps .rc4-apps__budget .rc4-apps__name { font-size: 22px; }
.rc4-apps .rc4-apps__ico {
	width: 20px; height: 20px; flex: none; color: var(--rc-purple-lt);
	fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.rc4-apps .rc4-apps__desc { margin: 0; font: 400 14.5px/1.5 var(--rc-font-sans); color: var(--rc-text-soft); text-wrap: pretty; }
.rc4-apps .rc4-apps__out {
	margin: 2px 0 0; padding-top: 8px; border-top: 1px solid var(--rc-line);
	font: 500 12.5px/1.45 var(--rc-font-mono); color: var(--rc-text);
	text-wrap: pretty;
	transition: opacity .3s var(--rc-ease-out), transform .3s var(--rc-ease-out);
}
.rc4-apps .rc4-apps__out b { font-weight: 500; color: #fff; }

/* Budget: reads -> you set -> writes back. */
.rc4-apps .rc4-apps__chain {
	list-style: none; margin: 0; padding: 0;
	display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
	border: 1px solid var(--rc-line);
}
.rc4-apps .rc4-apps__chain li {
	position: relative; margin: 0; padding: 10px 12px 11px 14px;
	font: 400 13.5px/1.4 var(--rc-font-sans); color: var(--rc-text-soft);
	text-wrap: pretty;
}
.rc4-apps .rc4-apps__chain li + li { border-left: 1px solid var(--rc-line); }
.rc4-apps .rc4-apps__chain li + li::before {
	content: ""; position: absolute; left: -5px; top: 50%;
	width: 8px; height: 8px; margin-top: -4px; box-sizing: border-box;
	border-top: 1px solid var(--rc-line-bright); border-right: 1px solid var(--rc-line-bright);
	background: var(--rc-card); transform: rotate(45deg);
}
.rc4-apps .rc4-apps__chain b {
	display: block; margin-bottom: 2px;
	font: 500 12px/16px var(--rc-font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--rc-purple-lt);
}

/* ---------- The Budget app window: the scene's one cut-corner object ---------- */
.rc4-apps .rc4-apps__win {
	--cut: 12px;
	position: relative;
	background: var(--rc-bg-rise);
	box-shadow: inset 0 0 0 1px var(--rc-line-strong);
	clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
}
.rc4-apps .rc4-apps__win::before,
.rc4-apps .rc4-apps__win::after {
	content: ""; position: absolute; z-index: 1; width: var(--cut); height: var(--cut); pointer-events: none;
}
.rc4-apps .rc4-apps__win::before {
	top: 0; left: 0;
	background: linear-gradient(to bottom right, transparent 50%, var(--rc-line-strong) 50%, var(--rc-line-strong) calc(50% + 1px), transparent calc(50% + 1px));
}
.rc4-apps .rc4-apps__win::after {
	right: 0; bottom: 0;
	background: linear-gradient(to bottom right, transparent calc(50% - 1px), var(--rc-line-strong) calc(50% - 1px), var(--rc-line-strong) 50%, transparent 50%);
}
.rc4-apps .rc4-apps__wbar {
	display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 14px;
	padding: 9px 12px 9px 20px; border-bottom: 1px solid var(--rc-line-strong);
	font: 500 12px/16px var(--rc-font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--rc-text-mute);
}
.rc4-apps .rc4-apps__ver { color: var(--rc-text-soft); }

/* The lever: Westside growth +3% / +8% / +12% (works; JS enables the buttons). */
.rc4-apps .rc4-apps__lever {
	display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
	padding: 13px 12px; border-bottom: 1px solid var(--rc-line);
}
.rc4-apps .rc4-apps__lever-lbl { font: 400 14px/1.3 var(--rc-font-sans); color: var(--rc-text-soft); }
.rc4-apps .rc4-apps__seg { display: inline-flex; border: 1px solid var(--rc-line-strong); }
.rc4-apps .rc4-apps__seg button {
	min-width: 58px; min-height: 40px; margin: 0; padding: 0 12px;
	border: 0; border-left: 1px solid var(--rc-line-strong); border-radius: 0;
	background: var(--rc-bg); color: var(--rc-text-soft);
	font: 500 13px/1 var(--rc-font-mono); letter-spacing: 0.04em;
	cursor: pointer; -webkit-appearance: none; appearance: none;
	transition: color .15s var(--rc-ease), background-color .15s var(--rc-ease);
}
.rc4-apps .rc4-apps__seg button:first-child { border-left: 0; }
.rc4-apps .rc4-apps__seg button[aria-pressed="true"] { background: var(--rc-card-soft); color: #fff; box-shadow: inset 0 -2px 0 var(--rc-purple-lt); }
.rc4-apps .rc4-apps__seg button:not([aria-pressed="true"]):not([disabled]):hover { color: var(--rc-text); background: var(--rc-card); }
.rc4-apps .rc4-apps__seg button[disabled] { cursor: default; }
.rc4-apps .rc4-apps__seg button:focus-visible { outline: 2px solid var(--rc-purple-lt); outline-offset: -2px; }

/* The grid of the plan. */
.rc4-apps .rc4-apps__table { width: 100%; border-collapse: collapse; }
.rc4-apps .rc4-apps__table th,
.rc4-apps .rc4-apps__table td { padding: 10px 12px; border-bottom: 1px solid var(--rc-line); text-align: left; vertical-align: middle; }
.rc4-apps .rc4-apps__table thead th {
	font: 500 12px/16px var(--rc-font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--rc-text-mute);
}
.rc4-apps .rc4-apps__table tbody th { font: 400 14px/1.3 var(--rc-font-sans); color: var(--rc-text); }
.rc4-apps .rc4-apps__table td {
	font: 500 13px/1.3 var(--rc-font-mono); color: var(--rc-text-soft);
	font-variant-numeric: tabular-nums; white-space: nowrap;
}
.rc4-apps .rc4-apps__table .n { text-align: right; }
.rc4-apps .rc4-apps__table .rc4-apps__next { color: #fff; transition: opacity .3s var(--rc-ease-out); }
/* The cell the lever edits: outlined in the focus colour. */
.rc4-apps .rc4-apps__table .rc4-apps__g { color: #fff; outline: 1px solid var(--rc-purple-lt); outline-offset: -1px; }
/* "This year" folds under the location name on narrow phones (see below); whichever copy shows is the one read. */
.rc4-apps .rc4-apps__sub { display: none; }
.rc4-apps .rc4-apps__more { margin: 0; padding: 7px 12px 0; font: 400 12px/1.4 var(--rc-font-mono); color: var(--rc-text-mute); text-align: right; }
/* What the lever does, in one line that redraws with each press (an aria-live region). */
.rc4-apps .rc4-apps__result {
	margin: 0; padding: 10px 12px 0;
	font: 400 14px/1.5 var(--rc-font-sans); color: var(--rc-text-soft);
	text-wrap: pretty;
	transition: opacity .3s var(--rc-ease-out);
}
.rc4-apps .rc4-apps__result b { font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rc4-apps .rc4-apps__hint { margin: 0; padding: 2px 12px 0; font: 400 13px/1.5 var(--rc-font-sans); color: var(--rc-text-mute); }
.rc4-apps .rc4-apps__try { white-space: nowrap; }
.rc4-apps .rc4-apps__try.is-off { visibility: hidden; }

.rc4-apps .rc4-apps__foot {
	display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
	margin-top: 12px; padding: 12px 12px 14px; border-top: 1px solid var(--rc-line);
}
.rc4-apps .rc4-apps__log { flex: 1 1 220px; margin: 0; font: 500 12px/1.55 var(--rc-font-mono); color: var(--rc-text-soft); }
.rc4-apps .rc4-apps__l2 { display: block; }
.rc4-apps .rc4-apps__ok { display: inline-flex; align-items: center; gap: 5px; color: #8FD9B1; white-space: nowrap; }
.rc4-apps .rc4-apps__ok svg { width: 12px; height: 12px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.rc4-apps .rc4-apps__pub {
	flex: none; min-height: 40px; margin: 0; padding: 0 16px;
	border: 0; border-radius: 0;
	background: var(--rc-purple); color: #fff;
	font: 600 13px/1 var(--rc-font-display); letter-spacing: 0.06em; text-transform: uppercase;
	cursor: pointer; -webkit-appearance: none; appearance: none;
	clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
	transition: background-color .15s var(--rc-ease), color .15s var(--rc-ease);
}
.rc4-apps .rc4-apps__pub:not([disabled]):hover { background: var(--rc-purple-dk); }
.rc4-apps .rc4-apps__pub[disabled] { cursor: default; }
.rc4-apps .rc4-apps__pub.is-published,
.rc4-apps .rc4-apps__pub.is-published:hover { background: var(--rc-card-soft); color: var(--rc-text-mute); cursor: default; }
.rc4-apps .rc4-apps__pub:focus-visible { outline: 2px solid var(--rc-purple-lt); outline-offset: -4px; }

/* Packets riding the wires (created by apps.js). */
.rc4-apps .rc4-apps__pk {
	position: absolute; left: 0; top: 0; z-index: 3;
	width: 6px; height: 6px; margin: -3px 0 0 -3px;
	background: var(--rc-purple-lt); pointer-events: none;
}

/* ---------- Before state (only while the figure is rewound) ---------- */
.rc4-apps .rc4-apps__fig.is-rc4-rewound .rc4-apps__card:not(.is-on) .rc4-apps__port { background: var(--rc-card); border-color: var(--rc-line-bright); }
.rc4-apps .rc4-apps__fig.is-rc4-rewound .rc4-apps__card:not(.is-on) .rc4-apps__out { opacity: var(--rc4-ghost); transform: translateY(4px); }
.rc4-apps .rc4-apps__fig.is-rc4-rewound .rc4-apps__budget:not(.is-on) :is(.rc4-apps__next, .rc4-apps__result) { opacity: var(--rc4-ghost); }
.rc4-apps .rc4-apps__fig.is-rc4-rewound:not(.is-back) .rc4-apps__ret-line {
	background: repeating-linear-gradient(180deg, var(--rc-purple-lt) 0 4px, transparent 4px 8px);
	opacity: 0.5;
}
.rc4-apps .rc4-apps__fig.is-rc4-rewound:not(.is-back) .rc4-apps__ret-line::before { opacity: 0; }
.rc4-apps .rc4-apps__fig.is-rc4-rewound .rc4-apps__ret-lbl { transition: background-size .45s var(--rc-ease-out); }
.rc4-apps .rc4-apps__fig.is-rc4-rewound:not(.is-marked) .rc4-apps__ret-lbl { background-size: 0 2px; }

/* ---------- Mid widths ---------- */
@media (max-width: 1140px) {
	.rc4-apps { --rc4a-gut: 48px; }
	.rc4-apps .rc4-apps__budget { padding: 18px; }
}

/* ---------- Tablets and phones: one column, the rail down the left edge ---------- */
@media (max-width: 999px) {
	.rc4-apps { --rc4a-gut: 24px; --rc4a-gap: 42px; }
	.rc4-apps .rc4-apps__grid { grid-template-columns: var(--rc4a-gut) minmax(0, 1fr); }
	.rc4-apps .rc4-apps__card,
	.rc4-apps .rc4-apps__budget { grid-column: 2; grid-row: auto; }
	.rc4-apps .rc4-apps__rail { grid-column: 1; grid-row: 1 / 5; }
	.rc4-apps .rc4-apps__budget .rc4-apps__port { left: -5px; right: auto; }
	.rc4-apps .rc4-apps__budget .rc4-apps__port::before { left: auto; right: 100%; }
	/* the return wire climbs on the right; its label reads to its left */
	.rc4-apps .rc4-apps__ret { left: auto; right: 44px; flex-direction: row-reverse; }
}
@media (max-width: 760px) {
	.rc4-apps .rc__container { padding-left: 16px; padding-right: 16px; }
	.rc4-apps { --rc4a-gut: 22px; --rc4a-py: 28px; --rc4a-bpy: 28px; --rc4a-rg: 12px; --rc4a-gap: 40px; }
	.rc4-apps .rc4-apps__db { padding: 10px 12px; }
	.rc4-apps .rc4-apps__card { padding: 14px; }
	.rc4-apps .rc4-apps__budget { padding: 14px; gap: 12px; }
	.rc4-apps .rc4-apps__name { font-size: 18px; }
	.rc4-apps .rc4-apps__budget .rc4-apps__name { font-size: 20px; }
	.rc4-apps .rc4-apps__desc { font-size: 14px; }
	/* the chain stacks; its arrows turn down */
	.rc4-apps .rc4-apps__chain { grid-template-columns: minmax(0, 1fr); }
	.rc4-apps .rc4-apps__chain li { padding: 8px 12px; }
	.rc4-apps .rc4-apps__chain li + li { border-left: 0; border-top: 1px solid var(--rc-line); }
	.rc4-apps .rc4-apps__chain li + li::before { left: 18px; top: -5px; margin-top: 0; transform: rotate(135deg); }
	.rc4-apps .rc4-apps__chain b { display: inline; margin: 0 8px 0 0; }
	.rc4-apps .rc4-apps__wbar { padding-left: 18px; }
	.rc4-apps .rc4-apps__table th,
	.rc4-apps .rc4-apps__table td { padding: 8px 9px; }
	.rc4-apps .rc4-apps__foot { flex-direction: column; align-items: flex-start; }
	.rc4-apps .rc4-apps__log { flex: none; }
}
/* Labels step up to 13px under 720px (Blueprint, Type); the status chip keeps the 12px chip size. */
@media (max-width: 719px) {
	.rc4-apps :is(.rc4-apps__db-sub, .rc4-apps__ret-lbl, .rc4-apps__chain b, .rc4-apps__wbar, .rc4-apps__table thead th, .rc4-apps__more, .rc4-apps__log, .rc4-apps__out) { font-size: 13px; }
}
@media (max-width: 480px) {
	/* "Run rate" moves under each location name, so the grid keeps three columns at 320px */
	.rc4-apps .rc4-apps__ty { display: none; }
	.rc4-apps .rc4-apps__sub {
		display: block; margin-top: 2px;
		font: 500 13px/1.3 var(--rc-font-mono); letter-spacing: 0; text-transform: none; color: var(--rc-text-mute);
	}
	.rc4-apps .rc4-apps__seg button { min-width: 52px; padding: 0 10px; }
}
/* Under 520px the window bar's version always takes its own row: the draft string ("v7 draft · v6 official")
   wraps there and the published one ("v7 official") would not, so Publish would move the plan up 18px. */
@media (max-width: 519px) {
	.rc4-apps .rc4-apps__ver { flex-basis: 100%; }
}
/* Two phrases joined by a dot stack, and the dot goes, below the width where they fit on one line
   (with room to spare), so no line ends or starts on a dot: the Forecast card's line under 414px
   (it fits from about 404px), the log's first line under 390px (from about 374px). */
@media (max-width: 413px) {
	.rc4-apps .rc4-apps__osep { display: none; }
	.rc4-apps .rc4-apps__o2 { display: block; }
}
@media (max-width: 389px) {
	.rc4-apps .rc4-apps__lsep { display: none; }
	.rc4-apps .rc4-apps__lb { display: block; }
}
/* 360px and narrower: the whole plan fits inside the window (it would run under the cut corner):
   tighter cells and card, and each location's run rate (a value, not a label) at 12px. */
@media (max-width: 360px) {
	.rc4-apps .rc4-apps__budget { padding: 14px 10px; }
	.rc4-apps .rc4-apps__table th,
	.rc4-apps .rc4-apps__table td { padding: 8px 6px; }
	.rc4-apps .rc4-apps__table tbody .rc4-apps__sub { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
	.rc4-apps *, .rc4-apps *::before, .rc4-apps *::after { transition: none !important; animation: none !important; }
	.rc4-apps .rc4-apps__pk { display: none; }
}
