/*
  Custom look for davidkofinyame.com, layered on top of LittleLink's own
  CSS files, which stay unchanged.

  - Background: Vincent van Gogh, "The Starry Night" (1889). Public domain.
    Scan: Google Art Project, via Wikimedia Commons.
  - Font: Lora, SIL Open Font License 1.1 (see fonts/Lora-OFL.txt).
    The font files are used unmodified, as the licence requires for the
    name "Lora".
  - The page is forced to dark mode (theme-dark in index.html).
  - The flowing sky, stars and moon are drawn into the painting by js/sky.js.
    This file only holds the plain painting it starts from (and falls
    back to without WebGL).
  - Everything that moves is switched off for visitors who ask their
    device to reduce motion (bottom of this file and js/sky.js).
*/

/* Font
  –––––––––––––––––––––––––––––––––––––––––––––––––– */
@font-face {
	font-family: "Lora";
	src: url("../fonts/Lora-Regular.ttf") format("truetype");
	font-weight: 400;
	font-display: swap;
}
@font-face {
	font-family: "Lora";
	src: url("../fonts/Lora-Bold.ttf") format("truetype");
	font-weight: 700;
	font-display: swap;
}

body {
	font-family: "Lora", Georgia, "Times New Roman", serif;
	background-color: #0b1020;
}

/* Sky: the painting behind the page
   The plain painting shows first. Once js/sky.js has drawn the
   living painting on the canvas, the canvas fades in over them.
  –––––––––––––––––––––––––––––––––––––––––––––––––– */
.sky {
	position: fixed;
	z-index: -1;
	inset: 0;
	overflow: hidden;
	container-type: size;
	pointer-events: none;
	animation: sky-in 1600ms ease-out backwards;
}

.frame {
	position: absolute;
	top: 40%;
	left: 50%;
	width: max(100vw, 100vh * 2000 / 1584);          /* fallback for older browsers */
	width: max(100cqw, 100cqh * 2000 / 1584);        /* painting is 2000 × 1584 */
	aspect-ratio: 2000 / 1584;
	translate: -50% -40%;
}

.painting {
	background: url("../images/starry-night.jpg") center / 100% 100% no-repeat;
}

#sky-canvas {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	transition: opacity 700ms ease;
}
.sky-live #sky-canvas {
	opacity: 1;
}

/* Layout: a centred welcome screen
  –––––––––––––––––––––––––––––––––––––––––––––––––– */
.container {
	min-height: 100vh;
	min-height: 100svh;
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding-top: 2.5rem;
	padding-bottom: 2.5rem;
}

/* The greeting is the only line of text, so it is the heading. */
.greeting {
	margin: 0 0 2rem;
	font-size: clamp(2rem, 6.5vw, 3rem);
	font-weight: 400;
	letter-spacing: 0;
	line-height: 1.2;
	text-wrap: balance;
	hyphens: manual;          /* LittleLink hyphenates headings; "after-noon" looks broken */
	/* The painting has no dark tint, so the greeting carries its own soft dark
	   shadow right behind the letters to stay readable on bright brushstrokes. */
	text-shadow:
		0 0 2px rgba(6, 8, 20, 0.95),
		0 0 4px rgba(6, 8, 20, 0.95),
		0 0 8px rgba(6, 8, 20, 0.9),
		0 0 8px rgba(6, 8, 20, 0.9),
		0 0 16px rgba(6, 8, 20, 0.85),
		0 0 28px rgba(6, 8, 20, 0.75),
		0 0 44px rgba(6, 8, 20, 0.6);
	animation: rise 1000ms cubic-bezier(0.2, 0.7, 0.2, 1) 200ms backwards;
}

/* Buttons
   One light style for every button, replacing the brand colours.
   The pale yellow is taken from the stars and moon in the painting;
   on hover, focus or tap they glow like a star.
  –––––––––––––––––––––––––––––––––––––––––––––––––– */
.button {
	--button-text: #14203a;
	--button-background: #f3e7b3;
	--button-border: 1px solid rgba(255, 255, 255, 0.6);
	max-width: 100%;          /* LittleLink's 300px buttons overflow 320px-wide phones */
	background-image: none;
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
	transition: background-color 200ms ease, box-shadow 250ms ease, translate 200ms ease;
	animation: rise 800ms cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
}
.button:nth-of-type(1) { animation-delay: 550ms; }
.button:nth-of-type(2) { animation-delay: 680ms; }

.button:focus-visible,
.button:active {
	--button-background: #fff4c8;
	box-shadow:
		0 0 0 1px rgba(255, 246, 210, 0.9),
		0 0 26px 6px rgba(255, 222, 120, 0.5),
		0 4px 18px rgba(0, 0, 0, 0.35);
}
@media (hover: hover) {
	.button:hover {
		--button-background: #fff4c8;
		box-shadow:
			0 0 0 1px rgba(255, 246, 210, 0.9),
			0 0 26px 6px rgba(255, 222, 120, 0.5),
			0 4px 18px rgba(0, 0, 0, 0.35);
		translate: 0 -2px;
	}
}

.button .icon {
	filter: brightness(0);   /* the icons are white; make them dark to match the text */
	opacity: 0.85;
}

/* Pause button for the moving sky: small and quiet, in the corner
  –––––––––––––––––––––––––––––––––––––––––––––––––– */
.motion-toggle {
	position: fixed;
	right: max(1rem, env(safe-area-inset-right, 0px));
	bottom: max(1rem, env(safe-area-inset-bottom, 0px));
	display: grid;
	place-items: center;
	box-sizing: border-box;
	width: 3rem;               /* 48px, LittleLink's own minimum for buttons */
	height: 3rem;
	margin: 0;
	padding: 0;
	line-height: 0;
	border: 1px solid rgba(255, 255, 255, 0.4);
	border-radius: 50%;
	background: rgba(8, 10, 24, 0.55);
	color: #ffffff;
	opacity: 0.75;
	cursor: pointer;
	transition: opacity 200ms ease, background-color 200ms ease;
}
.motion-toggle[hidden] {
	display: none;
}
/* LittleLink recolours anything hovered, focused or pressed; keep the icon white */
.motion-toggle:hover,
.motion-toggle:focus,
.motion-toggle:active {
	opacity: 1;
	background: rgba(8, 10, 24, 0.8);
	color: #ffffff;
}
.motion-toggle:focus-visible {
	outline: 2px solid #f3e7b3;
	outline-offset: 2px;
}
.motion-toggle .icon-play,
.motion-toggle.is-paused .icon-pause {
	display: none;
}
.motion-toggle.is-paused .icon-play {
	display: block;
}

/* Hint beside the pause button. It appears for a few seconds once the
   painting is live, then fades; it comes back when the button is hovered
   or focused. */
.motion-hint {
	position: fixed;
	right: calc(max(1rem, env(safe-area-inset-right, 0px)) + 3.5rem);
	bottom: calc(max(1rem, env(safe-area-inset-bottom, 0px)) + 0.5rem);
	height: 2rem;
	padding: 0 0.75rem;
	border-radius: 1rem;
	background: rgba(8, 10, 24, 0.8);
	color: #ffffff;
	font-size: 0.875rem;
	line-height: 2rem;
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
	transition: opacity 200ms ease;
	animation: hint 7s ease 1.5s;
}
.motion-toggle[hidden] + .motion-hint {
	display: none;
}
.motion-toggle:hover + .motion-hint,
.motion-toggle:focus-visible + .motion-hint {
	opacity: 1;
}

/* Animations
  –––––––––––––––––––––––––––––––––––––––––––––––––– */
@keyframes sky-in {
	from { opacity: 0; }
}
@keyframes hint {
	0%, 100% { opacity: 0; }
	8%, 88%  { opacity: 1; }
}
@keyframes rise {
	from {
		opacity: 0;
		transform: translateY(14px);
		filter: blur(6px);
	}
}
/* Visitors who ask their device to reduce motion get a still page:
   nothing slides in, and js/sky.js holds the painting still. */
@media (prefers-reduced-motion: reduce) {
	.sky,
	.greeting,
	.button {
		animation: none;
	}
	#sky-canvas,
	.button {
		transition: none;
	}
	.button:hover {
		translate: none;
	}
	/* nothing moves, so there is nothing to pause */
	.motion-toggle,
	.motion-hint {
		display: none;
	}
}
