/**
 * Westphal Solutions — HTML Try-It tool styles
 *
 * Mirrors the visual language of the markdown tool (sliding-thumb toggle,
 * toolbar, two panes) using the brand tokens from main.css. Self-contained for
 * now; when ws-markdown.css is on hand, the shared shell (.ws*__bar,
 * .ws*__modes, .ws*__thumb, pane chrome) can be lifted into one base file.
 */

.wshtml {
	--wshtml-mono: 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
	--wshtml-gap: 1px; /* hairline between the two panes */

	border: 1px solid var(--ws-border);
	border-radius: var(--ws-radius);
	background: var(--ws-surface);
	overflow: hidden;
	font-family: var(--ws-font);
	color: var(--ws-text);
}

/* ---------------------------------------------------------------------------
   Top bar: Run + Copy + Reset on the left, mode toggle + size on the right
   --------------------------------------------------------------------------- */
.wshtml__bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	border-bottom: 1px solid var(--ws-border);
	background: var(--ws-bg);
}

.wshtml__actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

.wshtml__spacer { flex: 1 1 auto; }

.wshtml__meta {
	display: flex;
	align-items: center;
	gap: 12px;
}

.wshtml__size {
	font-size: 0.8rem;
	color: var(--ws-muted);
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

/* ---- Buttons --------------------------------------------------------------- */
.wshtml__btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-family: var(--ws-font);
	font-size: 0.85rem;
	font-weight: 700;
	line-height: 1;
	padding: 9px 14px;
	border-radius: var(--ws-radius);
	border: 1px solid var(--ws-border);
	background: var(--ws-surface);
	color: var(--ws-text);
	cursor: pointer;
	transition: transform 0.15s var(--ws-ease),
				background-color 0.2s var(--ws-ease),
				border-color 0.2s var(--ws-ease),
				color 0.2s var(--ws-ease);
}

.wshtml__btn:hover { border-color: var(--ws-accent); }
.wshtml__btn:active { transform: translateY(1px); }
.wshtml__btn:focus-visible { outline: 2px solid var(--ws-accent); outline-offset: 2px; }

.wshtml__btn--run {
	background: var(--ws-accent);
	border-color: var(--ws-accent);
	color: var(--ws-black);
}
.wshtml__btn--run:hover {
	background: var(--ws-white);
	color: var(--ws-black);
}

.wshtml__btn.is-copied {
	background: var(--ws-slate);
	border-color: var(--ws-slate);
	color: var(--ws-white);
}

.wshtml__run-icon { transition: transform 0.2s var(--ws-ease); }
.wshtml__btn--run:hover .wshtml__run-icon { transform: translateX(2px); }

/* ---- Mode toggle (Code / Result), mirrors the theme switch thumb ----------- */
.wshtml__modes {
	position: relative;
	display: none; /* shown only on narrow screens */
	padding: 3px;
	border: 1px solid var(--ws-border);
	border-radius: var(--ws-radius-pill);
	background: var(--ws-surface);
}

.wshtml__thumb {
	position: absolute;
	top: 3px;
	left: 3px;
	width: calc(50% - 3px);
	height: calc(100% - 6px);
	border-radius: var(--ws-radius-pill);
	background: var(--ws-accent);
	transition: transform 0.28s var(--ws-ease);
}
.wshtml__modes[data-active="result"] .wshtml__thumb { transform: translateX(100%); }

.wshtml__mode {
	position: relative;
	z-index: 1;
	flex: 1 1 0;
	min-width: 72px;
	padding: 6px 14px;
	border: 0;
	background: transparent;
	font-family: var(--ws-font);
	font-size: 0.8rem;
	font-weight: 700;
	color: var(--ws-muted);
	cursor: pointer;
}
.wshtml__mode[aria-pressed="true"] { color: var(--ws-black); }
.wshtml__mode:focus-visible { outline: 2px solid var(--ws-accent); outline-offset: 2px; border-radius: var(--ws-radius-pill); }

/* ---------------------------------------------------------------------------
   Panes
   --------------------------------------------------------------------------- */
.wshtml__panes {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--wshtml-gap);
	background: var(--ws-border); /* the hairline gutter between panes */
}

.wshtml__pane {
	display: flex;
	flex-direction: column;
	min-width: 0;
	background: var(--ws-surface);
}

.wshtml__pane-label {
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--ws-muted);
	padding: 9px 12px;
	border-bottom: 1px solid var(--ws-border);
}

/* ---- Code editor ----------------------------------------------------------- */
.wshtml__code {
	flex: 1 1 auto;
	width: 100%;
	min-height: 360px;
	resize: vertical;
	border: 0;
	padding: 14px 16px;
	font-family: var(--wshtml-mono);
	font-size: 0.9rem;
	line-height: 1.6;
	tab-size: 2;
	color: var(--ws-text);
	background: var(--ws-bg);
	white-space: pre;
	overflow: auto;
}
.wshtml__code:focus { outline: 0; box-shadow: inset 0 0 0 2px var(--ws-accent); }

/* ---- Result iframe --------------------------------------------------------- */
.wshtml__result {
	flex: 1 1 auto;
	width: 100%;
	min-height: 360px;
	border: 0;
	background: #ffffff; /* the rendered document controls its own background */
}

/* ---------------------------------------------------------------------------
   Responsive: below 720px collapse to one pane, driven by the Code/Result toggle
   --------------------------------------------------------------------------- */
@media (max-width: 720px) {
	.wshtml__modes { display: flex; }
	.wshtml__panes { grid-template-columns: 1fr; }
	.wshtml[data-view="code"]   .wshtml__pane--result { display: none; }
	.wshtml[data-view="result"] .wshtml__pane--code   { display: none; }
}
