/*
 * Image Converter. Colours, type and borders follow the Anduro theme
 * (anduro/theme.json), so the tool reads as part of andu.ro inside its iframe.
 */

@font-face {
	font-family: "JetBrains Mono";
	src: url("/wp-content/themes/anduro/assets/fonts/jetbrains-mono-latin.woff2") format("woff2");
	font-weight: 100 800;
	font-display: swap;
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
	font-family: "JetBrains Mono";
	src: url("/wp-content/themes/anduro/assets/fonts/jetbrains-mono-latin-ext.woff2") format("woff2");
	font-weight: 100 800;
	font-display: swap;
	unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
	--base: #05070a;
	--surface: #0d1218;
	--surface-2: #151c24;
	--text: #c9d6df;
	--dim: #8a99a5;
	--cyan: #35e4ff;
	--teal: #0f9cb3;
	--yellow: #fbc916;
	--magenta: #ff4fa3;
	--green: #6ef07a;
	--red: #ff5c5c;
	--rule: 1px solid #1f2a35;
	--glow: 0 0 0 1px rgba(53, 228, 255, 0.35), 0 0 18px rgba(53, 228, 255, 0.18);
	--mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
	color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	background: var(--base);
	color: var(--text);
	font: 15px/1.6 var(--mono);
	-webkit-text-size-adjust: 100%;
}

/* Inside the andu.ro page the frame sits on the site's own background. */
html.is-embedded, html.is-embedded body { background: transparent; }

a { color: var(--cyan); }

:focus-visible {
	outline: 2px solid var(--yellow);
	outline-offset: 2px;
}

[hidden] { display: none !important; }

.ic {
	max-width: 68rem;
	margin: 0 auto;
	padding: 1.25rem 1rem 1rem;
	display: grid;
	gap: 1rem;
}

/* ------------------------------------------------------------ drop zone */

.drop {
	display: grid;
	gap: 0.4rem;
	place-items: center;
	text-align: center;
	padding: 2.5rem 1.25rem;
	border: 1px dashed var(--teal);
	border-radius: 2px;
	background: var(--surface);
	cursor: pointer;
	transition: border-color 0.2s, box-shadow 0.2s, padding 0.2s;
}

.drop:hover, .drop.is-over {
	border-color: var(--cyan);
	box-shadow: var(--glow);
}

.drop.is-over { border-style: solid; }

.drop__cmd {
	font-size: 1.15rem;
	color: var(--text);
}

.drop__prompt { color: var(--green); }

.drop__sub {
	color: var(--dim);
	font-size: 0.8rem;
	max-width: 46rem;
}

.has-file .drop { padding: 0.9rem 1rem; }
.has-file .drop__sub { display: none; }
.has-file .drop__cmd { font-size: 0.9rem; }

/* ------------------------------------------------------------ status */

.status {
	padding: 0.75rem 1rem;
	border: var(--rule);
	background: var(--surface);
}

.status__text { margin: 0; }
.status.is-error { border-color: var(--magenta); }
.status.is-error .status__text { color: var(--magenta); }
.status.is-ok .status__text { color: var(--green); }

.status__log summary { cursor: pointer; color: var(--dim); font-size: 0.8rem; margin-top: 0.5rem; }
.status__log pre {
	max-height: 14rem;
	overflow: auto;
	font-size: 0.72rem;
	color: var(--dim);
	white-space: pre-wrap;
	word-break: break-all;
}

.bar {
	height: 4px;
	margin-top: 0.6rem;
	background: var(--surface-2);
	overflow: hidden;
}

.bar span {
	display: block;
	height: 100%;
	width: 0;
	background: var(--cyan);
	box-shadow: 0 0 10px var(--cyan);
	transition: width 0.15s linear;
}

/* ------------------------------------------------------------ panels */

.work {
	display: grid;
	gap: 1rem;
	grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 60rem) {
	.work { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
	.panel--files, .panel--view { grid-column: 1 / -1; }
	.panel--meta { grid-column: 1; }
	.work__side { grid-column: 2; }
}

.panel {
	padding: 1rem 1.1rem 1.1rem;
	border: var(--rule);
	border-radius: 2px;
	background: var(--surface);
	min-width: 0;
	align-self: start;
}

.panel__head {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1rem;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 0.75rem;
}

.panel h2 {
	margin: 0;
	font-size: 0.78rem;
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: 0.14em;
	color: var(--dim);
}

.panel h2::before { content: "> "; color: var(--teal); }

.fname {
	margin: 0 0 0.6rem;
	color: var(--cyan);
	word-break: break-all;
}

.facts {
	display: grid;
	grid-template-columns: max-content minmax(0, 1fr);
	gap: 0.15rem 1rem;
	margin: 0;
	font-size: 0.85rem;
}

.facts dt { color: var(--dim); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.badge {
	display: inline-block;
	margin-left: 0.4rem;
	padding: 0 0.35rem;
	font-size: 0.7rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	border: 1px solid currentColor;
	border-radius: 2px;
	vertical-align: 1px;
}

.badge--lossless { color: var(--green); }
.badge--lossy { color: var(--yellow); }

/* ------------------------------------------------------------ controls */

.btn {
	font: inherit;
	font-size: 0.85rem;
	color: var(--text);
	background: var(--surface-2);
	border: 1px solid #2a3846;
	border-radius: 2px;
	padding: 0.45rem 0.9rem;
	cursor: pointer;
	text-decoration: none;
	display: inline-block;
	line-height: 1.4;
}

.btn:hover { border-color: var(--cyan); color: var(--cyan); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
	background: var(--cyan);
	border-color: var(--cyan);
	color: var(--base);
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.btn--primary:hover { color: var(--base); box-shadow: var(--glow); }
.btn--ghost { background: transparent; }
.btn--small { font-size: 0.75rem; padding: 0.2rem 0.55rem; }

input[type="text"], textarea, select {
	font: inherit;
	font-size: 0.85rem;
	width: 100%;
	color: var(--text);
	background: var(--base);
	border: 1px solid #2a3846;
	border-radius: 2px;
	padding: 0.4rem 0.5rem;
	min-width: 0;
}

input[type="text"]:focus, textarea:focus, select:focus { border-color: var(--cyan); outline: none; box-shadow: var(--glow); }

.check-label {
	display: inline-flex;
	gap: 0.5rem;
	align-items: center;
	font-size: 0.8rem;
	color: var(--dim);
	cursor: pointer;
}

input[type="checkbox"], input[type="radio"] { accent-color: var(--cyan); }

/* A choice of two, as one control. */
.seg { display: inline-flex; border: 1px solid #2a3846; border-radius: 2px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 0.2rem 0.6rem; font-size: 0.75rem; color: var(--dim); }
.seg label:hover span { color: var(--text); }
.seg input:checked + span { background: var(--surface-2); color: var(--cyan); box-shadow: inset 0 0 0 1px var(--cyan); }
.seg input:focus-visible + span { outline: 2px solid var(--yellow); outline-offset: 2px; }

.panel__btns { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* ------------------------------------------------------------ files */

.files { margin: 0; padding: 0; list-style: none; display: grid; gap: 1px; font-size: 0.8rem; max-height: 18rem; overflow-y: auto; }

.file {
	display: grid;
	grid-template-columns: 2.6rem minmax(0, 1fr) auto auto auto;
	gap: 0.75rem;
	align-items: center;
	padding: 0.15rem 0.3rem 0.15rem 0;
	border-left: 2px solid transparent;
}

.file.is-current { background: var(--surface-2); border-left-color: var(--cyan); }
.file__name { all: unset; cursor: pointer; padding: 0.15rem 0.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file__name:hover { color: var(--cyan); }
.file__name:focus-visible { outline: 2px solid var(--yellow); }
.file.is-current .file__name { color: var(--cyan); }
.file__info { color: var(--dim); font-size: 0.72rem; white-space: nowrap; }
.file__state { font-size: 0.72rem; white-space: nowrap; color: var(--dim); }
.file__state.is-ok { color: var(--green); }
.file__state.is-error { color: var(--red); }
.file__state a { color: var(--cyan); }
.file__x { all: unset; cursor: pointer; color: var(--dim); padding: 0 0.3rem; }
.file__x:hover { color: var(--red); }
.file__x:focus-visible { outline: 2px solid var(--yellow); }

@media (max-width: 34rem) {
	.file { grid-template-columns: 2.6rem minmax(0, 1fr) auto auto; }
	.file__info { display: none; }
}

/* ------------------------------------------------------------ output */

.preset { display: inline-flex; gap: 0.5rem; align-items: center; }
.preset span { font-size: 0.72rem; color: var(--dim); }
.preset select { width: auto; max-width: 15rem; padding: 0.2rem 0.4rem; font-size: 0.78rem; }

.formats {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
	gap: 0.4rem;
}

.fmt {
	position: relative;
	display: grid;
	gap: 0.05rem;
	padding: 0.5rem 0.65rem;
	border: 1px solid #2a3846;
	border-radius: 2px;
	background: var(--base);
	cursor: pointer;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.fmt input { position: absolute; opacity: 0; pointer-events: none; }
.fmt b { font-weight: 600; font-size: 0.9rem; }
.fmt small { color: var(--dim); font-size: 0.68rem; }
.fmt:hover { border-color: var(--teal); }
.fmt:has(input:disabled), .seg:has(input:disabled), .field:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }
.fmt:has(input:checked) { border-color: var(--cyan); box-shadow: var(--glow); }
.fmt:has(input:checked) b { color: var(--cyan); }
.fmt:has(input:focus-visible) { outline: 2px solid var(--yellow); outline-offset: 2px; }

.opts {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
	gap: 0.6rem 0.75rem;
	margin-top: 1rem;
}

.opt { display: grid; gap: 0.15rem; min-width: 0; }

.notes {
	margin: 0.9rem 0 0;
	padding: 0;
	list-style: none;
	display: grid;
	gap: 0.3rem;
	font-size: 0.78rem;
	color: var(--dim);
}

.notes li::before { content: "// "; color: var(--teal); }
.notes li.is-warn::before { color: var(--yellow); }
.notes li.is-lost { color: var(--red); }
.notes li.is-lost::before { color: var(--red); }

.go {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	align-items: center;
	margin-top: 1rem;
}

.go__est { color: var(--dim); font-size: 0.8rem; }

/* ------------------------------------------------------------ result */

.result {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	align-items: center;
	margin-bottom: 0.75rem;
}

.result__name { color: var(--cyan); word-break: break-all; }

.foot {
	margin: 0.25rem 0 0;
	color: var(--dim);
	font-size: 0.72rem;
}

/* ------------------------------------------------------------ this tool */

.file__thumb {
	display: grid;
	place-items: center;
	height: 2rem;
	overflow: hidden;
	background: var(--base);
	color: var(--dim);
	font-size: 0.6rem;
	text-transform: uppercase;
}
.file__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.tools { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.tool {
	font: inherit;
	font-size: 0.72rem;
	color: var(--dim);
	background: transparent;
	border: 1px solid #2a3846;
	border-radius: 2px;
	padding: 0.15rem 0.55rem;
	cursor: pointer;
}
.tool:hover:not(:disabled) { color: var(--cyan); border-color: var(--teal); }
.tool:disabled { opacity: 0.4; cursor: not-allowed; }
.tool[aria-pressed="true"] { color: var(--cyan); border-color: var(--cyan); background: var(--surface-2); }

/* The picture. A checkerboard shows through anything transparent. */
.stage {
	position: relative;
	overflow: hidden;
	user-select: none;
	touch-action: pan-y;
	background-color: var(--base);
	background-image: linear-gradient(45deg, #151c24 25%, transparent 25%, transparent 75%, #151c24 75%), linear-gradient(45deg, #151c24 25%, transparent 25%, transparent 75%, #151c24 75%);
	background-size: 16px 16px;
	background-position: 0 0, 8px 8px;
	border: var(--rule);
}
.stage.is-zoomed { overflow: auto; cursor: grab; touch-action: none; }
.stage__in { position: relative; margin: 0 auto; }
.stage__in img { position: absolute; top: 0; left: 0; display: block; max-width: none; }
.stage.is-zoomed .stage__in img { image-rendering: pixelated; }

.stage__handle {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 2.2rem;
	margin-left: -1.1rem;
	cursor: ew-resize;
	touch-action: none;
}
.stage__handle::before {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	left: 50%;
	width: 2px;
	margin-left: -1px;
	background: var(--cyan);
	box-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
}
.stage__handle span {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 1.5rem;
	height: 1.5rem;
	margin: -0.75rem 0 0 -0.75rem;
	border-radius: 50%;
	background: var(--cyan);
	box-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
}
.stage__handle span::after {
	content: "⇔";
	display: block;
	text-align: center;
	color: var(--base);
	font-size: 0.85rem;
	line-height: 1.5rem;
}
.stage__label {
	position: absolute;
	top: 0.4rem;
	padding: 0 0.4rem;
	font-size: 0.68rem;
	background: rgba(5, 7, 10, 0.75);
	color: var(--text);
	pointer-events: none;
}
.stage__label--l { left: 0.4rem; }
.stage__label--r { right: 0.4rem; }

.sizes { margin: 0.6rem 0 0; font-size: 0.85rem; color: var(--dim); min-height: 1.4em; }
.sizes.is-pending { opacity: 0.6; }
.sizes b { color: var(--green); font-weight: 600; }
.sizes b.is-bigger { color: var(--yellow); }

/* Metadata. */
.panel--meta .panel__head { align-items: flex-start; }
.panel--meta .notes { margin-top: 0.7rem; }
.notes li.is-warn { color: var(--yellow); }
.notes a { margin-left: 0.25rem; }
.tagbar { margin-top: 0.8rem; }
.fields {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
	gap: 0.5rem 0.75rem;
	margin-top: 0.9rem;
}
.field { display: grid; gap: 0.15rem; min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field span, .opt span { font-size: 0.72rem; color: var(--dim); text-transform: lowercase; }
input.is-bad { border-color: var(--red) !important; }
.extra { margin-top: 0.9rem; }
.extra summary { cursor: pointer; color: var(--dim); font-size: 0.8rem; }
.extra summary:hover { color: var(--cyan); }
.alltags { max-height: 26rem; overflow-y: auto; margin-top: 0.5rem; }
.alltags h3 { margin: 0.7rem 0 0.2rem; font-size: 0.72rem; font-weight: 500; color: var(--teal); text-transform: uppercase; letter-spacing: 0.1em; }
.alltags .facts { font-size: 0.75rem; }

/* Output options. */
.opt--wide, .box { grid-column: 1 / -1; }
.box { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.q { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.4rem; }
.q input[type="range"] { flex: 1; min-width: 0; accent-color: var(--cyan); }
.q output { min-width: 2ch; text-align: right; color: var(--cyan); font-size: 0.9rem; }
.q input[type="text"] { width: 7rem; flex: none; }
.q select { width: auto; }
input[type="color"] { width: 3rem; height: 1.8rem; padding: 0; background: var(--base); border: 1px solid #2a3846; border-radius: 2px; cursor: pointer; }
.check-label { align-self: end; padding-bottom: 0.4rem; }
.work__side { display: grid; gap: 1rem; align-content: start; min-width: 0; }
#sizeMode { justify-self: start; }
#qualityBox { justify-items: stretch; }
