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

:root {
  --bg-dark: #080404;
  --bg-dark-end: #0f0a0a;
  --bg-card: rgba(20, 11, 11, 0.45);
  --bg-card-hover: rgba(32, 14, 14, 0.6);
  --accent-crimson: #9e0c0c;
  --accent-crimson-hover: #c41212;
  --accent-gold: #c5a880;
  --text-primary: #f5f5f7;
  --text-secondary: #b8b0b0;
  --text-muted: #857c7c;
  --glass-border: rgba(255, 255, 255, 0.05);
  --glass-border-hover: rgba(255, 255, 255, 0.15);
  --glow-red: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 20px rgba(158, 12, 12, 0.15);
  --glow-red-strong: 0 12px 40px rgba(0, 0, 0, 0.65), 0 0 30px rgba(158, 12, 12, 0.4);

  --font-title: 'Cinzel', serif;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-fa: 'Vazirmatn', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Global document styling based on language/direction */
html {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  scroll-behavior: smooth;
}

html:has(#sort-section:target) {
  scroll-behavior: auto !important;
}

html[lang="fa"] body {
  font-family: var(--font-fa);
  direction: rtl;
}

html[lang="en"] body {
  font-family: var(--font-sans);
  direction: ltr;
}

body {
  background: radial-gradient(circle at 50% -20%, #200d0d 0%, var(--bg-dark) 60%, var(--bg-dark-end) 100%);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Typography headers */
html[lang="en"] h1,
html[lang="en"] h2,
html[lang="en"] h3,
html[lang="en"] .top-menu a {
  font-family: var(--font-title);
  letter-spacing: 0.5px;
}

html[lang="fa"] h1,
html[lang="fa"] h2,
html[lang="fa"] h3,
html[lang="fa"] .top-menu a {
  font-family: var(--font-fa);
  font-weight: 700;
}

a {
  color: inherit;
  text-decoration: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header & Navigation */
.top {
  padding: 40px 24px 24px;
  text-align: center;
  position: relative;
  z-index: 10;
}

.top-menu {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.top-menu a {
  color: var(--accent-gold);
  padding: 0 20px;
  height: 40px;
  font-size: 17px;
  font-weight: 600;
  border: 1px solid transparent;
  background: transparent;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.top-menu a:hover {
  color: #fff;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

.top-menu a.active {
  color: #fff;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

.top-menu .brand {
  font-weight: 700;
}

.top-menu .brand.active {
  color: #fff;
}

.top-menu .lang-switch {
  font-size: 15px;
  color: var(--accent-gold);
  border: 1px solid rgba(197, 168, 128, 0.15);
  background: rgba(197, 168, 128, 0.02);
  border-radius: 8px;
  backdrop-filter: blur(8px);
  text-transform: none;
  letter-spacing: normal;
}

.top-menu .lang-switch:hover {
  color: #fff;
  background: rgba(197, 168, 128, 0.15);
  border-color: var(--accent-gold);
  box-shadow: 0 4px 12px rgba(197, 168, 128, 0.1);
  transform: translateY(-2px);
  text-shadow: none;
}

.top h1 {
  font-size: 36px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 8px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.subtitle {
  color: var(--text-secondary);
  font-size: 16px;
  max-width: 600px;
  margin: 0 auto;
  font-weight: 300;
}

/* Filters styling */
.filters-container {
  display: flex;
  justify-content: center;
  padding: 16px 48px 32px;
  position: relative;
  z-index: 10;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

.filters-form {
  background: rgba(20, 11, 11, 0.4);
  border: 1px solid var(--glass-border);
  padding: 24px;
  border-radius: 16px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--glow-red);
  width: 100%;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.filters-form:hover {
  border-color: var(--glass-border-hover);
  box-shadow: var(--glow-red-strong);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  width: 100%;
  margin-bottom: 24px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

html[lang="fa"] .filter-group label {
  font-family: var(--font-fa);
  font-size: 12px;
  letter-spacing: 0;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(8, 4, 4, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
}

.input-wrapper:focus-within {
  border-color: var(--accent-crimson);
  background: rgba(18, 7, 7, 0.85);
  box-shadow: 0 0 12px rgba(158, 12, 12, 0.35);
}

.input-icon {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  fill: var(--text-muted);
  pointer-events: none;
  transition: fill 0.25s ease;
}

html[lang="fa"] .input-icon {
  left: auto;
  right: 12px;
}

.input-wrapper input,
.input-wrapper select {
  width: 100%;
  background: transparent;
  border: none;
  color: #fff;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  height: 42px;
  transition: color 0.25s ease;
}

html[lang="fa"] .input-wrapper input,
html[lang="fa"] .input-wrapper select {
  font-family: var(--font-fa);
  font-size: 13px;
}

.input-wrapper input {
  padding-left: 38px;
}

html[lang="fa"] .input-wrapper input {
  padding-left: 14px;
  padding-right: 38px;
}

.input-wrapper select {
  padding-left: 38px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23857c7c'%3E%3Cpath d='M7 10l5 5 5-5H7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

html[lang="fa"] .input-wrapper select {
  padding-left: 14px;
  padding-right: 38px;
  background-position: left 12px center;
}

.input-wrapper:focus-within .input-icon {
  fill: var(--accent-crimson);
}

.input-wrapper select option {
  background: #140b0b;
  color: #fff;
}

.range-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.range-separator {
  width: 12px;
  height: 2px;
  background: var(--text-muted);
  flex-shrink: 0;
  border-radius: 1px;
}

.filter-bottom-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  width: 100%;
  margin-top: 12px;
  flex-wrap: wrap;
  gap: 16px;
}

.filter-actions {
  display: flex;
  gap: 12px;
}

.btn-submit,
.reset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html[lang="fa"] .btn-submit,
html[lang="fa"] .reset-btn {
  font-family: var(--font-fa);
  font-size: 13px;
}

.btn-submit {
  background: var(--accent-crimson);
  color: #fff;
  border: none;
  box-shadow: 0 4px 12px rgba(158, 12, 12, 0.2);
}

.btn-submit:hover {
  background: var(--accent-crimson-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(158, 12, 12, 0.4);
}

.btn-submit:active {
  transform: translateY(0);
}

.reset-btn {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  text-decoration: none;
}

.reset-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
  transform: translateY(-2px);
}

.reset-btn:active {
  transform: translateY(0);
}

.btn-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Map page and Container */
.map {
  padding: 24px;
  text-align: center;
  position: relative;
  z-index: 5;
}

#map-container {
  background: rgba(18, 10, 10, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 24px;
  backdrop-filter: blur(12px);
  box-shadow: var(--glow-red);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#map-container svg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: block;
}

/* Cards Carousel (Home Grid) */
.cards-wrap {
  position: relative;
  padding: 20px 48px 48px;
  z-index: 5;
  max-width: 1440px;
  margin: 0 auto;
}

.cards {
  display: flex;
  gap: 24px;
  overflow-x: auto;
  padding: 16px 8px 32px;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 8px;
  align-items: stretch;
  -ms-overflow-style: none;
  /* IE and Edge */
  scrollbar-width: none;
  /* Firefox */
}

.cards::-webkit-scrollbar {
  display: none;
  /* Chrome, Safari, Opera */
}

.card {
  min-width: 320px;
  width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--glow-red);
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1),
    border-color 0.4s cubic-bezier(0.165, 0.84, 0.44, 1),
    box-shadow 0.4s cubic-bezier(0.165, 0.84, 0.44, 1),
    background-color 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
  backdrop-filter: blur(12px);
}

.card:hover {
  transform: translateY(-8px);
  border-color: var(--glass-border-hover);
  background-color: var(--bg-card-hover);
  box-shadow: var(--glow-red-strong);
}

.portrait-container {
  display: block;
  width: 100%;
  height: 240px;
  overflow: hidden;
  position: relative;
  /* Fix subpixel overflow bleed in WebKit/Blink during scaling */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  -webkit-mask-image: -webkit-radial-gradient(white, black);
  mask-image: -webkit-radial-gradient(white, black);
}

.portrait-container::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: -1px;
  right: -1px;
  height: 62px;
  background: linear-gradient(to top, rgba(20, 11, 11, 0.9) 0%, rgba(20, 11, 11, 0) 100%);
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.portrait {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  filter: grayscale(0.4) sepia(0.15) brightness(0.8);
  transition: transform 0.6s cubic-bezier(0.165, 0.84, 0.44, 1),
    filter 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
  /* Force GPU rendering to prevent edge bleeding on filters/transforms */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.card:hover .portrait {
  transform: scale(1.06) translateZ(0);
  filter: grayscale(0) sepia(0) brightness(1.0);
}

.meta {
  padding: 24px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.meta h3 {
  font-size: 20px;
  margin-bottom: 12px;
  color: #fff;
  line-height: 1.3;
  transition: color 0.3s ease;
}

.card:hover .meta h3 {
  color: var(--accent-gold);
}

.info {
  color: var(--text-secondary);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
  flex-grow: 1;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.info-item svg {
  width: 16px;
  height: 16px;
  fill: var(--text-muted);
  flex-shrink: 0;
  transition: fill 0.3s ease;
}

.card:hover .info-item svg {
  fill: var(--accent-crimson);
}

.info-value {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.details {
  display: block;
  width: 100%;
  text-align: center;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.25s ease;
}

.details:hover {
  background: var(--accent-crimson);
  border-color: var(--accent-crimson);
  box-shadow: 0 4px 12px rgba(158, 12, 12, 0.3);
}

/* Nav arrows on carousel */
.nav {
  position: absolute;
  top: 45%;
  transform: translateY(-50%);
  background: rgba(18, 11, 11, 0.7);
  border: 1px solid var(--glass-border);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  z-index: 15;
  backdrop-filter: blur(8px);
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.nav:hover {
  background: var(--accent-crimson);
  border-color: var(--accent-crimson);
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 0 15px rgba(158, 12, 12, 0.4);
}

.nav svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.nav.left {
  left: 16px;
}

.nav.right {
  right: 16px;
}

/* Detail Page Layout */
.detail {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 24px 60px;
  position: relative;
  z-index: 5;
}

.back-btn-container {
  padding: 20px 0;
}

.back-btn,
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(8px);
  cursor: pointer;
  font-family: inherit;
  outline: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.share-btn {
  color: var(--accent);
  border-color: rgba(220, 20, 60, 0.3);
  background: rgba(220, 20, 60, 0.05);
}

.back-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-2px);
}

.share-btn:hover {
  color: #fff;
  background: rgba(220, 20, 60, 0.20);
  border-color: rgba(220, 20, 60, 0.50);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(220, 20, 60, 0.15);
}

.back-btn:hover svg {
  transform: translateX(-4px);
}

.back-btn:hover svg.rotate-180 {
  transform: rotate(180deg) translateX(-4px);
}

.back-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Immersive blur backdrop */
.hero-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 600px;
  background-size: cover;
  background-position: center 30%;
  filter: blur(60px) brightness(0.15) saturate(1.4);
  opacity: 0.6;
  z-index: 1;
  pointer-events: none;
}

.hero-backdrop::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: linear-gradient(to bottom, rgba(8, 4, 4, 0) 40%, var(--bg-dark) 100%);
}

.detail .hero {
  display: flex;
  gap: 48px;
  padding: 40px 0;
  align-items: center;
  position: relative;
  z-index: 5;
}

.portrait-large-container {
  flex-shrink: 0;
  position: relative;
  border-radius: 16px;
  padding: 6px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(158, 12, 12, 0.15));
  box-shadow: var(--glow-red);
}

.portrait-large {
  width: 280px;
  height: 280px;
  background-size: cover;
  background-position: center;
  border-radius: 12px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.5s ease;
}

.portrait-large-container:hover .portrait-large {
  transform: scale(1.02);
}

.details-side {
  flex-grow: 1;
}

.details-side h1 {
  font-size: 44px;
  color: #fff;
  margin-bottom: 24px;
  line-height: 1.2;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.detail-meta-item {
  background: rgba(20, 11, 11, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  text-align: start;
}

.detail-meta-item svg {
  width: 22px;
  height: 22px;
  fill: var(--accent-gold);
  flex-shrink: 0;
}

.detail-meta-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
  letter-spacing: 0.5px;
}

html[lang="fa"] .detail-meta-label {
  font-size: 11px;
}

.detail-meta-value {
  font-size: 16px;
  color: #fff;
  font-weight: 600;
}

/* Story Section */
.story {
  padding: 40px;
  background: rgba(20, 11, 11, 0.25);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  margin-bottom: 40px;
  position: relative;
  z-index: 5;
  box-shadow: var(--glow-red);
  text-align: justify;
}

.story h2,
.gallery h2 {
  font-size: 24px;
  color: #fff;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(158, 12, 12, 0.2);
  padding-bottom: 10px;
  display: inline-block;
}

.story-content {
  color: var(--text-secondary);
  font-size: 17.5px;
  line-height: 1.9;
}

.story-content p {
  margin-bottom: 24px;
}

.story-content p:last-child {
  margin-bottom: 0;
}

.story-content i,
.story-content em {
  color: var(--accent-gold);
  font-style: italic;
}

.story-content a {
  color: var(--accent-gold);
  text-decoration: underline;
  transition: color 0.2s ease;
}

.story-content a:hover {
  color: #fff;
}

/* Beautiful drop-cap on English story */
html[lang="en"] .story-content p:first-of-type::first-letter {
  font-family: var(--font-title);
  float: left;
  margin-top: 1px;
  margin-right: 12px;
  color: var(--accent-gold);
}

@supports (initial-letter: 2) or (-webkit-initial-letter: 2) {
  html[lang="en"] .story-content p:first-of-type::first-letter {
    -webkit-initial-letter: 2;
    initial-letter: 2;
    font-size: inherit;
    line-height: inherit;
    margin-top: 0;
    float: none;
  }
}

/* Gallery Section */
.gallery {
  padding: 40px;
  background: rgba(20, 11, 11, 0.25);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  margin-bottom: 40px;
  position: relative;
  z-index: 5;
  box-shadow: var(--glow-red);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  padding: 0;
  margin-top: 10px;
}

.gitem {
  width: 100%;
  aspect-ratio: 4/3;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  cursor: pointer;
  filter: grayscale(0.3) brightness(0.9);
  transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.gitem:hover {
  transform: scale(1.04);
  filter: grayscale(0) brightness(1.1);
  border-color: var(--glass-border-hover);
  box-shadow: 0 8px 20px rgba(158, 12, 12, 0.2);
}

/* Lightbox styles */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 3, 3, 0.95);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lightbox.active {
  display: flex;
  opacity: 1;
}

.lightbox-content {
  max-width: 85%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(158, 12, 12, 0.15);
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

.lightbox.active .lightbox-content {
  transform: scale(1);
}

.lightbox-close {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s ease;
}

.lightbox-close:hover {
  background: var(--accent-crimson);
  border-color: var(--accent-crimson);
  transform: rotate(90deg);
}

/* Responsive queries */
@media (max-width: 900px) {
  .detail .hero {
    flex-direction: column;
    text-align: center;
    gap: 32px;
  }

  .details-side {
    width: 100%;
  }

  .details-side h1 {
    font-size: 36px;
    margin-bottom: 20px;
  }

  .detail-meta {
    justify-content: center;
  }

  .filter-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 720px) {
  .top {
    padding: 32px 16px 16px;
  }

  .top h1 {
    font-size: 28px;
  }

  .subtitle {
    font-size: 14px;
  }

  .filters-container {
    padding: 12px 16px 24px;
  }

  .filters-form {
    padding: 18px;
  }

  .filter-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .filter-actions {
    flex-direction: column;
    gap: 8px;
  }

  .btn-submit,
  .reset-btn {
    width: 100%;
  }

  .cards-wrap {
    padding: 16px 16px 32px;
  }

  .cards {
    gap: 16px;
    padding: 8px 4px 20px;
    scroll-padding-inline: 4px;
  }

  .card {
    min-width: 280px;
    width: 280px;
  }

  .portrait-container {
    height: 200px;
  }

  .nav {
    display: none;
    /* Hide carousel navigation buttons on mobile touch devices */
  }

  .story,
  .gallery {
    padding: 24px 16px;
  }

  .story h2,
  .gallery h2 {
    font-size: 20px;
  }

  .portrait-large {
    width: 220px;
    height: 220px;
  }

  .detail-meta {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .detail-meta-item {
    padding: 12px;
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .detail-meta {
    grid-template-columns: 1fr;
  }

  .detail-meta-item {
    padding: 14px 16px;
  }
}

/* --- Added during CSS cleanup --- */
.rotate-180 {
  transform: rotate(180deg);
}

.sort-bar-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

@media (max-width: 600px) {
  .filter-bottom-bar {
    flex-direction: column-reverse;
    align-items: center;
    justify-content: center;
  }

  .filter-actions {
    width: 100%;
    justify-content: center;
  }

  .sort-section-outer {
    padding: 0 16px;
    margin-bottom: 16px;
  }

  .sort-bar-container-centered {
    flex-direction: column;
    gap: 8px;
    width: 100%;
    align-items: center;
  }
}

.sort-section-outer {
  display: flex;
  justify-content: center;
  margin: 0 auto 24px;
  padding: 0 48px;
  max-width: 1440px;
  width: 100%;
}

.sort-bar-container-centered {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sort-bar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-family: var(--font-sans);
}

html[dir="rtl"] .sort-bar-label {
  font-family: var(--font-fa);
}

.sort-segmented-control {
  display: flex;
  background: rgba(8, 4, 4, 0.5);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  align-items: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.sort-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--font-sans);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

html[dir="rtl"] .sort-tab {
  font-family: var(--font-fa);
}

.sort-tab:hover {
  color: #fff;
}

.sort-tab.active {
  background: var(--accent-crimson);
  color: #fff;
  box-shadow: 0 2px 10px rgba(158, 12, 12, 0.35);
}

.sort-direction-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.sort-direction-icon svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  display: inline-block;
}

.map-page-main {
  padding: 18px;
  text-align: center;
  position: relative;
}

#map-info-panel {
  max-width: 600px;
  margin: 10px auto 24px;
  padding: 14px 20px;
  background: rgba(20, 11, 11, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  font-size: 18px;
  font-weight: 500;
  color: var(--accent-gold);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  min-height: 56px;
  line-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  font-family: var(--font-sans);
}

html[dir="rtl"] #map-info-panel {
  font-family: var(--font-fa);
}

#map-container {
  width: 100%;
  max-width: 900px;
  height: 70vh;
  margin: 0 auto;
  position: relative;
}

#map-container svg {
  width: 100%;
  height: 100%;
  display: block;
}

@media (max-width: 768px) {
  #map-container {
    height: auto;
    aspect-ratio: 1200 / 1070.6;
  }

  .map-page-main {
    padding: 10px !important;
  }
}

/* --- Age Multi-range Slider --- */
.age-slider-container {
  position: relative;
  width: 100%;
  height: 48px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.age-slider-track {
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  z-index: 1;
}

.age-slider-container input[type="range"] {
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  height: 6px;
  background: none;
  pointer-events: none;
  appearance: none;
  -webkit-appearance: none;
  z-index: 2;
  margin: 0;
}

.age-slider-container input[type="range"]::-webkit-slider-runnable-track {
  background: transparent;
  height: 6px;
}

.age-slider-container input[type="range"]::-webkit-slider-thumb {
  pointer-events: auto;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-gold);
  border: 1px solid var(--accent-gold);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(197, 168, 128, 0.5);
  transition: transform 0.1s ease, background-color 0.1s ease;
  margin-top: -6px;
  /* Centering offset */
}

.age-slider-container input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  background: #fff;
}

.age-slider-container input[type="range"]::-moz-range-track {
  background: transparent;
  height: 6px;
}

.age-slider-container input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-gold);
  border: 1px solid var(--accent-gold);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(197, 168, 128, 0.5);
  transition: transform 0.1s ease, background-color 0.1s ease;
  border: none;
}

.age-slider-container input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.25);
  background: #fff;
}

.age-slider-values {
  margin-top: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  font-family: var(--font-sans);
}

html[dir="rtl"] .age-slider-values {
  font-family: var(--font-fa);
}

/* --- Year Multi-range Slider --- */
.year-slider-container {
  position: relative;
  width: 100%;
  height: 48px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.year-slider-track {
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  z-index: 1;
}

.year-slider-container input[type="range"] {
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  height: 6px;
  background: none;
  pointer-events: none;
  appearance: none;
  -webkit-appearance: none;
  z-index: 2;
  margin: 0;
}

.year-slider-container input[type="range"]::-webkit-slider-runnable-track {
  background: transparent;
  height: 6px;
}

.year-slider-container input[type="range"]::-webkit-slider-thumb {
  pointer-events: auto;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-gold);
  border: 1px solid var(--accent-gold);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(197, 168, 128, 0.5);
  transition: transform 0.1s ease, background-color 0.1s ease;
  margin-top: -6px;
  /* Centering offset */
}

.year-slider-container input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  background: #fff;
}

.year-slider-container input[type="range"]::-moz-range-track {
  background: transparent;
  height: 6px;
}

.year-slider-container input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-gold);
  border: 1px solid var(--accent-gold);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(197, 168, 128, 0.5);
  transition: transform 0.1s ease, background-color 0.1s ease;
  border: none;
}

.year-slider-container input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.25);
  background: #fff;
}

.year-slider-values {
  margin-top: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  font-family: var(--font-sans);
}

html[dir="rtl"] .year-slider-values {
  font-family: var(--font-fa);
}

/* Graceful Placeholder for Missing Portrait Image */
.portrait-placeholder {
  background: linear-gradient(135deg, #1c1010 0%, #120a0a 100%) !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  position: relative;
}

.portrait-placeholder::before {
  content: '';
  width: 56px;
  height: 56px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%236b5858"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z"/></svg>');
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.45;
  transition: opacity 0.4s ease;
}

.card:hover .portrait-placeholder::before {
  opacity: 0.7;
}

.portrait-large.portrait-placeholder::before {
  width: 96px;
  height: 96px;
}

/* References Section */
.references-section {
  padding: 40px;
  background: rgba(20, 11, 11, 0.25);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  margin-bottom: 40px;
  position: relative;
  z-index: 5;
  box-shadow: var(--glow-red);
}

.references-section h2 {
  font-size: 24px;
  color: #fff;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(158, 12, 12, 0.2);
  padding-bottom: 10px;
  display: inline-block;
}

.references-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.reference-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.reference-link {
  color: var(--accent-gold);
  font-size: 15.5px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  word-break: break-all;
  line-height: 1.4;
}

.reference-link:hover {
  color: #fff;
  transform: translateX(6px);
}

html[lang="fa"] .reference-link:hover {
  transform: translateX(-6px);
}

.reference-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
  opacity: 0.8;
  transition: opacity 0.25s ease;
}

.reference-link:hover .reference-icon {
  opacity: 1;
}

@media (max-width: 720px) {
  .references-section {
    padding: 24px 16px;
  }

  .references-section h2 {
    font-size: 20px;
  }

  .reference-link {
    font-size: 14.5px;
  }
}

/* Site Footer */
.site-footer {
  text-align: center;
  padding: 48px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  margin-top: 60px;
  position: relative;
  z-index: 10;
}

.site-footer a {
  color: var(--text-muted);
  font-size: 13.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.25s ease;
}

html[lang="fa"] .site-footer a {
  font-family: var(--font-fa);
  letter-spacing: 0;
  font-size: 14px;
}

.site-footer a:hover {
  color: var(--accent-gold);
  text-shadow: 0 0 8px rgba(197, 168, 128, 0.25);
}

.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.site-footer .sep {
  color: rgba(255, 255, 255, 0.1);
  font-size: 12px;
  user-select: none;
}

.footer-dedication {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 12px;
}

html[lang="fa"] .footer-dedication {
  font-family: var(--font-fa);
  font-size: 13px;
}