/*
 * 캔버스 공통 스타일 — 프론트 팝업·인라인 달력·관리자 미리보기(Shadow DOM)가 함께 쓴다.
 * 모든 치수는 renderer.js가 --oucc-* 변수로 주입한다 (cqw = 캔버스 너비 비례, TRD §5.2).
 * 테마 CSS 간섭을 막기 위해 .oucc-frame 하위 요소는 필요한 속성을 명시적으로 초기화한다.
 */

.oucc-frame {
	container-type: inline-size;
	position: relative;
	box-sizing: border-box;
	/* PC 기준 너비 → 화면 너비 − 32px → (화면 높이 90% − 버튼 줄) × 비율 중 가장 작은 값 (F-CV-03) */
	width: min(calc(var(--oucc-w, 700) * 1px), calc(100vw - 32px), calc((90vh - 56px) * var(--oucc-ratio-num, 1)));
	width: min(calc(var(--oucc-w, 700) * 1px), calc(100vw - 32px), calc((90dvh - 56px) * var(--oucc-ratio-num, 1)));
	margin: 0;
	padding: 0;
	font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
	line-height: 1.2;
	text-align: left;
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

.oucc-frame--inline {
	width: min(calc(var(--oucc-w, 700) * 1px), 100%);
	margin-inline: auto;
}

.oucc-frame *,
.oucc-frame *::before,
.oucc-frame *::after {
	box-sizing: border-box;
}

.oucc-canvas {
	position: relative;
	isolation: isolate;
	width: 100%;
	aspect-ratio: var(--oucc-ratio, 1 / 1);
	overflow: hidden;
	background: var(--oucc-bg-color, #f6e7d5);
	border-radius: var(--oucc-radius, 0);
	transition: opacity 0.2s ease;
}

.oucc-frame.is-switching .oucc-canvas {
	opacity: 0;
}

.oucc-bg {
	position: absolute;
	inset: 0;
	z-index: -1;
	display: block;
	width: 100%;
	max-width: none;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	object-fit: cover;
	box-shadow: none;
	opacity: var(--oucc-bg-opacity, 1); /* 아래 캔버스 배경색과 섞여 밝기·톤 조절 */
}

/* 제목 */
.oucc-frame .oucc-title {
	position: absolute;
	display: flex;
	flex-wrap: nowrap;
	align-items: baseline;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	font-size: inherit;
	line-height: 1.15;
	letter-spacing: -0.02em;
	white-space: nowrap;
	text-transform: none;
	text-shadow: none;
}

.oucc-frame .oucc-title span {
	display: inline-block;
}

/* 다음 달 / 이번 달 전환 배지 */
.oucc-frame .oucc-switch {
	-webkit-appearance: none;
	appearance: none;
	position: absolute;
	top: var(--oucc-next-top, 3%);
	right: var(--oucc-next-right, 3%);
	z-index: 2;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0.4em 0.9em; /* 렌더러가 관리자 설정값으로 덮어씀 */
	border: var(--oucc-next-bw, 0px) solid var(--oucc-next-bc, transparent); /* 관리자 지정 테두리 (기본 없음) */
	border-radius: 999px;
	background: var(--oucc-next-bg, #6b2e1f);
	color: var(--oucc-next-fg, #fff);
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: 0;
	text-transform: none;
	white-space: nowrap;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
	cursor: pointer;
}

.oucc-frame .oucc-switch:hover {
	filter: brightness(1.08);
}

.oucc-frame .oucc-switch:focus {
	outline: none; /* 테마의 button:focus 스타일 무력화 — 마우스·터치·열기 시에는 링 없음 */
}

/* 키보드 포커스에만 링 표시 (접근성). 배지 배경색 링 + 흰 간격으로 어떤 배경에서도 보이게 */
.oucc-frame .oucc-switch:focus-visible {
	outline: 2px solid var(--oucc-next-bg, #6b2e1f);
	outline-offset: 2px;
	box-shadow: 0 0 0 2px #fff;
}

/* 달력 영역 (D-6: padding이 아닌 inset) */
.oucc-area {
	position: absolute;
	overflow: hidden; /* 표 행 높이 반올림으로 생기는 1~2px 넘침이 안내문을 침범하지 않도록 */
	top: var(--oucc-area-top, 25%);
	right: var(--oucc-area-right, 5%);
	bottom: var(--oucc-area-bottom, 15%);
	left: var(--oucc-area-left, 5%);
	padding: var(--oucc-area-pad, 0px);
	background: var(--oucc-area-bg, transparent);
	border-radius: var(--oucc-area-radius, 0px);
}

.oucc-frame .oucc-grid {
	width: 100%;
	margin: 0;
	border: 0;
	border-collapse: separate;
	border-spacing: 0;
	background: none;
	table-layout: fixed;
	font-size: inherit;
	line-height: 1.15;
}

.oucc-frame .oucc-grid caption,
.oucc-frame .oucc-grid thead,
.oucc-frame .oucc-grid tbody,
.oucc-frame .oucc-grid tr {
	border: 0;
	background: none;
}

.oucc-frame .oucc-grid th {
	height: var(--oucc-head-h);
	padding: 0;
	border: 0;
	background: var(--oucc-head-bg);
	color: var(--oucc-head-color);
	font-family: var(--oucc-head-font);
	font-size: var(--oucc-head-size);
	font-weight: var(--oucc-head-weight);
	text-align: center;
	vertical-align: middle;
	letter-spacing: 0.02em;
	text-transform: none;
}

.oucc-frame .oucc-grid th:first-child {
	border-start-start-radius: var(--oucc-head-radius);
	border-end-start-radius: var(--oucc-head-radius);
}

.oucc-frame .oucc-grid th:last-child {
	border-start-end-radius: var(--oucc-head-radius);
	border-end-end-radius: var(--oucc-head-radius);
}

.oucc-frame .oucc-grid th.is-sun {
	color: var(--oucc-sun);
}

.oucc-frame .oucc-grid th.is-sat {
	color: var(--oucc-sat);
}

.oucc-frame .oucc-grid td {
	height: calc(var(--oucc-row-h) - var(--oucc-divider-w, 0px));
	padding: 0 1px;
	overflow: hidden;
	border: 0;
	background: none;
	text-align: center;
	vertical-align: middle;
}

.oucc-cell {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	height: calc(var(--oucc-row-h) - var(--oucc-divider-w, 0px));
	overflow: hidden;
}

.oucc-frame .oucc-grid.has-divider tbody tr:not(:last-child) td {
	border-bottom: var(--oucc-divider-w, 1px) solid var(--oucc-divider-color);
}

/* 날짜 숫자 색 (TRD §4.3): 공휴일 > 일요일 > 토요일 > 평일 */
.oucc-date {
	display: block;
	color: var(--oucc-date-color);
	font-family: var(--oucc-date-font);
	font-size: var(--oucc-date-size);
	font-weight: var(--oucc-date-weight);
	font-variant-numeric: tabular-nums;
	line-height: 1.05;
}

td.is-sat .oucc-date {
	color: var(--oucc-sat);
}

td.is-sun .oucc-date {
	color: var(--oucc-sun);
}

td.is-holiday .oucc-date {
	color: var(--oucc-holiday);
}

td.is-outside .oucc-date {
	opacity: 0.35;
}

td.is-today .oucc-date {
	display: inline-block;
	min-width: 1.9em;
	height: 1.9em;
	line-height: calc(1.9em - 4px);
	border: 2px solid currentColor;
	border-radius: 50%;
}

.oucc-badge {
	display: inline-block;
	max-width: 100%;
	margin-top: 0.15em;
	padding: 0.12em 0.6em;
	overflow: hidden;
	border-radius: var(--oucc-badge-radius);
	font-family: var(--oucc-badge-font);
	font-size: var(--oucc-badge-size);
	font-weight: var(--oucc-badge-weight);
	line-height: 1.15;
	text-overflow: ellipsis;
	white-space: nowrap;
	vertical-align: top;
	flex-shrink: 0;
}

td.is-closed .oucc-badge {
	background: var(--oucc-closed-bg);
	color: var(--oucc-closed-fg);
}

td.is-short .oucc-badge {
	background: var(--oucc-short-bg);
	color: var(--oucc-short-fg);
}

td.is-open .oucc-badge {
	background: var(--oucc-open-bg);
	color: var(--oucc-open-fg);
}

.oucc-reason {
	display: block;
	max-width: 100%;
	margin-top: 0.1em;
	overflow: hidden;
	color: var(--oucc-reason-color);
	font-family: var(--oucc-reason-font);
	font-size: var(--oucc-reason-size);
	font-weight: var(--oucc-reason-weight);
	line-height: 1.1;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* 월 하단 안내문: 달력 영역 바로 아래 여백 (F-HD-08) */
.oucc-frame .oucc-footer {
	position: absolute;
	top: calc(100% - var(--oucc-area-bottom, 15%) + var(--oucc-footer-offset, 0px));
	right: var(--oucc-area-right, 5%);
	left: var(--oucc-area-left, 5%);
	margin: 0;
	padding: 0;
	color: var(--oucc-footer-color);
	font-family: var(--oucc-footer-font);
	font-size: var(--oucc-footer-size);
	font-weight: var(--oucc-footer-weight);
	line-height: 1.35;
	text-align: center;
	word-break: keep-all;
}

/* 하단 로고: 기본 위치 = 하단 가운데(아래 3%), 관리자 지정 X/Y만큼 이동 */
.oucc-frame .oucc-logo {
	position: absolute;
	bottom: 3%;
	left: 50%;
	z-index: 1;
	display: block;
	max-width: none;
	height: auto;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	transform: translate(calc(-50% + var(--oucc-logo-x, 0px)), var(--oucc-logo-y, 0px));
	pointer-events: none;
	user-select: none;
}

/* 편집 중 영역 표시 (F-AR-06) */
.oucc-frame.is-editing .oucc-area {
	outline: 1px dashed rgba(220, 38, 38, 0.85);
}

.oucc-frame.is-editing .oucc-title {
	outline: 1px dashed rgba(37, 99, 235, 0.85);
}

.oucc-frame.is-editing .oucc-logo {
	outline: 1px dashed rgba(22, 163, 74, 0.9);
}

.oucc-sr {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: -1px !important;
	padding: 0 !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

@media (prefers-reduced-motion: reduce) {
	.oucc-canvas {
		transition: none;
	}
}

/* 컨테이너 쿼리 단위 미지원 브라우저: PC 너비 고정 px 렌더 (TRD §13) */
@supports not (width: 1cqw) {
	.oucc-frame,
	.oucc-frame--inline {
		width: calc(var(--oucc-w, 700) * 1px);
		max-width: none;
	}
}
