/* Ehab Alatrebi — Portfolio & Case Studies
   Light editorial system. One accent (ink). Per-case brand tint on case heroes. */

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --ink: #141414;
  --ink-soft: #55555a;
  --ink-faint: #8a8a90;
  --line: #e4e4e0;
  --accent: #141414;
  --radius: 14px;
  --maxw: 1200px;
  --case: #141414;        /* overridden per case page */
  --case-ink: #ffffff;    /* text on case color */
  font-size: 16px;
}

/* Dark theme (toggled via html[data-theme]) */
html[data-theme="dark"] {
  --bg: #131315;
  --surface: #1b1b1e;
  --ink: #f1f1ef;
  --ink-soft: #a9a9b0;
  --ink-faint: #717178;
  --line: #2a2a2f;
  --accent: #f1f1ef;
}
html[data-theme="dark"] ::selection { background: #f1f1ef; color: #131315; }
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn-chat,
html[data-theme="dark"] .chat-send,
html[data-theme="dark"] .msg.user { color: #131315 !important; }
html[data-theme="dark"] .mc-carousel { background: #202024; }
html[data-theme="dark"] .mcc-btn { background: rgba(27,27,30,.92); color: var(--ink); }
html[data-theme="dark"] .mcc-dots i { background: rgba(255,255,255,.28); }
html[data-theme="dark"] .mcc-dots i.on { background: var(--ink); }
html[data-theme="dark"] .work-card .wc-img,
html[data-theme="dark"] .hero-visual .hv-a { background: #202024; }
html[data-theme="dark"] .work-card:hover { box-shadow: 0 20px 48px rgba(0,0,0,.5); }
html[data-theme="dark"] .more-card:hover { box-shadow: 0 16px 38px rgba(0,0,0,.5); }
html[data-theme="dark"] .hero-phones img { box-shadow: 0 24px 56px rgba(0,0,0,.6); }
html[data-theme="dark"] .about-photo { box-shadow: 0 18px 44px rgba(0,0,0,.5); }

/* Theme toggle button */
.theme-toggle {
  width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--ink-soft);
  cursor: pointer; font-size: 1rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .2s, border-color .2s, transform .15s;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink); }
.theme-toggle:active { transform: scale(.94); }
.theme-toggle svg { display: block; }
html[data-theme="dark"] .theme-toggle .tt-moon { display: none; }
html:not([data-theme="dark"]) .theme-toggle .tt-sun { display: none; }

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
::selection { background: #141414; color: #fff; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  height: 68px; display: flex; align-items: center; justify-content: space-between;
}
.nav-name { font-weight: 650; letter-spacing: -0.01em; font-size: 1rem; }
.nav-name span { color: var(--ink-faint); font-weight: 450; }
.nav-links { display: flex; align-items: center; gap: 28px; font-size: 0.92rem; }
.nav-links a { color: var(--ink-soft); transition: color .2s; }
.nav-links a:hover { color: var(--ink); }
.btn-chat {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--ink); color: #fff !important;
  padding: 9px 18px; border-radius: 999px; font-size: 0.9rem; font-weight: 550;
  transition: transform .18s ease, opacity .18s ease;
  border: none; cursor: pointer; font-family: inherit;
}
.btn-chat:hover { opacity: .88; }
.btn-chat:active { transform: scale(.98); }
.btn-chat .dot-ai { width: 7px; height: 7px; border-radius: 99px; background: #6ee7a0; }

@media (max-width: 720px) {
  .nav-links a.nav-hide-m { display: none; }
  .nav-links { gap: 16px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 26px; border-radius: 999px; font-weight: 560; font-size: 0.98rem;
  transition: transform .18s ease, opacity .18s ease, background .2s;
  cursor: pointer; border: none; font-family: inherit;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { opacity: .88; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--ink); }

/* ---------- Hero (home) ---------- */
.hero { padding: 84px 0 72px; }
.hero-grid {
  display: grid; grid-template-columns: 7fr 5fr; gap: 56px; align-items: center;
}
.hero h1 {
  font-size: clamp(2.2rem, 4.6vw, 3.6rem);
  line-height: 1.04; letter-spacing: -0.035em; font-weight: 680;
  max-width: 14ch;
}
.hero-sub {
  margin-top: 22px; color: var(--ink-soft); font-size: 1.08rem; max-width: 46ch;
}
.hero-ctas { margin-top: 34px; display: flex; gap: 14px; flex-wrap: wrap; }
.hero-phones {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start;
  max-width: 440px; justify-self: end;
}
.hero-phones img {
  border-radius: 18px;
  box-shadow: 0 24px 56px rgba(20,20,20,.22);
}
.hero-phones img:last-child { margin-top: 38px; }
@media (max-width: 900px) { .hero-phones { justify-self: start; max-width: 380px; } }

.hero-visual { position: relative; }
.hero-visual .hv-a {
  border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 24px 60px rgba(20,20,20,.14);
}
.hero-visual .hv-b {
  position: absolute; width: 58%; bottom: -13%; left: -12%;
  border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 18px 44px rgba(20,20,20,.18);
  border: 4px solid var(--bg);
}
@media (max-width: 900px) {
  .hero { padding: 56px 0 48px; }
  .hero-grid { grid-template-columns: 1fr; gap: 40px; }
  .hero-visual .hv-b { bottom: -10%; }
}

/* ---------- Metrics strip ---------- */
.metrics { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.metrics-inner {
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 34px 0;
}
.metric { padding: 0 26px; border-left: 1px solid var(--line); }
.metric:first-child { border-left: none; padding-left: 0; }
.metric b { display: block; font-size: 1.7rem; letter-spacing: -0.03em; font-weight: 680; }
.metric span { color: var(--ink-soft); font-size: 0.9rem; }
@media (max-width: 860px) {
  .metrics-inner { grid-template-columns: 1fr 1fr; gap: 24px 0; }
  .metric:nth-child(3) { border-left: none; padding-left: 0; }
}

/* ---------- Work index ---------- */
.work { padding: 88px 0 40px; }
.section-h { font-size: clamp(1.6rem, 2.6vw, 2.2rem); letter-spacing: -0.03em; font-weight: 660; margin-bottom: 10px; }
.section-sub { color: var(--ink-soft); max-width: 52ch; margin-bottom: 44px; }

.work-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.work-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform .25s ease, box-shadow .25s ease;
}
.work-card:hover { transform: translateY(-4px); box-shadow: 0 20px 48px rgba(20,20,20,.1); }
.work-card .wc-img { aspect-ratio: 16/9; overflow: hidden; background: #eceae6; }
.work-card .wc-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.work-card:hover .wc-img img { transform: scale(1.025); }
.work-card .wc-body { padding: 22px 24px 24px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.wc-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.wc-top h3 { font-size: 1.15rem; font-weight: 640; letter-spacing: -0.015em; }
.wc-top time { color: var(--ink-faint); font-size: 0.84rem; font-weight: 450; }
.wc-line { color: var(--ink-soft); font-size: 0.95rem; }
.wc-tags { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.wc-tags i {
  font-style: normal; font-size: 0.78rem; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; background: var(--bg);
}
.work-card.featured { grid-column: 1 / -1; }
.work-card.featured .wc-img { aspect-ratio: 16/9; background: #0e0f10; }
@media (max-width: 820px) { .work-grid { grid-template-columns: 1fr; } }

/* ---------- Card carousel ---------- */
.mc-carousel { position: relative; background: #f0efec; border-bottom: 1px solid var(--line); }
.mcc-track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  aspect-ratio: 3/2; scrollbar-width: none;
}
.mcc-track::-webkit-scrollbar { display: none; }
.mcc-track img {
  flex: 0 0 100%; width: 100%; height: 100%; object-fit: contain;
  scroll-snap-align: center; padding: 14px;
}
.mcc-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(255,255,255,.92); color: var(--ink); cursor: pointer;
  font-size: 0.95rem; line-height: 1; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s, transform .15s; z-index: 2;
}
.mc-carousel:hover .mcc-btn, .mcc-btn:focus-visible { opacity: 1; }
.mcc-btn:active { transform: translateY(-50%) scale(.94); }
.mcc-btn.prev { left: 10px; }
.mcc-btn.next { right: 10px; }
.mcc-dots {
  position: absolute; bottom: 8px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 6px; pointer-events: none;
}
.mcc-dots i {
  width: 6px; height: 6px; border-radius: 99px; background: rgba(20,20,20,.22);
  transition: background .2s, width .2s;
}
.mcc-dots i.on { background: var(--ink); width: 16px; }
@media (hover: none) { .mcc-btn { opacity: 1; } }

/* ---------- More work ---------- */
.more { padding: 48px 0 88px; }
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.more-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform .25s ease, box-shadow .25s ease;
}
.more-card:hover { transform: translateY(-3px); box-shadow: 0 16px 38px rgba(20,20,20,.09); }
.more-card .mc-img { aspect-ratio: 3/2; overflow: hidden; background: #eceae6; }
.more-card .mc-img img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.more-card .mc-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.mc-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.mc-top h3 { font-size: 1.02rem; font-weight: 640; letter-spacing: -0.01em; }
.mc-top time { color: var(--ink-faint); font-size: 0.8rem; }
.more-card p { color: var(--ink-soft); font-size: 0.88rem; flex: 1; }
.mc-role { color: var(--ink-faint); font-size: 0.8rem; }
@media (max-width: 980px) { .more-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .more-grid { grid-template-columns: 1fr; } }

/* ---------- About ---------- */
.about { padding: 80px 0; border-top: 1px solid var(--line); }
.about-side { position: relative; }
.about-photo {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover; object-position: center 20%;
  border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(20,20,20,.12);
}
.about-grid > div:last-child .section-h { margin-bottom: 22px; }
@media (max-width: 860px) {
  .about-side { aspect-ratio: 4/3; }
  .about-photo { position: static; aspect-ratio: 4/3; }
}
.about-grid { display: grid; grid-template-columns: 5fr 7fr; gap: 56px; }
.about p { color: var(--ink-soft); font-size: 1.05rem; max-width: 58ch; }
.about p + p { margin-top: 16px; }
.about p strong { color: var(--ink); font-weight: 600; }
@media (max-width: 860px) { .about-grid { grid-template-columns: 1fr; gap: 20px; } }

/* ---------- Footer ---------- */
.foot { border-top: 1px solid var(--line); padding: 64px 0 48px; }
.foot-grid { display: flex; justify-content: space-between; align-items: flex-end; gap: 32px; flex-wrap: wrap; }
.foot h2 { font-size: clamp(1.7rem, 3.2vw, 2.5rem); letter-spacing: -0.03em; font-weight: 670; max-width: 18ch; line-height: 1.1; }
.foot-links { display: flex; flex-direction: column; gap: 10px; text-align: right; color: var(--ink-soft); font-size: 0.96rem; }
.foot-links a:hover { color: var(--ink); }
.foot-meta { margin-top: 44px; padding-top: 20px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; color: var(--ink-faint); font-size: 0.84rem; flex-wrap: wrap; gap: 8px; }

/* ---------- Case pages ---------- */
.case-hero { background: var(--case); color: var(--case-ink); padding: 84px 0 0; }
.case-hero .ch-brand { font-size: 0.95rem; font-weight: 600; opacity: .8; margin-bottom: 22px; }
.case-hero h1 {
  font-size: clamp(1.9rem, 3.8vw, 3rem); line-height: 1.12; letter-spacing: -0.03em;
  font-weight: 660; max-width: 24ch;
}
.case-meta {
  margin-top: 34px; display: flex; gap: 40px; flex-wrap: wrap;
  padding-bottom: 44px; opacity: .92;
}
.case-meta div b { display: block; font-size: 0.8rem; font-weight: 600; opacity: .65; margin-bottom: 3px; }
.case-meta div span { font-size: 0.95rem; }
.case-hero .ch-img { border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; box-shadow: 0 -8px 60px rgba(0,0,0,.18); }

.case-body { padding: 84px 0; }
.case-sec { display: grid; grid-template-columns: 4fr 8fr; gap: 48px; margin-bottom: 76px; }
.case-sec:last-child { margin-bottom: 0; }
.case-sec h2 { font-size: 1.25rem; font-weight: 650; letter-spacing: -0.015em; position: sticky; top: 96px; align-self: start; }
.case-sec .cs-text p { color: var(--ink-soft); font-size: 1.05rem; max-width: 60ch; }
.case-sec .cs-text p + p { margin-top: 16px; }
.case-sec .cs-text strong { color: var(--ink); font-weight: 600; }
@media (max-width: 820px) {
  .case-sec { grid-template-columns: 1fr; gap: 14px; }
  .case-sec h2 { position: static; }
}

.case-outcomes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.case-outcomes .oc {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px 24px 22px;
}
.case-outcomes .oc b { display: block; font-size: 1.9rem; font-weight: 680; letter-spacing: -0.03em; color: var(--case-strong, var(--ink)); }
.case-outcomes .oc span { color: var(--ink-soft); font-size: 0.92rem; }
@media (max-width: 820px) { .case-outcomes { grid-template-columns: 1fr; } }

.case-gallery { padding: 0 0 84px; }
.case-gallery .cg-grid { display: grid; gap: 26px; }
.cg-grid figure {
  border-radius: var(--radius); overflow: hidden; background: var(--surface);
  border: 1px solid var(--line);
}
.cg-grid figcaption { padding: 13px 18px; font-size: 0.86rem; color: var(--ink-soft); border-top: 1px solid var(--line); }
.cg-2 { grid-template-columns: 1fr 1fr; }
.cg-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 820px) { .cg-2 { grid-template-columns: 1fr; } .cg-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .cg-3 { grid-template-columns: 1fr; } }

.case-next { border-top: 1px solid var(--line); }
.case-next a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 44px 0; gap: 20px;
}
.case-next .cn-label { color: var(--ink-faint); font-size: 0.9rem; margin-bottom: 6px; }
.case-next .cn-title { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 660; letter-spacing: -0.025em; }
.case-next .cn-arrow { font-size: 1.6rem; transition: transform .2s; }
.case-next a:hover .cn-arrow { transform: translateX(6px); }

/* ---------- Reveal on scroll ---------- */
.rv { opacity: 0; transform: translateY(22px); transition: opacity .7s cubic-bezier(.16,1,.3,1), transform .7s cubic-bezier(.16,1,.3,1); }
.rv.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .rv { opacity: 1; transform: none; transition: none; } }

/* ---------- Chat panel ---------- */
.chat-overlay {
  position: fixed; inset: 0; background: rgba(20,20,20,.32); z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.chat-overlay.open { opacity: 1; pointer-events: auto; }
.chat-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 100;
  background: var(--surface); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  transform: translateX(102%); transition: transform .32s cubic-bezier(.16,1,.3,1);
  box-shadow: -24px 0 60px rgba(20,20,20,.12);
}
.chat-panel.open { transform: none; }
@media (prefers-reduced-motion: reduce) { .chat-panel { transition: none; } .chat-overlay { transition: none; } }

.chat-head {
  padding: 20px 22px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.chat-head .ch-t { font-weight: 640; font-size: 1rem; display: flex; align-items: center; gap: 9px; }
.chat-head .ch-t .dot-ai { width: 8px; height: 8px; border-radius: 99px; background: #34c07c; }
.chat-head .ch-sub { color: var(--ink-faint); font-size: 0.8rem; margin-top: 2px; }
.chat-close { background: none; border: none; cursor: pointer; font-size: 1.15rem; color: var(--ink-soft); padding: 6px; line-height: 1; }
.chat-close:hover { color: var(--ink); }

.chat-msgs { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 88%; padding: 12px 16px; border-radius: 16px; font-size: 0.94rem; line-height: 1.5; }
.msg.user { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 6px; }
.msg.bot { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.bot a { text-decoration: underline; text-underline-offset: 2px; }
.msg.typing span {
  display: inline-block; width: 6px; height: 6px; border-radius: 99px; background: var(--ink-faint);
  margin-right: 4px; animation: blink 1.2s infinite;
}
.msg.typing span:nth-child(2) { animation-delay: .2s; }
.msg.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .msg.typing span { animation: none; } }

.chat-chips { padding: 0 22px 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.chat-chips button {
  font-family: inherit; font-size: 0.82rem; color: var(--ink-soft);
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 13px; cursor: pointer; transition: border-color .2s, color .2s;
}
.chat-chips button:hover { border-color: var(--ink); color: var(--ink); }

.chat-input { border-top: 1px solid var(--line); padding: 16px 22px; display: flex; gap: 10px; }
.chat-input input {
  flex: 1; font-family: inherit; font-size: 0.95rem; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
  padding: 11px 18px; outline: none; transition: border-color .2s;
}
.chat-input input:focus { border-color: var(--ink); }
.chat-input input::placeholder { color: var(--ink-faint); }
.chat-send {
  background: var(--ink); color: #fff; border: none; border-radius: 999px;
  width: 44px; height: 44px; cursor: pointer; font-size: 1rem; flex-shrink: 0;
  transition: opacity .2s, transform .15s;
}
.chat-send:hover { opacity: .88; }
.chat-send:active { transform: scale(.96); }
.chat-note { padding: 0 22px 14px; color: var(--ink-faint); font-size: 0.74rem; }
