/*
 * mod_netcamp_cheatsheets — Stylesheet
 * ---------------------------------------------------------------
 * Same design language as mod_netcamp_templates / mod_huawei_trainings:
 * white cards, soft shadows, rounded corners, brand blue (#2957aa) as
 * the single accent, system sans-serif font stack.
 */

.nch-module {
	--nch-primary: #2957aa;
	--nch-primary-dark: #1f4382;
	--nch-primary-soft: rgba(41, 87, 170, 0.08);
	--nch-bg-surface: #ffffff;
	--nch-bg-surface-raised: #f4f6fa;
	--nch-border: #e1e6ed;
	--nch-text: #1c2533;
	--nch-text-dim: #69748a;
	--nch-ok: #1ea672;
	--nch-warn: #d18a1c;
	--nch-radius: 12px;
	--nch-font-body: -apple-system, 'Segoe UI', Roboto, system-ui, Helvetica, Arial, sans-serif;

	color: var(--nch-text);
	font-family: var(--nch-font-body);
	-webkit-font-smoothing: antialiased;
}

.nch-module * {
	box-sizing: border-box;
}

.nch-module a {
	color: inherit;
	text-decoration: none;
}

/* ---------------------------------------------------------------
   Toolbar
   --------------------------------------------------------------- */

.nch-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem;
	align-items: center;
	background: var(--nch-bg-surface-raised);
	border: 1px solid var(--nch-border);
	border-radius: var(--nch-radius);
	padding: 0.85rem 1rem;
	margin-bottom: 1.5rem;
}

.nch-toolbar label {
	font-size: 0.82rem;
	color: var(--nch-text-dim);
}

.nch-toolbar select {
	background: var(--nch-bg-surface);
	border: 1px solid var(--nch-border);
	color: var(--nch-text);
	border-radius: 8px;
	padding: 0.5rem 0.6rem;
	font-size: 0.85rem;
	font-family: inherit;
	min-width: 160px;
}

.nch-toolbar select:focus {
	border-color: var(--nch-primary);
	outline: none;
}

.nch-toolbar noscript button {
	background: transparent;
	border: 1px solid var(--nch-border);
	color: var(--nch-text-dim);
	border-radius: 8px;
	padding: 0.5rem 0.85rem;
	font-size: 0.82rem;
	font-weight: 600;
	cursor: pointer;
	font-family: inherit;
}

.nch-toolbar__reset {
	background: transparent;
	border: 1px solid var(--nch-border);
	color: var(--nch-text-dim);
	border-radius: 8px;
	padding: 0.5rem 0.85rem;
	font-size: 0.82rem;
	font-weight: 600;
	transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.nch-toolbar__reset:hover {
	border-color: var(--nch-primary);
	color: var(--nch-primary);
	background: var(--nch-primary-soft);
}

/* ---------------------------------------------------------------
   Grid
   --------------------------------------------------------------- */

.nch-grid {
	display: grid;
	gap: 1.25rem;
	grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 640px) {
	.nch-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.nch-cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.nch-cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 980px) {
	.nch-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.nch-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.nch-empty {
	color: var(--nch-text-dim);
	background: var(--nch-bg-surface-raised);
	border: 1px dashed var(--nch-border);
	border-radius: var(--nch-radius);
	padding: 2rem;
	text-align: center;
}

/* ---------------------------------------------------------------
   Card
   --------------------------------------------------------------- */

.nch-card {
	position: relative;
	display: flex;
	flex-direction: column;
	background: var(--nch-bg-surface);
	border: 1px solid var(--nch-border);
	border-radius: var(--nch-radius);
	overflow: hidden;
	box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
	transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.nch-card:hover {
	transform: translateY(-3px);
	border-color: var(--nch-primary);
	box-shadow: 0 14px 28px -16px rgba(16, 24, 40, 0.22);
}

.nch-card__strip {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	z-index: 1;
}

.nch-card__strip.is-ok { background: var(--nch-ok); }
.nch-card__strip.is-warn { background: var(--nch-warn); }

.nch-card__media {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: var(--nch-bg-surface-raised);
	border: none;
	padding: 0;
	margin: 0;
	cursor: pointer;
	font-family: inherit;
}

.nch-card__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.4s ease;
}

.nch-card:hover .nch-card__media img {
	transform: scale(1.04);
}

.nch-card__media-fallback {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	width: 100%;
	height: 100%;
	color: var(--nch-primary);
}

.nch-card__media-fallback svg {
	width: 38px;
	height: 38px;
}

.nch-card__media-fallback span {
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	color: var(--nch-text-dim);
}

.nch-card__media-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	font-size: 0.82rem;
	font-weight: 600;
	color: #fff;
	background: rgba(15, 23, 42, 0.55);
	opacity: 0;
	transition: opacity 0.18s ease;
}

.nch-card__media-overlay svg {
	width: 17px;
	height: 17px;
}

.nch-card:hover .nch-card__media-overlay,
.nch-card__media:focus-visible .nch-card__media-overlay {
	opacity: 1;
}

.nch-card__body {
	display: flex;
	flex-direction: column;
	gap: 0.55rem;
	padding: 1.1rem 1.2rem 1.3rem;
	flex: 1;
}

.nch-card__badges {
	display: flex;
	gap: 0.4rem;
	flex-wrap: wrap;
}

.nch-badge {
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.03em;
	padding: 0.22rem 0.55rem;
	border-radius: 100px;
	border: 1px solid var(--nch-border);
	color: var(--nch-text-dim);
	background: var(--nch-bg-surface-raised);
}

.nch-badge--category {
	color: var(--nch-primary);
	border-color: var(--nch-primary-soft);
	background: var(--nch-primary-soft);
}

.nch-badge--ok {
	color: var(--nch-ok);
	border-color: rgba(30, 166, 114, 0.25);
	background: rgba(30, 166, 114, 0.1);
}

.nch-badge--warn {
	color: var(--nch-warn);
	border-color: rgba(209, 138, 28, 0.25);
	background: rgba(209, 138, 28, 0.1);
}

.nch-card__title {
	font-size: 1.05rem;
	font-weight: 700;
	line-height: 1.35;
	margin: 0;
	color: var(--nch-text);
}

.nch-card__excerpt {
	font-size: 0.86rem;
	color: var(--nch-text-dim);
	line-height: 1.5;
	margin: 0;
	flex-grow: 1;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.nch-card__excerpt p {
	margin: 0 0 0.4rem;
}

.nch-card__excerpt p:last-child {
	margin-bottom: 0;
}

.nch-card__excerpt strong {
	color: var(--nch-text);
	font-weight: 700;
}

.nch-card__meta {
	font-size: 0.78rem;
	color: var(--nch-text-dim);
	margin: 0;
}

.nch-card__footer {
	margin-top: auto;
	padding-top: 0.7rem;
	display: flex;
	align-items: center;
	border-top: 1px solid var(--nch-border);
}

/* ---------------------------------------------------------------
   Buttons
   --------------------------------------------------------------- */

.nch-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	font-size: 0.8rem;
	font-weight: 600;
	padding: 0.55rem 0.9rem;
	border-radius: 8px;
	white-space: nowrap;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.nch-btn svg {
	width: 15px;
	height: 15px;
	flex-shrink: 0;
}

.nch-module .nch-btn--primary {
	background: var(--nch-primary);
	color: #fff;
}

.nch-module .nch-btn--primary:hover {
	background: var(--nch-primary-dark);
	color: #fff;
}

.nch-module .nch-btn--locked {
	border: 1px solid rgba(209, 138, 28, 0.3);
	color: var(--nch-warn);
	background: rgba(209, 138, 28, 0.1);
}

.nch-module .nch-btn--locked:hover {
	background: rgba(209, 138, 28, 0.18);
}

.nch-btn--lg { font-size: 0.92rem; padding: 0.7rem 1.3rem; }
.nch-btn--block { display: flex; width: 100%; }

.nch-card__unavailable {
	font-size: 0.8rem;
	color: var(--nch-text-dim);
	font-style: italic;
}

/* ---------------------------------------------------------------
   Lightbox / preview modal
   --------------------------------------------------------------- */

.nch-lightbox {
	position: fixed;
	inset: 0;
	z-index: 2000;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 1.5rem;
}

/*
 * Visibility is controlled exclusively via this class, not via the
 * [hidden] attribute. Reason: a plain, unconditional author rule
 * elsewhere (e.g. ".nch-btn { display: inline-flex }" further down in
 * this very file, or any rule on the site styling "img"/"a" broadly)
 * always wins over the browser's own "[hidden] { display: none }"
 * default - that default lives in the lowest-priority "user agent"
 * cascade layer, so ANY normal author rule overrides it regardless of
 * selector specificity. That mismatch was the actual bug behind
 * "bigger image doesn't show on click" in v1.0.1: the inner <img> kept
 * being forced to display:block by .nch-lightbox__media img below,
 * no matter what the JS did with .hidden. Class + inline styles don't
 * have that problem, because they're either higher specificity (class
 * on this very element) or set directly via .style (always wins short
 * of an !important rule).
 */
.nch-lightbox.is-open {
	display: flex;
}

.nch-lightbox__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.72);
}

.nch-lightbox__panel {
	position: relative;
	background: var(--nch-bg-surface);
	border-radius: var(--nch-radius);
	box-shadow: 0 30px 60px -20px rgba(16, 24, 40, 0.45);
	max-width: 560px;
	width: 100%;
	max-height: 90vh;
	overflow: auto;
	z-index: 1;
}

.nch-lightbox__close {
	position: absolute;
	top: 0.7rem;
	right: 0.7rem;
	width: 32px;
	height: 32px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--nch-bg-surface);
	border: 1px solid var(--nch-border);
	border-radius: 100px;
	color: var(--nch-text-dim);
	cursor: pointer;
	z-index: 2;
}

.nch-lightbox__close:hover {
	color: var(--nch-primary);
	border-color: var(--nch-primary);
}

.nch-lightbox__close svg {
	width: 16px;
	height: 16px;
}

.nch-lightbox__media {
	background: var(--nch-bg-surface-raised);
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 160px;
}

.nch-lightbox__media img {
	width: 100%;
	display: block;
}

.nch-lightbox__footer {
	padding: 1.2rem 1.4rem 1.4rem;
	display: flex;
	flex-direction: column;
	gap: 0.8rem;
}

.nch-lightbox__footer h3 {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--nch-text);
}

.nch-lightbox__desc {
	font-size: 0.9rem;
	line-height: 1.65;
	color: var(--nch-text-dim);
}

.nch-lightbox__desc p {
	margin: 0 0 0.6rem;
}

.nch-lightbox__desc p:last-child {
	margin-bottom: 0;
}

.nch-lightbox__desc ul,
.nch-lightbox__desc ol {
	margin: 0 0 0.6rem;
	padding-left: 1.15rem;
}

.nch-lightbox__desc strong {
	color: var(--nch-text);
	font-weight: 700;
}

.nch-lightbox__desc a {
	color: var(--nch-primary);
	text-decoration: underline;
}

body.nch-lightbox-open {
	overflow: hidden;
}

/* ---------------------------------------------------------------
   Accessibility / motion
   --------------------------------------------------------------- */

.nch-module a:focus-visible,
.nch-module button:focus-visible,
.nch-module select:focus-visible {
	outline: 2px solid var(--nch-primary);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.nch-card,
	.nch-card__media img,
	.nch-card__media-overlay {
		transition: none !important;
	}
	.nch-card:hover {
		transform: none;
	}
}
