/*
 * Small additions theme.json can't express. Colors and type always come
 * from preset variables so the Light variation keeps working.
 *
 * Editorial: Newsreader (serif) for headlines and titles, Inter Tight for
 * everything else. Thin rules instead of boxes, no labels above headings,
 * no pills, square-ish corners, olive only for stars, hovers and focus.
 */

::selection {
	background: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--base);
}

body {
	font-feature-settings: "ss01", "cv11";
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

a {
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
	transition: color 0.15s ease;
}

h1,
h2,
h3,
h4 {
	font-optical-sizing: auto;
	text-wrap: balance;
}

p {
	text-wrap: pretty;
}

/* Dates and counts line up. */
.wp-block-post-date,
.kelvinb-log-date,
.kelvinb-watched-stats,
.kelvinb-places-stats {
	font-variant-numeric: tabular-nums;
}

h2 a,
.wp-block-heading a {
	text-decoration: none;
}

/* Older headlines ended in an olive full stop; it now takes the text colour. */
:is(h1, h2, h3) mark.has-inline-color {
	background: none;
	color: inherit !important;
}

mark.has-inline-color {
	background: none;
}

/* Comfortable measure for lead paragraphs. */
.kelvinb-lead {
	max-width: 36rem;
}

/* Block style: Card. A section under a thin rule, not a box. */
.is-style-card {
	padding: var(--wp--preset--spacing--30) 0 0 !important;
	border-top: 1px solid var(--wp--preset--color--line);
}

/* Block style: Eyebrow (kicker). Kept for older content: a quiet line in
   sentence case, not spaced-out capitals. */
.is-style-eyebrow {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--muted);
}

/* Block style: Pill terms. Now plain small text with commas. */
.is-style-pill a {
	color: var(--wp--preset--color--muted);
	text-decoration: none;
}

.is-style-pill a:hover {
	color: var(--wp--preset--color--contrast);
}

/* Buttons: the outline style is a plain bordered rectangle. */
.wp-block-button.is-style-outline .wp-block-button__link {
	border: 1px solid var(--wp--preset--color--line);
	background: transparent;
	color: var(--wp--preset--color--contrast);
}

.wp-block-button.is-style-outline .wp-block-button__link:hover {
	border-color: var(--wp--preset--color--contrast);
	background: transparent;
	color: var(--wp--preset--color--contrast);
}

.wp-element-button {
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

/* Header: name in the serif, menu in the sans. */
.wp-block-navigation .wp-block-navigation-item__content {
	color: var(--wp--preset--color--muted);
}

/* A thin underline draws in under menu links on hover, and stays under the
   current page. */
header .wp-block-navigation .wp-block-navigation-item__content {
	background: linear-gradient(currentColor, currentColor) no-repeat 0 100% / 0 1px;
	transition: color 0.15s ease, background-size 0.25s ease;
}

header .wp-block-navigation .wp-block-navigation-item__content:hover,
header .wp-block-navigation [aria-current="page"] {
	background-size: 100% 1px;
}

.wp-block-navigation .wp-block-navigation-item__content:hover,
.wp-block-navigation .current-menu-item > .wp-block-navigation-item__content,
.wp-block-navigation [aria-current="page"] {
	color: var(--wp--preset--color--contrast);
}

/* Footer: one sentence with the email, then the small print. */
.kelvinb-footer-note {
	max-width: 32rem;
	margin: 0;
	line-height: 1.3;
}

/* Feed cards (category and search archives). */
.kelvinb-feed .format-status .wp-block-post-excerpt {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--large) !important;
	line-height: 1.35;
	color: var(--wp--preset--color--contrast);
}

.kelvinb-feed .wp-block-post-title:empty {
	display: none;
}

/* Page header: All / Movies / TV shows, and counts. Plain words; the
   current one is underlined. */
.kelvinb-log-filter {
	display: flex;
	flex-wrap: wrap;
	gap: 1.25rem;
	margin: 0;
}

.kelvinb-log-filter a {
	color: var(--wp--preset--color--muted);
	text-decoration: none;
}

.kelvinb-log-filter a:hover {
	color: var(--wp--preset--color--contrast);
}

.kelvinb-log-filter a[aria-current="page"] {
	color: var(--wp--preset--color--contrast);
	text-decoration: underline;
}

.kelvinb-watched-stats,
.kelvinb-places-stats {
	margin: 0;
}

/* Watched: a ruled list, newest added first. One row per title: the title
   (serif), director, type and stars. Titles have no page of their own. */
.kelvinb-watched .wp-block-post-template {
	display: flex;
	flex-direction: column;
	margin: 0;
	border-top: 1px solid var(--wp--preset--color--line);
}

.kelvinb-watched .wp-block-post-template > .wp-block-post {
	margin: 0;
}

.kelvinb-watched-card {
	display: grid;
	grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.6fr) 6rem 6.5rem;
	grid-template-areas: "title director type rating";
	align-items: baseline;
	gap: var(--wp--preset--spacing--30);
	margin: 0;
	padding: 0.85rem 0;
	border-bottom: 1px solid var(--wp--preset--color--line);
}

.kelvinb-watched-card > * {
	margin: 0 !important;
}

.kelvinb-watched-card .wp-block-post-title {
	grid-area: title;
	font-size: var(--wp--preset--font-size--large) !important;
	line-height: 1.25;
}

.kelvinb-watched-card .kelvinb-watched-director {
	grid-area: director;
	font-size: var(--wp--preset--font-size--small) !important;
}

.kelvinb-watched-card .wp-block-post-terms {
	grid-area: type;
	font-size: var(--wp--preset--font-size--small) !important;
}

.kelvinb-watched-card .kelvinb-rating {
	grid-area: rating;
	justify-self: end;
}

.kelvinb-rating {
	margin: 0;
	font-size: var(--wp--preset--font-size--small);
	letter-spacing: 0.1em;
	line-height: 1;
	white-space: nowrap;
}

.kelvinb-star {
	display: inline-block;
}

.kelvinb-rating .is-on {
	color: var(--wp--preset--color--accent);
}

.kelvinb-rating .is-off {
	color: color-mix(in srgb, var(--wp--preset--color--muted) 30%, transparent);
}

.kelvinb-rating.is-unrated {
	letter-spacing: 0;
	color: var(--wp--preset--color--muted);
}

@media (max-width: 640px) {
	/* Title and stars on top; director and type underneath. */
	.kelvinb-watched-card {
		grid-template-columns: minmax(0, 1fr) auto;
		grid-template-areas:
			"title rating"
			"director type";
		row-gap: 0.25rem;
	}

	.kelvinb-watched-card .wp-block-post-terms {
		justify-self: end;
	}
}

/* Places: a grid of trips, newest first. A photo (4:3, the first one, with
   "+N" for the rest), then the date, title (serif), where and a short take,
   with no box around them. The whole item is a link. A trip without a photo
   gets a plain panel with the date instead. */
.kelvinb-log .wp-block-post-template {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
	gap: var(--wp--preset--spacing--50) var(--wp--preset--spacing--40);
	margin: 0;
}

.kelvinb-log .wp-block-post-template > .wp-block-post {
	display: flex;
	margin: 0;
}

.kelvinb-log-row {
	position: relative;
	display: flex;
	flex-direction: column;
	flex: 1;
	margin: 0;
}

.kelvinb-log-row > * {
	margin: 0 !important;
}

.kelvinb-log-date {
	color: var(--wp--preset--color--muted);
}

.kelvinb-log-row .kelvinb-log-date {
	order: -1;
	padding-top: var(--wp--preset--spacing--20);
	font-size: var(--wp--preset--font-size--small);
}

.kelvinb-log-row .kelvinb-log-date time {
	display: flex;
	gap: 0.3em;
}

.kelvinb-log-row .kelvinb-log-date-y::before {
	content: ", ";
	margin-left: -0.3em;
}

/* A trip without a photo already shows its date on the panel. */
.kelvinb-log-row:has(.kelvinb-log-face) .kelvinb-log-date {
	display: none;
}

.kelvinb-log-body {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	min-width: 0;
	padding-top: 0.2rem;
}

.kelvinb-log-row:has(.kelvinb-log-face) .kelvinb-log-body {
	padding-top: var(--wp--preset--spacing--20);
}

.kelvinb-log-body > * {
	margin-block: 0 !important;
}

.kelvinb-log-body .wp-block-post-title {
	font-size: var(--wp--preset--font-size--large) !important;
	line-height: 1.2;
}

.kelvinb-log-body .wp-block-post-title a {
	text-decoration: none;
	color: var(--wp--preset--color--contrast);
}

/* Stretched link: the whole item opens the trip. */
.kelvinb-log-body .wp-block-post-title a::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

.kelvinb-log-row:hover .wp-block-post-title a {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}

.kelvinb-log-row .kelvinb-log-where {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.kelvinb-log-where:empty {
	display: none;
}

.kelvinb-log-take {
	color: var(--wp--preset--color--muted);
}

.kelvinb-log-take p {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
	margin: 0;
}

.kelvinb-log-cover {
	position: relative;
	order: -2;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	border-radius: var(--wp--custom--radius--small);
}

.kelvinb-log-cover img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: opacity 0.2s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.kelvinb-log-row:hover .kelvinb-log-cover img {
	opacity: 0.85;
	transform: scale(1.03);
}

.kelvinb-log-cover .kelvinb-log-more {
	inset: auto 0.5rem 0.5rem auto;
	padding: 0.15em 0.5em;
	border-radius: var(--wp--custom--radius--small);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 500;
	letter-spacing: 0;
}

/* No photo: a plain panel with the date in the serif. */
.kelvinb-log-face {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	justify-content: flex-end;
	gap: 0.2rem;
	padding: var(--wp--preset--spacing--30);
	background: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--line);
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--muted);
}

.kelvinb-log-face-d {
	order: -1;
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--xx-large);
	line-height: 1;
	color: var(--wp--preset--color--contrast);
}

/* A trip's page: the photo mosaic (one photo full width, two side by side, or
   three as one big plus two stacked, "+N" on the last tile), then the date,
   title and where; the text and gallery (photos open in a lightbox); and
   newer / older trips. */
.kelvinb-entry-hero {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--20);
}

.kelvinb-entry-hero > * {
	margin: 0 !important;
}

.kelvinb-entry-hero .kelvinb-log-photos {
	order: -2;
	display: grid;
	grid-template-rows: minmax(0, 1fr);
	gap: 3px;
	aspect-ratio: 16 / 9;
	margin-bottom: var(--wp--preset--spacing--20) !important;
	overflow: hidden;
	border-radius: var(--wp--custom--radius--small);
}

.kelvinb-log-photos.has-2 {
	grid-template-columns: 1fr 1fr;
}

.kelvinb-log-photos.has-3 {
	grid-template-columns: 2fr 1fr;
	grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) !important;
}

.kelvinb-log-photos.has-3 .kelvinb-log-tile:first-child {
	grid-row: span 2;
}

.kelvinb-log-tile {
	position: relative;
	overflow: hidden;
	min-height: 0;
}

/* Images fill their tile without sizing it, so the mosaic keeps its frame. */
.kelvinb-entry-hero .kelvinb-log-tile img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.kelvinb-log-more {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: color-mix(in srgb, #000 55%, transparent);
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--x-large);
	color: #fff;
}

.kelvinb-entry-hero .kelvinb-log-date {
	order: -1;
	font-size: var(--wp--preset--font-size--small);
}

.kelvinb-entry-hero .kelvinb-log-date time {
	display: flex;
	gap: 0.3em;
}

.kelvinb-entry-hero .kelvinb-log-date-y::before {
	content: ", ";
	margin-left: -0.3em;
}

.kelvinb-entry-head > * {
	margin-block: 0;
}

.kelvinb-entry-hero .wp-block-post-title {
	line-height: 1.05;
}

.kelvinb-entry-head .kelvinb-log-where {
	margin-top: var(--wp--preset--spacing--10);
}

.kelvinb-entry-content {
	margin-top: var(--wp--preset--spacing--40) !important;
}

.kelvinb-entry-content .wp-block-gallery,
.kelvinb-entry-content .wp-block-image {
	margin-block: var(--wp--preset--spacing--50);
}

.kelvinb-entry-content img {
	border-radius: var(--wp--custom--radius--small);
}

/* Newer / older trips: two plain links under a rule. */
.kelvinb-entry-nav {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: var(--wp--preset--spacing--30);
	padding-top: var(--wp--preset--spacing--30);
	border-top: 1px solid var(--wp--preset--color--line);
}

.kelvinb-entry-nav > * {
	margin: 0 !important;
}

.kelvinb-entry-link {
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
}

.kelvinb-entry-link.is-older {
	align-items: flex-end;
	text-align: right;
}

.kelvinb-entry-link-dir,
.kelvinb-entry-link-meta {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--muted);
}

.kelvinb-entry-link-title {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--large);
	line-height: 1.2;
}

a.kelvinb-entry-link:hover .kelvinb-entry-link-title {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}

@media (max-width: 640px) {
	.kelvinb-entry-hero .kelvinb-log-photos {
		aspect-ratio: 4 / 3;
	}

	.kelvinb-entry-hero .wp-block-post-title {
		font-size: var(--wp--preset--font-size--xx-large) !important;
	}
}

/* Work: experience rows under thin rules. */
.kelvinb-timeline > .wp-block-group {
	border-top: 1px solid var(--wp--preset--color--line);
}

/* Mobile menu overlay: my name top-left (level with the close button), email
   at the bottom. */
.kelvinb-menu-mark,
.kelvinb-menu-email {
	display: none;
}

.is-menu-open .kelvinb-menu-mark {
	display: block;
	position: absolute;
	top: 0;
	left: 0;
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--large);
	line-height: 24px;
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
	background: none;
}

.is-menu-open .wp-block-navigation__responsive-container-content .wp-block-navigation-item__content {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--x-large);
	color: var(--wp--preset--color--contrast);
}

.is-menu-open .kelvinb-menu-email {
	display: block;
	margin-top: var(--wp--preset--spacing--60);
	font-size: var(--wp--preset--font-size--small);
}

.kelvinb-menu-email a {
	color: var(--wp--preset--color--muted);
}

/* Header stays visible while scrolling. The blur sits on a pseudo-element:
   backdrop-filter on the header itself would trap the mobile menu overlay
   (position: fixed) inside the header's height. */
.wp-site-blocks > header.wp-block-template-part {
	position: sticky;
	top: 0;
	z-index: 50;
}

.wp-site-blocks > header.wp-block-template-part::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: color-mix(in srgb, var(--wp--preset--color--base) 85%, transparent);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
}

body.admin-bar .wp-site-blocks > header.wp-block-template-part {
	top: var(--wp-admin--admin-bar--height, 0);
}

/* Page transitions: a short crossfade between pages, and the header stays
   put (browsers without support just navigate). */
@media (prefers-reduced-motion: no-preference) {
	@view-transition {
		navigation: auto;
	}

	/* Named only while a transition runs, so it never traps the mobile menu. */
	:root:active-view-transition .wp-site-blocks > header.wp-block-template-part {
		view-transition-name: kb-header;
	}

	::view-transition-old(root),
	::view-transition-new(root) {
		animation-duration: 0.2s;
	}
}

/* Motion (assets/js/motion.js). Things only start hidden once the script has
   opted in with html.kb-motion, so without it everything just shows. */
@media (prefers-reduced-motion: no-preference) {
	/* The page title and its lead rise in once, on load. */
	main h1:first-of-type,
	main h1:first-of-type ~ .kelvinb-lead {
		animation: kb-rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
	}

	main h1:first-of-type ~ .kelvinb-lead {
		animation-delay: 0.08s;
	}

	/* Rows, cards and headings ease in as they scroll into view. */
	.kb-motion .kb-reveal:not(.kelvinb-rating) {
		opacity: 0;
		transform: translateY(0.75rem);
		transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
		transition-delay: var(--kb-delay, 0ms);
	}

	.kb-motion .kb-reveal.is-in:not(.kelvinb-rating) {
		opacity: 1;
		transform: none;
	}

	/* Stars fill in one by one: each lit star pops from the faint colour to
	   olive, 70ms after the one before. */
	.kb-motion .kelvinb-rating.kb-reveal .kelvinb-star.is-on {
		color: color-mix(in srgb, var(--wp--preset--color--muted) 30%, transparent);
		transform: scale(0.6);
		transition: color 0.3s ease, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
		transition-delay: calc(var(--kb-delay, 0ms) + 150ms + var(--i) * 70ms);
	}

	.kb-motion .kelvinb-rating.is-in .kelvinb-star.is-on {
		color: var(--wp--preset--color--accent);
		transform: none;
	}

	/* Hovering a watched row lifts its stars in a small wave. */
	.kelvinb-watched-card:hover .kelvinb-rating .kelvinb-star.is-on {
		animation: kb-twinkle 0.5s ease calc(var(--i) * 50ms);
	}
}

@keyframes kb-rise {
	from {
		opacity: 0;
		transform: translateY(0.75rem);
	}
}

@keyframes kb-twinkle {
	50% {
		transform: translateY(-0.2em) scale(1.15);
	}
}

@media (prefers-reduced-motion: reduce) {
	* {
		transition: none !important;
	}
}

/* Keep short meta (a date, a place) on one line. */
.kelvinb-nowrap { white-space: nowrap; }
