@layer reset, defaults, themes, utilities, components;




/* ===========
	THEMES
=========== */

@layer themes {

  /* Default Dark (fallback) */
  :root {
    --fore-colour: white;
    --back-colour: #282828;
    --hot-colour: darkorange;
    --cold-colour: #66ccff;
  }

  :root blockquote {
    background-color: #3a3a3a; /* dark gray */
    border-left-color: #888888; /* medium gray */
    color: var(--fore-colour);
  }

  :root table th,
  :root table td {
    border-color: #555; /* darker gray border */
  }

  :root table tr:nth-child(even) {
    background-color: #2e2e2e; /* dark gray */
  }

  :root table tr:nth-child(odd) {
    background-color: #1c1c1c; /* very dark gray */
  }

  /* Light Theme */
  [data-theme="light"] {
    --fore-colour: #222;
    --back-colour: white;
    --hot-colour: crimson;
    --cold-colour: mediumBlue;
  }

  [data-theme="light"] blockquote {
    background-color: #f0f0f0; /* very light gray */
    border-left-color: #999999; /* medium gray */
    color: var(--fore-colour);
  }

  [data-theme="light"] table th,
  [data-theme="light"] table td {
    border-color: #999; /* medium gray border */
  }

  [data-theme="light"] table tr:nth-child(even) {
    background-color: #f0f0f0; /* light gray */
  }

  [data-theme="light"] table tr:nth-child(odd) {
    background-color: white;
  }

  /* Blue Theme */
  [data-theme="blue"] {
    --fore-colour: #001f3f;
    --back-colour: #e6f0ff;
    --hot-colour: royalblue;
    --cold-colour: steelblue;
  }
  
  [data-theme="blue"] blockquote {
  background-color: #c5d9ff; /* lighter, but more saturated pale blue */
  border-left-color: #004080; /* stronger royal blue border */
  color: #001f3f;             /* keep dark blue text */
}

  /* Green Theme */
  [data-theme="green"] {
  --fore-colour: #1b4332;
  --back-colour: #e9f5ec;
  --hot-colour: seagreen;
  --cold-colour: mediumseagreen;
}

[data-theme="green"] blockquote {
  background-color: #d7f2d9;
  border-left-color: #2a6e2a;
  color: var(--fore-colour);
}




/* =========== END THEMES */ }



/* ==========
	RESET
========== */

@layer reset {

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

/* ========== END RESET */ }



/* ==============
	UTILITIES
============== */

@layer utilities {

.uppercase {
	text-transform: uppercase;
}
.lowercase {
	text-transform: lowercase;
}
.undo-case {
	text-transform: none;
}

/* ============== END UTILITIES */ }



/* ==============
	DEFAULTS
============== */

@layer defaults {

/* STRUCTURE */

:root {
	--gap: 1.5rem;
	--line: 2px solid var(--fore-colour);
	--interface-font-size: 1.2em;
	--meta-font-size: 0.8em;
}
body {
	font-size: clamp(1rem, 1.5vw, 1.125rem); /* ~16–18px */
	font-family: Roboto, sans-serif;
	margin: 0;
	color: var(--fore-colour);
	background-color: var(--back-colour);
	line-height: 1.5;
}

table {
  border-collapse: collapse; /* Ensures borders don’t double up */
  width: 100%;
}
table th, table td {
  padding: 0.5rem 1rem;
  border: 1px solid #999; /* medium gray border */
}

table tr:nth-child(even) {
  background-color: #f0f0f0; /* light gray */
}

table tr:nth-child(odd) {
  background-color: white;
}

#skip-link {
	position: absolute;
	inset-block-start: 0;
	inset-inline-start: 0;
	color: var(--back-colour);
	background-color: var(--fore-colour);
	clip-path: inset(50%);
	&:focus {
		clip-path: unset;
	}
}
#container {
  margin-inline-start: 14em; /* match the sidebar width */
	inline-size: calc(100% - 14em - 3rem); /* subtract sidebar AND padding */
  padding-inline: 3rem;
}
.flex-list {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	padding-inline-start: 0;
	list-style-type: "";
}


#side-nav {
  background-color: var(--fore-colour);
	color: var(--back-colour); /* Keep this if you confirm contrast is good */
	padding-block-start: 2rem;
	padding-inline: 1rem;
	padding-left: 2rem;
	width: 14em;
	position: fixed;
	inset-block: 0;
	inset-inline-start: 0;
	overflow-y: auto;
	box-shadow: 2px 0 6px rgba(0,0,0,0.2);
}

/* SIDE NAV */
#side-nav ul {
	list-style: none;
	padding-left: 0;
	margin: 0;
}

#side-nav li {
	margin-bottom: 0.5em;
}

#side-nav a {
	color: var(--back-colour);
	text-decoration: none;
	font-size: var(--interface-font-size);
	display: block;
	padding: 0.3em 0.5em;
}

#side-nav a:hover {
	background-color: var(--hot-colour);
}

#side-nav-header {
	padding-block-end: 1rem;
	border-block-end: 1px solid var(--back-colour);
	padding-inline: 0.5rem;
}

#side-nav-header h1 {
	font-size: 1.4em;
	margin: 0;
	color: var(--hot-colour);
}

/* HEADER */

#header {
	color: var(--back-colour);
	background-color: var(--fore-colour);
}

#header * {
  margin-block: 0;
}

#main-nav {
	a {
		display: block;
		padding-block-start: 0.3em;
		padding-block-end: 0.2em;
		padding-inline: 0.4em;
		font-size: var(--interface-font-size);
		color: var(--back-colour);
		text-decoration: unset;
		&:hover {
			background-color: var(--hot-colour);
		}
	}
}
#header-message {
	padding-block-start: 0.3rem;
	padding-block-end: 0.2rem;
	padding-inline: 0.5rem;
	border-block-start: var(--line);
	border-color: var(--back-colour);
	&::before {
		content: "\25c9 \a0"; /* fisheye + non-breaking space */
		color: var(--hot-colour);
	}
	a {
		color: inherit;
		background-color: inherit;
	}
}

/* TEXT */
h1, h2, h3, h4, h5, h6 { {
  font-family: DM Serif Display, Oswald, serif;
}

:is(h1, h2, h3) + * {
	margin-block-start: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-family: "DM Serif Display", Oswald, serif;
  margin-block-start: 1em;
  margin-block-end: 0.25em;
}
h1 {
  font-size: clamp(2rem, 6vw, 3.5rem); /* 32–56px */
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 600;
}

h2 {
  font-size: clamp(1.75rem, 5vw, 2.75rem); /* 28–44px */
  line-height: 1.3;
  letter-spacing: -0.015em;
  font-weight: 600;
}

h3 {
  font-size: clamp(1.5rem, 4vw, 2.25rem); /* 24–36px */
  line-height: 1.4;
  letter-spacing: -0.01em;
  font-weight: 600;
}

h4 {
  font-size: clamp(1.25rem, 3vw, 1.75rem); /* 20–28px */
  line-height: 1.4;
  font-weight: 500;
}

h5 {
  font-size: clamp(1rem, 2.5vw, 1.5rem); /* 16–24px */
  line-height: 1.5;
  font-weight: 500;
}

h6 {
  font-size: clamp(0.875rem, 2vw, 1.25rem); /* 14–20px */
  line-height: 1.5;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}


details {
	margin-block: 1rem;
	margin-inline-start: var(--gap);
}
summary {
	cursor: pointer;
	font-weight: bold;
	margin-inline-start: -1rem;
	& + * {
		margin-block-start: 0;
	}
}

a:link {
  color: var(--hot-colour);
  background-color: transparent;
  text-decoration: underline;
}

a:visited {
  color: var(--cold-colour);
  background-color: transparent;
  text-decoration: underline;
}

a:hover,
a:focus {
  color: var(--back-colour);
  background-color: var(--hot-colour);
  text-decoration: none;
}

code {
	font-size: 0.8em;
}
.code-block {
	display: block;
	margin-block: 1rem;
	color: var(--back-colour);
	background-color: var(--fore-colour);
	overflow-x: auto;
	white-space: pre;
	tab-size: 4ch;
}

blockquote {
	background-color: #f0f0f0; /* very light gray */
	color: var(--fore-colour);
	border-left: 6px solid #999999; /* medium gray */
	padding: 1rem 1.5rem;
	margin-inline: var(--gap);
	font-style: italic;
	border-radius: 6px;
}
::marker {
	color: var(--hot-colour);
}

ul, ol {
  margin-block: 0;
  padding-inline-start: 1.5rem; 
}

li {
  margin-block: 0;
  padding: 0;
  line-height: inherit;
}


/* MEDIA */

img {
	display: block;
	margin-inline: auto;
	max-width: 100%;
	height: auto;  /* Maintain aspect ratio */
}
figure {
	margin-inline: var(--gap);
}
figcaption {
	text-align: center;
	blockquote + &::before {
		content: "\2014 \a0"; /* em dash + non-breaking space */
	}
}
.gallery {
	--gallery-cols: 1;
	display: grid;
	grid-template-columns: repeat(var(--gallery-cols), 1fr);
	gap: calc(2rem / var(--gallery-cols));
	padding-left: 0;
	list-style-type: "";
	&:has(:nth-child(2)) {
		--gallery-cols: 2;
	}
	&:has(:nth-child(5)) {
		--gallery-cols: 3;
	}
	&:has(:nth-child(10)) {
		--gallery-cols: 4;
	}
	img {
		height: 100%;
		width: 100%;
		aspect-ratio: 1;
		object-fit: cover;
	}
}
iframe {
	max-inline-size: 100%;
	display: block;
	margin-block: 1rem;
	border: var(--line);
}

/* POST LISTS */

.post-list {
	padding-inline-start: var(--gap);
	list-style-type: "";
	text-indent: calc(-1 * var(--gap));
	font-size: var(--interface-font-size);
}

#tag-index {
	padding-inline-start: 0;
	list-style-type: "";
	details {
		margin-block: 0;
	}
	[open] {
		margin-block-end: 1rem;
	}
	summary {
		font-size: var(--interface-font-size);
	}
}

/* POSTS */

article > header {
	margin-block-end: 1rem;
	padding-block-end: 1rem;
	border-block-end: var(--line);
	h1 {
		margin-block-end: 0.5rem;
		font-size: 2.2rem;
	}
	& + * {
		margin-block-start: 0;
	}
}
#post-tags {
	margin-block: 0;
	list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
	& > li:not(:last-child)::after {
		content: ",\a0"; /* comma + non-breaking space */
	}
	a::before {
		content: "#";
	}
}
#post-tags a,
.post-tags a,
article a {
  color: var(--hot-colour);
  background-color: transparent;
  text-decoration: underline;
}

#post-tags a:visited,
.post-tags a:visited,
article a:visited {
  color: var(--cold-colour);
}

#post-tags a:hover,
.post-tags a:hover,
article a:hover,
article a:focus {
  color: var(--back-colour);
  background-color: var(--hot-colour);
  text-decoration: none;
}


#post-nav > ul {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--gap);
	padding-inline-start: 0;
	list-style-type: "";
	& > :first-child > a::before {
		content: "\2190 \a0"; /* left arrow + non-breaking space */
	}
	& > :last-child {
		text-align: right;
		a::after {
			content: "\2192 \a0"; /* right arrow + non-breaking space */
		}
	}
}

/* FOOTER */

#footer {
	padding-block-start: 1rem;
	border-block: var(--line);
	font-size: var(--meta-font-size);
	[rel="return"]::before {
		content: "\2191 \a0"; /* up arrow + non-breaking space */
	}
}
#contact-links {
	& > li:not(:last-child)::after {
		content: "\a0 |\a0"; /* non-breaking space + pipe + non-breaking space */
	}
}

.post-excerpt {
  text-indent: 0 !important;
  margin-left: 0 !important;
  padding-left: 0 !important;
  white-space: normal;
  word-wrap: break-word;
}

#post-tags li {
  margin: 0;
  padding: 0;
}

#post-tags li a {
  text-decoration: underline; /* normal link underline */
  white-space: nowrap;        /* keep multi-word tags on one line */
  display: block;          /* makes each tag take a full line */
  margin-bottom: 0.3rem;  /* adds some spacing between lines */
  padding: 0;
  background: none;
  border-radius: 0;
  color: var(--hot-colour);
  background-color: transparent;  
}

#post-tags li a:visited {
  color: var(--cold-colour);
}

#post-tags li a:hover,
#post-tags li a:focus {
  color: var(--back-colour);
  background-color: var(--hot-colour);
  text-decoration: none;
}

/* ============== END DEFAULTS */ }

@layer defaults {
  a,
  a:link {
    color: var(--hot-colour);
    text-decoration: underline;
    background-color: transparent;
  }

  a:visited {
    color: var(--cold-colour);
  }

  a:hover,
  a:focus {
    color: var(--back-colour);
    background-color: var(--hot-colour);
    text-decoration: none;
  }
}

@layer components {
  .post-snippet {
    display: flex;
    gap: 0.3em;
    align-items: flex-start;
  }

  .post-snippet .post-meta {
    flex: 0 0 250px;
  }

  .post-snippet .post-excerpt {
    flex: 1;
  }
  .post-tags a {
  display: block;
  margin-bottom: 0.3em;
}

  
}

