/* Noise Media Gallery 2.0 - minimal, WordPress-native look.
   Inherits the theme's fonts and colours; everything is scoped to .nmg-*. */

.nmg-root {
	--nmg-accent: #2271b1;
	--nmg-accent-dark: #135e96;
	--nmg-ink: #1d2327;
	--nmg-muted: #50575e;
	--nmg-line: #dcdcde;
	--nmg-soft: #f6f7f7;
	color: var(--nmg-ink);
	margin: 1.5rem 0;
	font-size: 1rem;
	line-height: 1.5;
}
.nmg-root *, .nmg-root *::before, .nmg-root *::after,
.nmg-lb *, .nmg-lb *::before, .nmg-lb *::after { box-sizing: border-box; }

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

/* ---------- Header: plain, no background ---------- */
.nmg-header { margin: 0 0 1.5rem; }
.nmg-h { margin: 0 0 .25rem; font-size: 1.6rem; line-height: 1.25; font-weight: 600; color: inherit; }
.nmg-sub { margin: 0 0 1rem; max-width: 46rem; color: var(--nmg-muted); }

.nmg-tools { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 .9rem; }
.nmg-search { position: relative; flex: 1 1 260px; display: flex; align-items: center; }
.nmg-search svg { position: absolute; left: 10px; top: 50%; margin-top: -10px; color: #787c82; pointer-events: none; }
/* High specificity so theme input styles cannot push the text under the icon. */
.nmg-root .nmg-search input[type="search"] {
	width: 100%; height: 40px; min-height: 40px; margin: 0;
	padding: 0 36px 0 38px !important;
	border: 1px solid #8c8f94; border-radius: 4px; background: #fff; color: var(--nmg-ink);
	font: inherit; font-size: 1rem; box-shadow: none; -webkit-appearance: none; appearance: none;
}
.nmg-root .nmg-search input[type="search"]:focus { border-color: var(--nmg-accent); box-shadow: 0 0 0 1px var(--nmg-accent); outline: 2px solid transparent; }
.nmg-search input::-webkit-search-cancel-button { display: none; }
.nmg-clear {
	position: absolute; right: 4px; width: 32px; height: 32px; border: 0; border-radius: 4px; background: transparent;
	color: #50575e; font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0;
}
.nmg-clear:hover { color: var(--nmg-ink); background: var(--nmg-soft); }
.nmg-root select.nmg-sort {
	height: 40px; min-height: 40px; margin: 0; padding: 0 28px 0 10px; border: 1px solid #8c8f94; border-radius: 4px;
	background-color: #fff; color: var(--nmg-ink); font: inherit; font-size: .95rem; max-width: 100%;
}
.nmg-root .nmg-submit {
	height: 40px; padding: 0 16px; border: 1px solid var(--nmg-accent); border-radius: 3px; background: var(--nmg-accent);
	color: #fff; font: inherit; font-size: .95rem; cursor: pointer;
}

/* Category filters: simple outlined buttons */
.nmg-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.nmg-root a.nmg-chip {
	display: inline-flex; align-items: center; gap: .35rem; min-height: 34px; padding: 0 12px;
	border: 1px solid var(--nmg-line); border-radius: 3px; background: #fff; color: var(--nmg-ink);
	font-size: .9rem; text-decoration: none; box-shadow: none;
}
.nmg-root a.nmg-chip:hover { border-color: var(--nmg-accent); color: var(--nmg-accent); }
.nmg-root a.nmg-chip[aria-current="true"] { background: var(--nmg-accent); border-color: var(--nmg-accent); color: #fff; }
.nmg-chip .nmg-n { font-size: .78rem; opacity: .7; }
@media (max-width: 639px) {
	.nmg-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
	.nmg-chip { flex: 0 0 auto; white-space: nowrap; }
}

/* ---------- Grid ---------- */
.nmg-section-h { margin: 0 0 .75rem; font-size: 1.1rem; font-weight: 600; }
.nmg-featured { margin-bottom: 2rem; }
.nmg-count { margin: 0 0 .75rem; color: var(--nmg-muted); font-size: .88rem; }

.nmg-grid { display: grid; gap: 1.25rem; grid-template-columns: 1fr; transition: opacity .15s; }
.nmg-root.is-loading .nmg-grid { opacity: .55; }
@media (min-width: 640px)  { .nmg-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) {
	.nmg-root[data-cols="3"] .nmg-grid, .nmg-root[data-cols="4"] .nmg-grid { grid-template-columns: repeat(3, 1fr); }
	.nmg-root[data-cols="2"] .nmg-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1280px) { .nmg-root[data-cols="4"] .nmg-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px) { .nmg-grid--featured { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Card ---------- */
.nmg-card { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--nmg-line); border-radius: 4px; overflow: hidden; }
@media (hover: hover) { .nmg-card:hover { border-color: #a7aaad; } }

.nmg-thumb {
	position: relative; aspect-ratio: 16 / 9; cursor: pointer; overflow: hidden; background-color: #f0f0f1;
	/* Neutral fallback shown when there is no thumbnail or an image fails to load. */
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 180'%3E%3Crect width='320' height='180' fill='%23f0f0f1'/%3E%3Cg fill='%23c3c4c7'%3E%3Crect x='96' y='72' width='8' height='24' rx='4'/%3E%3Crect x='112' y='58' width='8' height='52' rx='4'/%3E%3Crect x='128' y='44' width='8' height='80' rx='4'/%3E%3Crect x='144' y='62' width='8' height='44' rx='4'/%3E%3Crect x='160' y='38' width='8' height='92' rx='4'/%3E%3Crect x='176' y='60' width='8' height='48' rx='4'/%3E%3Crect x='192' y='72' width='8' height='24' rx='4'/%3E%3Crect x='208' y='80' width='8' height='8' rx='4'/%3E%3C/g%3E%3Ctext x='160' y='158' text-anchor='middle' font-family='Arial,Helvetica,sans-serif' font-size='12' font-weight='700' letter-spacing='2' fill='%2350575e'%3ESILENCE the NOISE%3C/text%3E%3C/svg%3E");
	background-size: cover; background-position: center;
}
.nmg-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; max-width: none; }
.nmg-play {
	position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center; color: #fff; background: rgba(0,0,0,.65); padding-left: 3px;
	transition: background .15s;
}
.nmg-play svg { width: 22px; height: 22px; }
.nmg-thumb:hover .nmg-play { background: var(--nmg-accent); }
.nmg-badge {
	position: absolute; left: 8px; top: 8px; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 6px;
	border-radius: 3px; background: #fff; color: #1d2327; font-size: .72rem; font-weight: 600; border: 1px solid var(--nmg-line);
}
.nmg-badge svg { color: #dba617; }
.nmg-dur {
	position: absolute; right: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 4px; padding: 1px 6px;
	border-radius: 3px; background: rgba(0,0,0,.75); color: #fff; font-size: .75rem; font-variant-numeric: tabular-nums;
}

.nmg-body { display: flex; flex-direction: column; flex: 1; padding: .9rem 1rem 1rem; }
.nmg-cat { margin: 0 0 .25rem; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; color: var(--nmg-muted); }
.nmg-title { margin: 0 0 .4rem; font-size: 1.05rem; line-height: 1.35; font-weight: 600; }
.nmg-title a { color: var(--nmg-ink); text-decoration: none; }
.nmg-title a:hover { color: var(--nmg-accent); text-decoration: underline; }
.nmg-desc { margin: 0 0 .75rem; color: var(--nmg-muted); font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.nmg-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 36px; }
.nmg-by { font-size: .82rem; color: var(--nmg-muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nmg-root button.nmg-share {
	flex: 0 0 auto; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px;
	border: 1px solid transparent; background: transparent; color: var(--nmg-muted); cursor: pointer; padding: 0; box-shadow: none;
}
.nmg-root button.nmg-share:hover { color: var(--nmg-accent); background: var(--nmg-soft); }

[lang="ml"] { line-height: 1.6; }

/* ---------- Focus ---------- */
.nmg-root a:focus-visible, .nmg-root button:focus-visible, .nmg-root input:focus-visible, .nmg-root select:focus-visible,
.nmg-lb a:focus-visible, .nmg-lb button:focus-visible { outline: 2px solid var(--nmg-accent); outline-offset: 2px; }

/* ---------- Load more / empty ---------- */
.nmg-more-wrap { text-align: center; margin-top: 1.5rem; }
.nmg-root button.nmg-more {
	min-height: 40px; padding: 0 20px; border: 1px solid var(--nmg-accent); border-radius: 3px; background: #f6f7f7;
	color: var(--nmg-accent); font: inherit; cursor: pointer;
}
.nmg-root button.nmg-more:hover { background: #f0f0f1; border-color: var(--nmg-accent-dark); color: var(--nmg-accent-dark); }
.nmg-more[hidden], .nmg-empty[hidden], .nmg-clear[hidden], .nmg-submit[hidden], .nmg-featured[hidden] { display: none !important; }
.nmg-empty { padding: 1.5rem 1rem; text-align: center; color: var(--nmg-muted); background: var(--nmg-soft); border: 1px solid var(--nmg-line); border-radius: 4px; }
.nmg-pager { text-align: center; margin-top: 1.25rem; }
.nmg-pager a { display: inline-block; padding: .4rem .9rem; border: 1px solid var(--nmg-accent); border-radius: 3px; text-decoration: none; margin: 0 .25rem; }

/* ---------- Viewer (lightbox) ---------- */
html.nmg-lb-open { overflow: hidden; }
.nmg-lb { --nmg-accent: #2271b1; position: fixed; inset: 0; z-index: 999999; display: flex; align-items: center; justify-content: center; padding: 12px; }
.nmg-lb[hidden] { display: none; }
.nmg-lb-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.8); }
.nmg-lb-dialog {
	position: relative; width: min(100%, 1000px); max-height: 100%; overflow: auto; background: #fff; color: #1d2327;
	border-radius: 4px; box-shadow: 0 8px 30px rgba(0,0,0,.4); outline: none;
}
.nmg-lb-close {
	position: absolute; right: 8px; top: 8px; z-index: 2; width: 40px; height: 40px; border: 0; border-radius: 4px;
	background: rgba(0,0,0,.7); color: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
}
.nmg-lb-close:hover { background: #000; }
.nmg-lb-stage { background: #000; display: flex; justify-content: center; }
.nmg-player {
	--ar: 16/9; --ar-n: 1.7778;
	width: min(100%, calc((100vh - 230px) * var(--ar-n))); aspect-ratio: var(--ar); min-height: 180px; background: #000; position: relative;
}
@supports (height: 100dvh) { .nmg-player { width: min(100%, calc((100dvh - 230px) * var(--ar-n))); } }
.nmg-player iframe, .nmg-player video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.nmg-lb-error { color: #fff; padding: 2rem; text-align: center; }
.nmg-lb-info { padding: 1rem 1.25rem 1.25rem; }
.nmg-lb-title { margin: 0 0 .25rem; font-size: 1.2rem; line-height: 1.35; color: #1d2327; font-weight: 600; }
.nmg-lb-meta { margin: 0 0 .6rem; color: #50575e; font-size: .88rem; }
.nmg-lb-desc { font-size: .95rem; max-height: 9rem; overflow: auto; }
.nmg-lb-desc p { margin: 0 0 .6rem; }
.nmg-lb-links { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }
.nmg-btn {
	display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 3px; border: 1px solid var(--nmg-accent);
	background: var(--nmg-accent); color: #fff !important; font: inherit; font-size: .92rem; text-decoration: none !important; cursor: pointer;
}
.nmg-btn--ghost { background: #f6f7f7; color: var(--nmg-accent) !important; }
@media (max-width: 600px) {
	.nmg-lb { padding: 0; align-items: stretch; }
	.nmg-lb-dialog { border-radius: 0; width: 100%; }
	.nmg-player { width: 100%; }
}

/* ---------- Toast ---------- */
.nmg-toast {
	position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 1000000; padding: .6rem 1rem; border-radius: 4px;
	background: #1d2327; color: #fff; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.nmg-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { .nmg-grid, .nmg-play, .nmg-toast { transition: none; } }
@media (forced-colors: active) { .nmg-chip[aria-current="true"] { outline: 2px solid CanvasText; } }
