/**
 * AMA — Simple Download Monitor (SDM) skin.
 *
 * Layers over the plugin's own `sdm-styles` (css/sdm_wp_styles.css) — enqueued
 * with that as a dependency so these rules load AFTER and win by order. Only a
 * few of SDM's rules use !important (button text colour, thumbnail size); those
 * are matched with equal-or-higher specificity + !important below. Colours use
 * the global AMA tokens (with hex fallbacks so it holds up in any context).
 *
 * @package AMAIndiaTwentySix
 */

/* ── Download button — flatten every colour variant to the AMA navy pill ──── */
.sdm_download,
.sdm_download.green, .sdm_download.blue,   .sdm_download.purple, .sdm_download.teal,
.sdm_download.darkblue, .sdm_download.black, .sdm_download.grey, .sdm_download.pink,
.sdm_download.orange, .sdm_download.white {
	background: var(--ama-navy, #1a2744) !important;
	color: #fff !important;
	border: none !important;
	border-radius: 4px !important;
	box-shadow: none !important;
	text-shadow: none !important;
	font: 700 0.875rem/1 var(--font-sans, "Plus Jakarta Sans", system-ui, sans-serif) !important;
	padding: 12px 22px !important;
	letter-spacing: .01em;
	transition: background .15s ease;
}
.sdm_download:hover { background: var(--ama-maroon, #8a3a2a) !important; }
.sdm_download.disabled,
.sdm_download.disabled:hover {
	background: #e4dfd6 !important;
	color: #9c9c9c !important;
	cursor: not-allowed;
}

/* ── Download item card (list templates) ─────────────────────────────────── */
.sdm_download_item {
	border: 1px solid var(--ama-border, #d6cfc4);
	border-radius: 6px;
	box-shadow: 0 1px 4px rgba(0, 0, 0, .05);
	padding: 18px 20px;
	margin: 14px 0;
	background: #fff;
}
.sdm_download_item_top { display: flex; align-items: center; gap: 10px; }
.sdm_download_title {
	font-family: var(--font-serif, Georgia, "Times New Roman", serif);
	font-size: 1.2rem;
	font-weight: 600;
	line-height: 1.3; /* was inheriting SDM's 75px, which left a huge gap */
	color: var(--ama-navy, #1a2744);
	float: none;
}
.sdm_download_thumbnail_image { border-radius: 4px; border: 1px solid var(--ama-border, #d6cfc4); }
.sdm_download_description { color: var(--ama-muted, #534c45); border-bottom-color: var(--ama-border, #d6cfc4); line-height: 1.7; }
/* An empty description still renders its divider border — drop it when blank. */
.sdm_download_description:empty { border: 0; margin: 0; padding: 0; }
.sdm_download_item_count {
	border: 1px solid var(--ama-border, #d6cfc4);
	border-radius: 999px;
	color: var(--ama-muted, #534c45);
	font-size: 0.8125rem;
	font-weight: 600;
}

/* ── Single download page ────────────────────────────────────────────────── */
.sdm_post_title {
	font-family: var(--font-serif, Georgia, serif);
	font-size: clamp(1.5rem, 3vw, 2rem);
	font-weight: 600;
	color: var(--ama-navy, #1a2744);
}
.sdm_post_item_top_left img { border: 1px solid var(--ama-border, #d6cfc4); border-radius: 6px; }
.sdm_post_download_count {
	border: 1px solid var(--ama-border, #d6cfc4);
	border-radius: 4px;
	background: var(--ama-cream, #f5f0e8);
	color: var(--ama-navy, #1a2744);
	font-size: 1rem;
}
.sdm_post_download_section,
.sdm_post_download_file_size,
.sdm_post_download_version,
.sdm_post_download_published_date { color: var(--ama-muted, #534c45); }
.sdm_post_meta_section { border-top: 1px solid var(--ama-border, #d6cfc4); }

/* ── Category listings + object tree ─────────────────────────────────────── */
.sdm_cat_title,
.sdm_object_tree .sdm_post_title {
	font-family: var(--font-serif, Georgia, serif);
	color: var(--ama-navy, #1a2744);
}

/* ── Fancy-3 compact card ────────────────────────────────────────────────── */
.sdm_fancy3_download_item { border: 1px solid var(--ama-border, #d6cfc4); border-radius: 6px; overflow: hidden; }
.sdm_fancy3_download_title { color: var(--ama-navy, #1a2744); font-weight: 600; }
.sdm_fancy3_view_details_link a { color: var(--ama-maroon, #8a3a2a); text-decoration: none; }

/* ── Search results ──────────────────────────────────────────────────────── */
.sdm_search_result_item { border-bottom-color: var(--ama-border, #d6cfc4); }
.sdm_search_result_item .sdm_post_title { font-size: 1.15rem; }

/* ── Notice boxes → subtle, on-brand ─────────────────────────────────────── */
.sdm_yellow_box { background: #fbf4de; border-color: #e5d59a; color: #5a4a1e; border-radius: 4px; }
.sdm_grey_box   { background: #f3f0ea; border-color: var(--ama-border, #d6cfc4); color: var(--ama-muted, #534c45); border-radius: 4px; }
.sdm_blue_box   { background: #eaeff7; border-color: #c3d0e6; color: var(--ama-navy, #1a2744); border-radius: 4px; }

/* ── Pagination ──────────────────────────────────────────────────────────── */
.sdm_pagination a,
.sdm_pagination span {
	display: inline-block;
	padding: 6px 12px;
	border: 1px solid var(--ama-border, #d6cfc4);
	border-radius: 4px;
	color: var(--ama-navy, #1a2744);
	text-decoration: none;
	margin: 0 2px;
}
.sdm_pagination a:hover { background: var(--ama-cream, #f5f0e8); }

/* ══════════════════════════════════════════════════════════════════════════
   COMPACT VIEW — opt-in single row: ~title on the left, icon download button on
   the right, so many more downloads fit. Enable it either per download via the
   shortcode's css_class:
       [sdm_download id="5" css_class="ama-sdm-compact"]
   or by wrapping a list/category output:
       <div class="ama-sdm-compact"> …download shortcodes… </div>
   ══════════════════════════════════════════════════════════════════════════ */
.ama-sdm-compact .sdm_download_item,
.sdm_download_item.ama-sdm-compact {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 10px 16px;
	margin: 8px 0;
}
.ama-sdm-compact .sdm_download_item_top,
.sdm_download_item.ama-sdm-compact .sdm_download_item_top { flex: 1 1 auto; min-width: 0; }
.ama-sdm-compact .sdm_download_title,
.sdm_download_item.ama-sdm-compact .sdm_download_title { font-size: 1rem; line-height: 1.35; }

/* Hide the description divider + meta rows so the row stays a single line. */
.ama-sdm-compact .sdm_download_description,
.ama-sdm-compact .sdm_download_size,
.ama-sdm-compact .sdm_download_version,
.ama-sdm-compact .sdm_download_date,
.sdm_download_item.ama-sdm-compact .sdm_download_description,
.sdm_download_item.ama-sdm-compact .sdm_download_size,
.sdm_download_item.ama-sdm-compact .sdm_download_version,
.sdm_download_item.ama-sdm-compact .sdm_download_date { display: none; }
.ama-sdm-compact .sdm_download_item > div[style*="clear"],
.sdm_download_item.ama-sdm-compact > div[style*="clear"] { display: none; }

/* Button block on the right. */
.ama-sdm-compact .sdm_download_link,
.sdm_download_item.ama-sdm-compact .sdm_download_link {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
}
.ama-sdm-compact .sdm_download_item_count,
.sdm_download_item.ama-sdm-compact .sdm_download_item_count { margin: 0; float: none; }

/* Download-icon button — icon only (the "Download Now!" label is collapsed to
   font-size:0 so it stays in the DOM as the link's accessible name). */
.ama-sdm-compact .sdm_download,
.sdm_download_item.ama-sdm-compact .sdm_download {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	gap: 0;
	font-size: 0 !important;
	padding: 11px 15px !important;
}
.ama-sdm-compact .sdm_download::before,
.sdm_download_item.ama-sdm-compact .sdm_download::before {
	content: "";
	width: 18px;
	height: 18px;
	flex-shrink: 0;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 16l-6-6h4V4h4v6h4l-6 6zm-8 4h16v-2H4v2z'/%3E%3C/svg%3E") center / contain no-repeat;
	        mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 16l-6-6h4V4h4v6h4l-6 6zm-8 4h16v-2H4v2z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Small screens: let the button drop below the title rather than crush it. */
@media (max-width: 480px) {
	.ama-sdm-compact .sdm_download_item,
	.sdm_download_item.ama-sdm-compact { flex-wrap: wrap; }
}

/* ══════════════════════════════════════════════════════════════════════════
   Year-grouped download index — [ama_sdm_year_list]
   Only the year headings + group spacing live here; the download ITEMS are
   rendered by SDM's own fancy template, so they inherit the .sdm_download_item
   skin above (incl. the ama-sdm-compact variant) with zero extra styling.
   ══════════════════════════════════════════════════════════════════════════ */

.ama-sdm-years { margin: 0 0 1.5rem; }

.ama-sdm-years__year {
	font: 700 1.375rem/1.2 var(--font-sans, "Plus Jakarta Sans", system-ui, sans-serif);
	color: var(--ama-navy, #1a2744);
	margin: 1.75rem 0 0.9rem;
	padding-bottom: 0.4rem;
	border-bottom: 2px solid var(--ama-border, #d6cfc4);
}
.ama-sdm-years__year:first-child { margin-top: 0; }

/* Lay the year's downloads out inline, wrapping to the next line as needed,
   instead of each item taking a full-width row. Scoped to the year view only,
   so the standalone [sdm_show_dl_from_category] keeps its one-per-line layout. */
.ama-sdm-years__group {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 12px;
	align-items: stretch;
}
/* Items size to their content and wrap; the group gap handles spacing, so drop
   the SDM per-item vertical margins. !important because the compact item rule
   above (and the Elementor kit) set margin with higher weight. */
.ama-sdm-years__group .sdm_download_item,
.ama-sdm-years__group .sdm_download_item.ama-sdm-compact {
	margin: 0 !important;
	width: auto;
	max-width: 100%;
	flex: 0 1 auto;
}

.ama-sdm-years.ama-sdm-compact .ama-sdm-years__year { font-size: 1.125rem; margin-top: 1.25rem; }

/* ── layout="list": one download per line ─────────────────────────────────── */
/* Undoes the row grouping above so the items stack exactly as SDM's own
   [sdm_show_dl_from_category] renders them. Written at the same specificity as
   the rules it overrides (and placed after them), so no !important is needed
   beyond matching SDM's own margin !important. */
.ama-sdm-years__group--stack { display: block; }
.ama-sdm-years__group--stack .sdm_download_item,
.ama-sdm-years__group--stack .sdm_download_item.ama-sdm-compact {
	width: auto;
	max-width: none;
	margin: 0 0 10px !important;
}
.ama-sdm-years__group--stack .sdm_download_item:last-child,
.ama-sdm-years__group--stack .sdm_download_item.ama-sdm-compact:last-child {
	margin-bottom: 0 !important;
}

/* ── showmore="N": the newest N plain, the rest folded by year ────────────── */

/* The newest items carry no year heading, so they need the top margin the
   heading would otherwise have given the group below it. */
.ama-sdm-years__group--latest { margin-bottom: 1.25rem; }

.ama-sdm-years__fold { border-bottom: 1px solid var(--ama-border, #d6cfc4); }
.ama-sdm-years__fold:first-of-type { border-top: 1px solid var(--ama-border, #d6cfc4); }

.ama-sdm-years__toggle {
	display: flex;
	align-items: baseline;
	gap: 0.6rem;
	padding: 0.85rem 0.25rem;
	cursor: pointer;
	list-style: none;          /* Firefox */
	/* 2.5.8: comfortably past the 24px minimum, and the whole row is the target. */
	min-height: 44px;
	box-sizing: border-box;
}
.ama-sdm-years__toggle::-webkit-details-marker { display: none; }

/* A triangle of our own, so the control looks the same in every browser and
   can be coloured with the headings. */
.ama-sdm-years__toggle::before {
	content: "";
	flex: 0 0 auto;
	width: 0;
	height: 0;
	border-left: 6px solid currentColor;
	border-top: 4.5px solid transparent;
	border-bottom: 4.5px solid transparent;
	color: var(--ama-navy, #1a2744);
	transform: translateY(-1px);
	transition: transform 0.15s ease;
}
.ama-sdm-years__fold[open] > .ama-sdm-years__toggle::before { transform: rotate(90deg) translateX(-1px); }

/* Inside a summary the year is a label, not a section heading: no rule beneath
   it, no margins — the summary row owns the spacing. */
.ama-sdm-years__toggle .ama-sdm-years__year {
	margin: 0;
	padding: 0;
	border-bottom: 0;
	font-size: 1.125rem;
}
.ama-sdm-years__count {
	font: 400 0.8125rem/1 var(--font-body, system-ui, sans-serif);
	color: var(--ama-muted, #6b6459);
}

.ama-sdm-years__fold > .ama-sdm-years__group { padding: 0.25rem 0 1.1rem; }

.ama-sdm-years__toggle:focus-visible {
	outline: 2px solid var(--ama-navy, #1a2744);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.ama-sdm-years__toggle::before { transition: none; }
}

/* Small screens: stack the items again so titles never get crushed. */
@media (max-width: 480px) {
	.ama-sdm-years__group { flex-direction: column; align-items: stretch; }
	.ama-sdm-years__group .sdm_download_item,
	.ama-sdm-years__group .sdm_download_item.ama-sdm-compact { width: 100%; }
}
