/*!
 * CSS Portal — Generator layout
 * Load after code-tool.css (which provides the design tokens, switches,
 * segmented controls and the code editor).
 */

.gt {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 16px;
	margin: 8px 0 24px;
}

@media (min-width: 1000px) {
	.gt { grid-template-columns: 340px minmax(0, 1fr); align-items: start; }
	.gt-main { position: sticky; top: 16px; }
}

/* ---------- Controls panel ---------- */

.gt-panel {
	background: var(--ct-bg);
	border: 1px solid var(--ct-border);
	border-radius: var(--ct-radius);
	overflow: hidden;
}

.gt-panel__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	min-height: 46px;
	padding: 6px 8px 6px 16px;
	background: var(--ct-surface);
	border-bottom: 1px solid var(--ct-border);
}
.gt-panel__head h2 { margin: 0; font-size: 14px; font-weight: 600; color: var(--ct-text); }

.gt-section { border-bottom: 1px solid var(--ct-border); }
.gt-section:last-child { border-bottom: 0; }

.gt-section__title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 0;
	padding: 12px 16px;
	font-size: 11.5px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--ct-muted);
	list-style: none;
	cursor: pointer;
	user-select: none;
}
.gt-section__title::-webkit-details-marker { display: none; }
summary.gt-section__title::after { content: "›"; font-size: 16px; line-height: 1; transition: transform .15s; }
details[open] > summary.gt-section__title::after { transform: rotate(90deg); }
summary.gt-section__title:hover { color: var(--ct-text); }
summary.gt-section__title:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--ct-accent); }
.gt-section--presets .gt-section__title { cursor: default; padding-bottom: 8px; }

.gt-controls {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 14px;
	padding: 2px 16px 16px;
}
.gt-controls--2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 14px; }
.gt-controls--2 .gt-control--wide,
.gt-controls--2 .gt-control--range,
.gt-controls--2 .gt-control--segmented,
.gt-controls--2 .gt-control--switch { grid-column: 1 / -1; }

.gt-control { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.gt-control.is-disabled { opacity: .45; }
.gt-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gt-label { margin: 0; font-size: 13px; font-weight: 500; color: var(--ct-text); }
.gt-hint { margin: 0; font-size: 12px; color: var(--ct-muted); }

/* range + number */
.gt input[type="range"] {
	width: 100%;
	height: 20px;
	margin: 0;
	accent-color: var(--ct-accent);
	cursor: pointer;
}
.gt-num {
	display: inline-flex;
	align-items: center;
	height: 26px;
	padding: 0 6px 0 2px;
	font-size: 12px;
	color: var(--ct-muted);
	background: var(--ct-surface);
	border: 1px solid var(--ct-border);
	border-radius: 6px;
}
.gt-num:focus-within { border-color: var(--ct-accent); box-shadow: 0 0 0 3px var(--ct-accent-soft); }
.gt-num input {
	width: 46px;
	padding: 0 2px 0 6px;
	font: inherit;
	font-size: 12.5px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	text-align: right;
	color: var(--ct-text);
	background: transparent;
	border: 0;
	outline: none;
	-moz-appearance: textfield;
}
.gt-num input::-webkit-outer-spin-button,
.gt-num input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* colour */
.gt-color {
	display: flex;
	align-items: center;
	gap: 8px;
	height: 34px;
	padding: 0 8px 0 4px;
	background: var(--ct-bg);
	border: 1px solid var(--ct-border);
	border-radius: 8px;
}
.gt-color:focus-within { border-color: var(--ct-accent); box-shadow: 0 0 0 3px var(--ct-accent-soft); }
.gt-color input[type="color"] {
	flex: none;
	width: 26px;
	height: 26px;
	padding: 0;
	border: 0;
	border-radius: 6px;
	background: none;
	cursor: pointer;
}
.gt-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.gt-color input[type="color"]::-webkit-color-swatch { border: 1px solid rgba(15, 23, 42, .15); border-radius: 6px; }
.gt-color input[type="color"]::-moz-color-swatch { border: 1px solid rgba(15, 23, 42, .15); border-radius: 6px; }
.gt-color input[type="text"] {
	width: 100%;
	min-width: 0;
	padding: 0;
	font-family: var(--ct-mono);
	font-size: 12.5px;
	text-transform: lowercase;
	color: var(--ct-text);
	background: transparent;
	border: 0;
	outline: none;
}

/* select + text */
.gt select,
.gt-control--text input {
	width: 100%;
	height: 34px;
	padding: 0 10px;
	font: inherit;
	font-size: 13px;
	color: var(--ct-text);
	background-color: var(--ct-bg);
	border: 1px solid var(--ct-border);
	border-radius: 8px;
	outline: none;
}
.gt select {
	appearance: none;
	-webkit-appearance: none;
	padding-right: 30px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 10px center;
	cursor: pointer;
}
.gt select:focus-visible,
.gt-control--text input:focus { border-color: var(--ct-accent); box-shadow: 0 0 0 3px var(--ct-accent-soft); }

/* switch: label on the left, toggle on the right */
.gt-switch { justify-content: space-between; width: 100%; color: var(--ct-text); font-size: 13px; font-weight: 500; }

/* segmented: full width */
.gt-seg { display: flex; width: 100%; }
.gt-seg label { flex: 1; }
.gt-seg span { justify-content: center; width: 100%; padding: 0 8px; }

/* presets */
.gt-presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 0 16px 16px; }
.gt-preset {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
	height: 36px;
	padding: 0 10px;
	font: inherit;
	font-size: 13px;
	font-weight: 500;
	text-align: left;
	color: var(--ct-text);
	background: var(--ct-bg);
	border: 1px solid var(--ct-border);
	border-radius: 8px;
	cursor: pointer;
	transition: border-color .15s, background-color .15s;
}
.gt-preset span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gt-preset:hover { border-color: var(--ct-border-strong); background: var(--ct-surface); }
.gt-preset:focus-visible { outline: none; border-color: var(--ct-accent); box-shadow: 0 0 0 3px var(--ct-accent-soft); }
.gt-preset.is-active { border-color: var(--ct-accent); background: var(--ct-accent-soft); }
.gt-preset__swatch { display: inline-flex; flex: none; }
.gt-preset__swatch i {
	width: 14px;
	height: 14px;
	margin-left: -4px;
	border-radius: 50%;
	box-shadow: 0 0 0 2px var(--ct-bg), inset 0 0 0 1px rgba(15, 23, 42, .15);
}
.gt-preset__swatch i:first-child { margin-left: 0; }

/* ---------- Preview + code ---------- */

.gt-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.gt-card {
	background: var(--ct-bg);
	border: 1px solid var(--ct-border);
	border-radius: var(--ct-radius);
	overflow: hidden;
}

.gt-card__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 10px;
	min-height: 46px;
	padding: 6px 8px 6px 14px;
	background: var(--ct-surface);
	border-bottom: 1px solid var(--ct-border);
}
.gt-card__head h2 { margin: 0; font-size: 14px; font-weight: 600; color: var(--ct-text); }
.gt-card__tools { display: flex; align-items: center; gap: 2px; margin-left: auto; }

.gt-bg .ct-seg span { height: 24px; padding: 0 8px; font-size: 12px; }
.gt-bg { margin-left: auto; }

.gt-preview {
	display: block;
	width: 100%;
	height: 300px;
	border: 0;
	background: #f1f5f9;
	transition: height .15s ease;
}

.gt-tabs { display: inline-flex; padding: 2px; background: var(--ct-surface-2); border-radius: 8px; }

.gt [data-gt="code"].ce { height: clamp(260px, 40vh, 420px); }

@media (max-width: 575.98px) {
	.gt-card__tools .ct-tool span { display: none; }
	.gt-presets { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
	.gt-preview, .gt-preset, summary.gt-section__title::after { transition: none; }
}

/* Small screens: preview first, then settings, then code */
@media (max-width: 999.98px) {
	.gt-main { display: contents; }
	.gt-main > :first-child { order: -1; }
}

.gt-preset { padding: 0 8px; font-size: 12.5px; gap: 7px; }

/* Free-form panel sections (e.g. a curve editor) */
.gt-custom { display: grid; gap: 12px; padding: 2px 16px 16px; min-width: 0; }

/* Generators with a tall main column: don't make it sticky */
.gt--static .gt-main { position: static; }

/* Image thumbnails on preset buttons */
.gt-preset__thumb { flex: none; width: 22px; height: 22px; object-fit: contain; border-radius: 4px; background: var(--ct-surface-2); }
.gt-control[hidden] { display: none !important; }

/* Icon choice grid (radio buttons) */
.gt-choice { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.gt-choice legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.gt-choice label { position: relative; margin: 0; min-width: 0; }
.gt-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.gt-choice label > span {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 3px;
	padding: 7px 3px 5px;
	color: var(--ct-muted);
	background: var(--ct-bg);
	border: 1px solid var(--ct-border);
	border-radius: 8px;
	cursor: pointer;
	transition: border-color .15s, background-color .15s, color .15s;
}
.gt-choice svg { display: block; width: 28px; height: 20px; }
.gt-choice em { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-style: normal; font-family: var(--ct-mono); font-size: 10.5px; font-weight: 600; line-height: 1.3; }
.gt-choice label > span:hover { color: var(--ct-text); border-color: var(--ct-border-strong); }
.gt-choice input:checked + span { color: var(--ct-accent); border-color: var(--ct-accent); background: var(--ct-accent-soft); }
.gt-choice input:focus-visible + span { box-shadow: 0 0 0 3px var(--ct-accent-soft); border-color: var(--ct-accent); }
.gt-choice input:disabled + span { cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) { .gt-choice label > span { transition: none; } }
