/* SysaiQ — portfolio (/:lang/work, /:lang/work/:slug). Loaded after pages.css
   on those two pages only; uses its tokens (--mint, --violet, --grad, --panel…).
   Logical properties only; no letter-spacing / uppercase on Persian runs;
   every image box has an aspect-ratio so nothing shifts while loading. */

/* ---------- shared ---------- */
.page-work .site-main, .page-case .site-main { background: radial-gradient(120% 60% at 50% -12%, rgba(139, 107, 255, .09), transparent 60%); }
.w-idx { font-size: 11px; color: var(--mint); white-space: nowrap; }
.w-idx.mono { letter-spacing: .16em; }

/* ---------- index head + filter chips ---------- */
.w-head { margin-bottom: 8px; }
.w-head .sub { margin-bottom: 30px; }
.w-filter { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 10px; }
.w-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 8px 16px;
  border: 1px solid var(--line); border-radius: 100px; background: var(--panel); color: var(--dim);
  font: inherit; font-size: 13.5px; line-height: 1.4; cursor: pointer;
  transition: color .25s, border-color .25s, background .25s, box-shadow .25s;
}
.w-chip:hover { color: var(--ink); border-color: rgba(236, 234, 246, .32); }
.w-chip[aria-pressed="true"] { color: var(--btn-ink); background: var(--grad); border-color: transparent; font-weight: 600; box-shadow: 0 14px 34px -18px rgba(139, 107, 255, .8); }
.w-count { display: inline-block; min-width: 22px; padding: 1px 7px; border-radius: 100px; background: rgba(236, 234, 246, .08); font-size: 11.5px; text-align: center; font-weight: 500; }
.w-chip[aria-pressed="true"] .w-count { background: rgba(6, 16, 31, .16); }
.w-status { min-height: 22px; margin: 0 0 18px; font-size: 12.5px; color: var(--faint); }

/* ---------- cards ---------- */
.w-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 24px; }
.w-item { min-width: 0; }
.w-item[hidden] { display: none; }
.is-pending { opacity: 0; }
.is-entering { animation: w-in .6s cubic-bezier(.2, .6, .2, 1) backwards; }
@keyframes w-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.w-card {
  position: relative; display: flex; flex-direction: column; height: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  transition: transform .45s cubic-bezier(.2, .6, .2, 1), box-shadow .45s, border-color .45s;
}
/* gradient hairline along the top edge */
.w-card::before { content: ""; position: absolute; inset-inline: 0; top: 0; height: 1px; background: var(--grad); opacity: .35; z-index: 2; transition: opacity .45s; }
.w-card:hover, .w-card:focus-visible { transform: translateY(-6px); box-shadow: 0 30px 60px -28px rgba(139, 107, 255, .55); border-color: rgba(236, 234, 246, .2); }
.w-card:hover::before, .w-card:focus-visible::before { opacity: 1; }
.w-media { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; background: #081428; }
.w-media img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top center;
  transform: scale(1.001); transition: transform 7s cubic-bezier(.16, .6, .2, 1);
}
/* gentle Ken Burns: a slow push-in while the pointer rests on the card */
.w-card:hover .w-media img, .w-card:focus-visible .w-media img { transform: scale(1.07) translate3d(0, -1.2%, 0); }
.w-media::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(7, 10, 18, .5)); pointer-events: none; }
.w-body { display: flex; flex-direction: column; gap: 8px; padding: 18px 20px 20px; flex: 1; }
.w-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.w-cat { font-size: 12px; color: var(--dim); }
.w-flag { font-size: 11px; color: var(--btn-ink); background: var(--grad); border-radius: 100px; padding: 1px 10px; font-weight: 600; }
.w-body b { font-size: 17px; font-weight: 500; line-height: 1.45; color: var(--ink); }
.w-body p { margin: 0; font-size: 13.5px; color: var(--dim); line-height: 1.75; flex: 1; }
.w-tags { font-size: 9.5px; color: var(--mint); opacity: .85; line-height: 1.6; }
.w-tags .mono { letter-spacing: .14em; }
.w-go { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; font-style: normal; font-size: 12.5px; color: var(--mint); }
.w-go span { display: inline-block; transition: transform .3s; }
.w-card:hover .w-go span { transform: translateX(4px); }
[dir="rtl"] .w-card:hover .w-go span { transform: translateX(-4px); }

/* featured: the first project, wide, image beside the copy on desktop */
.w-item.is-featured { grid-column: 1 / -1; }
.is-featured .w-card { box-shadow: 0 50px 90px -50px rgba(139, 107, 255, .45); }
.is-featured .w-body { padding: 22px 24px 26px; gap: 10px; }
.is-featured .w-body b { font-size: clamp(22px, 2.8vw, 34px); font-weight: 300; line-height: 1.2; letter-spacing: -.01em; }
[dir="rtl"] .is-featured .w-body b { letter-spacing: 0; line-height: 1.45; }
.is-featured .w-body p { font-size: 15px; color: var(--body); flex: 0 1 auto; max-width: 520px; }
@media (min-width: 900px) {
  .is-featured .w-card { flex-direction: row; min-height: 380px; }
  .is-featured .w-media { flex: 1.6 1 0; aspect-ratio: auto; min-height: 380px; }
  .is-featured .w-body { flex: 1 1 0; justify-content: center; padding: 36px 36px 36px; }
}

/* ---------- case study: hero + cover + facts ---------- */
.w-detail { max-width: 1120px; }
.w-hero { padding-block: 4px 26px; }
.w-hero .tagline { font-size: clamp(16px, 2.3vw, 22px); color: var(--body); font-weight: 300; margin: 0 0 14px; max-width: 780px; line-height: 1.6; }
.w-hero__tags { margin: 0; font-size: 10.5px; color: var(--mint); opacity: .85; }
.w-hero__tags .mono { letter-spacing: .14em; }
.w-cover {
  position: relative; margin: 0; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 18px;
  border: 1px solid var(--line); background: #081428;
  box-shadow: 0 60px 110px -50px rgba(0, 0, 0, .85), 0 40px 120px -70px rgba(139, 107, 255, .55);
}
.w-cover::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(180deg, rgba(125, 255, 217, .05), transparent 30%, transparent 75%, rgba(7, 10, 18, .35)); pointer-events: none; }
.w-cover__img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.w-cover__badge { position: absolute; inset-block-end: 14px; inset-inline-start: 14px; z-index: 1; padding: 4px 12px; border-radius: 100px; font-size: 12px; color: var(--ink); background: rgba(10, 10, 14, .66); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid rgba(236, 234, 246, .12); }
.w-facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1px; margin: 22px 0 0;
  background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
}
.w-fact { background: var(--bg); padding: 16px 20px; min-width: 0; }
.w-fact dt { font-size: 11.5px; color: var(--faint); margin: 0 0 4px; }
.w-fact dd { margin: 0; font-size: 14.5px; color: var(--ink); line-height: 1.6; }
.w-fact a { color: var(--mint); }
.w-fact a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- sections ---------- */
.w-sec { margin: 64px 0; }
.w-sec__head { margin-bottom: 22px; }
.w-sec__h { font-size: clamp(22px, 3vw, 30px); font-weight: 300; letter-spacing: -.01em; line-height: 1.25; color: var(--ink); }
[dir="rtl"] .w-sec__h { letter-spacing: 0; line-height: 1.5; }
.w-sec__sub { margin: 8px 0 0; font-size: 14px; color: var(--dim); }
.w-sec--overview { margin-top: 44px; }
.w-sec--overview .lead { max-width: 820px; }

/* the story: problem → solution → outcome on a vertical rail */
.w-story { position: relative; margin: 64px 0; }
.w-story::before { content: ""; position: absolute; top: 34px; bottom: 34px; inset-inline-start: 21px; width: 1px; background: linear-gradient(180deg, var(--mint), var(--violet) 70%, transparent); opacity: .4; }
.w-beat { position: relative; display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 36px; padding-block: 30px; }
.w-beat + .w-beat { border-top: 1px solid var(--line); }
.w-beat__head { position: sticky; top: calc(var(--header-h) + 24px); align-self: start; display: grid; grid-template-columns: 44px 1fr; column-gap: 16px; align-items: center; }
.w-beat__n {
  grid-row: span 2; position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(125, 255, 217, .4); background: var(--bg);
  box-shadow: inset 0 0 18px rgba(125, 255, 217, .12); color: var(--mint); font-size: 13px; font-family: var(--mono);
}
[dir="rtl"] .w-beat__n { font-family: inherit; }
.w-beat__eyebrow { margin: 0; font-size: 10px; letter-spacing: .22em; color: var(--faint); justify-self: start; } /* the LTR island sits at the column start under RTL too */
.w-beat h2 { font-size: clamp(24px, 3.2vw, 36px); font-weight: 300; letter-spacing: -.015em; line-height: 1.2; }
[dir="rtl"] .w-beat h2 { letter-spacing: 0; line-height: 1.45; }
.w-beat--outcome h2 { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.w-beat .prose { font-size: 16px; max-width: 720px; }
.w-beat .prose h2 { font-size: 18px; font-weight: 500; margin: 22px 0 8px; }
.w-beat .prose h3 { font-size: 16px; }
.w-beat .prose ul { list-style: none; padding-inline-start: 0; }
.w-beat .prose ul > li { position: relative; padding-inline-start: 22px; margin-bottom: 10px; }
.w-beat .prose ul > li::before { content: ""; position: absolute; inset-inline-start: 2px; top: .8em; width: 8px; height: 1px; background: var(--mint); }

/* features */
.w-feats { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.w-feat { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px 22px 20px; transition: border-color .3s, transform .3s; }
.w-feat::before { content: ""; position: absolute; top: -1px; inset-inline-start: 22px; width: 40px; height: 1px; background: var(--grad); }
.w-feat:hover { border-color: rgba(236, 234, 246, .22); transform: translateY(-3px); }
.w-feat h3 { font-size: 16px; font-weight: 500; line-height: 1.5; margin: 10px 0 8px; }
.w-feat p { margin: 0; font-size: 13.5px; color: var(--dim); line-height: 1.8; }

/* pages & screens */
.w-pages { list-style: none; margin: 0; padding: 0; }
.w-pg { display: grid; grid-template-columns: 56px 220px minmax(0, 1fr); gap: 16px; align-items: baseline; padding: 16px 4px; border-top: 1px solid var(--line); }
.w-pg:last-child { border-bottom: 1px solid var(--line); }
.w-pg .pn { font-weight: 500; font-size: 15px; color: var(--ink); }
.w-pg .pd { color: var(--dim); font-size: 14px; line-height: 1.8; }

/* gallery */
.w-gal { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.w-gal.is-single { grid-template-columns: 1fr; }
.w-gal figure { margin: 0; }
.w-gal__link { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 14px; border: 1px solid var(--line); background: #081428; cursor: zoom-in; }
.w-gal__link img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; transition: transform 6s cubic-bezier(.16, .6, .2, 1), opacity .3s; }
.w-gal__link:hover img, .w-gal__link:focus-visible img { transform: scale(1.05); }
.w-gal__link::after { content: "⤢"; position: absolute; inset-block-start: 12px; inset-inline-end: 12px; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; color: var(--ink); background: rgba(10, 10, 14, .6); border: 1px solid rgba(236, 234, 246, .15); opacity: 0; transition: opacity .3s; }
.w-gal__link:hover::after, .w-gal__link:focus-visible::after { opacity: 1; }
.w-gal figcaption { margin-top: 10px; font-size: 13px; color: var(--dim); line-height: 1.7; }

/* technical approach */
.w-tech { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px 28px 8px; font-size: 15px; position: relative; overflow: hidden; }
.w-tech::before { content: ""; position: absolute; inset-inline: 0; top: 0; height: 1px; background: var(--grad); opacity: .6; }
.w-tech strong { color: var(--mint); font-weight: 500; }

/* industries + related service */
.w-duo { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 32px; margin: 64px 0; }
.w-duo .w-sec { margin: 0; }
.w-svc { display: flex; flex-direction: column; gap: 8px; padding: 22px 24px; border-radius: 16px; border: 1px solid var(--line); background: linear-gradient(160deg, rgba(139, 107, 255, .12), rgba(125, 255, 217, .05)); transition: border-color .3s, transform .3s; }
.w-svc:hover, .w-svc:focus-visible { border-color: rgba(125, 255, 217, .4); transform: translateY(-3px); }
.w-svc__t { font-size: 18px; font-weight: 400; color: var(--ink); }
.w-svc__go { font-size: 13px; color: var(--mint); }

/* related + pager + CTA */
.w-list--related { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.w-pager { display: flex; flex-wrap: wrap; gap: 16px; margin: 56px 0 0; padding-top: 24px; border-top: 1px solid var(--line); }
.w-pager__link { display: flex; flex-direction: column; gap: 4px; min-width: 0; max-width: 48%; padding: 10px 4px; }
.w-pager__next { margin-inline-start: auto; text-align: end; }
.w-pager__k { font-size: 12px; color: var(--faint); }
.w-pager__t { font-size: 17px; font-weight: 400; color: var(--ink); transition: color .25s; }
.w-pager__link:hover .w-pager__t { color: var(--mint); }
.w-cta {
  position: relative; overflow: hidden; margin: 72px 0 12px; padding: 52px 24px; text-align: center;
  border: 1px solid var(--line); border-radius: 20px; display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: radial-gradient(80% 120% at 50% 0%, rgba(139, 107, 255, .18), transparent 60%), linear-gradient(160deg, rgba(139, 107, 255, .08), rgba(125, 255, 217, .05));
}
.w-cta::before { content: ""; position: absolute; inset-inline: 15%; top: 0; height: 1px; background: var(--grad); }
.w-cta h2 { font-size: clamp(24px, 3.6vw, 36px); letter-spacing: -.01em; margin: 0; }
[dir="rtl"] .w-cta h2 { letter-spacing: 0; line-height: 1.45; }
.w-cta p { margin: 0 0 6px; max-width: 580px; color: var(--body); }
.w-cta__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

/* ---------- lightbox (<dialog>, driven by work.js) ---------- */
.w-lb { width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(5, 5, 7, .95); color: var(--ink); overflow: hidden; }
.w-lb[open] { display: flex; flex-direction: column; }
.w-lb::backdrop { background: rgba(5, 5, 7, .7); }
html.w-lb-open { overflow: hidden; }
.w-lb__stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 64px 16px 8px; touch-action: pan-y; }
.w-lb__fig { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 100%; max-height: 100%; }
.w-lb__img { display: block; max-width: min(94vw, 1500px); max-height: calc(100dvh - 170px); width: auto; height: auto; object-fit: contain; border-radius: 12px; box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .9); background: #081428; }
.w-lb__cap { font-size: 13.5px; color: var(--body); text-align: center; max-width: 760px; line-height: 1.7; }
.w-lb__cap:empty { display: none; }
.w-lb__bar { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 10px 16px 22px; }
.w-lb__bar[hidden] { display: none; }
.w-lb__btn { width: 46px; height: 46px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; border: 1px solid var(--line); background: rgba(14, 20, 34, .85); color: var(--ink); font: inherit; font-size: 19px; line-height: 1; cursor: pointer; transition: border-color .25s, background .25s; }
.w-lb__btn:hover { border-color: rgba(125, 255, 217, .5); background: rgba(24, 32, 56, .9); }
.w-lb__close { position: absolute; top: 14px; inset-inline-end: 14px; font-size: 24px; }
.w-lb__count { min-width: 70px; text-align: center; font-size: 13px; color: var(--dim); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .w-story::before { inset-inline-start: 21px; }
  .w-beat { grid-template-columns: 1fr; gap: 14px; padding-inline-start: 0; }
  .w-beat__head { position: static; }
  .w-beat .prose { padding-inline-start: 60px; }
  .w-pg { grid-template-columns: 44px minmax(0, 1fr); row-gap: 4px; }
  .w-pg .pd { grid-column: 2; }
  .w-duo { grid-template-columns: 1fr; gap: 48px; }
}
@media (max-width: 600px) {
  /* chips become one swipeable row instead of four stacked lines */
  .w-filter { flex-wrap: nowrap; overflow-x: auto; margin-inline: -16px; padding: 2px 16px 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .w-filter::-webkit-scrollbar { display: none; }
  .w-chip { flex: none; }
  .w-list, .w-list--related, .w-gal, .w-feats { grid-template-columns: 1fr; }
  .w-sec, .w-story, .w-duo { margin-block: 48px; }
  .w-cover { border-radius: 14px; }
  .w-facts { grid-template-columns: 1fr 1fr; }
  .w-fact { padding: 14px 16px; }
  .w-beat .prose { padding-inline-start: 0; }
  .w-story::before { display: none; }
  .w-pager__link { max-width: 100%; }
  .w-cta { padding: 38px 16px; }
  .w-lb__stage { padding: 60px 8px 8px; }
  .w-lb__img { max-width: 100%; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .w-media img, .w-gal__link img, .w-card, .w-feat, .w-svc { transition: none !important; }
  .w-card:hover .w-media img, .w-card:focus-visible .w-media img, .w-gal__link:hover img { transform: none; }
  .w-card:hover, .w-card:focus-visible, .w-feat:hover, .w-svc:hover { transform: none; }
  .is-entering { animation: none; }
  .is-pending { opacity: 1; }
}
