/**
 * youji/machine-specs — model picker, photo and, beside it, two panels:
 * grouped characteristic tables and the compatible options (graphite list).
 * view.js turns the panels into tabs (.has-tabs); without it they stack under
 * their headings. The table look comes from the theme (core-table.css,
 * enqueued by render.php); the rules below only lay the block out and add
 * safety nets.
 */

.machine-specs {
	display: grid;
	gap: var(--wp--preset--spacing--sm, 16px);
}

.machine-specs__picker {
	display: grid;
	gap: 6px;
	max-width: 420px;
	margin: 0;
}

.machine-specs__picker label {
	font-weight: 600;
	font-size: var(--wp--preset--font-size--small, 0.9375rem);
}

.machine-specs__select {
	width: 100%;
	padding: 10px 12px;
	border: var(--wp--custom--stroke--thin, 1px) solid var(--wp--preset--color--border, #d4d9e0);
	border-radius: var(--wp--custom--radius--sm, 4px);
	background-color: var(--wp--preset--color--base, #fff);
	color: var(--wp--preset--color--contrast, #16222e);
	font: inherit;
}

.machine-specs__select:focus-visible {
	outline: 2px solid var(--wp--preset--color--primary, #1256a0);
	outline-offset: 1px;
}

.machine-specs__status {
	margin: 0;
	font-size: var(--wp--preset--font-size--small, 0.9375rem);
	color: var(--wp--preset--color--muted, #5a6572);
}

.machine-specs__status strong {
	color: var(--wp--preset--color--contrast, #16222e);
}

.machine-specs__layout {
	display: grid;
	gap: var(--wp--preset--spacing--md, 24px);
	align-items: start;
}

@media (min-width: 782px) {
	.machine-specs__layout {
		grid-template-columns: minmax(320px, 2fr) 3fr;
	}

	.machine-specs__photo {
		position: sticky;
		/* Compact sticky header (72 px) + admin bar when shown + breathing room. */
		top: calc(var(--wp-admin--admin-bar--height, 0px) + 72px + var(--wp--preset--spacing--lg, 40px));
	}

	/* Tabs on their own row: the photo lines up with the panel box. */
	.machine-specs.has-tabs .machine-specs__panels {
		display: contents;
	}

	.machine-specs.has-tabs .machine-specs__tabs {
		grid-area: 1 / 2;
	}

	.machine-specs.has-tabs .machine-specs__photo {
		grid-area: 2 / 1;
	}

	.machine-specs.has-tabs .machine-specs__panel {
		grid-column: 2;
	}
}

.machine-specs__photo {
	margin: 0;
	padding: var(--wp--preset--spacing--sm, 16px);
	background-color: var(--wp--preset--color--surface, #f2f5f8);
	border-radius: var(--wp--custom--radius--md, 6px);
	border: var(--wp--custom--stroke--thin, 1px) solid var(--wp--preset--color--border, #d4d9e0);
	text-align: center;
}

.machine-specs__photo img {
	max-width: 100%;
	height: auto;
	max-height: 440px;
	object-fit: contain;
}

.machine-specs__photo figcaption {
	margin-top: 8px;
	font-size: var(--wp--preset--font-size--caption, 0.8125rem);
	color: var(--wp--preset--color--muted, #5a6572);
	text-align: left;
}

.machine-specs__panels {
	display: grid;
	gap: var(--wp--preset--spacing--md, 24px);
	min-width: 0;
}

/* The hidden attribute must win over the display values below. */
.machine-specs [hidden] {
	display: none;
}

/* ---------------------------------------------------------------------------
 * Panels. Without tabs each panel keeps its heading (Barlow H3, same look as
 * the table captions); with tabs the heading is for screen readers only.
 * ------------------------------------------------------------------------- */

.machine-specs__panel {
	display: grid;
	gap: var(--wp--preset--spacing--sm, 16px);
	min-width: 0;
}

/* Anchor scroll (#options): land with the tab row in view above the panel —
   the row height plus the panel gap — on top of the theme scroll-padding. */
.machine-specs.has-tabs .machine-specs__panel {
	scroll-margin-top: 72px;
}

.machine-specs__panel:focus-visible {
	outline: var(--wp--custom--stroke--focus, 3px) solid var(--wp--preset--color--primary, #00529c);
	outline-offset: 4px;
	border-radius: var(--wp--custom--radius--md, 6px);
}

.machine-specs__panel-title {
	margin: 0;
	font-size: var(--wp--preset--font-size--lead, 1.125rem);
}

.machine-specs.has-tabs .machine-specs__panel-title {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ---------------------------------------------------------------------------
 * Tabs: same vocabulary as the page anchor nav (muted label, brand underline
 * when selected), a rule under the row.
 * ------------------------------------------------------------------------- */

.machine-specs__tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 0 var(--wp--preset--spacing--lg, 32px);
	margin: 0;
	padding: 0;
	border-bottom: var(--wp--custom--stroke--thin, 1px) solid var(--wp--preset--color--border, #d5dfe6);
}

/* Empty until view.js builds the buttons (editor preview, no JS): no stray rule. */
.machine-specs__tabs:empty {
	display: none;
}

.machine-specs__tab {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 -1px;
	padding: 12px 0;
	border: 0;
	border-bottom: var(--wp--custom--stroke--medium, 2px) solid transparent;
	border-radius: 0;
	background: none;
	font: inherit;
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	font-weight: 500;
	line-height: 1.2;
	color: var(--wp--preset--color--muted, #526575);
	cursor: pointer;
	transition: color var(--wp--custom--transition, 150ms ease), border-color var(--wp--custom--transition, 150ms ease);
}

.machine-specs__tab:hover {
	color: var(--wp--preset--color--primary, #00529c);
}

.machine-specs__tab[aria-selected="true"] {
	color: var(--wp--preset--color--primary, #00529c);
	border-bottom-color: var(--wp--preset--color--primary, #00529c);
	font-weight: 600;
}

.machine-specs__tab:focus-visible {
	outline: var(--wp--custom--stroke--focus, 3px) solid var(--wp--preset--color--primary, #00529c);
	outline-offset: 2px;
	border-radius: var(--wp--custom--radius--sm, 4px);
}

/* ---------------------------------------------------------------------------
 * Options panel: graphite card, checks in the "inverse repère" blue, two
 * columns when the panel is wide enough.
 * ------------------------------------------------------------------------- */

.machine-specs__options {
	padding: var(--wp--preset--spacing--md, 24px) var(--wp--preset--spacing--lg, 32px);
	border-radius: var(--wp--custom--radius--md, 6px);
	background-color: var(--wp--preset--color--graphite, #101f30);
	color: var(--wp--preset--color--on-dark-soft, #c5d6e3);
}

.machine-specs__options-intro {
	margin: 0 0 var(--wp--preset--spacing--sm, 16px);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	color: var(--wp--preset--color--on-dark-soft, #c5d6e3);
}

.machine-specs__options-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 0 var(--wp--preset--spacing--lg, 32px);
}

@media (min-width: 1100px) {
	.machine-specs__options-list {
		grid-template-columns: 1fr 1fr;
	}
}

.machine-specs__options-list li {
	position: relative;
	margin: 0;
	padding: 12px 0 12px 2rem;
	border-top: var(--wp--custom--stroke--thin, 1px) solid var(--wp--custom--color--on-dark-border, #34495b);
	font-weight: 500;
	color: var(--wp--preset--color--on-dark, #fff);
}

/* Lucide check (same path as the theme icon), inverse accent blue. */
.machine-specs__options-list li::before {
	content: "";
	position: absolute;
	left: 0;
	top: calc(12px + 0.15em);
	width: 20px;
	height: 20px;
	background-color: var(--wp--preset--color--on-dark-accent, #a8c9e5);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}

.machine-specs__options-empty {
	margin: 0;
	padding: 12px 0;
	border-top: var(--wp--custom--stroke--thin, 1px) solid var(--wp--custom--color--on-dark-border, #34495b);
	color: var(--wp--preset--color--on-dark, #fff);
}

.machine-specs__options-note {
	margin: var(--wp--preset--spacing--sm, 16px) 0 0;
	padding-top: var(--wp--preset--spacing--sm, 16px);
	border-top: var(--wp--custom--stroke--thin, 1px) solid var(--wp--custom--color--on-dark-border, #34495b);
	font-size: var(--wp--preset--font-size--caption, 0.75rem);
	color: var(--wp--preset--color--on-dark-muted, #95adbf);
}

@media (max-width: 599px) {
	.machine-specs__options {
		padding: var(--wp--preset--spacing--sm, 16px) var(--wp--preset--spacing--md, 24px);
	}

	.machine-specs__tabs {
		gap: 0 var(--wp--preset--spacing--md, 24px);
	}
}

/* ---------------------------------------------------------------------------
 * Characteristic tables.
 * ------------------------------------------------------------------------- */

.machine-specs__tables {
	display: grid;
	gap: var(--wp--preset--spacing--md, 24px);
}

.machine-specs__table {
	margin: 0;
}

.machine-specs__specs-note {
	margin: 0;
	font-size: var(--wp--preset--font-size--caption, 0.75rem);
	color: var(--wp--preset--color--muted, #526575);
}

/* Two columns only: no need for the 560px minimum of the theme tables. */
.machine-specs__table table {
	min-width: 0;
}

/* Long double values (Fanuc · Siemens) must wrap, not overflow. */
.machine-specs__table td {
	overflow-wrap: anywhere;
}

/* Label column: a reasonable share, so values align across the groups. */
.machine-specs__table tbody th {
	width: 46%;
}

/* Safety net when the theme table styles are absent (theme switched). */
.machine-specs__table table {
	width: 100%;
	border-collapse: collapse;
}

.machine-specs__table th,
.machine-specs__table td {
	text-align: left;
	vertical-align: top;
	padding: 12px 16px;
}
