/*
 * CMHS modes, contract v1 (docs/reference/COMPANION_MODES.md in the CMHS repository).
 *
 * Master copy in companions/shared/; each app carries a byte-identical copy at
 * public/<app>/cmhs-modes.css. Link it after the app's own stylesheets.
 *
 * The values below are copies of the Society's website tokens (resources/css/tokens.css is the source
 * of truth; the CMHS name of each is in the comment). These apps are deployed as static trees and
 * cannot load the site's build, so the copy is deliberate: change a value there first, then here.
 */
:root {
	--cmhs-chrome-panel: #fdfbf7;        /* --chrome-panel-solid */
	--cmhs-chrome-tab: #f6f0e8;          /* --chrome-tab */
	--cmhs-chrome-ink: #1d1a18;          /* --chrome-ink */
	--cmhs-chrome-ink-soft: #57504b;     /* --chrome-ink-soft */
	--cmhs-chrome-bronze: #8a5a17;       /* --chrome-bronze */
	--cmhs-chrome-edge: rgb(168 113 42 / 32%);        /* --chrome-edge */
	--cmhs-chrome-edge-strong: rgb(168 113 42 / 60%); /* --chrome-edge-strong */
	--cmhs-chrome-radius: 20px;          /* --chrome-radius */
	--cmhs-chrome-shadow: 0 12px 34px rgb(62 40 20 / 13%), 0 2px 6px rgb(62 40 20 / 7%), inset 0 1px 0 rgb(255 255 255 / 85%); /* --chrome-shadow */
	--cmhs-brand-deep: #541e1b;          /* --brand-deep */
	--cmhs-night-ink: #f4efe6;           /* --night-ink */
	--cmhs-gold-soft: #d9ae4a;           /* --gold-soft */
	--cmhs-paper: #f4efe6;               /* --paper */
	--cmhs-focus: #0b63b5;               /* --focus */
	--cmhs-font-body: 'Source Sans CMHS', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif; /* --font-body */
	--cmhs-vp-top: 0px;
	--cmhs-vp-height: 100vh;
}

/* ------------------------------------------------------------------ standalone: the ribbon */

.cmhs-ribbon {
	position: relative;
	z-index: 2147483000;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 0.15rem 0.85rem;
	box-sizing: border-box;
	width: 100%;
	margin: 0;
	padding: 0.4rem 1rem;
	background-color: var(--cmhs-brand-deep);
	border-block-end: 1px solid rgb(217 174 74 / 45%);
	color: var(--cmhs-night-ink);
	font-family: var(--cmhs-font-body);
	font-size: 0.875rem;
	font-weight: 400;
	line-height: 1.35;
	letter-spacing: 0;
	text-align: center;
}

.cmhs-ribbon__part {
	color: var(--cmhs-night-ink);
}

.cmhs-ribbon__back,
.cmhs-ribbon__back:visited {
	color: var(--cmhs-night-ink);
	font-weight: 600;
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}

.cmhs-ribbon__back:hover {
	text-decoration-thickness: 2px;
}

.cmhs-ribbon__back:focus-visible {
	outline: 3px solid var(--cmhs-night-ink);
	outline-offset: 2px;
	border-radius: 2px;
}

.cmhs-ribbon__back::before {
	content: '\2190\00a0';
	text-decoration: none;
	display: inline-block;
}

/* ------------------------------------------------------------------ embedded */

html[data-cmhs-mode='embedded'] .cmhs-ribbon,
html[data-cmhs-mode='embedded'] [data-cmhs-brand] {
	display: none !important;
}

/*
 * The frame grows to fit the document, so the frame's viewport IS the document: anything sized from
 * the viewport would grow with every height report. html/body heights are reset here; each app
 * resets its own viewport-sized rules. `flow-root` stops a last child's margin collapsing through
 * <body>, which would put it outside the box cmhs-modes.js measures.
 */
html[data-cmhs-mode='embedded'],
html[data-cmhs-mode='embedded'] body {
	height: auto !important;
	min-height: 0 !important;
	max-height: none !important;
	overflow: hidden !important;
}

html[data-cmhs-mode='embedded'] body {
	display: flow-root;
}

/*
 * The sub-bar: the app's working controls as a lower tier of the Society's floating header — the same
 * near-white panel, copper hairline and radius (design call A, 6 Oct 2026; see the contract §6).
 */
html[data-cmhs-mode='embedded'] .cmhs-subbar {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 0.75rem;
	box-sizing: border-box;
	margin: 0.75rem 0.75rem 1rem;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--cmhs-chrome-edge);
	border-radius: var(--cmhs-chrome-radius);
	background: var(--cmhs-chrome-panel);
	box-shadow: var(--cmhs-chrome-shadow);
	color: var(--cmhs-chrome-ink);
	font-family: var(--cmhs-font-body);
}

html[data-cmhs-mode='embedded'] .cmhs-subbar :is(select, button, input, a) {
	font-family: inherit;
}

html[data-cmhs-mode='embedded'] .cmhs-subbar :is(select, button, input, a):focus-visible {
	outline: 3px solid var(--cmhs-focus);
	outline-offset: 2px;
}
