/*
 * The platform's own pages — the overview and the rules — live inside the
 * EasyAdmin shell. This file adds only what EasyAdmin has no class for,
 * and takes its colours from EasyAdmin's variables, so light and dark mode
 * both work.
 *
 * Plain CSS, no Tailwind: the kit's reset would fight EasyAdmin's
 * Bootstrap. bin/build-assets.mjs copies it to public/build/platform/app.css.
 * A wireframe never loads it.
 */

/* ---- PORTA theme -------------------------------------------------------- */

/* EasyAdmin's documented theme switches (doc/design.rst): one primary
   colour and one corner radius drive every button, link, focus ring and
   field. Colours are Tailwind palette values written out, since this
   file is plain CSS (AGENTS.md → Colours): the PORTA red is red-500, its
   hover red-600, the ink zinc-900. Links and active items get EasyAdmin's
   darker mix of it, which keeps text contrast. Corners are square everywhere;
   only pills and switches, which use --border-radius-full, stay round.
   This file is not in EasyAdmin's cascade layer, so it wins in both
   colour schemes. */
:root,
.ea-dark-scheme {
	--porta-red: #fb2c36;       /* red-500 */
	--porta-red-hover: #e7000b; /* red-600 */
	--porta-ink: #18181b;       /* zinc-900 */
	--ea-primary: var(--porta-red);
	--ea-primary-foreground: #ffffff; /* white */
	--ea-radius: 0;
	--button-primary-bg: var(--porta-red);
	--button-primary-hover-bg: var(--porta-red-hover);
	--button-primary-active-bg: var(--porta-red-hover);
}

/* red-500 is too light for text on white (3.8:1). Links in the light
   scheme take red-700 (6.4:1). */
:root:not(.ea-dark-scheme) {
	--link-color: #c10007;       /* red-700 */
	--link-color-rgb: 193, 0, 7;
	--link-hover-color: var(--porta-red-hover);
}

/* A focused field is not an error. Red belongs to actions and to errors,
   so a field in focus takes the PORTA ink instead. */
.form-control:focus,
.form-select:focus {
	border-color: var(--porta-ink);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--porta-ink) 15%, transparent);
}

.ea-dark-scheme .form-control:focus,
.ea-dark-scheme .form-select:focus { --porta-ink: #ffffff; /* white */ }

/* Checkboxes are square too; a switch stays a pill. */
.form-check-input[type="checkbox"]:not(.form-switch *) { border-radius: 0; }

/* ---- Overview ---------------------------------------------------------- */

.overview-intro {
	margin-bottom: 1rem;
	color: var(--bs-secondary-color);
}

/* The filters sit on a grey bar, apart from the table. */
.overview-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 0.75rem 1rem;
	margin-bottom: 1.25rem;
	padding: 1rem;
	background: var(--bs-tertiary-bg);
}

.overview-filters__field { flex: 0 1 13rem; }
.overview-filters .form-label { margin-bottom: 0.25rem; font-size: 0.8125rem; }

/* The search field holds two buttons at its end: the magnifier (submit)
   and, after a search, the clear cross 40 px to its left. Both are
   40 px wide, so the text stops before them. The browser's own clear
   cross shows on focus only, so it is hidden. */
.overview-filters__search {
	position: relative;
	flex: 1 1 18rem;
	min-width: 0;
}

.overview-filters__search .form-control { padding-right: 5.5rem; }

.overview-filters__search input[type="search"]::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
}

.overview-filters__submit,
.overview-filters__clear {
	position: absolute;
	top: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	padding: 0;
	border: 0;
	background: none;
	color: var(--porta-red);
}

.overview-filters__submit { right: 0; }
.overview-filters__clear { right: 2.5rem; }

.overview-filters__submit:hover,
.overview-filters__clear:hover { color: var(--porta-red-hover); }

.overview-filters__submit svg,
.overview-filters__clear svg { width: 1rem; height: 1rem; }

/* The table has no scroll box of its own: the page scrolls, once. On a
   phone EasyAdmin's datagrid stacks the cells under their data-label. */
.overview-table {
	table-layout: fixed;
	width: 100%;
}

.overview-table td { vertical-align: top; overflow-wrap: anywhere; }
.overview-table th,
.overview-table th * { white-space: normal; }
.overview-name { font-weight: 600; }

.overview-meta {
	display: block;
	margin-top: 0.125rem;
	font-size: 0.8125rem;
	color: var(--bs-secondary-color);
}

.overview-empty {
	padding: 3rem 1rem;
	text-align: center;
	border: 1px dashed var(--bs-border-color);
	border-radius: var(--border-radius);
}

.overview-empty h2 { font-size: 1.125rem; }
.overview-empty p { color: var(--bs-secondary-color); }

/* ---- Rules --------------------------------------------------------------- */

.rules-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 2rem;
}

@media (min-width: 75rem) {
	.rules-layout {
		grid-template-columns: minmax(0, 1fr) 14rem;
		align-items: start;
	}

	.rules-toc {
		position: sticky;
		top: 1.5rem;
		max-height: calc(100vh - 3rem);
		overflow-y: auto;
	}
}

@media (max-width: 74.99rem) {
	.rules-toc { display: none; }
}

.rules-toc__title {
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--bs-secondary-color);
}

.rules-toc ul { list-style: none; margin: 0; padding: 0; }

.rules-toc a {
	display: block;
	padding: 0.25rem 0;
	font-size: 0.8125rem;
	line-height: 1.4;
	color: var(--bs-secondary-color);
	text-decoration: none;
}

.rules-toc a:hover { color: var(--color-primary); }

.rules-source {
	margin-top: 2rem;
	padding-top: 1rem;
	border-top: 1px solid var(--bs-border-color);
	font-size: 0.8125rem;
	color: var(--bs-secondary-color);
}

.rules {
	max-width: 72ch;
	font-size: 0.9375rem;
	line-height: 1.7;
	overflow-wrap: anywhere;
}

.rules > * + * { margin-top: 1rem; }
.rules > :first-child { margin-top: 0; }

.rules h1 { font-size: 1.75rem; font-weight: 700; }

.rules h2 {
	margin-top: 2.5rem;
	padding-top: 1.25rem;
	border-top: 1px solid var(--bs-border-color);
	font-size: 1.375rem;
	font-weight: 700;
}

.rules h3 { margin-top: 2rem; font-size: 1.125rem; font-weight: 600; }
.rules h4 { margin-top: 1.5rem; font-size: 1rem; font-weight: 600; }
.rules hr + h2 { margin-top: 0; padding-top: 0; border-top: 0; }
.rules h2 + *, .rules h3 + *, .rules h4 + * { margin-top: 0.75rem; }
.rules :is(h2, h3)[id] { scroll-margin-top: 1.5rem; }

.rules-anchor {
	margin-left: 0.4em;
	color: var(--bs-secondary-color);
	text-decoration: none;
	font-weight: 400;
	opacity: 0;
}

.rules :is(h2, h3):hover .rules-anchor,
.rules-anchor:focus-visible { opacity: 1; }

.rules ul, .rules ol { padding-left: 1.5rem; }
.rules li + li { margin-top: 0.375rem; }
.rules li:has(> input[type="checkbox"]) { list-style: none; margin-left: -1.5rem; }
.rules input[type="checkbox"] { margin-right: 0.5rem; }

.rules blockquote {
	margin-inline: 0;
	padding: 0.75rem 1rem;
	background: var(--bs-tertiary-bg);
	border-left: 3px solid var(--color-primary);
}

.rules hr { margin-block: 2rem; }

.rules code {
	font-size: 0.875em;
	background: var(--bs-tertiary-bg);
	padding: 0.1em 0.35em;
	border-radius: var(--border-radius);
	color: inherit;
}

.rules pre {
	color: var(--bs-body-color);
	background: var(--bs-tertiary-bg);
	border: 1px solid var(--bs-border-color);
	border-radius: var(--border-radius);
	padding: 0.875rem 1rem;
	overflow-x: auto;
	font-size: 0.8125rem;
	line-height: 1.6;
	overflow-wrap: normal;
}

.rules pre code { background: none; padding: 0; font-size: inherit; color: inherit; }

/* The copy button sits in the corner of a code block. The block keeps room
   for it, so the button never covers the first line. */
.rules-pre { position: relative; padding-right: 7rem; }
.rules-copy { position: absolute; top: 0.5rem; right: 0.5rem; }

/* Tables scroll inside themselves, never the page. */
.rules table {
	display: block;
	max-width: 100%;
	overflow-x: auto;
	border-collapse: collapse;
	font-size: 0.875rem;
	overflow-wrap: normal;
}

.rules th, .rules td {
	text-align: left;
	vertical-align: top;
	padding: 0.5rem 0.75rem;
	border-bottom: 1px solid var(--bs-border-color);
}

.rules th {
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--bs-secondary-color);
	border-bottom-width: 2px;
}

/* ---- Login ------------------------------------------------------------- */

/* The PORTA mark and the name sit above the card, left-aligned with it. */
.login-brand {
	display: flex;
	align-items: center;
	gap: 0.875rem;
}

.login-brand__mark {
	flex: none;
	inline-size: 2.25rem;
	block-size: 2.25rem;
	background: var(--porta-red);
}

.login-brand__text { display: grid; gap: 0.125rem; }

.login-brand__name {
	font-size: 1.375rem;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: -0.01em;
	color: var(--bs-emphasis-color);
}

.login-brand__claim {
	font-size: 0.8125rem;
	color: var(--bs-secondary-color);
}

.page-login .login-wrapper .main-header #header-logo { margin-block: 0 1.5rem; padding: 0; border: none; }

.login-required { color: var(--color-primary); font-weight: 600; }

.page-login .form-control-label { font-weight: 600; }

.page-login .form-control.is-invalid { border-color: var(--color-danger, #e7000b /* red-600 */); }

.login-error { margin-block-end: 1.25rem; }

.login-help {
	margin: 1.5rem 0 0;
	font-size: 0.8125rem;
	line-height: 1.5;
	color: var(--bs-secondary-color);
	text-align: center;
	text-wrap: pretty;
}

/* EasyAdmin gives the card a fixed 25rem and wide padding: at 320 px the
   card touches the screen edge. */
@media (max-width: 30rem) {
	.page-login .login-wrapper { inline-size: 100%; padding: 2rem 1rem; }
	.page-login .login-wrapper .content { padding: 1.5rem 1.25rem; }
	.page-login .login-brand { padding-inline: 1.25rem; }
}

/* ---- Handbook ---------------------------------------------------------- */

/* The handbook (docs/handbook) renders inside `.rules`, so it shares the
   type of the rules pages; below is only what the handbook adds. Colours
   are Tailwind palette values, named in comments (AGENTS.md → Colours). */

.handbook-lede {
	max-width: 68ch;
	margin: -0.25rem 0 1.5rem;
	font-size: 1.0625rem;
	color: var(--bs-secondary-color);
}

.rules-toc ul ul { padding-left: 0.75rem; }
.rules-toc ul ul a { font-size: 0.78rem; }

.handbook img { display: block; max-width: 100%; height: auto; margin-block: 1rem; border: 1px solid var(--bs-border-color); }

/* Callouts: GitHub alerts, `> [!TIP]`. The type sets one colour for the frame and
   the title; the body stays the page's text colour. */
.handbook .callout {
	--callout: #52525c;              /* zinc-600, note */
	--callout-bg: #f4f4f5;           /* zinc-100 */
	border: 1px solid color-mix(in srgb, var(--callout) 35%, transparent);
	background: var(--callout-bg);
	padding: 0.75rem 1rem;
	margin-block: 1rem;
}
.handbook .callout--tip { --callout: #007a55; --callout-bg: #ecfdf5; }        /* emerald-700, emerald-50 */
.handbook .callout--important { --callout: #1447e6; --callout-bg: #eff6ff; }  /* blue-700, blue-50 */
.handbook .callout--warning { --callout: #bb4d00; --callout-bg: #fffbeb; }    /* amber-700, amber-50 */
.handbook .callout--caution { --callout: #c10007; --callout-bg: #fef2f2; }    /* red-700, red-50 */

.ea-dark-scheme .handbook .callout { --callout-bg: #27272a; }                 /* zinc-800 */
.ea-dark-scheme .handbook .callout--note { --callout: #9f9fa9; }             /* zinc-400 */
.ea-dark-scheme .handbook .callout--tip { --callout: #00d492; }              /* emerald-400 */
.ea-dark-scheme .handbook .callout--important { --callout: #51a2ff; }        /* blue-400 */
.ea-dark-scheme .handbook .callout--warning { --callout: #ffb900; }          /* amber-400 */
.ea-dark-scheme .handbook .callout--caution { --callout: #ff6467; }          /* red-400 */

.handbook .callout::before {
	content: attr(data-title);
	display: block;
	margin-bottom: 0.25rem;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--callout);
}
.handbook .callout > :last-child { margin-bottom: 0; }

/* Mermaid draws into the block; before it runs, the source stays readable. */
.handbook pre.mermaid {
	background: none;
	border: 1px solid var(--bs-border-color);
	padding: 1rem;
	text-align: center;
	white-space: pre;
}
.handbook pre.mermaid svg { max-width: 100%; height: auto; }

/* Code highlighted on the server (tempest/highlight). */
.handbook .hl-keyword, .handbook .hl-operator { color: #c10007; }            /* red-700 */
.handbook .hl-property, .handbook .hl-attribute { color: #1447e6; }         /* blue-700 */
.handbook .hl-type, .handbook .hl-generic { color: #7008e7; }               /* violet-700 */
.handbook .hl-value, .handbook .hl-literal, .handbook .hl-number { color: #007a55; } /* emerald-700 */
.handbook .hl-variable { color: #bb4d00; }                                  /* amber-700 */
.handbook .hl-comment { color: #71717b; font-style: italic; }               /* zinc-500 */
.handbook .hl-strong { font-weight: 700; }
.handbook .hl-em { font-style: italic; }
.handbook .hl-blur { opacity: 0.5; }

.ea-dark-scheme .handbook .hl-keyword, .ea-dark-scheme .handbook .hl-operator { color: #ff6467; }   /* red-400 */
.ea-dark-scheme .handbook .hl-property, .ea-dark-scheme .handbook .hl-attribute { color: #51a2ff; } /* blue-400 */
.ea-dark-scheme .handbook .hl-type, .ea-dark-scheme .handbook .hl-generic { color: #a684ff; }       /* violet-400 */
.ea-dark-scheme .handbook .hl-value, .ea-dark-scheme .handbook .hl-literal, .ea-dark-scheme .handbook .hl-number { color: #00d492; } /* emerald-400 */
.ea-dark-scheme .handbook .hl-variable { color: #ffb900; }                  /* amber-400 */
.ea-dark-scheme .handbook .hl-comment { color: #9f9fa9; }                   /* zinc-400 */

/* ---- Changelog ----------------------------------------------------------- */

.changelog { max-width: 56rem; }

.changelog-day { margin-bottom: 2rem; }

.changelog-date {
	margin-bottom: 0.5rem;
	padding-bottom: 0.5rem;
	border-bottom: 1px solid var(--bs-border-color);
	font-size: 1.125rem;
	font-weight: 700;
}

.changelog-list { margin: 0; padding: 0; list-style: none; }

.changelog-entry {
	display: grid;
	grid-template-columns: 5.5rem 7rem minmax(0, 1fr);
	align-items: baseline;
	gap: 0.25rem 0.75rem;
	padding: 0.375rem 0;
	font-size: 0.9375rem;
	line-height: 1.5;
}

.changelog-text { overflow-wrap: anywhere; }
.changelog-text code { font-size: 0.8125rem; }

.changelog-scope {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 0.8125rem;
	color: var(--bs-secondary-color);
	text-decoration: none;
}

.changelog-scope:hover { text-decoration: underline; }

/* The badges are plain squares, as the rest of the theme. Text and
   background pairs are Tailwind -800 on -100 (AA contrast). */
.changelog-badge {
	display: inline-block;
	padding: 0.0625rem 0.5rem;
	font-size: 0.75rem;
	font-weight: 600;
	text-align: center;
}

.changelog-badge--added { background: #dcfce7; color: #016630; }    /* green-100, green-800 */
.changelog-badge--changed { background: #dbeafe; color: #193cb8; }  /* blue-100, blue-800 */
.changelog-badge--fixed { background: #fef9c2; color: #733e0a; }    /* yellow-100, yellow-800 */
.changelog-badge--removed { background: #f4f4f5; color: #27272a; }  /* zinc-100, zinc-800 */
.changelog-badge--security { background: #ffe2e2; color: #9f0712; } /* red-100, red-800 */

@media (max-width: 39.99rem) {
	.changelog-entry { grid-template-columns: auto minmax(0, 1fr); }
	.changelog-text { grid-column: 1 / -1; }
}
