/* Life in Weeks: week grid */

.arl-liw {
	/* Lived/future colours are overridden inline from the General settings */
	--arl-liw-lived: #8c8f94;
	--arl-liw-future: #ffffff;
	/* Outline for unlived weeks so light colours (e.g. white) stay visible on light backgrounds */
	--arl-liw-future-border: #c3c4c7;
	--arl-liw-current: #d63638;
	--arl-liw-event-default: #000000;
	--arl-liw-gap: 2px;
	position: relative;
	max-width: 100%;
	margin: 1.5em 0;
	font-size: 12px;
	line-height: 1;
}

/*
 * Narrow: match the width of a typical paragraph block. Block themes expose the content width as
 * --wp--style--global--content-size (theme.json "contentSize"); classic themes fall back to 650px.
 * Wide (.arl-liw-wide) keeps the default behaviour of filling the container.
 */
.arl-liw.arl-liw-narrow {
	max-width: min(100%, var(--wp--style--global--content-size, 650px));
	margin-left: auto;
	margin-right: auto;
}

.arl-liw-grid {
	display: flex;
	flex-direction: column;
	gap: var(--arl-liw-gap);
}

.arl-liw-row {
	display: grid;
	grid-template-columns: 2.6em repeat(52, minmax(0, 1fr));
	gap: var(--arl-liw-gap);
	align-items: center;
}

.arl-liw-year,
.arl-liw-wn {
	font-size: 0.85em;
	font-variant-numeric: tabular-nums;
	opacity: 0.65;
	white-space: nowrap;
}

.arl-liw-year {
	padding-right: 0.4em;
	text-align: right;
}

.arl-liw-head {
	margin-bottom: 2px;
}

/* Weeks (and legend keys, which share the same states) */
.arl-liw .w,
.arl-liw-key {
	position: relative;
	display: block;
	box-sizing: border-box;
	aspect-ratio: 1;
	border: 1px solid transparent;
	background: transparent;
	border-radius: 1px;
}

.arl-liw-circle .w,
.arl-liw-circle .arl-liw-key {
	border-radius: 50%;
}

/* n = outside of life (before birth / after expectancy) */
.arl-liw .w.n {
	border-color: transparent;
}

/* l = lived */
.arl-liw .l {
	background: var(--arl-liw-lived);
	border-color: var(--arl-liw-lived);
}

/* f = future (unlived) */
.arl-liw .f {
	background: var(--arl-liw-future);
	border-color: var(--arl-liw-future-border);
	/* Where supported, outline with a slightly darker shade of the chosen colour instead */
	border-color: color-mix(in srgb, var(--arl-liw-future), #000 22%);
}

/* c = current week */
.arl-liw .c {
	box-shadow: 0 0 0 2px var(--arl-liw-current);
	z-index: 1;
}

/* e = week with one or more events, coloured by the first event's category */
.arl-liw .e {
	background: var(--c, var(--arl-liw-event-default));
	border-color: var(--c, var(--arl-liw-event-default));
}

.arl-liw .w.e {
	cursor: pointer;
	transform: scale(1.2);
	z-index: 1;
}

.arl-liw .w:not(.n):hover {
	outline: 1px solid currentColor;
	outline-offset: 1px;
	z-index: 2;
}

.arl-liw .w:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
	z-index: 2;
}

/* Notification-style counter for weeks with 2+ events */
.arl-liw-count {
	position: absolute;
	top: -0.6em;
	right: -0.7em;
	z-index: 2;
	box-sizing: border-box;
	min-width: 1.5em;
	height: 1.5em;
	padding: 0 0.3em;
	border-radius: 0.75em;
	background: #d63638;
	box-shadow: 0 0 0 1px #fff;
	color: #fff;
	font: 600 8px/1.5em system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	text-align: center;
	pointer-events: none;
}

/* Legend */
.arl-liw-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em 1.25em;
	margin: 1em 0 0;
	padding: 0;
	list-style: none;
	font-size: 13px;
	line-height: 1.4;
}

.arl-liw-legend li {
	display: flex;
	align-items: center;
	gap: 0.4em;
	margin: 0;
}

.arl-liw-legend .arl-liw-key {
	width: 0.85em;
	flex: none;
}

/* Attribution link (below the legend) */
.arl-liw-attribution {
	margin: 0.75em 0 0;
	font-size: 12px;
	line-height: 1.4;
	opacity: 0.75;
}

/* Tooltip */
.arl-liw-tip {
	position: absolute;
	z-index: 1000;
	box-sizing: border-box;
	width: max-content;
	max-width: min(300px, 100%);
	padding: 0.65em 0.8em;
	border-radius: 6px;
	background: #1d2327;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
	color: #f0f0f1;
	font-size: 13px;
	line-height: 1.4;
	pointer-events: none;
}

.arl-liw-tip.is-pinned {
	pointer-events: auto;
}

.arl-liw-tip-title {
	font-weight: 600;
}

.arl-liw-tip-meta,
.arl-liw-tip-event-meta,
.arl-liw-tip-hint {
	color: #a7aaad;
	font-size: 0.9em;
}

.arl-liw-tip-events {
	margin: 0.5em 0 0;
	padding: 0.5em 0 0;
	border-top: 1px solid rgba(255, 255, 255, 0.15);
	list-style: none;
}

.arl-liw-tip-events li {
	margin: 0;
}

.arl-liw-tip-events li + li {
	margin-top: 0.5em;
}

.arl-liw-tip-event-head {
	display: flex;
	align-items: center;
	gap: 0.4em;
}

.arl-liw-tip-dot {
	flex: none;
	width: 0.7em;
	height: 0.7em;
	border: 1px solid rgba(255, 255, 255, 0.5);
	border-radius: 50%;
}

.arl-liw-tip-name {
	font-weight: 600;
}

a.arl-liw-tip-name {
	color: #72aee6;
	text-decoration: underline;
}

.arl-liw-tip-desc {
	margin: 0.25em 0 0;
	white-space: pre-line;
}

.arl-liw-tip-hint {
	margin-top: 0.5em;
	font-style: italic;
}

.arl-liw-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}
