/* Diary of India: coming soon.
   Colours (light and dark) and fonts arrive as custom properties set from Settings → Coming Soon. */

/* Registered so the palette can ease when the device switches between light and dark,
   instead of the whole page flashing to the other brightness in one frame. */
@property --bg     { syntax: '<color>'; inherits: true; initial-value: #17204a; }
@property --text   { syntax: '<color>'; inherits: true; initial-value: #f2ede3; }
@property --accent { syntax: '<color>'; inherits: true; initial-value: #d2462d; }
@property --rule-c { syntax: '<color>'; inherits: true; initial-value: #24306b; }

:root {
	transition: --bg .45s ease, --text .45s ease, --accent .45s ease, --rule-c .45s ease;
	--rule: 2rem;                                 /* ruled-line pitch, also the body line height */
	--margin-x: clamp(26px, 8vw, 132px);          /* position of the red margin line */
	--gutter: clamp(18px, 3.2vw, 52px);           /* space between margin line and text */
	--muted: color-mix(in srgb, var(--text) 70%, var(--bg));
	--margin-c: color-mix(in srgb, var(--accent) 70%, var(--bg));
	--stamp-ink: .94;
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
	margin: 0;
	min-height: 100vh;
	min-height: 100dvh;
	background-color: var(--bg);
	color: var(--text);
	font-family: var(--font-body);
	font-size: clamp(1.0625rem, 0.98rem + 0.3vw, 1.1875rem);
	line-height: var(--rule);
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;     /* our own :active state gives the press feedback */
}

/* Paper: ruled lines and the double margin line of an exercise book. */
.doi { --l-rules: none; --l-margin: none; --l-photo: none; }
.doi.has-rules {
	--l-rules: repeating-linear-gradient(to bottom,
		transparent 0, transparent calc(var(--rule) - 1px),
		var(--rule-c) calc(var(--rule) - 1px), var(--rule-c) var(--rule));
}
.doi.has-margin {
	--l-margin: linear-gradient(90deg,
		transparent var(--margin-x),
		var(--margin-c) var(--margin-x), var(--margin-c) calc(var(--margin-x) + 1px),
		transparent calc(var(--margin-x) + 1px), transparent calc(var(--margin-x) + 5px),
		var(--margin-c) calc(var(--margin-x) + 5px), var(--margin-c) calc(var(--margin-x) + 6px),
		transparent calc(var(--margin-x) + 6px));
}
.doi.has-image {
	--l-photo: linear-gradient(color-mix(in srgb, var(--bg) var(--overlay), transparent), color-mix(in srgb, var(--bg) var(--overlay), transparent)), var(--photo);
}
.doi {
	background-image: var(--l-margin), var(--l-rules), var(--l-photo);
	background-size: auto, auto, cover;
	background-position: 0 0, 0 0, center;
	background-attachment: scroll, local, fixed;
}

.sheet {
	min-height: 100vh;
	min-height: 100dvh;
	display: grid;
	grid-template-rows: auto 1fr auto;
	padding: var(--rule) clamp(18px, 5vw, 72px) var(--rule) calc(var(--margin-x) + var(--gutter));
	max-width: 1440px;
}

/* Masthead */
.masthead { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1.5rem; }
.wordmark {
	margin: 0;
	font-family: var(--font-display);
	font-size: 1.375rem;
	line-height: var(--rule);
	letter-spacing: .01em;
}
.logo { display: block; max-height: calc(var(--rule) * 2); width: auto; }
.preview-note {
	margin: 0;
	padding: 0 .75rem;
	border: 1px dashed var(--accent);
	font-size: .875rem;
	color: var(--muted);
}

/* The entry */
/* Starts high on the page (top gap capped at 6rem) instead of floating mid-screen. */
.entry {
	position: relative;
	align-self: start;
	padding: clamp(2rem, 9vh, 6rem) 0 calc(var(--rule) * 2);
	max-width: 76rem;
}

.dateline {
	margin: 0 0 var(--rule);
	color: var(--muted);
	font-size: .9375rem;
}

.headline {
	margin: 0;
	max-width: 20ch;                               /* two lines on desktop for the default headline */
	font-family: var(--font-display);
	font-weight: 400;
	font-size: clamp(2.5rem, 1.1rem + 4.2vw, 5rem);
	line-height: 1.04;
	letter-spacing: -.02em;                        /* tracking tightens as type grows */
	text-wrap: pretty;
}

.intro {
	margin-top: var(--rule);
	max-width: 34rem;
	color: var(--muted);
}
.intro p { margin: 0 0 var(--rule); }
.intro p:last-child { margin-bottom: 0; }

/* Countdown: numbers written on the lines, not boxed. */
.countdown { margin-top: calc(var(--rule) * 1.5); }
.countdown-units { display: flex; flex-wrap: wrap; gap: .25rem clamp(1.25rem, 3vw, 2.5rem); }
.unit { display: inline-flex; align-items: baseline; gap: .4rem; white-space: nowrap; }
.num {
	font-family: var(--font-display);
	font-size: clamp(2rem, 1.4rem + 2.2vw, 3.25rem);
	line-height: 1.2;
	font-variant-numeric: tabular-nums lining-nums;
	min-width: 2ch;
}
.unit:first-child .num { min-width: 0; }
.label { color: var(--muted); font-size: .9375rem; letter-spacing: .01em; }

.launch-message {
	margin: calc(var(--rule) * 1.5) 0 0;
	font-family: var(--font-display);
	font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.25rem);
	line-height: 1.25;
	max-width: 24ch;
}

.contact { margin: calc(var(--rule) * 1.5) 0 0; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .22em; text-decoration-color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
a:active { opacity: .6; }                          /* instant on press, no transition */
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
.contact-address { color: var(--muted); }

/* The postmark: the one loud thing on the page. */
.stamp {
	width: min(100%, 360px);
	margin: 0 0 var(--rule) auto;
	color: var(--accent);
	opacity: var(--stamp-ink);
	transform: rotate(-9deg);
	pointer-events: none;
	/* A rubber stamp presses down and stops: critically damped (damping 1.0, response 0.4s), no
	   bounce, because no gesture threw it. cubic-bezier is the fallback for browsers without linear(). */
	animation: doi-stamp .6s cubic-bezier(.2, .8, .25, 1) .35s both;
	animation-timing-function: linear(0 0%, 0.1183 6%, 0.3294 13%, 0.5273 19%, 0.6819 25%, 0.7925 31%, 0.8677 38%, 0.9171 44%, 0.9487 50%, 0.9686 56%, 0.9809 63%, 0.9885 69%, 0.9931 75%, 0.9959 81%, 0.9976 88%, 0.9986 94%, 1 100%);
}
.stamp svg { display: block; width: 100%; height: auto; overflow: visible; }
.stamp .ring  { font-family: var(--font-display); font-size: 17px; }
.stamp .day   { font-family: var(--font-display); font-size: 62px; }
.stamp .month { font-family: var(--font-body); font-size: 19px; font-weight: 600; letter-spacing: .08em; }
.stamp .soon  { font-family: var(--font-display); font-size: 44px; }

/* Two keyframes only, so the spring curve shapes the whole press. The angle stays fixed:
   a stamp travels straight down onto the paper, it does not twist. */
@keyframes doi-stamp {
	from { opacity: 0; transform: rotate(-9deg) scale(1.14); }
	to   { opacity: var(--stamp-ink); transform: rotate(-9deg) scale(1); }
}
@keyframes doi-ink {
	from { opacity: 0; }
	to   { opacity: var(--stamp-ink); }
}

/* Footer */
.foot {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: baseline;
	gap: 0 2rem;
	color: var(--muted);
	font-size: .9375rem;
	letter-spacing: .01em;                          /* small text opens up slightly */
}
.social { display: flex; flex-wrap: wrap; gap: 0 1.5rem; margin: 0; padding: 0; list-style: none; }
.note { margin: 0; }

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

/* Wide screens: the headline spans the page; the stamp lands in its own column beside the
   introduction, so its cancellation waves never cross the text. */
@media (min-width: 900px) {
	.entry {
		display: grid;
		grid-template-columns: minmax(0, 34rem) minmax(0, 1fr);
		grid-template-areas:
			"date    date"
			"head    head"
			"intro   stamp"
			"count   stamp"
			"contact stamp"
			".       stamp";
		grid-template-rows: auto auto auto auto auto 1fr;
		column-gap: clamp(1.5rem, 4vw, 4rem);
		align-items: start;
	}
	.dateline       { grid-area: date; }
	.headline       { grid-area: head; }
	.intro          { grid-area: intro; }
	.countdown,
	.launch-message { grid-area: count; }
	.contact        { grid-area: contact; }
	.stamp {
		grid-area: stamp;
		justify-self: end;
		width: min(100%, 460px);
		margin: calc(var(--rule) * 0.25) 0 0;
	}
}

/* Narrow screens: the stamp sits above the headline. */
@media (max-width: 899.98px) {
	.entry { padding-top: calc(var(--rule) * 1.5); }
}

/* Phones: four columns, each label under its number, so the countdown stays on one row. */
@media (max-width: 480px) {
	.countdown-units { display: grid; grid-template-columns: repeat(4, auto); justify-content: start; column-gap: 1.5rem; }
	.unit { flex-direction: column; align-items: flex-start; gap: 0; }
	.num { min-width: 0; }
	.label { line-height: 1.2; }
}

/* The launch message replacing the countdown fades in rather than popping. */
.launch-message.is-new { animation: doi-ink .35s ease-out both; }

/* Reduced motion keeps the feedback without the movement: the stamp's ink simply fades in. */
@media (prefers-reduced-motion: reduce) {
	.stamp { animation: doi-ink .2s ease-out .15s both; }
	.launch-message.is-new { animation-duration: .2s; }
}

/* More contrast: secondary text at full strength, ruled lines and margin clearly visible, solid stamp. */
@media (prefers-contrast: more) {
	html:root { /* beats the inline colour settings, which also target :root */
		--stamp-ink: 1;
		--muted: var(--text);
		--margin-c: var(--accent);
		--rule-c: color-mix(in srgb, var(--text) 35%, var(--bg));
	}
}

/* Less transparency: the background photo sits under a nearly solid wash, the stamp is solid ink. */
@media (prefers-reduced-transparency: reduce) {
	html:root { --overlay: 92%; --stamp-ink: 1; }
}

@media print {
	.doi { background: none; }
}
