/*
	SCRAP CSS
	Copyright 2026 Paul Ledbury <paul@ledbury.co.uk>

	This file is part of SCRAP Content Management System

	SCRAP is free software: you can redistribute it and/or modify
	it under the terms of the GNU Affero General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	SCRAP is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU Affero General Public License for more details.

	You should have received a copy of the GNU Affero General Public License
	along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/* --- Global Styles --- */
html {
	font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	line-height: 1.6;
	color: #333;
	background-color: #f4f6f8;
	background-image: linear-gradient(rgba(156, 146, 172, 0.15) 1px, transparent 1px),
			  linear-gradient(90deg, rgba(156, 146, 172, 0.15) 1px, transparent 1px);
	background-size: 25px 25px; 
}
body {
	max-width: 1000px;
	margin: 0 auto;
	padding: 20px;
}

/* --- Layout Header & Logo --- */
header {
	background: #fff;
	padding: 15px 40px;
	border-radius: 8px;
	box-shadow: 0 2px 4px rgba(0,0,0,0.04);
	margin-bottom: 30px;
}
.header-container {
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-wrap: wrap;
}
.logo img {
	max-height: 50px; /* Adjust if needed, based on your logo size */
	display: block;
}

/* --- Navigation & Pure CSS Dropdown --- */
nav ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	gap: 20px;
}
nav a {
	color: #444;
	text-decoration: none;
	font-weight: 600;
	display: block;
	padding: 5px 10px;
}
nav a:hover { color: #0066cc; }

/* Dropdown Container */
.dropdown {
	position: relative;
}
/* Hidden Dropdown Menu Box */
.dropdown-content {
	display: none;
	position: absolute;
	background-color: #fff;
	min-width: 160px;
	box-shadow: 0px 8px 16px rgba(0,0,0,0.1);
	border-radius: 6px;
	padding: 10px 0;
	z-index: 1;
	top: 100%;
	left: 0;
	flex-direction: column;
	gap: 0;
}
/* Dropdown Links */
.dropdown-content a {
	padding: 8px 16px;
	font-weight: 600;
}
.dropdown-content a:hover { background-color: #f0f0f0; }
/* Show dropdown on hover */
.dropdown:hover .dropdown-content {
	display: flex;
}

/* --- Main Content Area --- */
main { 
	background: #fff; 
	padding: 5px 40px 20px; 
	border-radius: 8px; 
	box-shadow: 0 2px 4px rgba(0,0,0,0.04); 
	min-height: 400px;
}
main img {
	max-width: 100%; /* prevent images from breaking mobile view */
	height: auto;
	border-radius: 6px;
}

/* indented 384-pixel-wide images on larger screens */
/* indent to place image centreline at 33% of page: (100%/3 - 384px/2 - 40px/3) */
main img.indent {
	display: block;
	margin-left: max(0px, calc(33.3% - 205px));
	margin-right: auto;
}

/* reduced size images for index items */
/* same indent as main img.indent */
main img.index {
	display: block;
	max-width: 200px;
	margin-left: max(0px, calc(33.3% - 205px));
	margin-bottom: 10px;
}  

main img.center {
	display: block;
	margin-left: auto;
	margin-right: auto;
}

footer { margin-top: 20px; text-align: center; font-size: 0.9em; color: #666; }

footer a {
  color: inherit;
  text-decoration: none;
}

.svgtext {
    height: .72em;
    width: auto;
    vertical-align: baseline;
}

/* --- Index pages --- */

.index-item {margin-bottom: 0px; border-top: 1px solid #ccc; padding-bottom: 20px;}
.title {color: inherit; text-decoration: none;}
.subtitle {font-style: italic; color: #666;}
.subtitle i, .subtitle em {font-style: normal;}
.read-more {text-decoration: none;}

/* --- Site map --- */
.sitemap-list {
    list-style-type: none;
    padding-left: 0;
    margin: 20px 0;
    font-family: inherit;
}

.sitemap-list li {
    margin: 0 0 0 20px;
}

.sitemap-list .tree-indent {
    font-family: monospace;
}

/* Style for category folder names (non-link parents) */
.sitemap-list strong {
    color: #2c3e50;
    font-weight: 600;
}

/* Style for actual page links */
.sitemap-list a {
    color: #2980b9;
    text-decoration: none;
}

.sitemap-list a:hover {
    text-decoration: underline;
}

/* --- Site map flexbox for text truncation --- */

.sitemap-list .sitemap-item,
.sitemap-list .sitemap-spacer {
    display: flex;
    align-items: center;
    line-height: 1.15;	/* space for descenders */
    margin-top: -2px;	/* overlap rows to join tree lines */
}

/* Prevent the tree lines from shrinking */
.sitemap-list .tree-indent {
    flex-shrink: 0;
    margin-right: 8px;
}

/* Let the text/link fill the remaining space dynamically */
.sitemap-list .sitemap-item a,
.sitemap-list .sitemap-item span.title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0; /* to allow flex items to truncate properly */
    flex: 1;
    position: relative;
    top: -1.0px; /* nudges text up to clear the bottom boundary */
}

/* --- Markup --- */

.quote {font-size: smaller; font-style: italic; color: #666;}
.quote i, .quote em {font-style: normal;}

/* restyle u as overline overline (text-decoration: overline is positioned too high) */
not {
  position: relative;
  display: inline-block;
  text-decoration: none; /* Removes the default underline */
}

not::before {
  content: "";
  position: absolute;
  top: 0.25em; /* Adjust this value to control height */
  left: 0;
  width: 100%;
  height: 1px;
  background-color: currentColor;
}

u {
  text-decoration: underline dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* --- Contemporary Code Formatting --- */
:root {
	--font-code: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
	
	/* Unified Palette: Both block and inline share these core variables */
	--bg-code-base: #f5f6f8;   /* Soft, modern slate-gray background */
	--text-code-base: #24292e; /* Deep charcoal for high legibility without pitch-black harshness */
	--border-code: #d0d7de;	/* Muted gray divider line */
}

/* Base style for ALL code tags (Inline and inside Blocks) */
code {
	font-family: var(--font-code);
	font-size: 0.9em;
	color: var(--text-code-base);
	background-color: var(--bg-code-base);
	padding: 0.1em 0.2em;
	border-radius: 4px;
	border: 1px solid var(--border-code);
	word-break: break-word;
}

/* Code block container */
pre {
	background-color: var(--bg-code-base);
	border: 1px solid var(--border-code);
	border-left: 4px solid #6e7781; /* A subtle, slate gray accent bar instead of bright blue */
	border-radius: 6px;
	padding: 0.5em 0.75em;
	margin: 1.5em 0;
	overflow-x: auto;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02); /* Minimalist, subtle depth */
}

/* Code formatting adaptations specifically inside blocks */
pre code {
	font-size: 0.9em;			  /* Filled space scaling */
	background-color: transparent !important; /* Strips double backgrounds */
	border: none !important;	 /* Strips double borders */
	padding: 0;
	border-radius: 0;
	white-space: pre;
}

/* --- Desktop Defaults for Toggle (Hidden) --- */
.menu-toggle, .menu-button {
	display: none;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
	.header-container {
		flex-direction: row; /* Keeps logo and hamburger button on the same line */
		justify-content: space-between;
		align-items: center;
		width: 100%;
		position: relative;
	}

	/* Display the hamburger button */
	.menu-button {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		width: 30px;
		height: 21px;
		cursor: pointer;
		z-index: 10;
	}

	/* Three lines of the hamburger icon */
	.menu-button span {
		display: block;
		height: 3px;
		width: 100%;
		background-color: #333;
		border-radius: 3px;
		transition: all 0.3s ease;
	}

	/* Completely hide the checkbox */
	.menu-toggle {
		display: none;
	}

	/* Hide the menu off-screen or collapse it by default on mobile */
	nav .nav-links {
		display: none; 
		flex-direction: column;
		width: 150px;
		position: absolute;
		top: 100%;
		right: 0;
		background: #fff;
		box-shadow: -2px 4px 12px rgba(0,0,0,0.1);
		padding: 15px 0;
		gap: 10px;
		z-index: 9;
		border-radius: 6px;
	}

	nav a {
		padding: 10px 25px;
		text-align: left;
	}

	/* --- The CSS Toggle Magic --- */
	/* When checkbox is checked, show the menu list */
	.menu-toggle:checked ~ .nav-links {
		display: flex;
	}

	/* Optional: Turns the hamburger icon into an "X" when open */
	.menu-toggle:checked + .menu-button span:nth-child(1) {
		transform: translateY(9px) rotate(45deg);
	}
	.menu-toggle:checked + .menu-button span:nth-child(2) {
		opacity: 0;
	}
	.menu-toggle:checked + .menu-button span:nth-child(3) {
		transform: translateY(-9px) rotate(-45deg);
	}

	/* Mobile Dropdown submenu tweaks */
	.dropdown-content {
		position: static;
		box-shadow: none;
		background: #f9f9f9;
		padding-left: 20px;
	}
	
	header {padding: 15px 20px;}

	main {padding: 5px 20px;}

	/* adjust indents for 20 pixel page padding: 100%/3 - 384px/2 - 20px/3 */
	main img.indent {margin-left: max(0px, calc(33.3% - 199px));}
	main img.index {margin-left: max(0px, calc(33.3% - 199px));}  

}
