/* ========== NAV PAGE — index cards in a desk tray ========== */
/* Shares the notebook-desk design tokens from sayori.org */

:root {
	--desk: #a8d4e6;
	--desk-mid: #9ccadd;
	--desk-dark: #82b8cf;
	--paper: #fdfcf7;
	--paper-edge: #f5f2e8;
	--line: #dcd9cc;
	--red-line: #d97070;
	--ink: #2a2a2a;
	--pencil: #7d7d7d;
	--pencil-light: #b3b3b3;
	--pink: #ffb7c5;
	--pink-deep: #ff8aa3;
	--accent-blue: #6ba9c4;
	--shadow: rgba(40, 50, 60, 0.18);
	--surface-font: 'Comic Neue', 'LXGW WenKai GB Screen', 'Microsoft YaHei', 'PingFang SC', 'Noto Sans SC', 'Source Han Sans SC', 'Hiragino Sans GB', 'WenQuanYi Micro Hei', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	--mono-font: 'JetBrains Mono', Consolas, monospace;
	--tray: rgba(240, 234, 216, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; min-height: 100%; }

body {
	font-family: var(--surface-font);
	font-size: 15px;
	font-weight: 400;
	line-height: 1.55;
	color: var(--ink);
	background: var(--desk);
	background-image:
		radial-gradient(circle at 20% 30%, rgba(255,255,255,0.18), transparent 40%),
		radial-gradient(circle at 80% 70%, rgba(0,30,60,0.08), transparent 50%),
		repeating-linear-gradient(0deg, transparent 0 3px, rgba(255,255,255,0.04) 3px 4px),
		repeating-linear-gradient(90deg, transparent 0 3px, rgba(0,0,0,0.025) 3px 4px),
		linear-gradient(160deg, #b4dced 0%, #92c4d8 55%, #a8d4e6 100%);
	background-attachment: fixed;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; border: none; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; color: inherit; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

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

.nav-header {
	position: sticky;
	top: 0;
	z-index: 40;
	padding: 0.7rem clamp(0.9rem, 3vw, 2rem);
	background: rgba(168, 212, 230, 0.9);
	backdrop-filter: blur(10px);
	border-bottom: 1px dashed rgba(255,255,255,0.5);
	box-shadow: 0 4px 18px rgba(40,50,60,0.12);
}
.nav-header-inner {
	max-width: 1200px;
	margin: 0 auto;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.6rem 1rem;
}
.nav-brand {
	font-size: 1.15rem;
	font-weight: 700;
	color: #315d70;
	white-space: nowrap;
}
.nav-brand small {
	font-weight: 500;
	color: rgba(49,93,112,0.6);
	font-size: 0.8rem;
	margin-left: 0.45rem;
}
.nav-search-wrap {
	flex: 1 1 220px;
	position: relative;
	max-width: 380px;
}
.nav-search {
	width: 100%;
	padding: 0.42rem 0.85rem 0.42rem 2rem;
	border: 1px solid rgba(217,112,112,0.5);
	border-radius: 999px;
	background: rgba(255,253,248,0.95);
	font: inherit;
	font-size: 0.9rem;
	color: var(--ink);
	outline: none;
	transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.nav-search:focus {
	border-color: var(--red-line);
	box-shadow: 0 0 0 3px rgba(217,112,112,0.18);
}
.nav-search-wrap::before {
	content: '🔍';
	position: absolute;
	left: 0.65rem;
	top: 50%;
	transform: translateY(-50%);
	font-size: 0.75rem;
	opacity: 0.55;
	pointer-events: none;
}
.nav-count {
	font-size: 0.82rem;
	color: rgba(49,93,112,0.75);
	white-space: nowrap;
}
.nav-home-link {
	font-size: 0.85rem;
	font-weight: 700;
	color: var(--red-line);
	padding: 0.3rem 0.7rem;
	border: 1px solid rgba(217,112,112,0.55);
	border-radius: 999px;
	background: rgba(255,253,248,0.9);
	transition: background 0.18s ease, transform 0.18s ease;
	white-space: nowrap;
}
.nav-home-link:hover { background: rgba(255,238,242,0.95); transform: translateY(-1px); }

/* category chips */
.nav-chips {
	max-width: 1200px;
	margin: 0.55rem auto 0;
	display: flex;
	gap: 0.4rem;
	overflow-x: auto;
	padding-bottom: 0.2rem;
	scrollbar-width: thin;
}
.nav-chip {
	flex: 0 0 auto;
	padding: 0.22rem 0.66rem;
	font-size: 0.82rem;
	font-weight: 600;
	color: #476b7a;
	background: rgba(255,253,248,0.75);
	border: 1px solid rgba(107,169,196,0.45);
	border-radius: 999px;
	transition: background 0.16s ease, transform 0.16s ease;
}
.nav-chip:hover { background: rgba(255,255,255,0.95); transform: translateY(-1px); }

/* ---------- page body ---------- */

.nav-body {
	max-width: 1200px;
	margin: 0 auto;
	padding: 1.2rem clamp(0.9rem, 3vw, 2rem) 5rem;
}

.nav-hero {
	position: relative;
	margin: 0.6rem 0 1.4rem;
	padding: clamp(1.1rem, 2.5vw, 1.6rem) clamp(1.2rem, 3vw, 2rem);
	background:
		linear-gradient(90deg, rgba(217,112,112,0.3) 0 2px, transparent 2px 100%),
		linear-gradient(135deg, #fffdf8 0%, #f9f4e3 100%);
	background-position: clamp(1.2rem, 3vw, 2rem) 0, 0 0;
	border-radius: 3px 7px 4px 6px;
	box-shadow: 0 18px 40px rgba(40,50,60,0.22);
	transform: rotate(-0.4deg);
}
.nav-hero::before {
	content: '';
	position: absolute;
	top: -0.7rem;
	left: 50%;
	width: 8rem;
	height: 1.6rem;
	background: linear-gradient(90deg, rgba(255,240,200,0.2), rgba(255,240,200,0.75), rgba(255,240,200,0.24));
	box-shadow: 0 2px 4px rgba(0,0,0,0.1);
	transform: translateX(-50%) rotate(-1.8deg);
}
.nav-hero h1 {
	font-size: clamp(1.4rem, 3.4vw, 1.8rem);
	font-weight: 600;
	color: #315d70;
	margin-bottom: 0.3rem;
}
.nav-hero p {
	font-size: 0.92rem;
	color: rgba(42,42,42,0.72);
	max-width: 46em;
}

/* ---------- featured (⭐ 常用推荐) ---------- */

.featured {
	margin-bottom: 1.6rem;
	padding: 1rem clamp(0.9rem, 2vw, 1.3rem);
	background:
		linear-gradient(135deg, rgba(255,246,228,0.92), rgba(255,250,238,0.92));
	border: 1px dashed rgba(217,112,112,0.45);
	border-radius: 6px 9px 7px 10px;
	box-shadow: 0 12px 28px rgba(40,50,60,0.14);
}
.featured > h2 {
	font-size: 1.05rem;
	color: var(--red-line);
	font-weight: 700;
	margin-bottom: 0.6rem;
}
.featured .card-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

/* ---------- category sections ---------- */

.cat-section {
	margin-bottom: 1.9rem;
}
.cat-head {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 0.5rem 0.7rem;
	margin-bottom: 0.7rem;
	padding: 0.5rem 0.9rem 0.45rem;
	background: linear-gradient(135deg, #fffdf8 0%, #f9f4e3 100%);
	border-radius: 3px 7px 4px 6px;
	box-shadow: 0 8px 20px rgba(40,50,60,0.14);
	position: relative;
	width: fit-content;
	max-width: 100%;
	transform: rotate(-0.3deg);
}
.cat-head::before {
	content: '';
	position: absolute;
	top: -0.5rem;
	left: 1.6rem;
	width: 4.5rem;
	height: 1.1rem;
	background: linear-gradient(90deg, rgba(255,240,200,0.25), rgba(255,240,200,0.7), rgba(255,240,200,0.28));
	transform: rotate(-2.4deg);
	box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.cat-num {
	font-family: var(--mono-font);
	font-size: 0.95rem;
	font-weight: 700;
	color: var(--red-line);
}
.cat-icon { font-size: 1.05rem; }
.cat-name {
	font-size: 1.18rem;
	font-weight: 700;
	color: #315d70;
}
.cat-desc {
	font-size: 0.83rem;
	color: var(--pencil);
}
.cat-count {
	margin-left: auto;
	font-size: 0.78rem;
	color: rgba(71,107,122,0.7);
	font-weight: 600;
}

/* ---------- card grid ---------- */

.card-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
	gap: 0.75rem;
}

.nav-card {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 0.28rem;
	padding: 0.75rem 0.85rem 0.7rem;
	background:
		repeating-linear-gradient(180deg, transparent 0 25px, rgba(220,217,204,0.55) 25px 26px),
		linear-gradient(135deg, #fffdf8 0%, #faf5e6 100%);
	border: 1px solid rgba(126,104,81,0.16);
	border-radius: 4px 7px 5px 8px;
	box-shadow: 0 6px 16px rgba(40,50,60,0.1);
	transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.nav-card:hover {
	transform: translateY(-3px) rotate(-0.2deg);
	box-shadow: 0 12px 26px rgba(40,50,60,0.16);
	border-color: rgba(107,169,196,0.5);
}
.nav-card-top {
	display: flex;
	align-items: baseline;
	gap: 0.35rem;
	min-width: 0;
}
.nav-card-name {
	font-size: 0.98rem;
	font-weight: 700;
	color: #315d70;
	line-height: 1.35;
	overflow-wrap: anywhere;
}
.nav-card:hover .nav-card-name { color: var(--red-line); }
.tier-badge { flex: 0 0 auto; font-size: 0.85rem; }
.new-badge {
	flex: 0 0 auto;
	font-size: 0.68rem;
	font-weight: 700;
	color: #fff;
	background: var(--red-line);
	border-radius: 999px;
	padding: 0.05rem 0.42rem;
	transform: translateY(-1px);
}
.nav-card-desc {
	font-size: 0.84rem;
	line-height: 1.55;
	color: rgba(42,42,42,0.78);
}
.nav-card-domain {
	margin-top: auto;
	font-family: var(--mono-font);
	font-size: 0.72rem;
	color: var(--pencil-light);
	overflow-wrap: anywhere;
}
.nav-card details {
	font-size: 0.8rem;
	color: rgba(42,42,42,0.66);
}
.nav-card details > summary {
	cursor: pointer;
	font-size: 0.78rem;
	font-weight: 600;
	color: var(--accent-blue);
	padding-left: 0.9rem;
	position: relative;
}
.nav-card details > summary::before {
	content: '▸';
	position: absolute;
	left: 0;
	transition: transform 0.15s ease;
}
.nav-card details[open] > summary::before { transform: rotate(90deg); }
.nav-card details p {
	margin: 0.3rem 0 0.15rem;
	padding-left: 0.9rem;
	border-left: 2px dashed rgba(107,169,196,0.4);
}
.nav-card details p + p { margin-top: 0.15rem; }
.nav-card .field-label {
	font-weight: 700;
	color: rgba(49,93,112,0.85);
}

/* hidden by search */
.nav-card[hidden], .cat-section[hidden] { display: none; }

.no-results {
	display: none;
	text-align: center;
	padding: 2.5rem 1rem;
	font-size: 0.95rem;
	color: var(--pencil);
}
.no-results.is-visible { display: block; }

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

.nav-footer {
	max-width: 1200px;
	margin: 0 auto;
	padding: 0 2rem 2.4rem;
	text-align: center;
	font-size: 0.82rem;
	color: rgba(42,42,42,0.62);
}
.nav-footer .foot-note {
	display: inline-block;
	padding: 0.5rem 1.1rem;
	background: rgba(255,253,248,0.7);
	border-radius: 999px;
	border: 1px dashed rgba(126,104,81,0.3);
}
.nav-footer a { color: var(--red-line); font-weight: 600; }

.back-to-top {
	position: fixed;
	right: 1.1rem;
	bottom: 1.1rem;
	z-index: 40;
	width: 2.5rem;
	height: 2.5rem;
	border-radius: 50%;
	background: rgba(255,253,248,0.94);
	border: 1px solid rgba(217,112,112,0.55);
	color: var(--red-line);
	font-size: 1.1rem;
	font-weight: 700;
	box-shadow: 0 6px 18px rgba(40,50,60,0.2);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
}
.back-to-top.is-visible { opacity: 1; pointer-events: auto; }
.back-to-top:hover { transform: translateY(-2px); }

/* ---------- responsive & motion ---------- */

@media (max-width: 640px) {
	.card-grid { grid-template-columns: 1fr; }
	.featured .card-grid { grid-template-columns: 1fr; }
	.nav-count { display: none; }
	.nav-hero { transform: none; }
	.cat-head { width: 100%; }
	.cat-count { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
	.nav-card, .nav-chip, .nav-home-link, .back-to-top { transition: none; }
	.nav-card:hover { transform: none; }
}
