/* Base, layout, header, footer, buttons, the contact block and the tear-off email strip.
   Shared by every page (the home and the Arabic edition load it too, then home.css on top). */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 16px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@view-transition { navigation: auto; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink);
  font: 400 17px/1.55 var(--sans);
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
main { flex: 1 0 auto; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .22em; }
a:hover { text-decoration-thickness: 2px; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: start; }
img { max-width: 100%; height: auto; display: block; }
:focus-visible { outline: 2px solid var(--data); outline-offset: 3px; border-radius: 1px; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote { margin: 0; padding: 0; }
.nw { white-space: nowrap; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; background: var(--ink); color: var(--paper); padding: 8px 12px; z-index: 50; }
.skip:focus { top: 8px; }

.wrap { padding-inline: var(--m); width: 100%; max-width: 1720px; margin-inline: auto; }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--g); }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: 0; line-height: 1.45; }
.ico { width: 14px; height: 14px; flex: none; display: inline-block; vertical-align: -2px; }

/* ---------- header: name and level, the same four links, language and theme ---------- */
.top { display: flex; align-items: center; column-gap: clamp(20px, 2.4vw, 40px); min-height: 68px; border-bottom: 1px solid var(--rule); }
.me { display: grid; text-decoration: none; padding-block: 10px; margin-inline-end: auto; }
.me-n { font-weight: 540; font-size: 15.5px; line-height: 1.25; white-space: nowrap; }
.me-r { font-family: var(--mono); font-size: 11.5px; line-height: 1.45; color: var(--ink-2); white-space: nowrap; }
.me:hover .me-n { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .22em; }
.nav { display: flex; align-items: center; gap: clamp(16px, 2vw, 30px); font-size: 15px; }
.nav a { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink-2); white-space: nowrap; padding-block: 10px; transition: color .15s; }
.nav a:hover { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; }
.nav a[aria-current] { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 6px; text-decoration-color: var(--data); }
.nav .ico { width: 13px; height: 13px; vertical-align: 0; }
.tools { display: flex; justify-content: flex-end; align-items: center; gap: 18px; }
.lang { text-decoration: none; font-size: 15px; white-space: nowrap; padding-block: 10px; }
.lang:hover { text-decoration: underline; }
.lang[lang="ar"] { font-size: 16px; }
.theme { display: inline-flex; align-items: center; gap: 7px; height: 32px; font-family: var(--mono); font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.theme:hover { color: var(--ink); }
.theme svg { width: 14px; height: 14px; flex: none; display: block; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  font-size: 15px; font-weight: 500; line-height: 1.2; white-space: nowrap; text-decoration: none;
  border: 1px solid var(--ink); color: var(--ink); background: transparent; transition: background-color .15s, color .15s, border-color .15s; }
.btn:hover { background: var(--paper-2); text-decoration: none; }
.btn--primary { background: var(--ink); color: var(--paper); }
.btn--primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--data)); border-color: color-mix(in srgb, var(--ink) 86%, var(--data)); }
.btn .ico { width: 14px; height: 14px; vertical-align: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- section head ---------- */
.sec-head { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--g); align-items: baseline;
  border-top: 1px solid var(--ink); padding-top: 14px; margin-bottom: clamp(36px, 5vw, 64px); }
.sec-head h1, .sec-head h2 { grid-column: 1 / 8; font-weight: 450; font-size: clamp(32px, 3.4vw, 52px); line-height: 1.06; letter-spacing: -.018em; }
.sec-head p { grid-column: 9 / 13; font-size: 14.5px; color: var(--ink-2); line-height: 1.5; }
.sec-head .sec-go { grid-column: 9 / 13; justify-self: end; font-size: 15px; }

/* ---------- copy button ---------- */
.copy { display: inline-flex; align-items: center; font-family: var(--mono); font-size: 12px; color: var(--ink-2);
  border: 1px solid var(--rule-2); padding: 0 12px; min-height: 32px; white-space: nowrap; align-self: center; transition: border-color .15s, color .15s; }
.copy:hover { color: var(--ink); border-color: var(--ink); }
.copy.is-done { color: var(--data-ink); border-color: var(--data); }

/* ---------- contact block: email in plain text first, then the tear-off strip beside it ---------- */
.contact { margin-top: clamp(96px, 11vw, 160px); scroll-margin-top: 16px; }
.contact-in { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--g); row-gap: 28px; border-top: 1px solid var(--ink); padding-top: 14px; align-items: start; }
.contact-text { grid-column: 1 / 7; display: grid; gap: 14px; justify-items: start; }
.contact-h { font-weight: 450; font-size: clamp(28px, 2.8vw, 42px); line-height: 1.08; letter-spacing: -.018em; }
.contact-seek { font-size: 16px; line-height: 1.5; color: var(--ink-2); max-width: 36em; text-wrap: pretty; }
.mail-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 4px; }
.mail-big { font-size: clamp(22px, 2.1vw, 32px); font-weight: 450; letter-spacing: -.012em; line-height: 1.25; text-decoration: underline;
  text-decoration-thickness: 1px; text-underline-offset: .18em; user-select: all; -webkit-user-select: all; overflow-wrap: anywhere; }
.avail { display: grid; gap: 6px; font-size: 15px; line-height: 1.5; max-width: 38em; }
.avail b { font-weight: 540; }
.next-links { display: flex; flex-wrap: wrap; gap: 4px 22px; font-size: 15px; }
.next-links a { white-space: nowrap; padding-block: 6px; }
.next-links a[href^="tel"] { font-variant-numeric: tabular-nums; }
.contact .tear { grid-column: 8 / 13; }
.contact-in:not(:has(.tear)) .contact-text { grid-column: 1 / 10; }
main:has(> .contact:last-child) + .foot { margin-top: clamp(64px, 7vw, 104px); }

/* ---------- the tear-off strip: a "situation wanted" note with tall, narrow, perforated tabs ---------- */
.tear { --tab-h: 188px; container-type: inline-size; }
.tear-k { font-family: var(--mono); font-size: 12px; line-height: 1.45; color: var(--ink-2); margin-bottom: 12px; }
.tabs { --tabs: 6; position: relative; display: grid; grid-template-columns: repeat(var(--tabs), minmax(0, 1fr)); column-gap: 3px; padding-top: 8px; }
.tabs::before { content: ""; position: absolute; inset-inline: 0; top: 0; height: 8px; border: 1.25px dashed var(--data); }
.tabs::after { content: ""; position: absolute; inset-inline-start: 0; top: -5px; height: 18px; width: 1px; background: var(--data); }
.tab-slot { position: relative; height: var(--tab-h); }
.tab-slot:nth-child(n+7) { display: none; }
@container (min-width: 430px) { .tabs { --tabs: 8; } .tab-slot:nth-child(n+7) { display: block; } .tab-slot:nth-child(n+9) { display: none; } }
@container (min-width: 560px) { .tabs { --tabs: 10; } .tab-slot:nth-child(n+9) { display: block; } }
@container (max-width: 300px) { .tabs { --tabs: 5; } .tab-slot:nth-child(n+6) { display: none; } }
/* the stub left behind once a tab is torn */
.tab-slot::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 10px;
  border-inline: 1px solid var(--data); background: color-mix(in srgb, var(--data) 16%, var(--paper));
  clip-path: polygon(0 0, 100% 0, 100% 55%, 87.5% 100%, 75% 50%, 62.5% 95%, 50% 45%, 37.5% 100%, 25% 55%, 12.5% 95%, 0 50%);
  opacity: 0; transition: opacity 60ms linear 70ms; }
.tab-slot.is-torn::before { opacity: 1; }
.tab { position: absolute; inset: 0; width: 100%; display: flex; align-items: center; justify-content: center;
  padding: 10px 0 12px; background: var(--paper); border: 1px solid var(--data); border-top: 0;
  cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  transform-origin: 50% 0; transition: background-color .12s; will-change: transform; text-align: center; }
.tab:hover { background: color-mix(in srgb, var(--data) 8%, var(--paper)); }
.tab:active { cursor: grabbing; }
.tab:focus-visible { outline-offset: -5px; border-radius: 0; }
.tab-text { writing-mode: vertical-rl; transform: rotate(180deg); font-family: "Fragment Mono", ui-monospace, monospace; font-size: 11.5px; line-height: 1.35;
  color: var(--ink); white-space: nowrap; pointer-events: none; text-align: start; }
.tab-text > span { display: block; }
.tab-text > span:first-child { color: var(--ink-3); }
.tab-slot.is-torn .tab { visibility: hidden; }
.tab.is-falling { z-index: 3; pointer-events: none;
  clip-path: polygon(0 5px, 12.5% 10px, 25% 5px, 37.5% 11px, 50% 4px, 62.5% 10px, 75% 5px, 87.5% 11px, 100% 6px, 100% 100%, 0 100%); }
.tear-status { min-height: 24px; margin-top: 10px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 14px;
  font-family: var(--mono); font-size: 12px; line-height: 1.45; color: var(--ink-2); }
.tear-status .ok { color: var(--ink); }
.tear.has-copied .tear-msg { color: var(--data-ink); }
.reprint { font-family: var(--mono); font-size: 12px; color: var(--data-ink); text-decoration: underline; text-underline-offset: .25em;
  text-decoration-color: color-mix(in srgb, var(--data) 45%, transparent); white-space: nowrap; min-height: 24px; }
.reprint:hover { text-decoration-color: currentColor; }
/* a small "Copied" tag that appears on the strip, right where the tab was taken */
.tear-pop { position: absolute; top: 18px; z-index: 4; transform: translateX(-50%); padding: 3px 8px; background: var(--ink); color: var(--paper);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.4; white-space: nowrap; pointer-events: none; animation: pop 1.6s var(--ease) forwards; }
@keyframes pop { 0% { opacity: 0; translate: 0 4px; } 12% { opacity: 1; translate: 0 0; } 80% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .tear-pop { animation: none; } }

/* ---------- case study card: used on the home and the Work page (rendered there from js/work-data.js) ---------- */
.case-card { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--g); row-gap: 22px; align-items: end; }
.cc-plate { grid-column: 1 / 9; position: relative; display: grid; place-items: center; aspect-ratio: 16 / 10; overflow: hidden;
  background: var(--paper-2); text-decoration: none; }
.cc-phones { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 4%; width: 62%; align-items: start; transform: translateY(6%); }
.cc-phones img { width: 100%; height: auto; border: 4px solid var(--bezel); border-radius: 14% / 6.5%; background: #f1f1f1;
  box-shadow: 0 16px 36px -22px rgba(0, 0, 0, .5); transition: transform .2s var(--ease); }
.cc-phones img:nth-child(2) { margin-top: 9%; }
.cc-phones img:nth-child(3) { margin-top: 18%; }
.cc-single { width: 100%; height: 100%; object-fit: cover; }
/* the case study's own colour, as a rule along the top of its card (accents live in tokens.css) */
.case-card[data-accent] .cc-plate::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--accent); z-index: 1; }
.cc-plate { transition: transform .3s var(--ease), box-shadow .3s var(--ease); }
.case-card:hover .cc-plate { transform: translateY(-3px); box-shadow: 0 18px 36px -26px rgba(0, 0, 0, .45); }
[data-theme="dark"] .cc-phones img { filter: brightness(.94); }
.case-card:hover .cc-phones img { transform: translateY(-4px); }
.cc-cap { grid-column: 9 / 13; padding-bottom: 6px; }
.cc-k { font-size: 14px; line-height: 1.4; color: var(--ink-2); }
.cc-k b { font-weight: 540; color: var(--ink); }
.cc-cap h3, .cc-cap h2 { margin-top: 8px; font-weight: 460; font-size: clamp(25px, 2.2vw, 34px); line-height: 1.12; letter-spacing: -.016em; text-wrap: pretty; }
.cc-cap h3 a, .cc-cap h2 a { text-decoration: none; }
.cc-cap h3 a:hover, .cc-cap h2 a:hover { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 5px; text-decoration-color: var(--data); }
.cc-meta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; line-height: 1.45; color: var(--ink); }
.cc-meta span { white-space: nowrap; }
.cc-meta span + span { color: var(--ink-2); }
.cc-desc { margin-top: 12px; font-size: 15.5px; line-height: 1.5; color: var(--ink-2); max-width: 34em; text-wrap: pretty; }
.cc-cap .case-tags { margin-top: 14px; }
.cc-exp { margin-top: 14px; font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.cc-exp b { font-weight: 540; color: var(--ink); }
.cc-go { margin-top: 20px; }

@media (max-width: 1100px) {
  .cc-plate { grid-column: 1 / -1; }
  .cc-cap { grid-column: 1 / 10; }
}
@media (max-width: 720px) {
  .case-card { display: block; }
  .cc-cap { margin-top: 20px; }
  .cc-phones { width: 76%; }
  .cc-phones img { border-width: 3px; }
  .cc-go .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .cc-phones img, .cc-plate { transition: none; }
  .case-card:hover .cc-phones img, .case-card:hover .cc-plate { transform: none; }
}

/* ---------- tags: the chips of the hero skills row, reused for case studies (hero and cards) ---------- */
.case-tags { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding: 0; }
.case-tags li { font-size: 14px; line-height: 1.3; padding: 6px 11px; border: 1px solid var(--rule-2); white-space: nowrap; color: var(--ink); }
.case-tags--s { gap: 6px; }
.case-tags--s li { font-size: 13px; padding: 4px 9px; color: var(--ink-2); }
[lang="ar"] .case-tags li { line-height: 1.5; letter-spacing: 0; }

/* ---------- the faint pattern: the chart's grid as dots behind heroes, its ticks along section dividers ----------
   Never behind body text: the dots sit in the hero's top end corner and fade out before the text block,
   the ticks sit in the first few pixels under a section's top rule. */
.hero, .page-hero, .work-head { position: relative; isolation: isolate; }
.hero::before, .page-hero::before, .work-head::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  top: 0; inset-inline-end: 0; width: min(44%, 680px); height: min(100%, 420px);
  background-image: radial-gradient(circle at 1px 1px, var(--pat-dot) 1px, transparent 1.6px);
  background-size: var(--pat-size) var(--pat-size);
  -webkit-mask-image: radial-gradient(120% 100% at 100% 0, #000 0, rgba(0, 0, 0, .5) 38%, transparent 72%);
          mask-image: radial-gradient(120% 100% at 100% 0, #000 0, rgba(0, 0, 0, .5) 38%, transparent 72%);
}
[dir="rtl"] .hero::before, [dir="rtl"] .page-hero::before, [dir="rtl"] .work-head::before {
  -webkit-mask-image: radial-gradient(120% 100% at 0 0, #000 0, rgba(0, 0, 0, .5) 38%, transparent 72%);
          mask-image: radial-gradient(120% 100% at 0 0, #000 0, rgba(0, 0, 0, .5) 38%, transparent 72%);
}
.work-head::before { top: auto; bottom: 100%; height: clamp(40px, 6vw, 88px); }
.sec-head, .cs-head { position: relative; }
.sec-head::after, .cs-head::after {
  content: ""; position: absolute; top: 0; inset-inline: 0; height: 7px; pointer-events: none;
  background-image: repeating-linear-gradient(to right, var(--pat-dot) 0 1px, transparent 1px var(--pat-size));
  -webkit-mask-image: linear-gradient(to left, #000, transparent 60%);
          mask-image: linear-gradient(to left, #000, transparent 60%);
}
[dir="rtl"] .sec-head::after, [dir="rtl"] .cs-head::after {
  -webkit-mask-image: linear-gradient(to right, #000, transparent 60%);
          mask-image: linear-gradient(to right, #000, transparent 60%);
}

/* ---------- a case page's top band: a thin bar of its accent above the header ---------- */
body[data-accent]::before { content: ""; display: block; flex: none; height: 4px; background: var(--accent); }

/* ---------- gentle motion (js/shared.js adds these classes; nothing is hidden without script or with reduced motion) ---------- */
.rv { opacity: 0; transform: translateY(18px); }
.rv.is-in { opacity: 1; transform: none; transition: opacity .7s var(--ease), transform .7s var(--ease); }
@media (prefers-reduced-motion: reduce) { .rv { opacity: 1; transform: none; } }
@media print { .rv { opacity: 1 !important; transform: none !important; } }

/* ---------- footer ---------- */
.foot { margin-top: clamp(96px, 12vw, 160px); flex-shrink: 0; }
.reach { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px; border-top: 1px solid var(--ink); padding: 18px 0 20px; font-size: 15px; }
.reach a { text-decoration: none; white-space: nowrap; padding-block: 4px; }
.reach a:hover { text-decoration: underline; }
.reach .reach-mail { font-size: clamp(20px, 1.8vw, 26px); font-weight: 450; letter-spacing: -.01em; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; user-select: all; -webkit-user-select: all; }
.reach .copy { margin-inline-end: auto; }
[dir="rtl"] .reach .reach-mail { text-align: right; }
/* a page that already shows the contact block does not repeat the email row in the footer */
main:has(.contact) + .foot .reach { display: none; }
main:has(.contact) + .foot .row { border-top-color: var(--ink); }
.foot .row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 24px; border-top: 1px solid var(--rule); padding: 14px 0 22px;
  font-family: var(--mono); font-size: 12px; line-height: 1.45; color: var(--ink-2); }
.foot .row a { color: var(--ink-2); }
.foot .row a:hover { color: var(--ink); }
.foot-nav { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.foot-nav a { padding-block: 4px; }
.foot-nav a[lang="ar"] { font-family: var(--sans); font-size: 14px; }
.foot-note { margin-top: -10px; padding-bottom: 22px; font-family: var(--mono); font-size: 11.5px; line-height: 1.5; color: var(--ink-2); max-width: 70em; }
.foot-note > span { display: block; }
[lang="ar"] .foot-note { font-family: var(--sans); font-size: 13px; line-height: 1.7; }
[lang="ar"] .foot-note > span { font-family: "Fragment Mono", ui-monospace, monospace; font-size: 11.5px; line-height: 1.5; }

/* ---------- tablet ---------- */
@media (max-width: 1100px) {
  .contact-text { grid-column: 1 / 8; }
  .contact .tear { grid-column: 8 / 13; }
  .sec-head p, .sec-head .sec-go { grid-column: 8 / 13; }
}
@media (max-width: 900px) {
  .contact-in { display: block; }
  .contact .tear { margin-top: 36px; max-width: 560px; }
}

/* ---------- phone ---------- */
@media (max-width: 720px) {
  body { font-size: 16px; }
  .top { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; min-height: 0; padding-top: 4px; }
  .me { grid-column: 1; padding-block: 8px; }
  .tools { grid-column: 2; gap: 6px; }
  .lang { padding: 10px 6px; }
  .nav { grid-column: 1 / -1; grid-row: 2; justify-content: space-between; gap: 12px; border-top: 1px solid var(--rule); }
  .nav a { padding-block: 11px; font-size: 15px; }
  .theme .theme-t { display: none; }
  .theme { width: 44px; height: 44px; justify-content: center; }
  .sec-head { display: block; }
  .sec-head p, .sec-head .sec-go { margin-top: 10px; display: block; }
  .foot .row { display: grid; gap: 8px; }
  .tear { --tab-h: 180px; }
  .reach { gap: 8px 22px; }
  .reach .reach-mail { flex-basis: 100%; font-size: 22px; }
  .reach .copy { margin-inline-end: 0; }
  .btn { flex: 1 1 auto; }
}
@media print {
  .top .tools, .tear, .copy { display: none; }
}
