/**
 * @file css/components.css
 * @description المكونات التحريرية والتفاعلية المستقلة لاستوديو إيوان (IWAN Atelier)
 * بدون مكتبات أو فريموركات: رأس الصفحة، الأزرار، الكروت الحادة، مقارن الصور، والأكورديون.
 */

/* --------------------------------------------------------------------------
   1. رأس الصفحة الملتصق ثلاثي المناطق (The 3-Zone Sticky Header)
   -------------------------------------------------------------------------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 72px;
  z-index: 1000;
  display: flex;
  align-items: center;
  background-color: rgba(242, 240, 235, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: height var(--duration-hover) var(--ease-cinematic),
              background-color var(--duration-theme) var(--ease-subtle),
              border-color var(--duration-hover) var(--ease-subtle);
}

.site-header.is-scrolled {
  height: 64px;
  border-bottom-color: var(--border);
  background-color: rgba(242, 240, 235, 0.94);
}

[data-theme="dark"] .site-header {
  background-color: rgba(26, 24, 21, 0.85);
}

[data-theme="dark"] .site-header.is-scrolled {
  background-color: rgba(26, 24, 21, 0.95);
  border-bottom-color: var(--border-inverse);
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

/* المنطقة 1: الشعار والاسم المعماري */
.brand-mark {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.brand-mark-latin {
  font-family: var(--font-editorial);
  font-size: 0.95rem;
  font-style: italic;
  font-weight: 400;
  color: var(--accent-warm);
}

/* المنطقة 2: روابط التنقل التحريرية */
.nav-menu {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2vw, 2rem);
}

.nav-link {
  position: relative;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding-block: 0.4rem;
  transition: color var(--duration-hover) var(--ease-subtle);
}

/* تسطير ينمو من اليمين إلى اليسار للغة العربية */
.nav-link::after {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0%;
  height: 1.5px;
  background-color: var(--accent-warm);
  transform-origin: right center;
  transition: width var(--duration-hover) var(--ease-cinematic);
}

.nav-link:hover {
  color: var(--text-primary);
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

.nav-link.active {
  color: var(--text-primary);
  font-weight: 600;
}

/* المنطقة 3: زر الإجراء السريع CTA */
.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* زر قائمة الموبايل الهامبرغر */
.mobile-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  gap: 6px;
  width: 38px;
  height: 38px;
  background: transparent;
  cursor: pointer;
  z-index: 1010;
}

.mobile-toggle-bar {
  width: 24px;
  height: 1.5px;
  background-color: var(--text-primary);
  transition: transform var(--duration-hover) var(--ease-cinematic),
              width var(--duration-hover) var(--ease-cinematic);
}

.mobile-toggle-bar:nth-child(2) {
  width: 16px;
}

.mobile-toggle.is-open .mobile-toggle-bar:nth-child(1) {
  transform: translateY(3.5px) rotate(45deg);
  width: 22px;
}

.mobile-toggle.is-open .mobile-toggle-bar:nth-child(2) {
  transform: translateY(-4px) rotate(-45deg);
  width: 22px;
}

/* قائمة الموبايل بقطع دائري (Circular Clip-Path Reveal) */
.mobile-drawer {
  position: fixed;
  inset: 0;
  background-color: var(--bg-primary);
  z-index: 1005;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 2rem;
  clip-path: circle(0% at 90% 40px);
  transition: clip-path 0.65s var(--ease-cinematic);
  pointer-events: none;
}

.mobile-drawer.is-open {
  clip-path: circle(150% at 90% 40px);
  pointer-events: auto;
}

.mobile-nav-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.mobile-nav-link {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s var(--ease-cinematic),
              transform 0.4s var(--ease-cinematic);
}

.mobile-drawer.is-open .mobile-nav-link {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .nav-menu {
    display: none;
  }
  .mobile-toggle {
    display: flex;
  }
}

/* --------------------------------------------------------------------------
   2. الأزرار المعمارية (Architectural Buttons)
   -------------------------------------------------------------------------- */
/* الزر الأساسي بانزلاق خلفية الأوكر من الأسفل */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.75rem 1.6rem;
  background-color: var(--accent-primary);
  color: var(--bg-primary);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  position: relative;
  overflow: hidden;
  z-index: 1;
  border-radius: 0; /* ممنوع الـ border-radius الموحد */
  transition: color var(--duration-hover) var(--ease-subtle);
  white-space: nowrap;
}

.btn-primary::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--accent-warm);
  transform: translateY(100%);
  transition: transform 0.35s var(--ease-cinematic);
  z-index: -1;
}

.btn-primary:hover {
  color: #FFFFFF;
}

.btn-primary:hover::before {
  transform: translateY(0);
}

/* الزر الشفاف الشبح مع انعكاس اللون عند الهوفر */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.75rem 1.6rem;
  background-color: transparent;
  color: var(--text-primary);
  border: 1px solid var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: 0;
  transition: background-color var(--duration-hover) var(--ease-cinematic),
              color var(--duration-hover) var(--ease-cinematic);
  white-space: nowrap;
}

.btn-ghost:hover {
  background-color: var(--text-primary);
  color: var(--bg-primary);
}

/* --------------------------------------------------------------------------
   3. كروت الخدمات الحادة (Service Cards - Zero Pill & Sharp Edges)
   -------------------------------------------------------------------------- */
.service-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 0px; /* حواف حادة صريحة */
  padding: clamp(2rem, 3.5vw, 3rem);
  position: relative;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
  transition: transform var(--duration-hover) var(--ease-cinematic),
              border-color var(--duration-hover) var(--ease-subtle),
              box-shadow var(--duration-hover) var(--ease-subtle);
}

.service-card::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 0px;
  background-color: var(--accent-primary);
  transition: width var(--duration-hover) var(--ease-cinematic);
}

.service-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.07);
}

.service-card:hover::before {
  width: 3px;
}

.service-number {
  font-family: var(--font-editorial);
  font-size: 2.75rem;
  line-height: 1;
  color: var(--accent-warm);
  margin-bottom: 1.25rem;
  display: block;
}

/* --------------------------------------------------------------------------
   4. كروت المشاريع والمعرض (Project Cards with Curtain Reveal)
   -------------------------------------------------------------------------- */
.project-card {
  display: block;
  position: relative;
  overflow: hidden;
  background-color: var(--bg-secondary);
  border-radius: 0;
}

.project-card-media {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  width: 100%;
}

.project-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s var(--ease-cinematic),
              filter 0.5s var(--ease-subtle);
}

.project-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    transparent 40%,
    rgba(26, 24, 21, 0.85) 100%
  );
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(1.25rem, 2.5vw, 2rem);
  color: #F2F0EB;
  z-index: 2;
  clip-path: inset(0 0 0 0);
  transition: opacity var(--duration-hover) var(--ease-subtle);
}

.project-card-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  color: #F2F0EB;
  transform: translateY(8px);
  transition: transform 0.4s var(--ease-cinematic);
}

.project-card:hover .project-card-img {
  transform: scale(1.05);
}

.project-card:hover .project-card-title {
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   6. لايتبوكس المعرض ثلاثي الأبعاد المخصص (Custom 3D Lightbox)
   -------------------------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background-color: rgba(26, 24, 21, 0.96);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  perspective: 1200px;
  transition: opacity 0.35s var(--ease-cinematic);
}

.lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: scale(0.94) rotateX(6deg);
  transition: transform 0.4s var(--ease-cinematic);
}

.lightbox.is-open .lightbox-content {
  transform: scale(1) rotateX(0deg);
}

.lightbox-media-wrapper {
  position: relative;
  max-height: 75vh;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
}

.lightbox-img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
}

.lightbox-caption {
  margin-top: 1rem;
  color: #F2F0EB;
  text-align: center;
}

.lightbox-close {
  position: absolute;
  top: 1.5rem;
  left: 2rem;
  color: #F2F0EB;
  font-size: 1.75rem;
  background: transparent;
  cursor: pointer;
  z-index: 10;
  padding: 0.5rem;
}

.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(26, 24, 21, 0.6);
  border: 1px solid var(--border-inverse);
  color: #F2F0EB;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--duration-hover) var(--ease-subtle);
}

.lightbox-nav-btn:hover {
  background-color: var(--accent-warm);
}

.lightbox-prev {
  right: 1.5rem;
}

.lightbox-next {
  left: 1.5rem;
}

/* --------------------------------------------------------------------------
   7. شريط مقارنة قبل وبعد بالسحب (Before / After Physical Slider)
   -------------------------------------------------------------------------- */
.before-after-slider {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  user-select: none;
  cursor: ew-resize;
  background-color: var(--bg-secondary);
}

.ba-image-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ba-image-layer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* طبقة الصورة المعالجة بعد التشطيب المقصوصة بالعرض الديناميكي */
.ba-after-layer {
  position: absolute;
  inset: 0;
  width: var(--slider-pos, 50%);
  height: 100%;
  overflow: hidden;
  border-left: 2px solid #FFFFFF;
}

.ba-after-layer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* تثبيت العرض مساوياً للحاوية الأم لمنع انضغاط الصورة */
  max-width: none;
}

/* --------------------------------------------------------------------------
   8. الأكورديون الناعم بتقنية CSS Grid (Smooth Grid Accordion 0fr -> 1fr)
   -------------------------------------------------------------------------- */
.accordion-item {
  border-bottom: 1px solid var(--border);
  padding-block: 0.5rem;
}

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 1.25rem;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  text-align: right;
  transition: color var(--duration-hover) var(--ease-subtle);
}

.accordion-trigger:hover {
  color: var(--accent-primary);
}

.accordion-icon {
  width: 20px;
  height: 20px;
  stroke: var(--text-muted);
  transition: transform 0.4s var(--ease-cinematic),
              stroke var(--duration-hover) var(--ease-subtle);
}

.accordion-item.is-open .accordion-icon {
  transform: rotate(45deg);
  stroke: var(--accent-warm);
}

/* شبكة التمدد الصفرية للارتفاع النقي بدون max-height */
.accordion-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.4s var(--ease-cinematic);
}

.accordion-item.is-open .accordion-panel {
  grid-template-rows: 1fr;
}

.accordion-content {
  overflow: hidden;
}

.accordion-body {
  padding-bottom: 1.5rem;
  color: var(--text-secondary);
  line-height: 1.85;
}

/* --------------------------------------------------------------------------
   9. حاسبة تكلفة التشطيب والتصميم المعماري الفورية (Cost Estimator)
   -------------------------------------------------------------------------- */
.cost-estimator {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: clamp(2rem, 4vw, 3.5rem);
  position: relative;
}

.estimator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 4vw, 4rem);
  align-items: center;
}

@media (max-width: 900px) {
  .estimator-grid {
    grid-template-columns: 1fr;
  }
}

.estimator-control {
  margin-bottom: 1.75rem;
}

.estimator-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.estimator-range {
  width: 100%;
  accent-color: var(--accent-primary);
  height: 4px;
  background-color: var(--border-strong);
  cursor: pointer;
}

.estimator-select {
  width: 100%;
  padding: 0.85rem 1rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-body);
  cursor: pointer;
}

.estimator-result-box {
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  padding: clamp(1.75rem, 3vw, 2.5rem);
  text-align: right;
}

.estimator-price {
  font-family: var(--font-editorial);
  font-size: clamp(2.5rem, 4.5vw, 4.25rem);
  color: var(--accent-primary);
  line-height: 1;
  margin-block: 0.75rem;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   10. كروت المقالات التحريرية (Blog Cards - Zero Border & True Editorial)
   -------------------------------------------------------------------------- */
.blog-card {
  display: flex;
  flex-direction: column;
  background: transparent;
  border: none;
  padding: 0;
  gap: 1.25rem;
  position: relative;
}

.blog-card-media {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background-color: var(--bg-secondary);
}

.blog-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease-cinematic);
}

.blog-card:hover .blog-card-img {
  transform: scale(1.04);
}

.blog-card-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  transition: color var(--duration-hover) var(--ease-subtle);
}

.blog-card:hover .blog-card-title {
  color: var(--accent-primary);
}

/* --------------------------------------------------------------------------
   11. تذييل الموقع والعلامة المائية الضخمة (Site Footer)
   -------------------------------------------------------------------------- */
.site-footer {
  position: relative;
  background-color: var(--bg-dark);
  color: var(--text-inverse);
  padding-top: clamp(4rem, 8vw, 7rem);
  padding-bottom: 2rem;
  overflow: hidden;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  gap: clamp(2rem, 4vw, 4rem);
  margin-bottom: clamp(4rem, 7vw, 6rem);
}

@media (max-width: 900px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .footer-grid {
    grid-template-columns: 1fr;
  }
}

.footer-col-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: #F2F0EB;
  margin-bottom: 1.25rem;
}

.footer-links-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.footer-link {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: #A39D96;
  transition: color var(--duration-hover) var(--ease-subtle);
}

.footer-link:hover {
  color: var(--accent-warm);
}

/* العلامة المائية التحريرية العملاقة في أسفل الفوتر */
.footer-watermark {
  font-family: var(--font-editorial);
  font-size: clamp(4rem, 15vw, 14rem);
  font-style: italic;
  font-weight: 400;
  line-height: 0.8;
  color: rgba(242, 240, 235, 0.04);
  user-select: none;
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
  margin-bottom: 2rem;
}

.footer-bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-inverse);
  padding-top: 2rem;
  font-size: 0.875rem;
  color: #A39D96;
}

@media (max-width: 768px) {
  .footer-bottom-bar {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
}
