/* Looking Glass — visual inspired by evo.digital (Titillium Web + Open Sans,
   navy/cream palette, "vibrante" gradient, pill buttons). No inline styles. */

@font-face { font-family: "Open Sans"; font-style: normal; font-weight: 300 800; font-display: swap; src: url("../fonts/open-sans-latin.woff2") format("woff2"); }
@font-face { font-family: "Titillium Web"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/titillium-web-600-latin.woff2") format("woff2"); }
@font-face { font-family: "Titillium Web"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/titillium-web-700-latin.woff2") format("woff2"); }

:root {
	--navy: #003da5;
	--navy-600: #00317f;
	--navy-900: #00235e;
	--blue-light: #0049c4;
	--text: #001a45;
	--text-muted: #4d5b78;
	--cream: #f1ede5;
	--cream-dark: #e6e0d4;
	--surface: #ffffff;
	--line: #dcd6ca;
	--cyan: #75bade;
	--cyan-50: #dff5fc;
	--orange: #f25a2c;
	--orange-dark: #d9481d;
	--magenta: #e12066;
	--green: #1a7f37;
	--red: #c8102e;
	--ink-canvas: #000a1c;
	--ink-surface: #021430;
	--ink-raised: #0a1f45;
	--ink-border: #1c3263;
	--ink-fg: #f3f6fc;
	--ink-muted: #a8b6d4;
	--gradient-vibrante: linear-gradient(90deg, #5b2d90 0%, #b8237e 35%, #e2245d 60%, #f25a2c 100%);
	--gradient-azul: linear-gradient(to top, #0049c4 0%, #00235e 60%);
	--radius: 20px;
	--radius-sm: 12px;
	--shadow: 0 1px 2px rgba(0, 26, 69, .06), 0 8px 24px rgba(0, 26, 69, .08);
	--font-body: "Open Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
	--font-head: "Titillium Web", "Segoe UI", system-ui, sans-serif;
	--font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}

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

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 88px; }

body {
	margin: 0;
	font: 400 16px/1.6 var(--font-body);
	color: var(--text);
	background: var(--cream);
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

main { flex: 1; }

a { color: var(--navy); text-underline-offset: 3px; }
a:hover { color: var(--orange-dark); }

h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.15; color: var(--text); margin: 0 0 .5em; }

code, pre { font-family: var(--font-mono); font-size: .9em; }

:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }

.muted { color: var(--text-muted); font-weight: 400; }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--navy); color: #fff; padding: 8px 16px; border-radius: 999px; }
.skip-link:focus { left: 16px; color: #fff; }

/* ---------------------------------------------------------------- header */

.site-header {
	position: sticky;
	top: 0;
	z-index: 50;
	background: rgba(255, 255, 255, .96);
	backdrop-filter: saturate(1.4) blur(8px);
	border-bottom: 1px solid rgba(0, 26, 69, .08);
}

.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 68px; }

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.brand-logo { height: 28px; width: auto; display: block; }
.brand-asn {
	font: 600 13px/1 var(--font-body);
	letter-spacing: .02em;
	padding: 6px 12px;
	border-radius: 999px;
	border: 1.5px solid var(--navy);
	color: var(--navy);
}

.main-nav { display: flex; gap: 4px; padding: 4px; border: 1.5px solid rgba(0, 61, 165, .25); border-radius: 999px; }
.main-nav a {
	font: 600 14px/1 var(--font-body);
	padding: 8px 16px;
	border-radius: 999px;
	color: var(--text);
	text-decoration: none;
	white-space: nowrap;
}
.main-nav a:hover { background: var(--cyan-50); color: var(--navy); }
.main-nav a.active { background: var(--navy); color: #fff; }

/* ------------------------------------------------------------------ hero */

.hero {
	background: var(--gradient-vibrante);
	color: #fff;
	padding: 56px 0 104px;
	position: relative;
	overflow: hidden;
}

.hero::after {
	content: "";
	position: absolute;
	right: -120px;
	top: -160px;
	width: 520px;
	height: 520px;
	border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, .18);
	box-shadow: 0 0 0 40px rgba(255, 255, 255, .05), 0 0 0 80px rgba(255, 255, 255, .04), 0 0 0 120px rgba(255, 255, 255, .03);
	pointer-events: none;
}

.hero h1 { color: #fff; font-size: clamp(32px, 5vw, 52px); font-weight: 600; letter-spacing: -.02em; margin-bottom: 12px; }
.hero .lead { font-size: 18px; max-width: 620px; margin: 0; opacity: .92; }

.eyebrow {
	font: 700 12px/1.2 var(--font-body);
	letter-spacing: .12em;
	text-transform: uppercase;
	margin: 0 0 12px;
	opacity: .9;
}

.page-main { margin-top: -64px; position: relative; padding-bottom: 64px; }

/* ----------------------------------------------------------------- cards */

.card {
	background: var(--surface);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 28px;
	margin-bottom: 24px;
}

/* ----------------------------------------------------------------- forms */

.field { margin: 0 0 20px; border: 0; padding: 0; min-width: 0; }
.field-label { display: block; font: 600 14px/1.3 var(--font-body); margin-bottom: 8px; padding: 0; }
.field-help { font-size: 13px; color: var(--text-muted); margin: 6px 0 0; min-height: 1.3em; }

input[type="text"], input[type="password"], input[type="search"], input[type="number"], select, textarea {
	width: 100%;
	font: 400 16px/1.4 var(--font-body);
	color: var(--text);
	background: #fff;
	border: 1.5px solid var(--line);
	border-radius: var(--radius-sm);
	padding: 12px 14px;
	transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 4px rgba(0, 61, 165, .12); }
input:disabled { background: var(--cream); color: var(--text-muted); }

select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--navy) 50%), linear-gradient(135deg, var(--navy) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }

#query { font-family: var(--font-mono); font-size: 17px; }

textarea { font: 400 14px/1.55 var(--font-mono); resize: vertical; min-height: 360px; }

.form-grid { display: grid; grid-template-columns: minmax(0, 2fr) auto minmax(0, 1.2fr); gap: 20px; align-items: start; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill input, .segmented input { position: absolute; opacity: 0; pointer-events: none; }
.pill span {
	display: inline-block;
	font: 600 14px/1 var(--font-body);
	padding: 11px 18px;
	border-radius: 999px;
	border: 1.5px solid var(--line);
	cursor: pointer;
	transition: all .15s;
	user-select: none;
}
.pill span:hover { border-color: var(--navy); color: var(--navy); }
.pill input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.pill input:focus-visible + span, .segmented input:focus-visible + span { outline: 3px solid var(--cyan); outline-offset: 2px; }

.segmented { display: inline-flex; padding: 4px; border: 1.5px solid var(--line); border-radius: 999px; background: #fff; }
.segmented span { display: inline-block; font: 600 14px/1 var(--font-body); padding: 11px 18px; border-radius: 999px; cursor: pointer; }
.segmented input:checked + span { background: var(--navy); color: #fff; }

.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; padding-top: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--navy); }

.form-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

/* --------------------------------------------------------------- buttons */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	font: 600 15px/1 var(--font-body);
	padding: 14px 26px;
	border-radius: 999px;
	border: 1.5px solid transparent;
	text-decoration: none;
	cursor: pointer;
	transition: background .15s, color .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); color: #fff; }
.btn-primary[disabled] { opacity: .7; cursor: progress; }
.btn-ghost { background: transparent; border-color: var(--navy); color: var(--navy); }
.btn-ghost:hover { background: var(--navy); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #a00d25; color: #fff; }
.btn-small { padding: 8px 16px; font-size: 13px; }
.btn-block { width: 100%; }

.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--navy); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------------------------------------------------------------- alerts */

.alert { border-radius: var(--radius-sm); padding: 14px 18px; margin-bottom: 20px; font-weight: 600; border-left: 5px solid; background: #fff; box-shadow: var(--shadow); }
.alert-error { border-color: var(--red); color: #8a0b20; }
.alert-ok { border-color: var(--green); color: #135d28; }

.badge { display: inline-block; font: 700 11px/1 var(--font-body); letter-spacing: .04em; text-transform: uppercase; padding: 5px 9px; border-radius: 999px; background: var(--cream); color: var(--text-muted); }
.badge-ok { background: #dcf3e2; color: #135d28; }
.badge-warn { background: #fde8de; color: #a3360f; }

/* --------------------------------------------------------------- results */

.result { padding: 0; overflow: hidden; }

.result-head { display: flex; flex-wrap: wrap; gap: 12px 32px; padding: 20px 28px; border-bottom: 1px solid var(--cream-dark); }
.result-label { display: block; font: 700 11px/1.2 var(--font-body); letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }
.result-command code { background: var(--cream); padding: 3px 8px; border-radius: 6px; }
.result-notice { margin: 0; padding: 12px 28px; background: var(--cyan-50); font-size: 14px; }

.terminal-wrap, .code-block { position: relative; }

.terminal {
	margin: 0;
	padding: 24px 28px;
	background: var(--ink-surface);
	color: var(--ink-fg);
	font: 400 13.5px/1.55 var(--font-mono);
	overflow-x: auto;
	white-space: pre;
	min-height: 120px;
	tab-size: 8;
}
.terminal a { color: var(--cyan); text-decoration: none; border-bottom: 1px dotted rgba(117, 186, 222, .5); }
.terminal a:hover { color: #fff; border-bottom-color: #fff; }
.terminal b { color: #fff; }
.terminal .error, .terminal p.error { color: #ff8a8a; margin: 8px 0 0; white-space: normal; font-family: var(--font-body); font-weight: 600; }
.terminal .lg-best { color: #7ee2a8; }
.terminal .lg-alt { color: #c3e88d; }

.community-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 2px 24px; margin: 4px 0 8px 48px; white-space: normal; }
.community-item { white-space: nowrap; }
.community-code { display: inline-block; min-width: 104px; font-weight: 700; color: #fff; }
.community-desc { color: var(--ink-muted); font-style: italic; }
.community-desc-noexport { color: #ff9d7a; font-style: normal; font-weight: 700; }

.copy-btn {
	position: absolute;
	top: 12px;
	right: 12px;
	font: 600 12px/1 var(--font-body);
	padding: 7px 12px;
	border-radius: 999px;
	border: 1px solid var(--ink-border);
	background: var(--ink-raised);
	color: var(--ink-fg);
	cursor: pointer;
	opacity: .85;
}
.copy-btn:hover { opacity: 1; border-color: var(--cyan); }

.graph { padding: 24px 28px; text-align: center; }
.graph-img { max-width: 100%; height: auto; background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--cream-dark); min-height: 120px; }
.graph-legend { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 24px; padding: 0; margin: 0 0 16px; font-size: 14px; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; border: 1px solid rgba(0, 0, 0, .15); }
.swatch-upstream { background: #ccccff; }
.swatch-peer { background: #ccffcc; }
.swatch-best { background: #e2245d; height: 4px; width: 28px; vertical-align: 3px; border: 0; }

/* ------------------------------------------------------------------ docs */

.docs-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 28px; align-items: start; margin-top: -64px; position: relative; padding-bottom: 64px; }

.docs-sidebar { position: sticky; top: 88px; max-height: calc(100vh - 104px); overflow: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.docs-nav ul { list-style: none; padding: 0; margin: 0 0 20px; }
.docs-nav li a { display: block; padding: 7px 12px; border-radius: 10px; text-decoration: none; color: var(--text); font-size: 14px; line-height: 1.35; }
.docs-nav li a:hover { background: var(--cream); }
.docs-nav li a.active { background: var(--navy); color: #fff; font-weight: 600; }
.docs-nav-title { font: 700 11px/1.2 var(--font-body); letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 8px 12px; }
.toc .toc-l3 a { padding-left: 24px; font-size: 13px; color: var(--text-muted); }

.docs-content { padding: 36px 44px; }
.docs-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.docs-filter { flex: 1 1 280px; max-width: 420px; }
.docs-filter input { border-radius: 999px; padding: 10px 18px; font-size: 14px; }
.docs-updated { font-size: 13px; color: var(--text-muted); }

.prose { font-size: 16px; }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: 30px; font-weight: 700; margin: 48px 0 16px; padding-top: 24px; border-top: 1px solid var(--cream-dark); }
.prose h3 { font-size: 22px; font-weight: 700; margin: 32px 0 12px; color: var(--navy); }
.prose h4 { font-size: 18px; font-weight: 700; margin: 28px 0 10px; }
.prose h2 .anchor, .prose h3 .anchor, .prose h4 .anchor { opacity: 0; text-decoration: none; color: var(--cyan); margin-left: 4px; font-weight: 600; }
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose h4:hover .anchor, .prose .anchor:focus { opacity: 1; }
.prose p, .prose ul, .prose ol { margin: 0 0 16px; }
.prose li { margin-bottom: 4px; }
.prose code { background: var(--cream); padding: 2px 6px; border-radius: 6px; }
.prose hr { border: 0; border-top: 1px solid var(--cream-dark); margin: 32px 0; }
.prose em { color: var(--text-muted); }

.prose .code-block pre { margin: 0 0 20px; padding: 20px 24px; background: var(--ink-surface); color: var(--ink-fg); border-radius: var(--radius-sm); overflow-x: auto; }
.prose .code-block code { background: none; padding: 0; }

.callout { margin: 0 0 20px; padding: 16px 20px; border-radius: var(--radius-sm); background: #fff4ee; border-left: 5px solid var(--orange); }
.callout p:last-child { margin-bottom: 0; }

.table-wrap { overflow-x: auto; margin: 0 0 24px; }
.prose table, .data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.prose table { border: 1px solid var(--cream-dark); border-radius: var(--radius-sm); overflow: hidden; }
.prose th, .prose td, .data-table th, .data-table td { text-align: left; padding: 10px 14px; vertical-align: top; border-bottom: 1px solid var(--cream-dark); }
.prose thead th, .data-table thead th { background: var(--navy); color: #fff; font-weight: 600; white-space: nowrap; }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody tr:nth-child(even) td { background: #faf8f4; }
.prose tbody tr:hover td { background: var(--cyan-50); }
.prose tr.group th { background: var(--cream); color: var(--navy); font: 700 12px/1.2 var(--font-body); letter-spacing: .08em; text-transform: uppercase; padding: 10px 14px; }
.prose td:first-child { white-space: nowrap; font-family: var(--font-mono); font-size: 13px; }
.prose td:first-child strong { color: var(--navy); }
.prose .align-center { text-align: center; }
.prose .align-right { text-align: right; }
.prose table tr.filtered-out { display: none; }

/* ----------------------------------------------------------------- admin */

.admin-main { margin-top: 32px; }
.admin-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.admin-nav { display: flex; flex-wrap: wrap; gap: 4px; }
.admin-nav a { padding: 8px 14px; border-radius: 999px; text-decoration: none; font-weight: 600; font-size: 14px; }
.admin-nav a:hover { background: #fff; }
.admin-user { font-size: 14px; color: var(--text-muted); margin-right: 8px; }
.admin-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.admin-head h2 { margin: 0; font-size: 28px; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; margin: 0; }
.inline-form input[type="search"] { width: 240px; padding: 8px 14px; border-radius: 999px; font-size: 14px; }

.data-table td { background: #fff; }
.data-table.compact td, .data-table.compact th { padding: 7px 12px; font-size: 13px; }
.data-table thead th:first-child { border-top-left-radius: var(--radius-sm); }
.data-table thead th:last-child { border-top-right-radius: var(--radius-sm); }
.row-actions { white-space: nowrap; }
.row-actions a, .row-actions .inline-form { margin-right: 12px; }

.card.table-wrap { padding: 0; }

.auth-card { max-width: 440px; margin: 24px auto; }
.auth-card h2 { font-size: 28px; }

.editor-meta { grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) 110px 130px; }
.md-help { margin-top: 10px; font-size: 14px; }
.md-help summary { cursor: pointer; font-weight: 600; color: var(--navy); }
.md-help pre { background: var(--cream); padding: 14px; border-radius: var(--radius-sm); overflow-x: auto; font-size: 12.5px; }
.preview { border: 2px dashed var(--cyan); }

.danger-zone { display: flex; gap: 16px; align-items: center; justify-content: space-between; border: 1.5px solid #f3c2ca; }
.danger-zone p { margin: 4px 0 0; }

/* ---------------------------------------------------------------- footer */

.site-footer { background: var(--gradient-azul); color: #dbe5ff; padding: 40px 0 32px; margin-top: auto; }
.footer-inner { display: grid; grid-template-columns: auto 1fr; gap: 16px 40px; align-items: center; }
.footer-brand strong { display: block; font: 700 22px/1.1 var(--font-head); color: #fff; }
.footer-brand span { font-size: 14px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.footer-links a { color: #fff; text-decoration: none; font-weight: 600; font-size: 14px; padding: 8px 16px; border: 1.5px solid rgba(255, 255, 255, .35); border-radius: 999px; }
.footer-links a:hover { background: #fff; color: var(--navy); }
.footer-note { grid-column: 1 / -1; margin: 8px 0 0; font-size: 12.5px; color: #a8b6d4; border-top: 1px solid rgba(255, 255, 255, .12); padding-top: 16px; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 960px) {
	.form-grid, .editor-meta { grid-template-columns: 1fr 1fr; }
	.field-query { grid-column: 1 / -1; }
	.docs-layout { grid-template-columns: 1fr; }
	.docs-sidebar { position: static; max-height: none; }
	.docs-content { padding: 28px 24px; }
}

@media (max-width: 640px) {
	.container { padding: 0 16px; }
	.header-inner { flex-wrap: wrap; padding: 10px 0; gap: 10px; }
	.brand-asn { display: none; }
	.main-nav a { padding: 8px 12px; font-size: 13px; }
	.hero { padding: 36px 0 88px; }
	.card { padding: 20px; }
	.form-grid, .editor-meta { grid-template-columns: 1fr; }
	.result-head, .terminal, .graph { padding-left: 16px; padding-right: 16px; }
	.community-grid { margin-left: 16px; grid-template-columns: 1fr; }
	.footer-inner { grid-template-columns: 1fr; }
	.footer-links { justify-content: flex-start; }
	.form-actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
	* { transition: none !important; scroll-behavior: auto !important; }
}

@media print {
	.site-header, .site-footer, .docs-sidebar, .docs-tools, .copy-btn, .lg-form { display: none; }
	.hero { background: none; color: var(--text); padding: 0; }
	.hero h1 { color: var(--text); }
	.docs-layout, .page-main { margin: 0; display: block; }
	.card { box-shadow: none; }
}

/* --------------------------------------------------------------- loading */

@keyframes lg-spin { to { transform: rotate(360deg); } }
@keyframes lg-slide { from { background-position: 200% 0; } to { background-position: 0 0; } }
@keyframes lg-blink { 50% { opacity: 0; } }

.spinner {
	display: inline-block;
	width: 15px;
	height: 15px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: lg-spin .7s linear infinite;
	flex: none;
}

.btn.is-loading { cursor: progress; }

/* Bar under the header while the next page is loading */
.site-header::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: -3px;
	height: 3px;
	background: var(--gradient-vibrante);
	background-size: 200% 100%;
	opacity: 0;
	transition: opacity .2s;
	pointer-events: none;
}
body.is-navigating .site-header::after { opacity: 1; animation: lg-slide 1.1s linear infinite; }

/* Result card while the router is answering */
.result-progress { height: 3px; background: var(--gradient-vibrante); background-size: 200% 100%; visibility: hidden; }
.result.is-running .result-progress { visibility: visible; animation: lg-slide 1.1s linear infinite; }

.result-status { margin-left: auto; align-self: center; display: inline-flex; align-items: center; gap: 8px; font: 600 13px/1 var(--font-body); padding: 8px 14px; border-radius: 999px; background: var(--cyan-50); color: var(--navy); white-space: nowrap; }
.result:not(.is-running) .result-status .spinner { display: none; }
.result-status.is-done { background: #dcf3e2; color: #135d28; }
.result-status.is-warning { background: #fde8de; color: #a3360f; }

.result.is-running .terminal code::after { content: "▋"; color: var(--cyan); animation: lg-blink 1s steps(1) infinite; }

.graph-img { transition: opacity .2s; }
.result.is-running .graph-img { opacity: .35; }

@media (prefers-reduced-motion: reduce) {
	.spinner, body.is-navigating .site-header::after, .result.is-running .result-progress { animation-duration: 3s; }
	.result.is-running .terminal code::after { animation: none; }
}
