/**
 * Apna Mithila — base.css
 *
 * Reset, design tokens, layout primitives, sticky footer, responsive grids.
 * Mobile-first. Tokens overridden in dark-mode.css via html[data-theme="dark"].
 */

/* ==========================================================================
   1. Modern reset
   ========================================================================== */
*,
*::before,
*::after {
	box-sizing: border-box;
}

* {
	margin: 0;
	padding: 0;
}

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}
	*,
	*::before,
	*::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
		scroll-behavior: auto !important;
	}
}

body {
	min-height: 100vh;
	min-height: 100dvh;
	text-rendering: optimizeLegibility;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

img,
picture,
video,
canvas,
svg {
	display: block;
	max-width: 100%;
	height: auto;
}

svg {
	fill: currentColor;
}

input,
button,
textarea,
select {
	font: inherit;
	color: inherit;
}

button {
	background: none;
	border: none;
	cursor: pointer;
}

ul[role="list"],
ol[role="list"] {
	list-style: none;
}

a {
	color: inherit;
	text-decoration: none;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
	overflow-wrap: break-word;
}

#root,
#__next,
#am-page {
	isolation: isolate;
}

/* ==========================================================================
   2. Design tokens
   ========================================================================== */
:root {
	/* Brand palette (per PRD §12) */
	--am-terracotta:   #b5402a;
	--am-mustard:      #d99a1e;
	--am-deep-green:   #2f6b4f;
	--am-indigo:       #3b3a8c;
	--am-cream:        #fbf6ec;
	--am-ink:          #221a14;

	/* Semantic neutrals — LIGHT defaults (overridden in dark-mode.css) */
	--am-bg:           #fbf6ec;
	--am-surface:      #ffffff;
	--am-surface-alt:  #f6efe1;
	--am-text:         #221a14;
	--am-text-muted:   #6b5b4a;
	--am-border:       #e6dcc8;
	--am-accent:       #b5402a; /* = terracotta */
	--am-accent-2:     #d99a1e; /* = mustard */
	--am-link:         #b5402a;
	--am-link-hover:   #8a2f1f;
	--am-shadow:       0 6px 20px rgba(34, 26, 20, 0.08);
	--am-shadow-lg:    0 16px 40px rgba(34, 26, 20, 0.14);

	/* Typography */
	--am-font-dev:   "Palanquin", "Noto Sans Devanagari", system-ui, sans-serif;
	--am-font-latin: "Inter", system-ui, sans-serif;
	--am-font-head:  "Palanquin", "Noto Sans Devanagari", "Inter", system-ui, sans-serif;

	/* Spacing & shape */
	--am-gap:        1rem;
	--am-gap-sm:     0.5rem;
	--am-gap-lg:     1.5rem;
	--am-gap-xl:     2rem;
	--am-radius:     10px;
	--am-radius-sm:  6px;
	--am-radius-lg:  18px;
	--am-radius-pill: 999px;
	--am-container:  1200px;

	/* Layout */
	--am-nav-h:      56px;
	--am-topbar-h:   40px;

	/* Motion */
	--am-ease: cubic-bezier(0.4, 0, 0.2, 1);
	--am-dur:  180ms;

	color-scheme: light;
}

/* ==========================================================================
   3. Base typography
   ========================================================================== */
body {
	background: var(--am-bg);
	color: var(--am-text);
	font-family: var(--am-font-dev);
	font-size: 16px;
	line-height: 1.6;
	transition: background-color var(--am-dur) var(--am-ease),
	            color var(--am-dur) var(--am-ease);
}

@media (min-width: 768px) {
	body {
		font-size: 17px;
	}
}

h1, h2, h3, h4, h5, h6 {
	font-family: var(--am-font-head);
	font-weight: 700;
	line-height: 1.25;
	color: var(--am-text);
	text-wrap: balance;
}

h1 { font-size: clamp(1.75rem, 4vw + 1rem, 2.5rem); }
h2 { font-size: clamp(1.4rem, 2vw + 1rem, 1.9rem); }
h3 { font-size: clamp(1.15rem, 1vw + 1rem, 1.4rem); }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.9rem; }

p {
	margin-block: 0 1em;
}

p:last-child {
	margin-block-end: 0;
}

a {
	color: var(--am-link);
	text-decoration: underline;
	text-underline-offset: 2px;
}

a:hover {
	color: var(--am-link-hover);
	text-decoration-thickness: 2px;
}

img {
	max-width: 100%;
	height: auto;
}

figure {
	margin: 0;
}

figcaption {
	font-size: 0.85rem;
	color: var(--am-text-muted);
	margin-top: 0.35rem;
	font-style: italic;
}

blockquote {
	margin: 1.25rem 0;
	padding: 0.5rem 1rem;
	border-left: 4px solid var(--am-accent);
	background: var(--am-surface-alt);
	border-radius: 0 var(--am-radius-sm) var(--am-radius-sm) 0;
	font-style: italic;
	color: var(--am-text);
}

blockquote p:last-child { margin-block-end: 0; }

pre {
	background: var(--am-surface-alt);
	border: 1px solid var(--am-border);
	border-radius: var(--am-radius-sm);
	padding: 1rem;
	overflow-x: auto;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.9rem;
}

code, kbd, samp {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.9em;
}

code {
	background: var(--am-surface-alt);
	padding: 0.1em 0.4em;
	border-radius: 4px;
}

pre code {
	background: none;
	padding: 0;
}

hr {
	border: none;
	border-top: 1px solid var(--am-border);
	margin: 1.5rem 0;
}

table {
	width: 100%;
	border-collapse: collapse;
	margin: 1rem 0;
	font-size: 0.95rem;
}

th, td {
	padding: 0.6rem 0.75rem;
	border: 1px solid var(--am-border);
	text-align: start;
}

th {
	background: var(--am-surface-alt);
	font-weight: 700;
}

/* ==========================================================================
   4. Accessibility utilities
   ========================================================================== */
.sr-only,
.screen-reader-text {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	clip-path: inset(50%) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

.am-skip-link {
	position: absolute;
	top: -100px;
	left: 1rem;
	z-index: 1000;
	background: var(--am-accent);
	color: var(--am-cream);
	padding: 0.65rem 1rem;
	border-radius: var(--am-radius-sm);
	font-weight: 700;
	text-decoration: none;
	box-shadow: var(--am-shadow);
	transition: top var(--am-dur) var(--am-ease);
}

.am-skip-link:focus {
	top: 1rem;
	color: var(--am-cream);
}

/* Focus-visible outline for keyboard users only */
:focus-visible {
	outline: 3px solid var(--am-accent);
	outline-offset: 2px;
	border-radius: 3px;
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
	outline: 3px solid var(--am-accent);
	outline-offset: 2px;
}

/* ==========================================================================
   5. Layout: container, page, sticky footer
   ========================================================================== */
.am-container {
	width: 100%;
	max-width: var(--am-container);
	margin-inline: auto;
	padding-inline: 16px;
}

@media (min-width: 768px) {
	.am-container {
		padding-inline: 24px;
	}
}

/* Sticky footer: page is min-h flex column, main grows, footer sits at bottom. */
.am-page {
	min-height: 100vh;
	min-height: 100dvh;
	display: flex;
	flex-direction: column;
}

.am-main {
	flex: 1 0 auto;
	width: 100%;
	padding-block: 1.25rem;
}

@media (min-width: 768px) {
	.am-main {
		padding-block: 2rem;
	}
}

.am-footer {
	flex-shrink: 0;
	margin-top: auto;
}

/* ==========================================================================
   6. Two-column / single layouts
   ========================================================================== */
.am-layout {
	width: 100%;
}

.am-layout--two-col {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--am-gap-lg);
}

@media (min-width: 1024px) {
	.am-layout--two-col {
		grid-template-columns: minmax(0, 1fr) 320px;
		gap: var(--am-gap-xl);
		align-items: start;
	}
}

.am-layout--single {
	max-width: 768px;
	margin-inline: auto;
}

.am-layout__main {
	min-width: 0; /* prevents grid blowout */
}

/* ==========================================================================
   7. Grids (mobile-first)
   ========================================================================== */
.am-grid {
	display: grid;
	gap: var(--am-gap);
}

.am-grid--cards,
.am-grid--latest {
	grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 600px) {
	.am-grid--cards,
	.am-grid--latest {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 1024px) {
	.am-grid--cards,
	.am-grid--latest {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

.am-grid--list {
	grid-template-columns: minmax(0, 1fr);
	gap: var(--am-gap);
}

.am-grid--gallery {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 600px) {
	.am-grid--gallery {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (min-width: 1024px) {
	.am-grid--gallery {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

.am-grid--videos {
	grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 768px) {
	.am-grid--videos {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 1024px) {
	.am-grid--videos {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/* ==========================================================================
   8. Pagination & breadcrumbs
   ========================================================================== */
.am-pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 0.35rem;
	margin-top: var(--am-gap-lg);
	padding: 0;
	list-style: none;
}

.am-pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	padding: 0 0.75rem;
	border: 1px solid var(--am-border);
	border-radius: var(--am-radius-sm);
	background: var(--am-surface);
	color: var(--am-text);
	text-decoration: none;
	font-weight: 600;
	transition: background-color var(--am-dur) var(--am-ease),
	            color var(--am-dur) var(--am-ease),
	            border-color var(--am-dur) var(--am-ease);
}

.am-pagination .page-numbers:hover {
	background: var(--am-accent);
	color: var(--am-cream);
	border-color: var(--am-accent);
}

.am-pagination .page-numbers.current {
	background: var(--am-accent);
	color: var(--am-cream);
	border-color: var(--am-accent);
	cursor: default;
}

.am-pagination .page-numbers.dots {
	border: none;
	background: none;
	min-width: auto;
}

.am-pagination .prev,
.am-pagination .next {
	font-weight: 700;
}

.am-breadcrumbs {
	font-size: 0.85rem;
	color: var(--am-text-muted);
	padding: 0.5rem 0;
}

.am-breadcrumbs ol {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	align-items: center;
	list-style: none;
	margin: 0;
	padding: 0;
}

.am-breadcrumbs li {
	display: flex;
	align-items: center;
	gap: 0.4rem;
}

.am-breadcrumbs li + li::before {
	content: "›";
	color: var(--am-text-muted);
	font-weight: 700;
}

.am-breadcrumbs a {
	color: var(--am-link);
	text-decoration: none;
}

.am-breadcrumbs a:hover {
	text-decoration: underline;
}

.am-breadcrumbs [aria-current="page"] {
	color: var(--am-text);
	font-weight: 600;
}

/* ==========================================================================
   9. Page header & 404 scaffolding (basic — extended in components.css)
   ========================================================================== */
.am-page-header {
	margin-block-end: var(--am-gap-lg);
}

.am-page-title {
	font-size: clamp(1.6rem, 3vw + 1rem, 2.2rem);
}

.am-page-subtitle,
.am-archive-desc,
.am-search-term {
	color: var(--am-text-muted);
	margin-top: 0.5rem;
}
