/* ==========================================================================
   KF Agency — Public Clients Wall Component (assets/clients/clients-wall.css)
   Dependency-free styles for <section data-kf-clients>
   Supports EN (LTR) & AR (RTL), light theme & body.dark, reduced-motion, 360px+
   ========================================================================== */

[data-kf-clients] {
  --pcw-bg: var(--bg-alt, #f3effc);
  --pcw-surface: var(--surface, #ffffff);
  --pcw-ink: #0f0d24;
  --pcw-heading: var(--heading, #120d2b);
  --pcw-text: var(--text, #1c1638);
  --pcw-muted: var(--text-dim, #564e78);
  --pcw-faint: var(--text-faint, #877fa8);
  --pcw-line: var(--border, rgba(20, 14, 46, 0.09));
  --pcw-line-strong: var(--border-accent, rgba(124, 58, 237, 0.28));
  --pcw-acc: var(--accent, #7c3aed);
  --pcw-mag: var(--accent-pink, #db2777);
  --pcw-sky: var(--accent-blue, #0284c7);
  --pcw-grad: var(--kf-grad, var(--grad, linear-gradient(135deg, #db2777 0%, #7c3aed 55%, #0284c7 100%)));
  --pcw-font-disp: var(--kf-display, 'Space Grotesk', 'Cairo', sans-serif);
  --pcw-font-body: var(--kf-sans, 'DM Sans', 'Cairo', sans-serif);

  position: relative;
  padding: clamp(64px, 8vw, 108px) 0;
  background: var(--pcw-bg);
  border-top: 1px solid var(--pcw-line);
  border-bottom: 1px solid var(--pcw-line);
  color: var(--pcw-text);
  font-family: var(--pcw-font-body);
  box-sizing: border-box;
}

body.dark [data-kf-clients] {
  --pcw-bg: var(--bg-alt, #0d0d22);
  --pcw-surface: rgba(255, 255, 255, 0.04);
  --pcw-heading: #ffffff;
  --pcw-text: #e8e6f0;
  --pcw-muted: #9e9bb8;
  --pcw-faint: #7b7799;
  --pcw-line: rgba(255, 255, 255, 0.09);
  --pcw-line-strong: rgba(155, 109, 255, 0.35);
  --pcw-acc: #9b6dff;
}

[data-kf-clients] *,
[data-kf-clients] *::before,
[data-kf-clients] *::after {
  box-sizing: border-box;
}

[data-kf-clients][ data-lang="ar" ],
[dir="rtl"] [data-kf-clients],
body.ar [data-kf-clients] {
  direction: rtl;
  text-align: right;
  font-family: 'Cairo', sans-serif;
  --pcw-font-disp: 'Cairo', sans-serif;
  --pcw-font-body: 'Cairo', sans-serif;
}

[data-kf-clients][ data-lang="en" ],
body.en [data-kf-clients] {
  direction: ltr;
  text-align: left;
}

.pcw-container {
  width: min(1240px, calc(100% - clamp(32px, 6vw, 80px)));
  margin-inline: auto;
}

/* ---------- Section Header ---------- */
.pcw-header {
  max-width: 720px;
  margin-bottom: clamp(28px, 4vw, 44px);
}

.pcw-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pcw-acc);
}

.pcw-eyebrow::before {
  content: '';
  display: inline-block;
  width: 28px;
  height: 2px;
  background: var(--pcw-grad);
  border-radius: 2px;
}

[dir="rtl"] .pcw-eyebrow,
[data-kf-clients][data-lang="ar"] .pcw-eyebrow {
  letter-spacing: 0;
  font-size: 0.84rem;
}

.pcw-title {
  margin: 0 0 12px;
  font-family: var(--pcw-font-disp);
  font-size: clamp(1.85rem, 3.6vw, 2.75rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--pcw-heading);
}

[dir="rtl"] .pcw-title,
[data-kf-clients][data-lang="ar"] .pcw-title {
  letter-spacing: 0;
  line-height: 1.3;
}

.pcw-grad {
  background: var(--pcw-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.pcw-sub-lead {
  margin: 0;
  font-size: clamp(0.95rem, 1.4vw, 1.08rem);
  line-height: 1.65;
  color: var(--pcw-muted);
}

/* ---------- Headline Stats Strip ---------- */
.pcw-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 0 0 clamp(40px, 5vw, 56px);
  background: var(--pcw-line);
  border: 1px solid var(--pcw-line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(15, 13, 36, 0.04);
}

.pcw-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: clamp(20px, 2.6vw, 28px);
  background: var(--pcw-surface);
}

body.dark .pcw-stat {
  background: #111026;
}

.pcw-stat b {
  font-family: var(--pcw-font-disp);
  font-size: clamp(2rem, 3.2vw, 2.75rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  background: var(--pcw-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  align-self: flex-start;
  font-variant-numeric: tabular-nums;
}

[dir="rtl"] .pcw-stat b,
[data-kf-clients][data-lang="ar"] .pcw-stat b {
  letter-spacing: 0;
}

.pcw-stat span {
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--pcw-muted);
}

[dir="rtl"] .pcw-stat span,
[data-kf-clients][data-lang="ar"] .pcw-stat span {
  letter-spacing: 0;
  font-size: 0.84rem;
}

/* ---------- Subheadings ---------- */
.pcw-h {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 0 0 18px;
  font-family: var(--pcw-font-disp);
  font-size: clamp(1.2rem, 2vw, 1.45rem);
  font-weight: 700;
  line-height: 1.3;
  color: var(--pcw-heading);
}

.pcw-h small {
  font-family: var(--pcw-font-body);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pcw-acc);
  background: rgba(124, 58, 237, 0.09);
  padding: 4px 10px;
  border-radius: 999px;
}

[dir="rtl"] .pcw-h small,
[data-kf-clients][data-lang="ar"] .pcw-h small {
  letter-spacing: 0;
  font-size: 0.8rem;
}

/* ---------- Industry Spotlight Flip Cards ---------- */
.pcw-spot {
  margin: 0 0 clamp(44px, 5.5vw, 64px);
}

.pcw-feat {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
}

.pcw-feat.pcw-feat-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.pf {
  perspective: 1600px;
  border-radius: 18px;
  outline: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
}

.pf-static {
  cursor: default;
}

.pf-in {
  display: grid;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.2, 0.75, 0.2, 1);
}

.pf-face {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 256px;
  padding: 22px;
  border-radius: 18px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  min-width: 0;
}

.pf-front {
  background: var(--pcw-surface);
  border: 1px solid var(--pcw-line);
  box-shadow: 0 4px 16px rgba(15, 13, 36, 0.04);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

body.dark .pf-front {
  background: #121129;
}

.pf:hover .pf-front,
.pf:focus-visible .pf-front {
  border-color: var(--pcw-line-strong);
}

.pf .pf-front h4 {
  margin: 4px 0 0;
  font-family: var(--pcw-font-disp);
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--pcw-heading);
}

.pcw-meta {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--pcw-muted);
}

.pf-back {
  position: relative;
  overflow: hidden;
  background: var(--pcw-ink);
  border: 1px solid rgba(124, 58, 237, 0.4);
  color: #ffffff;
  transform: rotateY(180deg);
}

.pf-back::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--pcw-grad);
}

.pf .pf-back h4 {
  margin: 0;
  font-family: var(--pcw-font-disp);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  color: #ffffff;
}

.pcw-back-meta {
  margin: -4px 0 2px;
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.6);
}

.pcw-what {
  margin: 4px 0 0;
  font-size: 0.86rem;
  line-height: 1.58;
  color: rgba(255, 255, 255, 0.88);
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pcw-what span {
  display: block;
  margin-bottom: 3px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #c4b5fd;
}

[dir="rtl"] .pcw-what span,
[data-kf-clients][data-lang="ar"] .pcw-what span {
  letter-spacing: 0;
  font-size: 0.72rem;
}

.pf-hint {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--pcw-faint);
}

[dir="rtl"] .pf-hint,
[data-kf-clients][data-lang="ar"] .pf-hint {
  letter-spacing: 0;
  font-size: 0.74rem;
}

.pf-hint b {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--pcw-acc);
}

.pf-hint-back {
  justify-content: flex-end;
  color: rgba(255, 255, 255, 0.55);
}

.pf-hint-back b {
  color: #ffffff;
}

.pf-h-tap {
  display: none;
}

@media (hover: none) {
  .pf-h-hover {
    display: none;
  }
  .pf-h-tap {
    display: inline;
  }
}

@media (hover: hover) {
  .pf[role="button"]:hover .pf-in {
    transform: rotateY(180deg);
  }
  [dir="rtl"] .pf[role="button"]:hover .pf-in,
  [data-kf-clients][data-lang="ar"] .pf[role="button"]:hover .pf-in {
    transform: rotateY(-180deg);
  }
}

.pf.is-flipped .pf-in,
.pf[role="button"]:focus-within .pf-in {
  transform: rotateY(180deg);
}

[dir="rtl"] .pf.is-flipped .pf-in,
[dir="rtl"] .pf[role="button"]:focus-within .pf-in,
[data-kf-clients][data-lang="ar"] .pf.is-flipped .pf-in,
[data-kf-clients][data-lang="ar"] .pf[role="button"]:focus-within .pf-in {
  transform: rotateY(-180deg);
}

.pf:focus-visible {
  box-shadow: 0 0 0 2px var(--pcw-bg), 0 0 0 4px var(--pcw-acc);
}

/* ---------- Logo Box (Shared by Flip Cards & Wall Tiles) ---------- */
.pcw-logo {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 92px;
  padding: 14px 18px;
  background: #ffffff;
  border: 1px solid var(--pcw-line);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.pcw-logo img {
  display: block;
  max-width: 100%;
  max-height: 62px;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: filter 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}

.pcw-logo b {
  display: none;
  font-family: var(--pcw-font-disp);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--pcw-acc);
  user-select: none;
}

.pcw-logo.pcw-nologo {
  background: linear-gradient(135deg, rgba(219, 39, 119, 0.06), rgba(124, 58, 237, 0.1));
}

.pcw-logo.pcw-nologo b {
  display: block;
}

.pcw-logo.pcw-dark {
  background: var(--pcw-ink);
  border-color: rgba(255, 255, 255, 0.12);
}

.pcw-logo.pcw-dark.pcw-nologo b {
  color: #c4b5fd;
}

.pcw-grey img {
  filter: grayscale(1);
  opacity: 0.68;
}

.pcw-dark.pcw-grey img {
  filter: grayscale(1) brightness(1.12);
  opacity: 0.82;
}

.pcw-tile:hover .pcw-grey img,
.pcw-tile:focus-within .pcw-grey img,
.pcw-tile:focus-visible .pcw-grey img {
  filter: none;
  opacity: 1;
  transform: scale(1.03);
}

.pcw-tile:hover .pcw-logo,
.pcw-tile:focus-within .pcw-logo,
.pcw-tile:focus-visible .pcw-logo {
  border-color: var(--pcw-line-strong);
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.1);
}

.pcw-tile:focus-visible {
  outline: 2px solid var(--pcw-acc);
  outline-offset: 3px;
  border-radius: 14px;
}

/* ---------- Filter Chips & Wall ---------- */
.pcw-wall-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 22px;
}

.pcw-wall-head .pcw-h {
  margin-bottom: 4px;
}

.pcw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pcw-chips button {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--pcw-line);
  background: var(--pcw-surface);
  color: var(--pcw-muted);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

body.dark .pcw-chips button {
  background: #121129;
}

.pcw-chips button span {
  margin-inline-start: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--pcw-faint);
}

.pcw-chips button:hover {
  border-color: var(--pcw-line-strong);
  color: var(--pcw-heading);
}

.pcw-chips button.on {
  background: var(--pcw-ink);
  border-color: var(--pcw-ink);
  color: #ffffff;
}

body.dark .pcw-chips button.on {
  background: var(--pcw-acc);
  border-color: var(--pcw-acc);
  color: #ffffff;
}

.pcw-chips button.on span {
  color: rgba(255, 255, 255, 0.72);
}

.pcw-chips button:focus-visible,
.pcw-all:focus-visible {
  outline: 2px solid var(--pcw-acc);
  outline-offset: 2px;
}

.pcw-wall {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px 12px;
}

.pcw-tile {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  outline: none;
}

.pcw-tile .pcw-logo {
  height: 86px;
}

.pcw-tile .pcw-logo img {
  max-height: 56px;
}

.pcw-name {
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--pcw-muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-inline: 4px;
}

.pcw-sub {
  margin-top: -5px;
  font-size: 0.66rem;
  line-height: 1.25;
  color: var(--pcw-faint);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-inline: 4px;
}

.pcw-more {
  display: none;
}

.pcw-more.pcw-more-on {
  display: flex;
}

.pcw-tile[hidden] {
  display: none !important;
}

.pcw-all-p {
  margin: 26px 0 0;
  text-align: center;
}

.pcw-all {
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  padding: 11px 26px;
  border-radius: 999px;
  border: 1px solid var(--pcw-heading);
  background: var(--pcw-surface);
  color: var(--pcw-heading);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

body.dark .pcw-all {
  background: #121129;
  border-color: rgba(255, 255, 255, 0.28);
}

.pcw-all:hover {
  background: var(--pcw-heading);
  color: var(--pcw-surface);
}

body.dark .pcw-all:hover {
  background: var(--pcw-acc);
  border-color: var(--pcw-acc);
  color: #ffffff;
}

.pcw-rest {
  margin: 14px 0 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--pcw-faint);
  text-align: center;
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .pf-in {
    transition: none !important;
    transform: none !important;
  }
  .pf-face {
    transition: opacity 0.25s ease;
  }
  .pf-back {
    transform: none !important;
    opacity: 0;
    pointer-events: none;
  }
  .pf.is-flipped .pf-front,
  .pf[role="button"]:focus-within .pf-front {
    opacity: 0;
  }
  .pf.is-flipped .pf-back,
  .pf[role="button"]:focus-within .pf-back {
    opacity: 1;
    pointer-events: auto;
  }
  .pcw-logo,
  .pcw-logo img,
  .pcw-chips button,
  .pcw-all {
    transition: none !important;
  }
}

@media (prefers-reduced-motion: reduce) and (hover: hover) {
  .pf[role="button"]:hover .pf-front {
    opacity: 0;
  }
  .pf[role="button"]:hover .pf-back {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ---------- Responsive Breakpoints (Down to 360px) ---------- */
@media (max-width: 1024px) {
  .pcw-feat,
  .pcw-feat.pcw-feat-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .pcw-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .pcw-stat {
    padding: 18px 16px;
  }
  .pcw-stat b {
    font-size: 1.95rem;
  }
  .pcw-feat,
  .pcw-feat.pcw-feat-3 {
    grid-template-columns: 1fr;
  }
  .pcw-feat > .pf:nth-child(n+5) {
    display: none;
  }
  .pf-face {
    min-height: 224px;
    padding: 18px;
  }
  .pcw-wall {
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 12px 10px;
  }
  .pcw-tile .pcw-logo {
    height: 76px;
    padding: 10px 12px;
  }
  .pcw-tile .pcw-logo img {
    max-height: 48px;
  }
}

@media (max-width: 420px) {
  .pcw-container {
    width: calc(100% - 28px);
  }
  .pcw-stats {
    border-radius: 14px;
  }
  .pcw-stat {
    padding: 14px 12px;
  }
  .pcw-stat b {
    font-size: 1.7rem;
  }
  .pcw-stat span {
    font-size: 0.66rem;
  }
  .pcw-chips {
    gap: 6px;
  }
  .pcw-chips button {
    font-size: 0.73rem;
    padding: 6px 11px;
  }
  .pcw-wall {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 8px;
  }
}
