/* Load shared and page-specific stylesheets. */

/* Shared colours, typography and layout variables. */
:root {
  --green-deep:   #0F6A0B;
  --green-ink:    #083B06;
  --green-bright: #20B015;
  --mist:         #EDF7E9;
  --white:        #FFFFFF;
  --ink:          #1A2B19;
  --ink-soft:     #44564A;

  --brand-tint: linear-gradient(180deg, rgba(8,59,6,.62), rgba(8,59,6,.78));
  --brand-glow: radial-gradient(circle at 70% 20%, #2a9a21, transparent 55%);

  --font-heading: "Source Serif 4", "Noto Serif Sinhala", Georgia, serif;
  --font-body:    "Nunito Sans", "Noto Sans Sinhala", system-ui, sans-serif;

  --header-height: 76px;
  --pad-x: clamp(16px, 3.5vw, 48px);
}


/* BASE SETTINGS. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--white);
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--green-deep);
}

:focus-visible {
  outline: 3px solid var(--green-bright);
  outline-offset: 3px;
}
.site-header :focus-visible,
.site-footer :focus-visible {
  outline-color: var(--white);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--white);
  color: var(--green-deep);
  font-weight: 700;
}
.skip-link:focus {
  left: 8px;
}


/* HEADER. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  color: var(--white);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  background: var(--brand-tint), var(--brand-glow);
  background-color: var(--green-ink);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  padding: 8px var(--pad-x);
}

.badge-circle {
  display: block;
  width: auto;
  height: 60px;
}
.badge-circle img {
  width: auto;
  height: 100%;
  object-fit: contain;
}
.badge-circle--large {
  height: 88px;
}
.badge-link {
  display: inline-block;
  border-radius: 6px;
}

.main-nav ul {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.main-nav a {
  display: block;
  padding: 10px 14px;
  border-radius: 6px;
  color: var(--white);
  font-weight: 600;
  text-decoration: none;
}
.main-nav a:hover {
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 -3px 0 var(--green-bright);
}
.main-nav a[aria-current="page"] {
  box-shadow: inset 0 -3px 0 var(--green-bright);
}

.nav-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.nav-toggle-label {
  display: none;
}


/* THE NEWS PAGE (PC & TABLET DEFAULT VIEW UNCHANGED). */
.news-main {
  padding: clamp(40px, 6vw, 72px) var(--pad-x) clamp(64px, 9vw, 112px);
  max-width: 1360px;
  margin-inline: auto;
}

.news-section + .news-section {
  margin-top: clamp(56px, 8vw, 104px);
}

.news-section {
  scroll-margin-top: calc(var(--header-height) + 12px);
}

/* Render news cards and pagination. */
.band {
  position: relative;
  padding: 16px 24px;
  background: linear-gradient(to right,
              var(--green-deep),
              var(--green-deep) 55%,
              transparent 100%);
}
.band::before,
.band::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(to right,
              var(--green-bright),
              var(--green-bright) 35%,
              transparent 100%);
}
.band::before { top: 0; }
.band::after  { bottom: 0; }

.band h2 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.2rem);
  line-height: 1.2;
  color: var(--white);
}

/* Mobile news carousel and slide controls. */
.slider-wrap {
  position: relative;
}

/* Mobile news card layout and navigation. */
.slide-btn {
  display: none;
}

/* Render news cards and pagination. */
.news-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(20px, 2.4vw, 32px);
  margin: 36px 0 0;
  padding: 0;
  list-style: none;
}

.news-item {
  position: relative;
}
.news-item:hover,
.news-item:focus-within {
  z-index: 3;
}

/* C. ONE NEWS BLOCK. */
.news-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border-radius: 18px;
  background: var(--white);
  border: 1px solid rgba(15, 106, 11, 0.16);
  box-shadow: 0 6px 18px rgba(15, 106, 11, 0.08);
  color: inherit;
  text-decoration: none;
  transition: transform 0.35s ease, box-shadow 0.5s ease, border-color 0.5s ease;
}

.news-card:focus-visible {
  outline: none;
  transform: scale(1.04);
  border-color: rgba(32, 176, 21, 0.75);
  box-shadow:
    0 0 0 1px rgba(32, 176, 21, 0.5),
    0 0 22px 4px rgba(32, 176, 21, 0.42),
    0 0 52px 10px rgba(32, 176, 21, 0.2);
}
@media (hover: hover) {
  .news-card:hover {
    transform: scale(1.04);
    border-color: rgba(32, 176, 21, 0.75);
    box-shadow:
      0 0 0 1px rgba(32, 176, 21, 0.5),
      0 0 22px 4px rgba(32, 176, 21, 0.42),
      0 0 52px 10px rgba(32, 176, 21, 0.2);
  }
}

.news-thumb {
  aspect-ratio: 4 / 3;
  background: linear-gradient(160deg, #cfe9c9, #9fd496);
}
.news-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.news-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px 20px;
}
.news-date {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--green-deep);
}
.news-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  line-height: 1.35;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.news-summary {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-empty {
  margin: 36px 0 0;
  padding: 32px 20px;
  border: 1px dashed rgba(15, 106, 11, 0.35);
  border-radius: 18px;
  text-align: center;
  color: var(--ink-soft);
}

/* D. SCROLL ANIMATION. */
.reveal-on .news-item {
  opacity: 0;
  transform: translateY(32px) scale(0.97);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.reveal-on .news-item.is-in {
  opacity: 1;
  transform: none;
  transition-delay: calc(var(--col, 0) * 90ms);
}

/* E. PAGE NUMBERS. */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: clamp(40px, 6vw, 64px);
}
.page-link,
.page-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
}
.page-link {
  color: var(--green-deep);
  background: var(--white);
  border: 2px solid rgba(15, 106, 11, 0.35);
  transition: box-shadow 0.4s ease, border-color 0.4s ease, background 0.3s ease;
}
.page-link:hover,
.page-link:focus-visible {
  border-color: var(--green-bright);
  box-shadow: 0 0 14px 2px rgba(32, 176, 21, 0.4);
}
.page-link[aria-current="page"] {
  color: var(--white);
  background: var(--green-deep);
  border-color: var(--green-deep);
}
.page-dots {
  color: var(--ink-soft);
}

/* F. THE "<< Back" BUTTON. */
.news-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  padding: 10px 22px 10px 16px;
  border-radius: 999px;
  background: var(--green-deep);
  color: var(--white);
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  transition: transform 0.3s ease, box-shadow 0.4s ease;
}
.news-back-btn .arrow {
  display: inline-block;
  font-size: 1.2em;
  line-height: 1;
  transition: transform 0.3s ease;
}
.news-back-btn:hover,
.news-back-btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 0 0 2px var(--green-bright), 0 0 22px 4px rgba(32, 176, 21, 0.55);
}
.news-back-btn:hover .arrow,
.news-back-btn:focus-visible .arrow {
  transform: translateX(-6px);
}


/* FOOTER. */
.site-footer {
  background: var(--green-deep);
  color: var(--white);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px clamp(24px, 4vw, 64px);
  padding: 36px var(--pad-x);
}
.footer-links,
.footer-contact {
  font-size: 0.95rem;
  line-height: 1.5;
}

.footer-brand {
  display: flex;
  align-items: center;
  align-self: center;
  gap: 16px;
}
.footer-brand p {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.35;
}

.site-footer h2 {
  margin: 0 0 8px;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  line-height: 1.3;
}
.site-footer a {
  color: var(--white);
  text-underline-offset: 4px;
}
.site-footer a:hover {
  color: #d6f5d2;
}

.quick-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 32px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.social-links {
  display: flex;
  gap: 18px;
  margin: 0 0 4px;
  padding: 0;
  list-style: none;
}
.footer-contact address {
  margin: 0 0 4px;
  font-style: normal;
}
.footer-contact p {
  margin: 0;
}

.footer-bottom {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 18px var(--pad-x);
  background: var(--green-ink);
}
.designer-credit {
  grid-column: 2;
  margin: 0;
  font-size: 0.95rem;
  text-align: center;
}
.last-updated {
  grid-column: 3;
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.8;
  text-align: right;
}


/* Responsive layout for tablets and phones. */

/* Tablets keep the 3-column grid. */
@media (max-width: 1100px) {
  .news-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Mobile news carousel and slide controls. */
@media (max-width: 760px) {
  .news-main {
    padding-top: 24px;
    padding-bottom: 48px;
    overflow-x: hidden;
  }

  .news-section + .news-section {
    margin-top: 40px;
  }

  .band {
    padding: 12px 16px;
  }
  .band h2 {
    font-size: 1.35rem;
  }

  /* Mobile news carousel and slide controls. */
  .slider-wrap {
    position: relative;
    margin-top: 20px;
  }

  /* Soft white/blur gradient on right side so the peeking card looks blurred. */
  .slider-wrap::after {
    content: "";
    position: absolute;
    top: 0;
    right: -2px;
    bottom: 12px;
    width: 38px;
    pointer-events: none;
    z-index: 4;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.88));
    backdrop-filter: blur(1.5px);
    -webkit-backdrop-filter: blur(1.5px);
  }

  /* Horizontal sliding track. */
  .news-grid {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    gap: 14px !important;
    margin: 0 !important;
    padding: 10px 44px 18px 6px !important;
    scrollbar-width: none; /* Hide ugly scrollbar on Firefox. */
  }
  .news-grid::-webkit-scrollbar {
    display: none; /* Hide scrollbar on Chrome/Safari. */
  }

  /* Each card takes ~74% of screen width so 1 card + part of 2nd card is shown. */
  .news-item {
    flex: 0 0 74% !important;
    max-width: 260px !important;
    scroll-snap-align: start;
    opacity: 1 !important;
    transform: none !important;
    transition: filter 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
  }

  /* Non-active peeking cards are slightly blurred & dimmed until slid into view. */
  .news-item.peek-blur {
    filter: blur(1.2px);
    opacity: 0.72 !important;
    transform: scale(0.96) !important;
  }

  /* Mobile news card layout and navigation. */
  .news-card {
    border-radius: 14px;
  }
  .news-thumb {
    aspect-ratio: 16 / 10; /* Shorter image height so card is compact. */
  }
  .news-body {
    padding: 12px 14px 14px;
    gap: 4px;
  }
  .news-date {
    font-size: 0.76rem;
  }
  .news-title {
    font-size: 1rem;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }
  .news-summary {
    font-size: 0.84rem;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  /* Mobile news card layout and navigation. */
  .slide-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 45%;
    transform: translateY(-50%);
    z-index: 6;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid var(--green-bright);
    background: rgba(8, 59, 6, 0.88);
    color: var(--white);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
    padding: 0;
    line-height: 1;
  }
  .slide-btn:active {
    background: var(--green-bright);
  }
  .slide-btn--prev {
    left: -6px;
  }
  .slide-btn--next {
    right: 2px;
  }
}

/* Primary navigation links. */
@media (max-width: 900px) {
  .nav-toggle-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    cursor: pointer;
  }
  .nav-toggle-label span,
  .nav-toggle-label span::before,
  .nav-toggle-label span::after {
    display: block;
    width: 26px;
    height: 3px;
    border-radius: 2px;
    background: var(--white);
  }
  .nav-toggle-label span {
    position: relative;
  }
  .nav-toggle-label span::before,
  .nav-toggle-label span::after {
    content: "";
    position: absolute;
    left: 0;
  }
  .nav-toggle-label span::before { top: -8px; }
  .nav-toggle-label span::after  { top: 8px; }

  .nav-toggle:focus-visible + .nav-toggle-label {
    outline: 3px solid var(--white);
    outline-offset: 2px;
  }

  .main-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    padding: 8px 20px 20px;
    background: var(--green-ink);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.18);
  }
  .nav-toggle:checked ~ .main-nav {
    display: block;
  }
  .main-nav ul {
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .footer-inner {
    flex-direction: column;
  }
  .footer-brand {
    align-self: flex-start;
  }
  .footer-bottom {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .designer-credit,
  .last-updated {
    grid-column: 1;
    text-align: center;
  }
}

/* Reading progress indicator and back-to-top control. */
.read-bar { position: fixed; top: 0; left: 0; width: 100%; height: 4px; z-index: 1000; pointer-events: none;
  background: linear-gradient(90deg, #45b52e, #1b6e12); transform-origin: left; transform: scaleX(var(--read, 0)); }
.to-top { position: fixed; right: 22px; bottom: 22px; z-index: 900; width: 46px; height: 46px; border-radius: 50%; border: 2px solid #fff; cursor: pointer;
  background: #1b6e12; color: #fff; font-size: 1.3rem; box-shadow: 0 0 16px rgba(46, 160, 30, .7); opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; }
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { transform: translateY(-3px); }

/* Mobile news carousel and slide controls. */
@media (max-width: 760px) {
  .news-main {
    padding-top: 24px;
    padding-bottom: 48px;
    overflow-x: hidden;
  }

  .news-section + .news-section {
    margin-top: 40px;
  }

  .band {
    padding: 12px 16px;
  }
  .band h2 {
    font-size: 1.35rem;
  }

  /* Mobile news carousel and slide controls. */
  .slider-wrap {
    position: relative;
    margin-top: 20px;
  }

  /* Soft white/blur gradient on right side so the peeking card looks blurred. */
  .slider-wrap::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0; /* Changed from -2px to 0 for better alignment. */
    bottom: 12px;
    width: 45px; /* Increased width slightly for a smoother fade. */
    pointer-events: none;
    z-index: 4;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.95));
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }

  /* Horizontal sliding track. */
  .news-grid {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    gap: 16px !important; /* Increased gap between cards. */
    margin: 0 !important;
    padding: 10px 44px 24px 12px !important; /* Adjusted padding to make room for buttons and scrollbar. */
    scrollbar-width: none; /* Hide ugly scrollbar on Firefox. */
  }
  .news-grid::-webkit-scrollbar {
    display: none; /* Hide scrollbar on Chrome/Safari. */
  }

  /* Each card takes ~80% of screen width so 1 card + part of 2nd card is shown. */
  .news-item {
    flex: 0 0 80% !important; /* Increased width to show more of the main card. */
    max-width: 300px !important; /* Increased max-width. */
    scroll-snap-align: center; /* Center the card when snapping. */
    opacity: 1 !important;
    transform: none !important;
    transition: filter 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
  }

  /* Non-active peeking cards are slightly blurred & dimmed until slid into view. */
  .news-item.peek-blur {
    filter: blur(1.5px);
    opacity: 0.65 !important;
    transform: scale(0.94) !important;
  }

  /* Mobile news card layout and navigation. */
  .news-card {
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    height: 100%; /* Ensure card fills the item height. */
  }
  .news-thumb {
    aspect-ratio: 16 / 9; /* Mobile news card layout and navigation. */
  }
  .news-body {
    padding: 14px 16px 18px; /* Adjusted padding. */
    gap: 6px;
    flex-grow: 1; /* Allow text body to take remaining space. */
  }
  .news-date {
    font-size: 0.8rem;
  }
  .news-title {
    font-size: 1.1rem;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    word-break: break-word; /* Prevent long words from breaking layout. */
  }
  .news-summary {
    font-size: 0.9rem;
    -webkit-line-clamp: 3; /* Allow 3 lines for summary. */
    line-clamp: 3;
    word-break: break-word; /* Prevent long words from breaking layout. */
  }

  /* Mobile news card layout and navigation. */
  .slide-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 45%;
    transform: translateY(-50%);
    z-index: 6;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1.5px solid var(--green-bright);
    background: rgba(8, 59, 6, 0.9);
    color: var(--white);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    padding: 0;
    line-height: 1;
    transition: background 0.2s, transform 0.1s;
  }
  .slide-btn:active {
    background: var(--green-bright);
    transform: translateY(-50%) scale(0.95);
  }
  .slide-btn--prev {
    left: 4px; /* Moved slightly inward. */
  }
  .slide-btn--next {
    right: 4px; /* Moved slightly inward. */
  }
}

/* Mobile news carousel and slide controls. */


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

/* Primary navigation links. */
@media (max-width: 900px) {
  .main-nav { max-height: calc(100vh - var(--header-height)); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
}
@supports (height: 100dvh) {
  @media (max-width: 900px) {
    .main-nav { max-height: calc(100dvh - var(--header-height)); }
  }
}

/* Very long words in a news title or summary can no longer break the card. */
@media (max-width: 1100px) {
  .news-title, .news-summary { overflow-wrap: anywhere; }
}

/* Phones. */
@media (max-width: 760px) {
  .to-top { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }   /* Keeps away from the phone's bottom bar. */
  .pagination { gap: 8px; margin-top: 32px; }
  .news-back-btn { margin-bottom: 20px; padding: 9px 20px 9px 14px; }
}

/* Very small phones (narrower than 380px). */
@media (max-width: 380px) {
  .band h2 { font-size: 1.2rem; }
  .news-item { flex: 0 0 86% !important; }
  .slide-btn { width: 32px; height: 32px; }
}
