/* =============================================================================
BASE SIZES — STYLESHEET
-----------------------------------------------------------------------------
Design tokens and component patterns (header, buttons, form fields) are
copied 1:1 from the Krumpa Calculator reference implementation, per the
cross-plugin design-system rule: shared UI never gets re-authored per
plugin. Only the table itself is new (no equivalent exists elsewhere yet).
========================================================================== */

.w40iq-base-sizes,
:root {
	/* Surfaces */
	--w40iq-bg: #111013;
	--w40iq-bg-panel: #17161a;
	--w40iq-bg-raised: #1e1c21;
	--w40iq-bg-sunken: #0c0b0d;
	--w40iq-bg-field: #1a181d;

	/* Borders */
	--w40iq-border: #3a3640;
	--w40iq-border-soft: rgba(216, 212, 204, 0.12);

	/* Text */
	--w40iq-text: #d8d4cc;
	--w40iq-text-muted: #928d84;
	--w40iq-text-faint: #6d6860;
	--w40iq-heading: #e3c893;
	--w40iq-heading-strong: #f2dca8;
	--w40iq-on-accent: #17161a;

	/* Semantic */
	--w40iq-grot-green: #6dfc00;
	--w40iq-dark-green: #004f1b;

	/* Spacing scale */
	--w40iq-sp-1: 4px;
	--w40iq-sp-2: 8px;
	--w40iq-sp-3: 12px;
	--w40iq-sp-4: 16px;
	--w40iq-sp-6: 24px;
	--w40iq-sp-8: 32px;

	/* Radius */
	--w40iq-radius: 6px;
	--w40iq-radius-sm: 4px;
	--w40iq-radius-lg: 10px;

	/* Type */
	--w40iq-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--w40iq-font-size: 14px;
	--w40iq-line-height: 1.5;
	--w40iq-label-size: 11px;
	--w40iq-label-tracking: 0.04em;
	--w40iq-heading-size: 16px;

	/* Motion */
	--w40iq-transition: 140ms ease;

	/* Elevation */
	--w40iq-shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.28);
	--w40iq-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.34);

	/* Field control height */
	--w40iq-control-h: 40px;

	--w40iq-z-dropdown: 20;
}

@media (min-width: 640px) {
	.w40iq-base-sizes {
		--w40iq-font-size: 15px;
	}
}

/* -----------------------------------------------------------------------
Scope reset
--------------------------------------------------------------------- */
.w40iq-base-sizes,
.w40iq-base-sizes *,
.w40iq-base-sizes *::before,
.w40iq-base-sizes *::after {
	box-sizing: border-box;
}

.w40iq-base-sizes {
	position: relative;
	isolation: isolate;
	max-width: 100%;
	font-family: var(--w40iq-font);
	font-size: var(--w40iq-font-size);
	line-height: var(--w40iq-line-height);
	color: var(--w40iq-text);
	background: var(--w40iq-bg);
	border: 1px solid var(--w40iq-border);
	border-radius: var(--w40iq-radius-lg);
	padding: var(--w40iq-sp-3);
	display: grid;
	gap: var(--w40iq-sp-4);
	overflow-x: clip;
}

@media (min-width: 640px) {
	.w40iq-base-sizes {
		padding: var(--w40iq-sp-4);
	}
}

.w40iq-base-sizes h1,
.w40iq-base-sizes h2,
.w40iq-base-sizes h3,
.w40iq-base-sizes p {
	margin: 0;
	/* Re-assert the widget's own sans-serif font against the theme's
	   site-wide bold-italic "Bangers" heading font (see Krumpa Calculator
	   CSS §4 for the full rationale). */
	font-family: var(--w40iq-font);
	font-style: normal;
}

.w40iq-base-sizes img {
	max-width: 100%;
	display: block;
}

.w40iq-base-sizes a {
	color: var(--w40iq-heading);
}

/* -----------------------------------------------------------------------
Header — 1:1 pattern from .w40iq-arena-header
--------------------------------------------------------------------- */
.w40iq-base-sizes-header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--w40iq-sp-3);
	padding: var(--w40iq-sp-4);
	margin: calc(var(--w40iq-sp-3) * -1) calc(var(--w40iq-sp-3) * -1) 0;
	background: linear-gradient(160deg, var(--w40iq-bg-raised), var(--w40iq-bg-panel));
	border-bottom: 1px solid var(--w40iq-border);
	border-radius: var(--w40iq-radius-lg) var(--w40iq-radius-lg) 0 0;
}

@media (min-width: 640px) {
	.w40iq-base-sizes-header {
		margin: calc(var(--w40iq-sp-4) * -1) calc(var(--w40iq-sp-4) * -1) 0;
	}
}

.w40iq-base-sizes-header-text {
	display: grid;
	gap: 2px;
}

.w40iq-base-sizes-eyebrow {
	display: block;
	font-size: var(--w40iq-label-size);
	font-weight: 600;
	letter-spacing: var(--w40iq-label-tracking);
	text-transform: uppercase;
	color: var(--w40iq-heading);
}

.w40iq-base-sizes-title-row {
	display: flex;
	align-items: center;
	gap: var(--w40iq-sp-2);
}

.w40iq-base-sizes-title-row img {
	max-height: 56px;
	width: auto;
}

.w40iq-base-sizes-title {
	font-size: 20px;
	font-weight: 600;
	letter-spacing: 0.01em;
	color: var(--w40iq-heading-strong);
}

.w40iq-base-sizes-intro {
	font-size: 13px;
	color: var(--w40iq-text-muted);
}

/* -----------------------------------------------------------------------
Form fields — 1:1 pattern from Krumpa Calculator §6
--------------------------------------------------------------------- */
.w40iq-base-sizes .w40iq-field {
	display: grid;
	gap: var(--w40iq-sp-1);
	min-width: 0;
}

.w40iq-base-sizes .w40iq-field > label {
	display: block;
	font-size: var(--w40iq-label-size);
	font-weight: 600;
	letter-spacing: var(--w40iq-label-tracking);
	text-transform: uppercase;
	color: var(--w40iq-heading);
}

.w40iq-base-sizes input:not([type="checkbox"]),
.w40iq-base-sizes select {
	appearance: none;
	-webkit-appearance: none;
	width: 100%;
	min-height: var(--w40iq-control-h);
	padding: 8px var(--w40iq-sp-3);
	font: inherit;
	font-size: 13px;
	color: var(--w40iq-text) !important;
	-webkit-text-fill-color: var(--w40iq-text);
	background-color: var(--w40iq-bg-field);
	border: 1px solid var(--w40iq-border);
	border-radius: var(--w40iq-radius);
	color-scheme: dark;
	transition: border-color var(--w40iq-transition), box-shadow var(--w40iq-transition);
}

/* Divi applies a dark global option color after plugin styles. Native select
   popups inherit that rule separately from the closed field, so both layers
   need an explicit high-contrast palette. */
.w40iq-base-sizes select option {
	color: #f2dca8 !important;
	-webkit-text-fill-color: #f2dca8;
	background: #17161a !important;
}

.w40iq-base-sizes select option:checked {
	color: #111013 !important;
	-webkit-text-fill-color: #111013;
	background: #e3c893 !important;
}

.w40iq-base-sizes select {
	background-image: linear-gradient(45deg, transparent 50%, var(--w40iq-heading) 50%), linear-gradient(135deg, var(--w40iq-heading) 50%, transparent 50%);
	background-position: calc(100% - 18px) center, calc(100% - 13px) center;
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
	padding-right: var(--w40iq-sp-6);
}

.w40iq-base-sizes input::placeholder {
	color: var(--w40iq-text-faint);
}

.w40iq-base-sizes input:focus-visible,
.w40iq-base-sizes select:focus-visible,
.w40iq-base-sizes button:focus-visible,
.w40iq-base-sizes th[data-sort]:focus-visible {
	outline: 2px solid var(--w40iq-heading);
	outline-offset: 2px;
}

.w40iq-base-sizes .w40iq-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--w40iq-sp-2);
	min-height: var(--w40iq-control-h);
	padding: 10px var(--w40iq-sp-4);
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.01em;
	color: var(--w40iq-text);
	background: var(--w40iq-bg-raised);
	border: 1px solid var(--w40iq-border);
	border-radius: var(--w40iq-radius);
	cursor: pointer;
	transition: background var(--w40iq-transition), border-color var(--w40iq-transition), color var(--w40iq-transition);
	white-space: nowrap;
}

.w40iq-base-sizes .w40iq-button:hover {
	border-color: var(--w40iq-heading);
	color: var(--w40iq-heading-strong);
}

/* -----------------------------------------------------------------------
Controls row
--------------------------------------------------------------------- */
.w40iq-base-sizes-controls {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--w40iq-sp-3);
	align-items: end;
}

@media (min-width: 720px) {
	.w40iq-base-sizes-controls {
		grid-template-columns: minmax(0, 1fr) 220px auto;
	}
}

.w40iq-base-sizes-count {
	font-size: 12px;
	color: var(--w40iq-text-muted);
}

.w40iq-base-sizes-count-number {
	font-weight: 700;
	color: var(--w40iq-heading-strong);
}

/* -----------------------------------------------------------------------
Table
--------------------------------------------------------------------- */
.w40iq-base-sizes-table-wrap {
	background: var(--w40iq-bg-panel);
	border: 1px solid var(--w40iq-border);
	border-radius: var(--w40iq-radius-lg);
	box-shadow: var(--w40iq-shadow-sm);
	overflow: auto;
	max-height: min(70vh, 900px);
}

.w40iq-base-sizes-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13px;
}

.w40iq-base-sizes-table thead th {
	position: sticky;
	top: 0;
	z-index: 1;
	text-align: left;
	padding: var(--w40iq-sp-3) var(--w40iq-sp-3);
	font-size: var(--w40iq-label-size);
	font-weight: 700;
	letter-spacing: var(--w40iq-label-tracking);
	text-transform: uppercase;
	color: var(--w40iq-heading);
	background: var(--w40iq-bg-raised);
	border-bottom: 1px solid var(--w40iq-border);
	cursor: pointer;
	user-select: none;
	white-space: nowrap;
}

.w40iq-base-sizes-table thead th:hover {
	color: var(--w40iq-heading-strong);
}

.w40iq-base-sizes-table thead th::after {
	content: "";
	display: inline-block;
	width: 0;
	height: 0;
	margin-left: 6px;
	vertical-align: middle;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	opacity: 0.5;
}

.w40iq-base-sizes-table thead th.is-sorted-asc::after {
	border-bottom: 5px solid var(--w40iq-heading-strong);
	opacity: 1;
}

.w40iq-base-sizes-table thead th.is-sorted-desc::after {
	border-top: 5px solid var(--w40iq-heading-strong);
	opacity: 1;
}

.w40iq-base-sizes-table tbody td {
	padding: 9px var(--w40iq-sp-3);
	border-bottom: 1px solid var(--w40iq-border-soft);
	color: var(--w40iq-text);
	vertical-align: top;
}

.w40iq-base-sizes-table tbody tr:nth-child(even) {
	background: var(--w40iq-bg-sunken);
}

.w40iq-base-sizes-table tbody tr:hover {
	background: var(--w40iq-bg-raised);
}

.w40iq-base-sizes-table tbody td:last-child {
	font-weight: 600;
	color: var(--w40iq-heading-strong);
	white-space: nowrap;
}

.w40iq-base-sizes-empty {
	margin: 0;
	padding: var(--w40iq-sp-6);
	text-align: center;
	color: var(--w40iq-text-muted);
}

.w40iq-base-sizes-credit {
	font-size: 11px;
	color: var(--w40iq-text-faint);
}

.w40iq-base-sizes-notice {
	padding: var(--w40iq-sp-4);
	text-align: center;
	color: var(--w40iq-text-muted);
}
