/* =========================================================
   Announcements Widget
   ========================================================= */

/* ---- Theme hooks ---- */
:root {
  --primaryColor: #1c2b39;
  --secondaryColor: #62bb46;
}

/* ---- Base typography ---- */
#AnnouncementsWidget * {
  font-family: Montserrat, Helvetica, Arial, sans-serif;
}
#AnnouncementsWidget :is(h1, h2, h3, h4, h5, h6) {
  text-transform: uppercase;
}

/* ---- Shell ---- */
.ann-wrap {
  --ann-text: var(--primaryColor);
  --ann-accent: var(--secondaryColor);
  --ann-muted: rgba(28, 43, 57, 0.65);
  --ann-card-bg: #fff;

  --ann-gap: 24px; /* default grid gap for non-featured */
  --ann-body-h: 72px; /* fixed CTA height (tweak if needed) */
  --carousel-card-size: clamp(250px, 50vw, 400px);

  color: var(--ann-text);
}

.ann-section-title {
  margin: 32px 0 16px;
  font-weight: 700;
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: 0.02em;
  color: var(--ann-accent);
}

/* ---- Generic grid ---- */
.ann-grid {
  display: grid;
  gap: var(--ann-gap);
}

/* =========================================================
   FEATURED (grid areas)
   ========================================================= */
.ann-grid--featured {
  --g: clamp(12px, 1.4vw, 18px);
  --H: var(--ann-body-h);

  grid-template-columns:
    calc(
      (2 * (((100% - var(--g)) - (16 / 9) * (var(--H) + 2 * var(--g))) / 3)) +
        (16 / 9) * (var(--H) + 2 * var(--g))
    )
    calc(((100% - var(--g)) - (16 / 9) * (var(--H) + 2 * var(--g))) / 3);

  grid-template-rows: auto var(--H) auto auto;
  column-gap: var(--g);
  row-gap: var(--g);
  grid-template-areas:
    "i1 i2"
    "i1 d2"
    "i1 i3"
    "d1 d3";
}

/* Area hooks */
.feat-i1 {
  grid-area: i1;
}
.feat-d1 {
  grid-area: d1;
}
.feat-i2 {
  grid-area: i2;
}
.feat-d2 {
  grid-area: d2;
} /* <- fixed missing dot */
.feat-i3 {
  grid-area: i3;
}
.feat-d3 {
  grid-area: d3;
}

/* =========================================================
   CAMPUS GRID
   ========================================================= */
.ann-grid--campus {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* ---------------- Cards ---------------- */
.ann-card {
  background: var(--ann-card-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------------- Media (16:9 everywhere) ---------------- */
.ann-media {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background: #f3f4f6;
  overflow: hidden;
  text-decoration: none;
}
.ann-media img,
.ann-img.placeholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Hover zoom (respect reduced-motion) */
.ann-media > img {
  transform: translateZ(0);
  transition: transform 0.65s ease;
  will-change: transform;
}
.ann-card:hover .ann-media > img,
.ann-media:focus-visible > img {
  transform: scale(1.025);
}
@media (prefers-reduced-motion: reduce) {
  .ann-media > img {
    transition: none;
  }
}

/* ---------------- Placeholder banner ---------------- */
.ann-img.placeholder {
  box-sizing: border-box;
  display: grid;
  place-items: center;
  background-color: var(--secondaryColor);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Ccircle cx='2' cy='2' r='1' fill='%23ffffff' fill-opacity='0.15'/%3E%3Ccircle cx='12' cy='12' r='1' fill='%23ffffff' fill-opacity='0.25'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 20px 20px;
  padding: clamp(14px, 2vw, 28px);
  outline: 1px solid rgba(255, 255, 255, 0.95);
  outline-offset: -10px;
}
.placeholder-text {
  color: #fff;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  text-align: center;
  line-height: 1.15;
  font-size: clamp(1.25rem, 3.8vw, 1.75rem);
}

/* ---------------- CTA text blocks ---------------- */
.ann-body {
  padding: 12px 14px;
  height: auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}
.ann-body:hover {
  text-decoration: underline;
}
.ann-body > * {
  margin: 0 !important;
}

.ann-title {
  font-weight: 800 !important;
  font-size: 20px !important;
  line-height: 1.25 !important;
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
}
.ann-blurb {
  color: var(--ann-muted);
  line-height: 1.35;
  font-size: 14px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

/* Optional buttons inside CTAs */
.ann-cta .btn,
.ann-body .btn {
  display: inline-block;
  padding: 10px 14px;
  background: var(--ann-accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}
.ann-cta .btn:hover,
.ann-body .btn:hover {
  filter: brightness(0.95);
}

/* ---------------- Empty state ---------------- */
.ann-empty {
  margin: 24px 0 40px;
  padding: 24px;
  background: #f9fafb;
  color: var(--ann-muted);
  text-align: center;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 900px) {
  .ann-grid--featured {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    column-gap: 0;
    row-gap: 18px;
    grid-template-areas:
      "i1" "d1"
      "i2" "d2"
      "i3" "d3";
  }
  .ann-body {
    height: auto;
  }
}
@media (max-width: 600px) {
  .ann-title {
    font-size: 18px;
  }
  .ann-img.placeholder {
    padding: clamp(12px, 3vw, 20px);
    outline-offset: -8px;
  }
}

/* Campus grid (desktop) */
.ann-grid--campus {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
/* Campus grid → one column on small screens */
@media (max-width: 900px) {
  .ann-grid--campus {
    grid-template-columns: 1fr;
    row-gap: 18px;
    column-gap: 0;
  }
}

/* =========================================================
Carousel mode (only when .carousel is present)
   ========================================================= */

/* Outer widget shell provides padding/positioning in carousel */
#AnnouncementsWidget.carousel {
  padding: 2em;
  box-sizing: border-box;
  position: relative;
}

/* Inner horizontal scroller – only scrolls in carousel mode */
#AnnouncementsWidget.carousel .ann-scroller {
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
#AnnouncementsWidget.carousel .ann-scroller::-webkit-scrollbar {
  display: none;
}

/* Inline layout inside the scroller */
#AnnouncementsWidget.carousel .ann-scroller > .ann-wrap {
  display: inline-flex;
}

#AnnouncementsWidget.carousel .ann-scroller > .ann-wrap .ann-section-title {
  writing-mode: sideways-lr;
  text-orientation: sideways;
  font-size: clamp(0.65rem, 1.5vw, 1rem);
  text-align: end;
  margin: 0;
  padding-right: var(--ann-gap);
  color: var(--ann-muted);
  opacity: 0.65;
}
#AnnouncementsWidget.carousel
  .ann-scroller
  > .ann-wrap
  .ann-section-title:nth-of-type(2) {
  margin-left: calc(1.5 * var(--ann-gap));
}

/* Grid tweaks only in carousel */
#AnnouncementsWidget.carousel .ann-scroller .ann-grid--featured {
  grid-template-areas: "i1 i2 i3" "d1 d2 d3";
}
#AnnouncementsWidget.carousel .ann-scroller .ann-grid--campus {
  display: flex;
  gap: var(--ann-gap);
}
#AnnouncementsWidget.carousel .ann-scroller .ann-grid--campus .ann-body {
  margin-top: calc(0.5 * var(--ann-gap)) !important;
}

#AnnouncementsWidget.carousel .ann-scroller .ann-grid {
  grid-template-columns: unset;
  grid-template-rows: unset;
  column-gap: var(--ann-gap);
  row-gap: calc(0.5 * var(--ann-gap));
  padding-bottom: 2em;
}
#AnnouncementsWidget.carousel .ann-scroller .ann-grid .ann-card {
  width: var(--carousel-card-size);
  display: flex;
  flex-direction: column;
}
#AnnouncementsWidget.carousel .ann-scroller .ann-grid .ann-body {
  padding: 0.5rem;
  margin: 0;
}
#AnnouncementsWidget.carousel .ann-scroller .ann-grid .ann-body * {
  padding: 0;
  margin: 0;
  width: var(--carousel-card-size);
}
#AnnouncementsWidget.carousel .ann-scroller .ann-grid .ann-title {
  font-size: clamp(0.8rem, 1vw, 1rem) !important;
}
#AnnouncementsWidget.carousel .ann-scroller .ann-grid .ann-blurb {
  font-size: clamp(0.75rem, 0.9vw, 0.8rem);
}

/* Progress bar – visible only in carousel mode */
#AnnouncementsWidget .ann-progress {
  display: none;
}
#AnnouncementsWidget.carousel .ann-progress {
  display: block;
  position: absolute;
  left: 2em;
  right: 2em;
  bottom: 0.75em;
  height: 4px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}
#AnnouncementsWidget .ann-progress__bar {
  height: 100%;
  width: 100%;
  background: var(--ann-accent, #62bb46);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 60ms linear;
}

/* =========================================================
   Grid mode defaults (when NOT .carousel)
   ========================================================= */

/* Make the wrapper behave like a normal block and don't scroll */
#AnnouncementsWidget:not(.carousel) .ann-scroller {
  overflow: visible;
}
#AnnouncementsWidget:not(.carousel) .ann-scroller > .ann-wrap {
  display: block;
}
#AnnouncementsWidget:not(.carousel) .ann-progress,
#AnnouncementsWidget:not(.carousel) .section-header-wrapper {
  display: none;
}

/* =========================================================
   Progress bar (outside scroller)
   ========================================================= */
#AnnouncementsWidget .ann-progress {
  position: absolute;
  left: 2em;
  right: 2em;
  bottom: 0.75em;
  height: 4px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}
#AnnouncementsWidget .ann-progress__bar {
  height: 100%;
  width: 100%;
  background: var(--ann-accent, #62bb46);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 60ms linear;
}

/* =========================================================
   Section header (outside scroller)
   ========================================================= */
#AnnouncementsWidget .section-header-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  gap: 2rem;
}
#AnnouncementsWidget .section-title--small {
  font-size: 0.875rem;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.25rem;
}
#AnnouncementsWidget .section-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
}
#AnnouncementsWidget .btn {
  color: #1c2b39;
  background-color: transparent;
  border-radius: 200px;
  border: 2px solid rgba(28, 43, 57, 0.75);
  text-decoration: none;
  padding: 1rem 1.5rem;
  transition: all 0.3s ease;
}
#AnnouncementsWidget :is(.btn:hover, .btn:focus) {
  background-color: #1c2b39;
  border-color: #1c2b39;
  color: #ffffff;
}

@media (max-width: 900px) {
  #AnnouncementsWidget .section-header-wrapper {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  #AnnouncementsWidget .section-title {
    font-size: 2rem;
  }
}
