/* مطالعه موردی — صفحه جزئیات (هم‌خوان با گالری نمونه‌کار) */

.portfolio-case-page {
  --pf-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --pf-accent: #7c3aed;
  --pf-accent-2: #f59e0b;
  --pf-accent-soft: rgb(124 58 237 / 0.12);
  --pf-accent-border: rgb(124 58 237 / 0.28);
  --pf-radius-lg: 24px;
  --pf-radius-md: 16px;
  --pf-max: min(1240px, calc(100% - clamp(1.25rem, 4vw, 2.75rem)));
}

.pf-theme-commerce {
  --pf-accent: #059669;
  --pf-accent-2: #8b5cf6;
  --pf-accent-soft: rgb(5 150 105 / 0.12);
  --pf-accent-border: rgb(5 150 105 / 0.28);
}

.pf-theme-estate {
  --pf-accent: #2563eb;
  --pf-accent-2: #f59e0b;
  --pf-accent-soft: rgb(37 99 235 / 0.12);
  --pf-accent-border: rgb(37 99 235 / 0.28);
}

.pf-theme-media {
  --pf-accent: #dc2626;
  --pf-accent-2: #6366f1;
  --pf-accent-soft: rgb(220 38 38 / 0.1);
  --pf-accent-border: rgb(220 38 38 / 0.26);
}

[data-theme="dark"] .portfolio-case-page {
  --pf-accent-soft: rgb(167 139 250 / 0.14);
  --pf-accent-border: rgb(167 139 250 / 0.32);
}

.portfolio-case-page .site-main.container {
  padding-top: var(--header-clearance);
}

.pf-case-main.container {
  width: var(--pf-max);
  max-width: 1240px;
}

.pf-case {
  position: relative;
  isolation: isolate;
  padding-block: var(--space-4) clamp(3rem, 7vw, 5rem);
}

/* Ambient (shared pattern with index) */
.pf-ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

.pf-ambient__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  animation: pf-case-orb 18s var(--pf-ease) infinite;
}

.pf-ambient__orb--a {
  width: min(480px, 65vw);
  height: min(480px, 65vw);
  top: -8%;
  inset-inline-start: -6%;
  background: radial-gradient(circle, color-mix(in srgb, var(--pf-accent) 35%, transparent), transparent 70%);
}

.pf-ambient__orb--b {
  width: min(400px, 55vw);
  height: min(400px, 55vw);
  bottom: 0;
  inset-inline-end: -8%;
  background: radial-gradient(circle, color-mix(in srgb, var(--pf-accent-2) 28%, transparent), transparent 72%);
  animation-delay: -5s;
}

.pf-ambient__grid {
  position: absolute;
  inset: 0;
  opacity: 0.32;
  background-image:
    linear-gradient(rgb(15 23 42 / 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgb(15 23 42 / 0.04) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 75% 55% at 50% 15%, black, transparent);
}

@keyframes pf-case-orb {
  50% {
    transform: translate3d(2%, 3%, 0) scale(1.04);
  }
}

.pf-kicker {
  margin: 0 0 0.4rem;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--pf-accent);
}

.pf-lead,
.pf-muted {
  color: var(--color-text-muted);
  line-height: 1.75;
}

.pf-lead {
  margin: 0 0 1.1rem;
  max-width: 58ch;
}

/* Reading progress */
.pf-case-progress {
  position: fixed;
  top: var(--header-height, 64px);
  inset-inline: 0;
  z-index: 40;
  height: 3px;
  background: rgb(15 23 42 / 0.06);
  pointer-events: none;
}

.pf-case-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--pf-accent), var(--pf-accent-2));
  transition: width 0.12s linear;
}

/* Hero */
.pf-case-hero {
  margin-bottom: clamp(1.75rem, 4vw, 2.5rem);
  padding: clamp(1.1rem, 3vw, 1.75rem);
  border-radius: var(--pf-radius-lg);
}

.pf-case-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.pf-case-back:hover {
  color: var(--pf-accent);
}

.pf-case-hero__grid {
  display: grid;
  gap: clamp(1.25rem, 3vw, 2rem);
}

@media (min-width: 960px) {
  .pf-case-hero__grid {
    grid-template-columns: 1.05fr 0.95fr;
    align-items: stretch;
  }
}

.pf-case-hero h1 {
  margin: 0 0 0.65rem;
  font-size: clamp(1.75rem, 4.5vw, 2.45rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.pf-case-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem 1rem;
  margin: 0;
}

@media (min-width: 640px) {
  .pf-case-facts {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.pf-case-facts dt {
  margin: 0 0 0.15rem;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.pf-case-facts dd {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 700;
}

.pf-case-summary {
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem;
  border-radius: var(--pf-radius-md);
  border: 1px solid var(--pf-accent-border);
  background: color-mix(in srgb, var(--pf-accent-soft) 65%, var(--glass-l2-bg));
}

.pf-case-summary__title {
  margin: 0 0 0.55rem;
  font-size: var(--text-xs);
  font-weight: 800;
  color: var(--pf-accent);
}

.pf-case-summary ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.45rem;
}

.pf-case-summary li {
  font-size: var(--text-sm);
  line-height: 1.65;
  color: var(--color-text-muted);
}

.pf-case-summary strong {
  color: var(--color-text);
  font-weight: 700;
}

.pf-case-hero__visual {
  border-radius: var(--pf-radius-md);
  overflow: hidden;
  min-height: 240px;
  transition: transform 0.45s var(--pf-ease);
}

.pf-case-cover {
  margin: 0;
  height: 100%;
  min-height: 240px;
}

.pf-case-cover img {
  width: 100%;
  height: 100%;
  min-height: 240px;
  object-fit: cover;
}

.pf-case-pipeline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.5rem;
  min-height: 240px;
  padding: 1.25rem;
  background:
    radial-gradient(circle at 30% 20%, var(--pf-accent-soft), transparent 55%),
    radial-gradient(circle at 70% 80%, rgb(245 158 11 / 0.08), transparent 50%);
}

.pf-case-pipeline__node {
  padding: 0.45rem 0.85rem;
  font-size: var(--text-xs);
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid var(--pf-accent-border);
  background: var(--glass-l2-bg);
}

.pf-case-pipeline__node--core {
  color: var(--pf-accent);
  box-shadow: 0 0 0 1px var(--pf-accent-soft);
}

.pf-case-pipeline__wire {
  flex: 0 0 28px;
  height: 2px;
  background: linear-gradient(90deg, var(--pf-accent-border), transparent);
}

.pf-case-pipeline__metrics {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.pf-case-pipeline__metrics li {
  padding: 0.65rem;
  text-align: center;
  border-radius: var(--pf-radius-md);
  background: var(--glass-l1-bg);
  border: 1px solid var(--glass-l2-border);
}

.pf-case-pipeline__metrics strong {
  display: block;
  font-size: var(--text-sm);
  font-weight: 800;
}

.pf-case-pipeline__metrics span {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Layout */
.pf-case-layout {
  display: grid;
  gap: clamp(1.25rem, 3vw, 2rem);
  align-items: start;
}

@media (min-width: 1024px) {
  .pf-case-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

.pf-case-nav {
  position: sticky;
  top: calc(var(--header-clearance, 4rem) + 0.75rem);
  padding: 1rem;
  border-radius: var(--pf-radius-md);
}

.pf-case-nav__title {
  margin: 0 0 0.65rem;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-muted);
}

.pf-case-nav ol {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.pf-case-nav a {
  display: block;
  padding: 0.4rem 0.55rem;
  margin-bottom: 0.15rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  border-radius: 10px;
  border-inline-start: 2px solid transparent;
  transition:
    color 0.2s,
    background 0.2s,
    border-color 0.2s;
}

.pf-case-nav a:hover,
.pf-case-nav a.is-active {
  color: var(--pf-accent);
  background: var(--pf-accent-soft);
  border-inline-start-color: var(--pf-accent);
}

.pf-case-nav__stack span {
  display: block;
  margin-bottom: 0.4rem;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.pf-case-nav__stack ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.pf-case-nav__stack li {
  font-size: var(--text-xs);
  font-family: ui-monospace, monospace;
  color: var(--color-text-muted);
  padding: 0.15rem 0;
}

.pf-case-stream {
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 2.5vw, 1.35rem);
}

.pf-case-block {
  padding: clamp(1.1rem, 2.5vw, 1.5rem);
  border-radius: var(--pf-radius-md);
}

.pf-case-block--accent {
  border: 1px solid var(--pf-accent-border);
  background:
    linear-gradient(145deg, var(--pf-accent-soft), transparent 55%),
    var(--glass-l3-bg);
}

.pf-case-block__head {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--glass-l2-border);
}

.pf-case-block__head .pf-kicker {
  margin-bottom: 0.25rem;
}

.pf-case-block__head h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2.5vw, 1.55rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.pf-case-prose {
  margin: 0;
  font-size: var(--text-md);
  line-height: 1.85;
  max-width: 68ch;
}

.pf-case-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pf-case-chips li {
  padding: 0.55rem 0.85rem;
  font-size: var(--text-sm);
  border-radius: 999px;
}

.pf-case-flow {
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.65rem;
}

.pf-case-flow li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: start;
  padding: 0.75rem 0.85rem;
  border-radius: var(--pf-radius-md);
  background: var(--glass-l1-bg);
  border: 1px solid var(--glass-l2-border);
}

.pf-case-flow__index {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  font-size: var(--text-sm);
  font-weight: 800;
  border-radius: 10px;
  color: var(--pf-accent);
  background: var(--pf-accent-soft);
}

.pf-case-flow p {
  margin: 0;
  line-height: 1.7;
}

.pf-case-checklist {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.5rem;
}

.pf-case-checklist li {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.75rem 0.85rem;
  border-radius: var(--pf-radius-md);
  font-size: var(--text-sm);
  line-height: 1.65;
}

.pf-case-checklist__icon {
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.pf-case-bento {
  display: grid;
  gap: 0.65rem;
}

@media (min-width: 640px) {
  .pf-case-bento {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.pf-case-bento article {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 1rem;
  border-radius: var(--pf-radius-md);
}

.pf-case-bento p {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.65;
}

.pf-case-metrics {
  display: grid;
  gap: 0.65rem;
}

@media (min-width: 640px) {
  .pf-case-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.pf-case-metrics article {
  padding: 1rem;
  border-radius: var(--pf-radius-md);
  text-align: center;
}

.pf-case-metrics span {
  display: block;
  margin-bottom: 0.35rem;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.pf-case-metrics strong {
  font-size: var(--text-sm);
  font-weight: 800;
  line-height: 1.5;
}

.pf-case-visuals {
  display: grid;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .pf-case-visuals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.pf-case-visual {
  margin: 0;
  padding: 0;
  border-radius: var(--pf-radius-md);
  overflow: hidden;
}

.pf-case-visual__art {
  display: flex;
  gap: 0.35rem;
  padding: 1.25rem;
  min-height: 120px;
  align-items: flex-end;
  background: linear-gradient(160deg, var(--pf-accent-soft), transparent);
}

.pf-case-visual__art span {
  flex: 1;
  height: 48px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--pf-accent) 25%, transparent);
}

.pf-case-visual__art span:nth-child(2) {
  height: 72px;
}

.pf-case-visual figcaption {
  padding: 0.85rem 1rem 1rem;
}

.pf-case-visual strong {
  display: block;
  margin-bottom: 0.25rem;
}

.pf-case-visual span {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* Related */
.pf-case-related {
  margin-top: clamp(2rem, 5vw, 3rem);
}

.pf-section-head h2 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 800;
}

.pf-case-related__grid {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

@media (min-width: 768px) {
  .pf-case-related__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.pf-case-related__card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.1rem;
  border-radius: var(--pf-radius-md);
  text-decoration: none;
  color: inherit;
  transition: transform 0.4s var(--pf-ease);
}

.pf-case-related__card:hover {
  transform: translateY(-4px);
}

.pf-case-related__domain {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--pf-accent);
}

.pf-case-related__card h3 {
  margin: 0;
  font-size: var(--text-md);
  font-weight: 800;
}

.pf-case-related__card p {
  margin: 0;
  flex: 1;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
}

.pf-case-related__cta {
  margin-top: 0.5rem;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--pf-accent);
}

/* CTA */
.pf-case-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  margin-top: clamp(2rem, 5vw, 3rem);
  padding: clamp(1.25rem, 3vw, 1.75rem);
  border-radius: var(--pf-radius-lg);
}

.pf-case-cta h2 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.25rem, 2.8vw, 1.65rem);
  font-weight: 800;
}

.pf-case-cta__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

@media (min-width: 1024px) {
  .pf-case-stream {
    position: relative;
    padding-inline-start: 1.35rem;
    border-inline-start: 2px solid var(--pf-accent-border);
  }

  .pf-case-block {
    position: relative;
  }

  .pf-case-block::before {
    content: "";
    position: absolute;
    inset-inline-start: calc(-1.35rem - 7px);
    top: 1.65rem;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--pf-accent);
    box-shadow: 0 0 0 4px var(--pf-accent-soft);
  }
}

.pf-section-head {
  margin-bottom: 1.25rem;
}

.pf-section-head h2 {
  margin: 0.25rem 0 0.35rem;
  font-size: clamp(1.35rem, 2.8vw, 1.75rem);
  font-weight: 800;
}

@media (max-width: 1023px) {
  .pf-case-nav {
    position: relative;
    top: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
  }

  .pf-case-nav__title {
    width: 100%;
  }

  .pf-case-nav ol {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0;
  }

  .pf-case-nav a {
    margin: 0;
    border-inline-start: none;
    border: 1px solid var(--glass-l2-border);
  }

  .pf-case-nav__stack {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pf-ambient__orb {
    animation: none;
  }

  .pf-case-hero__visual,
  .pf-case-related__card {
    transition: none;
  }
}
