/* ====== الواجهة الأمامية — متوسطة ابن رجب الحنبلي ====== */

body.front-page {
  background: linear-gradient(180deg, var(--green-700) 0px, var(--green-600) 110px, var(--ivory) 150px);
}

/* ---------- الترويسة ---------- */
body.front-page .topbar {
  position: fixed;
  top: 8px;
  left: 50%;
  z-index: 60;
  width: min(740px, calc(100% - 28px));
  margin: 0;
  transform: translate(-50%, 0);
  background: linear-gradient(180deg, var(--topbar-a), var(--topbar-b));
  border: none;
  border-radius: 999px;
  padding: 0;
  transition: transform 0.4s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.35s ease, box-shadow 0.3s ease;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

body.front-page .topbar.is-hidden {
  transform: translate(-50%, calc(-100% - 26px));
  opacity: 0;
  pointer-events: none;
}

body.front-page.scrolled .topbar {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 20px;
  flex-wrap: wrap;
}

body.front-page .topbar .brand {
  gap: 11px;
}

body.front-page .topbar .brand .logo {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--green-600);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  overflow: hidden;
}

body.front-page .topbar .brand .logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.topbar .brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}

.topbar .brand-text b {
  font-family: var(--font-heading, "Tajawal"), sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
}

.topbar .brand-text span {
  font-size: 12px;
  color: var(--green-200);
}

body.front-page .topbar .brand-text span {
  font-size: 12px;
  color: var(--green-200);
}

/* ---------- الهيرو (عمودان) ---------- */
body.front-page .hero {
  position: relative;
  padding: 6.5rem 1.25rem 4.4rem;
  background: linear-gradient(180deg, var(--green-600) 0%, var(--green-500) 100%);
  background-size: 100% 100%;
}

.hero-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.25fr 0.9fr;
  gap: 3.2rem;
  align-items: center;
}

.hero-text {
  text-align: right;
}

body.front-page .hero h1 {
  color: #fff;
  font-size: clamp(1.9rem, 4.5vw, 2.8rem);
  font-weight: 700;
  line-height: 1.25;
  animation: heroIn 0.7s ease 0.08s both;
}

body.front-page .hero .sub {
  color: var(--green-100);
  font-size: clamp(1.05rem, 2.8vw, 1.3rem);
  font-weight: 700;
  margin-top: 0.35rem;
  animation: heroIn 0.7s ease 0.14s both;
}

.hero-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 1.1rem 0 1rem;
  animation: heroIn 0.7s ease 0.2s both;
}

.hero-divider span {
  width: 56px;
  height: 2px;
  background: var(--green-200);
  opacity: 0.5;
}

.hero-divider span:last-child {
  display: none;
}

.hero-divider i {
  width: 8px;
  height: 8px;
  background: var(--green-100);
  transform: rotate(45deg);
  flex-shrink: 0;
}

body.front-page .hero .tagline {
  max-width: 560px;
  color: var(--green-100);
  font-size: 0.98rem;
  line-height: 1.95;
  animation: heroIn 0.7s ease 0.26s both;
}

@keyframes heroIn {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

/* ---------- بطاقة الدخول ---------- */
.login-card {
  position: relative;
  margin-top: 0;
  background: #fff;
  border: 1px solid var(--ivory-2);
  border-radius: 14px;
  padding: 16px 30px 26px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: heroIn 0.7s ease 0.15s both;
}

.login-card::after,
.login-card::before {
  display: none;
}

.login-card .logo {
  position: static;
  top: auto;
  left: auto;
  transform: none;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--green-600);
  padding: 6px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(23, 54, 51, 0.12);
  overflow: hidden;
}

.login-card .logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.login-card h2 {
  font-size: 23px;
  font-weight: 700;
  color: var(--green-900);
  margin-bottom: 5px;
}

.login-card .hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 20px;
}

/* ---------- دائرة رمز الدخول ---------- */
.pin-wrap {
  margin-bottom: 18px;
}

.pin-circle {
  position: relative;
  width: 148px;
  height: 148px;
  margin: 0 auto;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pin-circle:hover {
  transform: scale(1.07);
}

.pin-ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pin-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.pin-ring-track,
.pin-ring-fill {
  fill: none;
  stroke-width: 7;
  stroke-linecap: round;
}

.pin-circle:hover .pin-ring-track,
.pin-circle:hover .pin-ring-fill {
  stroke-width: 9;
}

.pin-ring-track {
  stroke: var(--ivory-2);
  transition: stroke-width 0.3s ease;
}

.pin-ring-fill {
  stroke: var(--green-600);
  stroke-dasharray: 0 339.3;
  stroke-dashoffset: 339.3;
  transition: stroke-dasharray 0.25s ease, stroke 0.25s ease, stroke-width 0.3s ease;
}

.pin-circle.complete .pin-ring-fill {
  stroke: var(--ok);
}

.pin-circle:hover .pin-dots span {
  animation: dotHop 0.55s ease;
}

.pin-circle:hover .pin-dots span:nth-child(1) { animation-delay: 0s; }
.pin-circle:hover .pin-dots span:nth-child(2) { animation-delay: 0.08s; }
.pin-circle:hover .pin-dots span:nth-child(3) { animation-delay: 0.16s; }
.pin-circle:hover .pin-dots span:nth-child(4) { animation-delay: 0.24s; }

@keyframes dotHop {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.pin-dots {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  pointer-events: none;
}

.pin-dots span {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--green-600);
  background: transparent;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.pin-dots span.filled {
  background: var(--green-600);
  border-color: var(--green-600);
  transform: scale(1.12);
}

.pin-circle.complete .pin-dots span.filled {
  background: var(--ok);
  border-color: var(--ok);
}

.pin-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  text-align: center;
}

.pin-input:focus-visible {
  outline: 2px solid var(--green-600);
  outline-offset: 6px;
}

.pin-hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 12px;
  text-align: center;
}

/* خطأ: اهتزاز + أحمر كامل */
.pin-circle.wrong {
  animation: shake 0.55s ease;
}

.pin-circle.wrong .pin-ring-fill {
  stroke: var(--danger);
  stroke-dasharray: 339.3 0;
  stroke-dashoffset: 0;
  transition: stroke 0.15s ease;
}

.pin-circle.wrong .pin-dots span.filled {
  background: var(--danger);
  border-color: var(--danger);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-11px); }
  40% { transform: translateX(11px); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
}

/* نجاح: تكتمل الدائرة خضراء */
.pin-circle.success {
  animation: successPulse 0.6s ease;
}

.pin-circle.success .pin-ring-fill {
  stroke: var(--ok);
  stroke-dasharray: 339.3 0;
  stroke-dashoffset: 0;
}

@keyframes successPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.07); }
  100% { transform: scale(1); }
}

/* ---------- الأقسام والبطاقات ---------- */
body.front-page .front-content {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3.5rem;
}

body.front-page .section {
  padding: 2.8rem 0;
  border-bottom: 1px solid var(--ivory-2);
}

body.front-page .section:last-child {
  border-bottom: none;
}

body.front-page .section-title {
  gap: 14px;
  margin-bottom: 1.6rem;
}

body.front-page .section-title h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--green-900);
}

body.front-page .section-title::after {
  background: linear-gradient(90deg, var(--green-600), transparent);
  height: 2px;
}

body.front-page .sec-num {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--green-600);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--green-500);
  box-shadow: 0 4px 12px rgba(31, 41, 38, 0.16);
  transition: transform 0.3s ease;
}

body.front-page .section:hover .sec-num {
  transform: rotate(-6deg) scale(1.08);
}

body.front-page .cards-3 {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.2rem;
}

body.front-page .front-content .card {
  position: relative;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--ivory-2);
  border-radius: 10px;
  padding: 1.5rem 1.4rem;
  box-shadow: 0 4px 12px rgba(11, 31, 30, 0.06);
  transition: transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1), box-shadow 0.3s ease, border-color 0.3s ease;
}

body.front-page .front-content .card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--green-600);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}

body.front-page .front-content .card:hover {
  transform: translateY(-6px);
  border-color: var(--green-300);
  box-shadow: 0 14px 28px rgba(23, 54, 51, 0.12);
}

body.front-page .front-content .card:hover::before {
  transform: scaleX(1);
  transform-origin: left;
}

body.front-page .front-content .card h3 {
  font-size: 1.12rem;
  color: var(--green-800);
  margin-bottom: 0.5rem;
  transition: color 0.3s ease;
}

body.front-page .front-content .card:hover h3 {
  color: var(--green-950);
}

body.front-page .front-content .card p {
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.9;
}

/* ظهور البطاقات عند التمرير */
body.front-page .cards-3 .card.reveal {
  transition: opacity 0.55s ease, transform 0.55s cubic-bezier(0.22, 0.61, 0.36, 1);
}

body.front-page .cards-3 .card.reveal.in {
  transform: translateY(0) scale(1);
}

body.front-page .front-content .empty {
  background: var(--green-50);
  border: 1.5px dashed var(--green-300);
  color: var(--green-700);
  border-radius: 10px;
  padding: 40px 20px;
  font-size: 14px;
}

/* ---------- الفوتر ---------- */
body.front-page footer {
  background: linear-gradient(180deg, var(--green-950), var(--green-900));
  color: var(--soft-dark);
  border-top: 3px solid var(--green-700);
  padding: 2.2rem 1.25rem;
  margin-top: 0;
}

.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  text-align: center;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.footer-brand .logo {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 50%;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border: 2px solid var(--green-600);
  overflow: hidden;
}

.footer-brand .logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.footer-brand b {
  color: #fff;
  font-family: var(--font-heading, "Tajawal"), sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  display: block;
}

.footer-brand span {
  color: var(--green-200);
  font-size: 13px;
}

.footer-note {
  font-size: 13px;
  max-width: 560px;
  line-height: 1.8;
}

/* ---------- استجابة الشاشات ---------- */
@media (max-width: 900px) {
  .hero-inner {
    grid-template-columns: 1fr;
    gap: 2.4rem;
  }

  .hero-text {
    text-align: center;
  }

  .hero-divider {
    justify-content: center;
  }

  .hero-divider span:last-child {
    display: block;
  }

  body.front-page .hero .tagline {
    margin: 0 auto;
  }

  .login-card {
    max-width: 400px;
    margin: 0 auto;
  }
}

@media (max-width: 560px) {
  .topbar .brand-text span {
    display: none;
  }

  body.front-page .hero {
    padding: 6rem 1.1rem 3.4rem;
  }
}

/* ---------- قسم الأخبار ---------- */
.news-section {
  padding: 2.8rem 0;
  border-top: none;
}

.news-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.2rem;
}

.news-item {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  background: #fff;
  border: 1px solid var(--ivory-2);
  border-radius: 10px;
  padding: 1.3rem 1.2rem;
  box-shadow: 0 4px 12px rgba(11, 31, 30, 0.06);
  transition: transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1), box-shadow 0.3s ease, border-color 0.3s ease;
}

.news-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--green-600);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.news-item:hover {
  transform: translateY(-6px);
  border-color: var(--green-300);
  box-shadow: 0 14px 28px rgba(23, 54, 51, 0.12);
}

.news-item:hover::before {
  transform: scaleX(1);
  transform-origin: left;
}

.news-item h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--green-800);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.3s ease;
}

.news-item:hover h3 {
  color: var(--green-950);
}

.news-text {
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-date {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.news-date span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 9px;
}

.news-date .date-hijri {
  background: var(--green-100);
  color: var(--green-900);
  border: 1px solid var(--green-300);
}

.news-date .date-greg {
  background: var(--green-50);
  color: var(--green-800);
  border: 1px solid rgba(74, 122, 119, 0.3);
}

.news-imgs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: auto;
}

.news-img {
  position: relative;
  display: inline-flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--ivory-2);
  background: var(--ivory);
  cursor: zoom-in;
}

.news-img img {
  display: block;
  max-width: 140px;
  max-height: 140px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.news-nav {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: 1px solid var(--green-300);
  background: #fff;
  color: var(--green-700);
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  padding: 0;
}

.news-nav:hover {
  background: var(--green-600);
  border-color: var(--green-600);
  color: #fff;
}

.news-count {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(6, 17, 16, 0.62);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 7px;
  line-height: 1.4;
  pointer-events: none;
}

@media (max-width: 720px) {
  .news-item {
    padding: 1rem 0.95rem;
  }
  .news-img img {
    max-width: 120px;
    max-height: 120px;
  }
}

/* عارض الصور — عند الضغط على صورة الخبر */
.news-viewer {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.news-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 17, 16, 0.9);
  backdrop-filter: blur(3px);
}

.news-viewer-box {
  position: relative;
  max-width: min(1000px, 92vw);
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.news-viewer-img {
  max-width: 100%;
  max-height: 86vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  object-fit: contain;
  background: #fff;
}

.news-viewer-close {
  position: absolute;
  top: -44px;
  right: 0;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.news-viewer-close:hover {
  background: var(--danger);
}

.news-viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.news-viewer-nav:hover {
  background: var(--green-600);
}

.news-viewer-nav.prev {
  right: -58px;
}

.news-viewer-nav.next {
  left: -58px;
}

.news-viewer-counter {
  position: absolute;
  bottom: -42px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 999px;
  padding: 4px 14px;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .news-viewer-nav.prev {
    right: 8px;
  }
  .news-viewer-nav.next {
    left: 8px;
  }
  .news-viewer-close {
    top: -42px;
  }
}

/* احترام تفضيل تقليل الحركة */
@media (prefers-reduced-motion: reduce) {
  .pin-circle,
  .pin-circle:hover {
    transform: none;
  }
  .pin-circle .pin-dots span {
    animation: none;
  }
  body.front-page .cards-3 .card.reveal,
  body.front-page .hero h1,
  body.front-page .hero .sub,
  .hero-divider,
  body.front-page .hero .tagline,
  .login-card {
    transition: none;
    animation: none;
    opacity: 1;
    transform: none;
    filter: none;
  }
}
