/* Yaraku Translate Demo. Keep the mobile media query in sync with mobileQuery in includes/demo.php:
   phones in portrait (<768px) and phones in landscape (touch + short viewport). */

/* Pair page intro (default template) */
.ytd-pair-hero { padding: 24px 16px 12px; }
.pair-intro { max-width: 1320px; margin: 0 auto 20px; }
.pair-intro h1 { font-size: 26px; margin: 8px 0 4px; line-height: 1.4; }
.pair-intro p { margin: 0; font-size: 14px; color: #666; }

/* Language-pair links (mobile only, like the translator; shown in the media query below) */
.pair-links { display: none; max-width: 960px; margin: 0 auto; padding: 64px 16px 24px; }
.pair-links-title { text-align: center; margin: 0 0 24px; }
.pair-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.pair-list a { display: block; padding: 6px 14px; border: 1px solid #e6e6e6; border-radius: 999px; font-size: 13px; color: inherit; text-decoration: none; }
.pair-list a:hover, .pair-list a[aria-current] { border-color: #dc503c; color: #dc503c; }
.pair-more { text-align: center; font-size: 13px; }
.pair-more summary { cursor: pointer; color: #666; margin-bottom: 12px; }

/* Mobile translator (.ymt). Self-contained: it must not rely on the theme's base styles. */
.ymt { display: none; }
/* :where() keeps these resets at zero specificity so the .ymt-* rules below always win. */
:where(.ymt, .ymt *, .ymt *::before, .ymt *::after) { box-sizing: border-box; }
:where(.ymt) :where(button, textarea) { font: inherit; color: inherit; margin: 0; }
:where(.ymt) textarea { -webkit-appearance: none; appearance: none; box-shadow: none; }
.ymt-sr-only {
	position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (max-width: 767px), (pointer: coarse) and (max-height: 500px) {
	.pair-links { display: block; }

	.ytd-pair-hero { padding: 12px 16px 8px; }
	.pair-intro h1 { font-size: 20px; }
	.pair-intro p { font-size: 13px; }

	.ymt {
		--ymt-border: #d9dce0;
		--ymt-muted: #7a8088;
		--ymt-soft: #f4f5f7;
		--ymt-focus: #2b343b;
		--ymt-red: #dc503c;
		display: flex;
		flex-direction: column;
		gap: 12px;
		font-size: 15px;
		line-height: 1.7;
	}

	/* Language bar */
	.ymt-langbar { display: grid; grid-template-columns: 1fr 44px 1fr; align-items: center; gap: 4px; }
	.ymt-lang {
		display: flex; align-items: center; justify-content: space-between; gap: 6px;
		min-height: 44px; padding: 0 12px; min-width: 0;
		background: #fff; border: 1px solid var(--ymt-border); border-radius: 6px;
		font-size: 14px; text-align: left; cursor: pointer;
		-webkit-tap-highlight-color: transparent;
	}
	.ymt-lang span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.ymt-lang::after {
		content: ""; flex: none; width: 7px; height: 7px; margin-top: -4px;
		border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg);
	}
	.ymt-lang:active { background: var(--ymt-soft); }
	.ymt-swap {
		width: 44px; height: 44px; display: grid; place-items: center;
		background: none; border: 0; border-radius: 50%; cursor: pointer; color: var(--text, #1a1a1a);
		-webkit-tap-highlight-color: transparent;
	}
	.ymt-swap svg { width: 20px; height: 20px; }
	.ymt-swap:active { background: var(--ymt-soft); }
	.ymt-swap:disabled { opacity: .35; cursor: default; }

	/* Cards */
	.ymt-card {
		position: relative;
		display: flex; flex-direction: column;
		border: 1px solid var(--ymt-border); border-radius: 6px; background: #fff;
		transition: border-color .15s;
	}
	.ymt-card:focus-within { border-color: var(--ymt-focus); }
	.ymt-card.is-error, .ymt-card.is-error:focus-within { border-color: var(--ymt-red); }
	.ymt-target { background: var(--ymt-soft); }
	.ymt-card[hidden] { display: none; }

	.ymt textarea {
		display: block; width: 100%; min-height: 168px; max-height: 50vh; max-height: 50dvh;
		padding: 14px 44px 8px 14px; border: 0; background: transparent; resize: none; outline: none;
		font-size: 16px; /* >=16px prevents iOS zoom on focus */
		line-height: 1.7; overflow-y: auto; overflow-wrap: anywhere; white-space: pre-wrap;
	}
	.ymt textarea::placeholder { color: #a3a8ae; }
	.ymt textarea[hidden] { display: none; }
	.ymt-target textarea { min-height: 140px; }

	.ymt-card-foot {
		display: flex; align-items: center; justify-content: space-between; gap: 8px;
		padding: 4px 6px 6px 14px; min-height: 52px;
	}
	.ymt-count { font-size: 12px; color: var(--ymt-muted); font-variant-numeric: tabular-nums; }
	.ymt-count.is-over { color: var(--ymt-red); font-weight: 700; }
	.ymt-detected { font-size: 12px; color: var(--ymt-muted); }

	.ymt-icon {
		width: 44px; height: 44px; display: grid; place-items: center; flex: none;
		background: none; border: 0; border-radius: 50%; color: var(--ymt-muted); cursor: pointer;
		-webkit-tap-highlight-color: transparent;
	}
	.ymt-icon svg { width: 20px; height: 20px; }
	.ymt-icon:active { background: rgba(0,0,0,.06); }
	.ymt-icon[hidden] { display: none; }
	.ymt-clear { position: absolute; top: 2px; right: 2px; }

	/* Loading */
	.ymt-loading {
		min-height: 140px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
		font-size: 13px; color: var(--ymt-muted);
	}
	.ymt-loading[hidden] { display: none; }
	.ymt-progress { width: 60%; height: 4px; border-radius: 2px; background: #e1e3e6; overflow: hidden; }
	.ymt-progress i { display: block; width: 40%; height: 100%; border-radius: 2px; background: #6b737c; animation: ymt-progress 1.1s ease-in-out infinite; }
	@keyframes ymt-progress { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
	.ymt.is-loading .ymt-target .ymt-copy-wrap { visibility: hidden; }
	/* Live re-translation: keep the previous result on screen, dimmed, instead of flashing the loader. */
	.ymt.is-loading .ymt-target textarea { opacity: .55; transition: opacity .15s; }

	/* Messages */
	.ymt-message { margin: -2px 2px 0; font-size: 13px; line-height: 1.6; color: var(--ymt-muted); }
	.ymt-message[hidden] { display: none; }
	.ymt-message.is-error { color: var(--ymt-red); }
	.ymt-retry {
		min-height: 36px; margin-left: 4px; padding: 0 12px; border: 1px solid currentColor; border-radius: 999px;
		background: #fff; color: inherit; font-size: 13px; cursor: pointer;
	}

	/* Copy tooltip */
	.ymt-copy-wrap { position: relative; display: inline-flex; }
	.ymt-tooltip {
		position: absolute; bottom: calc(100% + 4px); right: 0; white-space: nowrap;
		padding: 4px 10px; border-radius: 4px; background: #2b343b; color: #fff; font-size: 12px;
		animation: ymt-fade .15s ease;
	}
	.ymt-tooltip[hidden] { display: none; }
	@keyframes ymt-fade { from { opacity: 0; transform: translateY(4px); } }

	/* Language sheet */
	.ymt-sheet { position: fixed; inset: 0; z-index: 1000; }
	.ymt-sheet[hidden] { display: none; }
	.ymt-sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.35); opacity: 0; transition: opacity .2s; }
	.ymt-sheet-panel {
		position: absolute; left: 0; right: 0; bottom: 0;
		max-height: 85vh; max-height: 85dvh; display: flex; flex-direction: column;
		background: #fff; border-radius: 12px 12px 0 0;
		padding-bottom: env(safe-area-inset-bottom);
		transform: translateY(100%); transition: transform .22s ease;
	}
	.ymt-sheet.is-open .ymt-sheet-backdrop { opacity: 1; }
	.ymt-sheet.is-open .ymt-sheet-panel { transform: none; }
	.ymt-sheet-head {
		display: flex; align-items: center; justify-content: space-between;
		padding: 6px 6px 6px 16px; border-bottom: 1px solid #eee;
	}
	.ymt-sheet-head h2 { margin: 0; font-size: 15px; }
	.ymt-sheet-list { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
	.ymt-sheet-list button {
		display: flex; align-items: center; justify-content: space-between; width: 100%;
		min-height: 48px; padding: 0 16px; border: 0; background: none; text-align: left; font-size: 15px; cursor: pointer;
		-webkit-tap-highlight-color: transparent;
	}
	.ymt-sheet-list button:active, .ymt-sheet-list button:focus-visible { background: var(--ymt-soft); outline: none; }
	.ymt-sheet-list button[aria-selected="true"] { background: var(--ymt-soft); font-weight: 700; }
	.ymt-sheet-list button[aria-selected="true"]::after {
		content: ""; width: 12px; height: 7px; margin-top: -4px;
		border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg);
	}
	.ymt-sheet-open, .ymt-sheet-open body { overflow: hidden; }
}

/* Landscape phones: keep fields compact so Translate stays reachable with the keyboard open. */
@media (pointer: coarse) and (max-height: 500px) {
	.ymt textarea { min-height: 96px; max-height: 40vh; max-height: 40dvh; }
	.ymt-loading { min-height: 96px; }
}

@media (prefers-reduced-motion: reduce) {
	.ymt-progress i { animation-duration: 3s; }
	.ymt-sheet-panel, .ymt-sheet-backdrop { transition: none; }
}
