:root {
  --imerg-red: #d64227;
  --imerg-red-dark: #b62f1d;
  --imerg-navy: #173b63;
  --imerg-ink: #172033;
  --imerg-green: #4d8b3a;
  --imerg-warm: #fafaf7;
  --imerg-soft: #f3f5f7;
  --imerg-line: rgba(23, 59, 99, 0.12);
  --imerg-shadow: 0 18px 48px rgba(23, 32, 51, 0.12);
}

body {
  background:
    radial-gradient(circle at 8% 12%, rgba(214, 66, 39, 0.08), transparent 30rem),
    radial-gradient(circle at 90% 8%, rgba(77, 139, 58, 0.08), transparent 28rem),
    linear-gradient(180deg, #fff 0%, var(--imerg-warm) 48%, #fff 100%) !important;
  color: var(--imerg-ink);
  letter-spacing: 0;
}

a {
  color: #0f6388;
}

a:hover {
  color: var(--imerg-red-dark);
}

#main-site-header,
header#main-site-header {
  background: rgba(255, 255, 255, 0.94) !important;
  border-bottom: 0 !important;
  box-shadow: 0 8px 28px rgba(23, 32, 51, 0.08);
  backdrop-filter: blur(12px);
}

#main-site-header::after,
header#main-site-header::after {
  content: "";
  display: block;
  height: 4px;
  background: linear-gradient(90deg, var(--imerg-red), var(--imerg-green), var(--imerg-navy));
}

#header-logo {
  content: url("/assets/images/bv-pdtc.png") !important;
  width: 72px !important;
  height: 72px !important;
  object-fit: contain;
  padding: 4px;
  filter: drop-shadow(0 8px 14px rgba(23, 32, 51, 0.12));
}

nav#header-left,
#header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

nav#header-left::after,
#header-left::after {
  content: "I-EMeRG Digital Library";
  color: var(--imerg-navy);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.05;
  max-width: 11rem;
}

#header-navbar-wrapper,
nav.navbar {
  background: transparent !important;
}

.navbar-nav .nav-link,
#main-site-header a,
#main-site-header button {
  color: var(--imerg-navy) !important;
  font-weight: 650;
}

#main-site-header .nav-link:hover,
#main-site-header a:hover,
#main-site-header button:hover {
  color: var(--imerg-red) !important;
}

#main-site-header .btn,
#main-site-header button {
  border-radius: 8px !important;
}

main#main-content {
  background: transparent !important;
}

body:has(ds-home-page) main#main-content,
body:has(ds-themed-home-page) main#main-content {
  position: relative;
  padding-top: 0 !important;
}

body:has(ds-home-page) main#main-content::before,
body:has(ds-themed-home-page) main#main-content::before {
  content: "";
  display: block;
  min-height: clamp(360px, 48vh, 520px);
  margin: 0 0 2rem;
  background:
    linear-gradient(100deg, rgba(255, 255, 255, 0.96) 0%, rgba(255, 255, 255, 0.86) 44%, rgba(255, 255, 255, 0.36) 72%),
    linear-gradient(135deg, rgba(23, 59, 99, 0.92), rgba(23, 59, 99, 0.72)),
    url("/assets/dspace/images/banner.jpg") center/cover no-repeat;
  border-bottom: 1px solid var(--imerg-line);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.7);
}

body:has(ds-home-page) main#main-content::after,
body:has(ds-themed-home-page) main#main-content::after {
  content: "I-EMeRG Digital Library\A Knowledge for Community-Driven Change\A A curated repository by Bala Vikasa for NGOs, changemakers, researchers, and development professionals.";
  white-space: pre-line;
  position: absolute;
  top: clamp(5rem, 10vw, 8rem);
  left: max(2rem, calc((100vw - 1140px) / 2));
  width: min(680px, calc(100vw - 4rem));
  color: var(--imerg-ink);
  font-size: clamp(1rem, 1.7vw, 1.2rem);
  line-height: 1.65;
  font-weight: 500;
}

body:has(ds-home-page) main#main-content::after,
body:has(ds-themed-home-page) main#main-content::after {
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

body:has(ds-home-page) main#main-content h1:first-of-type,
body:has(ds-themed-home-page) main#main-content h1:first-of-type {
  position: absolute;
  top: clamp(2.2rem, 5vw, 4rem);
  left: max(2rem, calc((100vw - 1140px) / 2));
  z-index: 2;
  width: min(720px, calc(100vw - 4rem));
  color: transparent !important;
  font-size: 0 !important;
  border: 0 !important;
}

body:has(ds-home-page) main#main-content h1:first-of-type::before,
body:has(ds-themed-home-page) main#main-content h1:first-of-type::before {
  content: "I-EMeRG";
  display: block;
  color: var(--imerg-navy);
  font-size: clamp(3.2rem, 7vw, 6.25rem);
  font-weight: 900;
  line-height: 0.88;
  letter-spacing: 0;
  text-shadow:
    0 2px 0 #fff,
    0 8px 0 rgba(214, 66, 39, 0.16),
    0 18px 34px rgba(23, 32, 51, 0.20);
}

body:has(ds-home-page) main#main-content h1:first-of-type::after,
body:has(ds-themed-home-page) main#main-content h1:first-of-type::after {
  content: "Digital Library";
  display: block;
  margin-top: 0.35rem;
  color: var(--imerg-red);
  font-size: clamp(1.55rem, 3vw, 2.55rem);
  font-weight: 800;
}

.container,
.container-fluid {
  letter-spacing: 0;
}

body:has(ds-home-page) main#main-content .container,
body:has(ds-themed-home-page) main#main-content .container {
  max-width: 1140px;
}

ds-search-form,
.search-form,
form[role="search"],
.input-group {
  border-radius: 8px;
}

body:has(ds-home-page) ds-search-form,
body:has(ds-themed-home-page) ds-search-form {
  display: block;
  margin-top: -4rem;
  position: relative;
  z-index: 3;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(23, 59, 99, 0.12);
  border-radius: 8px;
  padding: 1.1rem;
  box-shadow: var(--imerg-shadow);
}

.form-control,
input[type="text"],
input[type="search"],
select,
textarea {
  border-color: rgba(23, 59, 99, 0.18) !important;
  border-radius: 8px !important;
}

.form-control:focus,
input[type="text"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  border-color: var(--imerg-red) !important;
  box-shadow: 0 0 0 0.2rem rgba(214, 66, 39, 0.14) !important;
}

.btn-primary,
button.btn-primary,
a.btn-primary {
  background: linear-gradient(135deg, var(--imerg-red), var(--imerg-red-dark)) !important;
  border-color: var(--imerg-red-dark) !important;
  color: #fff !important;
  border-radius: 8px !important;
  font-weight: 750;
  box-shadow: 0 12px 22px rgba(214, 66, 39, 0.22);
}

.btn-secondary,
button.btn-secondary,
a.btn-secondary {
  background: var(--imerg-navy) !important;
  border-color: var(--imerg-navy) !important;
  color: #fff !important;
  border-radius: 8px !important;
}

.btn-outline-primary {
  border-color: var(--imerg-red) !important;
  color: var(--imerg-red) !important;
  border-radius: 8px !important;
}

.btn-outline-primary:hover {
  background: var(--imerg-red) !important;
  color: #fff !important;
}

.card,
.list-group,
ds-themed-community-list-element,
ds-themed-item-search-result-list-element,
ds-themed-collection-search-result-list-element,
ds-community-list-element,
ds-item-search-result-list-element,
ds-collection-search-result-list-element {
  border-radius: 8px !important;
}

.card {
  border: 1px solid var(--imerg-line) !important;
  box-shadow: 0 12px 30px rgba(23, 32, 51, 0.08);
}

.card:hover,
ds-themed-community-list-element:hover,
ds-themed-item-search-result-list-element:hover,
ds-themed-collection-search-result-list-element:hover {
  transform: translateY(-2px);
  transition: transform 160ms ease, box-shadow 160ms ease;
  box-shadow: var(--imerg-shadow);
}

h1,
h2,
h3,
h4,
h5 {
  color: var(--imerg-ink);
  letter-spacing: 0;
}

h2::after {
  content: "";
  display: block;
  width: 3rem;
  height: 3px;
  margin-top: 0.5rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--imerg-red), var(--imerg-green));
}

.breadcrumb {
  background: var(--imerg-soft) !important;
  border-radius: 8px;
  padding: 0.75rem 1rem !important;
}

footer,
footer.footer,
footer.navbar,
#main-footer {
  background: var(--imerg-navy) !important;
  color: rgba(255, 255, 255, 0.88) !important;
  border-top: 4px solid var(--imerg-red);
}

footer a,
#main-footer a {
  color: #fff !important;
  text-decoration: none;
}

footer a:hover,
#main-footer a:hover {
  color: #ffd8cf !important;
}

@media (max-width: 767px) {
  #header-logo {
    width: 56px !important;
    height: 56px !important;
  }

  nav#header-left::after,
  #header-left::after {
    font-size: 0.95rem;
    max-width: 8rem;
  }

  body:has(ds-home-page) main#main-content::before,
  body:has(ds-themed-home-page) main#main-content::before {
    min-height: 420px;
  }

  body:has(ds-home-page) main#main-content::after,
  body:has(ds-themed-home-page) main#main-content::after {
    top: 13rem;
    width: calc(100vw - 2rem);
    left: 1rem;
    font-size: 0.98rem;
    line-height: 1.55;
  }

  body:has(ds-home-page) main#main-content h1:first-of-type,
  body:has(ds-themed-home-page) main#main-content h1:first-of-type {
    left: 1rem;
    width: calc(100vw - 2rem);
  }

  body:has(ds-home-page) ds-search-form,
  body:has(ds-themed-home-page) ds-search-form {
    margin-top: -2.5rem;
  }
}

/* I-EMeRG production polish: use the real DSpace home-news hero, hide demo copy. */
#header-logo {
  content: url("/assets/images/pdtc-wide.png") !important;
  width: clamp(258px, 23vw, 378px) !important;
  height: 68px !important;
  object-fit: contain !important;
  object-position: left center;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  filter: none !important;
}

nav#header-left::after,
#header-left::after {
  content: "" !important;
  display: none !important;
}

#main-site-header .navbar-brand,
#main-site-header #header-left a,
#main-site-header #header-left button {
  min-width: clamp(258px, 23vw, 378px);
}

#main-site-header::before,
header#main-site-header::before {
  content: none !important;
  display: none !important;
}

body:has(ds-home-page) main#main-content::before,
body:has(ds-home-page) main#main-content::after,
body:has(ds-themed-home-page) main#main-content::before,
body:has(ds-themed-home-page) main#main-content::after {
  display: none !important;
  content: none !important;
}

body:has(ds-home-page) main#main-content,
body:has(ds-themed-home-page) main#main-content {
  overflow: hidden;
}

ds-home-news .background-image-container {
  min-height: clamp(500px, 58vh, 650px) !important;
  margin-top: 0 !important;
  position: relative;
  display: flex !important;
  align-items: center;
  background:
    linear-gradient(90deg, rgba(10, 16, 25, 0.74) 0%, rgba(10, 16, 25, 0.58) 42%, rgba(255, 255, 255, 0.16) 72%, rgba(255, 255, 255, 0.34) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.56)),
    url("/assets/images/library-cover.jpg") center/cover no-repeat !important;
  border-bottom: 1px solid rgba(23, 59, 99, 0.12);
}

ds-home-news .background-image,
ds-home-news picture.background-image,
ds-home-news .credits {
  display: none !important;
}

ds-home-news .container {
  position: relative;
  z-index: 2;
}

ds-home-news .home-news-content {
  max-width: 740px;
  margin: 0 !important;
  padding: clamp(2rem, 6vw, 4.5rem) 0 !important;
  color: var(--imerg-ink) !important;
  text-shadow: none;
}

ds-home-news .home-news-content > * {
  display: block !important;
}

ds-home-news .home-news-content .d-flex {
  display: block !important;
}

ds-home-news .home-news-content .d-flex > div {
  display: block !important;
}

ds-home-news .home-news-content h1 {
  display: block !important;
  margin: 0 !important;
  color: transparent !important;
  font-size: 0 !important;
  line-height: 1 !important;
}

ds-home-news .home-news-content h1::before {
  content: "I-EMeRG";
  display: block;
  color: #fff;
  font-size: clamp(2.8rem, 5.4vw, 5.25rem);
  font-weight: 920;
  line-height: 0.92;
  letter-spacing: 0;
  text-shadow:
    0 1px 0 #d9e3ec,
    0 3px 0 #8da0b3,
    0 6px 0 #4d5f73,
    0 10px 18px rgba(0, 0, 0, 0.42),
    0 22px 34px rgba(0, 0, 0, 0.22);
}

ds-home-news .home-news-content h1::after {
  content: "Digital Library";
  display: block;
  margin-top: 0.2rem;
  color: var(--imerg-green);
  font-size: clamp(1.7rem, 3.6vw, 3.25rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 12px 26px rgba(0, 0, 0, 0.2);
}

ds-home-news .home-news-content p,
ds-home-news .home-news-content ul {
  display: none !important;
}

ds-home-news .home-news-content .d-flex > div:first-child::after {
  content: "Knowledge for Community-Driven Change\A A curated repository by Bala Vikasa for NGOs, changemakers, researchers, and development professionals.\A Explore e-books, research articles, field resources, and learning materials.";
  white-space: pre-line;
  display: block;
  max-width: 700px;
  margin-top: 1.25rem;
  color: #fff;
  font-size: clamp(1.02rem, 1.35vw, 1.28rem);
  font-weight: 620;
  line-height: 1.65;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.42);
}

body:has(ds-home-page) main#main-content h1:first-of-type,
body:has(ds-themed-home-page) main#main-content h1:first-of-type {
  position: static !important;
  width: auto !important;
}

body:has(ds-home-page) ds-search-form,
body:has(ds-themed-home-page) ds-search-form {
  margin-top: -3.25rem !important;
}

@media (max-width: 991px) {
  #main-site-header::before,
  header#main-site-header::before {
    display: none;
  }

  #header-logo {
    width: 240px !important;
  }
}

@media (max-width: 767px) {
  #header-logo {
    width: 190px !important;
    height: 54px !important;
  }

  ds-home-news .background-image-container {
    min-height: 520px !important;
    align-items: flex-start;
    padding-top: 2.5rem;
  }

  ds-home-news .home-news-content::before {
    font-size: clamp(2.7rem, 13vw, 4rem);
  }

  ds-home-news .home-news-content::after {
    font-size: 1rem;
    line-height: 1.55;
  }
}

/* Final I-EMeRG hero correction */
ds-home-news .home-news-content h1::after {
  color: #d64227 !important;
}

ds-home-news .home-news-content .d-flex > div:first-child::after {
  color: #ffffff !important;
  font-weight: 800 !important;
  text-shadow: 0 2px 12px rgba(0,0,0,.38);
}
