:root {
  --bg: #eeeae1;
  --paper: #f8f6ef;
  --ink: #11120f;
  --muted: #6c6b64;
  --red-mid: #ff3636;
  --red-soft: #ff4444;
  --yellow: #f59e0b;
  --line: 2px solid var(--ink);
  --max: 1180px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Cairo', sans-serif;
  font-weight: 400;
  overflow-x: hidden;
}

::selection {
  background: var(--red-soft);
  color: #ffffff;
}

a { color: inherit; text-decoration: none; }
.wrap { width: min(var(--max), calc(100% - 28px)); margin: auto; }
.mono { font-family: 'IBM Plex Mono', monospace; letter-spacing: .02em; }

.top {
  position: fixed;
  z-index: 50;
  top: 13px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1150px, calc(100% - 22px));
  border: var(--line);
  background: rgba(238, 234, 225, 0.92);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  box-shadow: 4px 4px var(--ink);
}

.brand {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .brand-svg-img { width: 28px; height: 28px; object-fit: contain; }

.nav-back {
  font-size: 11px;
  font-weight: 700;
  background: var(--ink);
  color: #fff;
  padding: 6px 14px;
  border-radius: 3px;
  transition: background 0.2s ease;
}
.nav-back:hover { background: var(--red-soft); }

.mobile-dock {
  display: none;
  position: fixed;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99;
  background: var(--ink);
  color: #fff;
  border: 2px solid var(--ink);
  box-shadow: 4px 4px var(--red-soft);
  padding: 6px 12px;
  border-radius: 40px;
  width: min(320px, calc(100% - 30px));
}
.mobile-dock nav { display: flex; justify-content: space-around; }
.mobile-dock a { color: #fff; font-size: 11px; font-weight: 700; padding: 6px 12px; }

.page-header {
  padding: 140px 0 40px;
  border-bottom: var(--line);
}
.page-header h1 {
  font-size: clamp(40px, 7vw, 82px);
  margin: 10px 0;
  font-weight: 800;
  line-height: 1;
}
.page-header p {
  font-size: 16px;
  color: var(--muted);
  max-width: 650px;
  line-height: 1.8;
  margin: 0;
}

.filters-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 30px;
}
.filter-btn {
  background: var(--paper);
  border: var(--line);
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Cairo', sans-serif;
}
.filter-btn.active, .filter-btn:hover {
  background: var(--red-soft);
  color: #fff;
  box-shadow: 3px 3px var(--ink);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 25px;
  padding: 50px 0;
}

.skeleton-card {
  background: var(--paper);
  border: var(--line);
  box-shadow: 5px 5px var(--ink);
  height: 380px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.skeleton-thumb {
  width: 100%;
  height: 240px;
  background: linear-gradient(90deg, #e2ddd3 25%, #ece7dc 50%, #e2ddd3 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s infinite;
  border-bottom: var(--line);
}
.skeleton-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.skeleton-line {
  height: 12px;
  background: #e2ddd3;
  border-radius: 2px;
  animation: skeletonShimmer 1.5s infinite;
}
.skeleton-line.short { width: 30%; }
.skeleton-line.title { height: 18px; width: 75%; }
.skeleton-line.desc { width: 90%; }

@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.gallery-card {
  background: var(--paper);
  border: var(--line);
  box-shadow: 5px 5px var(--ink);
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
}
.gallery-card:hover {
  transform: translateY(-6px);
  box-shadow: 9px 9px var(--ink);
}
.gallery-card.is-featured-card {
  border-color: var(--ink);
  box-shadow: 6px 6px 0px var(--yellow);
}

.gallery-thumb-container {
  width: 100%;
  height: 240px;
  position: relative;
  overflow: hidden;
  background: #e2ddd3;
  border-bottom: var(--line);
}

.gallery-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}
.gallery-card:hover .gallery-thumb {
  transform: scale(1.03);
}

.hover-previews-strip {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  gap: 5px;
  z-index: 3;
  opacity: 0;
  transform: translateY(6px);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}
.gallery-card:hover .hover-previews-strip {
  opacity: 1;
  transform: translateY(0);
}
.hover-mini-thumb {
  width: 32px;
  height: 32px;
  border-radius: 3px;
  border: 1.5px solid var(--ink);
  box-shadow: 1.5px 1.5px 0px var(--ink);
  object-fit: cover;
  background: #fff;
}

.gallery-badges-container {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 2;
}

.gallery-badge-item {
  background: var(--ink);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border: 1.5px solid var(--ink);
  box-shadow: 2px 2px 0px var(--red-soft);
  border-radius: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.gallery-badge-item.featured {
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 2px 2px 0px var(--ink);
}

.gallery-info {
  padding: 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.gallery-tag {
  font: 600 10px 'IBM Plex Mono';
  color: var(--red-soft);
  display: block;
  margin-bottom: 5px;
}
.gallery-info h3 { font-size: 18px; margin: 0 0 6px; font-weight: 700; }
.gallery-info p { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.7; }

.gallery-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--red-soft);
  text-decoration: underline;
  align-self: flex-start;
}
.gallery-link:hover { color: var(--ink); }

.cloud-cta {
  background: var(--ink);
  color: white;
  padding: 70px 40px;
  border: var(--line);
  box-shadow: 12px 12px var(--red-soft);
  text-align: center;
  margin: 60px 0 100px;
  border-radius: 4px;
}
.cloud-cta h2 { font-size: clamp(32px, 5vw, 58px); margin: 0 0 15px; font-weight: 800; line-height: 1.1; }
.cloud-cta p { font-size: 15px; color: #bbb; max-width: 600px; margin: 0 auto 30px; line-height: 1.8; }

.btn-cloud-huge {
  display: inline-block;
  background: var(--red-soft);
  color: #fff;
  padding: 18px 36px;
  font-size: 16px;
  font-weight: 800;
  border: 2px solid var(--red-soft);
  transition: all 0.25s ease;
  box-shadow: 5px 5px 0px #fff;
}
.btn-cloud-huge:hover {
  transform: translateY(-3px);
  box-shadow: 8px 8px 0px #fff;
  background: var(--red-mid);
}

/* Modals */
.project-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17, 18, 15, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 14px;
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-shell {
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 6px 6px 0px var(--red-soft);
  max-width: 1050px;
  width: 100%;
  height: 92vh;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.modal-top-bar {
  padding: 8px 14px;
  background: #fff;
  border-bottom: 2px solid var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  gap: 8px;
  min-height: 46px;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  flex: 1;
}
.modal-title-group h2 {
  font-size: 13.5px;
  font-weight: 800;
  margin: 0;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.modal-badge-tag {
  font-size: 10px;
  background: var(--bg);
  border: 1px solid var(--ink);
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 700;
  color: var(--red-soft);
  white-space: nowrap;
}

.modal-badge-counter {
  font-size: 10.5px;
  background: var(--ink);
  color: #fff;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 700;
  white-space: nowrap;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.modal-action-icon-btn {
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  font-size: 11.5px;
  font-weight: 800;
  height: 28px;
  padding: 0 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 3px;
  box-shadow: 1.5px 1.5px 0px var(--ink);
  transition: all 0.15s ease;
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}
.modal-action-icon-btn:hover {
  background: var(--red-soft);
  color: #fff;
}

.modal-external-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--red-soft);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  height: 28px;
  padding: 0 10px;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  box-shadow: 1.5px 1.5px 0px var(--ink);
  white-space: nowrap;
}

/* مسرح العرض المنزلق العمودي */
.modal-stage-wrapper {
  flex: 1;
  min-height: 0;
  background: #11120f;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-slides-track {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.modal-slide-item {
  width: 100%;
  height: 100%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  box-sizing: border-box;
}

.modal-display-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  margin: auto;
  border-radius: 2px;
  box-shadow: 0 4px 25px rgba(0,0,0,0.65);
  user-select: none;
  cursor: zoom-in;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-display-img.zoomed {
  transform: scale(2.1);
  cursor: zoom-out;
}

.modal-arrow-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(248, 246, 239, 0.95);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  box-shadow: 2px 2px 0px var(--ink);
  width: 36px;
  height: 36px;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 3px;
  transition: all 0.15s ease;
}
.modal-arrow-btn:hover {
  background: var(--red-soft);
  color: #fff;
  transform: translateY(-50%) scale(1.08);
}
.modal-arrow-btn.right-side-btn { right: 12px; }
.modal-arrow-btn.left-side-btn { left: 12px; }

.modal-bottom-card {
  padding: 10px 14px;
  background: var(--paper);
  border-top: 1.5px solid var(--ink);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-shrink: 0;
  max-height: 120px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-bottom-desc-text {
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink);
  font-weight: 600;
  margin: 0;
}

.modal-thumbs-strip {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: #fff;
  border-top: 1.5px solid var(--ink);
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}

.modal-thumb-box {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border: 1.5px solid var(--ink);
  cursor: pointer;
  border-radius: 3px;
  overflow: hidden;
  opacity: 0.45;
  transition: all 0.15s ease;
  background: #eee;
}
.modal-thumb-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.modal-thumb-box.active {
  opacity: 1;
  border-color: var(--red-soft);
  box-shadow: 2px 2px 0px var(--red-soft);
  transform: translateY(-2px);
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.gallery-error, .gallery-empty {
  grid-column: 1 / -1;
  padding: 40px 0;
  color: var(--muted);
  text-align: center;
}
.gallery-error { color: var(--red-soft); }

footer {
  border-top: var(--line);
  padding: 24px 0 45px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
}

/* تحسينات الجوال الدقيقة */
@media(max-width: 800px) {
  .top { display: none; }
  .mobile-dock { display: block; }
  .gallery-grid { grid-template-columns: 1fr; }
  .cloud-cta { padding: 45px 20px; }
  footer { flex-direction: column; text-align: center; gap: 8px; }

  .project-modal {
    padding: 8px;
  }
  .modal-shell {
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    box-shadow: 4px 4px 0px var(--red-soft);
  }
  
  .modal-top-bar {
    padding: 8px 10px;
    flex-wrap: nowrap;
    gap: 6px;
  }
  .modal-title-group {
    gap: 5px;
  }
  .modal-title-group h2 {
    font-size: 12px;
    max-width: 140px;
  }
  .modal-badge-tag {
    font-size: 9px;
    padding: 1px 4px;
    display: none;
  }
  .modal-badge-counter {
    font-size: 9.5px;
    padding: 1px 5px;
  }
  
  .modal-header-actions {
    gap: 4px;
  }
  .modal-action-icon-btn {
    height: 26px;
    padding: 0 7px;
    font-size: 10.5px;
  }
  .modal-external-btn {
    height: 26px;
    padding: 0 7px;
    font-size: 10px;
  }

  .modal-arrow-btn { 
    width: 32px; 
    height: 32px; 
    font-size: 13px; 
  }
  .modal-arrow-btn.right-side-btn { right: 8px; }
  .modal-arrow-btn.left-side-btn { left: 8px; }

  .modal-bottom-card {
    padding: 8px 10px;
    max-height: 90px;
  }
  .modal-bottom-desc-text {
    font-size: 11px;
    line-height: 1.5;
  }

  .modal-thumbs-strip {
    padding: 6px 10px;
    gap: 6px;
  }
  .modal-thumb-box { 
    width: 44px; 
    height: 44px; 
  }
}