/**
 * Architectural Scale Converter — front-end styles.
 *
 * Every colour, radius and font is inherited from the active theme through its
 * own custom properties, with a neutral fallback for themes that do not define
 * them. Bopea's variables (--jl-*) are the first choice, and its dark skin
 * class (body.options_dark_skin) is honoured.
 */

.archsc {
	--archsc-accent: var( --jl-main-color, #7118ff );
	--archsc-text: var( --jl-txt-color, #16181c );
	--archsc-title: var( --jl-theme-head-color, var( --jl-txt-color, #101114 ) );
	--archsc-bg: var( --jl-boxbg-color, #ffffff );
	--archsc-surface: rgba( 0, 0, 0, 0.035 );
	--archsc-surface-strong: rgba( 0, 0, 0, 0.06 );
	--archsc-border: var( --jl-post-line-color, #e3e6ea );
	--archsc-muted: var( --jl-meta-color, #6b7280 );
	--archsc-radius: var( --jl-border-rounded, 6px );
	--archsc-btn-radius: var( --jl-button-radius, 5px );
	--archsc-input-radius: var( --jl-input-radius, 5px );
	--archsc-title-font: var( --jl-title-font, inherit );
	--archsc-body-font: var( --jl-body-font, inherit );
	--archsc-gap: 16px;

	box-sizing: border-box;
	display: block;
	margin: 0 0 32px;
	padding: 20px;
	border: 1px solid var( --archsc-border );
	border-radius: var( --archsc-radius );
	background: var( --archsc-bg );
	color: var( --archsc-text );
	font-family: var( --archsc-body-font );
	font-size: 15px;
	line-height: 1.55;
	overflow-wrap: break-word;
}

.archsc *,
.archsc *::before,
.archsc *::after {
	box-sizing: inherit;
}

/*
 * This stylesheet sets display on elements that are also toggled with the
 * hidden attribute (grids, fields, rows). An author-level display value beats
 * the user-agent [hidden] rule, so restore it here.
 */
.archsc [hidden] {
	display: none !important;
}

.archsc--compact {
	padding: 14px;
	font-size: 14px;
}

/* Dark surfaces: Bopea's skin toggle, or a forced dark instance. */
body.options_dark_skin .archsc,
.archsc--theme-dark {
	--archsc-surface: rgba( 255, 255, 255, 0.05 );
	--archsc-surface-strong: rgba( 255, 255, 255, 0.09 );
	--archsc-border: var( --jl-post-line-color, #333546 );
	--archsc-bg: var( --jl-boxbg-color, #12141d );
	--archsc-text: var( --jl-txt-color, #f4f5f7 );
	--archsc-title: var( --jl-theme-head-color, #ffffff );

	/*
	 * Deliberately not --jl-meta-color here: Bopea's dark meta colour is pure
	 * white, which would erase the label/value hierarchy. This grey measures
	 * about 8:1 against a near-black page.
	 */
	--archsc-muted: #a7adba;
}

.archsc--theme-light {
	--archsc-surface: rgba( 0, 0, 0, 0.035 );
	--archsc-surface-strong: rgba( 0, 0, 0, 0.06 );
	--archsc-border: #e3e6ea;
	--archsc-bg: #ffffff;
	--archsc-text: #16181c;
	--archsc-title: #101114;
	--archsc-muted: #6b7280;
}

/* ---------------------------------------------------------------- Header */

.archsc__title {
	margin: 0 0 14px;
	color: var( --archsc-title );
	font-family: var( --archsc-title-font );
	font-size: 1.35em;
	font-weight: 700;
	line-height: 1.25;
}

.archsc__bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 18px;
	border-bottom: 1px solid var( --archsc-border );
}

.archsc__tabs {
	display: flex;
	flex: 1 1 auto;
	flex-wrap: wrap;
	gap: 2px;

	/*
	 * Without min-width:0 a flex item is at least as wide as its content, so
	 * the tab strip would widen the whole card past the viewport on a phone
	 * even though it scrolls internally.
	 */
	min-width: 0;
	max-width: 100%;
}

.archsc__tab {
	flex: 0 0 auto;
	margin: 0;
	padding: 9px 14px;
	border: 0;
	border-bottom: 2px solid transparent;
	border-radius: 0;
	background: none;
	color: var( --archsc-muted );
	font-family: inherit;
	font-size: 0.92em;
	font-weight: 600;
	line-height: 1.3;
	white-space: nowrap;
	cursor: pointer;
	transition: color 0.15s ease, border-color 0.15s ease;
}

.archsc__tab:hover,
.archsc__tab:focus-visible {
	color: var( --archsc-title );
}

.archsc__tab.is-active {
	border-bottom-color: var( --archsc-accent );
	color: var( --archsc-title );
}

.archsc__actions {
	display: flex;
	flex: 0 0 auto;
	gap: 6px;
	padding-bottom: 6px;
}

.archsc__action {
	padding: 7px 12px;
	border: 1px solid var( --archsc-border );
	border-radius: var( --archsc-btn-radius );
	background: var( --archsc-surface );
	color: var( --archsc-text );
	font-family: inherit;
	font-size: 0.82em;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.archsc__action:hover,
.archsc__action:focus-visible {
	border-color: var( --archsc-accent );
	background: var( --archsc-surface-strong );
}

.archsc__action--ghost {
	background: none;
}

.archsc__tab:focus-visible,
.archsc__action:focus-visible,
.archsc__chip:focus-visible,
.archsc__row-remove:focus-visible,
.archsc__history-item:focus-visible {
	outline: 2px solid var( --archsc-accent );
	outline-offset: 2px;
}

/* ---------------------------------------------------------------- Panels */

.archsc__panel[hidden] {
	display: none;
}

.archsc__intro {
	margin: 0 0 16px;
	color: var( --archsc-muted );
	font-size: 0.92em;
}

.archsc__subhead {
	margin: 26px 0 12px;
	color: var( --archsc-title );
	font-family: var( --archsc-title-font );
	font-size: 1.02em;
	font-weight: 700;
	letter-spacing: 0.01em;
}

.archsc__noscript {
	margin: 0 0 16px;
	padding: 10px 12px;
	border-left: 3px solid var( --archsc-accent );
	background: var( --archsc-surface );
	font-size: 0.9em;
}

/* ---------------------------------------------------------------- Fields */

.archsc__grid {
	display: grid;
	grid-template-columns: repeat( auto-fit, minmax( 175px, 1fr ) );
	gap: var( --archsc-gap );
	margin-bottom: 16px;
}

.archsc--compact .archsc__grid {
	grid-template-columns: 1fr;
	gap: 12px;
}

.archsc__field {
	display: flex;
	flex-direction: column;
	gap: 5px;
	min-width: 0;
}

.archsc__field[hidden] {
	display: none;
}

.archsc__label {
	color: var( --archsc-muted );
	font-size: 0.78em;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.archsc__control {
	width: 100%;
	max-width: 100%;
	margin: 0;
	padding: 10px 12px;
	border: 1px solid var( --archsc-border );
	border-radius: var( --archsc-input-radius );
	background: var( --archsc-bg );
	color: var( --archsc-text );
	font-family: inherit;
	font-size: 0.96em;
	line-height: 1.4;
	appearance: none;
	-webkit-appearance: none;
}

select.archsc__control {
	padding-right: 30px;
	background-image: linear-gradient( 45deg, transparent 50%, currentColor 50% ), linear-gradient( 135deg, currentColor 50%, transparent 50% );
	background-position: calc( 100% - 16px ) calc( 50% + 2px ), calc( 100% - 11px ) calc( 50% + 2px );
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
}

.archsc__control:focus {
	border-color: var( --archsc-accent );
	outline: 2px solid var( --archsc-accent );
	outline-offset: 1px;
}

.archsc__hint {
	margin: -6px 0 16px;
	color: var( --archsc-muted );
	font-size: 0.82em;
}

.archsc__inline-actions {
	margin: 0 0 16px;
}

/* ------------------------------------------------------------- Segmented */

.archsc__segmented {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 0;
	margin-bottom: 18px;
	padding: 3px;
	border: 1px solid var( --archsc-border );
	border-radius: var( --archsc-btn-radius );
	background: var( --archsc-surface );
}

.archsc__segment {
	position: relative;
	margin: 0;
	cursor: pointer;
}

.archsc__segment input {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect( 0 0 0 0 );
	white-space: nowrap;
}

.archsc__segment span {
	display: block;
	padding: 8px 14px;
	border-radius: calc( var( --archsc-btn-radius ) - 1px );
	color: var( --archsc-muted );
	font-size: 0.86em;
	font-weight: 600;
	line-height: 1.2;
	white-space: nowrap;
}

.archsc__segment.is-active span {
	background: var( --archsc-accent );
	color: #fff;
}

.archsc__segment input:focus-visible + span {
	outline: 2px solid var( --archsc-accent );
	outline-offset: 1px;
}

/* --------------------------------------------------------------- Results */

.archsc__results {
	margin-top: 18px;
	padding: 16px;
	border: 1px solid var( --archsc-border );
	border-radius: var( --archsc-radius );
	background: var( --archsc-surface );
}

.archsc__result {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px;
	padding: 7px 0;
	border-bottom: 1px dashed var( --archsc-border );
}

.archsc__result:last-of-type {
	border-bottom: 0;
}

.archsc__result--lead {
	margin: -16px -16px 10px;
	padding: 14px 16px;
	border-bottom: 1px solid var( --archsc-border );
	border-left: 3px solid var( --archsc-accent );
	border-radius: var( --archsc-radius ) var( --archsc-radius ) 0 0;
	background: var( --archsc-bg );
}

.archsc__result-label {
	color: var( --archsc-muted );
	font-size: 0.82em;
	font-weight: 700;
	letter-spacing: 0.03em;
	text-transform: uppercase;
}

.archsc__result-value {
	color: var( --archsc-title );
	font-family: var( --archsc-title-font );
	font-size: 1.02em;
	font-weight: 700;
	text-align: end;
	overflow-wrap: anywhere;
}

.archsc__result--lead .archsc__result-value {
	font-size: 1.6em;
	line-height: 1.2;
}

.archsc__note {
	margin: 10px 0 0;
	color: var( --archsc-muted );
	font-size: 0.84em;
}

/* ----------------------------------------------------------------- Chips */

.archsc__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 12px;
}

.archsc__chip {
	display: inline-block;
	padding: 5px 10px;
	border: 1px solid var( --archsc-border );
	border-radius: 999px;
	background: var( --archsc-bg );
	color: var( --archsc-text );
	font-family: inherit;
	font-size: 0.8em;
	font-weight: 600;
	line-height: 1.3;
	white-space: nowrap;
}

button.archsc__chip {
	cursor: pointer;
}

button.archsc__chip.is-active {
	border-color: var( --archsc-accent );
	background: var( --archsc-accent );
	color: #fff;
}

.archsc__chip--static {
	cursor: default;
}

.archsc__chipset {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

/* --------------------------------------------------------------- Preview */

.archsc__preview {
	margin-top: 16px;
}

.archsc__preview:empty {
	display: none;
}

.archsc__svg {
	display: block;
	width: 100%;
	max-width: 320px;
	max-height: 260px;
	margin: 0 auto;
}

.archsc__svg-sheet {
	fill: var( --archsc-bg );
	stroke: var( --archsc-border );
	stroke-width: 3;
}

.archsc__svg-margin {
	fill: none;
	stroke: var( --archsc-muted );
	stroke-dasharray: 8 6;
	stroke-width: 2;
}

.archsc__svg-drawing {
	fill: var( --archsc-accent );
	fill-opacity: 0.18;
	stroke: var( --archsc-accent );
	stroke-width: 3;
}

/* ------------------------------------------------------------ Model rows */

.archsc__rows {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-bottom: 14px;
}

.archsc__row {
	display: grid;
	grid-template-columns: minmax( 0, 1.4fr ) minmax( 0, 1fr ) minmax( 0, 1fr ) auto;
	align-items: center;
	gap: 8px;
}

.archsc__row-out {
	padding: 0 4px;
	color: var( --archsc-title );
	font-weight: 700;
	overflow-wrap: anywhere;
}

.archsc__row-remove {
	width: 32px;
	height: 32px;
	padding: 0;
	border: 1px solid var( --archsc-border );
	border-radius: var( --archsc-btn-radius );
	background: none;
	color: var( --archsc-muted );
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
}

.archsc__row-remove:hover,
.archsc__row-remove:focus-visible {
	border-color: var( --archsc-accent );
	color: var( --archsc-title );
}

.archsc__refs {
	margin: 0;
	padding: 0;
	list-style: none;
}

.archsc__ref {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 10px;
	padding: 7px 0;
	border-bottom: 1px dashed var( --archsc-border );
}

.archsc__ref:last-child {
	border-bottom: 0;
}

.archsc__ref-label {
	color: var( --archsc-muted );
	font-size: 0.88em;
}

.archsc__ref-value {
	color: var( --archsc-title );
	font-weight: 700;
}

/* ----------------------------------------------------------------- Table */

.archsc__filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 14px;
}

.archsc__field--search {
	min-width: 200px;
	flex: 1 1 200px;
}

.archsc__table-wrap {
	width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.archsc__table {
	width: 100%;
	min-width: 620px;
	margin: 0;
	border-collapse: collapse;
	font-size: 0.9em;
}

.archsc__table th,
.archsc__table td {
	padding: 9px 12px;
	border-bottom: 1px solid var( --archsc-border );
	text-align: start;
	vertical-align: top;
}

.archsc__table thead th {
	border-bottom-width: 2px;
	color: var( --archsc-muted );
	font-size: 0.85em;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	white-space: nowrap;
}

.archsc__table tbody th {
	color: var( --archsc-title );
	font-weight: 700;
	white-space: nowrap;
}

.archsc__table tbody tr:hover {
	background: var( --archsc-surface );
}

.archsc__table tbody tr[hidden] {
	display: none;
}

.archsc__empty {
	margin: 14px 0 0;
	color: var( --archsc-muted );
	font-size: 0.9em;
}

/* --------------------------------------------------------------- History */

.archsc__history {
	margin-top: 20px;
	padding-top: 14px;
	border-top: 1px solid var( --archsc-border );
}

.archsc__history[hidden] {
	display: none;
}

.archsc__history-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 8px;
}

.archsc__history-title {
	color: var( --archsc-muted );
	font-size: 0.78em;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.archsc__history-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.archsc__history-list li {
	margin: 0 0 5px;
}

.archsc__history-item {
	width: 100%;
	padding: 7px 10px;
	border: 1px solid var( --archsc-border );
	border-radius: var( --archsc-btn-radius );
	background: var( --archsc-surface );
	color: var( --archsc-text );
	font-family: inherit;
	font-size: 0.84em;
	text-align: start;
	cursor: pointer;
	overflow-wrap: anywhere;
}

.archsc__history-item:hover,
.archsc__history-item:focus-visible {
	border-color: var( --archsc-accent );
}

/* ----------------------------------------------------------------- Toast */

.archsc__status {
	margin: 12px 0 0;
	min-height: 1.4em;
	color: var( --archsc-muted );
	font-size: 0.84em;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.archsc__status.is-visible {
	opacity: 1;
}

/* Screen-reader helper, in case the theme does not provide one. */
.archsc .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect( 1px, 1px, 1px, 1px );
	clip-path: inset( 50% );
	white-space: nowrap;
}

/* ------------------------------------------------------------ Responsive */

@media ( max-width: 600px ) {
	.archsc {
		padding: 14px;
	}

	.archsc__tabs {
		flex-wrap: nowrap;
		overflow-x: auto;
		scrollbar-width: thin;
		-webkit-overflow-scrolling: touch;
	}

	.archsc__grid {
		grid-template-columns: 1fr;
		gap: 12px;
	}

	/*
	 * Place the row explicitly: auto-placement would push the remove button on
	 * to a third row of its own once the result spans the full width.
	 */
	.archsc__row {
		grid-template-columns: minmax( 0, 1fr ) minmax( 0, 1fr ) auto;
	}

	.archsc__row > .archsc__control--label {
		grid-column: 1;
		grid-row: 1;
	}

	.archsc__row > .archsc__control--value {
		grid-column: 2;
		grid-row: 1;
	}

	.archsc__row-remove {
		grid-column: 3;
		grid-row: 1;
	}

	.archsc__row-out {
		grid-column: 1 / -1;
		grid-row: 2;
		text-align: end;
	}

	.archsc__result {
		flex-direction: column;
		align-items: flex-start;
	}

	.archsc__result-value {
		text-align: start;
	}

	.archsc__bar {
		flex-direction: column;
		align-items: stretch;
	}

	.archsc__actions {
		justify-content: flex-end;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.archsc *,
	.archsc *::before,
	.archsc *::after {
		transition: none !important;
	}
}

/* ------------------------------------------------- Theme compatibility */

/*
 * Bopea — and it is far from the only magazine theme that does this — styles
 * every <button> on the site as a solid call-to-action, and strips focus
 * indicators from inputs:
 *
 *   input[type='submit'], button { color: #fff !important; display: flex;
 *       height: 43px; padding: 0 30px; background-color: var(--jl-main-color);
 *       text-transform: var(--jl-button-transform); }
 *   input[type='submit']:hover, button:hover {
 *       background-color: var(--jl-btn-bg) !important; }
 *   input[type='text'], … , textarea {
 *       outline: none !important; box-shadow: none !important; }
 *
 * The !important declarations beat ordinary class rules, which left every
 * button in this plugin as white text on a white card, painted them black on
 * hover, and removed the keyboard focus ring. These rules answer in kind and
 * are scoped to the plugin wrapper, so they cannot leak into the theme.
 */

.archsc button {
	height: auto;
	min-height: 0;
	letter-spacing: normal;
	text-transform: none;
}

.archsc .archsc__tab {
	display: inline-block;
	color: var( --archsc-muted ) !important;
	background-color: transparent !important;
}

.archsc .archsc__tab:hover,
.archsc .archsc__tab:focus-visible,
.archsc .archsc__tab.is-active {
	color: var( --archsc-title ) !important;
}

.archsc .archsc__action,
.archsc .archsc__history-item {
	display: inline-block;
	color: var( --archsc-text ) !important;
	background-color: var( --archsc-surface ) !important;
}

.archsc .archsc__action--ghost {
	background-color: transparent !important;
}

.archsc .archsc__action:hover,
.archsc .archsc__action:focus-visible,
.archsc .archsc__history-item:hover,
.archsc .archsc__history-item:focus-visible {
	color: var( --archsc-text ) !important;
	background-color: var( --archsc-surface-strong ) !important;
}

.archsc button.archsc__chip {
	color: var( --archsc-text ) !important;
	background-color: var( --archsc-bg ) !important;
}

.archsc button.archsc__chip:hover,
.archsc button.archsc__chip:focus-visible {
	background-color: var( --archsc-surface-strong ) !important;
}

.archsc button.archsc__chip.is-active,
.archsc button.archsc__chip.is-active:hover,
.archsc button.archsc__chip.is-active:focus-visible {
	color: #fff !important;
	background-color: var( --archsc-accent ) !important;
}

.archsc .archsc__row-remove {
	color: var( --archsc-muted ) !important;
	background-color: transparent !important;
}

.archsc .archsc__row-remove:hover,
.archsc .archsc__row-remove:focus-visible {
	color: var( --archsc-title ) !important;
	background-color: var( --archsc-surface ) !important;
}

/*
 * Bopea paints placeholders with --jl-except-color, which is #ddd on its dark
 * skin — bright enough to read as an entered value. State the placeholder
 * colour explicitly so it always reads as secondary.
 */
.archsc .archsc__control::placeholder {
	color: var( --archsc-muted );
	opacity: 0.6;
}

.archsc .archsc__control::-webkit-input-placeholder {
	color: var( --archsc-muted );
	opacity: 0.6;
}

/* Put back the focus ring the theme removes from text inputs. */
.archsc .archsc__control:focus,
.archsc .archsc__control:focus-visible {
	outline: 2px solid var( --archsc-accent ) !important;
	outline-offset: 1px !important;
}

/* ---------------------------------------------------------------- Print */

@media print {
	.archsc {
		border: 0;
		padding: 0;
	}

	.archsc__tabs,
	.archsc__actions,
	.archsc__history,
	.archsc__status,
	.archsc__filters,
	.archsc__inline-actions,
	.archsc__row-remove {
		display: none !important;
	}

	.archsc__panel {
		display: block !important;
		page-break-inside: avoid;
	}

	.archsc__panel[hidden] {
		display: none !important;
	}

	.archsc__results {
		background: none;
	}

	.archsc__table {
		min-width: 0;
	}
}
