/******************************
**
**	Start Now Cornwall Advent Calendar
**	Colours and font from the main site (css/root.css).
**	Ported from headstart-kernow/advent: the popup, snow, toast and cookie
**	box are the same; the doors are square pictures instead.
**
*******************************/

:root {
	--navy: #0B3954;
	--teal: #02B2BF;
	--deepteal: #087E8B;
	--pink: #E1408D;
	--orange: #F7931D;
	--sky: #5CC0ED;
	--red: #C81D25;
	--gold: #F6C453;

	--font: "Outfit", system-ui, sans-serif;

	--tile-radius: 14px;
	--tile-frame: 5px;          /* the white frame round each picture */
	--pop: 0.55s;               /* advent.js waits about this long before the popup */

	/* landscape: the area the pictures are scattered over */
	--grid-top: 5%;
	--grid-side: 6%;
	--grid-bottom: calc(var(--logo-h) + 56px);  /* clear of the logos */
	/* must match the adventLayout() call in index.php (the pictures are square) */
	--area-aspect: 1.8;

	--logo-h: 56px;
}

/* portrait: phones and tall windows */
@media (orientation: portrait) {
	:root {
		--grid-top: 4%;
		--grid-side: 4%;
		--area-aspect: 0.5;
		--tile-radius: 10px;
		--tile-frame: 3px;
		--logo-h: 36px;
	}
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
	background: var(--navy);
	color: var(--navy);
	font-family: var(--font);
	font-size: 18px;
	line-height: 1.5;
}

.visually-hidden {
	position: absolute;
	width: 1px; height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.preview-bar {
	position: fixed;
	top: 0; left: 0; right: 0;
	z-index: 5;
	background: var(--pink);
	color: #fff;
	text-align: center;
	font-weight: 700;
	font-size: 15px;
	padding: 4px 16px;
}

.notice {
	position: absolute;
	top: 12px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 12;
	width: max-content;
	max-width: calc(100% - 32px);
	margin: 0;
	padding: 8px 20px;
	border-radius: 999px;
	background: #fff;
	font-weight: 700;
	text-align: center;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.preview .notice { top: 44px; }

/* ---------- the stage: a winter night in Start Now's colours ---------- */

.stage {
	position: relative;
	display: block;
	width: 100%;
	height: 100vh;
	height: 100svh;
	min-height: 480px;
	overflow: hidden;
	background:
		radial-gradient(circle at 20% 15%, #ffffff22 0 2px, transparent 3px) 0 0 / 60px 60px,
		radial-gradient(circle at 70% 60%, #ffffff1a 0 2px, transparent 3px) 0 0 / 90px 90px,
		radial-gradient(120% 80% at 50% 0%, var(--deepteal) 0%, var(--navy) 70%);
}

/* a giant, faint jumper behind everything (images/bg.png, a transparent PNG). On a
   phone it is sized by height, so the sleeves run off the sides. */
.stage::before {
	content: "";
	position: absolute;
	inset: 0;
	background: url("images/bg.png") center / auto 100% no-repeat;
	opacity: 0.2;
	pointer-events: none;
}
@media (orientation: portrait) {
	.stage::before { background-size: auto 65%; }
}

.grid {
	position: absolute;
	top: var(--grid-top);
	right: var(--grid-side);
	bottom: var(--grid-bottom);
	left: var(--grid-side);
	container-type: size;
}
.preview .grid { top: calc(var(--grid-top) + 30px); }

/* ---------- a day's picture ---------- */

/* Each picture's place comes from index.php: --lx/--ly/--lw for landscape, --px/--py/--pw
   for portrait (centre as % of the area, width as % of its width). The width is capped
   by the area's height too, so on a screen of a different shape the pictures shrink
   rather than overlap. */
.door {
	--x: var(--lx);
	--y: var(--ly);
	--w: var(--lw);
	position: absolute;
	left: calc(var(--x) * 1%);
	top: calc(var(--y) * 1%);
	width: min(calc(var(--w) * 1cqw), calc(var(--w) * var(--area-aspect) * 1cqh));
	aspect-ratio: 1;
	translate: -50% -50%;
	/* no frame: the picture (a transparent PNG) is the door */
	padding: 0;
	border: 0;
	border-radius: var(--tile-radius);
	background: none;
	font: inherit;
	cursor: pointer;
	container-type: size;
	-webkit-tap-highlight-color: transparent;
}
@media (orientation: portrait) {
	.door { --x: var(--px); --y: var(--py); --w: var(--pw); }
}

/* the colour of each day: the popup's heading, and the placeholder picture */
.door--c1 { --c: var(--pink); }
.door--c2 { --c: var(--teal); }
.door--c3 { --c: var(--orange); }
.door--c4 { --c: var(--deepteal); }
.door--c5 { --c: var(--red); }
.door--c6 { --c: var(--sky); }

.door__pic {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	/* a shadow that follows the shape of the jumper or cat, not a box */
	filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.5));
}

/* until the real picture arrives (images/tiles/NN.jpg) */
.door__pic--placeholder {
	display: grid;
	place-items: center;
	background:
		repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.12) 0 8px, transparent 8px 16px),
		var(--c);
	border-radius: var(--tile-radius);
	font-size: 46cqmin;
	line-height: 1;
}

/* the day's number, a badge in the top corner */
.door__num {
	position: absolute;
	top: -2%;
	left: -2%;
	display: grid;
	place-items: center;
	width: 30%;
	aspect-ratio: 1;
	border-radius: 50%;
	background: var(--pink);
	border: 2px solid #fff;
	color: #fff;
	font-weight: 800;
	font-size: 19cqmin;
	line-height: 1;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* days still to come: shown in full colour; a grey number, no wobble and no pointer are the only difference */
.door--future { cursor: default; }
.door--future .door__num { background: #5b6b78; }
.preview .door--future { cursor: pointer; }

/* today's: a gold glow round its outline, gently bobbing, until it's been opened */
.door--today {
	animation: bob 2.4s ease-in-out infinite;
	z-index: 3;
}
.door--today .door__pic {
	filter: drop-shadow(0 0 3px var(--gold)) drop-shadow(0 0 12px rgba(246, 196, 83, 0.9)) drop-shadow(0 6px 8px rgba(0, 0, 0, 0.4));
}
.door--today .door__num { background: var(--gold); color: var(--navy); }
@keyframes bob {
	0%, 100% { transform: translateY(0) rotate(0deg); }
	50% { transform: translateY(-4%) rotate(-2deg); }
}

/* the ones that can be opened wobble on hover, to show they're clickable */
.door:not(.door--future):hover,
.preview .door--future:hover {
	z-index: 4;
	animation: wobble 0.7s ease-in-out;
}
@keyframes wobble {
	0%, 100% { transform: rotate(0deg); }
	20% { transform: rotate(-7deg); }
	45% { transform: rotate(5deg); }
	70% { transform: rotate(-3deg); }
	85% { transform: rotate(1deg); }
}
/* and stay a touch bigger while the pointer is on them */
.door:not(.door--future):hover .door__pic,
.preview .door--future:hover .door__pic { scale: 1.06; }
.door__pic { transition: filter 0.2s, scale 0.2s; }

.door:focus-visible {
	outline: 3px solid var(--gold);
	outline-offset: 4px;
}

/* opening: it jumps up and wiggles, then the popup appears (advent.js).
   :hover too, because the pointer is always on the one being clicked */
.door.is-open,
.door.is-open:hover {
	z-index: 10;
	animation: pop var(--pop) cubic-bezier(0.3, 0.7, 0.4, 1.4) forwards;
}
@keyframes pop {
	0%   { transform: scale(1) rotate(0deg); }
	35%  { transform: scale(1.3) rotate(-8deg); }
	60%  { transform: scale(1.25) rotate(6deg); }
	100% { transform: scale(1.28) rotate(0deg); }
}

/* ---------- logos, over the bottom of the page ---------- */

.logos {
	position: absolute;
	left: 50%;
	bottom: 16px;
	transform: translateX(-50%);
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 32px;
	max-width: calc(100% - 32px);
	padding: 10px 24px;
	border-radius: 16px;
	background: #fff;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.logos a { flex: 0 1 auto; min-width: 0; }

.logos img {
	display: block;
	height: var(--logo-h);
	width: auto;
	max-width: 100%;
	object-fit: contain;
}

@media (max-width: 600px) {
	.logos { gap: 14px; padding: 8px 12px; bottom: 10px; }
}

/* ---------- the popup ---------- */

dialog {
	width: min(680px, calc(100vw - 32px));
	max-height: calc(100svh - 48px);
	padding: 0;
	border: 0;
	border-radius: 16px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(246, 196, 83, 0.35);
	color: #eef3fb;
	/* a winter night, with a little snow */
	background:
		radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.16) 0 2px, transparent 3px) 0 0 / 173px 173px,
		radial-gradient(circle at 67% 41%, rgba(255, 255, 255, 0.10) 0 1.5px, transparent 2.5px) 0 0 / 241px 199px,
		radial-gradient(circle at 33% 77%, rgba(255, 255, 255, 0.13) 0 2.5px, transparent 3.5px) 0 0 / 317px 263px,
		radial-gradient(circle at 84% 63%, rgba(255, 255, 255, 0.08) 0 1px, transparent 2px) 0 0 / 131px 157px,
		radial-gradient(circle at 51% 9%, rgba(255, 255, 255, 0.11) 0 1.5px, transparent 2.5px) 0 0 / 389px 347px,
		radial-gradient(130% 90% at 50% 0%, #0f5a73 0%, #0B3954 55%, #061f30 100%);
	overflow: hidden;
	/* clip, not just hide: a "hidden" box can still be scrolled by script, and the
	   YouTube player scrolls it when it starts, pushing the header out of view.
	   Only .popup__body scrolls. */
	overflow: clip;
	opacity: 0;
	transform: translateY(16px) scale(0.96);
	transition: opacity 0.3s, transform 0.3s;
}
dialog[open] { display: flex; flex-direction: column; }
dialog.is-shown { opacity: 1; transform: none; }

dialog::backdrop {
	background: rgba(4, 24, 36, 0.78);
}

/* a big festive emoji tucked into the bottom corner */
.popup__emoji {
	position: absolute;
	right: -10px;
	bottom: -14px;
	font-size: 96px;
	line-height: 1;
	transform: rotate(-14deg);
	opacity: 0.9;
	pointer-events: none;
	filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.4));
}

.popup__head {
	display: flex;
	flex: none;
	align-items: center;
	gap: 12px;
	padding: 14px 16px 14px 24px;
	background: linear-gradient(135deg, var(--popup-colour, var(--pink)), color-mix(in srgb, var(--popup-colour, var(--pink)) 60%, #000));
	border-bottom: 3px solid #F6C453;
	color: #fff;
}

.popup__head h2 {
	flex: 1;
	margin: 0;
	font-size: 1.6rem;
	line-height: 1.2;
	text-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.popup__close {
	flex: none;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.2);
	color: #fff;
	font-size: 30px;
	line-height: 1;
	cursor: pointer;
}
.popup__close:hover { background: rgba(255, 255, 255, 0.35); }

.popup__body {
	/* auto, not "flex: 1": that starts from a height of 0%, which Safari on an iPad took
	   literally, squashing the popup to one line (Kate, 3 Dec 2026) */
	flex: 1 1 auto;
	min-height: 0;
	overflow: auto;
	padding: 20px 24px;
}

.popup__body.is-loading { min-height: 160px; }

.popup__body > :first-child { margin-top: 0; }
.popup__body > :last-child { margin-bottom: 0; }
.popup__body h3 { margin: 1.2em 0 0.4em; font-size: 1.35rem; line-height: 1.25; color: #fff; }
.popup__body a { color: #F6C453; }
.popup__body a:hover { color: #fff; }
.popup__body img { max-width: 100%; height: auto; border-radius: 8px; }

/* what kind of day it is: Wellbeing, Craft, Joke, Kindness */
.popup__body .kind {
	margin: 0 0 0.2em;
	color: #F6C453;
	font-size: 0.85rem;
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}
.popup__body .kind + h3 { margin-top: 0; }

/* a joke's punchline, behind a button */
.popup__body .answer summary {
	display: inline-block;
	padding: 6px 18px;
	border-radius: 6px;
	background: #F6C453;
	color: var(--navy);
	font-weight: 800;
	cursor: pointer;
	list-style: none;
}
.popup__body .answer summary:hover { background: #fff; }
.popup__body .answer summary::-webkit-details-marker { display: none; }
.popup__body .answer[open] summary { display: none; }
.popup__body .answer p { margin: 0; font-size: 1.6rem; font-weight: 900; color: #F6C453; }

/* the Cornish word of the day */
.popup__body .cornish {
	margin: 1.2em 0 0;
	padding: 14px 18px;
	border-radius: 10px;
	position: relative;
	padding-right: 92px; /* room for the flag */
	background: rgba(255, 255, 255, 0.07);
}
/* St Piran's flag: a white cross on black */
.popup__body .cornish::after {
	content: "";
	position: absolute;
	top: 16px;
	right: 18px;
	width: 57px;
	height: 38px;
	border-radius: 3px;
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 20'%3E%3Crect width='30' height='20' fill='%23000'/%3E%3Crect x='12.5' width='5' height='20' fill='%23fff'/%3E%3Crect y='7.5' width='30' height='5' fill='%23fff'/%3E%3C/svg%3E") center / 100% 100%;
	box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35), 0 4px 10px rgba(0, 0, 0, 0.4);
	transform: rotate(5deg);
}
.popup__body .cornish .video { margin: 0.8em -74px 0 0; } /* full width, under the flag */

/* a YouTube Short (portrait): <div class="video video--short"> - phone-shaped, not stretched */
.popup__body .video.video--short {
	aspect-ratio: 9 / 16;
	width: min(240px, 100%);
	max-height: 60svh;
	margin: 0.8em 0 0;
}

/* A Cornish word with a video: the words on the left, the video beside them, so the
   whole popup fits without scrolling. The flag moves to the right of the words. */
.popup__body .cornish:has(.video) {
	--clip-w: 170px;
	display: grid;
	grid-template-columns: 1fr var(--clip-w);
	grid-auto-rows: min-content;
	column-gap: 18px;
	padding-right: 18px;
}
.popup__body .cornish:has(.video) > p { grid-column: 1; padding-right: 70px; }
.popup__body .cornish:has(.video) .video {
	grid-column: 2;
	grid-row: 1 / span 6;
	width: var(--clip-w);
	margin: 0;
}
.popup__body .cornish:has(.video)::after { right: calc(18px + var(--clip-w) + 18px); }
.popup__body .cornish p { margin: 0; }
.popup__body .cornish__label { font-size: 0.85rem; font-weight: 700; color: #a9bbd6; }
.popup__body .cornish__word { font-size: 1.6rem; font-weight: 900; line-height: 1.2; margin: 0.1em 0; }
.popup__body .cornish__say { font-style: italic; color: #a9bbd6; }
.popup__body .cornish__mean { font-weight: 700; margin-top: 0.3em; }

/* a YouTube video: <div class="video"><iframe ...></iframe></div> */
.popup__body .video {
	aspect-ratio: 16 / 9;
	margin: 1em 0;
	border-radius: 8px;
	overflow: hidden;
	background: #000;
}
.popup__body .video iframe { display: block; width: 100%; height: 100%; border: 0; }

/* the still frame shown until the video is tapped (advent.js stillFrames) */
.popup__body .video__still {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	padding: 0;
	border: 0;
	background: #000;
	cursor: pointer;
}
.popup__body .video__still img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 0;
}
.popup__body .video__play {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 60px;
	height: 60px;
	translate: -50% -50%;
	border-radius: 50%;
	background: var(--gold) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5v14l11-7z' fill='%23002456'/%3E%3C/svg%3E") 55% 50% / 30px 30px no-repeat;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
	transition: transform 0.15s;
}
.popup__body .video__still:hover .video__play,
.popup__body .video__still:focus-visible .video__play { transform: scale(1.1); }
.popup__body .video__still:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.popup__body .button {
	display: inline-block;
	padding: 8px 20px;
	border-radius: 6px;
	background: var(--pink);
	color: #fff;
	font-weight: 700;
	text-decoration: none;
}
.popup__body .button:hover { background: var(--teal); color: #fff; }

.popup__foot {
	display: flex;
	flex: none;
	align-items: center;
	gap: 12px;
	padding: 12px 24px 16px;
	padding-right: 96px; /* room for the emoji */
	border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.popup__share {
	padding: 8px 18px;
	border: 2px solid #F6C453;
	border-radius: 6px;
	background: transparent;
	color: #F6C453;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}
.popup__share:hover { background: #F6C453; color: var(--navy); }
.popup__share { display: inline-flex; align-items: center; gap: 8px; }
.popup__share svg { width: 18px; height: 18px; fill: currentColor; }

.popup__shared { font-size: 0.9rem; }

@media (max-width: 600px) {
	dialog { width: calc(100vw - 16px); max-height: calc(100svh - 16px); }
	.popup__body { padding: 16px; }
	.popup__head { padding-left: 16px; }
	.popup__foot { padding: 10px 80px 14px 16px; }
	.popup__emoji { font-size: 72px; }
	.popup__body .cornish { padding-right: 76px; }
	.popup__body .cornish::after { width: 45px; height: 30px; right: 14px; }
	.popup__body .cornish .video { margin-right: -62px; }
	.popup__body .video.video--short { margin-right: 0; }
	.popup__body .cornish:has(.video) { --clip-w: 120px; column-gap: 12px; padding-right: 14px; }
	.popup__body .cornish:has(.video) > p { padding-right: 0; }
	/* no room for the flag beside the words on a phone: it sits under them instead */
	.popup__body .cornish:has(.video)::after { top: auto; bottom: 16px; left: 18px; right: auto; }
}

/* ---------- falling snow over the whole page (advent.js) ---------- */

#snow {
	position: fixed;
	inset: 0;
	z-index: 4;
	pointer-events: none;
}

/* ---------- a message for a locked day ---------- */

.toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	transform: translateX(-50%);
	z-index: 10;
	max-width: calc(100vw - 32px);
	padding: 10px 20px;
	border-radius: 999px;
	background: #fff;
	color: var(--navy);
	font-weight: 700;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
	text-align: center;
}

.door.is-shaking { animation: shake 0.4s; }
@keyframes shake {
	0%, 100% { rotate: 0deg; }
	25% { rotate: -7deg; }
	75% { rotate: 7deg; }
}

/* ---------- cookie popup (same choices and cookie as the main site) ---------- */

#cookie_popup_message {
	position: fixed;
	z-index: 20;
	bottom: 16px;
	left: 16px;
	width: min(310px, calc(100vw - 32px));
	padding: 12px;
	border-radius: 8px;
	background: #fffffff2;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
	color: #000;
	font-size: 15px;
}
#cookie_popup_message p { margin: 0 0 10px; }
#cookie_popup_message a { color: var(--deepteal); }
.cookie_options_row { display: flex; align-items: center; gap: 10px; }
.cookie_options_label { font-weight: 700; margin-right: 10px; }
.cookie_options_row button {
	padding: 4px 16px;
	border: 0;
	border-radius: 5px;
	background: #666;
	color: #fff;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}
.cookie_options_row .yes:hover { background: #3c3; }
.cookie_options_row .no:hover { background: #c33; }

/* ---------- people who prefer less motion ---------- */

@media (prefers-reduced-motion: reduce) {
	:root { --pop: 0.01s; }
	dialog { transition: none; }
	.door.is-shaking, .door--today, .door.is-open, .door:hover { animation: none; }
	.door { transition: none; }
}
