/* ==========================================================================
   topplay020 · Portfolio
   Five themes, each a ground and a low-poly gradient that runs down the page. Urbanist + DM Mono + IBM Plex Sans Arabic.
   Logical properties throughout, so EN (LTR) and AR (RTL) share one stylesheet.
   The page sits on top of a fixed WebGL canvas: at 1000px and up the words hold
   one column and the tower stands in the free side; below that, each section
   opens with a transparent "window" onto the tower and its words sit on solid ground.
   ========================================================================== */

:root {
    --hl: var(--accent);
    --f-display: "Urbanist", "IBM Plex Sans Arabic", system-ui, sans-serif;
    --f-body: "Urbanist", "IBM Plex Sans Arabic", system-ui, sans-serif;
    --f-mono: "DM Mono", "IBM Plex Sans Arabic", ui-monospace, monospace;

    --ease: cubic-bezier(.16, 1, .3, 1);
    --gutter: clamp(20px, 4vw, 64px);
    --radius: 10px;
    --nav-h: 72px;
}


/* ---------- Themes: every colour of the page and the 3D comes from these tokens ---------- */
:root, [data-theme="prism"] {
    color-scheme: dark;
    --bg: #0c0a1c; --surface: #17142c; --ink: #f6f5fb; --muted: #b1aec6; --line: rgba(255, 255, 255, .13);
    --accent: #ffd27a; --accent-hover: #ffe09f; --on-accent: #1a1030; --glow: #ffd27a;
    --grad: linear-gradient(100deg, #35c8ff, #6f6bff 34%, #ff4f9a 66%, #ffb04f);
    --pal: #21d1ff, #2b85ff, #3833d1, #7a33d9, #eb61b8, #ff216b, #ff8047, #ffd67a;
    --hl-work: #5ec8ff; --hl-services: #8f9bff; --hl-stack: #d08bff; --hl-features: #ff7fb4; --hl-process: #ff9d63; --hl-contact: #ffd27a;
    --nav-bg: rgba(12, 10, 28, .74); --nav-solid: rgba(12, 10, 28, .88); --glass: rgba(12, 10, 28, .62); --hover: rgba(23, 20, 44, .8);
    --ghost: rgba(255, 255, 255, .3); --tag: rgba(255, 255, 255, .09); --sticker-ink: #1a1030; --sticker-edge: #fff;
    --poster-filter: none; --poster-op: 1;
}
[data-theme="ember"] {
    color-scheme: dark;
    --bg: #130806; --surface: #231210; --ink: #fbf4ef; --muted: #c4afa6; --line: rgba(255, 255, 255, .13);
    --accent: #ffb24d; --accent-hover: #ffc978; --on-accent: #220c04; --glow: #ffb24d;
    --grad: linear-gradient(100deg, #ff3d55, #ff6a3d 40%, #ff9a3d 70%, #ffd166);
    --pal: #8c1a2e, #cc1f29, #f2451f, #ff731a, #ff9e29, #ffc247, #ffdb80, #fff0b8;
    --hl-work: #ff7a6b; --hl-services: #ff8a57; --hl-stack: #ff9f4a; --hl-features: #ffb84d; --hl-process: #ffcc66; --hl-contact: #ffe08a;
    --nav-bg: rgba(19, 8, 6, .74); --nav-solid: rgba(19, 8, 6, .88); --glass: rgba(19, 8, 6, .62); --hover: rgba(35, 18, 16, .8);
    --ghost: rgba(255, 255, 255, .3); --tag: rgba(255, 255, 255, .09); --sticker-ink: #220c04; --sticker-edge: #fff;
    --poster-filter: hue-rotate(115deg) saturate(1.2); --poster-op: 1;
}
[data-theme="aurora"] {
    color-scheme: dark;
    --bg: #04120f; --surface: #0c211c; --ink: #f1fbf7; --muted: #a5c2b8; --line: rgba(255, 255, 255, .13);
    --accent: #5ff0b0; --accent-hover: #8ff7c9; --on-accent: #04201a; --glow: #5ff0b0;
    --grad: linear-gradient(100deg, #1ee3c0, #3df08a 40%, #a6f24d 70%, #4dc9ff);
    --pal: #067373, #089e8c, #0dc78c, #29e085, #66ed73, #9ef26b, #4dd9d9, #73b3ff;
    --hl-work: #4de8c8; --hl-services: #57ec9f; --hl-stack: #8ef07a; --hl-features: #bdf26b; --hl-process: #66dfe6; --hl-contact: #8cc4ff;
    --nav-bg: rgba(4, 18, 15, .74); --nav-solid: rgba(4, 18, 15, .88); --glass: rgba(4, 18, 15, .62); --hover: rgba(12, 33, 28, .8);
    --ghost: rgba(255, 255, 255, .3); --tag: rgba(255, 255, 255, .09); --sticker-ink: #04201a; --sticker-edge: #fff;
    --poster-filter: hue-rotate(250deg) saturate(1.1); --poster-op: 1;
}
[data-theme="arctic"] {
    color-scheme: dark;
    --bg: #06111f; --surface: #0e1f33; --ink: #f2f8fd; --muted: #a8bdd0; --line: rgba(255, 255, 255, .14);
    --accent: #7fd8ff; --accent-hover: #abe6ff; --on-accent: #04182b; --glow: #7fd8ff;
    --grad: linear-gradient(100deg, #2f7dff, #3db4ff 45%, #8fe3ff 75%, #e6f8ff);
    --pal: #0a296b, #0f479e, #146bcc, #1f94eb, #38bdfa, #73d9ff, #b3edff, #e6faff;
    --hl-work: #5cb8ff; --hl-services: #6fc6ff; --hl-stack: #85d3ff; --hl-features: #9ddfff; --hl-process: #b8e9ff; --hl-contact: #d9f4ff;
    --nav-bg: rgba(6, 17, 31, .74); --nav-solid: rgba(6, 17, 31, .88); --glass: rgba(6, 17, 31, .62); --hover: rgba(14, 31, 51, .8);
    --ghost: rgba(255, 255, 255, .3); --tag: rgba(255, 255, 255, .1); --sticker-ink: #04182b; --sticker-edge: #fff;
    --poster-filter: hue-rotate(-40deg) saturate(.85); --poster-op: 1;
}
[data-theme="paper"] {
    color-scheme: light;
    --bg: #f4f1ea; --surface: #e8e3d8; --ink: #1b1726; --muted: #58536a; --line: rgba(27, 23, 38, .17);
    --accent: #3b2fd0; --accent-hover: #2c22ad; --on-accent: #fff; --glow: #3b2fd0;
    --grad: linear-gradient(100deg, #0a7fc4, #4a3fe0 36%, #d6246f 68%, #e0641a);
    --pal: #4db3f2, #598cf2, #8073e6, #b373e0, #f280b8, #ff8085, #ffa873, #ffd180;
    --hl-work: #07659e; --hl-services: #4a45c8; --hl-stack: #8530bf; --hl-features: #bf2869; --hl-process: #b94c15; --hl-contact: #7e5d00;
    --nav-bg: rgba(244, 241, 234, .78); --nav-solid: rgba(244, 241, 234, .92); --glass: rgba(244, 241, 234, .7); --hover: rgba(232, 227, 216, .85);
    --ghost: rgba(27, 23, 38, .36); --tag: rgba(27, 23, 38, .08); --sticker-ink: #fff; --sticker-edge: #fff;
    --poster-filter: saturate(.8); --poster-op: .22;
}

/* ---------- The theme picker ---------- */
.theme { position: relative; }
.theme-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px; transition: background-color .2s, border-color .2s; }
.theme-btn:hover, .theme-btn[aria-expanded="true"] { background: var(--surface); border-color: var(--ghost); }
.hexa { display: block; width: 22px; height: 22px; background: var(--grad); clip-path: polygon(50% 0, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%); transition: transform .5s var(--ease); }
.theme-btn:hover .hexa { transform: rotate(60deg) scale(1.1); }
.theme-menu { --ring: var(--ink); position: absolute; inset-block-start: calc(100% + 8px); inset-inline-end: 0; z-index: 2; display: flex; gap: 2px; padding: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 34px rgba(0, 0, 0, .3); animation: themeIn .28s var(--ease); }
.theme-menu[hidden] { display: none; }
@keyframes themeIn { from { opacity: 0; transform: translateY(-6px) scale(.97); } }
.swatch { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 7px; background: transparent; }
.swatch .hexa { width: 28px; height: 28px; }
.swatch:hover .hexa { transform: rotate(60deg) scale(1.12); }
.swatch[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--ring); }

/* On a phone the menu centres under the nav, so it can never run off the screen. */
@media (max-width: 640px) {
    .theme { position: static; }
    .theme-menu { position: fixed; inset-block-start: calc(var(--nav-h) + 2px); inset-inline-end: auto; left: 50%; translate: -50% 0; }
}

/* ---------- The wave: the new theme is revealed outward from the click, by script ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 2; }
#themeRim { display: none; position: fixed; inset: 0; z-index: 90; pointer-events: none; background: var(--grad); view-transition-name: theme-rim; }
::view-transition-group(theme-rim) { z-index: 3; animation: none; }
::view-transition-old(theme-rim) { display: none; }
::view-transition-new(theme-rim) { animation: none; }

/* ---------- Stickers and details on each project ---------- */
.stickers { display: flex; flex-wrap: wrap; gap: 10px 8px; margin-block: 14px 4px; }
.sticker {
    --c: var(--hl);
    display: inline-block; padding: 5px 11px; background: var(--c); color: var(--sticker-ink);
    font-family: var(--f-display); font-size: 13.5px; font-weight: 600; line-height: 1.25; letter-spacing: 0;
    border: 2.5px solid var(--sticker-edge); border-radius: 7px;
    box-shadow: 0 5px 12px rgba(0, 0, 0, .34);
    transform: rotate(var(--r, 0deg));
    transition: transform .45s cubic-bezier(.2, 1.7, .3, 1), opacity .18s;
    transition-delay: calc(.2s + var(--k, 0) * 90ms);
}
.sticker:nth-child(2) { --c: var(--accent); }
.sticker:nth-child(3) { --c: var(--ink); --sticker-ink: var(--bg); }
[data-theme="paper"] .sticker:nth-child(2) { --sticker-ink: #fff; }
.sticker:hover { transform: rotate(calc(var(--r, 0deg) * -1)) scale(1.1); transition-delay: 0s; }
.anim .stickers[data-r]:not(.in) { opacity: 1; transform: none; }
.anim .stickers[data-r]:not(.in) .sticker { opacity: 0; transform: rotate(calc(var(--r, 0deg) * 4)) scale(1.45); }
.row-points { margin-block-start: 12px; display: grid; gap: 5px; }
.row-points li { position: relative; padding-inline-start: 18px; font-size: 15.5px; line-height: 1.45; color: var(--ink); }
.row-points li::before { content: ""; position: absolute; inset-inline-start: 0; inset-block-start: .42em; width: 9px; height: 9px; background: var(--hl); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--nav-h) + 8px);
    -webkit-text-size-adjust: 100%;
    background: var(--bg);
}

body {
    font-family: var(--f-body);
    font-size: 17px;
    line-height: 1.6;
    letter-spacing: .012em;
    color: var(--ink);
    background: var(--bg);
    overflow-x: clip;
    -webkit-font-smoothing: antialiased;
}
html[lang="ar"] body { letter-spacing: 0; }

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul, ol { list-style: none; }
b, em { font-weight: inherit; font-style: normal; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--glow); outline-offset: 3px; border-radius: 4px; }

.i { width: 1.25em; height: 1.25em; fill: currentColor; flex: none; }

html[lang="ar"] body { line-height: 1.8; }

.skip {
    position: fixed; inset-block-start: 10px; inset-inline-start: 10px; z-index: 100;
    padding: 10px 16px; background: var(--ink); color: var(--on-accent); border-radius: 8px;
    transform: translateY(-200%); transition: transform .2s;
}
.skip:focus { transform: none; }

/* ---------- The tower ---------- */
#scene, #poster { position: fixed; inset: 0; width: 100%; height: 100lvh; pointer-events: none; }
#scene { z-index: 0; opacity: 0; transition: opacity .6s; display: block; }
#poster { z-index: 0; object-fit: cover; object-position: 50% 40%; transition: opacity .6s; filter: var(--poster-filter); opacity: var(--poster-op); }
.gl-on #scene { opacity: 1; }
.gl-on #poster { opacity: 0; }
.no-gl #scene { display: none; }

/* ---------- Nav ---------- */
.nav {
    position: fixed; inset-block-start: 0; inset-inline: 0; z-index: 20;
    height: var(--nav-h); padding-inline: var(--gutter);
    display: flex; align-items: center; justify-content: space-between; gap: 24px;
    transition: background-color .25s, box-shadow .25s;
}
.nav.scrolled { background: var(--nav-solid); box-shadow: 0 1px 0 var(--line); }
@supports (backdrop-filter: blur(1px)) {
    .nav.scrolled { background: var(--nav-bg); backdrop-filter: blur(12px); }
}

.brand { font-family: var(--f-mono); font-size: 18px; font-weight: 500; letter-spacing: -.02em; display: inline-flex; direction: ltr; }
.brand b, .wm b { background: var(--grad); background-size: 240% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: gradShift 7s ease-in-out infinite alternate; }
@keyframes gradShift { to { background-position: 100% 0; } }
.motion-off .brand b, .motion-off .wm b { animation-play-state: paused; }

.nav-links { display: flex; gap: 28px; }
.nav-links a {
    font-size: 15px; font-weight: 500; color: var(--muted); padding-block: 8px;
    background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
    transition: color .2s, background-size .25s var(--ease);
}
html[dir="rtl"] .nav-links a { background-position: 100% 100%; }
.nav-links a:hover, .nav-links a.active { color: var(--ink); background-size: 100% 1px; }

.nav-end { display: flex; align-items: center; gap: 12px; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang button { min-height: 36px; padding-inline: 12px; font-size: 13px; font-weight: 500; color: var(--muted); transition: color .2s, background-color .2s; }
.lang button:hover { color: var(--ink); }
.lang button[aria-pressed="true"] { background: var(--surface); color: var(--ink); }

.menu-btn { display: none; width: 44px; height: 44px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 8px; }
.menu-btn .i { width: 22px; height: 22px; }

#mobile-menu {
    position: fixed; inset: 0; z-index: 15; background: var(--bg);
    padding: calc(var(--nav-h) + 24px) var(--gutter) 32px;
    display: flex; flex-direction: column; justify-content: space-between;
    opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s;
}
#mobile-menu.open { opacity: 1; visibility: visible; }
#mobileLinks a {
    display: flex; align-items: baseline; gap: 14px; padding-block: 12px;
    font-family: var(--f-display); font-size: 34px; font-weight: 500; letter-spacing: -.02em;
    border-block-end: 1px solid var(--line);
}
#mobileLinks small { font-family: var(--f-mono); font-size: 13px; color: var(--accent); letter-spacing: 0; }
.m-channels { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.m-channels:empty { display: none; }
.m-channels a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 600; }
.m-mail { display: block; font-family: var(--f-mono); font-size: 16px; color: var(--muted); padding-block: 12px; }

/* ---------- Floor rail ---------- */
#floors {
    position: fixed; inset-inline-end: 18px; inset-block-start: 50%; transform: translateY(-50%); z-index: 10;
    display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
}
#floors a {
    display: flex; align-items: center; gap: 10px; min-height: 30px; padding-inline: 8px;
    font-family: var(--f-mono); font-size: 12px; color: var(--muted);
    text-shadow: 0 0 6px var(--bg), 0 0 2px var(--bg);
    transition: color .2s;
}
#floors a span { opacity: 0; transform: translateX(calc(var(--dirx, 1) * 6px)); transition: opacity .2s, transform .25s var(--ease); white-space: nowrap; }
#floors a i { width: 16px; height: 2px; background: currentColor; opacity: .55; transition: width .25s var(--ease), opacity .2s, background-color .2s; }
#floors a:hover span { opacity: 1; transform: none; }
#floors a:hover { color: var(--ink); }
#floors a.active { color: var(--ink); }
#floors a.active i { width: 28px; opacity: 1; background: var(--glow); }

/* ---------- Layout ---------- */
main, .foot { position: relative; z-index: 1; }
.window { display: none; }

.sec { position: relative; overflow-x: clip; min-height: 100svh; display: flex; align-items: center; padding-block: calc(var(--nav-h) + 48px) 96px; }
.sec-body { inline-size: 100%; padding-inline: var(--gutter); }
.col { inline-size: min(52vw, 780px); }

h2 { font-family: var(--f-display); font-size: clamp(38px, 4.4vw, 68px); font-weight: 500; line-height: 1.04; letter-spacing: -.035em; }
h2 .hl { color: var(--hl); white-space: nowrap; }
#portfolio { --hl: var(--hl-work); } #services { --hl: var(--hl-services); } #stack { --hl: var(--hl-stack); } #features { --hl: var(--hl-features); } #process { --hl: var(--hl-process); } #contact { --hl: var(--hl-contact); }
h3 { font-family: var(--f-display); font-size: 22px; font-weight: 500; line-height: 1.2; letter-spacing: -.005em; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3, html[lang="ar"] .h1-sub { letter-spacing: 0; line-height: 1.3; }

.floor { font-family: var(--f-mono); font-size: 13px; color: var(--hl); margin-block-end: 14px; }
.lede { color: var(--muted); font-size: 19px; line-height: 1.5; max-inline-size: 56ch; margin-block-start: 14px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    min-height: 50px; padding: 12px 22px; border-radius: 8px;
    font-size: 16px; font-weight: 600; line-height: 1.2;
    transition: transform .18s var(--ease), background-color .18s, border-color .18s, color .18s;
}
.btn .i { transition: transform .25s var(--ease); }
.btn:hover { transform: translateY(-2px); }
.btn:hover .i { transform: translate(calc(var(--dirx, 1) * 2px), -2px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn-primary { position: relative; overflow: hidden; background: var(--accent); color: var(--on-accent); }
.btn-primary::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .55) 50%, transparent 65%); transform: translateX(-120%); transition: transform .6s var(--ease); }
.btn-primary:hover::after { transform: translateX(120%); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { border: 1px solid var(--ghost); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-sm { min-height: 40px; padding: 8px 16px; font-size: 14px; }
html[dir="rtl"] { --dirx: -1; }

.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-block-start: 28px; }

/* ---------- Hero ---------- */
.badge { display: inline-flex; align-items: center; gap: 10px; font-family: var(--f-mono); font-size: 13px; color: var(--muted); }
.dot { width: 8px; height: 8px; background: var(--glow); border-radius: 2px; }

h1 { margin-block-start: 18px; font-family: var(--f-display); font-weight: 500; }
.wm { display: block; direction: ltr; text-align: start; font-size: clamp(60px, 8.1vw, 128px); line-height: .95; letter-spacing: -.045em; }
html[dir="rtl"] .wm { text-align: right; }
.h1-sub { display: block; margin-block-start: 16px; font-size: clamp(25px, 2.6vw, 38px); line-height: 1.15; letter-spacing: -.02em; }
.h1-sub em { color: var(--accent); white-space: nowrap; display: inline-block; }

.hero-desc { margin-block-start: 22px; font-size: 19px; line-height: 1.5; max-inline-size: 52ch; color: var(--ink); }
.hero-fact { margin-block-start: 12px; font-family: var(--f-mono); font-size: 14px; line-height: 1.6; color: var(--muted); max-inline-size: 60ch; }

[data-enter] { opacity: 0; transform: translateY(14px); }
.ready [data-enter] { animation: enter .8s var(--ease) forwards; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes enter { to { opacity: 1; transform: none; } }

/* ---------- Work ---------- */
.rows { margin-block-start: 40px; }
.row {
    position: relative; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 28px;
    align-items: center; min-height: 46vh; padding-block: 32px; border-block-start: 1px solid var(--line);
}
.row.featured { grid-template-columns: minmax(0, 1fr); gap: 22px; }
/* Screenshots keep their own proportions: nothing is cropped. The hairline holds dark ones off the dark page. */
.thumb { display: block; overflow: hidden; border-radius: var(--radius); background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.thumb img { width: 100%; height: auto; transition: transform .5s var(--ease); }
.row:hover .thumb img { transform: scale(1.025); }

.row-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-family: var(--f-mono); font-size: 12px; color: var(--hl); }
.row h3 { margin-block-start: 8px; font-size: 26px; }
.row.featured h3 { font-size: clamp(28px, 2.8vw, 38px); letter-spacing: -.025em; }
.row-sub { margin-block-start: 4px; color: var(--ink); font-weight: 500; }
.row-desc { margin-block-start: 10px; color: var(--muted); font-size: 16px; line-height: 1.55; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-block-start: 14px; }
.tag { font-family: var(--f-mono); font-size: 12px; line-height: 1; padding: 6px 8px; background: var(--tag); border-radius: 5px; color: var(--ink); }

.go {
    display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-block-start: 10px;
    font-weight: 600; color: var(--hl);
    background: linear-gradient(currentColor, currentColor) 0 85% / 0 1px no-repeat;
    transition: background-size .25s var(--ease);
}
html[dir="rtl"] .go { background-position: 100% 85%; }
.go:hover { background-size: 100% 1px; }
.go .i { transition: transform .25s var(--ease); }
.go:hover .i { transform: translate(calc(var(--dirx, 1) * 2px), -2px); }

/* With the 3D running on a wide screen, each screenshot assembles beside its row: the row is words only. */
@media (min-width: 1000px), (min-width: 640px) and (max-height: 500px) and (orientation: landscape) {
    .gl-capable .thumb { display: none; }
    .gl-capable .row, .gl-capable .row.featured { display: block; min-height: 66vh; align-content: center; padding-block: 48px; border: 0; }

    /* The words and the shape trade sides as the page goes down. */
    .gl-capable #portfolio .col { inline-size: 100%; }
    .gl-capable #portfolio .floor, .gl-capable #portfolio h2, .gl-capable #portfolio .lede, .gl-capable .row-body { inline-size: min(52vw, 780px); max-inline-size: 100%; }
    .gl-capable .row:nth-child(even) .row-body { margin-inline-start: auto; margin-inline-end: 24px; }
    .gl-capable #services .col, .gl-capable #features .col, .gl-capable #contact .col, .gl-capable .foot .col { margin-inline-start: auto; margin-inline-end: 24px; }
    .gl-capable .row h3, .gl-capable .row.featured h3 { font-size: clamp(34px, 3.2vw, 48px); letter-spacing: -.025em; }
    .gl-capable .row-sub { font-size: 19px; margin-block-start: 6px; }
    .gl-capable .row-desc { font-size: 17px; max-inline-size: 60ch; }
}

/* ---------- Services ---------- */
.svc-list { margin-block-start: 32px; }
.svc {
    display: grid; grid-template-columns: 32px minmax(0, 5fr) minmax(0, 7fr); gap: 14px; align-items: center;
    padding: 14px 8px; min-height: 58px; border-block-start: 1px solid var(--line); border-radius: 2px;
    transition: background-color .2s, transform .25s var(--ease);
}
.svc:last-child { border-block-end: 1px solid var(--line); }
.svc:hover { background: var(--hover); transform: translateX(calc(var(--dirx, 1) * 4px)); }
.svc .i { color: var(--hl); width: 22px; height: 22px; transition: color .2s; }
.svc:hover .i { color: var(--ink); }
.svc h3 { font-size: 18px; }
.svc p { color: var(--muted); font-size: 15.5px; line-height: 1.4; }

/* ---------- Toolbox ---------- */
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-block-start: 32px; border-block-start: 1px solid var(--line); border-inline-start: 1px solid var(--line); }
.chips li {
    font-family: var(--f-mono); font-size: 14px; padding: 13px 14px;
    border-block-end: 1px solid var(--line); border-inline-end: 1px solid var(--line);
    transition: background-color .2s, color .2s;
}
.chips li:hover { background: var(--hl); color: var(--on-accent); }

.chips { grid-auto-flow: row dense; grid-auto-rows: 48px; }
.chips li { display: flex; align-items: center; gap: 9px; min-width: 0; padding-block: 0; white-space: nowrap; overflow: hidden; }
.chips li.wide { grid-column: span 2; }
.chips li.hot { font-weight: 500; }
.chips li.hot::after, .legend i { content: ""; width: 8px; height: 8px; flex: none; background: var(--hl); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.chips li.hot::after { margin-inline-start: auto; }
.legend { display: flex; align-items: center; gap: 8px; margin-block-start: 12px; font-family: var(--f-mono); font-size: 13px; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Why ---------- */
.why { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; margin-block-start: 32px; }
.why li { padding-block: 20px; border-block-start: 1px solid var(--line); }
.why-top { display: flex; align-items: center; gap: 10px; }
.why .i { color: var(--hl); width: 24px; height: 24px; transition: color .2s, transform .25s var(--ease); }
.why li:hover .i { color: var(--ink); transform: translateY(-2px); }
.why p { margin-block-start: 8px; color: var(--muted); font-size: 16px; line-height: 1.5; }

/* ---------- Process ---------- */
.steps { margin-block-start: 32px; }
.steps li { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 14px; padding-block: 22px; border-block-start: 1px solid var(--line); transition: background-color .2s; }
.steps li:last-child { border-block-end: 1px solid var(--line); }
.steps b { font-family: var(--f-mono); font-size: 30px; line-height: 1.1; color: var(--hl); transition: color .2s; }
.steps li:hover b { color: var(--ink); }
.steps p { margin-block-start: 4px; color: var(--muted); }

/* ---------- Contact ---------- */
.contact h2 { font-size: clamp(44px, 5vw, 80px); }
.mail-big {
    display: inline-block; margin-block-start: 26px; direction: ltr;
    font-family: var(--f-mono); font-size: clamp(19px, 2.2vw, 30px); color: var(--hl);
    background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size .3s var(--ease);
    max-inline-size: 100%; overflow-wrap: anywhere;
}
.mail-big:hover { background-size: 100% 1px; }

.btn[hidden] { display: none; }
.msg-wa .i { color: #25d366; }
.msg-tg .i { color: #2aabee; }

/* ---------- Footer ---------- */
.foot { padding: 0 var(--gutter) 28px; }
.foot .col { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block-start: 18px; border-block-start: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.foot-social { display: flex; flex-wrap: wrap; gap: 0 18px; }
.foot-social a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 500; transition: color .2s; }
.foot-social a:hover { color: var(--ink); }

/* ---------- Words slide in from their own side, once ---------- */
.anim [data-r] { transition: opacity .7s var(--ease), transform .95s var(--ease); transition-delay: calc(var(--i, 0) * 50ms); }
.anim [data-r]:not(.in) { opacity: 0; transform: translate3d(calc(var(--from, 0) * 1px), 22px, 0); }
.anim .thumb[data-r]:not(.in) { transform: translate3d(0, 22px, 0) scale(.96); }

/* ---------- Progress along the page ---------- */
#progress { position: fixed; inset-block-start: 0; inset-inline: 0; z-index: 25; height: 2px; background: var(--grad); transform-origin: 0 50%; transform: scaleX(0); pointer-events: none; }
html[dir="rtl"] #progress { transform-origin: 100% 50%; }
@supports (animation-timeline: scroll()) {
    #progress { animation: progressGrow linear both; animation-timeline: scroll(root); }
    @keyframes progressGrow { to { transform: scaleX(1); } }
}
@supports not (animation-timeline: scroll()) { #progress { display: none; } }

/* ---------- Pause the motion ---------- */
#motionBtn {
    position: fixed; inset-block-end: 16px; inset-inline-end: 16px; z-index: 12; width: 44px; height: 44px;
    display: inline-flex; align-items: center; justify-content: center; border-radius: 8px;
    background: var(--glass); border: 1px solid var(--line); color: var(--ink);
    transition: background-color .2s, transform .18s var(--ease);
}
#motionBtn:hover { background: var(--surface); transform: translateY(-2px); }
#motionBtn:active { transform: scale(.96); }
#motionBtn .i { width: 18px; height: 18px; }
.no-gl #motionBtn { display: none; }
@media (prefers-reduced-motion: reduce) { #motionBtn { display: none; } }
/* Stacked, it stays at the top of the hero and scrolls away with it: never over the words. */
@media (max-width: 639px), (max-width: 999px) and (min-height: 501px), (max-width: 999px) and (orientation: portrait) {
    #motionBtn { position: absolute; inset-block-start: 72px; inset-block-end: auto; inset-inline-end: var(--gutter); z-index: 5; }
}

/* ---------- Toast ---------- */
#toast {
    position: fixed; inset-block-end: 24px; inset-inline-start: 50%; translate: calc(var(--dirx, 1) * -50%) 0; z-index: 30;
    padding: 12px 18px; background: var(--ink); color: var(--on-accent); border-radius: 8px; font-weight: 600; font-size: 15px;
    opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .2s, transform .25s var(--ease);
}
#toast.show { opacity: 1; transform: none; }

/* ---------- Medium: the tower no longer has a side of its own ---------- */
@media (max-width: 1240px) {
    .nav-links { gap: 18px; }
    .nav-links a { font-size: 14px; }
    .row { grid-template-columns: minmax(0, 1fr); gap: 18px; }
}

@media (min-width: 1000px), (min-width: 640px) and (max-height: 500px) and (orientation: landscape) {
    /* The poster's dark side faces the words, and fades into the page instead of ending on an edge. */
    #poster { inset-inline-start: auto; inset-inline-end: 0; width: 56vw; -webkit-mask-image: linear-gradient(to right, transparent, #000 24%); mask-image: linear-gradient(to right, transparent, #000 24%); }
    html[dir="rtl"] #poster { inset-inline-start: auto; transform: scaleX(-1); }
}

/* ---------- No room for the links: the menu takes over ---------- */
@media (max-width: 999px) {
    :root { --nav-h: 64px; }
    body { font-size: 16.5px; }
    .nav-links, #floors, .nav-cta { display: none; }
    .menu-btn { display: inline-flex; }
    .brand { padding-block: 10px; }
    .lang button { min-height: 40px; }
    .nav.scrolled { background: var(--nav-solid); backdrop-filter: none; }
    .theme-btn { width: 40px; height: 40px; }
    .row h3 a { display: inline-block; padding-block: 4px; }
    .mail-big { padding-block: 8px; }
}

/* ---------- Landscape phone: side by side, with less air ---------- */
@media (max-width: 999px) and (min-width: 640px) and (max-height: 500px) and (orientation: landscape) {
    .sec { padding-block: calc(var(--nav-h) + 12px) 36px; }
    .wm { font-size: clamp(48px, 8vw, 72px); }
    .h1-sub { font-size: 22px; margin-block-start: 8px; }
    .hero-desc { font-size: 15px; margin-block-start: 10px; }
    .hero-fact { display: none; }
    .cta { margin-block-start: 14px; }
    .btn { min-height: 44px; padding: 8px 16px; font-size: 15px; }
    .badge { display: none; }
    h1 { margin-block-start: 0; }
    .svc { grid-template-columns: 26px minmax(0, 1fr); gap: 0 10px; min-height: 0; padding: 10px 4px; }
    .svc p { grid-column: 2; font-size: 14px; }
    .why { grid-template-columns: minmax(0, 1fr); }
    .chips { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .chips li { padding: 9px 8px; font-size: 12.5px; }
}

/* ---------- Stacked: one column, the scene runs behind all of it ---------- */
@media (max-width: 639px), (max-width: 999px) and (min-height: 501px), (max-width: 999px) and (orientation: portrait) {
    :root {
        --win: min(92vw, max(44svh, 240px));
        --win-row: min(66vw, max(40svh, 220px));
    }
    .sec { display: block; min-height: 0; padding: 0; }
    .sec-body { padding-block: 4px 56px; }
    .col { inline-size: 100%; max-inline-size: 720px; margin-inline: auto; }
    .window { display: block; height: var(--win); }

    /* The poster only stands in at the top until the scene is drawn. */
    #poster { height: 62svh; object-position: 62% 30%; -webkit-mask-image: linear-gradient(#000 72%, transparent); mask-image: linear-gradient(#000 72%, transparent); }

    /* Hero: everything on the first screen, the shape takes what the words leave. */
    .hero { min-height: 100svh; display: flex; flex-direction: column; }
    .hero .window { flex: 1 1 auto; height: auto; min-height: min(84vw, 36svh); margin-block-start: var(--nav-h); }
    .hero .sec-body { flex: none; padding-block: 0 24px; }
    h1 { margin-block-start: 10px; }
    .wm { font-size: clamp(50px, 16.2vw, 112px); }
    .h1-sub { font-size: clamp(22px, 6vw, 34px); margin-block-start: 10px; }
    .hero-desc { font-size: 16px; line-height: 1.45; margin-block-start: 12px; }
    .hero-fact { font-size: 12px; margin-block-start: 8px; }
    .hero .cta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-block-start: 16px; }
    .hero .cta .btn { min-height: 48px; padding: 8px 10px; font-size: 15px; }

    /* Work: each project gets an open space where its screenshot assembles. */
    #portfolio > .window { display: none; }
    #portfolio .sec-body { padding-block: 52px 8px; }
    .rows { margin-block-start: 4px; }
    .row, .row.featured { display: block; min-height: 0; padding-block: 0 40px; border: 0; }
    .row > .window { display: none; height: var(--win-row); }
    .gl-capable .row > .window { display: block; }
    .gl-capable .thumb { display: none; }
    .thumb { margin-block: 20px 16px; }
    .row h3, .row.featured h3 { font-size: 28px; letter-spacing: -.02em; margin-block-start: 6px; }
    .row-sub { font-size: 16.5px; }
    .row-desc { font-size: 15.5px; }

    h2 { font-size: clamp(36px, 10.6vw, 60px); }
    .contact h2 { font-size: clamp(38px, 11vw, 66px); }
    .lede { font-size: 17px; }
    .svc-list, .chips, .why, .steps { margin-block-start: 22px; }

    .foot { padding-block-end: 20px; }
    .foot .col { border-block-start: 1px solid var(--line); padding-block-start: 10px; }

    /* No scene to draw: plain ground behind the words, a shorter glimpse of the poster. */
    .no-gl .sec-body { background: var(--bg); padding-block-start: 28px; }
    .no-gl .sec:not(.hero) > .sec-body { box-shadow: 0 -1px 0 var(--line); }
    .no-gl .sec:not(.hero) > .window { height: 0; }
    .no-gl .foot { background: var(--bg); }
}

@media (max-width: 560px) {
    .contact .cta .btn { flex: 1 1 40%; padding-inline: 10px; }
    .svc { grid-template-columns: 26px minmax(0, 1fr); gap: 1px 12px; padding: 12px 4px; }
    .svc p { grid-column: 2; font-size: 15px; }
    .why { grid-template-columns: minmax(0, 1fr); }
    .why li { padding-block: 15px; }
    .chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chips li { padding: 11px 12px; font-size: 13.5px; }
    .steps li { grid-template-columns: 46px minmax(0, 1fr); padding-block: 16px; }
    .steps b { font-size: 23px; }
    .lang button { padding-inline: 10px; }
}

/* Short phones: keep the buttons on the first screen. */
@media (max-width: 999px) and (min-height: 501px) and (max-height: 720px), (max-width: 639px) and (max-height: 720px) {
    .hero-fact { display: none; }
    .hero .window { min-height: 26svh; }
    .hero-desc { font-size: 15px; }
    .hero .badge { font-size: 12px; }
}

/* The narrowest phones: buttons lose their icons rather than their words. */
@media (max-width: 374px) {
    .hero .cta .btn .i { display: none; }
    .lang button { padding-inline: 8px; font-size: 12px; }
    .brand { font-size: 16px; }
    .nav-end { gap: 6px; }
    .swatch { width: 40px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
    [data-enter] { opacity: 1; transform: none; }
}
