/* Elvish Translator — widget styles
   Brand colors: blue #0361FF, green #009B21, red #FB0000
   Red always marks the CURRENT INPUT side; it moves when the flip
   arrow swaps input/output. Blue marks the output side, green is
   used for success states (copied, spoken) and the translate button. */

:root {
	--et-blue: #0361FF;
	--et-green: #009B21;
	--et-red: #FB0000;
	--et-ink: #1a1a2e;
	--et-bg: #ffffff;
	--et-muted: #6b7280;
	--et-border: #e5e7eb;
	--et-radius: 14px;
}

/* Optional Tengwar / Cirth webfonts — supply your own font files, see readme.txt */
@font-face {
	font-family: 'Tengwar Annatar';
	src: url('../fonts/tengwar-annatar.woff2') format('woff2'),
	     url('../fonts/tengwar-annatar.ttf') format('truetype');
	font-display: swap;
}
@font-face {
	font-family: 'Cirth Erebor';
	src: url('../fonts/cirth-erebor.woff2') format('woff2'),
	     url('../fonts/cirth-erebor.ttf') format('truetype');
	font-display: swap;
}

.et-widget, .et-widget *, .et-widget *::before, .et-widget *::after {
	box-sizing: border-box;
}

.et-widget {
	width: 100%;
	max-width: 100%;
	margin: 24px 0;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	color: var(--et-ink);
	display: grid;
	grid-template-columns: 1fr 56px 1fr;
	align-items: stretch;
	gap: 16px;
}

.et-panel {
	width: 100%;
	background: var(--et-bg);
	border: 2px solid var(--et-border);
	border-radius: var(--et-radius);
	padding: 16px;
	display: flex;
	flex-direction: column;
	box-shadow: 0 1px 3px rgba(0,0,0,0.06);
	transition: border-color .2s ease, box-shadow .2s ease;
	min-width: 0; /* let grid children shrink instead of overflowing */
}

/* Physical position: whichever panel is currently the INPUT always sits on
   the left (order 1), output always sits on the right (order 3), flip
   button stays centered between them (order 2) — regardless of which
   panel that happens to be. Driven by the widget's data-direction
   attribute, so it re-orders itself automatically when JS flips it. */
.et-panel--source { order: 1; }
.et-flip-wrap { order: 2; }
.et-panel--fixed { order: 3; }

.et-widget[data-direction="to_source"] .et-panel--source { order: 3; }
.et-widget[data-direction="to_source"] .et-panel--fixed { order: 1; }

/* Input side is always red */
.et-panel.et-is-input {
	border-color: var(--et-red);
	box-shadow: 0 0 0 3px rgba(251,0,0,0.08);
}

/* Output side is always blue */
.et-panel.et-is-output {
	border-color: var(--et-blue);
	box-shadow: 0 0 0 3px rgba(3,97,255,0.08);
}

.et-panel__head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 10px;
}

/* Custom dropdown caret (SVG chevron) since native selects can't take one directly */
.et-lang-select {
	width: 100%;
	max-width: 220px;
	font-size: 14px;
	padding: 8px 34px 8px 12px;
	border-radius: 8px;
	border: 1px solid #d1d5db;
	background-color: #fff;
	font-weight: 600;
	color: var(--et-ink);
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%231a1a2e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
	background-repeat: no-repeat;
	background-position: right 12px center;
	cursor: pointer;
}

.et-fixed-label {
	font-weight: 700;
	font-size: 15px;
	color: var(--et-muted); /* neutral until the panel is marked input/output below */
}

/* Label color follows whichever role the panel currently holds. */
.et-panel.et-is-input .et-fixed-label {
	color: var(--et-red);
}
.et-panel.et-is-output .et-fixed-label {
	color: var(--et-blue);
}

.et-textarea {
	width: 100%;
	flex: 1 1 auto;
	min-height: 160px;
	border: none;
	resize: none; /* no drag handle / grip in the corner */
	font-size: 16px;
	line-height: 1.5;
	outline: none;
	background: transparent;
	font-family: inherit;
	padding: 0;
}

/* No highlight ring / background change on click or focus — the panel's
   own red/blue border already shows which side is active. */
.et-textarea:focus,
.et-textarea:focus-visible,
.et-textarea:active {
	outline: none;
	box-shadow: none;
	background: transparent;
}

.et-output {
	overflow-y: auto;
	white-space: pre-wrap;
	word-break: break-word;
}

.et-output--script.et-output--tengwar {
	font-family: 'Tengwar Annatar', serif;
	font-size: 26px;
	line-height: 2;
}

.et-output--script.et-output--cirth {
	font-family: 'Cirth Erebor', serif;
	font-size: 24px;
	line-height: 2;
}

.et-panel__footer {
	display: flex;
	justify-content: flex-end;
	margin-top: 6px;
}

.et-word-count {
	font-size: 12px;
	color: var(--et-muted);
}

.et-word-count.et-word-count--over {
	color: var(--et-red);
	font-weight: 700;
}

.et-panel__actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-top: 10px;
	flex-wrap: wrap;
}

.et-actions-left {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.et-btn {
	border: 1px solid #d1d5db;
	background: #f9fafb;
	color: var(--et-ink);
	font-size: 13px;
	font-weight: 600;
	padding: 6px 12px;
	border-radius: 8px;
	cursor: pointer;
	transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.et-btn:hover {
	border-color: var(--et-blue);
	color: var(--et-blue);
}

.et-btn.et-btn--success {
	border-color: var(--et-green);
	color: #fff;
	background: var(--et-green);
}

.et-flip-wrap {
	display: flex;
	align-items: center;
	justify-content: center;
}

.et-flip-btn {
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: 2px solid var(--et-blue);
	background: #fff;
	color: var(--et-blue);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: transform .2s ease, background .2s ease, color .2s ease;
	padding: 0;
}

.et-flip-btn svg {
	display: block;
	width: 20px;
	height: 20px;
	pointer-events: none;
}

.et-flip-btn:hover {
	background: var(--et-blue);
	color: #fff;
	transform: rotate(180deg);
}

/* Translate button lives bottom-right of whichever panel is currently the
   input side; hidden on the output side. */
.et-translate-btn {
	background: var(--et-green);
	color: #fff;
	border: none;
	padding: 10px 20px;
	border-radius: 999px;
	font-weight: 700;
	font-size: 14px;
	cursor: pointer;
	white-space: nowrap;
	transition: filter .15s ease;
	margin-left: auto;
	display: none;
}

.et-panel.et-is-input .et-translate-btn {
	display: inline-flex;
	align-items: center;
}

.et-translate-btn:hover {
	filter: brightness(1.08);
}

.et-translate-btn:disabled {
	opacity: .6;
	cursor: default;
	filter: none;
}

.et-status {
	grid-column: 1 / -1;
	min-height: 18px;
	font-size: 13px;
	color: var(--et-muted);
	text-align: center;
}

.et-status.et-status--error {
	color: var(--et-red);
	font-weight: 600;
}

.et-error {
	color: var(--et-red);
	font-weight: 600;
}

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

@media (max-width: 820px) {
	.et-widget {
		grid-template-columns: 1fr;
		gap: 12px;
	}
	.et-flip-wrap {
		padding: 4px 0;
	}
	.et-flip-btn:hover {
		transform: rotate(90deg);
	}
	.et-textarea {
		min-height: 130px;
	}
}

@media (max-width: 480px) {
	.et-panel {
		padding: 12px;
	}
	.et-lang-select {
		max-width: 100%;
	}
	.et-panel__actions {
		flex-direction: column;
		align-items: stretch;
	}
	.et-actions-left {
		justify-content: space-between;
	}
	.et-translate-btn {
		margin-left: 0;
		width: 100%;
		justify-content: center;
		text-align: center;
	}
}
