/* Arabic and right to left, the drawn portrait, drawn devices for real screens, the intro name. */

:root, .force-day {
  --paper: #fdf8f0; --paper-ink: #2b1d16; --cloth: #fffdf9; --cloth-shade: #e8ded6;
  --shumagh: #c32248; --shumagh-shade: #80142e; --red-glow: none; --aura-op: 0;
}
:root[data-mode="night"], .force-night {
  --paper: #d9cab6; --paper-ink: #1b130f; --cloth: #f8f2ea; --cloth-shade: #cfc3b6;
  --shumagh: #ff2f55; --shumagh-shade: #b01d40; --aura-op: .6;
  --red-glow: drop-shadow(0 0 1.2px #ff2f55) drop-shadow(0 0 3.5px color-mix(in srgb, #ff2f55 55%, transparent));
}

/* Arabic type: Alexandria for headlines, Readex Pro for text, Aref Ruqaa for names */
[lang="ar"] { --f-display: "Alexandria", "Readex Pro", "Geeza Pro", system-ui, sans-serif; }
[lang="en"] { --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif; }
:root[lang="ar"] body { font-size: 1.06rem; }
:is(h1, h2, h3, .statement, .s-big, .pv-next strong, .mo-word, .mail, .brand-name, .card-title.latin):lang(ar) { letter-spacing: 0; font-stretch: 100%; }
:is(.hero h1, .contact h2, .pv-head h1, .id-top h1):lang(ar) { line-height: 1.22; }
.hero h1:lang(ar) { font-weight: 700; max-width: 11ch; }
.statement:lang(ar) { line-height: 1.55; }
.lede:lang(ar), .sec-head p:lang(ar) { line-height: 1.75; }
:is(.pv-meta dt, .about-text h2, .pv-next span):lang(ar) { letter-spacing: 0; }
.s-big-ar { font-family: "Alexandria", "Readex Pro", sans-serif; font-stretch: 100%; letter-spacing: 0; line-height: 1.3; }

/* Right to left: logical sides for everything placed by hand */
.skip { left: auto; inset-inline-start: 12px; }
.card-title { left: auto; inset-inline-start: 6%; }
.process { padding: 4px 0 0; padding-inline-start: 40px; }
.process .trail { left: auto; inset-inline-start: 0; }
.process li::before { left: auto; inset-inline-start: -35px; }
.copy ul { padding-left: 0; padding-inline-start: 1.1em; }
.tree ul { margin-left: 0; padding-left: 0; border-left: 0; margin-inline-start: 7px; padding-inline-start: 22px; border-inline-start: 1px solid var(--rule-2); }
.tree ul li::before { left: auto; inset-inline-start: -22px; }
.tree small { margin-left: 0; margin-inline-start: 8px; }
.mo-word { left: auto; inset-inline-start: 7%; }
.pair i + i { margin-left: 0; margin-inline-start: -9px; }
.skip-intro { right: auto; inset-inline-end: var(--pad-r); }
.drift-track { direction: ltr; }
.ic-flip:dir(rtl) { transform: scaleX(-1); }
.btn-solid:hover .ic-flip:dir(rtl) { transform: scaleX(-1) translateX(4px); }
[dir="rtl"] .frame[data-area="s"] .glyph { left: 25%; }
[dir="rtl"] .pv-cover .glyph { left: 26%; }
[dir="rtl"] .mo-stage .glyph { left: 28%; }

.frame[data-area="a"] .card-title { font-size: clamp(1.9rem, 1.1rem + 2.6vw, 3.7rem); }
[dir="rtl"] .frame[data-area="a"] .glyph { left: 30%; }

/* The logo at a size it deserves: in the nav, on the sand, in the footer */
:root { --nav-h: 72px; }
.brand { gap: 12px; }
.brand-mark { width: 58px; height: 58px; }
.brand-name { font-size: 1.1rem; }
.foot-mark { width: 46px; height: 46px; }
.art.mini { --sw: 13; }

/* Navigation tools */
.nav-tools { display: flex; align-items: center; gap: 8px; }
.lang-btn { min-width: 44px; height: 44px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--rule-2); background: transparent; color: var(--ink); font: 600 .95rem/1 var(--f-text); cursor: pointer; transition: border-color .3s, box-shadow .3s; }
.lang-btn:hover { border-color: var(--glow); box-shadow: var(--halo); }
@media (max-width: 560px) {
  :root { --nav-h: 64px; }
  .brand-mark { width: 44px; height: 44px; }
  .nav-in { gap: 6px; }
  .nav-links { gap: 0; }
  .nav-links a { padding: 12px 4px; font-size: .84rem; }
  .nav-tools { gap: 4px; }
  .lang-btn { padding: 0 9px; font-size: .84rem; }
  .mode-btn { width: 40px; height: 40px; }
}

/* The drawn portrait, neck and up: paper, a white shumagh with red checks that glow at night, ink on top */
.hero-portrait { margin: 0; justify-self: center; width: min(100%, 500px); display: grid; justify-items: center; }
.portrait { position: relative; width: 100%; aspect-ratio: 900 / 799; -webkit-mask-image: linear-gradient(to bottom, #000 74%, transparent 98%); mask-image: linear-gradient(to bottom, #000 74%, transparent 98%); }
.portrait > span, .pt-red i, .pt-aura i { position: absolute; inset: 0; display: block; }
.pt-fill, .pt-cloth, .pt-cshade, .pt-rshade, .pt-lines, .pt-red i, .pt-aura i { -webkit-mask-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
.pt-aura { filter: blur(16px); opacity: var(--aura-op); }
.pt-aura i { background: var(--shumagh); -webkit-mask-image: url(../assets/portrait/cloth.png); mask-image: url(../assets/portrait/cloth.png); }
.pt-cshade { background: var(--cloth-shade); -webkit-mask-image: url(../assets/portrait/cloth-shade.png); mask-image: url(../assets/portrait/cloth-shade.png); }
.pt-rshade { background: var(--shumagh-shade); -webkit-mask-image: url(../assets/portrait/red-shade.png); mask-image: url(../assets/portrait/red-shade.png); }
.pt-fill { background: var(--paper); -webkit-mask-image: url(../assets/portrait/fill.png); mask-image: url(../assets/portrait/fill.png); }
.pt-cloth { background: var(--cloth); -webkit-mask-image: url(../assets/portrait/cloth.png); mask-image: url(../assets/portrait/cloth.png); }
.pt-red { filter: var(--red-glow); }
.pt-red i { background: var(--shumagh); -webkit-mask-image: url(../assets/portrait/red.png); mask-image: url(../assets/portrait/red.png); }
.pt-lines { background: var(--paper-ink); -webkit-mask-image: url(../assets/portrait/lines.png); mask-image: url(../assets/portrait/lines.png); }
.signature { margin: -4% 0 0; position: relative; font: 700 clamp(1.8rem, 1.1rem + 2.2vw, 2.9rem)/1.3 var(--f-callig); color: var(--ink); }
@keyframes pt-fade { from { opacity: 0; } }
@keyframes pt-draw { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes pt-dye { from { clip-path: circle(0% at 50% 10%); } to { clip-path: circle(150% at 50% 10%); } }
@keyframes write { from { clip-path: inset(-20% 0 -20% 100%); } to { clip-path: inset(-20% 0 -20% 0); } }
.pt-fill, .pt-cloth, .pt-cshade, .pt-aura { animation: pt-fade .8s ease .15s backwards; }
.pt-lines { animation: pt-draw 2.1s var(--wind) .3s backwards; }
.pt-red, .pt-rshade { animation: pt-dye 1.4s var(--settle) 1.8s backwards; }
.signature { animation: write 1.3s var(--wind) 2.6s backwards; }
.sand-mark { width: clamp(104px, 11vw, 156px); aspect-ratio: 1; margin-top: -2%; animation: pt-fade 1s ease 3.4s backwards; }
.sand-mark .art .ln { --sw: 6; }
.sand-mark .art .ln.fine { --sw: 3; }
.intro-on :is(.pt-fill, .pt-cloth, .pt-cshade, .pt-aura, .pt-lines, .pt-red, .pt-rshade, .signature, .sand-mark) { animation-play-state: paused; }
.intro-on.intro-out :is(.pt-fill, .pt-cloth, .pt-cshade, .pt-aura, .pt-lines, .pt-red, .pt-rshade, .signature, .sand-mark) { animation-play-state: running; }
@media (max-width: 820px) { .hero-portrait { order: -1; width: min(80vw, 380px); } }

/* Real screens in drawn devices */
.dev { position: absolute; bottom: var(--b, 6%); left: var(--x, 50%); transform: translateX(-50%) rotate(var(--r, 0deg)); transform-origin: 50% 100%; transition: transform .9s var(--settle); filter: drop-shadow(0 12px 14px rgba(70, 46, 26, .16)); }
.dev.phone { height: var(--h, 84cqh); aspect-ratio: 220 / 452; }
.dev.window { width: var(--w, 80cqw); aspect-ratio: 640 / 432; }
.dev.bare { width: var(--w, 80cqw); aspect-ratio: 640 / 420; }
.dev svg { display: block; width: 100%; height: 100%; overflow: visible; }
.device .body { fill: var(--sky-hi); }
.device .isl { fill: var(--ink); }
.frame:hover .dev { transform: translateX(-50%) translateY(-6px) rotate(var(--r, 0deg)); }
:root[data-mode="night"] .dev { filter: drop-shadow(0 0 26px color-mix(in srgb, var(--glow) 26%, transparent)); }
:root[data-mode="night"] .device image { filter: brightness(.86); }
.cap .alt { font: 700 1.45rem/1 var(--f-callig); color: var(--ink-2); }
.cap .alt:lang(en) { font: 600 1rem/1.2 "Bricolage Grotesque", sans-serif; }
.pv-head .alt { font: 700 var(--t-xl)/1.2 var(--f-callig); color: var(--glow); text-shadow: var(--halo); }
.pv-head .alt:lang(en) { font: 600 var(--t-l)/1.2 "Bricolage Grotesque", sans-serif; color: var(--ink-2); text-shadow: none; }
.pv-shots { margin-top: clamp(40px, 6vw, 72px); }
.pv-shots h2 { font-size: var(--t-l); margin-bottom: 18px; }
.shots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(12px, 2vw, 20px); }
.shot { margin: 0; display: grid; gap: 10px; align-content: start; }
.shot .scene { aspect-ratio: 3 / 4; }
.shot.window, .shot.bare { grid-column: span 2; }
.shot.window .scene, .shot.bare .scene { aspect-ratio: 3 / 2; }
.shot.solo { grid-column: 1 / -1; }
.shot.solo .scene { aspect-ratio: 2.39 / 1; }
.shot figcaption { font-size: var(--t-xs); color: var(--ink-2); }
@media (max-width: 760px) { .shots { grid-template-columns: repeat(2, minmax(0, 1fr)); } .shot.window, .shot.bare { grid-column: 1 / -1; } }

/* Lockups with the Arabic name */
.wm-ar { display: block; font: 700 clamp(1.6rem, 1.2rem + 1.2vw, 2.3rem)/1.3 var(--f-callig); letter-spacing: 0; }
.lock-h .wm small { margin-top: 12px; font-family: "Bricolage Grotesque", sans-serif; }

/* Intro: the mark, then the name written under it */
.intro-stage { position: relative; z-index: 1; display: grid; justify-items: center; gap: 0; will-change: transform; }
.intro-mark { width: min(46vmin, 380px); aspect-ratio: 1; }
.intro-name { margin: -4% 0 0; font: 700 clamp(1.9rem, 1.2rem + 3vw, 3.3rem)/1.3 var(--f-callig); color: var(--ink); clip-path: inset(-20% 0 -20% 100%); }
.intro-name.write { clip-path: inset(-20% 0 -20% 0); transition: clip-path 1.1s var(--wind); }
.intro.opening .intro-name { opacity: 0; transition: opacity .35s ease; }

/* Lost page: footprints walk off into the dunes, the hourglass lies half buried */
.lost { padding-block: clamp(20px, 3vw, 40px) clamp(64px, 10vw, 120px); display: grid; gap: clamp(24px, 4vw, 48px); }
.lost-scene { aspect-ratio: 2.39 / 1; }
.lost-scene .steps { position: absolute; inset: 0; width: 100%; height: 100%; }
.steps path { fill: var(--dune-deep); opacity: .55; }
:root[data-mode="night"] .steps path { opacity: .9; }
[dir="rtl"] .steps { transform: scaleX(-1); }
.lost-glass { position: absolute; width: min(34cqh, 24cqw); aspect-ratio: 1; left: 77%; bottom: -1%; transform: translateX(-50%) rotate(84deg); }
[dir="rtl"] .lost-glass { left: 23%; transform: translateX(-50%) rotate(-84deg); }
.lost-glass :is(.dune, .grains) { display: none; }
.lost-fore { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 24%; z-index: 1; }
.lost-fore path { fill: var(--dune); }
.lost-code { margin: 0 0 10px; font: 620 var(--t-xs)/1 var(--f-text); letter-spacing: .14em; color: var(--ink-2); }
.lost-copy h1 { font-size: var(--t-xxl); font-stretch: 90%; letter-spacing: -.04em; }
.lost-copy > p.mat { margin-top: 14px; font-size: var(--t-l); color: var(--ink-2); max-width: 40ch; }
@media (max-width: 760px) { .lost-scene { aspect-ratio: 4 / 3; } }

/* Footer: keyboard shortcuts and the sound switch */
.keys { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 7px; margin: 0; }
.keys > span:first-child { margin-inline-end: 4px; }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 22px; padding: 0 6px; border: 1px solid var(--rule-2); border-bottom-width: 2px; border-radius: 6px; font: 600 .72rem/1 var(--f-text); color: var(--ink); direction: ltr; }
@media (pointer: coarse) { .keys { display: none; } }
.sound-btn[aria-pressed="true"] { color: var(--glow); text-decoration-style: wavy; }

/* The hourglass turns over when you reach the bottom */
.flip { transform-box: view-box; transform-origin: 196px 178px; transition: transform 1.1s cubic-bezier(.5, -.35, .3, 1.35); }
.at-end :is(.brand-mark, .foot-mark) .flip { transform: rotate(180deg); }

/* Small details: highlight color, scrollbar, wavy ink underlines, longer drips on hover,
   and the nav hourglass, whose sand runs down as you scroll the page */
::selection { background: var(--glow); color: var(--on-glow); }
:is(.signature, .card-title, .wm-ar, .intro-name, .s-callig)::selection { background: var(--shumagh); color: #fff; }
:root { accent-color: var(--glow); scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--dune-deep) 75%, transparent) transparent; }
:is(.elsewhere, .meta-row, .foot-links, .av-body) a { text-decoration-thickness: 1px; text-underline-offset: 4px; }
:is(.elsewhere, .meta-row, .foot-links, .av-body) a:hover { text-decoration-line: underline; text-decoration-style: wavy; text-decoration-color: var(--glow); text-decoration-thickness: 1.5px; }
.frame .art .stream { transform-box: fill-box; transform-origin: 50% 0; transition: transform 1s var(--settle); }
.frame:hover .art .stream { transform: scaleY(2); }
@supports (animation-timeline: scroll()) {
  .brand-mark .sand-top { animation: sand-drain linear both; animation-timeline: scroll(root block); }
  .brand-mark .sand-bot { animation: sand-fill linear both; animation-timeline: scroll(root block); }
}
@keyframes sand-drain { from { clip-path: inset(0 0 0 0); } to { clip-path: inset(100% 0 0 0); } }
@keyframes sand-fill { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }

/* Phones: a smaller portrait so the headline shows on the first screen, and shorter project frames */
@media (max-width: 560px) {
  .hero-in { gap: 14px; padding-block: 18px calc(5svh + 36px); }
  .hero-portrait { width: min(60vw, 236px); }
  .signature { font-size: 1.4rem; margin-top: -3%; }
  .sand-mark { width: 72px; margin-top: -3%; }
  .frame .scene, .frame[data-area="a"] .scene, .frame[data-area="s"] .scene { --ar: 2 / 1; }
  .frame[data-area="m"] .scene { aspect-ratio: 2 / 1; }
  .frame .glyph, .frame[data-area="s"] .glyph { width: min(84cqh, 46cqw); }
  .frame[data-area="a"] .glyph { left: 75%; }
  [dir="rtl"] .frame[data-area="a"] .glyph { left: 25%; }
  .frame { gap: 10px; }
  .card-title { font-size: 1.75rem; }
  .cap h3 { font-size: 1.22rem; }
  .cap .alt { font-size: 1.2rem; }
  .cap .alt:lang(en) { font-size: .9rem; }
  .bento { gap: 26px; }
  .feature .scene, .pv-cover, .lost-scene { aspect-ratio: 16 / 10; }
  .marks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  :is(.pt-fill, .pt-cloth, .pt-cshade, .pt-aura, .pt-lines, .pt-red, .pt-rshade, .signature, .sand-mark) { animation: none; }
  .frame:hover .art .stream { transform: none; }
  .flip { transition: none; }
  .intro-name { clip-path: none; }
}
