/*
Theme Name:        lifeandculture
Theme URI:
Author:            Mark Scoot
Description:       A plain, fast, responsive theme with two sections under one name: Tech (IT learning notes) and Life (personal posts, including photography).
Version:           1.0.0
Requires at least: 6.0
Requires PHP:      7.4
License:           GNU General Public License v2 or later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html
Text Domain:       lifeandculture
*/

/*
 * HOW THIS FILE IS ORGANISED
 * --------------------------
 * The comment block above is the "theme header". The site software reads it
 * to show the theme's name and details on the Themes screen. It must be the
 * first thing in style.css.
 *
 * Everything below is ordinary CSS, grouped into numbered parts:
 *   1. Design tokens (colours, fonts, sizes as CSS variables)
 *   2. Base / reset
 *   3. Accessibility helpers
 *   4. Layout wrapper
 *   5. Site header and main menu
 *   6. Home intro
 *   7. Post lists (home, archives, search)
 *   8. Section badges (Tech / Life labels)
 *   9. Single posts and pages
 *  10. Code blocks
 *  11. Images, captions, alignment, embeds, tables
 *  12. Buttons and forms
 *  13. Pagination and post navigation
 *  14. Footer
 *  15. Dark mode
 *
 * No CSS framework and no web fonts: the "system font stack" uses fonts the
 * visitor's device already has, so nothing extra is downloaded.
 */


/* ==========================================================================
   1. Design tokens
   CSS custom properties ("variables") let us define a value once and reuse
   it everywhere with var(--name). Changing a colour here changes it sitewide.
   ========================================================================== */
:root {
	/* Colours */
	--color-bg: #ffffff;          /* page background */
	--color-text: #1f2328;        /* main text */
	--color-muted: #5b636e;       /* dates, captions, secondary text */
	--color-border: #e3e6ea;      /* thin dividing lines */
	--color-link: #0b5cad;        /* links */
	--color-link-hover: #07427d;  /* links on hover */
	--color-surface: #f6f8fa;     /* light boxes (inline code, search box) */

	/* Section colours: one accent for Tech, one for Life */
	--color-tech: #0b5cad;        /* blue for Tech */
	--color-tech-bg: #e7f0fa;
	--color-life: #8a4b12;        /* warm brown for Life */
	--color-life-bg: #fbf0e4;

	/* Code blocks get their own dark panel so they stand out from prose */
	--code-bg: #1e2329;
	--code-text: #e6edf3;

	/* Fonts: system stacks, no downloads */
	--font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
		"Helvetica Neue", Arial, "Noto Sans", sans-serif;
	--font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
		"Liberation Mono", monospace;

	/* Sizes */
	--content-width: 46rem;       /* max line length for comfortable reading */
	--gap: 1.5rem;                /* standard spacing unit */
	--radius: 6px;                /* rounded corners */
}


/* ==========================================================================
   2. Base / reset
   Small, sensible defaults so every browser starts from the same place.
   ========================================================================== */

/* Make width/height include padding and border: far easier to reason about. */
*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	/* Stop phones from inflating text size when rotated. */
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--color-bg);
	color: var(--color-text);
	font-family: var(--font-body);
	font-size: 1.0625rem;         /* 17px: a touch larger than default for reading */
	line-height: 1.65;
	/* Lay out header / main / footer as a column so the footer sits at the
	   bottom even on short pages. */
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

/* Headings: tighter line height and a consistent weight. */
h1, h2, h3, h4, h5, h6 {
	line-height: 1.25;
	margin: 2rem 0 0.75rem;
	font-weight: 700;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

/* Paragraphs and lists: space below only, so spacing doesn't double up. */
p, ul, ol, dl, blockquote, figure, table, pre {
	margin: 0 0 var(--gap);
}

a {
	color: var(--color-link);
	text-underline-offset: 0.15em;  /* move the underline slightly down: easier to read */
}
a:hover {
	color: var(--color-link-hover);
}

/* A visible focus ring for keyboard users. */
:focus-visible {
	outline: 3px solid var(--color-link);
	outline-offset: 2px;
}

hr {
	border: 0;
	border-top: 1px solid var(--color-border);
	margin: 2rem 0;
}

blockquote {
	margin-left: 0;
	padding-left: 1rem;
	border-left: 4px solid var(--color-border);
	color: var(--color-muted);
}


/* ==========================================================================
   3. Accessibility helpers
   ========================================================================== */

/* Hide text visually but keep it readable by screen readers.
   The core software also uses this class name, e.g. in pagination. */
.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* "Skip to content" link: hidden until a keyboard user tabs to it. */
.skip-link {
	position: absolute;
	left: 0.5rem;
	top: -3rem;
	z-index: 100;
	padding: 0.5rem 1rem;
	background: var(--color-text);
	color: var(--color-bg);
	border-radius: var(--radius);
}
.skip-link:focus {
	top: 0.5rem;
	color: var(--color-bg);
}


/* ==========================================================================
   4. Layout wrapper
   .wrap centres content and keeps lines from getting too long.
   ========================================================================== */
.wrap {
	width: 100%;
	max-width: var(--content-width);
	margin: 0 auto;
	padding: 0 1.25rem;
}

/* The main area grows to fill space, pushing the footer down. */
.site-main {
	flex: 1;
	padding-top: 2rem;
	padding-bottom: 3rem;
}


/* ==========================================================================
   5. Site header and main menu
   ========================================================================== */
.site-header {
	border-bottom: 1px solid var(--color-border);
}

/* Title on the left, menu on the right; wraps onto two lines on small screens. */
.site-header__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem 1.5rem;
	padding-top: 1rem;
	padding-bottom: 1rem;
}

.site-title {
	margin: 0;
	font-size: 1.35rem;
	font-weight: 800;
	letter-spacing: -0.01em;
}
.site-title a {
	color: var(--color-text);
	text-decoration: none;
}

.site-description {
	margin: 0;
	font-size: 0.9rem;
	color: var(--color-muted);
}

/* --- Menu: top level --- */
.main-nav ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.main-nav .menu {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1rem;
}

.main-nav li {
	position: relative;   /* lets the dropdown position itself under its parent */
}

.main-nav a {
	display: block;
	padding: 0.35rem 0;
	color: var(--color-text);
	text-decoration: none;
	font-weight: 600;
}
.main-nav a:hover {
	color: var(--color-link);
}

/* Highlight the item for the page you're on.
   current-menu-item / current-menu-ancestor are added automatically;
   current-section is added by this theme (see functions.php) when you're
   reading a post that belongs to Tech or Life. */
.main-nav .current-menu-item > a,
.main-nav .current-menu-ancestor > a,
.main-nav .current-section > a {
	color: var(--color-link);
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 0.35em;
}

/* --- Menu: sub-menu (e.g. Photography under Life) ---
   Default (phones, touch screens): show it indented under its parent.
   No JavaScript is needed, and it's always reachable by tapping. */
.main-nav .sub-menu {
	padding-left: 0.75rem;
	font-size: 0.95rem;
}
.main-nav .sub-menu a {
	font-weight: 500;
}

/* On wide screens with a mouse: turn the sub-menu into a dropdown.
   (hover: hover) means "this device can hover", so touch screens skip it. */
@media (min-width: 48em) and (hover: hover) {
	.main-nav .sub-menu {
		position: absolute;
		top: 100%;
		left: -0.75rem;
		z-index: 10;
		min-width: 11rem;
		padding: 0.4rem 0;
		background: var(--color-bg);
		border: 1px solid var(--color-border);
		border-radius: var(--radius);
		box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
		/* Hidden until the parent is hovered or focused */
		display: none;
	}
	.main-nav .sub-menu a {
		padding: 0.4rem 0.75rem;
	}
	/* :focus-within opens the dropdown for keyboard users too. */
	.main-nav li:hover > .sub-menu,
	.main-nav li:focus-within > .sub-menu {
		display: block;
	}
	/* A small arrow after parents that have children. */
	.main-nav .menu-item-has-children > a::after {
		content: " \25BE";   /* ▾ */
		font-size: 0.8em;
	}
}


/* --- Banner image (only present when one is set in the Customizer) ---
   It sits outside the centred .wrap, so it spans the full screen width. */
.site-banner {
	border-bottom: 1px solid var(--color-border);
	background: var(--color-surface);       /* grey placeholder while the image loads */
}
.site-banner img {
	display: block;                         /* removes the small gap under inline images */
	width: 100%;                            /* always the full screen width... */
	height: auto;                           /* ...with the height worked out from: */
	/* aspect-ratio: the box is always 4 wide by 1 tall, at every screen
	   width (about 98px tall on a 390px phone, 400px at 1600px). The
	   browser also reserves this space before the image arrives, so the page
	   doesn't jump down when it loads. The Customizer crops banners to
	   exactly 2400×600 (functions.php), so the photo fits this box perfectly
	   and nothing is trimmed. */
	aspect-ratio: 4 / 1;
	/* Safety net for a banner that isn't exactly 4:1 (e.g. one set before
	   the crop rule): fill the box without squashing the picture. */
	object-fit: cover;
}


/* ==========================================================================
   6. Home intro
   ========================================================================== */
.home-intro {
	margin-bottom: 2.5rem;
	padding-bottom: 1.5rem;
	border-bottom: 1px solid var(--color-border);
}
.home-intro__text {
	font-size: 1.25rem;
	margin-bottom: 0.75rem;
}
.home-intro__sections {
	margin: 0;
	color: var(--color-muted);
}


/* ==========================================================================
   7. Post lists (home, archives, search)
   ========================================================================== */

/* Heading block at the top of archive / search / 404 pages */
.page-header {
	margin-bottom: 2rem;
}
.page-header .page-title {
	margin-top: 0;
}
.page-header .eyebrow {
	margin-bottom: 0.25rem;
}
.archive-description {
	color: var(--color-muted);
}

/* Small label above a title, e.g. "Section" or "Life" */
.eyebrow {
	margin: 0 0 0.4rem;
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--color-muted);
}

/* One post in a list */
.post-summary {
	padding: 1.25rem 0;
	border-bottom: 1px solid var(--color-border);
}
.post-summary:first-child {
	padding-top: 0;
}

.post-summary__title {
	margin: 0.35rem 0 0.25rem;
	font-size: 1.3rem;
}
.post-summary__title a {
	color: var(--color-text);
	text-decoration: none;
}
.post-summary__title a:hover {
	color: var(--color-link);
	text-decoration: underline;
}

.post-summary__excerpt p {
	margin: 0.5rem 0 0;
}

/* Date, author and other small details */
.entry-meta {
	font-size: 0.9rem;
	color: var(--color-muted);
}
.entry-meta a {
	color: inherit;
}

/* --- Posts WITH a featured image: text on the left, thumbnail on the right ---
   The class "has-post-thumbnail" is added automatically to posts that have
   a featured image, so posts without one keep the plain layout above.
   CSS grid with named areas: we draw the layout as a little map. */
.post-summary.has-post-thumbnail {
	display: grid;
	grid-template-columns: 1fr 7rem;        /* text takes the rest; thumbnail 7rem (112px) */
	grid-template-areas:
		"header  thumb"
		"excerpt thumb";                    /* the thumbnail spans both rows */
	grid-template-rows: auto 1fr;           /* the excerpt row takes any spare height */
	column-gap: 1rem;
	align-items: start;
}
.has-post-thumbnail > .entry-header         { grid-area: header; }
.has-post-thumbnail > .post-summary__excerpt { grid-area: excerpt; }
.has-post-thumbnail > .post-summary__thumb  { grid-area: thumb; }

/* Bigger thumbnail on wider screens: 10rem (160px). */
@media (min-width: 36em) {
	.post-summary.has-post-thumbnail {
		grid-template-columns: 1fr 10rem;
		column-gap: 1.5rem;
	}
}

.post-summary__thumb {
	display: block;
	border-radius: var(--radius);
	overflow: hidden;                       /* clip the image to the rounded corners */
	background: var(--color-surface);       /* grey square while it loads */
}
.post-summary__thumb img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;                    /* always a square, so the list stays tidy */
	object-fit: cover;                      /* fill the square, trimming the edges */
}

/* Lines up the badge and date on one row */
.post-summary__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
}


/* ==========================================================================
   8. Section badges (Tech / Life labels)
   Every post shows one of these so readers always know which section it's in.
   ========================================================================== */
.section-badges {
	display: inline-flex;
	gap: 0.35rem;
}

.section-badge {
	display: inline-block;
	padding: 0.1rem 0.55rem;
	border-radius: 999px;         /* pill shape */
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	text-decoration: none;
	line-height: 1.6;
}
.section-badge:hover {
	text-decoration: underline;
}

.section-badge--tech {
	background: var(--color-tech-bg);
	color: var(--color-tech);
}
.section-badge--life {
	background: var(--color-life-bg);
	color: var(--color-life);
}

/* A coloured bar on section archive headers, single posts and the
   Photography page, using the section's accent colour. */
.section-tech .page-header,
.section-tech .entry-header,
.section-life .page-header,
.section-life .entry-header {
	border-left: 4px solid var(--section-accent, var(--color-border));
	padding-left: 1rem;
}
.section-tech { --section-accent: var(--color-tech); }
.section-life { --section-accent: var(--color-life); }

/* Post summaries in lists don't need the bar: the badge is enough. */
.post-summary .entry-header {
	border-left: 0;
	padding-left: 0;
}


/* ==========================================================================
   9. Single posts and pages
   ========================================================================== */
.entry-header {
	margin-bottom: 1.75rem;
}
.entry-title {
	margin: 0.35rem 0 0.4rem;
	font-size: 2rem;
}

/* The large featured image at the top of single posts and pages. */
.entry-thumbnail {
	margin: 0 0 1.75rem;
}
.entry-thumbnail img {
	display: block;
	width: 100%;                            /* fill the content column... */
	height: auto;                           /* ...keeping the image's shape */
	border-radius: var(--radius);
}

/* Keep long words and URLs from breaking the layout on phones. */
.entry-content {
	overflow-wrap: break-word;
}

.entry-content > *:first-child {
	margin-top: 0;
}

.entry-footer {
	margin-top: 2rem;
	padding-top: 1rem;
	border-top: 1px solid var(--color-border);
}

/* Page links for posts split with <!--nextpage--> */
.page-links {
	margin: 1.5rem 0;
	font-weight: 600;
}


/* ==========================================================================
   10. Code blocks
   Very important for the Tech section. Two kinds:
     - inline code:   `like this` inside a sentence  -> <code>
     - code blocks:   multi-line examples            -> <pre><code>
   ========================================================================== */

/* Use a monospace font for anything code-like. */
code,
kbd,
samp,
pre {
	font-family: var(--font-mono);
	font-size: 0.9em;
}

/* Inline code: a light grey chip so it stands out from the sentence. */
:not(pre) > code {
	padding: 0.1em 0.35em;
	background: var(--color-surface);
	border: 1px solid var(--color-border);
	border-radius: 4px;
	/* Allow long inline commands to wrap rather than overflow on phones. */
	overflow-wrap: anywhere;
}

/* Keyboard keys, e.g. <kbd>Ctrl</kbd> + <kbd>C</kbd> */
kbd {
	padding: 0.1em 0.4em;
	border: 1px solid var(--color-border);
	border-bottom-width: 2px;
	border-radius: 4px;
	background: var(--color-surface);
}

/* Code blocks: a dark panel.
   .wp-block-code is the class the editor's "Code" block adds, so we style
   both plain <pre> and that block the same way. */
pre,
.wp-block-code {
	display: block;
	padding: 1rem 1.25rem;
	background: var(--code-bg);
	color: var(--code-text);
	border-radius: var(--radius);
	line-height: 1.5;
	/* THE KEY PART: never wrap code lines (wrapping changes meaning in
	   YAML/Python/shell), and instead let the box scroll sideways. */
	white-space: pre;
	overflow-x: auto;
	/* Smooth "momentum" scrolling on iPhones. */
	-webkit-overflow-scrolling: touch;
	/* Show tabs as 4 spaces wide instead of the default 8. */
	tab-size: 4;
	-moz-tab-size: 4;
	/* Don't let the page's break-word rule wrap code. */
	overflow-wrap: normal;
	word-break: normal;
}

/* Code inside a block inherits the panel's look (no chip, no border). */
pre code,
.wp-block-code code {
	padding: 0;
	background: none;
	border: 0;
	border-radius: 0;
	color: inherit;
	font-size: inherit;
	white-space: inherit;
	overflow-wrap: normal;
}

/* --- Copy button on code blocks ---
   js/copy-code.js wraps each <pre> in <div class="code-block"> and adds a
   <button class="copy-button"> holding an SVG icon. Without JavaScript none
   of this exists, so these rules simply never apply and code blocks look
   exactly as styled above. */

/* Size of the square button, and the gap around it. Used below to work
   out how wide the gutter must be. */
.code-block {
	--copy-size: 2rem;
	--copy-gap: 0.5rem;
}

/* THE WRAPPER
   - position: relative makes it the reference point for the button, so the
     button is placed on the wrapper, not inside the scrolling <pre>.
   - It now draws the dark panel itself (background + rounded corners).
   - padding-right creates a gutter down the right-hand side, exactly wide
     enough for the button plus a gap on each side. The <pre> sits to the
     left of the gutter, so when code scrolls sideways it is cut off at the
     <pre>'s edge and never passes under the button.
   - No overflow: hidden here, or the tooltip above the button would be cut off. */
.code-block {
	position: relative;
	margin: 0 0 var(--gap);
	padding-right: calc(var(--copy-size) + var(--copy-gap) * 2);
	background: var(--code-bg);
	border-radius: var(--radius);
}

/* THE <pre> INSIDE THE WRAPPER
   It keeps its own sideways scrolling (from the rules above), but the
   wrapper now provides the panel colour and spacing. The right padding
   stops the last characters on a scrolled line touching the gutter. */
.code-block > pre {
	margin: 0;
	padding-right: 1rem;
	background: transparent;
	border-radius: 0;
	/* Short blocks must still be tall enough for the button. */
	min-height: calc(var(--copy-size) + var(--copy-gap) * 2);
}

/* THE BUTTON
   A small square in the gutter's top corner. Class selectors (.copy-button)
   beat the plain "button" rules in part 12, so it doesn't pick up the big
   blue button look. Its background is solid and matches the code panel. */
.copy-button {
	position: absolute;                     /* pinned to the wrapper... */
	top: var(--copy-gap);                   /* ...near the top */
	right: var(--copy-gap);                 /* ...and inside the right gutter */
	display: flex;                          /* centre the icon... */
	align-items: center;
	justify-content: center;                /* ...both ways */
	width: var(--copy-size);
	height: var(--copy-size);
	padding: 0;
	background: var(--code-bg);             /* solid, same as the panel */
	color: var(--code-text);                /* the SVG uses this via currentColor */
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 4px;
	cursor: pointer;
}
.copy-button:hover {
	/* Slightly lighter on hover. A solid colour mixed from the panel colour,
	   so it stays opaque. Browsers that don't understand color-mix() ignore
	   that line and keep the first one. */
	background: var(--code-bg);
	background: color-mix(in srgb, var(--code-bg), #ffffff 12%);
	color: #ffffff;
}

/* The icon inside the button. pointer-events: none means clicks always
   land on the button itself, not the drawing. */
.copy-button__icon {
	display: block;
	pointer-events: none;
}

/* Clear focus ring for keyboard users: a light blue that shows up well
   against the dark panel (the default blue ring would be hard to see). */
.copy-button:focus-visible {
	outline: 2px solid #8cc4ff;
	outline-offset: 2px;
}

/* THE TOOLTIP (pure CSS, no title attribute)
   ::after is a "pseudo-element": an extra box CSS can draw on an element
   without any HTML. content: attr(data-tooltip) fills it with the text in
   the button's data-tooltip attribute ("Copy code", then "Copied").
   ::before draws the small arrow pointing down at the button.
   Screen readers ignore these and use the button's aria-label instead. */
.copy-button::after,
.copy-button::before {
	position: absolute;
	right: 0;                               /* line up with the button's right edge, so it never goes off-screen */
	pointer-events: none;                   /* the tooltip can't be clicked or hovered itself */
	opacity: 0;                             /* hidden until needed */
	visibility: hidden;
	transition: opacity 0.12s ease;         /* quick fade in/out */
}
.copy-button::after {
	content: attr(data-tooltip);
	bottom: calc(100% + 0.45rem);           /* sit just above the button */
	padding: 0.25rem 0.5rem;
	background: var(--code-bg);
	color: var(--code-text);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 4px;
	font-family: var(--font-body);
	font-size: 0.75rem;
	font-weight: 600;
	line-height: 1.3;
	white-space: nowrap;                    /* keep "Copy code" on one line */
}
.copy-button::before {
	/* A CSS triangle: a zero-size box whose top border is coloured and
	   whose side borders are transparent. */
	content: "";
	bottom: calc(100% + 0.45rem - 5px);
	right: calc(var(--copy-size) / 2 - 5px); /* centred over the button */
	border: 5px solid transparent;
	border-top-color: var(--code-bg);
	border-bottom-width: 0;
	z-index: 1;                             /* drawn over the tooltip's border line */
}

/* Show the tooltip on mouse hover, on keyboard focus, and during the
   2-second "Copied"/"Copy failed" state (so touch-screen users, who can't
   hover, still see the confirmation). */
.copy-button:hover::after,
.copy-button:hover::before,
.copy-button:focus-visible::after,
.copy-button:focus-visible::before,
.copy-button.is-copied::after,
.copy-button.is-copied::before,
.copy-button.is-failed::after,
.copy-button.is-failed::before {
	opacity: 1;
	visibility: visible;
}

/* States set by the script for 2 seconds after a click. The tick icon
   turns green automatically because it uses currentColor. */
.copy-button.is-copied {
	color: #7ee2a8;                         /* green: success */
	border-color: #7ee2a8;
}
.copy-button.is-failed {
	color: #ff9b9b;                         /* red: something went wrong */
	border-color: #ff9b9b;
}

/* Visitors who ask their device for less motion get no fade. */
@media (prefers-reduced-motion: reduce) {
	.copy-button::after,
	.copy-button::before {
		transition: none;
	}
}

/* A button is no use on paper: hide it and drop the gutter when printing. */
@media print {
	.copy-button {
		display: none;
	}
	.code-block {
		padding-right: 0;
	}
}

/* Text selected inside code should still be readable. */
pre ::selection {
	background: #3d5a80;
	color: #ffffff;
}


/* ==========================================================================
   11. Images, captions, alignment, embeds, tables
   ========================================================================== */

/* Images and videos never wider than their container. */
img,
video,
iframe {
	max-width: 100%;
}
img {
	height: auto;
	vertical-align: middle;
}

figure {
	margin-left: 0;
	margin-right: 0;
}

figcaption,
.wp-caption-text {
	margin-top: 0.4rem;
	font-size: 0.875rem;
	color: var(--color-muted);
	text-align: center;
}

.wp-caption {
	max-width: 100%;
}

/* Alignment classes the editor adds when you align an image. */
.alignleft {
	float: left;
	margin: 0.3rem 1.25rem 1rem 0;
}
.alignright {
	float: right;
	margin: 0.3rem 0 1rem 1.25rem;
}
.aligncenter {
	display: block;
	margin-left: auto;
	margin-right: auto;
}
/* On phones, floats squash text: stack instead. */
@media (max-width: 30em) {
	.alignleft,
	.alignright {
		float: none;
		margin: 0 0 1rem;
	}
}

/* Clear floats at the end of the content. */
.entry-content::after {
	content: "";
	display: table;
	clear: both;
}

/* Tables: scroll sideways on small screens instead of overflowing. */
table {
	display: block;
	max-width: 100%;
	overflow-x: auto;
	border-collapse: collapse;
}
th,
td {
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--color-border);
	text-align: left;
}
th {
	background: var(--color-surface);
}


/* ==========================================================================
   12. Buttons and forms
   ========================================================================== */
.button,
button,
input[type="submit"] {
	display: inline-block;
	padding: 0.6rem 1.1rem;
	border: 0;
	border-radius: var(--radius);
	background: var(--color-link);
	color: #ffffff;
	font: inherit;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
}
.button:hover,
button:hover,
input[type="submit"]:hover {
	background: var(--color-link-hover);
	color: #ffffff;
}

/* Text boxes */
input[type="search"],
input[type="text"],
input[type="email"],
input[type="url"],
textarea {
	padding: 0.55rem 0.75rem;
	border: 1px solid var(--color-border);
	border-radius: var(--radius);
	background: var(--color-bg);
	color: var(--color-text);
	font: inherit;
}

/* Search form: label, box and button on one row; wraps on phones. */
.search-form {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 1rem 0 2rem;
}
.search-form label {
	flex: 1 1 14rem;
}
.search-form .search-field {
	width: 100%;
}

/* Photography page: grid of recent Flickr photos.
   2 columns on phones, 3 on wider screens, so 6 photos always fill
   complete rows (3×2 or 2×3). */
.photo-grid {
	list-style: none;
	margin: 2rem 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(2, 1fr);  /* two equal columns */
	gap: 0.5rem;
}
@media (min-width: 36em) {
	.photo-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}
.photo-grid a {
	display: block;
	border-radius: var(--radius);
	overflow: hidden;                       /* clip the image to the rounded corners */
	background: var(--color-surface);       /* grey placeholder while the image loads */
}
.photo-grid img {
	display: block;
	width: 100%;
	/* Every tile is a square, whatever the photo's shape. The box size is
	   known before the image loads, so the page doesn't jump around. */
	aspect-ratio: 1 / 1;
	object-fit: cover;                      /* fill the square, cropping the edges */
}
.photo-grid a:hover img {
	opacity: 0.85;
}

/* Photography page: the Flickr call-to-action */
.photo-cta {
	margin: 2rem 0;
}
.photo-cta .button {
	background: var(--color-life);
}
.photo-cta .button:hover {
	filter: brightness(0.9);
}

/* A notice only logged-in admins see (e.g. "set your Flickr URL") */
.admin-notice {
	padding: 0.75rem 1rem;
	border: 1px dashed var(--color-muted);
	border-radius: var(--radius);
	color: var(--color-muted);
	font-size: 0.95rem;
}


/* ==========================================================================
   13. Pagination and post navigation
   ========================================================================== */

/* "1 2 3 Next" links under lists */
.pagination .nav-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-top: 2rem;
}
.pagination .page-numbers {
	padding: 0.3rem 0.7rem;
	border: 1px solid var(--color-border);
	border-radius: var(--radius);
	text-decoration: none;
}
.pagination .page-numbers.current {
	background: var(--color-text);
	color: var(--color-bg);
	border-color: var(--color-text);
}

/* "Previous post / Next post" under a single post */
.post-navigation .nav-links {
	display: grid;
	grid-template-columns: 1fr;
	gap: 1rem;
	margin-top: 2.5rem;
}
@media (min-width: 40em) {
	.post-navigation .nav-links {
		grid-template-columns: 1fr 1fr;
	}
	.post-navigation .nav-next {
		text-align: right;
	}
}
.post-navigation a {
	display: block;
	text-decoration: none;
}
.post-navigation .nav-label {
	display: block;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--color-muted);
}
.post-navigation .nav-title {
	font-weight: 600;
}


/* ==========================================================================
   14. Footer
   ========================================================================== */
.site-footer {
	border-top: 1px solid var(--color-border);
	padding: 1.5rem 0;
	font-size: 0.9rem;
	color: var(--color-muted);
}
.site-footer p {
	margin: 0;
}
.site-footer a {
	color: inherit;
}


/* ==========================================================================
   15. Dark mode
   If the visitor's device is set to dark mode, swap the colour variables.
   Because everything above uses var(--...), this is all we need.
   ========================================================================== */
@media (prefers-color-scheme: dark) {
	:root {
		--color-bg: #15181c;
		--color-text: #e6e8eb;
		--color-muted: #9aa3ad;
		--color-border: #2c3138;
		--color-link: #6cb2ff;
		--color-link-hover: #a3cfff;
		--color-surface: #1f2329;

		--color-tech: #8cc4ff;
		--color-tech-bg: #16304d;
		--color-life: #f0b47a;
		--color-life-bg: #3b2814;

		--code-bg: #0d1014;
	}

	/* Buttons keep white text on a darker blue. */
	.button,
	button,
	input[type="submit"] {
		background: #2563a8;
	}
	.button:hover,
	button:hover,
	input[type="submit"]:hover {
		background: #1d4f87;
	}
	.photo-cta .button {
		background: #8a4b12;
	}
}
