@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700&display=swap');

@font-face {
  font-family: 'CairoBold';
  src: url('../fonts/Cairo-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'arabswell_2';
  src: url('../fonts/arabswell_2.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'CairoLight';
  src: url('../fonts/Cairo-Light.ttf') format('truetype');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-alt: #f8f2eb;
  --primary: #955549;
  --primary-dark: #7a4038;
  --text: #2e221f;
  --muted: #6f5f59;
  --border: #e9ddd7;
  --shadow: 0 12px 32px rgba(55, 31, 20, 0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
  background: linear-gradient(135deg, #fffaf7 0%, var(--bg) 100%);
  color: var(--text);
  line-height: 1.7;
  direction: rtl;
  position: relative;
}
body.drawer-open,
body.viewer-open {
  overflow: hidden;
  height: 100%;
  touch-action: none;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.container {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  isolation: isolate;
  background: rgba(255, 248, 244, 0.56);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 8px 30px rgba(80, 45, 34, 0.08);
  overflow: visible;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  gap: 1rem;
  position: relative;
  direction: ltr;
}

/* scroll progress overlay (1px high) */
.header-row {
  --scroll-progress: 0%;
}

.header-row::before {
  content: '';
  position: absolute;
  left: 0;
  right: auto;
  bottom: 0;
  height: 1px;
  width: var(--scroll-progress, 0%);
  background: #000;
  pointer-events: none;
  transition: width 120ms linear;
  z-index: 12;
}
.brand-wrap {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  direction: rtl;
}
.brand h1 {
  margin: 0;
  font-size: 1.495rem;
  color: var(--primary-dark);
  font-family: 'arabswell_2', 'CairoBold', 'Segoe UI', Tahoma, Arial, sans-serif;
  line-height: 1.2;
  transform: none;
  text-align: center;
}

.brand p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.header-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.header-icon img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* logo zoom animation when loader finishes */
@keyframes logoZoom {
  from { transform: scale(1.12); }
  to { transform: scale(1); }
}

.header-icon img.logo-animate {
  animation: logoZoom 420ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  will-change: transform;
}

.drawer-links button,
.mobile-menu-toggle,
.drawer-close {
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: 0.2s ease;
}
.drawer-links button {
  color: #5f463f;
}

.drawer-links button:hover {
  background: linear-gradient(135deg, rgba(149, 85, 73, 0.08) 0%, rgba(149, 85, 73, 0.14) 100%);
  color: #6d433d;
  box-shadow: inset 0 0 0 1px rgba(149, 85, 73, 0.12);
  transform: translateX(-2px);
}

.drawer-links button.active {
  background: linear-gradient(135deg, rgba(149, 85, 73, 0.22) 0%, rgba(149, 85, 73, 0.34) 100%);
  color: #5c2f28;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(149, 85, 73, 0.2);
}

.mobile-menu-toggle,
.ai-chat-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: var(--primary-dark);
  background: rgba(149,85,73,0.12);
  border: 1px solid rgba(149,85,73,0.18);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35);
  cursor: pointer;
  position: relative;
  transition: background 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.mobile-menu-toggle {
  display: inline-flex;
  font-size: 1rem;
}

.mobile-menu-toggle:hover,
.ai-chat-link:hover {
  background: rgba(149,85,73,0.18);
  transform: translateY(-1px);
}

.ai-chat-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.hamburger {
  display: inline-block;
  width: 22px;
  height: 18px;
  position: relative;
}

.hamburger span,
.hamburger span::before,
.hamburger span::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.hamburger span {
  top: 50%;
  transform: translateY(-50%);
}

.hamburger span::before {
  top: -7px;
}

.hamburger span::after {
  top: 7px;
}

.mobile-menu-toggle.open .hamburger span {
  transform: rotate(45deg);
}

.mobile-menu-toggle.open .hamburger span::before {
  transform: translateY(7px) rotate(90deg);
}

.mobile-menu-toggle.open .hamburger span::after {
  opacity: 0;
}

.drawer {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  width: min(92vw, 320px);
  max-width: 320px;
  z-index: 40;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  overscroll-behavior: none;
}
.drawer.open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.drawer-panel {
  width: 100%;
  max-height: min(72dvh, 540px);
  background: #FFF8F4;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.16);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  
}

@media (min-width: 900px) {
  .drawer {
    width: 320px;
  }
}
.drawer-header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.3rem 1.1rem 1rem;
  border-bottom: 1px solid rgba(149, 85, 73, 0.14);
  
}
.drawer-header h3 {
  margin: 0;
  color: var(--primary-dark);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
}
.drawer-links {
  display: grid;
  gap: 0.4rem;
  padding: 0.85rem 0.8rem 1rem;
  font-family: 'CairoBold', 'Segoe UI', Tahoma, Arial, sans-serif;
}
.drawer-links button {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  text-align: right;
  padding: 0.95rem 1rem;
  border-radius: 16px;
  font-size: 0.98rem;
  font-weight: 700;
  width: 100%;
  color: var(--text);
  touch-action: manipulation;
}

.drawer-panel,
.drawer-links button,
.drawer-header h3 {
  font-family: 'CairoBold', 'Segoe UI', Tahoma, Arial, sans-serif;
}

.drawer-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(149, 85, 73, 0.12) 0%, rgba(149, 85, 73, 0.2) 100%);
  color: #8a5a4d;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}

.drawer-icon svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.drawer-links button:hover .drawer-icon {
  background: linear-gradient(135deg, rgba(149, 85, 73, 0.2) 0%, rgba(149, 85, 73, 0.3) 100%);
  color: var(--primary-dark);
  box-shadow: inset 0 0 0 1px rgba(149, 85, 73, 0.15);
}

.drawer-links button.active .drawer-icon {
  background: linear-gradient(135deg, var(--primary) 0%, #a6685a 100%);
  color: #fff;
  box-shadow: 0 8px 16px rgba(149, 85, 73, 0.22);
}

/* ==========================================================================
   CONTENT UI — rebuilt from scratch
   (Header / drawer above this point are untouched.)
   Same palette: --bg --surface --surface-alt --primary --primary-dark
   --text --muted --border --shadow
   ========================================================================== */

/* ---- placeholder / "coming soon" pages ---------------------------------- */
.placeholder-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  padding: 1rem 0;
}

.placeholder-card {
  width: min(100%, 560px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 2.2rem 1.75rem;
  text-align: center;
}

.placeholder-card h4 {
  margin: 0 0 0.6rem;
  color: var(--primary-dark);
  font-size: 1.25rem;
  font-family: 'CairoBold', 'Segoe UI', Tahoma, Arial, sans-serif;
}

.placeholder-card p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

/* ---- shared section shell layout ----------------------------------------- */
.section-shell {
  padding: 1.6rem 0 3rem;
}
.compact-shell {
  padding-top: 0;
  padding-bottom: 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

/* Page-level headers, e.g. "الإعلانات :" on their own section pages */
.section-shell > .section-header:not(.home-header) {
  margin-bottom: 1.4rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.section-header h3 {
  margin: 0;
  font-family: 'CairoBold', 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
  font-weight: 700;
  color: var(--primary-dark);
}

.section-shell > .section-header:not(.home-header) > h3:not(.home-date):not(.section-title-ornament) {
  font-size: clamp(1.3rem, 1.1rem + 1vw, 1.7rem);
  position: relative;
  padding-inline-start: 1rem;
}

.section-shell > .section-header:not(.home-header) > h3:not(.home-date):not(.section-title-ornament)::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 0.15em;
  bottom: 0.15em;
  width: 5px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
}

/* ---- home page: date banner ----------------------------------------------- */
.section-header.home-header {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 0;
  background: linear-gradient(135deg, rgba(255, 250, 246, 0.9) 0%, rgba(249, 238, 230, 0.75) 100%);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 1.5rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.6rem;
}

.section-header h3.home-date {
  font-weight: 700;
  color: var(--text);
  font-family: 'CairoBold', arabswell_2, 'Segoe UI', Tahoma, Arial, sans-serif;
  font-size: clamp(1.05rem, 0.9rem + 0.6vw, 1.32rem);
  text-align: center;
  margin: 0;
}

.section-header h3.home-date .num {
  color: var(--primary);
  font-weight: 800;
  margin: 0 0.25rem;
}

.section-header.home-header .section-divider {
  margin: 0;
}

/* Home mini-sections become their own cards */
.section-shell.compact-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 1.35rem 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.compact-shell + .compact-shell {
  margin-top: 1.4rem;
}

.compact-shell .section-header {
  margin-bottom: 1.1rem;
  justify-content: flex-start;
}

/* ---- decorative pill title used on home mini-sections --------------------- */
.section-header h3.section-title-ornament {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 1.05rem;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(149, 85, 73, 0.14) 0%, rgba(149, 85, 73, 0.06) 100%);
  color: var(--primary-dark);
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  box-shadow: inset 0 0 0 1px rgba(149, 85, 73, 0.14);
  position: relative;
  overflow: hidden;
}

.section-header h3.section-title-ornament::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(149, 85, 73, 0.18);
}

/* For the announcements mini-header, replace the small dot with the drawer icon */
.section-title-ornament.announcements-ornament::before,
.section-title-ornament.news-ornament::before,
.section-title-ornament.beststudent-ornament::before {
  display: none;
}
.announcement-ornament-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
}
.announcement-ornament-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}
/* reuse drawer-icon visual style but smaller */
.announcement-ornament-icon.drawer-icon {
  background: transparent;
  color: inherit;
  box-shadow: none;
}

.section-header h3.section-title-ornament::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 0%, rgba(255,255,255,0.8) 45%, transparent 90%);
  transform: translateX(-120%) skewX(-20deg);
  animation: none;
  pointer-events: none;
}

.section-header h3.section-title-ornament.shimmer-on::after {
  animation: shimmer-title 2.6s ease-in-out 1;
}

@keyframes shimmer-title {
  0% { transform: translateX(-120%) skewX(-20deg); }
  100% { transform: translateX(120%) skewX(-20deg); }
}

/* image loading shimmer */
.loading-shimmer {
  position: relative;
  overflow: hidden;
  background-color: var(--surface-alt);
}
.loading-shimmer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 0%, rgba(255,255,255,0.75) 45%, transparent 90%);
  transform: translateX(-120%) skewX(-20deg);
  animation: shimmer-title 1.6s linear infinite;
  pointer-events: none;
}
.loading-shimmer img {
  filter: blur(4.2px) saturate(0.9);
  transform: scale(1.02);
}

.section-divider {
  width: min(100%, 260px);
  height: 1px;
  margin: 0 auto;
  background: linear-gradient(90deg, transparent, rgba(149, 85, 73, 0.3), transparent);
}

/* ---- timetable + internal-laws panels ------------------------------------- */
.timings-panel {
  display: grid;
  gap: 1.5rem;
  align-items: start;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .timings-panel {
    grid-template-columns: minmax(260px, 340px) 1fr;
  }
}

.timings-control {
  display: grid;
  gap: 0.85rem;
  align-content: start;
  padding: 1.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.timings-control label {
  font-family: 'CairoBold', 'Segoe UI', Tahoma, Arial, sans-serif;
  font-weight: 700;
  color: var(--primary-dark);
  font-size: 0.98rem;
}

.timings-control select {
  width: 100%;
  min-height: 50px;
  padding: 0.85rem 1rem 0.85rem 2.4rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 1rem;
  font-family: 'CairoBold', 'Segoe UI', Tahoma, Arial, sans-serif;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%236f5f59' d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 1rem center;
  background-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.timings-control select:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(149, 85, 73, 0.18);
}

.timings-status {
  color: var(--muted);
  font-size: 0.93rem;
}

.timings-preview {
  display: grid;
  gap: 1.1rem;
  align-content: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 1.35rem;
  box-shadow: var(--shadow);
}

.timings-preview-header h4 {
  margin: 0;
  font-size: 1.12rem;
  color: var(--primary-dark);
  font-family: 'CairoBold', 'Segoe UI', Tahoma, Arial, sans-serif;
}

.timings-image-wrap {
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.timings-image-wrap img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.timings-actions {
  display: flex;
  justify-content: flex-start;
  margin: 0;
}

.timings-download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0 1.4rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  border-radius: 14px;
  font-family: 'CairoBold', 'Segoe UI', Tahoma, Arial, sans-serif;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 12px 26px rgba(149, 85, 73, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  margin: 0;
}

.timings-download-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(149, 85, 73, 0.22);
}

.timings-download-btn.disabled {
  pointer-events: none;
  opacity: 0.5;
  box-shadow: none;
}

/* internal laws list */
.laws-list {
  display: grid;
  gap: 1rem;
}

.laws-list-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.laws-list-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

@media (hover: hover) {
  .laws-list-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 32px rgba(80, 45, 34, 0.1);
  }
}

.laws-list-empty {
  padding: 1.5rem 1rem;
  border: 1px dashed var(--border);
  border-radius: 20px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.65);
}

.laws-file-icon {
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  font-family: 'CairoBold', 'Segoe UI', Tahoma, Arial, sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
  box-shadow: 0 8px 18px rgba(149, 85, 73, 0.22);
}

.laws-file-meta {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
  flex: 1;
}

.laws-file-meta strong {
  color: var(--primary-dark);
  font-size: 0.96rem;
  word-break: break-word;
  font-family: 'CairoBold', 'Segoe UI', Tahoma, Arial, sans-serif;
}

.laws-file-meta span {
  color: var(--muted);
  font-size: 0.86rem;
}

.laws-download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 1rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  border-radius: 12px;
  font-family: 'CairoBold', 'Segoe UI', Tahoma, Arial, sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.laws-download-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(149, 85, 73, 0.2);
}

/* ---- image lightbox --------------------------------------------------------- */
.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.image-viewer.open {
  display: flex;
}
.image-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(19, 12, 10, 0.82);
  backdrop-filter: blur(3px);
}
.image-viewer-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.02);
  box-shadow: none;
}
.image-viewer-stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 0;
  background: rgba(0,0,0,0.04);
}
.image-viewer-image {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.35);
  background: #fff;
  transition: transform 0.08s ease-out;
  transform-origin: center center;
  touch-action: none;
  user-select: none;
  cursor: grab;
  will-change: transform;
}
.image-viewer-image:active {
  cursor: grabbing;
}
.image-viewer-loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: 'CairoBold', 'Segoe UI', Tahoma, Arial, sans-serif;
  font-size: 0.98rem;
  background: rgba(18, 12, 10, 0.36);
  backdrop-filter: blur(2px);
  z-index: 12;
}
.image-viewer-loader::before {
  content: '';
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
  margin-inline-end: 0.7rem;
  vertical-align: middle;
}
.image-viewer.is-loading .image-viewer-loader {
  display: grid;
}
.image-viewer-loader[hidden] {
  display: none !important;
}
.image-viewer-toolbar {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  z-index: 1002;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.image-viewer-btn,
.image-viewer-close {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.96);
  color: var(--primary-dark);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(0,0,0,0.18);
  padding: 0;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.image-viewer-btn:hover,
.image-viewer-close:hover {
  background: #fff;
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(0,0,0,0.22);
}
.image-viewer-btn svg,
.image-viewer-close svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}
.image-viewer-zoom-in,
.image-viewer-zoom-out,
.image-viewer-reset {
  font-size: 1.2rem;
  font-weight: 700;
  font-family: 'CairoBold', 'Segoe UI', Tahoma, Arial, sans-serif;
}
.image-viewer-reset {
  width: auto;
  min-width: 52px;
  padding: 0 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
}
.image-viewer-close {
  position: static;
  z-index: 1003;
}
.image-viewer-download {
  position: static;
  z-index: 1003;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
@media (max-width: 640px) {
  .image-viewer {
    padding: 0;
  }
  .image-viewer-panel {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  .image-viewer-stage {
    width: 100vw;
    height: 100vh;
  }
  .image-viewer-toolbar {
    top: 0.55rem;
    right: 0.55rem;
    gap: 0.35rem;
  }
  .image-viewer-btn,
  .image-viewer-close {
    width: 38px;
    height: 38px;
  }
}

/* ==========================================================================
   ITEM LISTS / CARDS
   ========================================================================== */

.list-stack {
  display: grid;
  gap: 1.15rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  align-items: start;
}

.section-shell.compact-shell .list-stack {
  width: min(100%, 900px);
  margin-inline: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 1.25rem;
}

.section-shell.compact-shell .list-stack > .item-card {
  flex: 1 1 300px;
  width: min(100%, 320px);
  align-self: stretch;
}

/* home mini-lists read better a touch narrower */
#latest-announcements-list.list-stack,
#latest-news-list.list-stack,
#latest-best-students-list.list-stack {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.item-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 1.15rem;
  box-shadow: 0 10px 26px rgba(80, 45, 34, 0.07);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  min-width: 0;
}

@media (hover: hover) {
  .item-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 42px rgba(80, 45, 34, 0.14);
    border-color: rgba(149, 85, 73, 0.28);
  }
}

.item-card .item-title {
  margin: 0;
  font-size: 1.08rem;
  color: var(--primary-dark);
  line-height: 1.55;
  font-family: 'CairoBold', arabswell_2, 'Segoe UI', Tahoma, Arial, sans-serif;
}

/* ---- media (images) -------------------------------------------------------- */
.item-card .media-block {
  width: 100%;
  min-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  order: -1; /* image sits above the title, cover-style */
}
.item-card .thumb {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 150px;
  margin: 0;
  border-radius: 16px;
  background: var(--surface-alt);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  box-shadow: none;
}

.item-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  background: #fff;
  display: block;
}

.item-card .image-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  margin: 0;
  align-items: stretch;
}

.item-card:has(.image-gallery .mini-thumb + .mini-thumb) .image-gallery {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.item-card:has(.image-gallery .mini-thumb + .mini-thumb) .mini-thumb {
  aspect-ratio: 4 / 3;
}

.item-card .mini-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  box-shadow: none;
}
.item-card .mini-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  background: #fff;
  display: block;
  border-radius: 9px;
}

/* ---- body meta (excerpt + tags) -------------------------------------------- */
.item-card .meta {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
}

.item-card .excerpt {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.8;
  font-family: 'Vazirmatn', 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
}

.item-card .tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.item-card .date-line {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: fit-content;
  margin-top: 0;
  padding: 0.32rem 0.85rem;
  border-radius: 999px;
  background: rgba(149, 85, 73, 0.09);
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: start;
  font-family: 'CairoBold', arabswell_2, 'Segoe UI', Tahoma, Arial, sans-serif;
}

.item-card .location-line {
  margin-top: 0;
  width: fit-content;
  padding: 0.32rem 0.85rem;
  border-radius: 999px;
  background: rgba(149, 85, 73, 0.06);
  border: 1px solid rgba(149, 85, 73, 0.14);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: start;
  font-family: 'CairoBold', arabswell_2, 'Segoe UI', Tahoma, Arial, sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.item-card .location-label {
  color: var(--primary);
  display: inline;
}

.item-card .location-value {
  color: var(--text);
  display: inline;
}

/* ---- best-student & club cards: centered profile style --------------------- */
.item-card.best-student-card,
.item-card.club-card,
.item-card.lost-found-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, #fffaf6 0%, #ffffff 100%);
  border: 1px solid rgba(149, 85, 73, 0.12);
  box-shadow: 0 16px 36px rgba(149, 85, 73, 0.13);
}

.item-card.club-card,
.item-card.lost-found-card {
  box-shadow: 0 16px 36px rgba(149, 85, 73, 0.1);
  gap: 0.75rem;
}

.item-card.best-student-card::before,
.item-card.club-card::before {
  content: '';
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 56px;
  background: linear-gradient(135deg, rgba(149, 85, 73, 0.16) 0%, rgba(149, 85, 73, 0.05) 100%);
  pointer-events: none;
}

.item-card.best-student-card .student-profile-row,
.item-card.club-card .club-profile-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  margin: 0.1rem 0 0.1rem;
  position: relative;
}

.item-card.best-student-card .student-profile-row .thumb,
.item-card.club-card .club-profile-row .thumb {
  width: 96px;
  max-width: 96px;
  min-height: 96px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 10px 24px rgba(149, 85, 73, 0.24);
  padding: 0;
  background: linear-gradient(135deg, rgba(255, 247, 240, 0.95), rgba(255, 255, 255, 0.95));
  margin: 0;
}

.item-card.best-student-card .thumb img,
.item-card.club-card .thumb img {
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.96);
  object-fit: cover;
}

.item-card.best-student-card .student-name-wrap,
.item-card.club-card .club-name-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.item-card.best-student-card .item-title,
.item-card.club-card .item-title {
  margin: 0;
  font-size: 1.12rem;
  color: var(--primary-dark);
  text-align: center;
}

.item-card.best-student-card .excerpt,
.item-card.club-card .excerpt {
  background: rgba(149, 85, 73, 0.06);
  padding: 0.85rem 1rem;
  border-radius: 14px;
  color: #6a4037;
  margin-top: 0;
  text-align: center;
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, Arial, sans-serif;
}

/* ---- club / lost-found expandable details ---------------------------------- */
.item-card.club-card .club-toggle-btn,
.item-card.lost-found-card .club-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  align-self: center;
  padding: 0.65rem 1.15rem;
  border: 1px solid rgba(149, 85, 73, 0.18);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary-dark);
  font-family: 'CairoBold', arabswell_2, 'Segoe UI', Tahoma, Arial, sans-serif;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 8px 18px rgba(149, 85, 73, 0.1);
  margin-top: 0;
}

.item-card.club-card .club-toggle-btn:hover,
.item-card.lost-found-card .club-toggle-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(149, 85, 73, 0.18);
}

.item-card.club-card .club-toggle-btn.is-open,
.item-card.lost-found-card .club-toggle-btn.is-open {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  border-color: transparent;
}

.item-card.club-card .club-toggle-icon,
.item-card.lost-found-card .club-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.item-card.club-card .club-toggle-icon svg,
.item-card.lost-found-card .club-toggle-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.item-card.club-card .club-toggle-btn.is-open .club-toggle-icon,
.item-card.lost-found-card .club-toggle-btn.is-open .club-toggle-icon {
  transform: rotate(180deg);
}

.item-card.club-card .club-details,
.item-card.lost-found-card .club-details {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.15rem 0.1rem 0;
  border-top: 1px dashed var(--border);
  padding-top: 0.75rem;
}

.item-card.club-card .club-details[hidden],
.item-card.lost-found-card .club-details[hidden] {
  display: none;
  border-top: 0;
  padding-top: 0;
}

.item-card.club-card .club-detail-content,
.item-card.lost-found-card .club-detail-content {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.item-card.club-card .club-description {
  margin: 0;
  color: #6a4037;
  font-size: 0.94rem;
  line-height: 1.8;
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, Arial, sans-serif;
  text-align: center;
}

.item-card.club-card .club-join-box {
  background: rgba(149, 85, 73, 0.07);
  border: 1px solid rgba(149, 85, 73, 0.14);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.item-card.club-card .join-title {
  color: var(--primary-dark);
  font-size: 0.9rem;
  font-weight: 700;
  font-family: 'CairoBold', arabswell_2, 'Segoe UI', Tahoma, Arial, sans-serif;
}

.item-card.club-card .join-text {
  margin: 0;
  color: #6a4037;
  font-size: 0.92rem;
  line-height: 1.75;
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, Arial, sans-serif;
}

/* ---- lost & found: image-forward layout ------------------------------------ */
.item-card.lost-found-card .thumb,
.item-card.lost-found-card .mini-thumb {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 4 / 5;
  height: auto;
  max-height: none;
  min-width: 0;
  min-height: 0;
  margin: 0;
  border-radius: 14px;
  background: var(--surface-alt);
}

.item-card.lost-found-card .thumb img,
.item-card.lost-found-card .mini-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: var(--surface-alt);
  display: block;
  border-radius: 13px;
}

.item-card.lost-found-card .image-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  margin: 0;
  align-items: stretch;
}

/* ---- empty / loading / pagination ------------------------------------------- */
.empty-state {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 20px;
  padding: 1.75rem 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.98rem;
}

.load-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  margin: 1.5rem auto 0;
  padding: 0.95rem 1.5rem;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 999px;
  background: linear-gradient(135deg, #b6786a 0%, var(--primary) 100%);
  color: #fff;
  font-family: 'CairoBold', arabswell_2, 'Segoe UI', Tahoma, Arial, sans-serif;
  font-weight: 700;
  font-size: 0.98rem;
  min-width: 190px;
  box-shadow: 0 14px 32px rgba(149, 85, 73, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  cursor: pointer;
  text-transform: none;
}

.load-more-btn .btn-icon {
  display: inline-flex;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.22);
}

.load-more-btn .btn-icon svg {
  width: 15px;
  height: 15px;
  stroke: #fff;
  stroke-width: 2;
  fill: none;
}

.load-more-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 40px rgba(149, 85, 73, 0.26);
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}

.load-more-btn:active {
  transform: translateY(0);
  box-shadow: 0 12px 24px rgba(149, 85, 73, 0.2);
}

.loader {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  width: 100%;
  min-height: 130px;
  padding: 1rem 1.25rem;
  margin: 0;
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 1rem;
  font-family: 'CairoBold', arabswell_2, 'Segoe UI', Tahoma, Arial, sans-serif;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(253,247,242,0.95) 100%);
  border: 1px solid rgba(149, 85, 73, 0.14);
  box-shadow: 0 12px 24px rgba(80, 45, 34, 0.06);
}
.loader::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid rgba(149,85,73,0.22);
  border-top-color: var(--primary);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.font-loader-screen {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  background: rgba(246, 244, 239, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.32s ease, visibility 0.32s ease;
}

.font-loader-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.font-loader-ring {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 5px solid rgba(149, 85, 73, 0.16);
  border-top-color: var(--primary);
  border-right-color: rgba(149, 85, 73, 0.6);
  animation: loaderSpin 0.9s linear infinite;
  box-shadow: 0 8px 20px rgba(149, 85, 73, 0.12);
}

.font-loader-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary-dark);
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
  letter-spacing: 0.01em;
}

@keyframes loaderSpin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */

@media (max-width: 768px) {
  .item-card.lost-found-card .image-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .item-card .image-gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .item-card.lost-found-card .image-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Desktop: show exactly two post cards per row for latest news and announcements */
@media (min-width: 900px) {
  .section-shell.compact-shell .list-stack {
    justify-content: center;
  }

  .section-shell.compact-shell:has(.item-card + .item-card) .list-stack {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }

  .section-shell.compact-shell:has(.item-card + .item-card) .list-stack > .item-card {
    flex: 1 1 calc(50% - 0.625rem);
    max-width: 420px;
    width: 100%;
  }

  #latest-announcements-list.list-stack,
  #latest-news-list.list-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
  }
}

@media (max-width: 640px) {
  .header-row {
    padding: 0.85rem 0;
  }
  .section-shell {
    padding-bottom: 1.6rem;
  }
  .section-shell.compact-shell {
    padding: 1.1rem 1rem 1.3rem;
    border-radius: 20px;
  }
}

/* Roomier layout on larger desktop screens */
@media (min-width: 1200px) {
  .container {
    width: min(1280px, calc(100% - 3rem));
  }
  .section-header.home-header {
    padding: 1.9rem 2rem;
  }
}
