/* SW KASI Sync - 일출/일몰·월출/월몰 위젯 */

.sw-ksasi {
	--ks-bg: #ffffff;
	--ks-fg: #1f2937;
	--ks-muted: #6b7280;
	--ks-border: #e5e7eb;
	--ks-sun-bg: linear-gradient(180deg, #fff7e6 0%, #ffffff 100%);
	--ks-sun: #f59e0b;
	--ks-moon-bg: linear-gradient(180deg, #eef2ff 0%, #ffffff 100%);
	--ks-moon: #6366f1;
	--ks-track: #e5e7eb;
	--ks-btn-bg: #f3f4f6;
	--ks-btn-hover: #e5e7eb;

	position: relative;
	box-sizing: border-box;
	max-width: 420px;
	margin: 0 0 1.5em;
	padding: 18px;
	border: 1px solid var(--ks-border);
	border-radius: 16px;
	background: var(--ks-bg);
	color: var(--ks-fg);
	font-size: 15px;
	line-height: 1.4;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
}

.sw-ksasi *,
.sw-ksasi *::before,
.sw-ksasi *::after {
	box-sizing: border-box;
}

.sw-ksasi--dark {
	--ks-bg: #111827;
	--ks-fg: #f3f4f6;
	--ks-muted: #9ca3af;
	--ks-border: #1f2937;
	--ks-sun-bg: linear-gradient(180deg, #2a2116 0%, #111827 100%);
	--ks-sun: #fbbf24;
	--ks-moon-bg: linear-gradient(180deg, #1e1b4b 0%, #111827 100%);
	--ks-moon: #a5b4fc;
	--ks-track: #374151;
	--ks-btn-bg: #1f2937;
	--ks-btn-hover: #374151;
}

/* 헤더 */
.sw-ksasi__head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 14px;
}

.sw-ksasi__title {
	font-size: 17px;
	font-weight: 700;
}

.sw-ksasi__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 8px;
	margin-top: 2px;
	color: var(--ks-muted);
	font-size: 13px;
}

.sw-ksasi__place::after {
	content: "·";
	margin-left: 8px;
}

.sw-ksasi__nav {
	display: flex;
	gap: 4px;
	flex-shrink: 0;
}

.sw-ksasi__btn {
	min-width: 32px;
	height: 32px;
	padding: 0 10px;
	border: 0;
	border-radius: 8px;
	background: var(--ks-btn-bg);
	color: var(--ks-fg);
	font-size: 16px;
	line-height: 32px;
	cursor: pointer;
	transition: background .15s;
}

.sw-ksasi__btn:hover,
.sw-ksasi__btn:focus-visible {
	background: var(--ks-btn-hover);
}

.sw-ksasi__btn--today {
	font-size: 13px;
}

/* 카드 */
.sw-ksasi__body {
	display: grid;
	gap: 10px;
}

.sw-ksasi__card {
	padding: 14px 12px 12px;
	border-radius: 12px;
}

.sw-ksasi__card--sun {
	background: var(--ks-sun-bg);
}

.sw-ksasi__card--moon {
	background: var(--ks-moon-bg);
}

.sw-ksasi__row {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	text-align: center;
}

.sw-ksasi__item {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.sw-ksasi__label {
	color: var(--ks-muted);
	font-size: 12px;
}

.sw-ksasi__time {
	font-size: 22px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	letter-spacing: -.02em;
}

.sw-ksasi__card--sun .sw-ksasi__item:first-child .sw-ksasi__time,
.sw-ksasi__card--sun .sw-ksasi__item:last-child .sw-ksasi__time {
	color: var(--ks-sun);
}

.sw-ksasi__card--moon .sw-ksasi__item:first-child .sw-ksasi__time,
.sw-ksasi__card--moon .sw-ksasi__item:last-child .sw-ksasi__time {
	color: var(--ks-moon);
}

.sw-ksasi__time--sub {
	font-size: 16px;
	font-weight: 600;
	padding-top: 4px;
}

.sw-ksasi__none {
	color: var(--ks-muted);
	font-weight: 400;
}

.sw-ksasi__foot {
	margin-top: 10px;
	color: var(--ks-muted);
	font-size: 13px;
	text-align: center;
}

.sw-ksasi__foot strong {
	color: var(--ks-fg);
}

/* 해 ↔ 달 전환 (type="both") — 두 카드를 같은 칸에 겹쳐 높이를 고정하고 교차 페이드 */
.sw-ksasi__cards {
	display: grid;
}

.sw-ksasi--flip .sw-ksasi__card {
	position: relative;
	display: flex;
	flex-direction: column;
	justify-content: center;
	grid-area: 1 / 1;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	user-select: none;
	transition: opacity .35s ease, transform .35s ease, visibility .35s;
}

.sw-ksasi--flip:not([data-view="moon"]) .sw-ksasi__card--moon,
.sw-ksasi--flip[data-view="moon"] .sw-ksasi__card--sun {
	visibility: hidden;
	opacity: 0;
	transform: scale(.97);
	pointer-events: none;
}

.sw-ksasi--flip .sw-ksasi__card:active {
	transform: scale(.985);
}

.sw-ksasi__switch {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 1;
	padding: 3px 9px;
	border: 0;
	border-radius: 999px;
	background: var(--ks-btn-bg);
	color: var(--ks-muted);
	font: inherit;
	font-size: 11px;
	font-weight: 600;
	line-height: 1.5;
	cursor: pointer;
	transition: background .15s, color .15s;
}

.sw-ksasi__switch:hover,
.sw-ksasi__switch:focus-visible {
	background: var(--ks-btn-hover);
	color: var(--ks-fg);
}

.sw-ksasi__switch:focus-visible {
	outline: 2px solid var(--ks-moon);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.sw-ksasi--flip .sw-ksasi__card {
		transition: none;
	}
}

/* 태양 궤적 */
.sw-ksasi__arc {
	max-width: 220px;
	margin: 0 auto 6px;
}

.sw-ksasi__arc svg {
	display: block;
	width: 100%;
	height: auto;
	overflow: visible;
}

.sw-ksasi__arc-track {
	fill: none;
	stroke: var(--ks-track);
	stroke-width: 2;
	stroke-dasharray: 4 4;
}

.sw-ksasi__arc-done {
	fill: none;
	stroke: var(--ks-sun);
	stroke-width: 3;
	stroke-linecap: round;
}

.sw-ksasi__arc-sun {
	fill: var(--ks-sun);
	filter: drop-shadow(0 0 4px rgba(245, 158, 11, .6));
}

.sw-ksasi__arc-horizon {
	stroke: var(--ks-track);
	stroke-width: 1;
}

/* 달 위상 그래픽 */
.sw-ksasi__moon {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 16px;
	margin: 2px 0 12px;
}

.sw-ksasi__moon-svg {
	display: block;
	flex-shrink: 0;
	width: 84px;
	height: 84px;
	border-radius: 50%;
	box-shadow: 0 0 18px rgba(200, 210, 255, .25);
}

.sw-ksasi__moon-dark {
	fill: #15171f;
}

.sw-ksasi__moon-earthshine {
	opacity: .14;
}

.sw-ksasi__moon-lit {
	filter: brightness(1.3) contrast(1.08);
}

.sw-ksasi__moon-info {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.sw-ksasi__moon-name {
	font-size: 17px;
	font-weight: 700;
}

.sw-ksasi__moon-meta {
	color: var(--ks-muted);
	font-size: 13px;
	font-variant-numeric: tabular-nums;
}

/* 박명 */
.sw-ksasi__twilight {
	width: 100%;
	margin: 0;
	border-collapse: collapse;
	font-size: 13px;
	font-variant-numeric: tabular-nums;
}

.sw-ksasi__twilight th,
.sw-ksasi__twilight td {
	padding: 6px 8px;
	border: 0;
	border-bottom: 1px solid var(--ks-border);
	background: transparent;
	color: var(--ks-fg);
	text-align: center;
}

.sw-ksasi__twilight thead th {
	color: var(--ks-muted);
	font-weight: 500;
}

.sw-ksasi__twilight tbody th {
	font-weight: 600;
	text-align: left;
}

/* 기타 */
.sw-ksasi__error {
	padding: 12px;
	border-radius: 10px;
	background: #fef2f2;
	color: #b91c1c;
	font-size: 14px;
}

.sw-ksasi__credit {
	margin-top: 10px;
	color: var(--ks-muted);
	font-size: 11px;
	text-align: right;
}

.sw-ksasi.is-loading {
	pointer-events: none;
}

.sw-ksasi.is-loading .sw-ksasi__body {
	opacity: .4;
	transition: opacity .15s;
}

@media (max-width: 360px) {
	.sw-ksasi {
		padding: 14px;
	}

	.sw-ksasi__time {
		font-size: 19px;
	}
}
