/* PetitParser Examples - Shared Stylesheet
 * Matches the official styling of https://petitparser.github.io/
 */

@import url("https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500;600&display=swap");

/* --- CSS Variables --- */
:root {
	--color-primary: #003962;
	--color-primary-dark: #002744;
	--color-primary-gradient-end: #7b91ad;
	--color-accent: #0e5f8e;
	--color-accent-hover: #003962;
	--color-text: #606c71;
	--color-text-muted: #606c71;
	--color-bg: #ffffff;
	--color-card-bg: #ffffff;
	--color-border: #e1e4e8;
	--color-border-light: #eff1f3;
	--color-code-bg: #f3f6fa;
	--color-code-border: #dce6f0;
	--color-pre-bg: #f8f9fa;
	--color-error-bg: #fdf7f7;
	--color-error-border: #d9534f;
	--color-error-text: #a61717;
	--color-success: #159957;
	--font-sans:
		"Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
	--font-mono:
		"JetBrains Mono", ui-monospace, "SF Mono", Menlo, Monaco, Consolas,
		"Liberation Mono", monospace;
	--container-max-width: 102.4rem;
	--border-radius: 6px;
	--transition-speed: 0.2s;
}

/* --- Base & Reset --- */
*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	font-size: 62.5%; /* 1rem = 10px */
	scroll-behavior: smooth;
}

body {
	margin: 0;
	padding: 0;
	font-family: var(--font-sans);
	font-size: 1.6rem;
	line-height: 1.5;
	color: var(--color-text);
	background-color: var(--color-bg);
	-webkit-font-smoothing: antialiased;
}

a {
	color: var(--color-accent);
	text-decoration: none;
	transition: color var(--transition-speed);
}

a:hover {
	color: var(--color-primary-dark);
	text-decoration: underline;
}

h1,
h2,
h3,
h4,
h5,
h6 {
	color: var(--color-primary);
	font-weight: 600;
	line-height: 1.3;
	margin-top: 2rem;
	margin-bottom: 1rem;
}

h1 {
	font-size: 2.8rem;
}
h2 {
	font-size: 2.2rem;
}
h3 {
	font-size: 1.8rem;
}
h4 {
	font-size: 1.6rem;
}

p {
	margin-top: 0;
	margin-bottom: 1.2rem;
}

/* --- Hero Banner (Page Header) --- */
.page-header {
	color: #ffffff;
	text-align: center;
	background-color: var(--color-primary);
	background-image: linear-gradient(
		120deg,
		var(--color-primary),
		var(--color-primary-gradient-end)
	);
}

@media screen and (min-width: 64em) {
	.page-header {
		padding: 8rem 9.6rem;
	}
}

@media screen and (min-width: 42em) and (max-width: 64em) {
	.page-header {
		padding: 4.8rem 6.4rem;
	}
}

@media screen and (max-width: 42em) {
	.page-header {
		padding: 3.2rem 1.6rem;
	}
}

.page-header h1,
.page-header .project-name {
	color: #ffffff;
	font-weight: 700;
	margin-top: 0;
	margin-bottom: 0.16rem;
}

@media screen and (min-width: 64em) {
	.page-header h1,
	.page-header .project-name {
		font-size: 5.2rem;
		line-height: normal;
	}
}

@media screen and (min-width: 42em) and (max-width: 64em) {
	.page-header h1,
	.page-header .project-name {
		font-size: 3.6rem;
		line-height: normal;
	}
}

@media screen and (max-width: 42em) {
	.page-header h1,
	.page-header .project-name {
		font-size: 2.8rem;
		line-height: normal;
	}
}

.page-header h2,
.page-header .project-tagline {
	color: #ffffff;
	font-weight: normal;
	opacity: 0.7;
	margin-top: 0;
	margin-bottom: 3.2rem;
	line-height: 1.5;
}

@media screen and (min-width: 64em) {
	.page-header h2,
	.page-header .project-tagline {
		font-size: 2rem;
	}
}

@media screen and (min-width: 42em) and (max-width: 64em) {
	.page-header h2,
	.page-header .project-tagline {
		font-size: 1.84rem;
	}
}

@media screen and (max-width: 42em) {
	.page-header h2,
	.page-header .project-tagline {
		font-size: 1.6rem;
	}
}

.page-header .header-nav {
	margin-top: 0;
}

.btn,
.btn-banner {
	display: inline-block;
	margin-bottom: 1.6rem;
	color: rgba(255, 255, 255, 0.7);
	background-color: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 0.48rem;
	text-decoration: none;
	font-family: inherit;
	font-weight: normal;
	line-height: normal;
	transition: color 0.2s, background-color 0.2s, border-color 0.2s;
}

.btn:hover,
.btn-banner:hover {
	color: rgba(255, 255, 255, 0.8);
	text-decoration: none;
	background-color: rgba(255, 255, 255, 0.2);
	border-color: rgba(255, 255, 255, 0.3);
}

.btn + .btn,
.btn + .btn-banner,
.btn-banner + .btn,
.btn-banner + .btn-banner {
	margin-left: 1.6rem;
}

@media screen and (min-width: 64em) {
	.btn,
	.btn-banner {
		padding: 1.2rem 1.6rem;
		font-size: 1.6rem;
	}
}

@media screen and (min-width: 42em) and (max-width: 64em) {
	.btn,
	.btn-banner {
		padding: 0.96rem 1.44rem;
		font-size: 1.44rem;
	}
}

@media screen and (max-width: 42em) {
	.btn,
	.btn-banner {
		display: block;
		width: 100%;
		padding: 1.2rem;
		font-size: 1.44rem;
	}
	.btn + .btn,
	.btn + .btn-banner,
	.btn-banner + .btn,
	.btn-banner + .btn-banner {
		margin-top: 1.6rem;
		margin-left: 0;
	}
}

/* --- Layout Container --- */
.container,
.main-content {
	width: 100%;
	max-width: var(--container-max-width);
	margin-left: auto;
	margin-right: auto;
	word-wrap: break-word;
}

.container :first-child,
.main-content :first-child {
	margin-top: 0;
}

@media screen and (min-width: 64em) {
	.container,
	.main-content {
		padding: 3.2rem 9.6rem;
	}
}

@media screen and (min-width: 42em) and (max-width: 64em) {
	.container,
	.main-content {
		padding: 3.2rem 6.4rem;
	}
}

@media screen and (max-width: 42em) {
	.container,
	.main-content {
		padding: 3.2rem 1.6rem;
	}
}

/* --- Milligram-compatible Flex Grid --- */
.row {
	display: flex;
	flex-direction: column;
	margin-left: -1rem;
	margin-right: -1rem;
	width: calc(100% + 2rem);
}

.row .column {
	flex: 1 1 auto;
	padding-left: 1rem;
	padding-right: 1rem;
	margin-bottom: 1.5rem;
}

@media (min-width: 64rem) {
	.row {
		flex-direction: row;
	}
	.row .column-20 {
		flex: 0 0 20%;
		max-width: 20%;
	}
	.row .column-25 {
		flex: 0 0 25%;
		max-width: 25%;
	}
	.row .column-33,
	.row .column-34 {
		flex: 0 0 33.3333%;
		max-width: 33.3333%;
	}
	.row .column-50 {
		flex: 0 0 50%;
		max-width: 50%;
	}
	.row .column-66,
	.row .column-67 {
		flex: 0 0 66.6666%;
		max-width: 66.6666%;
	}
	.row .column-75 {
		flex: 0 0 75%;
		max-width: 75%;
	}
}

/* --- Cards & Panels --- */
.card {
	background-color: var(--color-card-bg);
	border: 1px solid var(--color-border);
	border-radius: var(--border-radius);
	padding: 2rem;
	margin: 2rem 0;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.card > :last-child,
.card > :last-child > :last-child {
	margin-bottom: 0;
}

.card h2,
.card h3 {
	margin-top: 0;
	margin-bottom: 1.2rem;
	padding-bottom: 0.6rem;
	border-bottom: 1px solid var(--color-border-light);
}

.card-title {
	font-size: 1.8rem;
	font-weight: 600;
	color: var(--color-primary);
	margin-top: 0;
	margin-bottom: 1rem;
}

/* --- Form Controls & Inputs --- */
input[type="text"],
input[type="search"],
input[type="url"],
input[type="number"],
input[type="email"],
select,
textarea {
	width: 100%;
	font-family: inherit;
	font-size: 1.4rem;
	color: var(--color-text);
	background-color: #ffffff;
	border: 1px solid #d1d5db;
	border-radius: 4px;
	padding: 0.8rem 1.2rem;
	margin-bottom: 1.2rem;
	box-sizing: border-box;
	transition:
		border-color var(--transition-speed),
		box-shadow var(--transition-speed);
}

input[type="text"],
input[type="search"],
input[type="url"],
input[type="number"],
input[type="email"] {
	height: 4.2rem;
	line-height: 4.2rem;
}

select {
	height: 4.2rem;
	line-height: 4.2rem;
	padding: 0 3.6rem 0 1.2rem;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23606c71' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 1.2rem center;
	background-size: 1.6rem 1.6rem;
}

textarea {
	font-family: var(--font-mono);
	font-size: 1.35rem;
	line-height: 1.5;
	min-height: 160px;
	resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
	border-color: var(--color-accent);
	outline: none;
	box-shadow: 0 0 0 3px rgba(14, 95, 142, 0.15);
}

label {
	display: block;
	font-size: 1.35rem;
	font-weight: 600;
	color: var(--color-text);
	margin-bottom: 0.5rem;
}

label.label-inline {
	display: inline-block;
	font-weight: 400;
	margin-left: 0.6rem;
	vertical-align: middle;
}

/* --- Buttons --- */
button,
.button,
input[type="submit"],
input[type="button"] {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 4.2rem;
	line-height: 4.2rem;
	box-sizing: border-box;
	font-family: var(--font-sans);
	font-size: 1.4rem;
	font-weight: 600;
	padding: 0 1.8rem;
	color: #ffffff;
	background-color: var(--color-primary);
	border: 1px solid var(--color-primary);
	border-radius: 4px;
	cursor: pointer;
	text-decoration: none;
	transition:
		background-color var(--transition-speed),
		border-color var(--transition-speed),
		transform var(--transition-speed);
	margin-bottom: 1rem;
}

/* --- Action & Toolbar Layout --- */
.toolbar {
	display: flex;
	flex-direction: column;
	gap: 1.2rem;
	margin-top: 1rem;
	margin-bottom: 1.2rem;
}

.toolbar-field {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
}

.toolbar-field label {
	margin-bottom: 0.5rem;
}

.toolbar-field select,
.toolbar-field input {
	margin-bottom: 0;
}

.toolbar-action {
	display: flex;
	align-items: flex-end;
}

.toolbar-action button,
.toolbar-action .button {
	width: 100%;
	margin-bottom: 0;
}

@media (min-width: 48rem) {
	.toolbar {
		flex-direction: row;
		align-items: flex-end;
	}
	.toolbar-action button,
	.toolbar-action .button {
		width: auto;
		white-space: nowrap;
	}
}

button:hover,
.button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
	background-color: var(--color-accent);
	border-color: var(--color-accent);
	color: #ffffff;
	text-decoration: none;
}

button:active,
.button:active,
input[type="submit"]:active {
	transform: translateY(1px);
}

.button-outline {
	color: var(--color-primary);
	background-color: transparent;
	border-color: var(--color-primary);
}

.button-outline:hover {
	color: #ffffff;
	background-color: var(--color-primary);
	border-color: var(--color-primary);
}

.button-sm {
	font-size: 1.25rem;
	padding: 0.45rem 1rem;
	margin-bottom: 0.5rem;
}

.preset-btn {
	font-size: 1.25rem;
	font-weight: 500;
	padding: 0.4rem 1rem;
	margin-right: 0.5rem;
	margin-bottom: 0.6rem;
	background-color: #ffffff;
	color: var(--color-accent);
	border: 1px solid #d1d5db;
	border-radius: 4px;
}

.preset-btn:hover {
	background-color: #f3f6fa;
	border-color: var(--color-accent);
	color: var(--color-primary);
}

.button-group {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem;
	margin-bottom: 1.2rem;
}

/* --- Inline Code & Code Blocks --- */
code,
kbd,
pre,
samp {
	font-family: var(--font-mono);
}

code {
	font-size: 0.9em;
	padding: 0.2rem 0.45rem;
	color: #567482;
	background-color: var(--color-code-bg);
	border-radius: 3px;
}

pre {
	background-color: var(--color-pre-bg);
	border: 1px solid var(--color-border);
	border-radius: var(--border-radius);
	padding: 1.2rem 1.6rem;
	overflow-x: auto;
	font-size: 1.35rem;
	line-height: 1.5;
	margin-top: 0;
	margin-bottom: 1.5rem;
}

pre code {
	padding: 0;
	background: transparent;
	border: none;
	font-size: inherit;
	color: inherit;
}

/* --- AST Tree & Output Panels --- */
#output,
#ast-output,
.ast-tree,
.output-panel {
	font-family: var(--font-mono);
	font-size: 1.3rem;
	line-height: 1.6;
	background-color: var(--color-pre-bg);
	border: 1px solid var(--color-border);
	border-radius: var(--border-radius);
	padding: 1.5rem;
	max-height: 520px;
	overflow-y: auto;
	white-space: pre-wrap;
	word-break: break-word;
}

#output > #ast-output {
	background: transparent;
	border: none;
	border-radius: 0;
	padding: 0;
	max-height: none;
	overflow: visible;
}

#output.error,
.output-panel.error {
	color: var(--color-error-text);
	background-color: var(--color-error-bg);
	border: 1px solid rgba(217, 83, 79, 0.3);
	border-left: 4px solid var(--color-error-border);
}

.node-type {
	color: var(--color-primary);
	font-weight: 600;
}

.node-prop {
	color: var(--color-text-muted);
}

.node-val {
	color: var(--color-accent);
}

.node-str {
	color: #c7254e;
}

/* --- Stats & Badges --- */
.stats {
	font-size: 1.35rem;
	color: var(--color-text-muted);
	margin-bottom: 1.2rem;
	line-height: 1.5;
}

.stats span {
	font-weight: 600;
	color: var(--color-accent);
}

.badge {
	display: inline-block;
	padding: 0.25rem 0.8rem;
	font-size: 1.2rem;
	font-weight: 600;
	border-radius: 12px;
	background-color: #e9ecef;
	color: var(--color-text);
	line-height: 1.2;
}

.badge-primary {
	background-color: rgba(0, 57, 98, 0.1);
	color: var(--color-primary);
}

.badge-success {
	background-color: rgba(21, 153, 87, 0.12);
	color: var(--color-success);
}

.badge-accent {
	background-color: rgba(14, 95, 142, 0.12);
	color: var(--color-accent);
}

/* --- Alerts & Errors --- */
.error,
.alert-error {
	color: var(--color-error-text);
	background-color: var(--color-error-bg);
	border: 1px solid rgba(217, 83, 79, 0.3);
	border-left: 4px solid var(--color-error-border);
	border-radius: 4px;
	padding: 1.2rem 1.6rem;
	margin-bottom: 1.5rem;
	font-family: var(--font-mono);
	font-size: 1.35rem;
	white-space: pre-wrap;
	word-break: break-word;
}

.alert-info {
	background-color: #f0f7fb;
	border: 1px solid #bee5eb;
	border-left: 4px solid var(--color-accent);
	color: #0c5460;
	border-radius: 4px;
	padding: 1.2rem 1.6rem;
	margin-bottom: 1.5rem;
	font-size: 1.35rem;
}

.alert-warning {
	background-color: #fff8e6;
	border: 1px solid #ffeeba;
	border-left: 4px solid #f39c12;
	color: #856404;
	border-radius: 4px;
	padding: 1.2rem 1.6rem;
	margin-bottom: 1.5rem;
	font-size: 1.35rem;
}

.hide-empty:empty {
	display: none;
}

/* --- Tab Navigation --- */
.tab-buttons {
	display: flex;
	gap: 0.4rem;
	border-bottom: 2px solid var(--color-border);
	margin-bottom: 1.5rem;
	overflow-x: auto;
}

.tab-button,
.tab-buttons > button {
	background: transparent;
	border: none;
	border-radius: 4px 4px 0 0;
	padding: 0.8rem 1.6rem;
	font-family: var(--font-sans);
	font-size: 1.35rem;
	font-weight: 600;
	color: var(--color-text-muted);
	cursor: pointer;
	margin-bottom: -2px;
	border-bottom: 2px solid transparent;
	transition: all var(--transition-speed);
}

.tab-button:hover,
.tab-buttons > button:hover {
	color: var(--color-primary);
	background: rgba(0, 57, 98, 0.04);
}

.tab-button.active,
.tab-buttons > button.active {
	color: var(--color-accent);
	border-bottom: 2px solid var(--color-accent);
	background: transparent;
}

.tab-body {
	display: none;
}

.tab-body.active {
	display: block;
}

/* --- Horizontal Rules --- */
hr {
	border: 0;
	border-top: 1px solid var(--color-border);
	margin: 1.2rem 0;
}

/* --- Tables --- */
table {
	width: 100%;
	border-collapse: collapse;
	margin-bottom: 1.8rem;
	font-size: 1.4rem;
	overflow-x: auto;
	display: block;
}

@media (min-width: 48rem) {
	table {
		display: table;
	}
}

th,
td {
	padding: 0.8rem 1.2rem;
	border: 1px solid var(--color-border);
	text-align: left;
}

th {
	background-color: #f6f8fa;
	font-weight: 600;
	color: var(--color-primary);
}

tbody tr:nth-child(even) {
	background-color: #fafbfc;
}

/* --- Markdown Body Content --- */
.markdown-body {
	font-size: 1.45rem;
	line-height: 1.65;
	color: var(--color-text);
}

.card.markdown-body {
	background-color: #f8fafc;
	border: 1px solid #e2e8f0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
	color: var(--color-primary);
	border-bottom: 1px solid var(--color-border-light);
	padding-bottom: 0.4rem;
}

.markdown-body ul,
.markdown-body ol {
	padding-left: 2rem;
	margin-top: 0;
	margin-bottom: 1.2rem;
}

.markdown-body li {
	margin-bottom: 0.4rem;
}

.markdown-body blockquote {
	margin: 1rem 0;
	padding: 0.6rem 1.2rem;
	color: var(--color-text-muted);
	border-left: 4px solid var(--color-code-border);
	background-color: #fafbfc;
	border-radius: 0 4px 4px 0;
}

.markdown-body pre {
	margin: 1rem 0;
}

/* --- Showcase Grid --- */
.showcase-section-title {
	font-size: 2.2rem;
	font-weight: 700;
	color: var(--color-primary);
	margin-top: 3.5rem;
	margin-bottom: 1.8rem;
	padding-bottom: 0.6rem;
	border-bottom: 2px solid var(--color-border-light);
}

.showcase-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
	gap: 2rem;
	margin-bottom: 3rem;
}

.showcase-card {
	background: var(--color-card-bg);
	border: 1px solid var(--color-border);
	border-radius: var(--border-radius);
	padding: 2rem;
	display: flex;
	flex-direction: column;
	transition:
		transform var(--transition-speed),
		box-shadow var(--transition-speed),
		border-color var(--transition-speed);
	cursor: pointer;
}

.showcase-card:hover {
	transform: translateY(-2px);
	border-color: var(--color-accent);
	box-shadow: 0 6px 16px rgba(0, 57, 98, 0.08);
}

.showcase-card-header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	margin-bottom: 0.8rem;
}

.showcase-card-title {
	font-size: 1.7rem;
	font-weight: 700;
	margin: 0;
	color: var(--color-primary);
}

.showcase-card-desc {
	font-size: 1.35rem;
	color: var(--color-text-muted);
	flex-grow: 1;
	margin-bottom: 1.4rem;
	line-height: 1.5;
}

.showcase-card-footer {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-top: auto;
	padding-top: 0.5rem;
}

.showcase-card-actions {
	display: flex;
	gap: 0.6rem;
}

/* --- Footer --- */
footer,
.site-footer {
	padding-top: 3.2rem;
	margin-top: 3.2rem;
	border-top: solid 1px #eff0f1;
	text-align: center;
	color: #819198;
	font-size: 1.44rem;
}

@media screen and (min-width: 42em) {
	footer,
	.site-footer {
		font-size: 1.6rem;
	}
}

.site-footer-owner {
	display: block;
	font-weight: bold;
}

.site-footer-credits {
	color: #819198;
}

footer a,
.site-footer a {
	color: var(--color-accent);
}

