/* Chalympics Planner — templates/template-chalympics-planner.php */

.chalympics-planner {
	--ink: #1D1A1A;
	--ink-2: #6E6868;
	--ink-3: #A8A2A0;
	--hair: rgba(29, 26, 26, .09);
	--bg: #F5F3F1;
	--card: #FFFFFF;
	--accent: #5B3A6C;
	--accent-2: #4A2E59;
	--accent-soft: #F1E9F5;
	--shadow: 0 1px 3px rgba(29, 26, 26, .05), 0 0 0 1px var(--hair);
	--shadow-lift: 0 12px 32px rgba(29, 26, 26, .10), 0 0 0 1px var(--hair);
	background: var(--bg);
	color: var(--ink);
	font-family: Switzer, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
	-webkit-font-smoothing: antialiased;
	padding: 0 32px 96px;
}
.chalympics-planner * { box-sizing: border-box; }
.chalympics-planner button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
.cp-ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- top ---------- */
.cp-top { text-align: center; padding: 44px 0 32px; }
.cp-top__logo { height: 44px; width: auto; margin: 0 auto 16px; display: block; }
.cp-top__title {
	font-size: 60px; line-height: 1.02; font-weight: 700; letter-spacing: -.035em;
	margin: 0 0 10px; color: var(--ink);
}
.cp-top__sub .cp-short { display: none; }
.cp-top__sub { font-size: 21px; font-weight: 500; color: var(--ink-2); margin: 0; letter-spacing: -.01em; }

/* ---------- layout ---------- */
.cp-wrap {
	max-width: 1240px; margin: 0 auto;
	display: grid; grid-template-columns: 420px 1fr; gap: 28px; align-items: start;
}

/* ---------- your nights ---------- */
.cp-plan {
	position: sticky; top: 20px;
	background: var(--card); border-radius: 28px; box-shadow: var(--shadow);
	padding: 12px 12px 14px;
}
.cp-nights { list-style: none; margin: 0 0 12px; padding: 0; }
.cp-night { position: relative; }
.cp-night + .cp-night { margin-top: 2px; }
.cp-night__row {
	display: grid; grid-template-columns: 34px 92px 1fr; align-items: center; gap: 12px;
	width: 100%; min-height: 62px; padding: 8px 14px 8px 12px;
	border: 0; border-radius: 16px; background: transparent; text-align: left;
	transition: background-color .2s ease, box-shadow .2s ease;
}
button.cp-night__row { cursor: pointer; }
@media (hover: hover) { button.cp-night__row:hover { background: #F7F5F4; } }
.cp-night__num {
	width: 32px; height: 32px; border-radius: 50%;
	display: inline-flex; align-items: center; justify-content: center;
	font-size: 15px; font-weight: 600; color: var(--ink-2); background: #F0EDEB;
	transition: background-color .2s, color .2s;
}
.cp-night__date { display: flex; flex-direction: column; font-size: 14px; color: var(--ink-2); line-height: 1.2; }
.cp-night__date b { font-size: 17px; font-weight: 600; color: var(--ink); }
.cp-night__what {
	font-size: 17px; font-weight: 500; line-height: 1.25; letter-spacing: -.01em; min-width: 0;
	overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.cp-night.is-set .cp-night__row, .cp-night.is-locked .cp-night__row { padding-right: 50px; }
.cp-night.is-set .cp-night__what span { cursor: grab; }
.cp-night.is-set .cp-night__num,
.cp-night.is-locked .cp-night__num { background: var(--accent); color: #fff; }
.cp-night__icon {
	position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
	color: var(--ink-3); display: inline-flex;
}
/* iOS-style clear button: solid grey circle, bold white ✕ */
.chalympics-planner .cp-night__x {
	position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
	width: 28px; height: 28px; border: 0; border-radius: 50%; padding: 0;
	display: inline-flex; align-items: center; justify-content: center;
	background: #ADA6A3; color: #fff; cursor: pointer;
	transition: background-color .15s ease, transform .15s ease;
}
.chalympics-planner .cp-night__x svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; }
@media (hover: hover) { .chalympics-planner .cp-night__x:hover { background: #8E8784; transform: translateY(-50%) scale(1.08); } }
.cp-night__x:active { transform: translateY(-50%) scale(.92); }
.cp-night__x:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* invisible 44px tap target around it */
.cp-night__x::before { content: ""; position: absolute; inset: -9px; border-radius: 50%; }

.cp-night.is-shabbos .cp-night__row { opacity: .4; }
.cp-night.is-shabbos .cp-night__what { font-weight: 400; font-style: italic; }

/* the night you're choosing for */
.cp-night.is-target .cp-night__row,
.cp-night.is-target .cp-night__row:hover {
	background: var(--accent-soft);
	box-shadow: inset 0 0 0 2px var(--accent);
}
.cp-night.is-target .cp-night__num { background: var(--accent); color: #fff; }
.cp-night.is-target .cp-night__what { color: var(--accent); font-weight: 600; }
.cp-night.is-target.is-empty .cp-night__what::after {
	content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 8px; vertical-align: middle;
	border-radius: 50%; background: var(--accent); animation: cp-blink 1.4s ease-in-out infinite;
}
@keyframes cp-blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.cp-night.is-over .cp-night__row { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.cp-night.is-pulse .cp-night__row { animation: cp-pulse .7s ease; }
@keyframes cp-pulse { 0% { background: #E5D5EC; } 100% { background: transparent; } }

/* download */
.cp-send {
	display: flex; align-items: center; justify-content: center; gap: 10px;
	width: 100%; height: 58px; border: 0; border-radius: 18px;
	background: var(--accent); color: #fff !important; font-size: 19px !important; font-weight: 600; letter-spacing: -.01em;
	cursor: pointer; transition: transform .1s ease, background-color .2s ease;
}
.cp-send svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .cp-send:hover { background: var(--accent-2); } }
.cp-send:active { transform: scale(.98); }
.cp-send.is-busy { opacity: .6; cursor: progress; }
.cp-quiet-row { display: flex; justify-content: center; align-items: center; gap: 4px; margin-top: 8px; color: var(--ink-3); }
.cp-quiet {
	border: 0; background: none; padding: 6px 10px; cursor: pointer;
	font-size: 15px; font-weight: 500; color: var(--ink-2) !important; border-radius: 8px;
}
.cp-quiet:hover { color: var(--ink) !important; background: #F3F0EE; }

/* ---------- games ---------- */
.cp-games__title {
	font-size: 30px; font-weight: 700; letter-spacing: -.025em; line-height: 1.15;
	margin: 6px 0 18px; color: var(--ink);
}
.cp-games__title span { color: var(--accent); }
.cp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.cp-game {
	position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
	text-align: left; width: 100%;
	padding: 22px 64px 22px 22px; border: 0; border-radius: 24px;
	background: var(--card); box-shadow: var(--shadow); cursor: pointer;
	transition: box-shadow .2s ease, transform .2s ease, background-color .2s ease;
}
@media (hover: hover) {
	.cp-game:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
	}
.cp-game:active { transform: scale(.985); }
.cp-game:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.cp-game__title { font-size: 21px; font-weight: 600; line-height: 1.2; letter-spacing: -.02em; }
.cp-game__text { font-size: 16px; line-height: 1.5; color: var(--ink-2); }
.cp-game__mark {
	position: absolute; top: 20px; right: 20px;
	width: 34px; height: 34px; border-radius: 50%;
	display: inline-flex; align-items: center; justify-content: center;
	color: var(--accent); background: var(--accent-soft);
	transition: background-color .2s ease, color .2s ease, transform .2s ease;
}
.cp-game__night { font-size: 14px; font-weight: 600; color: var(--accent); margin-top: 2px; }

.cp-game.is-on { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.cp-game.is-on .cp-game__mark { background: var(--accent); color: #fff; }
.cp-game.is-locked { cursor: default; background: #EFEBE9; box-shadow: none; }
.cp-game.is-locked:hover { transform: none; }
.cp-game.is-locked .cp-game__mark, .cp-game.is-locked:hover .cp-game__mark { color: var(--ink-3); background: transparent; transform: none; }
.cp-game.is-locked .cp-game__night { color: var(--ink-2); }
.cp-game.is-dragging { opacity: .4; }

/* drag ghost */
.cp-ghost {
	position: fixed; left: 0; top: 0; z-index: 100000; pointer-events: none;
	padding: 12px 18px; border-radius: 14px; max-width: 280px;
	background: #5B3A6C; color: #fff;
	font: 600 16px Switzer, -apple-system, system-ui, sans-serif;
	box-shadow: 0 14px 34px rgba(29, 26, 26, .25);
}
body.cp-is-dragging, body.cp-is-dragging * { cursor: grabbing !important; user-select: none !important; -webkit-user-select: none !important; }

/* ---------- phone bar + toast ---------- */
.cp-bar { display: none; }
.cp-bar { transition: transform .3s cubic-bezier(.2, .8, .2, 1), opacity .3s ease; }
.cp-bar.is-away { transform: translateY(140%); opacity: 0; pointer-events: none; }
.cp-toast {
	position: fixed; left: 50%; bottom: 32px; z-index: 1000;
	transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
	max-width: calc(100vw - 32px);
	padding: 12px 20px; border-radius: 22px;
	background: rgba(29, 26, 26, .9); color: #fff; font-size: 16px; font-weight: 500;
	-webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
	transition: opacity .25s ease, transform .25s ease;
	width: max-content; text-align: center; line-height: 1.3;
}
.cp-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- download preview ---------- */
.cp-preview {
	width: min(680px, calc(100vw - 48px)); height: min(860px, calc(100vh - 48px)); height: min(860px, calc(100dvh - 48px)); max-height: none;
	padding: 0; border: 0; border-radius: 28px; overflow: hidden;
	background: #F5F3F1; color: #1D1A1A;
	box-shadow: 0 40px 100px rgba(29, 26, 26, .3);
	font-family: Switzer, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}
.cp-preview::backdrop { background: rgba(29, 26, 26, .4); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.cp-preview[open] { animation: cp-rise .32s cubic-bezier(.2, .8, .2, 1); }
@keyframes cp-rise { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }
.cp-preview__inner { display: flex; flex-direction: column; height: 100%; }
.cp-preview__head {
	display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
	padding: 14px 16px; background: rgba(245, 243, 241, .9);
	border-bottom: 1px solid rgba(29, 26, 26, .08);
}
.cp-preview__title { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.cp-preview__cancel {
	justify-self: start; border: 0; background: none; padding: 8px 10px; border-radius: 10px; cursor: pointer;
	font: 500 17px Switzer, -apple-system, system-ui, sans-serif; color: #5B3A6C;
}
.cp-preview__cancel:hover { background: rgba(91, 58, 108, .08); }
.cp-preview__body { flex: 1; min-height: 0; overflow-y: auto; padding: 24px; -webkit-overflow-scrolling: touch; }
.cp-paper { display: flex; flex-direction: column; gap: 18px; }
.cp-pg { position: relative; width: 100%; aspect-ratio: 1275 / 1650; overflow: hidden; border-radius: 6px; background: #EDE8EE;
	box-shadow: 0 1px 2px rgba(29, 26, 26, .06), 0 10px 30px rgba(29, 26, 26, .12); }
.cp-pg > .cpb-page { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.cp-pages-count { text-align: center; font-size: 14px; color: #6E6868; margin: -4px 0 2px; }
.cp-preview__foot { padding: 14px 20px 20px; background: #F5F3F1; border-top: 1px solid rgba(29, 26, 26, .08); }
.cp-preview .cp-send {
	display: flex; align-items: center; justify-content: center; gap: 10px;
	width: 100%; height: 58px; border: 0; border-radius: 18px; cursor: pointer;
	background: #5B3A6C; color: #fff !important; font: 600 19px Switzer, -apple-system, system-ui, sans-serif; letter-spacing: -.01em;
}
.cp-preview .cp-send:hover { background: #4A2E59; }
.cp-preview .cp-send svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.cp-preview .cp-send.is-busy { opacity: .6; cursor: progress; }
html.cp-modal-open { overflow: hidden; }

/* ---------- printable booklet ---------- */
/* Pages are laid out off-screen at full size (1275 x 1650) for the PDF and for printing. */
.cp-sheet { position: fixed; left: -20000px; top: 0; width: 1275px; pointer-events: none; }
.cp-sheet:empty { display: none; }

@media print {
	@page { size: letter; margin: 0; }
	html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
	body > *:not(.cp-sheet) { display: none !important; }
	.cp-sheet { position: static; left: auto; width: auto; }
	.cp-sheet .cpb-page { zoom: .64; break-after: page; page-break-after: always; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
	.cp-sheet .cpb-page:last-child { break-after: auto; page-break-after: auto; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
	.cp-wrap { grid-template-columns: 380px 1fr; }
	.cp-grid { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
	.cp-wrap { grid-template-columns: 1fr; gap: 28px; max-width: 680px; }
	.cp-plan { position: static; }
	.cp-grid { grid-template-columns: 1fr; }
	.cp-games { scroll-margin-top: 16px; }
}
@media (max-width: 640px) {
	.chalympics-planner { padding: 0 14px 112px; }
	.cp-top { padding: 28px 0 20px; }
	.cp-top__logo { height: 36px; margin-bottom: 12px; }
	.cp-top__title { font-size: 40px; }
	.cp-top__sub { font-size: 17px; }
	.cp-plan { padding: 8px 8px 6px; border-radius: 24px; }
	.cp-plan > .cp-send { display: none; }
	.cp-quiet-row { margin-top: 0; }
	.cp-night__row { grid-template-columns: 32px 66px 1fr; gap: 10px; min-height: 58px; padding: 0 44px 0 10px; }
	.cp-night__date b { font-size: 16px; }
	.cp-night__what { font-size: 16px; }
	.cp-games__title { font-size: 25px; }
	.cp-game { padding: 20px 60px 20px 20px; border-radius: 22px; }
	.cp-game__title { font-size: 20px; }
	.cp-bar {
		display: flex; align-items: center; gap: 12px;
		position: fixed; left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 900;
		padding: 8px 8px 8px 18px; border-radius: 22px;
		background: rgba(255, 255, 255, .85); box-shadow: 0 10px 34px rgba(29, 26, 26, .14), 0 0 0 1px var(--hair);
		-webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
	}
	.cp-bar__label { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; color: var(--accent); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
	.cp-bar__label small { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); }
	.cp-bar .cp-send { width: auto; height: 50px; padding: 0 22px; border-radius: 15px; font-size: 17px !important; }
	.cp-toast { bottom: 92px; }

	/* preview becomes a bottom sheet */
	.cp-preview { width: 100vw; max-width: 100vw; height: 92vh; height: 92dvh; margin: auto 0 0; border-radius: 26px 26px 0 0; }
	.cp-preview[open] { animation: cp-sheet-up .34s cubic-bezier(.2, .8, .2, 1); }
	@keyframes cp-sheet-up { from { transform: translateY(100%); } to { transform: none; } }
	.cp-preview__body { padding: 16px 12px; }
	.cp-top__sub .cp-long { display: none; }
	.cp-top__sub .cp-short { display: inline; }
	.cp-preview__foot { padding: 12px 14px max(14px, env(safe-area-inset-bottom)); }
}

/* small phones (iPhone SE / mini) */
@media (max-width: 360px) {
	.chalympics-planner { padding-left: 10px; padding-right: 10px; }
	.cp-top__title { font-size: 34px; }
	.cp-plan { padding: 6px 6px 4px; }
	.cp-night__row { grid-template-columns: 30px 52px 1fr; gap: 8px; padding-left: 8px; padding-right: 10px; }
	.cp-night.is-set .cp-night__row, .cp-night.is-locked .cp-night__row { padding-right: 44px; }
	.cp-night__num { width: 28px; height: 28px; font-size: 14px; }
	.cp-night__date b { font-size: 15px; }
	.cp-night__date { font-size: 13px; }
	.cp-night__what { font-size: 15px; }
	.chalympics-planner .cp-night__x { right: 10px; }
	.cp-bar { left: 8px; right: 8px; padding-left: 14px; }
	.cp-bar .cp-send { padding: 0 16px; }
	.cp-bar__label { font-size: 15px; }
}
