/**
 * YouTube TV Screen - フロント
 */

.ytv-wrap {
	--ytv-accent: #ff5a3c;
	--ytv-max: 1000px;
	--ytv-ratio: 16 / 9;
	--ytv-frame-ratio: 1.777;
	--ytv-remote-w: 208px;
	--ytv-gap: 18px;

	box-sizing: border-box;
	display: flex;
	align-items: flex-start;
	gap: var(--ytv-gap);
	width: 100%;
	max-width: var(--ytv-max);
	margin: 1.5em 0;
	outline: none;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
}

.ytv-wrap *,
.ytv-wrap *::before,
.ytv-wrap *::after {
	box-sizing: border-box;
}

.ytv-wrap:focus-visible {
	outline: 2px solid var(--ytv-accent);
	outline-offset: 6px;
}

/* 配置 */
.ytv-align-center { margin-left: auto; margin-right: auto; }
.ytv-align-left   { margin-right: auto; }
.ytv-align-right  { margin-left: auto; }

/* リモコン位置 */
.ytv-remote-right { flex-direction: row; max-width: calc(var(--ytv-max) + var(--ytv-remote-w) + var(--ytv-gap)); }
.ytv-remote-left  { flex-direction: row-reverse; max-width: calc(var(--ytv-max) + var(--ytv-remote-w) + var(--ytv-gap)); }
.ytv-remote-bottom { flex-direction: column; align-items: center; }
.ytv-no-remote .ytv-remote { display: none; }

.ytv-tv {
	flex: 1 1 auto;
	min-width: 0;
	width: 100%;
}

.ytv-remote-bottom .ytv-tv { max-width: var(--ytv-max); }

/* =========================================================
   テレビ本体（画像フレーム：リビング／カスタム画像）
   ========================================================= */
.ytv-image-frame .ytv-frame {
	position: relative;
	width: 100%;
	aspect-ratio: var(--ytv-frame-ratio);
	background-image: var(--ytv-frame-image);
	background-size: 100% 100%;
	background-position: center;
	background-repeat: no-repeat;
	border-radius: 6px;
	overflow: hidden;
}

.ytv-image-frame .ytv-screen {
	position: absolute;
	top: var(--ytv-screen-top, 5.6%);
	left: var(--ytv-screen-left, 15.2%);
	width: var(--ytv-screen-width, 70%);
	height: var(--ytv-screen-height, 51.2%);
	border-radius: 3px;
}

.ytv-image-frame .ytv-bezel-bottom,
.ytv-image-frame .ytv-stand {
	display: none;
}

/* =========================================================
   テレビ本体（CSS描画：レトロ／モダン）
   ========================================================= */
.ytv-theme-retro .ytv-frame {
	position: relative;
	padding: 22px 22px 0;
	border-radius: 30px 30px 18px 18px;
	background:
		linear-gradient(180deg, #4a4a52 0%, #33333a 12%, #26262c 60%, #1b1b20 100%);
	box-shadow:
		inset 0 2px 0 rgba(255, 255, 255, .18),
		inset 0 -3px 8px rgba(0, 0, 0, .6),
		0 22px 40px rgba(0, 0, 0, .35);
}

.ytv-theme-retro .ytv-screen {
	position: relative;
	width: 100%;
	aspect-ratio: var(--ytv-ratio);
	border-radius: 22px / 30px;
	box-shadow:
		inset 0 0 0 6px #101014,
		inset 0 0 40px rgba(0, 0, 0, .95);
}

.ytv-theme-modern .ytv-frame {
	position: relative;
	padding: 8px 8px 0;
	border-radius: 10px 10px 4px 4px;
	background: linear-gradient(180deg, #2b2d33 0%, #17181c 100%);
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, .12),
		0 18px 34px rgba(0, 0, 0, .35);
}

.ytv-theme-modern .ytv-screen {
	position: relative;
	width: 100%;
	aspect-ratio: var(--ytv-ratio);
	border-radius: 4px;
	box-shadow: inset 0 0 0 2px #0b0b0d;
}

/* 下ベゼル（ロゴ・LED・つまみ） */
.ytv-bezel-bottom {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 0 20px;
	height: 52px;
	color: rgba(255, 255, 255, .55);
	font-size: 13px;
	letter-spacing: .18em;
	font-weight: 700;
}

.ytv-theme-modern .ytv-bezel-bottom {
	height: 26px;
	padding: 0 12px;
	font-size: 10px;
}

.ytv-brand {
	text-shadow: 0 1px 0 rgba(0, 0, 0, .6);
}

.ytv-led {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: #5a1f18;
	box-shadow: 0 0 6px rgba(0, 0, 0, .8) inset;
	transition: background .25s, box-shadow .25s;
}

.is-on .ytv-led {
	background: var(--ytv-accent);
	box-shadow: 0 0 10px var(--ytv-accent);
}

.ytv-knobs {
	display: flex;
	gap: 10px;
}

.ytv-knobs i {
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: radial-gradient(circle at 35% 30%, #6a6a74, #2a2a30 70%);
	box-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}

.ytv-theme-modern .ytv-knobs { display: none; }

/* スタンド */
.ytv-stand {
	position: relative;
	display: flex;
	justify-content: center;
	gap: 120px;
	height: 26px;
}

.ytv-stand span {
	width: 18px;
	height: 26px;
	background: linear-gradient(180deg, #26262c, #131316);
	border-radius: 0 0 6px 6px;
	transform: perspective(60px) rotateX(-14deg);
}

.ytv-theme-modern .ytv-stand { gap: 0; }
.ytv-theme-modern .ytv-stand span:first-child { display: none; }
.ytv-theme-modern .ytv-stand span {
	width: 120px;
	height: 10px;
	border-radius: 0 0 10px 10px;
	transform: none;
}

/* =========================================================
   画面の中身
   ========================================================= */
.ytv-screen {
	position: relative;
	overflow: hidden;
	background: #000;
	container-type: size;
}

.ytv-player-slot {
	position: absolute;
	inset: 0;
	overflow: hidden;
}

/* YouTube API はマウント用の div を iframe に置き換えるため、
   div / iframe どちらにも効くように「>*」で指定する。 */
.ytv-player-slot > * {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	display: block;
	border: 0;
	background: #000;
}

/* 画面の形に合わせて16:9を収める */
.ytv-fit-contain .ytv-player-slot > * {
	width: min(100cqw, calc(100cqh * 16 / 9));
	height: min(100cqh, calc(100cqw * 9 / 16));
}

.ytv-fit-cover .ytv-player-slot > * {
	width: max(100cqw, calc(100cqh * 16 / 9));
	height: max(100cqh, calc(100cqw * 9 / 16));
}

/* コンテナクエリ非対応ブラウザ向け */
@supports not (container-type: size) {
	.ytv-player-slot > * {
		width: 100%;
		height: 100%;
	}
}

/* 電源OFF時は画面を隠す */
.ytv-wrap:not(.is-on) .ytv-player-slot {
	visibility: hidden;
}

/* 走査線 */
.ytv-scanlines {
	position: absolute;
	inset: 0;
	pointer-events: none;
	opacity: 0;
	background:
		repeating-linear-gradient(
			to bottom,
			rgba(0, 0, 0, .22) 0,
			rgba(0, 0, 0, .22) 1px,
			transparent 1px,
			transparent 3px
		);
	mix-blend-mode: multiply;
	transition: opacity .3s;
}

.ytv-has-scanlines.is-on .ytv-scanlines { opacity: 1; }

/* 画面の映り込み */
.ytv-glare {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background:
		radial-gradient(120% 80% at 15% -10%, rgba(255, 255, 255, .12), rgba(255, 255, 255, 0) 55%);
	opacity: .8;
}

.ytv-theme-retro .ytv-glare { opacity: 1; }

/* 砂嵐 */
.ytv-noise {
	position: absolute;
	inset: -20%;
	pointer-events: none;
	opacity: 0;
	z-index: 4;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.75'/%3E%3C/svg%3E");
	background-size: 140px 140px;
	transition: opacity .12s;
}

.is-noise .ytv-noise {
	opacity: .85;
	animation: ytv-static .12s steps(2) infinite;
}

@keyframes ytv-static {
	0%   { background-position: 0 0; }
	25%  { background-position: -30px 20px; }
	50%  { background-position: 40px -25px; }
	75%  { background-position: -20px -40px; }
	100% { background-position: 25px 30px; }
}

/* 電源OFF表示 */
.ytv-standby {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4%;
	background: #000;
	color: rgba(255, 255, 255, .55);
	letter-spacing: .3em;
	font-size: clamp(11px, 4.5cqw, 26px);
	font-weight: 700;
	transition: opacity .35s ease, visibility .35s;
}

.is-on .ytv-standby {
	opacity: 0;
	visibility: hidden;
}

.ytv-standby-text {
	animation: ytv-blink 2.4s ease-in-out infinite;
}

@keyframes ytv-blink {
	0%, 100% { opacity: .35; }
	50% { opacity: .85; }
}

.ytv-standby-btn {
	appearance: none;
	cursor: pointer;
	border: 1px solid rgba(255, 255, 255, .28);
	background: rgba(255, 255, 255, .06);
	color: #fff;
	border-radius: 999px;
	padding: .5em 1.4em;
	font-size: clamp(10px, 3cqw, 15px);
	letter-spacing: .12em;
	font-family: inherit;
	transition: background .2s, border-color .2s, transform .1s;
}

.ytv-standby-btn:hover {
	background: var(--ytv-accent);
	border-color: var(--ytv-accent);
}

.ytv-standby-btn:active { transform: scale(.96); }

/* ブラウン管の消灯アニメーション */
.ytv-flash {
	position: absolute;
	inset: 0;
	z-index: 6;
	pointer-events: none;
	background: #fff;
	opacity: 0;
	transform: scaleY(0);
}

.is-crtoff .ytv-flash {
	animation: ytv-crt-off .38s ease-out forwards;
}

@keyframes ytv-crt-off {
	0%   { opacity: .0; transform: scaleY(1); }
	28%  { opacity: .35; transform: scaleY(1); }
	60%  { opacity: .75; transform: scaleY(.012); }
	100% { opacity: 0; transform: scaleY(.012) scaleX(.0); }
}

.is-crton .ytv-flash {
	animation: ytv-crt-on .5s ease-out forwards;
}

@keyframes ytv-crt-on {
	0%   { opacity: .8; transform: scaleY(.01) scaleX(.2); }
	45%  { opacity: .5; transform: scaleY(.04) scaleX(1); }
	100% { opacity: 0; transform: scaleY(1) scaleX(1); }
}

/* OSD（チャンネル・タイトル表示） */
.ytv-osd {
	position: absolute;
	top: 4%;
	left: 3%;
	z-index: 7;
	max-width: 70%;
	padding: .5em .9em;
	border-left: 3px solid var(--ytv-accent);
	border-radius: 3px;
	background: rgba(0, 0, 0, .62);
	color: #fff;
	backdrop-filter: blur(2px);
	opacity: 0;
	transform: translateY(-6px);
	transition: opacity .25s, transform .25s;
	pointer-events: none;
	line-height: 1.35;
}

.ytv-osd.is-visible {
	opacity: 1;
	transform: translateY(0);
}

.ytv-osd-ch {
	display: block;
	font-size: clamp(11px, 4cqw, 22px);
	font-weight: 800;
	letter-spacing: .08em;
	text-shadow: 0 0 12px rgba(0, 0, 0, .8);
}

.ytv-osd-title {
	display: block;
	font-size: clamp(9px, 2.6cqw, 14px);
	opacity: .8;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ytv-osd-title:empty { display: none; }

/* =========================================================
   リモコン
   ========================================================= */
.ytv-remote {
	flex: 0 0 var(--ytv-remote-w);
	width: var(--ytv-remote-w);
	padding: 16px 14px 18px;
	border-radius: 26px;
	background: linear-gradient(165deg, #3a3d45 0%, #23252b 40%, #16171b 100%);
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, .16),
		inset 0 -2px 6px rgba(0, 0, 0, .6),
		0 16px 30px rgba(0, 0, 0, .32);
	color: #cfd3da;
	user-select: none;
}

.ytv-remote-bottom .ytv-remote {
	margin-top: 4px;
	width: 260px;
	flex: none;
}

.ytv-remote-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 12px;
}

.ytv-remote-brand {
	font-size: 9px;
	letter-spacing: .22em;
	opacity: .55;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ボタン共通 */
.ytv-btn {
	appearance: none;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 34px;
	height: 34px;
	padding: 0 8px;
	border: 0;
	border-radius: 10px;
	background: linear-gradient(180deg, #4b4e57 0%, #32353d 100%);
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, .18),
		0 2px 3px rgba(0, 0, 0, .45);
	color: #e8ebf0;
	font-size: 13px;
	font-family: inherit;
	line-height: 1;
	transition: transform .08s ease, box-shadow .12s, background .2s, color .2s;
}

.ytv-btn:hover { background: linear-gradient(180deg, #565a65 0%, #3a3d46 100%); }

.ytv-btn:active,
.ytv-btn.is-pressed {
	transform: translateY(1px);
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, .5);
}

.ytv-btn:focus-visible {
	outline: 2px solid var(--ytv-accent);
	outline-offset: 2px;
}

.ytv-btn-power {
	background: linear-gradient(180deg, #d8402c 0%, #94210f 100%);
	color: #fff;
	border-radius: 50%;
	min-width: 36px;
	height: 36px;
	padding: 0;
	font-size: 15px;
}

.is-on .ytv-btn-power {
	background: linear-gradient(180deg, #58d68a 0%, #23874d 100%);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 0 12px rgba(88, 214, 138, .45);
}

.is-muted .ytv-btn-mute {
	background: linear-gradient(180deg, #d8402c 0%, #94210f 100%);
	color: #fff;
}

.is-shuffle [data-act="shuffle"] {
	background: linear-gradient(180deg, #3d8bd8 0%, #1d4f86 100%);
	color: #fff;
}

/* 小型ディスプレイ */
.ytv-remote-display {
	margin-bottom: 12px;
	padding: 7px 10px;
	border-radius: 8px;
	background: #10161a;
	box-shadow: inset 0 2px 6px rgba(0, 0, 0, .7);
	color: #7be0a4;
	font-family: "SFMono-Regular", Consolas, "Courier New", monospace;
	min-height: 44px;
}

.ytv-rd-ch {
	display: block;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: .1em;
}

.ytv-rd-title {
	display: block;
	margin-top: 2px;
	font-size: 10px;
	opacity: .65;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* 十字キー */
.ytv-dpad {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	grid-template-rows: repeat(3, 1fr);
	gap: 5px;
	margin-bottom: 12px;
}

.ytv-dpad .ytv-btn { width: 100%; }

.ytv-dpad-up    { grid-area: 1 / 2; }
.ytv-dpad-left  { grid-area: 2 / 1; }
.ytv-dpad-ok    { grid-area: 2 / 2; }
.ytv-dpad-right { grid-area: 2 / 3; }
.ytv-dpad-down  { grid-area: 3 / 2; }

.ytv-dpad-ok {
	border-radius: 50%;
	background: linear-gradient(180deg, #5d626d 0%, #383c45 100%);
	font-size: 14px;
	font-weight: 700;
}

.ytv-remote-row {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 10px;
}

.ytv-btn-wide { flex: 1; font-size: 11px; letter-spacing: .04em; }

.ytv-row-label {
	font-size: 9px;
	letter-spacing: .12em;
	opacity: .55;
	width: 26px;
}

.ytv-vol-meter {
	flex: 1;
	height: 6px;
	border-radius: 3px;
	background: rgba(0, 0, 0, .45);
	box-shadow: inset 0 1px 2px rgba(0, 0, 0, .6);
	overflow: hidden;
}

.ytv-vol-meter i {
	display: block;
	height: 100%;
	width: 60%;
	background: var(--ytv-accent);
	transition: width .18s;
}

/* テンキー */
.ytv-keypad {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 5px;
}

.ytv-keypad .ytv-btn {
	width: 100%;
	font-size: 13px;
	font-weight: 600;
}

.ytv-remote-foot {
	margin-top: 10px;
	text-align: center;
}

.ytv-remote-hint {
	font-size: 9px;
	letter-spacing: .06em;
	opacity: .45;
}

/* =========================================================
   全画面
   ========================================================= */
.ytv-wrap:fullscreen {
	max-width: none;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 2vmin;
	background: #05050a;
	align-items: center;
	justify-content: center;
}

.ytv-wrap:fullscreen .ytv-tv {
	max-width: min(100%, calc((100vh - 4vmin) * var(--ytv-frame-ratio)));
}

/* =========================================================
   レスポンシブ
   ========================================================= */
@media (max-width: 782px) {
	.ytv-wrap {
		flex-direction: column;
		align-items: center;
	}

	.ytv-remote,
	.ytv-remote-right .ytv-remote,
	.ytv-remote-left .ytv-remote {
		width: min(100%, 280px);
		flex: none;
	}

	.ytv-tv { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
	.ytv-noise,
	.ytv-flash,
	.ytv-standby-text {
		animation: none !important;
	}
}

/* 管理者向けの注意書き */
.ytv-notice {
	padding: 12px 16px;
	border-left: 4px solid #d63638;
	background: #fcf0f1;
	color: #3c434a;
}
