// Portfolio landing page — Elspeth Belden
const { useState, useEffect, useLayoutEffect, useRef } = React;

// "Hair like this" squiggle — 4 strand outlines, each drawn in sequence
// with stroke-dasharray/dashoffset the first time it scrolls into view.
const HAIR_PATHS = [
  "M115.356 74.7964C99.0798 87.6924 69.4594 114.164 53.5749 130.939C53.2084 131.316 52.7617 131.797 52.3476 132.258C52.109 132.524 51.8588 132.808 51.5986 133.107C48.2823 136.949 45.227 141.018 41.8932 145.802C37.9407 151.551 33.357 158.49 28.1675 168.517C23.7541 177.839 14.8495 194.281 20.2297 206.952C21.5392 209.192 23.6586 210.84 26.6871 211.984C30.1396 213.514 35.2316 211.226 39.9049 206.57C56.1956 189.306 69.0113 155.103 62.9797 137.415C57.4983 129.288 48.6119 130.825 40.4153 138.342C18.653 157.407 13.1824 188.326 13.8332 218.149C14.4304 245.268 16.3036 275.058 32.4717 294.247C35.6553 302.341 45.5981 287.114 50.3184 275.247C55.6608 262.667 59.7321 249.279 63.6004 235.733C64.0213 234.224 64.4603 232.637 64.9306 230.966C65.4221 229.303 65.7328 227.861 66.6739 225.384C70.067 216.228 73.6472 204.827 77.2716 194.248C79.0921 188.886 80.9362 183.53 82.8324 178.309C83.7913 175.675 84.7581 173.081 85.797 170.49C86.297 169.248 86.8582 167.892 87.4651 166.57C87.5977 166.281 87.7991 165.853 87.9636 165.521C88.0493 165.347 88.1348 165.177 88.2207 165.011C88.322 164.815 88.4365 164.599 88.5473 164.399C88.6595 164.197 88.7741 163.998 88.8953 163.798C89.0335 163.57 89.2328 163.258 89.4442 162.968C89.5526 162.818 89.6707 162.664 89.8072 162.499C89.9397 162.337 90.2578 161.971 90.6329 161.643C91.0518 161.294 91.461 160.92 92.5275 160.476C93.3233 160.156 94.5344 159.897 95.8704 160.149C97.2064 160.381 98.4168 161.152 99.1097 161.89C107.319 171.342 108.379 180.886 109.9 188.552C113.532 215.405 111.409 234.663 108.729 250.913C107.804 255.304 106.373 258.641 104.912 261.912C102.086 268.106 98.7133 273.984 93.9613 279.36C91.5532 282.001 88.7973 284.611 84.8807 286.433C81.1012 288.354 75.1933 288.447 71.2569 285.918C64.2357 281.247 63.8534 274.518 63.239 269.39C62.847 264.017 63.2846 258.92 64.0205 253.903C65.6119 243.885 68.1583 234.277 72.8223 224.863C78.3319 214.239 84.2995 203.744 91.6494 193.916C95.3858 189.024 99.3647 184.224 104.757 180.184C107.479 178.221 110.67 176.304 114.842 175.767C119.057 175.12 123.795 177.149 126.437 179.932C145.067 209.214 131.121 238.397 124.822 265.129C124.745 265.383 124.697 265.544 124.606 265.796C124.594 265.83 124.58 265.868 124.562 265.913C124.553 265.936 124.543 265.96 124.532 265.988C124.535 265.98 124.502 266.065 124.445 266.187C124.376 266.319 124.332 266.461 124.023 266.894C123.84 267.114 123.658 267.447 122.844 267.967C122.431 268.212 121.772 268.526 120.823 268.551C119.882 268.594 118.777 268.17 118.15 267.626C116.887 266.484 116.884 265.737 116.751 265.345C116.665 264.934 116.663 264.728 116.657 264.564C116.656 263.981 116.694 263.93 116.708 263.793C116.723 263.692 116.747 263.572 116.747 263.569C116.749 263.558 116.751 263.548 116.753 263.537C116.77 263.455 116.786 263.379 116.804 263.298C116.839 263.138 116.882 262.956 116.931 262.751C116.959 262.635 116.989 262.51 117.022 262.375C117.086 262.114 117.173 261.767 117.247 261.476C117.308 261.233 117.375 260.971 117.447 260.69C117.518 260.414 117.601 260.093 117.676 259.804C117.74 259.556 117.808 259.296 117.879 259.025C118.014 258.509 118.197 257.811 118.321 257.345C118.893 255.181 119.511 252.887 120.086 250.779C121.276 246.409 122.512 241.962 123.733 237.637C126.196 228.916 128.74 220.178 131.352 211.492C137.393 191.522 143.687 171.605 151.247 151.991C153.299 146.725 155.448 141.496 157.895 136.297C160.224 131.365 162.511 126.372 164.909 121.386C171.21 108.253 178.505 94.9351 189.119 84.0355C189.379 83.7682 189.641 83.5171 189.921 83.2778C190.061 83.1582 190.205 83.0415 190.357 82.9275C190.525 82.8002 190.798 82.6105 191.056 82.4619C191.63 82.1808 192.065 81.7845 193.712 81.728C195.243 81.6636 196.984 82.8845 197.519 83.9109C198.007 84.723 198.14 85.2859 198.265 85.8611C198.352 86.2997 198.39 86.6569 198.415 87.0407C198.461 87.8466 198.442 88.2783 198.409 88.9277C198.264 91.153 197.926 93.0051 197.552 94.9727C196.812 98.745 195.899 102.419 194.95 106.065C193.037 113.361 190.947 120.511 188.809 127.675C185.274 139.774 181.712 151.366 178.49 162.372C177.322 166.377 176.158 170.296 175.023 174.128C168.942 194.412 164.061 212.398 161.624 227.462C159.895 237.791 158.859 248.589 158.85 259.456C158.85 259.566 158.85 259.653 158.85 259.712C158.85 259.73 158.85 259.809 158.85 259.778C158.85 259.771 158.849 259.759 158.848 259.733C158.848 259.727 158.848 259.719 158.848 259.711C158.842 259.697 158.868 259.789 158.808 259.268C158.796 259.187 158.782 259.085 158.744 258.911C158.698 258.727 158.671 258.508 158.417 257.937C158.273 257.646 158.096 257.24 157.512 256.623C156.982 256.045 155.593 255.08 153.828 255.213C152.081 255.346 151.083 256.271 150.634 256.764C150.163 257.3 150.005 257.645 149.878 257.901C149.649 258.4 149.613 258.603 149.566 258.772C149.526 258.932 149.509 259.028 149.496 259.104C149.47 259.253 149.463 259.322 149.456 259.378C149.434 259.599 149.444 259.507 149.442 259.529C149.442 259.531 149.441 259.533 149.441 259.535C149.44 259.552 149.439 259.563 149.439 259.572C149.437 259.607 149.437 259.605 149.437 259.596C149.443 259.484 149.452 259.265 149.458 259.105C149.474 258.733 149.49 258.37 149.506 258.017C149.54 257.289 149.578 256.556 149.62 255.833C149.704 254.38 149.804 252.927 149.919 251.474C150.152 248.56 150.446 245.672 150.823 242.778C151.603 236.984 152.582 231.234 154.585 225.438C159.993 210.17 165.388 195.697 170.677 183.193C172.725 178.378 174.752 173.841 176.929 169.66C177.721 168.123 178.551 166.588 179.548 165.022C181.314 162.155 183.121 157.845 185.716 154.067C186.14 153.439 186.873 152.628 188.006 152.118C189.134 151.593 190.431 151.572 191.294 151.762C193.047 152.172 193.781 152.863 194.451 153.414C195.706 154.56 196.402 155.637 197.03 156.875C204.201 172.66 210.957 191.262 222.693 198.365C223.686 198.843 224.546 199.041 225.404 198.995C226.597 198.944 228.055 198.265 229.554 196.874C237.029 189.41 241.606 174.284 243.01 156.951C243.538 147.258 241.951 136.063 238.463 123.962C238.337 123.529 238.22 123.161 238.117 122.865C238.06 122.701 237.962 122.439 237.896 122.288C237.837 122.144 237.76 122.016 237.816 122.105C237.858 122.163 237.946 122.31 238.232 122.559C238.483 122.77 238.99 123.137 239.809 123.265C240.612 123.424 241.657 123.088 242.035 122.819C242.973 122.203 243.093 121.698 243.155 121.616C243.202 121.513 243.207 121.485 243.201 121.505C243.09 121.839 242.95 123.131 242.908 124.12C242.803 126.268 242.84 128.68 242.928 131.001C243.117 135.792 243.537 140.741 244.167 145.915C245.566 156.021 247.081 167.953 252.374 177.381C253.235 178.742 254.212 179.65 254.751 179.863C258.189 181.413 262.262 178.813 265.057 176.641C267.935 174.356 270.084 172.084 271.982 169.998C273.242 168.601 274.416 167.21 275.549 165.8C279.474 160.905 283.047 155.299 287.259 148.548C289.35 145.217 291.566 141.588 294.277 137.687C295.714 135.689 297.042 133.705 299.384 131.521C299.705 131.237 299.985 131.003 300.385 130.717C300.824 130.405 301.296 130.12 301.85 129.885C302.476 129.619 303.417 129.357 304.457 129.481C305.57 129.558 306.855 130.381 307.319 130.937C309.415 133.695 309.048 134.929 309.364 136.761C309.68 140.313 309.845 143.914 309.955 147.844C310.712 200.295 307.015 223.296 303.761 240.639C302.707 245.714 301.528 250.333 299.982 254.927C297.703 261.493 294.446 269.595 287.992 276.24C281.688 283.407 269.838 285.329 261.919 281.91C259.297 281.009 257.184 279.072 255.935 277.1C247.766 262.147 256.406 235.746 263.937 217.249C266.937 210.231 271.396 200.84 278.526 190.791C281.629 186.499 285.2 182.054 289.951 178.042C294.557 174.262 301.312 169.882 309.3 172.285C311.94 173.123 314.478 174.238 316.89 175.678C335.398 187.982 336.134 206.642 337.337 218.31C338.002 230.707 336.887 240.154 335.655 248.467C334.92 253.204 334.056 257.592 333.037 261.948C331.698 267.588 330.022 273.778 327.48 280.183C323.789 289.108 319.366 298.333 314.04 307.356C311.426 311.72 308.619 316.034 305.147 320.013C303.378 321.998 301.5 323.913 298.94 325.515C296.582 327.076 292.292 328.351 288.843 326.271C282.495 322.551 281.349 315.632 280.972 310.656C280.658 305.589 281.223 300.7 281.879 296.489C290.541 254.599 309.562 217.116 326.715 179.13C335.736 159.738 344.811 141.165 351.093 127.565C357.624 113.793 360.059 105.682 360.273 105.932C360.991 105.774 359.334 114.469 353.527 128.609C347.958 142.603 339.463 161.471 330.698 180.952C313.6 220.304 293.9 259.743 287.231 301.612C286.463 309.088 286.724 318.119 291.866 320.923C293.499 322.282 297.79 319.183 300.617 315.712C303.63 312.175 306.241 308.12 308.689 303.953C313.536 295.602 317.802 286.673 321.438 277.75C329.402 255.398 333.406 230.053 329.083 206.873C326.606 194.095 319.346 182.203 307.245 178.741C299.374 176.406 290.16 186.312 284.097 194.881C277.735 203.93 272.633 214.085 268.48 224.508C267.12 227.942 265.868 231.428 264.744 234.951C262.361 242.677 260.496 250.736 259.929 258.315C259.2 265.764 260.807 274.234 264.354 274.822C275.332 278.946 283.24 271.467 287.503 263.387C295.093 248.609 296.925 235.371 298.837 224.686C300.018 217.216 300.769 210.516 301.291 203.728C301.568 200.077 301.885 195.069 302.114 189.05C302.589 175.827 302.83 157.105 301.247 137.536C301.2 137.055 301.14 136.671 301.084 136.4C301.031 136.123 300.932 135.868 300.976 135.984C301.002 136.038 301.103 136.253 301.381 136.55C301.582 136.793 302.317 137.354 303.064 137.516C303.852 137.703 304.387 137.604 304.727 137.517C305.078 137.413 305.11 137.371 305.143 137.358C305.122 137.346 304.412 137.952 303.852 138.596C303.25 139.266 302.603 140.079 302.013 140.859C299.536 144.152 297.081 147.959 294.621 151.707C289.682 159.245 284.667 166.993 278.711 174.156C275.912 177.474 272.824 180.879 268.776 183.906C264.921 186.765 258.476 190.267 251.584 187.323C243.859 182.765 243.369 177.168 241.361 172.204C239.761 167.164 238.696 162.106 237.837 157.125C236.575 149.683 235.803 142.396 235.397 135.361C235.203 131.842 235.093 128.4 235.2 124.992C235.32 123.092 235.186 121.831 235.981 119.02C236.052 118.817 236.135 118.605 236.245 118.373C236.36 118.131 236.644 117.566 237.152 117.037C237.69 116.513 238.458 115.788 240.152 115.676C241.709 115.608 242.875 116.463 243.254 116.817C243.874 117.383 244.154 117.847 244.409 118.281C244.474 118.395 244.524 118.489 244.552 118.544C244.586 118.609 244.618 118.673 244.649 118.737C244.712 118.865 244.771 118.993 244.828 119.121C244.942 119.379 245.047 119.642 245.149 119.916C245.241 120.165 245.294 120.321 245.365 120.532C245.5 120.937 245.632 121.368 245.765 121.832C248.62 131.849 249.926 140.584 250.443 146.684C250.741 150.137 250.862 153.709 250.679 157.372C249.287 172.73 247.041 189.25 235.217 202.685C233.002 204.839 229.954 206.857 226.223 207.231C222.494 207.622 219.126 206.229 216.659 204.613C198.395 188.753 194.756 169.713 189.585 160.525C189.484 160.334 189.36 160.144 189.24 159.988C189.063 159.739 188.772 159.537 188.971 159.694C189.09 159.749 189.416 160.04 190.419 160C190.902 159.972 191.491 159.77 191.887 159.498C192.291 159.228 192.514 158.952 192.641 158.771C190.52 161.933 189.213 165.324 186.65 169.579C183.337 174.978 180.307 181.984 176.818 190.323C172.796 200.056 168.198 212.064 162.52 228.205C162.179 229.173 161.858 230.218 161.568 231.28C160.13 236.619 159.381 241.88 158.816 246.762C158.54 249.201 158.324 251.578 158.153 253.856C158.069 254.984 157.993 256.128 157.929 257.226C157.897 257.779 157.867 258.333 157.84 258.867C157.833 259.013 157.827 259.137 157.82 259.267C157.813 259.426 157.807 259.54 157.801 259.682C157.797 259.763 157.793 259.834 157.79 259.896C157.789 259.913 157.785 259.994 157.782 260.045C157.781 260.074 157.779 260.104 157.776 260.148C157.775 260.16 157.774 260.172 157.773 260.187C157.774 260.171 157.769 260.231 157.764 260.278C157.757 260.338 157.756 260.393 157.714 260.614C157.682 260.743 157.687 260.862 157.48 261.368C157.333 261.629 157.273 262.049 156.334 262.823C155.867 263.19 154.963 263.619 153.937 263.553C152.913 263.501 152.122 263.007 151.714 262.634C150.9 261.848 150.856 261.459 150.731 261.202C150.636 260.948 150.607 260.81 150.582 260.701C150.537 260.492 150.529 260.404 150.52 260.33C150.494 260.088 150.498 260.022 150.498 260.044C150.498 260.042 150.497 260.041 150.497 260.039C150.497 260.032 150.497 260.026 150.497 260.02C150.496 259.996 150.496 259.977 150.495 259.96C150.493 259.832 150.494 259.74 150.494 259.685C150.495 259.619 150.495 259.544 150.496 259.456C150.558 251.848 151.072 245.18 151.788 239.054C154.105 220.386 157.661 206.693 163.197 186.628C165.672 177.757 168.357 168.809 170.898 160.086C174.778 146.862 178.724 134.191 182.014 123.31C184.489 115.068 187.302 105.626 189.492 95.8125C189.955 93.6619 190.376 91.5236 190.603 89.5217C190.722 88.6112 190.72 87.3797 190.687 87.3851C190.694 87.4158 190.714 87.5065 190.787 87.6747C190.829 87.7675 190.856 87.8324 190.965 88.0095C191.075 88.1827 191.234 88.3931 191.465 88.6063C191.914 89.0438 192.722 89.4089 193.379 89.4468C194.032 89.507 194.556 89.3204 194.664 89.2762C195.032 89.1233 195.023 89.0803 194.977 89.1265C194.929 89.165 194.817 89.2642 194.667 89.4191C188.472 95.7839 183.353 103.226 179.071 110.621C173.821 119.733 169.995 127.727 166.45 134.762C165.68 136.304 164.93 137.802 164.192 139.267C163.896 139.854 163.601 140.45 163.307 141.054C161.311 145.437 159.445 150.006 157.704 154.498C156.387 157.898 155.125 161.3 153.888 164.741C153.445 166.083 153.015 167.418 152.548 168.875C150.23 176.129 147.509 185.093 144.156 196.197C138.869 213.765 134.24 229.226 129.56 245.603C128.636 248.847 127.698 252.18 126.771 255.547C126.322 257.178 125.859 258.88 125.389 260.644C125.271 261.086 125.173 261.453 125.058 261.89C124.932 262.372 124.818 262.808 124.719 263.192C124.677 263.354 124.604 263.641 124.548 263.861C124.491 264.088 124.441 264.286 124.4 264.455C124.352 264.646 124.279 264.963 124.269 265.008C124.268 265.013 124.266 265.025 124.268 265.012C124.27 265 124.275 264.975 124.285 264.9C124.291 264.804 124.326 264.758 124.306 264.24C124.296 264.097 124.284 263.915 124.205 263.593C124.107 263.278 124.022 262.768 123.32 261.995C122.685 261.172 120.779 260.632 119.782 261.024C118.761 261.339 118.422 261.75 118.174 261.979C117.731 262.459 117.683 262.626 117.597 262.766C117.526 262.898 117.496 262.968 117.472 263.022C117.386 263.229 117.409 263.185 117.403 263.198C117.408 263.189 117.443 263.082 117.489 262.929C119.504 256.401 121.415 249.5 123.065 242.075C125.345 231.693 127.373 219.649 127.195 207.961C127.061 199.317 125.367 190.318 120.653 185.856C116.875 181.68 111.133 185.423 106.984 189.169C103.81 192.058 101.257 194.911 98.8014 197.854C98.7904 197.867 98.7794 197.88 98.7684 197.893C98.6024 198.093 98.4362 198.296 98.2708 198.499C91.3724 207.811 85.5675 218.151 80.2318 228.654C73.5031 243.523 68.1395 265.155 74.5143 277.302C74.8899 277.738 75.2801 278.053 75.6853 278.271C76.623 278.784 77.484 278.994 78.3787 278.973C81.9875 278.969 86.5574 274.388 89.463 270.188C92.4989 265.875 94.6609 261.436 96.0881 257.918C96.9245 255.81 98.268 252.463 98.8768 249.11C100.555 238.804 101.641 222.753 100.732 206.537C99.929 192.593 97.3272 176.546 90.8702 169.872C91.7077 170.865 93.842 171.746 95.3695 171.488C96.0964 171.418 96.8158 171.131 97.0289 171.025C97.2837 170.907 97.4892 170.788 97.6599 170.678C98.3272 170.232 98.5325 169.947 98.6424 169.83C98.7891 169.655 98.7769 169.655 98.7307 169.739C96.2007 174.889 93.5053 182.437 90.9729 189.07C88.5836 195.458 86.1898 202.08 83.7737 209.393C82.5597 213.064 81.3036 217.025 79.9207 221.293C79.0316 223.984 78.2629 226.527 77.0051 229.759C76.8599 230.158 76.4457 231.573 76.1159 232.763C75.0549 236.504 72.6585 245.275 69.0679 256.366C66.8328 263.219 64.1484 270.978 60.723 279.019C57.8469 285.823 54.793 292.608 49.8376 299.092C47.2474 302.223 44.3486 305.776 38.5737 307.359C32.4444 308.976 26.7321 305.055 24.031 301.895C17.9599 295.223 13.8801 287.316 10.9185 279.326C9.09679 274.722 7.81203 270.659 6.79711 267.451C6.07246 265.149 5.45606 263.186 4.85878 261.161C4.05147 258.406 3.2712 255.537 2.49887 251.544C1.89311 248.423 1.42286 244.722 1.26793 242.229C1.19427 241.069 1.18164 240.17 1.17328 239.364C1.16379 238.437 1.15856 237.603 1.08672 236.604C1.03493 235.882 0.938168 235.123 0.825987 234.204C0.647521 232.732 0.421447 230.806 0.297782 227.889C0.168381 224.818 0.0819869 221.63 0.0319948 218.378C-0.0972848 210.037 0.150114 201.103 1.13641 192.256C2.58715 178.534 6.25328 165.041 11.1151 154.978C14.9211 146.785 21.7106 136.618 31.1339 128.231C34.9338 124.822 39.4249 121.698 44.9603 119.814C55.0929 115.456 69.0814 121.48 73.7833 129.48C76.6527 133.574 77.3103 137.406 77.7624 140.707C78.8944 152.314 76.4779 162.586 73.6492 172.482C70.1107 184.265 65.1713 195.039 59.487 203.599C58.3311 205.33 56.7411 207.369 54.5305 209.822C52.9656 211.548 51.0731 213.507 48.7159 215.577C43.0354 221.229 33.1081 227.876 22.2347 223.737C17.0255 221.848 11.6325 217.815 8.87131 212.304C8.58642 211.812 8.30783 211.285 8.05609 210.767C8.05193 210.759 8.04775 210.75 8.04358 210.742C2.26141 198.341 5.7474 182.045 14.7741 164.435C17.1278 159.918 18.876 157.251 20.4495 154.869C22.0099 152.527 23.4318 150.458 25.3844 147.397C27.6161 143.906 30.2081 139.752 33.2131 135.343C36.2352 130.957 39.4911 126.313 43.8709 121.633C45.4902 119.944 47.1997 118.217 48.9111 116.558C49.3161 116.165 49.7593 115.736 50.2136 115.298C54.514 111.141 60.9587 105.088 67.6774 99.3667C86.8308 81.6524 107.003 64.9517 128.793 50.3115C141.795 41.6373 155.397 33.6404 170.061 27.5467C195.718 17.0152 221.977 6.49731 250.054 1.95437C271.272 -1.62131 292.305 0.10056 306.893 3.96811C321.542 7.8002 328.936 12.0696 328.601 13.0674C328.182 14.2302 320.083 12.1045 305.699 10.107C291.323 8.07192 271.693 7.54295 251.591 11.1821C224.984 15.8193 199.483 26.3301 174.086 37.1325C168.334 39.5921 162.687 42.4316 157.148 45.5111C155.631 46.3707 154.098 47.2625 152.602 48.153C141.403 54.8355 131.526 62.0032 121.931 69.528C119.732 71.2565 117.538 73.0162 115.356 74.7964Z",
  "M335.507 179.774C330.522 175.396 324.298 164.95 321.62 159.027C321.568 158.92 321.517 158.813 321.466 158.706C320.81 157.32 320.18 155.967 319.488 154.415C317.869 150.671 315.568 145.643 312.364 134.65C311.371 131.479 310.462 128.271 309.646 125.026C308.799 121.659 308.042 118.206 307.424 114.8C305.519 94.6916 306.197 74.6339 321.891 57.3546C325.949 53.3992 333.213 53.7639 336.838 55.7339C340.831 57.5881 343.679 60.1086 346.257 62.6634C351.356 67.8564 355.237 73.589 358.64 79.5803C358.877 79.9821 359.115 80.3926 359.353 80.8091C362.705 86.6554 366.011 93.9174 367.717 100.586C368.316 102.911 368.813 105.074 369.192 106.951C370.953 115.739 371.549 121.843 371.886 126.848C373.16 140.643 372.339 154.748 369.146 168.267C365.326 184.178 353.84 195.19 344.968 205.911C344.387 206.618 343.815 207.329 343.269 208.033C340.486 211.619 337.958 215.467 335.589 219.45C334.076 221.994 332.63 224.592 331.224 227.228C328.301 232.709 325.553 238.341 322.785 244.007C322.029 245.554 321.277 247.102 320.538 248.647C318.628 252.877 316.921 256.916 315.451 260.683C314.086 264.177 312.925 267.434 311.956 270.37C311.49 271.787 311.018 273.31 310.63 274.599C307.746 284.122 305.168 295.297 303.64 303.683C303.39 305.039 303.164 306.33 302.964 307.535C302.041 314.23 301.387 320.949 301.054 327.667C300.981 328.113 300.907 328.562 300.834 329.019C299.967 334.72 299.599 341.831 300.622 352.823C301.115 357.585 301.895 363.1 303.687 369.23C304.873 373.175 305.557 375.156 306.104 376.759C306.274 377.238 306.444 377.689 306.629 378.131C307.258 379.63 308.279 381.068 309.571 382.546C311.3 384.495 313.425 386.595 316.566 388.932C317.232 389.421 317.906 389.854 318.584 390.239C321.247 392.338 324.153 387.778 325.342 385.017C326.659 382.022 327.217 379.575 327.684 377.506C327.966 376.211 328.213 374.964 328.473 373.77C329.357 369.801 330.71 364.103 331.685 359.734C332.484 356.277 333.339 349.239 333.76 343.864C333.926 341.833 334.245 339.095 334.584 335.863C334.936 332.519 335.309 328.639 335.58 324.483C336.251 313.996 336.487 308.355 336.695 303.864C336.751 302.587 336.802 301.4 336.852 300.19C336.939 298.061 337.05 295.407 337.153 292.831L337.151 292.957C337.155 291.087 337.158 289.113 337.15 287.159C337.132 281.508 336.97 275.793 336.676 271.477C336.205 260.276 334.935 249.057 331.421 238.574C329.625 233.191 327.33 228.281 325.295 224.806C323.276 221.326 321.881 219.451 322.225 219.11C322.529 218.797 324.608 220.053 327.441 223.254C330.277 226.443 333.368 231.447 335.533 237.068C339.907 248.389 341.745 260.404 342.727 272.29C343.285 279.183 343.495 286.13 343.618 292.957L343.616 293.079C343.47 300.615 343.232 308.187 342.856 315.728C342.35 325.826 341.636 335.916 340.54 346.013C340.427 347.055 340.31 348.082 340.187 349.128C339.461 357.647 338.358 366.162 337.131 372.185C336.129 377.157 334.974 380.764 333.789 383.811C332.937 385.986 332.089 387.852 331.096 389.765C330.515 390.853 329.751 392.29 328.332 394.004C327.256 395.25 325.84 396.728 323.363 397.717C320.823 398.774 317.487 398.46 315.125 397.245C308.376 394.193 302.372 387.412 299.214 380.486C296.972 375.809 295.372 370.148 294.423 364.774C293.041 357.059 292.848 349.935 292.551 346.352C292.024 340.055 292.228 332.834 292.714 326.516C293.166 320.486 293.836 315.245 293.992 312.251C294.185 308.652 294.685 305.631 295.55 301.169C296.156 298.083 296.941 294.279 298.079 289.169C299.407 283.252 300.671 279.102 301.816 275.609C302.743 272.805 303.643 270.284 304.557 267.73C305.23 265.854 305.926 263.885 306.717 261.597C308.812 255.521 311.455 249.377 313.816 244.72C314.461 243.446 315.149 242.053 315.858 240.603C316.329 239.64 316.811 238.646 317.303 237.635C318.931 234.283 320.665 230.747 322.418 227.588C323.862 224.985 325.234 222.92 326.472 221.107C326.858 220.542 327.231 220.001 327.59 219.475C328.256 218.286 328.934 217.103 329.628 215.923C330.146 215.043 330.673 214.166 331.209 213.295C331.38 212.944 331.56 212.576 331.75 212.192C332.706 210.265 333.922 207.898 335.762 205.148C336.193 204.506 336.631 203.882 337.073 203.278C339.648 199.78 342.276 196.983 344.923 194.051C347.338 191.378 349.816 188.615 352.26 185.226C353.924 182.917 355.633 180.193 357.045 177.413C359.081 173.467 360.393 169.411 361.099 166.472C361.135 166.327 361.171 166.184 361.206 166.044C361.504 164.848 361.861 163.84 362.203 162.836C362.205 162.832 362.207 162.827 362.209 162.823C362.232 162.755 362.255 162.687 362.278 162.618C363.668 154.709 364.213 146.674 363.964 138.654C363.916 137.959 363.863 137.257 363.805 136.563C363.527 133.169 363.097 129.884 362.645 127.768C362.169 125.473 361.343 119.672 359.996 113.617C359.213 110.042 358.276 106.374 357.365 103.272C357.275 102.967 357.182 102.665 357.086 102.366C356.513 100.579 356.086 98.8204 355.569 97.001C355.082 95.2944 354.525 93.566 353.667 91.7493C353.242 90.8498 352.724 89.8876 352.156 88.8839C351.655 87.9958 351.112 87.068 350.546 86.0938C350.02 85.1897 348.973 83.1065 347.458 80.5339C346.52 78.9402 345.413 77.1785 344.148 75.3944C340.695 70.926 336.45 66.4962 332.437 64.7996C331.596 64.5645 330.955 64.5837 330.58 64.7341C330.301 64.8409 330.137 65.0108 330.023 65.1882C329.87 65.4332 329.847 65.6815 329.795 65.9057C329.761 66.0313 329.697 66.1338 329.569 66.2443C329.442 66.3534 329.318 66.4521 329.2 66.5319C329.024 66.6517 328.865 66.7278 328.72 66.8006C328.556 66.8819 328.409 66.9584 328.274 67.1001C328.177 67.2025 328.103 67.337 328.014 67.505C327.871 67.7747 327.698 68.1128 327.321 68.5892C325.937 70.3295 324.489 72.7559 323.309 75.3539C321.981 78.2527 320.964 81.3277 320.314 83.8437C319.576 86.6526 318.556 90.7375 317.882 94.924C317.403 97.8441 317.079 100.799 316.959 103.316C316.839 105.789 316.943 108.371 317.214 110.725C317.309 111.561 317.425 112.359 317.554 113.094C317.909 115.129 318.29 117.175 318.549 118.92C318.624 119.425 318.614 120.077 318.613 120.905C318.614 121.5 318.612 122.15 318.65 122.905C319.351 126.075 320.136 129.229 320.997 132.349C321.044 132.455 321.093 132.563 321.143 132.672C321.144 132.673 321.145 132.675 321.146 132.677C322.274 135.134 323.8 138.445 325.165 143.37C325.518 144.627 325.657 145.447 325.786 146.186C325.913 146.912 326.028 147.554 326.351 148.454C326.716 149.472 327.261 150.618 327.868 151.851C328.738 153.617 329.706 155.496 330.533 157.528C330.588 157.665 330.648 157.812 330.711 157.965C331.295 159.393 332.24 161.566 333.125 163.67C336.405 169.633 340.275 175.443 345.29 179.184C353.916 186.779 364.284 177.389 369.417 167.559C372.178 162.727 374.49 157.801 376.278 154.101C377.993 150.589 379.157 148.35 379.588 148.507C380.018 148.632 379.701 151.148 378.726 155.003C377.669 159.044 375.917 164.362 373.261 169.63C369.016 177.538 362.675 188.894 349.795 187.559C349.193 187.478 348.592 187.362 348 187.215C343.64 186.086 340.362 183.866 337.455 181.495C336.793 180.948 336.104 180.331 335.507 179.774Z",
  "M32.6911 275.414C32.2745 282.712 31.8984 296.835 32.1265 304.648C32.1294 304.791 32.1324 304.935 32.1354 305.078C32.1734 306.931 32.2351 308.685 32.3237 310.739C32.546 315.649 32.8678 322.246 33.8377 336.156C34.2032 340.186 34.589 344.25 34.9688 348.289C36.4674 379.383 46.497 415.302 22.2167 445.191C18.8127 448.828 13.7573 449.145 11.1064 449.075C9.47159 449.206 6.8467 447.921 5.95874 446.41C5.44017 445.666 5.15705 444.936 4.98615 444.302C4.8329 443.706 4.79929 443.407 4.75784 443.006C4.64717 441.38 4.81355 440.698 4.96152 439.777C5.26091 438.205 5.67299 436.902 6.08431 435.67C6.91739 433.221 7.86447 430.936 8.8193 428.726C10.7478 424.292 12.8077 420.021 14.9019 415.777C15.1409 415.273 15.3865 414.757 15.6374 414.232C20.439 404.177 26.5968 391.976 30.6083 384.385C35.716 374.745 39.1238 368.251 41.6857 362.881C42.9538 360.057 44.3902 356.644 44.7807 354.692C50.6825 325.685 13.4728 302.616 19.7307 265.662C19.9005 264.816 20.0965 263.964 20.3196 263.109C22.6075 254.972 29.1067 250.365 35.1221 247.216C38.8346 245.33 42.7034 243.959 46.6737 242.987C54.935 241.318 63.7389 239.517 73.0445 245.191C75.1262 246.722 76.9305 248.592 78.398 250.643C82.4999 256.264 84.0243 262.452 84.8895 267.93C86.0227 275.655 85.8005 282.418 85.4456 287.905C84.5368 301.15 81.4764 315.594 80.0235 326.101C79.7866 327.801 79.5883 329.415 79.4429 330.895C79.3016 332.773 79.2163 334.726 79.2664 336.468C79.4398 342.758 80.3236 349.001 81.9759 355.013C82.0709 355.551 82.1707 356.091 82.2779 356.638C83.6953 363.419 86.6742 371.828 95.0866 382.56C98.7837 387.193 103.599 392.193 110.05 397.193C114.224 400.393 116.428 401.985 118.22 403.316C118.751 403.704 119.254 404.063 119.768 404.412C121.538 405.609 123.587 406.568 126.037 407.604C129.22 408.94 133.062 410.426 138.1 412.538C153.268 418.636 161.398 418.842 167.021 419.252C167.416 419.271 167.801 419.288 168.178 419.302C169.884 419.369 171.434 419.4 173.012 419.452C178.133 419.653 185.436 419.859 190.987 419.701C195.39 419.65 204.142 418.45 210.623 416.851C213.077 416.267 216.406 415.524 220.28 414.463C224.29 413.367 228.888 411.92 233.674 410.021C245.74 405.144 251.679 401.531 256.446 398.714C257.799 397.893 259.045 397.109 260.278 396.308C264.179 393.78 268.893 390.446 273.403 386.743C278.817 382.331 283.897 377.37 287.488 373.358C291.117 369.49 294.508 365.395 297.619 361.089C302.786 353.912 307.83 346.72 312.084 339.114C315.629 332.829 318.496 326.557 320.217 321.763C321.957 316.976 322.644 314.134 323.126 314.197C323.559 314.244 323.776 317.25 322.77 322.468C321.779 327.68 319.376 334.543 315.948 341.176C311.837 349.198 306.952 356.737 302.031 364.139C298.668 369.178 294.943 373.975 290.907 378.497C278.635 392.247 263.53 403.424 246.954 411.538C235.354 417.214 223.028 421.428 210.35 424.032C209.045 424.3 207.735 424.551 206.423 424.784C195.762 426.986 184.826 427.797 177.12 427.692C172.782 427.65 169.246 427.351 166.196 426.983C164.77 426.811 163.447 426.62 162.195 426.422C159.489 425.994 157.11 425.539 154.699 425.099C153.404 424.862 151.636 424.526 149.517 424.06C140.867 422.254 126.287 417.643 114.512 410.221C109.273 407 103.54 402.65 98.6177 397.9C91.5031 391.156 86.3036 383.576 83.7812 379.734C79.2252 373.029 75.5409 364.326 73.6466 356.335C71.7743 348.719 71.3477 341.874 71.005 338.041C70.9628 337.574 70.9277 337.111 70.8991 336.65C70.6722 332.413 71.1249 328.688 71.8806 323.604C72.4718 319.685 73.3206 314.94 74.3352 308.539C75.5037 301.158 76.3425 295.992 76.9293 291.591C77.7195 285.421 78.2301 280.7 77.6667 273.896C77.047 266.348 74.9873 258.862 71.7054 254.643C70.8437 253.478 69.7661 252.361 68.455 251.396C67.7872 250.902 66.8646 250.456 65.7923 250.115C62.2549 248.992 57.6025 249.024 53.5205 249.456C50.1218 249.819 47.2895 250.305 44.811 250.883C44.0395 251.064 43.299 251.258 42.5933 251.467C41.1107 252.031 39.6728 252.664 38.2766 253.381C37.2405 253.914 36.2315 254.492 35.2644 255.117C34.9227 255.382 34.564 255.674 34.2047 255.982C32.4244 257.526 30.3537 259.612 28.9247 262.35C28.4546 263.263 28.1175 264.168 27.9067 265.057C26.8958 269.268 26.4817 273.251 26.7346 277.452C26.9908 281.596 27.9282 285.955 29.8322 290.76C31.1256 294.041 32.9659 297.682 34.9664 301.256C37.9386 306.561 41.1754 311.795 43.1596 315.649C43.9072 317.088 44.4358 318.396 44.9441 319.699C44.9461 319.705 44.9481 319.711 44.9502 319.716C44.9847 319.805 45.0196 319.894 45.054 319.983C49.9872 329.275 54.3261 340.016 53.709 351.527C53.6859 352.526 53.6293 353.507 53.5381 354.494C53.4885 355.031 53.4286 355.568 53.3589 356.104C52.4763 360.969 50.9579 364.178 50.1814 366.632C49.1767 369.61 46.0014 376.626 42.4802 383.894C40.1916 388.643 37.7947 393.515 35.8862 397.517C34.7685 399.859 33.5162 401.967 32.2271 404.146C31.0284 406.172 29.7917 408.271 28.6331 410.618C28.0421 411.815 27.4501 413.109 26.8256 414.483C26.2618 415.72 25.6865 416.993 25.0601 418.328C24.468 419.593 23.0358 422.284 21.2712 425.758C20.1858 427.899 18.9834 430.314 17.7949 432.917C16.9359 434.97 16.1259 437.011 15.4861 438.973C15.1812 439.911 14.8982 440.921 14.7792 441.634C14.7474 441.821 14.7307 441.967 14.7246 442.055C14.7164 442.142 14.7282 442.203 14.7165 442.054C14.705 441.968 14.7079 441.917 14.6363 441.654C14.5636 441.403 14.4222 441.03 14.1161 440.609C13.5969 439.726 11.8919 438.964 11.1384 439.059C13.5911 439.088 14.5185 438.716 14.9689 438.211C15.293 437.872 15.6094 437.527 15.9182 437.176C16.7743 436.049 17.4042 434.991 17.8115 434.102C18.1037 433.464 18.2967 432.887 18.4824 432.292C18.7354 431.479 18.9696 430.649 19.3622 429.549C19.669 428.692 20.103 427.694 20.4606 427.07C20.628 426.779 20.7835 426.565 20.9238 426.369C21.0844 426.145 21.2266 425.941 21.3414 425.667C21.4241 425.469 21.474 425.247 21.5338 424.974C21.6276 424.541 21.7555 423.956 22.0467 423.144C23.1414 420.11 24.1459 416.397 24.8421 412.701C25.6381 408.522 26.0846 404.366 26.2891 400.991C26.529 397.212 26.8355 391.787 26.9029 386.25C26.957 382.394 26.9196 378.541 26.8076 375.168C26.7027 371.939 26.4389 368.483 26.1696 365.202C25.8412 361.198 25.507 357.415 25.3924 354.132C25.3696 353.474 25.449 352.647 25.5458 351.604C25.6144 350.865 25.6915 350.012 25.7487 349.041C25.4554 344.896 25.1677 340.712 24.9107 336.543C24.8836 336.397 24.856 336.246 24.828 336.095C24.8275 336.093 24.8269 336.091 24.8263 336.088C24.1959 332.685 23.3599 328.019 23.4151 321.367C23.4295 319.672 23.5436 318.607 23.6461 317.644C23.7473 316.699 23.8383 315.854 23.8281 314.623C23.8168 313.224 23.6963 311.577 23.5812 309.78C23.4187 307.257 23.2698 304.427 23.4172 301.587C23.4272 301.393 23.4383 301.184 23.4497 300.967C23.5566 298.909 23.7414 295.858 24.1075 292.834C24.5036 283.843 25.3543 274.843 26.8978 265.939C28.4026 257.259 30.5739 248.668 33.6178 240.374C35.7283 234.635 37.7934 228.697 40.847 223.094C44.288 216.478 50.0961 211.052 55.3633 209.564C60.5844 207.998 63.5585 208.871 63.5571 209.229C63.581 209.754 60.6225 209.881 56.3442 211.982C52.0355 214.024 47.6804 218.887 44.7154 225.119C42.1119 230.392 40.348 236.178 38.4743 242.047C36.8074 247.27 35.4956 252.605 34.4844 257.998C34.3809 258.592 34.2803 259.189 34.1829 259.785C33.4596 264.216 33.0754 268.378 32.8349 272.535C32.7797 273.492 32.7323 274.451 32.6911 275.414Z",
];

// Per-strand delay/duration (ms) — from the Figma Make prototype. The
// strokes overlap rather than running strictly one-after-another, which
// is what gives the reveal its organic, hand-sketched feel.
const HAIR_TIMING = [
  { delay: 0, duration: 1150 },
  { delay: 575, duration: 580 },
  { delay: 740, duration: 580 },
];

function AnimatedHair({ style, preserveAspectRatio }) {
  const svgRef = useRef(null);
  const [visible, setVisible] = useState(false);
  const reduced = typeof window !== "undefined" && window.matchMedia
    && window.matchMedia("(prefers-reduced-motion: reduce)").matches;

  // Draw once, the first time it scrolls into view.
  useEffect(() => {
    if (reduced || !svgRef.current) return;
    const el = svgRef.current;
    const obs = new IntersectionObserver((entries) => {
      entries.forEach((entry) => {
        if (!entry.isIntersecting) return;
        setVisible(true);
        obs.disconnect();
      });
    }, { threshold: 0.4 });
    obs.observe(el);
    return () => obs.disconnect();
  }, [reduced]);

  return (
    <svg
      ref={svgRef}
      viewBox="0 0 379.776 449.085"
      xmlns="http://www.w3.org/2000/svg"
      preserveAspectRatio={preserveAspectRatio}
      style={{ height: "0.75em", width: "auto", flexShrink: 0, overflow: "visible", ...style }}
    >
      <style>{`
        @keyframes hairDraw {
          0% { stroke-dashoffset: 1; opacity: 0.82; }
          55% { opacity: 0.95; }
          88% { stroke-dashoffset: 0.02; opacity: 1; animation-timing-function: ease-out; }
          94% { stroke-dashoffset: -0.012; }
          100% { stroke-dashoffset: 0; }
        }
      `}</style>
      <defs>
        {HAIR_PATHS.map((d, i) => (
          <mask key={i} id={`hair-draw-mask-${i}`} maskUnits="userSpaceOnUse" x="0" y="0" width="379.776" height="449.085">
            <path
              d={d}
              pathLength="1"
              style={{
                fill: "none",
                stroke: "#fff",
                strokeWidth: 36,
                strokeLinecap: "round",
                strokeLinejoin: "round",
                strokeDasharray: 1,
                strokeDashoffset: reduced ? 0 : 1,
                ...(reduced ? {} : {
                  animationName: "hairDraw",
                  animationDuration: `${HAIR_TIMING[i].duration}ms`,
                  animationDelay: `${HAIR_TIMING[i].delay}ms`,
                  animationTimingFunction: "cubic-bezier(0.76, 0, 0.24, 1)",
                  animationFillMode: "forwards",
                  animationPlayState: visible ? "running" : "paused",
                }),
              }}
            />
          </mask>
        ))}
      </defs>
      {HAIR_PATHS.map((d, i) => (
        <path key={i} d={d} fill="#E5E3DF" mask={`url(#hair-draw-mask-${i})`} />
      ))}
    </svg>
  );
}

function RollingLink({ href, children, style, onClick, as = "a", className, hover: hoverProp, target, rel, download }) {
  const [internalHover, setInternalHover] = useState(false);
  const hover = hoverProp !== undefined ? hoverProp : internalHover;
  const reduced = typeof window !== "undefined" && window.matchMedia
    && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
  const text = String(children);
  const Tag = as;
  const tagProps = as === "a"
    ? { href, onClick, target, rel, download, "aria-label": text }
    : { "aria-label": text };
  const hoverHandlers = hoverProp === undefined
    ? { onMouseEnter: () => setInternalHover(true), onMouseLeave: () => setInternalHover(false) }
    : {};

  return (
    <Tag
      {...tagProps}
      className={className}
      {...hoverHandlers}
      style={{ position: "relative", display: "inline-flex", cursor: "pointer", ...style }}
    >
      <span aria-hidden="true" style={{ display: "inline-flex" }}>
        {text.split("").map((ch, i) => (
          <span key={i} style={{
            position: "relative", display: "inline-block",
            height: "1em", lineHeight: "1em", overflow: reduced ? "visible" : "hidden"
          }}>
            {reduced ? (
              <span style={{ display: "block", opacity: hover ? 0.6 : 1, transition: "opacity 0.2s ease" }}>
                {ch === " " ? " " : ch}
              </span>
            ) : (
              <span style={{
                display: "block",
                transform: hover ? "translateY(1em)" : "translateY(0)",
                transition: "transform 0.55s cubic-bezier(0.43, 0.195, 0.02, 1)",
                transitionDelay: `${i * 0.025}s`
              }}>
                <span style={{ display: "block", height: "1em" }}>{ch === " " ? " " : ch}</span>
                <span style={{ display: "block", height: "1em", opacity: 0.6, position: "absolute", top: "-1em", left: 0 }}>
                  {ch === " " ? " " : ch}
                </span>
              </span>
            )}
          </span>
        ))}
      </span>
      <span aria-hidden="true" style={{
        position: "absolute", left: 0, right: 0, bottom: -4,
        height: 1, background: "currentColor",
        transformOrigin: "right",
        transform: hover ? "scaleX(0)" : "scaleX(1)",
        transition: "transform 0.22s ease"
      }} />
    </Tag>
  );
}

// ─────────────── DATA ───────────────
// Shared with HeroStacked's own carousel and the intro overlay's image
// flicker, so both stay in sync with whatever's in this folder.
// Costa deliberately sits last — both the intro's flicker/expand sequence
// (IntroOverlay) and HeroStacked's own carousel land on/start from this
// order, and the intro is specifically meant to end on Costa, not
// whichever happens to be the final entry here.
const DESKTOP_HERO_IMAGES = [
  "assets/hero/Desktop hp hero/Bupa.jpg",
  "assets/hero/Desktop hp hero/HSBC.jpg",
  "assets/hero/Desktop hp hero/NatWest.jpg",
  "assets/hero/Desktop hp hero/NatWestWGDLL.jpg",
  "assets/hero/Desktop hp hero/ArtFund.jpg",
  "assets/hero/Desktop hp hero/Costa.jpg",
];

const MOBILE_HERO_IMAGES = [
  "assets/hero/mobile/Bupa-Hero.jpg",
  "assets/hero/mobile/Costa.jpg",
  "assets/hero/mobile/HSBC-Hero.jpg",
  "assets/hero/mobile/NatWest-Hero.jpg",
  "assets/hero/mobile/NatWest-Hero-WGDLL.jpg",
  "assets/hero/mobile/Costa.jpg",
];

// Private site for NDA case studies (Bupa, later Goldman), behind
// Cloudflare Access — company email sign-in.
const PRIVATE_SITE = "https://work.elspethbelden.com";

const CASE_STUDIES = [
  {
    id: "goldman-ai",
    num: "01",
    year: "2026",
    client: "Goldman Sachs",
    title: "An AI companion for the trading floor",
    tagline: "A north star for an in-house proprietary AI tool, built on the design system I helped establish.",
    tags: ["AI / LLM", "Product Vision", "Design System"],
    role: "Experience Lead",
    duration: "6 months",
    locked: true,
    featured: true,
    imageLabel: "GS AI — product shot",
    imageTint: "goldman",
    thumbSrc: "assets/thumbnails/GS Thumb.png",
    bgImage: "assets/card-backgrounds/image.jpg"
  },
  {
    id: "natwest-ds",
    num: "02",
    year: "2024",
    client: "NatWest",
    title: "A design system built to survive a rebrand",
    tagline: "A 400% efficiency improvement by rebuilding the system, the governance, and the team around it.",
    tags: ["Design Systems", "Tokenisation", "Governance"],
    role: "Experience Lead",
    duration: "12 months",
    href: "natwest.html",
    thumbSrc: "assets/thumbnails/Pulse_logo loop.gif",
    thumbFit: "contain",
    thumbBg: "#3C1053",
    imageLabel: "NatWest DS — component grid",
    imageTint: "natwest",
    bgImage: "assets/card-backgrounds/Cover.webp"
  },
  {
    id: "bupa-north-star",
    num: "03",
    year: "2023",
    client: "Bupa",
    title: "A North Star vision for Bupa's app",
    tagline: "Unifying the customer experience across markets. The output unlocked £20m+ of follow-on work.",
    tags: ["Experience Strategy", "Service Design", "UX Design", "Research"],
    role: "Experience Lead",
    duration: "4 months",
    // NDA work lives on the private site (Cloudflare Pages + Access).
    href: PRIVATE_SITE + "/bupa.html",
    protected: true,
    imageLabel: "Bupa app — journey map",
    imageTint: "bupa",
    thumbSrc: "assets/thumbnails/Bupa-thumbnail.png",
    bgImage: "assets/hero/Bupa-hero.jpg"
  },
  {
    id: "costa-express",
    num: "04",
    year: "2019",
    client: "Costa Express",
    title: "A facelift for Costa's self-serve coffee machines",
    tagline: "UI redesign across two screen formats, aligned to the new Costa brand. One visual language, two very different canvases.",
    tags: ["Brand Refresh", "GUI Design", "Concept"],
    role: "Senior Designer",
    duration: "2 formats",
    href: "costa.html",
    imageLabel: "Costa Express — machine in-situ",
    imageTint: "costa",
    thumbSrc: "assets/thumbnails/Costa-thumb.png",
    bgImage: "assets/card-backgrounds/costa.jpg"
  },
  {
    id: "nord-anglia",
    num: "05",
    year: "2022",
    client: "Nord Anglia",
    title: "One digital identity for a global network of schools",
    tagline: "Delivering a component library for 76 international schools, designed in parallel with an evolving brand.",
    tags: ["UX / UI Design", "Component Library", "User Testing", "Brand Translation"],
    role: "Experience Designer",
    duration: "60+ modules",
    href: "nord-anglia.html",
    imageLabel: "Nord Anglia — school pages mockup",
    imageTint: "nordanglia",
    thumbSrc: "assets/thumbnails/Nord Thumbnail.webp",
    bgImage: "assets/hero/Nord Hero.jpg"
  }
];

const PAST_CLIENTS = [
  "ASOS", "HSBC", "Guinness Storehouse",
  "GovUK", "E.ON", "Art Fund", "Sainsbury's",
  "National Theatre", "Chelsea FC", "Topman", "Nord Anglia",
  "Diageo", "Freeview", "NowTV", "Bethesda"
];

// Whether the intro splash will actually play: an actual browser reload
// (not a fresh arrival, not back/forward — see IntroOverlay), reduced
// motion off, and GSAP loaded. A plain function, not a value read off
// `window.__introActive`, specifically so components that need the
// answer during their OWN first render (useState initializers, which run
// before any effect — including the one that sets that flag — has had a
// chance to fire) can call it directly instead of racing it. Several
// components key their *resting* state off this (not just whether to
// wait for an intro event), so getting it right on the very first render
// matters — otherwise they're stuck waiting forever for an intro event
// that was never going to fire.
// Portfolio 02: the intro is switched off for now (HeroWall replaces the
// old hero); remove this early return to bring it back.
const INTRO_ENABLED = false;
function willPlayIntro() {
  if (!INTRO_ENABLED) return false;
  const reduced = window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
  const navEntry = typeof performance !== "undefined" && performance.getEntriesByType
    ? performance.getEntriesByType('navigation')[0]
    : null;
  const isReload = !!navEntry && navEntry.type === 'reload';
  return isReload && !reduced && typeof window.gsap !== "undefined";
}

// `100vh` on mobile Safari/Chrome is the *largest* possible viewport —
// taller than what's actually visible while the address bar is showing —
// so full-bleed sections sized in vh (hero, case-study cards, footer) run
// taller than the screen, pushing the real bottom of the page further
// down than it looks like it should be. `dvh` tracks the real, current
// viewport instead; feature-detected once at load (not per render, since
// support can't change at runtime) and fallen back to `vh` wherever it's
// unsupported.
const VH = (typeof CSS !== "undefined" && CSS.supports && CSS.supports("height", "100dvh")) ? "dvh" : "vh";

// ─────────────── RESPONSIVE HOOK ───────────────

function useIsMobile(bp = 768) {
  const [m, setM] = React.useState(window.innerWidth < bp);
  React.useEffect(() => {
    const fn = () => setM(window.innerWidth < bp);
    window.addEventListener('resize', fn);
    return () => window.removeEventListener('resize', fn);
  }, [bp]);
  return m;
}

// Splits text into individually-animated letter spans, each rising in on
// its own staggered delay instead of the whole word arriving as one block.
// Words are kept as their own nowrap groups with a real breakable space
// between them, so multi-word names can still wrap at a word boundary
// instead of becoming one unbreakable run of letters. `tracking` restores
// the letter-spacing an inline-block split otherwise loses (each letter is
// its own atomic box, so a parent's CSS letter-spacing no longer pulls
// them together).
function renderStaggeredLetters(text, loaded, baseDelay, { stagger = 35, tracking = "0em" } = {}) {
  const words = text.split(" ");
  let i = 0;
  const nodes = [];
  words.forEach((word, wi) => {
    nodes.push(
      <span key={"w" + wi} style={{ display: "inline-block", whiteSpace: "nowrap" }}>
        {word.split("").map((ch, ci) => {
          const delay = baseDelay + i * stagger;
          i++;
          return (
            <span
              key={ci}
              style={{
                display: "inline-block",
                marginRight: tracking,
                opacity: loaded ? 1 : 0,
                transform: loaded ? "translateY(0)" : "translateY(0.3em)",
                transition: `opacity 650ms cubic-bezier(0.2, 0.8, 0.2, 1) ${delay}ms, transform 650ms cubic-bezier(0.2, 0.8, 0.2, 1) ${delay}ms`,
              }}
            >
              {ch}
            </span>
          );
        })}
      </span>
    );
    if (wi < words.length - 1) {
      i++;
      nodes.push(" ");
    }
  });
  return nodes;
}

// Same idea as renderStaggeredLetters above (translateY + opacity, same
// 650ms cubic-bezier(0.2, 0.8, 0.2, 1)), one step coarser — whole words
// rather than individual letters — for body copy where a letter-by-letter
// reveal would be too fussy. `revealed` is a plain boolean (not tied to a
// parent CSS class toggling), so the caller can key it off whatever event
// it likes; baseDelay/stagger let multiple calls continue one shared
// count — see the hero-intro-copy paragraph's two lines below.
function renderStaggeredWords(text, revealed, baseDelay, stagger = 80) {
  return text.split(" ").map((word, i) => {
    const delay = baseDelay + i * stagger;
    return (
      <span
        key={i}
        style={{
          display: "inline-block",
          opacity: revealed ? 1 : 0,
          transform: revealed ? "translateY(0)" : "translateY(12px)",
          transition: `opacity 650ms cubic-bezier(0.2, 0.8, 0.2, 1) ${delay}ms, transform 650ms cubic-bezier(0.2, 0.8, 0.2, 1) ${delay}ms`,
        }}
      >
        {word}{" "}
      </span>
    );
  });
}

// The hand-drawn scribble between client names in the marquee below —
// a Figma asset (downloaded to assets/Client scribble.svg), with its
// fills swapped for currentColor so it still picks up --ink like the ✺
// character it replaces, instead of being stuck at the asset's own flat
// grey.
function ClientScribble({ style }) {
  return (
    <svg viewBox="0 0 21.1222 23.496" style={{ width: "0.32em", height: "auto", display: "block", ...style }} xmlns="http://www.w3.org/2000/svg">
      <path d="M13.7603 2.5662C13.9888 2.22348 14.2173 1.88076 14.4457 1.53803C13.4873 0.896086 12.4126 0.393275 11.2507 0.159131C6.49364 -0.898656 2.60413 3.51128 1.80075 7.6353L1.80599 7.61421C0.299083 13.1162 1.79984 20.4262 7.75353 22.8897C8.04924 23.0015 8.34984 23.0955 8.65775 23.1723C15.3919 25.0825 20.8022 18.1638 21.0074 12.2357L21.0042 12.2618C21.4647 8.68844 20.6414 4.48045 17.3979 2.34289C16.4102 1.73695 15.166 1.52307 14.05 1.81337C14.0853 1.97254 14.1207 2.1317 14.1561 2.29086C15.1664 2.08502 16.2133 2.32157 17.0558 2.88851C19.8317 4.87776 20.5135 8.81712 19.9791 12.1099L19.9759 12.1359C19.5659 17.743 14.646 23.5751 8.97946 21.9088C8.71531 21.8425 8.46312 21.7635 8.21474 21.6696C3.21755 19.6815 1.63374 13.0291 3.04843 7.94553L3.05367 7.92444C3.80688 4.14864 7.14839 0.514278 11.0061 1.3837C11.9749 1.57472 12.905 1.99832 13.7603 2.5662ZM14.4457 1.53803L13.7603 2.5662L13.5663 2.43749L14.1561 2.29086L14.05 1.81337L14.4457 1.53803Z" fill="currentColor" />
      <path d="M6.60824 20.4717C6.75834 20.0881 6.90844 19.7045 7.05854 19.3209C6.21046 18.9869 5.41643 18.5293 4.70875 17.9622C1.54001 15.4851 0.453665 10.861 1.92974 7.12511C3.3362 2.99974 9.02237 2.96988 12.5212 5.17061C12.5708 5.19905 12.6204 5.2279 12.67 5.25717L12.6561 5.24874C16.9085 7.8405 20.6997 13.5572 17.858 18.0594L17.8512 18.0697C16.3015 20.8133 12.7044 21.3287 9.66141 20.5362C8.73468 20.3212 7.82058 20.0234 6.92973 19.6715C6.8655 19.8214 6.80128 19.9712 6.73705 20.1211C7.62596 20.5312 8.5478 20.8875 9.49998 21.1597C12.5473 22.1539 16.8014 21.8056 18.7266 18.6387L18.7198 18.649C22.2209 13.2758 17.9094 6.93788 13.3474 4.14267L13.3335 4.13424C13.2791 4.10204 13.2245 4.0703 13.1699 4.039C9.42677 1.6391 2.57736 1.44873 0.720829 6.67575C-0.929885 10.8725 0.301861 16.1273 3.93036 18.9386C4.73955 19.5815 5.64639 20.0982 6.60824 20.4717ZM7.05854 19.3209L6.60824 20.4717L6.73705 20.1211L6.92973 19.6715L7.05854 19.3209Z" fill="currentColor" />
      <path d="M5.15441 4.69592C5.53933 4.84256 5.92425 4.98919 6.30917 5.13583C6.60449 4.36572 7.03434 3.6607 7.59157 3.08055C9.71182 0.707535 13.7545 1.15743 15.5783 3.76853C18.2136 7.25789 17.6515 12.434 15.4482 16.1979C14.8931 17.1425 14.2217 18.0209 13.4397 18.766L13.411 18.7949C12.226 20.1147 10.4224 20.889 8.8351 20.3035C7.23752 19.7477 6.20668 18.0414 5.80186 16.2604L5.79537 16.2339C4.9763 13.4123 4.60173 10.406 5.16073 7.51507C5.32951 6.65848 5.58544 5.81669 5.95054 5.02525C5.80471 4.95233 5.65887 4.87941 5.51304 4.8065C5.0787 5.61484 4.75883 6.48388 4.53257 7.373C3.77968 10.3751 4.03501 13.5438 4.78702 16.5089L4.78053 16.4824C5.16382 18.4545 6.2649 20.6112 8.41838 21.4359C10.58 22.2845 12.9698 21.2145 14.3547 19.6757L14.326 19.7045C15.2164 18.8689 15.9625 17.8968 16.5728 16.8586C18.9629 12.74 19.6702 7.10041 16.5972 2.98412C14.4635 -0.142392 9.26768 -0.754547 6.68836 2.21824C6.00785 2.93332 5.49711 3.78814 5.15441 4.69592ZM6.30917 5.13583L5.15441 4.69592L5.51304 4.8065L5.95054 5.02525L6.30917 5.13583Z" fill="currentColor" />
      <path d="M17.0771 6.37622C16.8572 6.72448 16.6372 7.07274 16.4172 7.421C17.0538 7.82543 17.6116 8.33052 18.0522 8.92444C20.1138 11.5277 18.9765 15.6651 15.9959 17.1283L15.9786 17.1381C12.9404 18.9159 8.80607 17.8811 6.03786 15.6768C4.75656 14.6533 3.68772 13.3147 3.25936 11.7988L3.24917 11.7651C1.84393 8.33246 5.75605 5.47867 9.28035 5.38216L9.32306 5.37805C11.0706 5.08837 12.9156 5.20435 14.5758 5.85227C15.3081 6.14132 16.0015 6.53859 16.5742 7.07154C16.6895 6.95625 16.8048 6.84096 16.9201 6.72567C16.3297 6.09844 15.6029 5.62042 14.8303 5.26067C13.0788 4.45418 11.1008 4.22505 9.19102 4.4538L9.23373 4.44969C7.27302 4.5129 5.24692 5.05583 3.652 6.39827C2.00878 7.68495 1.3034 10.1943 2.04701 12.1658L2.03682 12.1322C2.54469 14.0116 3.78732 15.5443 5.22396 16.6961C8.32306 19.1369 12.8948 20.3927 16.6346 18.2483L16.6173 18.2582C20.1699 16.5396 21.6244 11.3553 19.0528 8.17738C18.5106 7.45402 17.832 6.8498 17.0771 6.37622ZM16.4172 7.421L17.0771 6.37622L16.9201 6.72567L16.5742 7.07154L16.4172 7.421Z" fill="currentColor" />
      <path d="M10.4144 3.706C10.5605 3.63238 10.6717 3.50394 10.7234 3.3486C10.7751 3.19326 10.763 3.02381 10.6898 2.87747C10.6167 2.73113 10.4883 2.61982 10.3331 2.56797C10.1778 2.51611 10.0083 2.52801 9.86172 2.60074C9.86172 2.60074 9.86172 2.60074 9.86172 2.60074C9.12002 2.96861 8.44333 3.45563 7.85214 4.02292C4.39502 7.47833 3.72976 12.9231 5.57758 17.2909C6.09751 18.4451 6.91263 19.6046 8.21129 20.1988C9.50755 20.8151 11.0935 20.5317 12.1923 19.796C13.633 18.8567 14.5356 17.4229 15.1328 15.9513L15.1274 15.964C16.78 11.8242 17.1913 5.72599 12.4753 3.21797L12.5196 3.23686C11.6765 2.82371 10.6072 2.75102 9.74102 3.1524C8.96686 3.49648 8.37209 4.10291 7.95186 4.78009C7.91842 4.83438 7.90619 4.89966 7.91918 4.96247C7.93217 5.02528 7.96909 5.08031 8.02209 5.11565C8.07509 5.15098 8.1401 5.1639 8.20306 5.15173C8.26604 5.13956 8.3216 5.10316 8.35885 5.05142C8.35885 5.05142 8.35885 5.05142 8.35885 5.05142C8.78048 4.46728 9.34333 3.98308 9.98409 3.7488C10.7036 3.47735 11.4892 3.57952 12.1625 3.95107L12.2067 3.96996C15.8476 6.04589 15.578 11.7541 13.9606 15.4567L13.9552 15.4695C13.4096 16.7744 12.5941 17.9847 11.4893 18.6973C9.72915 19.9616 7.56432 18.8166 6.76441 16.7659C5.09663 12.9149 5.73878 7.88727 8.71861 4.92215C9.22319 4.43278 9.79341 4.01874 10.4144 3.706Z" fill="currentColor" />
      <path d="M3.44714 15.3798C3.53496 15.5178 3.67383 15.6157 3.83353 15.6516C3.99323 15.6876 4.16062 15.6588 4.29894 15.5714C4.43725 15.484 4.53523 15.3453 4.57138 15.1856C4.60753 15.026 4.57883 14.8585 4.49192 14.7199C4.49192 14.7199 4.49192 14.7199 4.49192 14.7199C4.15189 14.178 3.90783 13.597 3.81602 13.0071C3.33188 9.93808 7.09667 7.85075 10.1686 7.76476L10.2181 7.7605C12.8472 7.3769 15.8802 8.42614 16.6694 10.871C17.041 11.9734 16.8883 13.2207 16.3862 14.3478L16.3718 14.3825C15.0064 18.4253 9.1359 19.3816 5.74288 16.7479L5.73167 16.7391C5.40305 16.5105 5.10705 16.2193 4.85268 15.8923C4.45072 15.3737 4.14674 14.7648 3.98905 14.1207C3.97415 14.0588 3.93663 14.0041 3.88306 13.9689C3.8295 13.9338 3.76456 13.921 3.70219 13.9334C3.63983 13.9459 3.5848 13.9827 3.54889 14.0358C3.51296 14.0888 3.49937 14.1538 3.50942 14.2166C3.50942 14.2166 3.50942 14.2166 3.50942 14.2166C3.62982 14.9483 3.91498 15.6471 4.32987 16.2683C4.59307 16.6601 4.91117 17.0221 5.29158 17.3259L5.28036 17.3172C8.8013 20.4693 15.689 19.842 17.5625 14.8361L17.5481 14.8707C18.1646 13.5473 18.4054 11.936 17.9073 10.4601C16.7984 7.16123 12.9987 6.03937 10.0577 6.47772L10.1071 6.47346C6.69306 6.61207 2.04944 8.81386 2.58296 13.2045C2.71224 13.9998 3.03561 14.7328 3.44714 15.3798Z" fill="currentColor" />
      <path d="M13.6164 4.76367C13.4593 4.7181 13.2904 4.73636 13.1467 4.81483C13.0031 4.8933 12.8965 5.02549 12.8504 5.1824C12.8042 5.33931 12.8223 5.50818 12.9005 5.65192C12.9788 5.79566 13.1109 5.90244 13.2677 5.94917C13.2677 5.94917 13.2677 5.94917 13.2677 5.94917C13.7841 6.10297 14.2542 6.35771 14.653 6.70592C16.8668 8.71117 16.4613 12.6557 14.6752 15.1166C13.5728 16.8298 11.4186 17.604 9.93496 16.3246C9.12381 15.6799 8.58445 14.671 8.33537 13.5897L8.33152 13.5734C7.89807 11.8895 7.8585 10.0717 8.28994 8.38803C8.70004 6.75398 9.7681 5.01686 11.4313 5.08838L11.4593 5.08938C11.9815 5.06463 12.5408 5.29866 13.037 5.63548C13.5178 5.96144 13.9548 6.37819 14.3525 6.83099C14.3944 6.87879 14.4528 6.91 14.5164 6.91655C14.58 6.92311 14.6434 6.90467 14.693 6.86504C14.7425 6.82541 14.7744 6.7676 14.782 6.70408C14.7896 6.64056 14.7719 6.57673 14.7345 6.52543C14.7345 6.52543 14.7345 6.52543 14.7345 6.52543C14.3588 6.01414 13.9334 5.52958 13.4197 5.11754C12.8896 4.69695 12.235 4.32792 11.4593 4.30168L11.4874 4.30268C9.17995 4.07536 7.75197 6.30409 7.22935 8.08481C6.65961 9.97014 6.64394 11.9754 7.09701 13.8821L7.09316 13.8658C7.37155 15.1662 8.00989 16.4548 9.12356 17.3459C10.1075 18.1568 11.5629 18.5129 12.8258 18.1197C14.0951 17.7458 15.0506 16.8337 15.7336 15.8637C17.7472 12.9971 18.407 8.51407 15.4699 5.76145C14.9322 5.29744 14.2912 4.95844 13.6164 4.76367Z" fill="currentColor" />
      <path d="M7.61633 9.17511C7.75208 9.08388 7.84646 8.94265 7.87845 8.78213C7.91044 8.62161 7.87747 8.45502 7.78674 8.31893C7.69602 8.18284 7.55492 8.08833 7.39445 8.05613C7.23397 8.02392 7.06731 8.05671 6.93088 8.14694C6.93088 8.14694 6.93088 8.14694 6.93088 8.14694C6.3428 8.53507 5.82078 9.05432 5.45924 9.69297C3.71812 12.9181 6.41643 16.6204 9.55679 17.2222L9.54026 17.2183C10.9538 17.5937 12.6719 17.4561 13.925 16.4572C15.18 15.484 15.8031 13.8754 15.6981 12.3487C15.6427 11.4615 15.3487 10.5936 14.8664 9.85389L14.8553 9.83725C13.8975 8.4505 12.4119 7.23833 10.5801 7.04939C8.74953 6.79115 6.84473 8.11058 6.37289 9.81849C5.66941 11.5469 6.57865 13.7798 8.22636 14.5089C8.81789 14.8159 9.45725 14.9913 10.0973 15.0706C10.1603 15.0783 10.2246 15.0626 10.2764 15.0249C10.3282 14.9874 10.3631 14.9313 10.3735 14.8687C10.3839 14.8061 10.3691 14.7418 10.3323 14.6894C10.2956 14.6371 10.2398 14.6013 10.1777 14.5881C10.1777 14.5881 10.1777 14.5881 10.1777 14.5881C9.59378 14.4634 9.03299 14.2542 8.54417 13.9488C7.18567 13.1607 6.68003 11.5198 7.29217 10.1498C7.77808 8.81257 9.10632 8.01804 10.4466 8.22893C11.7923 8.40829 12.9869 9.37273 13.791 10.569L13.7799 10.5523C14.1402 11.1193 14.3547 11.769 14.3964 12.4317C14.6364 14.8347 12.2265 16.7347 9.8535 15.9653L9.83697 15.9614C7.31833 15.5111 5.30284 12.494 6.54694 10.3064C6.79734 9.85752 7.16601 9.47766 7.61633 9.17511Z" fill="currentColor" />
    </svg>
  );
}

// One row of the footer's scrolling client-name marquee. `animationName`
// picks the direction (see the client-scroll / client-scroll-reverse
// keyframes in Contact) so two rows can run opposite ways. Giving the two
// mobile rows different `duration`s (rather than just opposite direction
// at the same speed) keeps their phase constantly drifting apart, so the
// scribbles don't keep lining up between rows the way they do at a
// shared speed. A negative `delay` starts the row as if it had already
// been playing for that long — i.e. mid-cycle, not flush at the very
// start of the loop — useful for the first row so its first name isn't
// sitting right at the left edge on load.
function renderClientMarqueeRow(list, animationName, duration = 60, delay = 0) {
  return (
    <div style={{
      display: "flex",
      animation: `${animationName} ${duration}s linear infinite`,
      animationDelay: `${delay}s`,
      whiteSpace: "nowrap",
    }}>
      {[...list, ...list].map((c, i) => (
        <span key={i} style={{
          // Geist Light, not the theme's own --font-display (PP Editorial
          // New in the default theme) — a deliberate, fixed choice for
          // this carousel specifically, independent of whichever display
          // font the rest of the page is currently set to.
          fontFamily: "'Geist', system-ui, sans-serif",
          fontSize: "clamp(28px, 4vw, 48px)",
          fontWeight: 300,
          lineHeight: 1.81,
          letterSpacing: "-0.021em",
          padding: "0 24px",
          color: "var(--ink)",
          display: "inline-flex",
          alignItems: "center",
          gap: 40,
        }}>
          {c}
          <ClientScribble style={{ color: "var(--ink)", verticalAlign: "middle" }} />
        </span>
      ))}
    </div>
  );
}

// ─────────────── COMPONENTS ───────────────

// Reload-only splash. Renders nothing (real layout shows immediately) for
// prefers-reduced-motion, GSAP failing to load, or — the main gate — any
// page load that isn't an actual browser reload (typed URL, external
// link, back/forward, or a link back from a case study all skip it; see
// the navigation-type check below). Never leaves a stuck white screen,
// and never replays itself just because the user browsed back to the
// homepage from somewhere else.
//
// Ported from a Figma prototype built specifically for this motion.
// "Elspeth" and "Belden" are each independently positioned — Elspeth via
// `right`, Belden via `left`, both with their own `top`/`fontSize` — not
// laid out together in a shared flex row the way the real .hero-name is.
// There's no shared layout calculation for the two words to disagree
// about, so nothing can jump: each is just a plain tween from its own
// start values to its own (measured, pixel-exact) end values. The photo
// is a single element that grows from a small centred square to
// fullscreen via top/left/width/height — not a transform/scale — then
// fades to reveal the real page underneath.
//
// Because the real .hero-name's position is only ever read once (its
// section stays 100vh — unchanged — for this component's entire life;
// see 'intro-hero-settle' below), there's no need to keep re-measuring it
// every frame the way a shared-box FLIP would.
//
// The real page's own background/nav/name animations (Hero's image
// fade/scale-in, the nav row's fade-up, etc.) are never duplicated or
// overridden here — they're untouched. HeroStacked just waits for this
// component's 'intro-reveal' event instead of firing on its own mount, so
// the viewer actually sees them play out — concurrently with the wordmark
// growing, not as a separate wipe revealed afterward.
function IntroOverlay() {
  const isMobile = useIsMobile();
  const rootRef = useRef(null);
  const panelRef = useRef(null);
  const photoRef = useRef(null);
  const elspethRef = useRef(null);
  const beldenRef = useRef(null);
  const [active, setActive] = useState(null); // null = deciding, true = playing
  const [lettersIn, setLettersIn] = useState(false);
  const [flickerIndex, setFlickerIndex] = useState(0);

  useEffect(() => {
    // Only an actual browser reload (F5 / Cmd+R) plays the splash — not a
    // fresh arrival from elsewhere (typed URL, external link), and not
    // navigating back to the homepage from a case study or via back/
    // forward, all of which land here with the page already scrolled to
    // wherever the browser's own history/back-forward cache has it. The
    // splash assumes it's covering the very top of the page, so playing
    // it under any of those only reads as broken, not intentional.
    const willPlay = willPlayIntro();
    // Set synchronously (not via the state below) so HeroStacked's own
    // mount effect — which runs right after this one — can read it
    // immediately, before any state update has flushed.
    window.__introActive = willPlay;
    setActive(willPlay);
  }, []);

  useLayoutEffect(() => {
    if (active !== true) return;
    window.__lenis && window.__lenis.stop();
    const raf = requestAnimationFrame(() => setLettersIn(true));
    // Hides the real .hero-name for as long as this clone exists; the two
    // are pixel-identical by the time this class comes off in cleanup, so
    // nothing visibly changes at handoff.
    document.body.classList.add('intro-active');

    const vw = window.innerWidth;
    const vh = window.innerHeight;
    const elspethEl = elspethRef.current;
    const beldenEl = beldenRef.current;

    // Phase A (hold): small, centred — a bit smaller than the prototype's
    // own clamp(52px, 4.98vw, 76px) starting size, scaled down by ~15%.
    const holdFontSizePx = Math.min(65, Math.max(44, vw * 0.042));
    const holdGapPx = holdFontSizePx * 0.18;
    const photoSize = 224;
    // Phase B (open gap): same size, gap widens to make room for the
    // photo. Half the photo's size plus a margin either side, rather than
    // the prototype's flat 7.8vw — that came out within a pixel of the
    // photo's own width (no breathing room at all, the photo sitting
    // edge-to-edge against both words).
    const openGapPx = photoSize / 2 + 28;
    // Mobile has no room to open a gap beside "Elspeth Belden" for the
    // photo (see the `!isMobile` gap-open tween below), so it stacks
    // instead: a smaller square sits above the held wordmark, both
    // nudged apart from true centre by half their combined height so
    // the pair reads as one centred group.
    const mobilePhotoSize = Math.min(160, vw * 0.42);
    const mobilePhotoGap = 24;
    // Line box height (line-height 0.88), so the gap is measured from the
    // text itself rather than from its centre.
    const mobileTextHeight = holdFontSizePx * 0.88;
    const mobileStackTop = vh / 2 - (mobilePhotoSize + mobilePhotoGap + mobileTextHeight) / 2;
    const mobilePhotoCenterY = mobileStackTop + mobilePhotoSize / 2;
    const textHoldTop = isMobile
      ? mobileStackTop + mobilePhotoSize + mobilePhotoGap + mobileTextHeight / 2
      : vh / 2;

    // `top` is animated directly (in px) and `yPercent` handles the
    // vertical-centring half of it (equivalent to the prototype's
    // `transform: translate(0, -50%)`) — GSAP's percentage-of-self
    // transform, cleared back to 0 once `top` holds the real, final pixel
    // position in phase D below.
    gsap.set([elspethEl, beldenEl], { top: textHoldTop, yPercent: -50, fontSize: holdFontSizePx });
    gsap.set(elspethEl, { right: vw / 2 + holdGapPx });
    gsap.set(beldenEl, { left: vw / 2 + holdGapPx });

    if (photoRef.current) {
      const ps = isMobile ? mobilePhotoSize : photoSize;
      const photoCenterY = isMobile ? mobilePhotoCenterY : vh / 2;
      gsap.set(photoRef.current, {
        top: photoCenterY - ps / 2,
        left: vw / 2 - ps / 2,
        width: ps,
        height: ps,
        opacity: 0,
      });
    }

    const tl = gsap.timeline({
      // Mobile starts the photo alongside the letter stagger rather than
      // after it, to get people into the site sooner.
      delay: isMobile ? 0 : 1.1,
      defaults: { ease: "power2.inOut" },
      onComplete: () => {
        window.__lenis && window.__lenis.start();
        // Only now — once the clone is actually gone and the real
        // .hero-name is visible again — is it safe to start the section's
        // own height shrink (see HeroStacked below). 'intro-settle' (the
        // white "Approach" section's own reveal, below) fires in the same
        // breath rather than several seconds earlier, so the section
        // actually becomes visible at the same moment the shrinking hero
        // pulls it into view, instead of sitting ready-but-unmoved for a
        // beat first.
        window.dispatchEvent(new CustomEvent('intro-hero-settle'));
        window.dispatchEvent(new CustomEvent('intro-settle'));
        setActive(false);
      },
    });

    // t1: gap opens / photo appears — immediately, no held pause once the
    // name has landed. t4: photo has reached fullscreen and starts its
    // own fade to the real page.
    const t1 = isMobile ? 0 : 0.4;
    // The gap-opening slide and the photo's own fade-in are quick (not
    // stretched across the whole hold) — the photo is meant to already be
    // flicking through images almost as soon as it's visible, not sitting
    // on a static first frame until some later moment.
    const openDuration = 0.4;
    const introImages = isMobile ? MOBILE_HERO_IMAGES : DESKTOP_HERO_IMAGES;
    // Each image gets a proper beat on screen rather than a rapid-fire
    // flick. One pass through the set, landing on its last image (Costa).
    const flickerCount = introImages.length;
    const flickerStep = 0.3;
    // t3: grow begins — text and photo both animate to their final
    // state, nav/intro copy reveal. This follows directly from how long
    // the flicker itself takes, not a fixed number independent of it —
    // no extra pause here, the grow starts the instant the flicker lands
    // on Costa.
    const t3 = t1 + flickerCount * flickerStep;
    const t4 = t3 + 1.45;
    // No hold once Costa fills the screen: cut to the site straight away.
    const costaHoldExtra = 0;
    const t5 = t4 + costaHoldExtra;

    // The gap between "Elspeth" and "Belden" only opens on desktop, where
    // there's room either side for the photo to drop into — mobile stacks
    // the photo above the (already-together) wordmark instead (see
    // mobileStackTop above), so there's no gap to open.
    if (!isMobile) {
      tl.to(elspethEl, { right: vw / 2 + openGapPx, duration: openDuration }, t1)
        .to(beldenEl, { left: vw / 2 + openGapPx, duration: openDuration }, t1);
    }

    if (photoRef.current) {
      tl.to(photoRef.current, { opacity: 1, duration: openDuration }, t1);

      // Flicks through the hero carousel's images, twice through the
      // set, starting the instant the photo appears and landing on the
      // last one just before the grow begins.
      for (let i = 0; i < flickerCount; i++) {
        const imgIndex = i % introImages.length;
        tl.call(() => setFlickerIndex(imgIndex), [], t1 + i * flickerStep);
      }

      tl.to(photoRef.current, { top: 0, left: 0, width: vw, height: vh, duration: t4 - t3 }, t3);
    }

    // No fade at the handoff: the hero underneath is showing the same
    // last image (HeroStacked starts its carousel there while the intro
    // plays) with the same gradient, so the overlay just unmounts at t5
    // in a single frame — a direct cut between identical pictures. Any
    // fade here stacked two gradients and briefly showed the panel.
    tl.set({}, {}, t5);

    tl.call(() => window.dispatchEvent(new CustomEvent('intro-reveal')), [], t3)
      // Measured here, right as the grow begins — not at mount, several
      // seconds earlier — so there's no chance of racing the custom
      // webfont's own load (a fallback-font measurement taken before it
      // swaps in would quietly target the wrong position). Elspeth and
      // Belden then grow independently, each a single tween from its own
      // phase-A/B values straight to its own measured, final position —
      // no shared box, no correction, nothing for either one to jump
      // against.
      .call(() => {
        const realEl = document.querySelector('.hero-name:not([data-intro-clone])');
        const realWords = realEl ? realEl.querySelectorAll('.hero-name-word') : [];
        const realFirstRect = realWords[0] ? realWords[0].getBoundingClientRect() : null;
        const realLastRect = realWords[realWords.length - 1] ? realWords[realWords.length - 1].getBoundingClientRect() : null;
        const realFontSizePx = realEl ? parseFloat(getComputedStyle(realEl).fontSize) : 0;
        const duration = t4 - t3;
        gsap.to(elspethEl, {
          top: realFirstRect ? realFirstRect.top : vh * 0.7,
          right: realFirstRect ? vw - realFirstRect.right : vw * 0.37,
          yPercent: 0,
          fontSize: realFontSizePx || holdFontSizePx * 3,
          duration,
          ease: "power2.inOut",
        });
        gsap.to(beldenEl, {
          top: realLastRect ? realLastRect.top : vh * 0.7,
          left: realLastRect ? realLastRect.left : vw * 0.63,
          yPercent: 0,
          fontSize: realFontSizePx || holdFontSizePx * 3,
          duration,
          ease: "power2.inOut",
        });
      }, [], t3);

    // Resume scrolling as soon as the grow begins rather than waiting for
    // the whole timeline (including the photo's own fade-out) to finish,
    // so scrolling isn't left locked any longer than it needs to be.
    tl.call(() => window.__lenis && window.__lenis.start(), [], t3);

    // The hero's paragraph + nav (HeroStacked's 'intro-top-reveal' listener)
    // are fired at the cut (t5), not at t4: anything revealed earlier finishes
    // animating hidden behind the overlay and then pops in at the cut.
    tl.call(() => window.dispatchEvent(new CustomEvent('intro-top-reveal')), [], t5);

    return () => {
      cancelAnimationFrame(raf);
      tl.kill();
      // The final grow tweens for Elspeth/Belden are created dynamically
      // inside the tl.call() above (so their target can be measured at
      // the last possible moment — see the comment there), so they're not
      // part of `tl` itself and `tl.kill()` doesn't reach them.
      gsap.killTweensOf([elspethEl, beldenEl]);
      document.body.classList.remove('intro-active');
    };
  }, [active, isMobile]);

  if (active !== true) return null;

  return (
    <div ref={rootRef} style={{ position: "fixed", inset: 0, zIndex: 99999 }}>
      <style>{`body.intro-active .hero-name:not([data-intro-clone]) { visibility: hidden; }`}</style>
      <div ref={panelRef} style={{ position: "absolute", inset: 0, background: "#1A1A1A" }} />
      {/* Grows from a small centred square (beside the wordmark on
          desktop, stacked above it on mobile — see the timeline above)
          to fullscreen via its own top/left/width/height — never a
          transform, so there's no scale origin math needed at all. */}
      <div ref={photoRef} style={{ position: "fixed", overflow: "hidden", zIndex: 2, background: "#1F1A14" }}>
        <img
          src={(isMobile ? MOBILE_HERO_IMAGES : DESKTOP_HERO_IMAGES)[flickerIndex]}
          style={{ width: "100%", height: "100%", objectFit: "cover", display: "block" }}
        />
      </div>
      {/* Same darken-for-legibility gradient as the real hero's own
          background (see HeroStacked) — fixed at full viewport size and
          full strength from the very first frame, not tied to the
          photo's own grow tween at all. Trying to fade this in sync with
          the grow kept reading as late no matter how it was eased, since
          a dark value easing off opacity 1 barely registers next to the
          same fraction of the photo's own size change. Putting it in
          place from the start — in front of the photo, so it's there
          however small or large the photo currently is — sidesteps the
          sync problem entirely: there's nothing left to time, and it
          matches the real hero's identical (also now static) gradient
          exactly, so the eventual handoff has no visible change either. */}
      <div style={{
        position: "fixed", inset: 0, zIndex: 3, pointerEvents: "none",
        background: "linear-gradient(180deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.1) 40%, rgba(0,0,0,0.55) 100%)",
      }} />
      {/* Matches HeroStacked's extra mobile bottom darkening, so nothing changes at the cut. */}
      {isMobile && (
        <div style={{
          position: "fixed", left: 0, right: 0, bottom: 0, height: "38%",
          zIndex: 3, pointerEvents: "none",
          background: "linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.55) 100%)",
        }} />
      )}
      <h1
        data-intro-clone="true"
        // No .hero-name class here on purpose — every position/size value
        // is set directly below (and animated), so the class's own flex
        // layout would only be dead weight to override. zIndex: 4 keeps
        // the wordmark above the photo and its darkening gradient
        // (zIndex: 2 / 3): it needs to actually be visible while it
        // grows — name over photo is the point of this beat — rather
        // than sitting hidden underneath it.
        style={{
          position: "fixed", inset: 0, margin: 0, padding: 0,
          color: "#F4F1EC", fontFamily: "var(--font-name)", fontWeight: 200,
          lineHeight: 0.88,
          zIndex: 4, pointerEvents: "none",
        }}
      >
        {/* letterSpacing lives on each word span (not the h1 above) because
            it's an em value, and GSAP animates fontSize directly on these
            spans, not on the h1 — set a level up, "em" would resolve
            against the h1's own (unrelated, unanimated) inherited
            font-size instead of the word's real, growing one, computing a
            near-zero px value that let the two words render visibly wider
            than the real heading despite an identical fontSize target. */}
        <span ref={elspethRef} style={{ position: "absolute", whiteSpace: "nowrap", letterSpacing: "-0.022em" }}>
          {renderStaggeredLetters("Elspeth", lettersIn, 120, { stagger: 65, tracking: "-0.022em" })}
        </span>
        <span ref={beldenRef} style={{ position: "absolute", whiteSpace: "nowrap", letterSpacing: "-0.022em" }}>
          {renderStaggeredLetters("Belden", lettersIn, 575, { stagger: 65, tracking: "-0.022em" })}
        </span>
      </h1>
    </div>
  );
}

// E-mark that turns into a house outline on hover — same component as the
// case-study pages' breadcrumb (natwest.jsx etc.), with a size prop.
function BrandMark({ size = 21 }) {
  const [hover, setHover] = useState(false);
  return (
    <span
      onMouseEnter={() => setHover(true)}
      onMouseLeave={() => setHover(false)}
      style={{ position: "relative", display: "inline-block", width: size, height: size }}
    >
      <svg width={size} height={size} viewBox="0 0 32 32" fill="currentColor" aria-hidden="true" style={{
        position: "absolute", top: 0, left: 0,
        transform: hover ? "scale(0) rotate(-14deg)" : "scale(1) rotate(0deg)",
        transition: "transform 0.25s ease"
      }}>
        <path d="M0 5 H32 V9 H4 V14 H32 V18 H4 V23 H32 V27 H0 Z" />
      </svg>
      <svg width={size} height={size} viewBox="0 0 32 32" fill="none" stroke="currentColor" strokeWidth="3.5" strokeLinejoin="round" strokeLinecap="round" aria-hidden="true" style={{
        position: "absolute", top: 0, left: 0,
        transform: hover ? "scale(1) rotate(0deg)" : "scale(0) rotate(14deg)",
        transition: "transform 0.25s ease"
      }}>
        <path d="M16 4 L3 17 L3 29 L29 29 L29 17 Z" />
      </svg>
    </span>
  );
}

// ─────────────── HERO WALL (Figma 141:1410) ───────────────
// Five staggered columns of project tiles behind the big name, with the
// motion borrowed from vivmgmt.com: columns rise in from below on load,
// the name wipes up after them, and on scroll the gallery travels at 1.5×
// scroll speed so the tiles slide up past the name. All geometry is in
// Figma units (the frame is 1672 wide) and converted with --u, so the
// whole composition scales with the viewport.
const WALL = "assets/hero-wall/";
// Layers are in tile-space design px (tile = 398×531). `fit: "fill"`
// stretches (vectors/SVGs); everything else is object-fit: cover.
// Only layers that can actually be seen are kept: anything fully covered
// by an opaque layer above it (left over from the Figma layer stacks) has
// been dropped, so it isn't downloaded for nothing. Cover layers that sat
// a fraction of a px off the tile edge were snapped to 0 so nothing peeks
// out from under them.
const HERO_WALL_COLUMNS = [
  { left: -145.5, top: 0, tiles: [
    { bg: "#bfbab4", layers: [
      { src: "hair-like-this.svg", l: 5.5, t: -143.37, w: 532, h: 624, fit: "fill" },
    ] },
    { bg: "#d4b6a9", layers: [
      { src: "costa-latte.jpg", l: -281.5, t: 0, w: 1210, h: 534 },
    ] },
    { bg: "#444", layers: [
      { src: "c1t3-top.jpg" },
      { color: "rgba(0,0,0,0.05)" },
    ] },
    // Bottom-left corner: only ever a thin sliver at the screen edge
    // before the zoom pushes this column off, so just its colour.
    { bg: "#c8b3b0", layers: [] },
  ] },
  { left: 262.7, top: 355.05, tiles: [
    // "Looks like good design" recording on NatWest purple.
    { bg: "#3c1053", layers: [
      { video: "natwest-good-design.mp4", l: 0, t: -0.05, w: 398, h: 533.14 },
    ] },
    { bg: "#a7a1cf", layers: [{ src: "image-5.webp" }] },
    // "What's your Whisky" (Figma 208:7): the flavour-profile recording on
    // near-black, running off the bottom edge, top corners rounded.
    { bg: "#12120f", layers: [
      { video: "whisky.mp4", l: 79.3, t: 27.95, w: 241, h: 520,
        style: { borderTopLeftRadius: `${(8 / 241) * 100}% ${(8 / 520) * 100}%`,
                 borderTopRightRadius: `${(8 / 241) * 100}% ${(8 / 520) * 100}%` } },
    ] },
    { bg: "#162738", layers: [
      // Box at the recording's own 2666×1826 ratio (taller than Figma's
      // 456×295 frame) so nothing is cropped; same width and centre.
      { video: "artfund-site.mp4", l: -87.7, t: 102.3, w: 456, h: 312.3, radius: 16 },
    ] },
  ] },
  { left: 670.9, top: 149.91, tiles: [
    { bg: "#a7a1cf", layers: [
      { src: "marlow-machine.jpg", l: -206.9, t: -0.91, w: 728, h: 614 },
    ] },
    // NatWest cover crop (shows while the recording loads), then the
    // "Good design in action" card recording over it.
    { bg: "#331148", layers: [
      { clip: true, l: 37.1, t: 288.09, w: 324, h: 224, layers: [
        { src: "natwest-cover.jpg", l: -737.0, t: -226.06, w: 1440, h: 900 },
      ] },
      { video: "natwest-cards.mp4", l: 22.1, t: -93.91, w: 354, h: 728 },
    ] },
    { bg: "#162738", layers: [
      { video: "artfund-phone.mp4", l: 96.3, t: 38.95, w: 205, h: 454, radius: 2 },
    ] },
    // "WGDLL" (Figma 141:1508): the magazine mockup, which covers the tile.
    { layers: [
      { src: "wgdll-magazine.jpg", l: -92.9, t: -92.91, w: 800, h: 686 },
      { color: "rgba(0,0,0,0.05)", l: -92.9, t: -92.91, w: 800, h: 686 },
    ] },
  ] },
  { left: 1079.1, top: 355.05, tiles: [
    { bg: "#e3dae9", layers: [
      { src: "natwest-hand.jpg", l: -317.1, t: -87.24, w: 986.3, h: 646.1 },
    ] },
    { bg: "#ced3dd", layers: [{ src: "screenshot-191210.jpg", l: -28.1, t: 40.95, w: 447, h: 490 }] },
    // "Bupa" (Figma 208:13): two phones cut from the Bupa shot on navy —
    // the second through a polygon mask, with a navy patch over an edge.
    { bg: "#27386e", layers: [
      { src: "bupa-2.jpg", l: -458.7, t: -0.05, w: 858, h: 431 },
      { color: "#27386e", l: -1.7, t: 340.95, w: 31, h: 84 },
      { src: "bupa-2.jpg", l: -326.7, t: 63.45, w: 946, h: 475,
        mask: { src: "bupa-phone-mask.svg", l: 249, t: 54.5, w: 390.5, h: 413 } },
    ] },
    // "Costa" (Figma 141:1520): the Costa Express screen recording in a
    // bordered frame on a dark plum→indigo gradient.
    { bg: "#231920", layers: [
      { color: "linear-gradient(178.45deg, #231920 0.75%, #231d29 34.25%, #4a4d6e 73.34%)",
        l: -0.1, t: -0.05, w: 425, h: 753 },
      { clip: true, l: 40.9, t: 36.95, w: 319, h: 572, radius: 4, layers: [
        { video: "costa-express.mp4" },
        { color: "transparent", radius: 4,
          style: { border: "1px solid #000", boxShadow: "inset 0 4px 4px rgba(0,0,0,0.26)", boxSizing: "border-box" } },
      ] },
    ] },
  ] },
  { left: 1487.3, top: 0, tiles: [
    // "Container-book" (Figma 141:1526): the alt book mockup, which covers
    // the tile (the original mockup under it never shows, so it's dropped).
    { bg: "#fdf6fe", layers: [{ src: "book-mockup-alt.jpg", l: -254.3, t: -79, w: 968, h: 645 }] },
    { bg: "#30ccd6", layers: [{ src: "image-10.jpg", l: -49.3, t: 77, w: 497, h: 356 }] },
    { bg: "#007bce", layers: [
      { src: "phone-hand.jpg", l: -117.3, t: -39, w: 575, h: 575 },
    ] },
    // Bottom-right corner: only ever a thin sliver at the screen edge
    // before the zoom pushes this column off, so just its colour.
    { bg: "#a9b4cb", layers: [] },
  ] },
];
const WALL_TILE_W = 398, WALL_TILE_H = 531, WALL_GAP = 10, WALL_TOP = 307;
// Extra scroll drift per column (× scroll px), on top of the gallery's
// shared 0.5× — small, so the columns slip against each other subtly.
// Tiles that stay *behind* the name (top-left and top-right corners);
// every other tile scrolls over it.
const WALL_BEHIND_NAME = (ci, ti) => ti === 0 && (ci === 0 || ci === HERO_WALL_COLUMNS.length - 1);
const WALL_COL_DRIFT = [0.125, 0, 0.075, -0.0625, 0.1625];
const wallColH = (cols) => Math.max(...cols.map(c => c.top + c.tiles.length * (WALL_TILE_H + WALL_GAP) - WALL_GAP)) + 40;
const WALL_COL_H = wallColH(HERO_WALL_COLUMNS);
// Mobile: two full-width columns, no panning. The outer desktop columns
// (cropped off on desktop anyway) are dropped, and the middle three's
// tiles are dealt row by row, alternating left/right, so neighbours mix.
const MOBILE_WALL_COLUMNS = (() => {
  const src = [1, 2, 3].map(i => HERO_WALL_COLUMNS[i].tiles);
  const cols = [[], []];
  let k = 0;
  for (let r = 0; r < Math.max(...src.map(t => t.length)); r++)
    src.forEach(tiles => { if (tiles[r]) cols[k++ % 2].push(tiles[r]); });
  // Figma mobile (173:23) leads with the NatWest hand, then "Looks like
  // good design" — swap the first two on the left.
  [cols[0][0], cols[0][1]] = [cols[0][1], cols[0][0]];
  // Swap the NatWest card recording (left) with the green Art Fund
  // screens (right) — both third in their column.
  [cols[0][2], cols[1][2]] = [cols[1][2], cols[0][2]];
  // …and fifth on the left (now Bupa) with the Art Pass red-dots
  // recording (right), so Art Pass sits on the left.
  [cols[0][4], cols[1][4]] = [cols[1][4], cols[0][4]];
  // Right column starts ~a quarter of a tile lower, so the two are staggered.
  // Both nudged down 10px from the top of the wall.
  return cols.map((tiles, i) => ({ left: 0, top: i ? 134 : 10, tiles }));
})();
const MOBILE_WALL_COL_H = wallColH(MOBILE_WALL_COLUMNS);
const MOBILE_WALL_MARGIN = 12; // px, each screen edge
// Mobile drift: the right column runs clearly ahead of the left (never
// lags, so it can't drop past the section's bottom edge).
const MOBILE_COL_DRIFT = [0, -0.15];

// pw/ph: the parent box in Figma px (the tile, or an enclosing group), so
// nested layers can use their own group-relative coordinates.
function renderWallLayers(layers, pw = WALL_TILE_W, ph = WALL_TILE_H) {
  return layers.map((ly, i) => {
    // Defaults to filling the parent; explicit l/t/w/h are parent-space px.
    const w = ly.w ?? pw, h = ly.h ?? ph;
    const box = {
      position: "absolute",
      left: `${((ly.l ?? 0) / pw) * 100}%`,
      top: `${((ly.t ?? 0) / ph) * 100}%`,
      width: `${(w / pw) * 100}%`,
      height: `${(h / ph) * 100}%`,
      // Corner radius in Figma px, as % of the box so it scales with the wall.
      ...(ly.radius && { borderRadius: `${(ly.radius / w) * 100}% / ${(ly.radius / h) * 100}%` }),
    };
    if (ly.layers) return (
      <div key={i} style={{ ...box, opacity: ly.opacity, overflow: ly.clip ? "hidden" : undefined }}>
        {renderWallLayers(ly.layers, w, h)}
      </div>
    );
    // `style` adds extras such as a border or inset shadow on a frame.
    if (ly.color) return <div key={i} style={{ ...box, background: ly.color, ...ly.style }} />;
    if (ly.video) {
      // Muted + playsInline so it autoplays everywhere (incl. iOS); held on
      // its first frame for reduced-motion users.
      const still = window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
      // React sets `muted` as a property but never as the HTML attribute,
      // which autoplay policies can check — so autoplay can silently not
      // start. Mark it muted explicitly and start it ourselves once it can
      // play (files with the index at the end only get there once fully
      // loaded).
      const startMuted = (el) => {
        if (!el || still) return;
        el.muted = true; el.defaultMuted = true; el.setAttribute("muted", "");
        const go = () => { const p = el.play(); if (p && p.catch) p.catch(() => {}); };
        if (el.readyState >= 3) go(); else el.addEventListener("canplay", go, { once: true });
      };
      return (
        <video key={i} ref={startMuted} src={WALL + ly.video} muted loop playsInline autoPlay={!still} preload="auto"
          aria-hidden="true" style={{ ...box, maxWidth: "none", display: "block", objectFit: "cover", ...ly.style }} />
      );
    }
    // Optional alpha mask (Figma "Mask group"): an SVG shape placed at
    // ly.mask.{l,t,w,h} in the layer's own px. Sized as % of the layer and
    // positioned with CSS's %-offset rule — p% = offset / (box − mask) —
    // so it scales with the wall.
    let maskStyle = null;
    if (ly.mask) {
      const m = ly.mask;
      const size = `${(m.w / w) * 100}% ${(m.h / h) * 100}%`;
      const pos = `${(m.l / (w - m.w)) * 100}% ${(m.t / (h - m.h)) * 100}%`;
      const url = `url("${WALL + m.src}")`;
      maskStyle = {
        WebkitMaskImage: url, maskImage: url,
        WebkitMaskSize: size, maskSize: size,
        WebkitMaskPosition: pos, maskPosition: pos,
        WebkitMaskRepeat: "no-repeat", maskRepeat: "no-repeat",
      };
    }
    return (
      <img key={i} src={WALL + ly.src} alt="" draggable="false" style={{
        ...box, maxWidth: "none", display: "block",
        objectFit: ly.fit === "fill" ? "fill" : "cover",
        ...maskStyle,
      }} />
    );
  });
}

function HeroWall() {
  const isMobile = useIsMobile();
  const reduced = typeof window !== "undefined" && window.matchMedia
    && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
  const [entered, setEntered] = useState(reduced);
  // Layout width (no scrollbar), so both name edges sit evenly against the
  // columns — innerWidth includes the scrollbar and skews everything ~15px.
  const viewW = () => document.documentElement.clientWidth || window.innerWidth;
  const [vw, setVw] = useState(viewW);
  const [vh, setVh] = useState(() => window.innerHeight);
  // The wall is rendered twice, in sync: a back layer (corner tiles only,
  // under the name) and a front layer (all other tiles, over it). One
  // transform can't put tiles on both sides of the name, since each
  // column's transform makes it its own stacking context.
  const galleryRefs = useRef([]);   // [back, front]
  const colRefs = useRef([[], []]); // per layer, per column
  const nameRef = useRef(null);
  const taglineRef = useRef(null);

  // Figma px → CSS px. Desktop maps the 1672-wide frame to the viewport;
  // mobile sizes two tiles + one gap to fill the width inside 12px margins.
  const columns = isMobile ? MOBILE_WALL_COLUMNS : HERO_WALL_COLUMNS;
  const colDrift = isMobile ? MOBILE_COL_DRIFT : WALL_COL_DRIFT;
  const u = isMobile ? (vw - MOBILE_WALL_MARGIN * 2) / (2 * WALL_TILE_W + WALL_GAP) : vw / 1672;
  // Mobile: name centred on the first screen, with the work starting right
  // under its line box (tiles overlap just the descenders).
  const MOBILE_NAME_DIV = 5.0; // name size = (vw − 40) / this
  const mobileNameH = ((vw - 40) / MOBILE_NAME_DIV) * 0.88;
  const mobileNameTop = (vh - mobileNameH) / 2;
  // Desktop: name + wall sit 80 Figma units lower than the frame, so the
  // work is cut off further down at the bottom of the first screen.
  const DROP = 80;
  const galleryTop = isMobile ? mobileNameTop + mobileNameH : (WALL_TOP + DROP) * u;
  const nameTop = isMobile ? mobileNameTop : (443 + DROP) * u;
  const colH = (isMobile ? MOBILE_WALL_COL_H : WALL_COL_H) * u;
  const nameH = isMobile ? mobileNameH : 242.44 * u * 0.88;
  // Gallery moves an extra 0.5× scroll (1.5× total, as on vivmgmt.com).
  // The section is sized so that extra travel ends exactly when the
  // gallery's bottom meets the section's bottom at the bottom of the
  // screen — from there it scrolls 1:1 with the page, so no gap opens
  // up above the next section. Solves: galleryTop + colH − 0.5·sEnd = H,
  // with sEnd = H − vh.
  const PARALLAX = reduced ? 0 : 0.5;
  // Scroll zoom ("camera push") into the middle three columns: over the
  // first ~screen of scrolling the wall scales up ZOOM× around their
  // centre and recentres them, so they fill the width inside 12px side
  // margins (nothing cropped) and the outer two columns slide
  // off either edge. Desktop only — on mobile the middle three already
  // overfill the screen.
  // The wall is *laid out* at the zoomed size (gu = u × ZOOM) and drawn
  // scaled down to start with, so it's rasterised at full resolution and
  // stays sharp as it scales up (a layer scaled *up* would be blurry).
  const ZOOM_MARGIN = 12;
  const midW = HERO_WALL_COLUMNS[3].left + WALL_TILE_W - HERO_WALL_COLUMNS[1].left; // 1214.4
  const ZOOM = isMobile || reduced ? 1 : Math.max(1, (vw - ZOOM_MARGIN * 2) / (midW * u));
  const gu = u * ZOOM;
  // Spread over ~1.5 screens of scrolling for a gradual push-in; the sEnd
  // cap is defined below, so it's applied in the scroll effect.
  const ZOOM_SCREENS = 1.5;
  const zoomSpan = vh * ZOOM_SCREENS;
  // Centre of the middle three columns, in zoomed-layout px. Mobile: the
  // screen centre, so the zoom's recentring shift is zero (no side pan).
  const midCx = isMobile ? vw / 2 : ((HERO_WALL_COLUMNS[1].left + HERO_WALL_COLUMNS[3].left + WALL_TILE_W) / 2) * gu;
  // Wall's on-screen height once fully zoomed = colH × ZOOM.
  // Mobile: sized to the column that actually ends lowest once each
  // column's drift is applied (the staggered right column runs ahead, so
  // the left one sets the bottom) — no spare buffer, so the next section
  // follows on closely. Per column: galleryTop + bottom − (P − d)·sEnd = H.
  const mobileSectionH = () => Math.max(vh, ...columns.map((c, i) => {
    const b = (c.top + c.tiles.length * (WALL_TILE_H + WALL_GAP) - WALL_GAP) * gu;
    const k = PARALLAX - (colDrift[i] || 0);
    return (galleryTop + b + k * vh) / (1 + k);
  }));
  const sectionH = isMobile && PARALLAX ? mobileSectionH()
    : PARALLAX
    ? Math.max(vh, (galleryTop + colH * ZOOM + PARALLAX * vh) / (1 + PARALLAX))
    : galleryTop + colH * ZOOM;
  const sEnd = Math.max(0, sectionH - vh);
  // Finish the zoom before the wall's hand-off point (sEnd) on any screen.
  const zoomEnd = Math.max(1, Math.min(zoomSpan, sEnd * 0.95));

  useEffect(() => {
    // On touch screens the browser's address bar collapses/expands while
    // scrolling, changing innerHeight — ignore height-only changes there
    // so the centred name and the wall don't jump mid-scroll.
    const touch = window.matchMedia && window.matchMedia("(pointer: coarse)").matches;
    let lastW = viewW();
    const onResize = () => {
      const w = viewW();
      setVw(w);
      if (!touch || w !== lastW) setVh(window.innerHeight);
      lastW = w;
    };
    window.addEventListener("resize", onResize);
    // The scrollbar appears after first paint (once the page is long
    // enough) without firing a resize, so watch the layout width directly.
    const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(onResize) : null;
    if (ro) ro.observe(document.documentElement);
    return () => { window.removeEventListener("resize", onResize); if (ro) ro.disconnect(); };
  }, []);

  useEffect(() => {
    if (reduced) return;
    const id = requestAnimationFrame(() => requestAnimationFrame(() => setEntered(true)));
    return () => cancelAnimationFrame(id);
  }, []);

  // Scroll-driven, written straight to the element (not React state) so it
  // stays on the compositor. Driven from Lenis's own scroll callback, which
  // fires inside the same frame Lenis moves the page — a window "scroll"
  // listener only hears about it a frame later, which left the wall
  // trailing the page by one frame (felt as judder, since the wall moves
  // at a different speed from everything around it).
  useEffect(() => {
    let raf = 0;
    const apply = () => {
      raf = 0;
      const y = Math.max(window.scrollY, 0);
      // Name fades out ahead of the top edge: starts once its top is ~22%
      // of the way down the screen, gone just as it reaches the top.
      if (nameRef.current) {
        // Mobile: the work starts right under the name and rises over it
        // within the first ~quarter screen, so fade it over that instead.
        const fadeFrom = isMobile ? 0 : nameTop - 0.22 * vh;
        const fadeTo = isMobile ? 0.25 * vh : nameTop + 0.1 * nameH;
        const fade = (y - fadeFrom) / (fadeTo - fadeFrom);
        const op = String(1 - Math.min(1, Math.max(0, fade)));
        nameRef.current.style.opacity = op;
        // Mobile tagline fades with the name.
        if (taglineRef.current) taglineRef.current.style.opacity = op;
      }
      if (!PARALLAX) return;
      // Shared travel: 0.5× until the wall's bottom meets the section's
      // bottom (sEnd, still below the fold), then a gentler TAIL× so the
      // images keep drifting until they're off screen instead of locking
      // to the page. Past sEnd the wall only ever pulls *up* from the next
      // section (a little extra space above the quote), never into it.
      // Mobile: much gentler, so little gap opens above "About me".
      const TAIL = isMobile ? 0.05 : 0.2;
      const travel = PARALLAX * Math.min(y, sEnd) + TAIL * Math.max(0, y - sEnd);
      // Zoom progress, eased (smoothstep). Scale goes 1/ZOOM → 1 on the
      // full-size layer; x shifts the middle-three centre from where it
      // sits in the Figma layout to the middle of the screen.
      const zt = Math.min(1, Math.max(0, y / zoomEnd));
      const zp = zt * zt * (3 - 2 * zt);
      const scale = (1 + (ZOOM - 1) * zp) / ZOOM;
      const dx0 = -midCx * (1 - 1 / ZOOM), dx1 = vw / 2 - midCx;
      const dx = dx0 + (dx1 - dx0) * zp;
      galleryRefs.current.forEach(g => {
        if (g) g.style.transform = `translate3d(${dx}px, ${-travel}px, 0) scale(${scale})`;
      });
      // Per-column drift on top of that: positive = lags behind (slower),
      // negative = runs ahead. Unclamped, so the columns keep slipping
      // against each other all the way out. The two tallest columns (1,
      // 3) set where the wall ends, so 1 stays at 0 and 3 only runs ahead;
      // the shorter columns have the slack to lag, and every lag is below
      // TAIL, so no column ever drops back past the section bottom.
      colRefs.current.forEach(layer => layer.forEach((el, i) => {
        // ÷ scale: the columns sit inside the scaled wall layer, so this
        // keeps the drift's on-screen size the same at any zoom.
        if (el) el.style.transform = `translate3d(0, ${(y * (colDrift[i] || 0)) / scale}px, 0)`;
      }));
    };
    // Fallback for native scroll (no Lenis yet, or none at all): batch to
    // the next frame. Once Lenis is up, it drives `apply` synchronously.
    const onScroll = () => { if (!raf) raf = requestAnimationFrame(apply); };
    let offLenis = null, waitRaf = 0;
    const attachLenis = () => {
      const lenis = window.__lenis;
      if (lenis && lenis.on) {
        window.removeEventListener("scroll", onScroll);
        offLenis = lenis.on("scroll", apply);
        apply();
      } else {
        waitRaf = requestAnimationFrame(attachLenis);
      }
    };
    apply();
    window.addEventListener("scroll", onScroll, { passive: true });
    attachLenis();
    return () => {
      window.removeEventListener("scroll", onScroll);
      cancelAnimationFrame(raf); cancelAnimationFrame(waitRaf);
      if (typeof offLenis === "function") offLenis();
    };
  }, [sEnd, PARALLAX, nameTop, nameH, vh, vw, ZOOM, midCx, zoomEnd, colDrift, isMobile]);

  // Load sequence: the name rises letter by letter from its baseline
  // first; once the last letter has landed the columns rise in from below
  // the fold (centre-out, vivmgmt.com-style), and the header copy follows
  // as they settle.
  const EASE = "cubic-bezier(0.22, 1, 0.36, 1)";
  const NAME_START = 0.15, LETTER_STAGGER = 0.055, LETTER_DUR = 0.9;
  const NAME_LETTERS = "Elspeth".length + "Belden".length;
  const COL_DUR = 1.9;
  // Columns set off as the last letter starts rising (~0.8s) rather than
  // after it lands — they enter from below the fold, so the name is
  // complete by the time they reach it.
  const colStart = NAME_START + (NAME_LETTERS - 1) * LETTER_STAGGER;
  const colDelay = (isMobile ? [0, 0.12] : [0.24, 0.08, 0, 0.16, 0.32]).map(d => colStart + d);
  const headerDelay = colStart + 0.9;

  // Mobile: the two words together measure ~4.76em, so /5 fills the width
  // with roughly a word space between them.
  const nameSize = isMobile ? `${(vw - 40) / MOBILE_NAME_DIV}px` : `${242.44 * u}px`;
  // Letter-by-letter rise from the baseline (same idea as the quote's
  // word rise). Each letter's mask is a clip-path rather than overflow
  // hidden: generous on the sides and top so serifs/ascenders are never
  // trimmed, with its bottom edge just under the descenders (the "p") —
  // the letter starts below that edge and slides up into view.
  const nameWord = (word, offset) => (
    <span style={{ display: "inline-block", whiteSpace: "nowrap" }}>
      {word.split("").map((ch, i) => (
        <span key={i} style={{ display: "inline-block", clipPath: "inset(-60% -40% -0.28em -40%)" }}>
          <span style={{
            display: "inline-block",
            // 1.5em clears the mask fully: the line box is only 0.88em but
            // ascenders sit above it, so a smaller drop left their tips
            // peeking under the mask edge before the rise.
            transform: entered ? "translateY(0)" : "translateY(1.5em)",
            transition: reduced ? "none" : `transform ${LETTER_DUR}s ${EASE} ${NAME_START + (offset + i) * LETTER_STAGGER}s`,
          }}>{ch}</span>
        </span>
      ))}
    </span>
  );

  // Header copy reveals the way the old hero's intro row did: the
  // paragraph word by word (renderStaggeredWords: fade + 12px rise, 80ms
  // apart), then "Latest work" at +400ms and "Let's talk" at +600ms —
  // all offset to start once the columns are mostly in.
  const headerMs = headerDelay * 1000;
  const linkFade = (ms) => ({
    opacity: entered ? 1 : 0,
    transition: reduced ? "none" : `opacity 650ms cubic-bezier(0.2, 0.8, 0.2, 1) ${headerMs + ms}ms`,
  });
  // RollingLink draws its own underline — no border here.
  const linkStyle = { fontSize: 12, lineHeight: "12px", letterSpacing: "1.44px", color: "var(--ink)" };

  // Gallery — parallax wrapper (scroll) around per-column entrance (load).
  // layer 0 = back (WALL_BEHIND_NAME tiles), 1 = front (the rest). Both
  // keep every tile slot so the columns lay out identically; tiles that
  // belong to the other layer are left as empty, invisible slots.
  const renderGallery = (layer) => (
    <div ref={el => (galleryRefs.current[layer] = el)} aria-hidden="true" style={{
      position: "absolute", top: galleryTop, left: 0, width: "100%", height: colH * ZOOM,
      transformOrigin: `${midCx}px 0px`,
      // Initial state matches the first scroll frame (unzoomed) so there's
      // no jump before the scroll effect runs.
      transform: `translate3d(${-midCx * (1 - 1 / ZOOM)}px, 0, 0) scale(${1 / ZOOM})`,
      willChange: PARALLAX ? "transform" : undefined, zIndex: layer ? 3 : 1,
      pointerEvents: "none",
    }}>
      {columns.map((col, ci) => (
        // Outer: position + per-column scroll drift (set in the scroll
        // effect). Inner: the load-time rise. Kept on separate elements
        // so the two transforms never fight.
        <div key={ci} ref={el => (colRefs.current[layer][ci] = el)} style={{
          position: "absolute",
          // Desktop: Figma's own column x. Mobile: two columns inside
          // 12px margins.
          left: isMobile ? MOBILE_WALL_MARGIN + ci * (WALL_TILE_W + WALL_GAP) * gu : col.left * gu,
          top: col.top * gu,
          width: WALL_TILE_W * gu,
          willChange: PARALLAX ? "transform" : undefined,
        }}>
          <div style={{
            display: "flex", flexDirection: "column", gap: WALL_GAP * gu,
            // × ZOOM: this sits inside the scaled-down layer.
            transform: entered ? "translate3d(0,0,0)" : `translate3d(0, ${(vh + 200) * ZOOM}px, 0)`,
            transition: reduced ? "none" : `transform ${COL_DUR}s ${EASE} ${colDelay[ci]}s`,
          }}>
            {col.tiles.map((tile, ti) => {
              const behind = !isMobile && WALL_BEHIND_NAME(ci, ti);
              const mine = behind === (layer === 0);
              return (
                <div key={ti} style={{
                  position: "relative", width: "100%", aspectRatio: `${WALL_TILE_W} / ${WALL_TILE_H}`,
                  overflow: "hidden", background: mine ? (tile.bg || "transparent") : "transparent",
                  visibility: mine ? "visible" : "hidden",
                }}>
                  {mine && renderWallLayers(tile.layers)}
                </div>
              );
            })}
          </div>
        </div>
      ))}
    </div>
  );

  return (
    <section id="top" style={{ position: "relative", height: sectionH, overflow: "hidden" }}>
      {/* Header (Figma 143:1877): menu + tagline | — | Latest work | Let's talk */}
      <header style={{
        position: "absolute", top: isMobile ? 20 : 29, left: 0, right: 0, zIndex: 4,
        padding: isMobile ? "0 20px" : "0 32px",
        display: "grid",
        gridTemplateColumns: isMobile ? "auto 1fr auto" : "repeat(4, minmax(0, 1fr))",
        columnGap: isMobile ? 24 : 40,
        rowGap: 24,
        alignItems: "start",
      }}>
        <div style={{ display: "flex", flexDirection: "column", gap: 40, gridColumn: isMobile ? "1" : undefined }}>
          {/* Same E → house mark as the case-study pages' breadcrumb. */}
          <a href="#top" aria-label="Home" style={{ display: "block", width: 24, height: 24, color: "var(--ink)", ...linkFade(0) }}
            onClick={(e) => { e.preventDefault(); if (window.__lenis) window.__lenis.scrollTo(0); else window.scrollTo({ top: 0, behavior: "smooth" }); }}>
            <BrandMark size={24} />
          </a>
          {!isMobile && (
            // nowrap: only ever breaks at the <br> (after "organisations").
            <p style={{ fontFamily: "'Geist', system-ui, sans-serif", fontSize: 22, lineHeight: 1.3, letterSpacing: "-0.3px", color: "var(--ink)", margin: 0, maxWidth: 495, whiteSpace: "nowrap" }}>
              {renderStaggeredWords("I help complex organisations", entered, headerMs)}
              <br />
              {renderStaggeredWords("ship products that feel simple.", entered, headerMs + 4 * 80)}
            </p>
          )}
        </div>
        {!isMobile && <div />}
        <div className="mono" style={{ display: "flex", justifyContent: "flex-end", padding: "7px 0", ...linkFade(400) }}>
          <RollingLink href={`#${CASE_STUDIES[0].id}`} style={linkStyle}>Latest work</RollingLink>
        </div>
        <div className="mono" style={{ display: "flex", justifyContent: "flex-end", padding: "7px 0", ...linkFade(600) }}>
          <RollingLink href="#contact" style={linkStyle}>Let's talk</RollingLink>
        </div>
      </header>

      {/* Mobile tagline (Figma 173:23): sits just above the name rather
          than in the header — 20px / 30px, ~52px clear of the name. */}
      {isMobile && (
        <p ref={taglineRef} style={{
          position: "absolute", left: 20, right: 20, top: nameTop - 52 - 2 * 30, zIndex: 2,
          fontFamily: "'Geist', system-ui, sans-serif", fontSize: 20, lineHeight: "30px", letterSpacing: "-0.3px",
          color: "var(--ink)", margin: 0, whiteSpace: "nowrap",
        }}>
          {renderStaggeredWords("I help complex organisations", entered, headerMs)}
          <br />
          {renderStaggeredWords("ship products that feel simple.", entered, headerMs + 4 * 80)}
        </p>
      )}

      {/* Back layer: corner tiles only, under the name. */}
      {renderGallery(0)}

      {/* Name (Figma 141:1024) — scrolls 1:1, between the two wall layers;
          fades as it leaves the top of the screen (scroll effect above). */}
      <h1 ref={nameRef} style={{
        // Mobile: above both wall layers, so the work passes under the name.
        position: "absolute", top: nameTop, left: 0, right: 0, zIndex: isMobile ? 4 : 2,
        padding: isMobile ? "0 20px" : `0 ${24 * u}px`,
        margin: 0,
        display: "flex", justifyContent: "space-between", alignItems: "flex-start",
        fontFamily: "var(--font-name)", fontWeight: 200,
        // -0.044em matches Figma's letter positions with the name split
        // into per-letter spans (which drops kerning, ~0.007em wider than
        // the whole-word text) — measured to restore the gaps between the
        // "h"/"B" and the middle column.
        fontSize: nameSize, lineHeight: 0.88, letterSpacing: "-0.044em",
        color: "#1a1a1a", pointerEvents: "none",
      }}>
        {nameWord("Elspeth", 0)}
        {nameWord("Belden", "Elspeth".length)}
      </h1>

      {/* Front layer: every other tile, over the name. */}
      {renderGallery(1)}
    </section>
  );
}

function Hero() {
  const [layout, setLayout] = useState(window.__tweaks.heroLayout);
  useEffect(() => {
    const onChange = (e) => setLayout(e.detail.heroLayout);
    window.addEventListener('tweaks-changed', onChange);
    return () => window.removeEventListener('tweaks-changed', onChange);
  }, []);

  if (layout === "split") return <HeroSplit />;
  if (layout === "marquee") return <HeroMarquee />;
  return <HeroStacked />;
}

function HeroStacked() {
  const isMobile = useIsMobile();
  const HERO_IMAGES = isMobile ? MOBILE_HERO_IMAGES : DESKTOP_HERO_IMAGES;
  const [loaded, setLoaded] = useState(false);
  // Starts on the intro's final image (it lands on the last one) so the
  // intro can cut straight to the hero with no visible change.
  const [activeImg, setActiveImg] = useState(() => willPlayIntro() ? HERO_IMAGES.length - 1 : 0);
  // The paragraph + nav row reveals on its own signal — 'intro-top-reveal',
  // fired the instant the intro's photo fills the viewport — rather than
  // tagging along on `loaded` above (which fires earlier, at
  // 'intro-reveal', for the background/name/letter-stagger) or waiting for
  // 'intro-settle' (much later: only once the photo has also faded and the
  // white "Approach" section is on its way up).
  const [introRowRevealed, setIntroRowRevealed] = useState(() => !willPlayIntro());
  // Full-screen for the duration of the splash (so the wordmark clone's
  // measured position lines up cleanly with the viewport), settling back
  // to the normal 92vh the moment the white "Approach" section pops up —
  // part of the same push-up beat as that section's own entrance.
  const [fullHeight, setFullHeight] = useState(() => willPlayIntro());
  const heroRef = useRef(null);
  // Same scroll-linked reveal as the case study covers: the carousel is
  // static, and scrolling past the hero pans it down and fades it out.
  const scrollProgress = useHeroScrollProgress(heroRef);
  const heroHeight = heroRef.current ? heroRef.current.getBoundingClientRect().height : 0;
  const scrollY = scrollProgress * heroHeight * 0.7;
  const scrollOpacity = mapRange(scrollProgress, [0, 0.5, 1], [1, 1, 0]);
  useEffect(() => {
    // Normally trigger the loading animation on next frame so transitions
    // apply. But while the intro splash is covering the page, its own
    // reveal animations (background scale/blur, nav-row fade, name
    // stagger — all untouched, unmodified) should only actually start
    // once the splash is ready to uncover them, not get a head start
    // hidden behind it. IntroOverlay sets this flag synchronously before
    // this effect runs, and fires 'intro-reveal' when it's ready.
    if (window.__introActive) {
      const onReveal = () => setLoaded(true);
      window.addEventListener('intro-reveal', onReveal);
      return () => window.removeEventListener('intro-reveal', onReveal);
    }
    const id = requestAnimationFrame(() => setLoaded(true));
    return () => cancelAnimationFrame(id);
  }, []);
  useEffect(() => {
    if (introRowRevealed) return;
    const onTopReveal = () => setIntroRowRevealed(true);
    window.addEventListener('intro-top-reveal', onTopReveal);
    return () => window.removeEventListener('intro-top-reveal', onTopReveal);
  }, [introRowRevealed]);
  useEffect(() => {
    // Gentle cycle every 5s with a long crossfade — held until the intro
    // has handed off, so the hero is still on the intro's image at the cut.
    let t;
    const start = () => {
      t = setInterval(() => {
        setActiveImg(i => (i + 1) % HERO_IMAGES.length);
      }, 5000);
    };
    if (window.__introActive) {
      window.addEventListener('intro-hero-settle', start, { once: true });
    } else {
      start();
    }
    return () => {
      window.removeEventListener('intro-hero-settle', start);
      clearInterval(t);
    };
  }, []);
  useEffect(() => {
    if (!fullHeight) return;
    // Waits for 'intro-hero-settle' (dispatched once the intro clone has
    // actually unmounted), not the earlier 'intro-settle' — so the whole
    // 900ms shrink plays out visibly instead of starting hidden behind
    // the still-animating clone.
    const onSettle = () => setFullHeight(false);
    window.addEventListener('intro-hero-settle', onSettle);
    return () => window.removeEventListener('intro-hero-settle', onSettle);
  }, [fullHeight]);
  const restingHeight = isMobile ? `100${VH}` : `92${VH}`;
  return (
    <section ref={heroRef} style={{
      minHeight: fullHeight ? `100${VH}` : restingHeight,
      height: fullHeight ? `100${VH}` : restingHeight,
      // A gentler curve than the page's usual cubic-bezier(0.2, 0.8, 0.2, 1)
      // on purpose: that one reaches ~80% of its travel in the first 20% of
      // its duration, which (coinciding with the intro clone unmounting)
      // read as an instant snap rather than a 900ms shrink.
      transition: fullHeight ? undefined : "height 900ms cubic-bezier(0.4, 0, 0.2, 1), min-height 900ms cubic-bezier(0.4, 0, 0.2, 1)",
      padding: 0,
      display: "flex",
      flexDirection: "column",
      position: "relative",
      overflow: "hidden",
      color: "#F4F1EC",
    }}>
      {/* Background carousel — scroll-driven pan/fade wrapper (no
          transition, tracks scroll directly) wraps the load-in wrapper
          (scale/blur zoom-in, which keeps its own eased transition). */}
      <div style={{
        position: "absolute", inset: 0,
        zIndex: 0,
        transform: `translateY(${scrollY}px)`,
        opacity: scrollOpacity,
        willChange: "transform, opacity",
      }}>
        <div style={{
          position: "absolute", inset: 0,
          transform: loaded ? "scale(1)" : "scale(1.25)",
          filter: loaded ? "blur(0px)" : "blur(20px)",
          opacity: loaded ? 1 : 0,
          transition: "transform 1800ms cubic-bezier(0.2, 0.8, 0.2, 1), filter 1400ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 1400ms ease-out",
          willChange: "transform, filter, opacity",
          // Fallback color in case images haven't loaded
          background: "#1F1A14",
        }}>
          {HERO_IMAGES.map((src, i) => (
            <div
              key={i}
              style={{
                position: "absolute",
                inset: 0,
                backgroundImage: `url("${src}")`,
                backgroundSize: "cover",
                backgroundPosition: "center",
                opacity: i === activeImg ? 1 : 0,
                transition: "opacity 1800ms ease-in-out",
              }}
            />
          ))}
        </div>
      </div>

      {/* Darken for legibility — static, not tied to `loaded`. This whole
          hero sits behind the intro overlay's own opaque curtain until
          long after this div's own transition would have finished, so
          animating it here was invisible: by the time the curtain lifts,
          it's already settled. The intro overlay renders this identical
          gradient as a permanent, unanimated layer over its own growing
          photo (see IntroOverlay) so the two always match and the
          handoff has nothing left to fade. */}
      <div style={{
        position: "absolute", inset: 0,
        background: "linear-gradient(180deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.1) 40%, rgba(0,0,0,0.55) 100%)",
        zIndex: 1,
      }} />

      {/* Extra darkening behind the mobile foreground content, on top of the
          hero-wide gradient above, since that one alone wasn't enough
          contrast for this text specifically. */}
      {isMobile && (
        <div style={{
          position: "absolute", left: 0, right: 0, bottom: 0,
          height: "38%",
          background: "linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.55) 100%)",
          zIndex: 2,
          pointerEvents: "none",
        }} />
      )}

      {/* Four equal columns: the statement now spans the first two (it
          needs the room — at a single column's width each line was
          re-wrapping mid-phrase instead of breaking evenly at the
          intended spot), then one nav link per remaining column. */}
      <div className="hero-intro-row">
        <div className="hero-intro-copy">
          <p>
            {renderStaggeredWords("I help complex organisations", introRowRevealed, 0)}
            <br />
            {renderStaggeredWords("ship products that feel simple.", introRowRevealed, 4 * 80)}
          </p>
        </div>
        {/* The two links reveal in sequence (200ms apart), not together —
            desktop only. Mobile has no room for "Latest work" alongside
            the copy, and the footer (the other way to reach "Let's
            talk") sits a long scroll away, so mobile keeps just that one
            link, pinned to the top-right corner instead of trailing
            below the copy. */}
        {!isMobile && (
          <div className="hero-intro-action" style={{
            opacity: introRowRevealed ? 1 : 0,
            transition: "opacity 650ms cubic-bezier(0.2, 0.8, 0.2, 1) 400ms",
          }}>
            <RollingLink href={`#${CASE_STUDIES[0].id}`} className="mono hero-intro-link">
              Latest work
            </RollingLink>
          </div>
        )}
        <div
          className={isMobile ? "hero-intro-action hero-intro-action-mobile" : "hero-intro-action"}
          style={{
            opacity: introRowRevealed ? 1 : 0,
            transition: `opacity 650ms cubic-bezier(0.2, 0.8, 0.2, 1) ${isMobile ? 400 : 600}ms`,
          }}
        >
          <RollingLink href="#contact" className="mono hero-intro-link">
            Let's talk
          </RollingLink>
        </div>
      </div>

      <div className="hero-spacer" />

      {/* Full-width name moves to the bottom while keeping the existing
          staggered letter entrance and responsive single-line treatment. */}
      <h1 className="hero-name">
        <span className="hero-name-word">{renderStaggeredLetters("Elspeth", loaded, 600, { tracking: "-0.022em" })}</span>
        <span className="hero-name-word">{renderStaggeredLetters("Belden", loaded, 845, { tracking: "-0.022em" })}</span>
      </h1>

      <style>{`
        .hero-intro-row {
          position: relative;
          z-index: 3;
          display: grid;
          grid-template-columns: repeat(4, 1fr);
          width: 100%;
          height: 302px;
          margin-top: 29px;
          padding: 7px 32px;
          color: inherit;
        }

        .hero-intro-copy {
          grid-column: span 2;
        }

        .hero-intro-copy p {
          /* No max-width here on purpose — the column itself (now 2 of 4
             tracks, not 1) is what each line should fit within; a ch-based
             cap narrower than that was forcing "I help complex
             organisations" to re-wrap a second time instead of landing on
             its own single, even line. white-space: nowrap guarantees
             each of the two explicit lines stays exactly one line,
             regardless of width. */
          margin: 0;
          color: inherit;
          font-family: var(--font-display);
          font-size: clamp(20px, 2.2vw, 30px);
          font-weight: 200;
          line-height: 1.3;
          white-space: nowrap;
        }

        .hero-intro-action {
          display: flex;
          align-items: flex-start;
          justify-content: flex-end;
          padding: 7px 0;
        }

        .hero-intro-link {
          color: inherit;
          padding-bottom: 4px;
        }

        .hero-spacer {
          flex: 1;
        }

        .hero-name {
          position: relative;
          z-index: 2;
          display: flex;
          justify-content: space-between;
          width: 100%;
          margin: 0;
          padding: 0 32px 32px;
          color: inherit;
          font-family: var(--font-name);
          font-size: clamp(58px, 14.5vw, 270px);
          font-weight: 200;
          line-height: 0.88;
          letter-spacing: -0.022em;
          white-space: nowrap;
        }

        .hero-name-word {
          white-space: nowrap;
        }

        @media (max-width: 767px) {
          .hero-intro-row {
            height: auto;
            min-height: 230px;
            margin-top: 20px;
            padding: 7px 20px;
            row-gap: 20px;
            grid-template-columns: 1fr 1fr;
          }

          .hero-intro-copy {
            grid-column: 1 / -1;
          }

          .hero-intro-copy p {
            font-size: 17px;
          }

          /* Detached from the grid flow entirely — pinned to the row's
             own top-right padding edge so it reads as a persistent nav
             link rather than a second line trailing under the copy.
             top/right match the row's own padding (7px 20px) exactly —
             an absolutely positioned child's containing block is the
             padding BOX, whose edge sits flush with the row's outer
             edge, not inset by that padding, so 0/0 here would ignore
             it and run the link off the screen's right edge. */
          .hero-intro-action-mobile {
            position: absolute;
            top: 7px;
            right: 20px;
          }

          .hero-name {
            justify-content: flex-start;
            gap: 0.28em;
            padding: 0 20px 28px;
            /* "Elspeth Belden" (incl. the gap above) renders at ~5.04x its
               own font-size at this tracking — 4.476 undersized that,
               letting "Belden" run past the right edge on every mobile
               width instead of landing flush with the same 20px the left
               side already gets. */
            font-size: calc((100vw - 40px) / 5.04);
          }
        }
      `}</style>
    </section>
  );
}

function HeroSplit() {
  return (
    <section style={{
      minHeight: "100vh",
      padding: "140px 0 64px",
      display: "grid",
      gridTemplateColumns: "1fr 1fr",
      position: "relative",
    }}>
      {/* Left: image placeholder */}
      <div style={{
        padding: "0 0 0 32px",
        display: "flex", alignItems: "center",
      }}>
        <ImagePlaceholder label="portrait / studio shot" aspect="3/4" full tint="warm" />
      </div>

      {/* Right: type */}
      <div style={{
        padding: "0 32px 0 64px",
        display: "flex", flexDirection: "column", justifyContent: "space-between",
      }}>
        <div className="mono" style={{ color: "var(--ink-soft)" }}>
          EB — EXPERIENCE DESIGNER · 2026
        </div>

        <h1 style={{
          fontFamily: "var(--font-display)",
          fontSize: "clamp(64px, 9vw, 160px)",
          lineHeight: 0.92,
          fontWeight: 200,
          letterSpacing: "-0.035em",
          margin: "40px 0",
        }}>
          Products, systems,
          <br />and stories.
        </h1>

        <p style={{
          fontFamily: "var(--font-display)", fontWeight: 200,
          fontSize: 22,
          lineHeight: 1.4,
          maxWidth: "38ch",
          color: "var(--ink-soft)",
        }}>
          I'm Elspeth — an experience lead at{" "}
          Publicis Sapient
          , designing work for Goldman Sachs, NatWest and Bupa.
        </p>
      </div>
    </section>
  );
}

function HeroMarquee() {
  return (
    <section style={{
      minHeight: "100vh",
      padding: "140px 0 64px",
      display: "flex",
      flexDirection: "column",
      justifyContent: "center",
      position: "relative",
      overflow: "hidden",
    }}>
      {/* Marquee rows */}
      {[0, 1, 2].map(row => (
        <div key={row} style={{
          fontFamily: "var(--font-display)",
          fontSize: "clamp(80px, 14vw, 220px)",
          fontWeight: 200,
          lineHeight: 0.9,
          letterSpacing: "-0.04em",
          whiteSpace: "nowrap",
          padding: "8px 0",
          color: row === 1 ? "var(--accent)" : "var(--ink)"
        }}>
          <MarqueeRow
            text={row === 1 ? "Belden — Experience Designer —" : "Elspeth Belden — Experience Designer —"}
            reverse={row === 1}
            speed={row === 1 ? 55 : 80}
          />
        </div>
      ))}

      <div style={{
        position: "absolute", bottom: 40, left: 32, right: 32,
        display: "flex", justifyContent: "space-between", alignItems: "end"
      }}>
        <div className="mono" style={{ color: "var(--ink-soft)" }}>
          PORTFOLIO · 2026
        </div>
        <p style={{
          fontFamily: "var(--font-display)", fontWeight: 200,
          fontSize: 20,
          maxWidth: "38ch",
          textAlign: "right",
          color: "var(--ink-soft)",
        }}>
          Designing for Goldman Sachs, NatWest & Bupa at{" "}
          Publicis Sapient.
        </p>
      </div>
    </section>
  );
}

function MarqueeRow({ text, reverse, speed = 80 }) {
  return (
    <div style={{
      display: "flex",
      animation: `marquee-${reverse ? 'right' : 'left'} ${speed}s linear infinite`
    }}>
      {Array.from({ length: 4 }).map((_, i) => (
        <span key={i} style={{ paddingRight: "0.5em" }}>{text}</span>
      ))}
      <style>{`
        @keyframes marquee-left {
          from { transform: translateX(0); }
          to { transform: translateX(-50%); }
        }
        @keyframes marquee-right {
          from { transform: translateX(-50%); }
          to { transform: translateX(0); }
        }
      `}</style>
    </div>
  );
}

// ─────────────── IMAGE PLACEHOLDER ───────────────

function ImagePlaceholder({ label = "image", aspect = "4/3", full = false, tint = "warm" }) {
  const tints = {
    warm:    { bg: "#E8DFD2", stripe: "#DCCFB9", text: "#6B5E48" },
    cool:    { bg: "#D9DDE2", stripe: "#C5CBD3", text: "#5A6370" },
    sage:    { bg: "#D5DCCC", stripe: "#C3CCB4", text: "#5B6750" },
    accent:  { bg: "#EBD6C6", stripe: "#E0C4AE", text: "#7A4A2B" },
  };
  const c = tints[tint] || tints.warm;
  return (
    <div style={{
      width: full ? "100%" : "100%",
      height: full ? "100%" : "auto",
      aspectRatio: full ? "auto" : aspect,
      background: `repeating-linear-gradient(135deg, ${c.bg} 0 14px, ${c.stripe} 14px 28px)`,
      position: "relative",
      display: "flex", alignItems: "end", justifyContent: "space-between",
      padding: 18,
      overflow: "hidden",
    }}>
      <div style={{
        fontFamily: "var(--font-mono)",
        fontSize: 11,
        letterSpacing: "0.14em",
        textTransform: "uppercase",
        color: c.text,
      }}>
        [ {label} ]
      </div>
      <div style={{
        fontFamily: "var(--font-mono)",
        fontSize: 11,
        letterSpacing: "0.14em",
        color: c.text,
      }}>
        ░░░
      </div>
    </div>
  );
}

// ─────────────── PULL QUOTE ───────────────

// The first white section after the hero. When the intro splash plays, it
// stays hidden below its resting position until a second after the hero's
// own animations have settled, then pops up into place. The hero visibly
// recedes on its own at the same moment (see HeroStacked's fullHeight —
// shrinking it back to 92vh pulls this section up through normal layout
// flow), so there's no separate scroll nudge here. Skips straight to its
// resting state when there's no splash to key off (reduced motion, GSAP
// unavailable).
// Word-by-word rise from the baseline: each word sits in its own mask
// (overflow hidden) and slides up from just below it. The mask is padded
// down by 0.2em (and pulled back with a matching negative margin, so
// line spacing is unchanged) so descenders — the g, p — aren't clipped.
function renderBaselineWords(text, shown, baseDelay = 0, stagger = 90) {
  return text.split(" ").map((word, i) => {
    const delay = baseDelay + i * stagger;
    const mask = (
      <span style={{
        display: "inline-block", overflow: "hidden", verticalAlign: "top",
        paddingBottom: "0.2em", marginBottom: "-0.2em",
      }}>
        <span style={{
          display: "inline-block",
          transform: shown ? "translateY(0)" : "translateY(110%)",
          transition: `transform 900ms cubic-bezier(0.22, 1, 0.36, 1) ${delay}ms`,
        }}>{word}</span>
      </span>
    );
    return (
      <React.Fragment key={i}>
        {word === "messy"
          // The scribble sits outside the word's rise mask (so it isn't
          // clipped) and starts drawing once the word has landed.
          ? <span style={{ position: "relative", display: "inline-block", verticalAlign: "top" }}>
              {mask}
              <MessyScribble play={shown} delay={delay + 700} />
            </span>
          : mask}
        {" "}
      </React.Fragment>
    );
  });
}

// Red scribble over "messy" in the About headline — the hand-drawn
// zigzag from Figma (Port, node 216:3756; source in
// assets/messy-scribble.svg), revealed the same way as the footer's
// "hair like this" squiggle: the filled outline is masked by a stroke
// traced along it. The outline's start has been rotated to the top-left
// tip so it draws top to bottom; tracing out along one edge reveals the
// whole line, so the draw only needs the first half of the outline.
const MESSY_SCRIBBLE_PATH = "M10.261 1.07197C10.2552 0.672964 13.4764 0.254924 19.2244 0.0770034C24.9666 -0.102244 32.773 0.0249441 40.8731 0.527016C54.0963 1.34153 67.2766 2.61306 80.4161 4.22796C81.1051 4.30777 81.7977 4.38931 82.4864 4.47181C87.611 5.08625 92.3639 5.64444 97.1222 6.24415C98.212 6.38154 99.3112 6.52262 100.407 6.66619C108.755 7.7227 124.716 10.5995 133.453 12.4166C133.613 12.449 133.773 12.4815 133.933 12.514C136.014 12.939 137.961 13.3366 140.27 13.8197C140.868 13.945 141.488 14.0754 142.136 14.2129C144.951 14.7971 148.294 15.6773 152.668 16.6652C153.064 16.7535 153.435 16.8185 154.005 16.9452C154.083 16.9634 154.165 16.9828 154.287 17.017C154.35 17.035 154.425 17.0567 154.538 17.0978C154.603 17.1215 154.682 17.1513 154.798 17.207C154.963 17.3186 155.064 17.2364 155.663 17.8929C155.762 18.0139 156.048 18.407 156.146 18.9424C156.262 19.4871 156.124 20.1167 155.934 20.4689C155.74 20.8512 155.506 21.0838 155.33 21.2334C155.214 21.3309 155.112 21.3994 155.023 21.4536C154.636 21.6718 154.588 21.6584 154.455 21.7076C154.269 21.7641 154.175 21.7795 154.1 21.7942C153.944 21.8223 153.857 21.8319 153.766 21.8427C153.43 21.8791 153.182 21.8918 152.921 21.9066C149.11 22.0559 144.82 22.1301 139.483 22.2858C135.984 22.4138 132.48 22.5474 128.96 22.6846C127.914 22.7254 126.845 22.7673 125.773 22.8095C106.114 23.5853 86.4255 24.4096 66.7491 25.0906C54.1425 25.5035 41.2543 25.5204 28.7493 23.558C28.3252 23.5055 27.9042 23.453 27.4985 23.4072C27.2963 23.3844 27.097 23.3632 26.9187 23.348C26.8312 23.3405 26.7468 23.3347 26.6976 23.3327C26.6769 23.3315 26.6564 23.3326 26.7038 23.3309C26.7337 23.3278 26.7573 23.3335 26.9338 23.3019C26.9696 23.295 27.0473 23.2787 27.1383 23.2503C27.2177 23.2235 27.3802 23.1784 27.6335 23.0195C27.8167 22.9159 28.591 22.3302 28.5994 21.2696C28.6017 21.0336 28.5628 20.8158 28.5073 20.6356C28.4534 20.4649 28.4124 20.3798 28.3603 20.2778C28.2593 20.0862 28.1584 19.9587 28.0737 19.8625C27.8053 19.5884 27.7945 19.6454 27.8312 19.6511C27.8727 19.6715 27.9732 19.7112 28.0916 19.7492C28.3283 19.8258 28.6372 19.9028 28.9493 19.9702C29.5795 20.1061 30.2753 20.221 30.9694 20.325C32.3639 20.5321 33.794 20.7027 35.2327 20.8669C38.1142 21.1925 41.006 21.484 43.9104 21.7809C54.2894 22.8384 64.6975 23.6862 75.1191 24.4418C75.7413 24.4834 76.374 24.5255 77.0134 24.5676C89.3671 25.3838 104.711 26.2509 114.351 26.9412C117.101 27.1364 119.653 27.3226 122.035 27.5013C130.249 28.1168 136.443 28.5667 141.739 28.9471C152.307 29.6321 162.889 30.287 173.448 30.8193C175.72 30.9325 177.972 31.0363 180.237 31.1375C181.373 31.1884 182.507 31.2381 183.638 31.2908C184.22 31.3181 184.763 31.3439 185.354 31.3773C185.653 31.3956 185.913 31.407 186.292 31.446C186.318 31.449 186.344 31.4521 186.371 31.4559C186.397 31.46 186.424 31.461 186.543 31.4851C186.602 31.4991 186.666 31.5088 186.822 31.5705C186.904 31.6061 187.011 31.6454 187.198 31.79C187.245 31.8272 187.296 31.8727 187.353 31.9317C187.382 31.9624 187.407 31.9901 187.443 32.0351C187.489 32.0935 187.536 32.1623 187.582 32.2443C187.78 32.5553 187.838 33.1865 187.646 33.5724C187.468 33.9647 187.249 34.1197 187.117 34.217C186.979 34.3116 186.888 34.3493 186.817 34.3788C186.678 34.4333 186.61 34.4457 186.553 34.4589C186.426 34.4842 186.439 34.4789 186.414 34.4832C186.275 34.5018 186.144 34.5078 186.087 34.5112C186.013 34.5152 185.922 34.5191 185.838 34.5221C185.773 34.5244 185.703 34.5266 185.628 34.5287C181.028 34.6057 176.545 34.5887 171.976 34.6073C152.38 34.6623 132.771 34.829 113.208 35.2488C100.943 35.5359 88.5241 35.8324 76.4259 36.6689C73.5638 36.9022 70.5553 37.0894 68.2697 37.6706C68.216 37.6776 67.9802 37.8013 68.1517 37.6962C68.1889 37.6671 68.2462 37.6195 68.316 37.5299C68.3506 37.485 68.3879 37.4292 68.4229 37.3604C68.4622 37.2867 68.5211 37.132 68.5373 36.9852C68.5815 36.6765 68.4658 36.3629 68.3584 36.2127C68.2495 36.0541 68.1671 36.0014 68.1333 35.976C68.0551 35.9352 68.3421 36.0688 68.7392 36.1616C68.9893 36.2242 69.2702 36.2848 69.6153 36.3502C69.938 36.4121 70.4275 36.4929 70.668 36.5297C71.2684 36.623 71.9656 36.7187 72.7603 36.8161C73.4269 36.8976 74.04 36.9666 74.7641 37.0433C80.4013 37.6238 85.8964 37.987 91.7497 38.3516C98.0589 38.7017 104.693 38.9974 110.275 39.223C116.158 39.4636 121.022 39.638 126.026 39.8246C128.083 39.9004 130.022 39.9844 131.851 40.0755C136.466 40.3012 141.287 40.6318 146.065 40.9963C146.562 41.0332 147.064 41.0683 147.581 41.112C147.71 41.1232 147.836 41.1342 147.989 41.1505C148.06 41.1582 148.134 41.1663 148.228 41.1794C148.273 41.1859 148.315 41.1915 148.402 41.2079C148.443 41.2159 148.488 41.2251 148.547 41.2405C148.566 41.2461 148.669 41.2707 148.803 41.3281C148.874 41.3597 148.964 41.4 149.098 41.4931C149.165 41.5406 149.245 41.6022 149.336 41.6965C149.381 41.7437 149.429 41.7993 149.478 41.8667C149.527 41.9374 149.573 41.995 149.654 42.1753C149.803 42.491 149.832 42.9977 149.691 43.3553C149.557 43.7191 149.357 43.918 149.218 44.0386C148.931 44.2702 148.793 44.2974 148.689 44.3401C148.598 44.3707 148.572 44.376 148.527 44.3874C148.448 44.4065 148.394 44.4156 148.344 44.4235C148.255 44.4368 148.23 44.4388 148.176 44.4447C148.065 44.4558 148.012 44.4593 147.934 44.4648C147.761 44.4762 147.673 44.4802 147.515 44.4874C146.482 44.5294 145.499 44.544 144.5 44.5613C142.485 44.5932 140.551 44.6121 138.596 44.63C134.718 44.6644 130.969 44.6873 127.408 44.708C125.417 44.7192 123.408 44.7301 121.578 44.7395C119.554 44.7501 117.682 44.7595 115.959 44.7684C106.239 44.8855 96.5839 44.9998 86.8833 45.1132C86.2353 45.1027 85.5807 45.0916 84.9204 45.0802C76.6454 44.9371 66.4913 45.0275 50.4772 45.1611C44.2354 45.2129 37.0275 45.2721 28.7714 45.3215C27.8022 45.3273 26.9054 45.3324 25.9236 45.3378C19.8088 45.371 16.6422 45.3058 14.079 45.2534C13.3305 45.2379 12.629 45.2235 11.8946 45.213C9.46039 45.1789 6.82513 45.2435 3.79515 45.3603C3.49978 45.373 3.17408 45.3874 2.87265 45.4056C2.72284 45.4148 2.57468 45.4248 2.43181 45.4386C2.37127 45.4446 2.30172 45.4529 2.26875 45.4594C2.25689 45.4614 2.24744 45.4667 2.30255 45.4532C2.35143 45.4354 2.35804 45.452 2.5486 45.3456C2.62908 45.2925 2.75041 45.2246 2.90367 45.0013C3.0431 44.8079 3.10716 44.4783 3.09212 44.3268C3.07449 43.9637 2.9144 43.7588 2.85394 43.6802C2.77126 43.5804 2.73411 43.5558 2.70444 43.5306C2.64861 43.4877 2.64438 43.4886 2.64809 43.4887C2.65987 43.4932 2.71444 43.516 2.77554 43.5374C2.89872 43.5812 3.06011 43.6302 3.22127 43.6751C3.54922 43.7663 3.90611 43.8525 4.27446 43.9368C5.0136 44.1052 5.79811 44.2656 6.61755 44.4283C8.2694 44.7552 10.0438 45.0864 12.0024 45.4576C12.9183 45.6309 13.8695 45.8128 14.8591 46.004C34.5506 49.7368 43.3845 50.4738 50.024 51.1753C51.9747 51.3679 53.7433 51.5356 55.5524 51.7207C61.4176 52.3276 69.7669 53.2567 76.0846 53.9233C81.0924 54.4669 91.1447 55.2074 98.7776 55.6214C101.663 55.782 105.563 56.0387 110.159 56.3133C112.473 56.4516 114.964 56.5947 117.59 56.7335C120.369 56.8805 123.291 57.0167 126.313 57.1277C141.19 57.6569 149.098 57.5923 155.424 57.443C156.626 57.4119 157.771 57.3695 158.916 57.3284C158.919 57.3283 158.911 57.3284 158.937 57.328C158.942 57.3279 158.947 57.3278 158.962 57.3278C158.971 57.3278 158.98 57.3278 159.003 57.3283C159.037 57.3314 159.02 57.3209 159.23 57.3487C159.299 57.3643 159.361 57.3553 159.644 57.4681C159.785 57.5485 160.047 57.5887 160.432 58.145C160.614 58.4202 160.751 58.9127 160.669 59.3445C160.594 59.7787 160.387 60.0644 160.237 60.2288C159.923 60.5513 159.76 60.5899 159.649 60.6475C159.539 60.6944 159.477 60.7117 159.428 60.726C159.332 60.7521 159.291 60.7584 159.256 60.7647C159.136 60.7839 159.13 60.7811 159.107 60.7839C159.072 60.7867 159.066 60.7868 159.058 60.7873C159.035 60.7885 159.037 60.7883 159.033 60.7885C159.026 60.7888 159.029 60.7887 159.028 60.7887C159.028 60.7887 159.028 60.7887 159.028 60.7887C159.028 60.7887 159.027 60.7888 159.027 60.7888C159.026 60.7888 159.025 60.7889 159.024 60.789C159.02 60.7891 159.018 60.7893 159.016 60.7894C159.011 60.7897 159.004 60.7901 158.996 60.7906C158.984 60.7913 158.969 60.7922 158.952 60.7933C158.927 60.7949 158.887 60.7975 158.86 60.7995C158.792 60.8042 158.73 60.809 158.663 60.8142C158.526 60.8249 158.394 60.8361 158.258 60.8478C157.986 60.8717 157.716 60.897 157.434 60.9244C153.422 61.3245 148.633 61.9169 143.625 62.5518C142.02 62.7558 140.447 62.9551 138.919 63.148C130.935 64.156 122.85 65.1466 116.67 65.8734C100.69 67.7012 84.4793 68.5267 68.4687 69.0468C60.2301 69.3531 52.2852 69.5309 46.4579 69.5124C40.5427 69.4973 37.3521 69.2699 37.2702 68.8611C37.3088 68.4477 40.4592 67.8816 46.3492 67.2878C52.1508 66.6981 60.0917 66.1504 68.3331 65.7784C84.9392 65.1203 101.441 64.095 117.934 62.0795C126.401 61.1062 134.696 60.0793 143.191 59.0205C145.799 58.6952 148.382 58.3809 150.982 58.082C152.274 57.9337 153.58 57.7881 154.888 57.6512C155.542 57.583 156.191 57.5174 156.85 57.4554C157.174 57.4249 157.512 57.3944 157.843 57.3666C158.008 57.3528 158.178 57.3391 158.346 57.3266C158.43 57.3204 158.517 57.3142 158.605 57.3084C158.649 57.3055 158.693 57.3027 158.739 57.3001C158.756 57.299 158.789 57.2972 158.809 57.2961C158.817 57.2957 158.837 57.2947 158.848 57.2941C158.856 57.2938 158.857 57.2937 158.868 57.2932C158.873 57.293 158.877 57.2928 158.881 57.2927C158.883 57.2926 158.884 57.2925 158.886 57.2924C158.886 57.2924 158.887 57.2924 158.888 57.2924C158.888 57.2924 158.889 57.2923 158.889 57.2923C158.889 57.2923 158.888 57.2923 158.881 57.2926C158.877 57.2929 158.876 57.2928 158.848 57.2945C158.84 57.295 158.831 57.2955 158.806 57.2976C158.793 57.2988 158.778 57.3001 158.745 57.3042C158.701 57.3123 158.691 57.3019 158.469 57.3607C158.406 57.3805 158.327 57.4003 158.16 57.483C158.018 57.5958 157.627 57.6316 157.272 58.5385C157.112 58.9915 157.222 59.6321 157.443 59.964C157.657 60.3119 157.866 60.452 158.006 60.5462C158.289 60.7195 158.405 60.7346 158.496 60.7646C158.805 60.8378 158.796 60.8148 158.85 60.8234C158.922 60.8275 158.932 60.8265 158.948 60.8269C159.045 60.8264 158.994 60.8264 159.006 60.8264C152.433 61.0536 145.793 61.009 139.212 60.858C131.938 60.6866 124.683 60.3728 117.413 59.9696C110.488 59.5849 103.565 59.1517 96.6446 58.6553C95.1865 58.5508 93.7283 58.4433 92.2705 58.3329C80.3655 57.5583 68.494 56.5328 60.1439 55.6505C53.2489 54.9268 48.2378 54.2499 43.9506 53.6467C41.0003 53.2301 38.3922 52.845 35.7504 52.4739C34.332 52.2744 32.3939 52.0006 30.059 51.6554C25.2051 50.9384 18.632 49.9068 11.4292 48.5928C9.78534 48.2927 8.13391 47.9821 6.43586 47.6332C5.59073 47.4587 4.73674 47.2761 3.86596 47.068C3.4291 46.9631 2.9929 46.8539 2.52963 46.7206C2.30159 46.6544 2.05881 46.581 1.7897 46.4836C1.64467 46.43 1.50961 46.3795 1.3095 46.2837C1.20202 46.2302 1.09384 46.178 0.911918 46.0537C0.820449 45.9888 0.700515 45.903 0.541932 45.7342C0.384814 45.5429 0.0601225 45.2353 0.00196934 44.4486C-0.00911558 44.2459 0.0242432 43.9014 0.162368 43.5938C0.283689 43.3051 0.507359 43.0386 0.674283 42.8995C0.936731 42.6723 1.1947 42.5737 1.27203 42.5432C1.51323 42.455 1.59455 42.4472 1.69154 42.4265C1.8541 42.3969 1.95608 42.3878 2.03995 42.3794C2.22299 42.3625 2.35898 42.3557 2.4953 42.3489C2.76799 42.3362 3.02544 42.3293 3.27866 42.3234C3.78186 42.3121 4.29349 42.3058 4.77725 42.3008C5.77575 42.2907 6.76681 42.2857 7.74659 42.2817C9.71449 42.2741 11.6861 42.2717 13.6324 42.2716C18.2848 42.2722 23.484 42.2901 28.7495 42.3088C30.8798 42.317 33.1126 42.3248 35.2282 42.3329C45.7212 42.371 55.4825 42.4007 60.4172 42.3262C69.0801 42.1952 79.0161 42.161 87.7958 42.129C96.1701 42.0985 103.497 42.0697 107.659 41.9632C112.618 41.836 116.892 41.8302 123.188 41.8192C124.493 41.8168 125.911 41.8139 127.379 41.8101C130.962 41.7991 135.089 41.7842 140.23 41.7313C142.158 41.7104 143.971 41.6918 145.649 41.6625C146.069 41.6549 146.464 41.6471 146.885 41.6353C147.065 41.6303 147.283 41.6233 147.473 41.615C147.629 41.611 147.941 41.5838 147.876 41.5938C147.856 41.5983 147.825 41.6044 147.764 41.6245C147.72 41.64 147.649 41.662 147.525 41.7347C147.411 41.8136 147.171 41.9324 146.99 42.3878C146.907 42.6099 146.893 42.9095 146.961 43.1433C146.993 43.2606 147.039 43.3622 147.087 43.4449C147.117 43.4962 147.148 43.5408 147.178 43.5798C147.299 43.7352 147.401 43.8074 147.476 43.8588C147.761 44.0306 147.811 44.005 147.825 44.0166C147.845 44.0215 147.855 44.0233 147.859 44.0242C147.87 44.0259 147.836 44.0198 147.8 44.0151C147.729 44.0055 147.628 43.9948 147.548 43.9867C147.359 43.968 147.174 43.9521 146.989 43.9365C146.611 43.9051 146.233 43.8758 145.858 43.8459C142.357 43.5616 139.377 43.3173 136.652 43.1223C132.793 42.8448 129.445 42.6426 125.913 42.4845C122.791 42.3458 119.653 42.2206 116.18 42.104C107.119 41.7932 97.9184 41.3817 90.6748 40.8886C88.9144 40.7697 87.1445 40.6494 85.4162 40.5269C83.3481 40.3798 81.5915 40.2492 79.5727 40.0826C76.8366 39.8527 74.2495 39.6199 71.5321 39.2595C70.1999 39.0617 68.954 38.9385 67.3872 38.4381C67.2892 38.4027 67.1949 38.3654 67.1019 38.324C67.0554 38.3033 67.0092 38.2815 66.9629 38.2581C66.9015 38.2253 66.9228 38.2423 66.7558 38.1417C66.5265 37.9814 66.1316 37.7501 65.9963 37.0527C65.9334 36.7285 66.0596 36.3122 66.1559 36.1602C66.2436 36.0005 66.3436 35.8844 66.4367 35.7939C66.8001 35.4565 67.1394 35.3551 67.3824 35.2654C67.538 35.2129 67.7008 35.1664 67.8758 35.1222C68.6863 34.926 69.2146 34.8554 69.8998 34.7578C74.2811 34.2183 77.476 34.155 80.6277 34.0243C81.542 33.9931 82.4598 33.9641 83.3806 33.9349C86.6452 33.7653 89.944 33.6243 93.3227 33.496C93.9029 33.4615 94.4033 33.4291 94.9884 33.3935C97.9213 33.2156 101.526 33.0089 106.066 32.8407C113.219 32.5768 119.349 32.4936 125.996 32.421C131.076 32.3671 136.45 32.3227 142.546 32.2313C146.725 32.1686 151.437 32.0838 156.174 32.0078C161.829 31.9162 167.458 31.838 171.96 31.8155C173.038 31.8101 173.937 31.8078 174.867 31.8078C176.651 31.8084 178.196 31.8489 179.729 31.8875C179.735 31.8877 179.742 31.888 179.749 31.8882C179.851 31.8909 179.953 31.8934 180.052 31.896C181.642 31.878 183.248 31.8612 184.81 31.8275C185.015 31.8228 185.216 31.8177 185.397 31.812C185.611 31.8053 185.795 31.7986 185.956 31.7884C185.979 31.7871 186.05 31.7814 186.046 31.7812C186.046 31.7811 186.044 31.7813 186.036 31.7824C186.032 31.7831 186.03 31.7824 185.985 31.7915C185.936 31.8075 185.889 31.7935 185.646 31.9234C185.534 32.002 185.269 32.1148 185.092 32.6265C184.896 33.1634 185.301 33.7784 185.387 33.8227C185.64 34.0627 185.748 34.0713 185.822 34.1078C185.961 34.1571 185.983 34.1535 186.003 34.1587C186.039 34.1633 185.891 34.1477 185.826 34.1439C185.622 34.1293 185.457 34.1206 185.25 34.1098C184.478 34.0711 183.677 34.0403 182.875 34.0089C179.703 33.8881 176.508 33.7707 173.318 33.6342C168.025 33.408 162.73 33.1461 157.441 32.8711C156.429 32.8274 155.406 32.7824 154.397 32.7373C149.452 32.5166 144.648 32.2873 141.513 32.18C138.268 32.0695 130.332 31.6309 121.794 31.113C121.397 31.0889 120.999 31.0649 120.601 31.041C114.723 30.6881 108.643 30.3497 103.676 30.0952C100.773 29.9465 98.0222 29.7267 95.1925 29.4991C92.5524 29.2866 89.8412 29.0676 86.8731 28.8925C85.3863 28.8048 83.7796 28.7236 82.0647 28.6352C80.555 28.5572 78.9586 28.4735 77.2879 28.3743C75.7354 28.2818 72.2817 28.0213 67.8538 27.6615C65.1174 27.439 62.0085 27.1777 58.7459 26.8928C53.6744 26.5012 48.6033 26.0721 43.5357 25.5917C39.9749 25.2511 36.4388 24.9275 32.8554 24.5157C31.0403 24.3419 29.4507 24.1851 28.1079 23.9801C27.6713 23.9118 27.2444 23.8378 26.7844 23.7194C26.5436 23.6553 26.3098 23.5876 26.0166 23.466C25.7286 23.3319 25.3913 23.2196 24.8811 22.6984C24.754 22.5527 24.5879 22.3445 24.4547 21.9819C24.2516 21.541 24.3111 20.597 24.632 20.1415C24.7797 19.8934 24.9504 19.7159 25.1004 19.5891C25.253 19.4634 25.3192 19.4253 25.4137 19.3684C25.5825 19.2696 25.7434 19.2101 25.8069 19.1881C26.1466 19.0785 26.2333 19.0852 26.3327 19.0682C26.5163 19.0469 26.5895 19.0458 26.6755 19.0416C27.7831 19.0207 28.3651 19.0659 29.2864 19.1105C29.6993 19.1336 30.1435 19.1643 30.6233 19.2029C31.8097 19.2992 33.1727 19.4562 34.0815 19.5895C34.5135 19.6532 34.8226 19.7106 35.1248 19.7643C35.4536 19.8239 35.7652 19.878 36.1279 19.9159C36.3885 19.9431 36.6818 19.9578 37.0146 19.9719C37.5665 19.9959 38.2714 20.0249 39.3546 20.1108C43.3728 20.4315 47.9643 20.5999 52.4909 20.6331C57.5349 20.6726 62.451 20.5605 66.4045 20.4084C66.4627 20.4062 66.5213 20.4039 66.5803 20.4017C70.9795 20.2328 77.238 20.0479 83.4698 19.8564C87.8905 19.7207 92.3058 19.582 96.0972 19.4445C99.8131 19.3097 103.682 19.12 107.427 18.9364C111.922 18.716 116.254 18.504 119.923 18.4075C120.679 18.3875 121.582 18.4139 122.76 18.4453C123.574 18.4684 124.538 18.4936 125.604 18.5101C126.676 18.4679 127.746 18.4262 128.794 18.3858C132.424 18.2461 136.032 18.1134 139.652 17.9887C139.819 17.9743 139.99 17.9596 140.158 17.9448C140.161 17.9445 140.164 17.9442 140.166 17.9439C143.26 17.6652 147.41 17.3488 152.64 17.1518C152.84 17.1406 153.052 17.1269 153.189 17.1134C153.221 17.1104 153.249 17.1069 153.245 17.1077C153.244 17.1082 153.23 17.1102 153.195 17.118C153.141 17.1343 153.105 17.1234 152.809 17.2468C152.703 17.2951 152.56 17.3623 152.359 17.5125C152.206 17.637 151.508 18.1405 151.429 19.2704C151.396 19.8381 151.594 20.3485 151.787 20.6483C151.936 20.8816 152.056 21.0036 152.168 21.1108C152.403 21.3238 152.5 21.3675 152.582 21.4192C152.902 21.5921 152.905 21.5669 152.957 21.5896C153.026 21.6109 153.002 21.6016 152.98 21.5964C152.702 21.5275 152.162 21.4246 151.672 21.3108C151.276 21.2195 150.877 21.1234 150.473 21.0231C148.62 20.56 147.49 20.2044 146.47 19.8925C145.469 19.5855 144.578 19.3108 143.26 18.9987C142.627 18.8492 141.943 18.7021 141.219 18.5597C140.225 18.364 139.148 18.1645 138.01 17.9565C135.256 17.4532 132.173 16.9075 129.095 16.2454C128.886 16.2004 128.661 16.1519 128.427 16.1017C126.199 15.6245 122.891 14.9308 119.62 14.1993C109.826 12.393 99.9929 10.7619 90.141 9.31548C73.7142 6.9085 57.2066 4.9929 40.6549 3.79097C32.6088 3.20355 24.8745 2.69977 19.175 2.27284C13.4712 1.8438 10.2559 1.48076 10.261 1.07197Z";

function MessyScribble({ play, delay = 0 }) {
  const reduced = typeof window !== "undefined" && window.matchMedia
    && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
  const maskPathRef = useRef(null);

  // Measured length + Web Animations API rather than pathLength="1" in
  // CSS, which some browsers (Safari especially) don't apply reliably.
  useLayoutEffect(() => {
    const p = maskPathRef.current;
    if (!p) return;
    const L = p.getTotalLength();
    p.style.strokeDasharray = `${L} ${L}`;
    p.style.strokeDashoffset = reduced ? "0" : `${L}`;
  }, [reduced]);

  useEffect(() => {
    const p = maskPathRef.current;
    if (reduced || !play || !p || !p.animate) return;
    const L = p.getTotalLength();
    // Same shape as the footer's hairDraw: eased draw, tiny overshoot.
    const a = p.animate([
      { offset: 0, strokeDashoffset: `${L}`, opacity: 0.82 },
      { offset: 0.55, opacity: 0.95 },
      { offset: 0.88, strokeDashoffset: `${L * 0.51}`, opacity: 1, easing: "ease-out" },
      { offset: 0.94, strokeDashoffset: `${L * 0.49}` },
      { offset: 1, strokeDashoffset: "0", opacity: 1 },
    ], {
      duration: 1100,
      delay,
      easing: "cubic-bezier(0.76, 0, 0.24, 1)",
      fill: "forwards",
    });
    return () => a.cancel();
  }, [play, reduced]);

  return (
    <svg
      viewBox="0 0 187.764 69.5137"
      aria-hidden="true"
      style={{
        position: "absolute", left: "-0.09em", top: "0.26em",
        width: "2.4em", height: "0.89em",
        overflow: "visible", pointerEvents: "none",
      }}
    >
      <defs>
        <mask id="messy-scribble-mask" maskUnits="userSpaceOnUse" x="-4" y="-4" width="196" height="78">
          <path
            ref={maskPathRef}
            d={MESSY_SCRIBBLE_PATH}
            fill="none"
            stroke="#fff"
            strokeWidth="7"
            strokeLinecap="round"
            strokeLinejoin="round"
          />
        </mask>
      </defs>
      <path
        d={MESSY_SCRIBBLE_PATH}
        // CSS custom properties only resolve in style, not attributes.
        style={{ fill: "var(--accent)" }}
        mask="url(#messy-scribble-mask)"
      />
    </svg>
  );
}

function PullQuote() {
  const isMobile = useIsMobile();
  const [revealed, setRevealed] = useState(() => !willPlayIntro());
  // The quote's word rise waits until it's actually on screen (a third
  // of it visible), once — reduced motion just shows it.
  const quoteRef = useRef(null);
  const [quoteIn, setQuoteIn] = useState(() =>
    !!(window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches));
  useEffect(() => {
    if (quoteIn || !quoteRef.current) return;
    const io = new IntersectionObserver(([e]) => {
      if (e.isIntersecting) { setQuoteIn(true); io.disconnect(); }
    }, { threshold: 0.3 });
    io.observe(quoteRef.current);
    return () => io.disconnect();
  }, [quoteIn]);

  useEffect(() => {
    if (revealed) return;
    const onSettle = () => setRevealed(true);
    window.addEventListener('intro-settle', onSettle);
    return () => window.removeEventListener('intro-settle', onSettle);
  }, [revealed]);

  return (
    <section id="approach" style={{
      // Pulls up 1px to overlap the hero's bottom edge, covering the
      // sub-pixel rounding seam that a vh-based height (hero's resting
      // 92vh) can leave against the next section at certain viewport
      // heights — same fix as the footer's own marginTop below.
      marginTop: "-1px",
      padding: isMobile ? "60px 20px" : "120px 32px",
      opacity: revealed ? 1 : 0,
      transform: revealed ? "translateY(0)" : "translateY(56px)",
      transition: "opacity 900ms cubic-bezier(0.2, 0.8, 0.2, 1), transform 900ms cubic-bezier(0.34, 1.56, 0.64, 1)",
    }}>
      {/* Big display quote — spans the first two of the three columns
          below it; the third is left empty, same "deliberately blank
          column" language as the hero intro row and case-study grid. */}
      <div style={{
        display: "grid",
        gridTemplateColumns: isMobile ? "1fr" : "minmax(0,1fr) minmax(0,3fr) minmax(0,1fr)",
        gap: 40,
        paddingBottom: isMobile ? 56 : 104,
      }}>
        <blockquote ref={quoteRef} style={{
          // Desktop spans all three columns so each half of the line
          // (broken after the comma) sits on a single line.
          gridColumn: isMobile ? "1" : "1 / -1",
          fontFamily: "var(--font-display)",
          // Mobile: 34px keeps the headline to 3 lines down to 360px wide.
          fontSize: isMobile ? 34 : "clamp(40px, 6vw, 96px)",
          lineHeight: 1.12,
          fontWeight: 200,
          letterSpacing: "-0.5px",
          color: "var(--ink)",
          margin: 0,
        }}>
          {isMobile
            ? renderBaselineWords("I design products end to end, and I like untangling the messy bits.", quoteIn, 0)
            : <>
                {renderBaselineWords("I design products end to end,", quoteIn, 0)}
                <br />
                {renderBaselineWords("and I like untangling the messy bits.", quoteIn, 6 * 90)}
              </>}
        </blockquote>
      </div>

      {/* Photo + bio — four equal columns; the bio now spans two of them
          (3 and 4, same "span 2" treatment as the quote above it), so
          only column 2 is left empty for breathing room. */}
      <div style={{
        display: isMobile ? "flex" : "grid",
        flexDirection: isMobile ? "column" : undefined,
        gridTemplateColumns: isMobile ? undefined : "repeat(4, 1fr)",
        gap: isMobile ? 32 : 40,
      }}>
        <div style={{
          gridColumn: isMobile ? undefined : "1",
          // Mobile: 60% width, centred, rather than full-bleed.
          width: isMobile ? "60%" : undefined,
          alignSelf: isMobile ? "center" : undefined,
          aspectRatio: "332 / 416",
          overflow: "hidden",
        }}>
          <image-slot
            placeholder="Elly"
            fit="cover"
            src="assets/About photo.jpg"
            shape="rect"
            style={{ width: "100%", height: "100%", display: "block", transform: "scaleX(-1)" }}
          ></image-slot>
        </div>
        {!isMobile && <div style={{ gridColumn: "2" }} />}
        <div style={{ gridColumn: isMobile ? undefined : "3 / span 2", maxWidth: isMobile ? undefined : 704 }}>
          <div className="mono" style={{
            color: "var(--ink-soft)",
            marginBottom: 24,
            // 13px Geist Mono — the site's small-caps label size (matches
            // "I've also worked with" in the footer).
            fontSize: 13,
            lineHeight: "18.6px",
            letterSpacing: "1.44px",
          }}>
            ABOUT ME
          </div>
          <div style={{
            fontFamily: "'Geist', system-ui, sans-serif",
            fontSize: isMobile ? 20 : 22,
            letterSpacing: "-0.3px",
            lineHeight: 1.3,
            color: "var(--ink)",
          }}>
            <p style={{ margin: "0 0 20px" }}>
              Hi, I’m Elly. I have a visual designer’s eye and a problem solver’s brain. For over a decade I’ve worked across finance, healthcare, retail, the arts and the public sector, usually on products with a lot of complexity behind a simple screen.
            </p>
            <p style={{ margin: "0 0 20px" }}>
              I like to bring a bit of play into serious work, because how a product feels is what people remember.
            </p>
            <p style={{ margin: 0 }}>
              Most recently, I led design on an AI assistant for a global investment bank, from first sketch to launch. 40,000 people now use it every week.
            </p>
          </div>
        </div>
      </div>
    </section>
  );
}

// ─────────────── SELECTED WORK ───────────────

// Tints used both in placeholder + as blurred backdrop
const TINT_COLORS = {
  warm:   { bg: "#E8DFD2", stripe: "#DCCFB9", text: "#6B5E48", solid: "#C9A07A" },
  cool:   { bg: "#D9DDE2", stripe: "#C5CBD3", text: "#5A6370", solid: "#7B8896" },
  sage:   { bg: "#D5DCCC", stripe: "#C3CCB4", text: "#5B6750", solid: "#8FA180" },
  accent: { bg: "#EBD6C6", stripe: "#E0C4AE", text: "#7A4A2B", solid: "#B66B40" },
  costa:  { bg: "#F3E2DA", stripe: "#ECD6CA", text: "#6E1F37", solid: "#B51244" },
  nordanglia: { bg: "#E3EEF5", stripe: "#CDE0EC", text: "#2A5A72", solid: "#0D7EA8", dark: "#060F18", overlay: "rgba(6,14,26,0.48)" },
  goldman: { bg: "#1A2D45", stripe: "#4A6FA3", text: "#5A80B5", solid: "#7297C5", dark: "#0E1E30", overlay: "rgba(10,20,38,0.22)" },
  bupa:    { bg: "#C8E4F5", stripe: "#015A96", text: "#3050A0", solid: "#0179C8", dark: "#011C38", overlay: "rgba(1,28,56,0.42)" },
  natwest: { bg: "#1A0A30", stripe: "#3A1A55", text: "#7A48A0", solid: "#5A287D", dark: "#100820", overlay: "rgba(16,8,30,0.52)" },
};

function SelectedWork() {
  const isMobile = useIsMobile();
  const stackRef = useRef(null);
  const [activeIndex, setActiveIndex] = useState(0);
  // Mobile's sticky "01 / 05" counter waits for the first card's own
  // entrance reveal, so it fades in with that card's text instead of
  // sitting there before anything else has appeared.
  const [firstRevealed, setFirstRevealed] = useState(false);
  // …and fades back out with that card's text when scrolling back up
  // past it (0 = fully shown, 1 = faded out).
  const [firstOpenBack, setFirstOpenBack] = useState(0);

  // Tracked on every viewport size, not just mobile — besides driving the
  // mobile "N / total" indicator below, it's also how each panel knows
  // whether it's the one currently filling most of the screen, so only
  // that one's photo layer reacts to the mouse (see useMouseDrift).
  useEffect(() => {
    let raf = null;
    const onScroll = () => {
      if (raf) return;
      raf = requestAnimationFrame(() => {
        raf = null;
        const el = stackRef.current;
        if (!el) return;
        const rect = el.getBoundingClientRect();
        const perCard = rect.height / CASE_STUDIES.length;
        const scrolledIntoStack = -rect.top;
        const idx = Math.max(0, Math.min(CASE_STUDIES.length - 1, Math.floor(scrolledIntoStack / perCard)));
        setActiveIndex(idx);
      });
    };
    onScroll();
    window.addEventListener('scroll', onScroll, { passive: true });
    return () => {
      window.removeEventListener('scroll', onScroll);
      if (raf) cancelAnimationFrame(raf);
    };
  }, []);

  // Mirrors the last card's own closing fade (see CaseStudyPanel) so the
  // sticky "N / total" indicator — which lives here, not on the card
  // itself — fades out in step with it as the footer arrives, instead of
  // floating on top of the fading/shrinking card underneath it.
  const [footerCloseProgress, setFooterCloseProgress] = useState(0);

  useEffect(() => {
    if (!isMobile) return;
    let raf = null;
    const onScroll = () => {
      if (raf) return;
      raf = requestAnimationFrame(() => {
        raf = null;
        const footer = document.getElementById('contact');
        if (!footer) return;
        const vh = window.innerHeight || 1;
        const rect = footer.getBoundingClientRect();
        // Over the footer's own height (it's shorter than the screen on
        // mobile), so this reaches 1 at the page bottom, in step with the
        // last card's text fade.
        const p = Math.max(0, Math.min(1, (vh - rect.top) / (rect.height || 1)));
        setFooterCloseProgress(p);
      });
    };
    onScroll();
    window.addEventListener('scroll', onScroll, { passive: true });
    window.addEventListener('resize', onScroll);
    return () => {
      window.removeEventListener('scroll', onScroll);
      window.removeEventListener('resize', onScroll);
      if (raf) cancelAnimationFrame(raf);
    };
  }, [isMobile]);

  const activeCard = CASE_STUDIES[activeIndex];

  return (
    <section id="work" style={{ padding: 0 }}>
      {/* Header sits above the immersive panels */}
      <div style={{
        padding: isMobile ? "60px 20px 32px" : "100px 32px 60px",
        display: "grid",
        gridTemplateColumns: isMobile ? "1fr" : "1fr 3fr 1fr",
        gap: 32,
        alignItems: "start",
      }}>
        <div className="mono" style={{
          color: "var(--ink-soft)",
          fontSize: 13,
          lineHeight: "18.6px",
          letterSpacing: "1.44px",
        }}>
          CASE STUDIES
        </div>
        <h2 style={{
          fontFamily: "var(--font-display)",
          fontSize: "clamp(48px, 7vw, 112px)",
          lineHeight: 0.95,
          fontWeight: 200,
          letterSpacing: "-0.035em",
          color: "var(--ink)",
        }}>
          Recent work
        </h2>
        <div />
      </div>

      <style>{`
        .case-thumb image-slot {
          transition: transform 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
        }
        .case-thumb:hover image-slot {
          transform: scale(1.05);
        }
        .case-badge {
          opacity: 0.7;
          transition: opacity 300ms;
        }
        .case-thumb:hover .case-badge {
          opacity: 1;
        }
        /* Goldman thumbnail crops from the right on mobile so the GS mark
           stays in frame, instead of the default centred cover crop. */
        @media (max-width: 767px) {
          #cs-goldman-ai::part(image) {
            position: absolute !important;
            left: 0 !important;
            top: 0 !important;
            width: 100% !important;
            height: 100% !important;
            max-width: none !important;
            transform: none !important;
            object-fit: cover !important;
            object-position: right center !important;
          }
        }
      `}</style>

      {/* Immersive case-study panels — sticky stack.
          The wrapping div gets enough height for all cards to stack,
          and each <article> is position:sticky top:0 so it pins as the next rises over. */}
      <div ref={stackRef} style={{
        position: "relative",
        marginTop: -1,
        // Each card pins for ~80vh of scroll before the next one slides over.
        // Total scroll length = (count - 1) * pinDistance + 1 viewport for the last card.
        // We achieve this naturally by giving each article a height of 100vh
        // (the sticky pin stops when the article's bottom reaches the viewport bottom).
      }}>
        {/* Sticky number — mobile only. Lives outside the card stack so it
            stays pinned top-right for the whole section, updating as the
            active card changes, instead of being tied to one card's pin window. */}
        {isMobile && (
          <div style={{
            position: "sticky", top: 0, height: 0, zIndex: CASE_STUDIES.length + 10, pointerEvents: "none",
            opacity: firstRevealed ? 1 : 0,
            transition: "opacity 700ms ease-out",
          }}>
            <div className="mono" style={{
              position: "absolute",
              top: 20, right: 20,
              color: activeCard.bgImage ? "rgba(244,241,236,0.85)" : "#4A4A48",
              opacity: activeIndex === CASE_STUDIES.length - 1 ? 1 - footerCloseProgress
                : activeIndex === 0 ? 1 - firstOpenBack : 1,
            }}>
              {activeCard.num} / {String(CASE_STUDIES.length).padStart(2, "0")}
            </div>
          </div>
        )}

        {CASE_STUDIES.map((cs, i) => (
          <CaseStudyPanel key={cs.id} cs={cs} index={i} total={CASE_STUDIES.length} isActive={i === activeIndex}
            onReveal={i === 0 ? () => setFirstRevealed(true) : undefined}
            onOpenBack={i === 0 ? setFirstOpenBack : undefined} />
        ))}
      </div>
    </section>
  );
}

// Subtle mouse-reactive drift for the blurred case-study photo layer. The
// photo is oversized (see the inset on its div) so the drift never pulls
// an edge into view, and a CSS transition eases each update so the photo
// trails the pointer instead of snapping straight to it. Only the panel
// currently filling most of the screen (`active`) listens and drifts —
// the rest sit still and ease back to center if they were mid-drift.
function useMouseDrift(active, strength = 16) {
  const ref = useRef(null);
  useEffect(() => {
    const el = ref.current;
    if (!active) {
      if (el) el.style.transform = "translate3d(0px, 0px, 0)";
      return;
    }
    if (window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
    let raf = null;
    const onMove = (e) => {
      if (raf) return;
      raf = requestAnimationFrame(() => {
        raf = null;
        if (!el) return;
        const x = (e.clientX / window.innerWidth - 0.5) * 2;
        const y = (e.clientY / window.innerHeight - 0.5) * 2;
        el.style.transform = `translate3d(${(x * strength).toFixed(2)}px, ${(y * strength).toFixed(2)}px, 0)`;
      });
    };
    window.addEventListener('mousemove', onMove, { passive: true });
    return () => {
      window.removeEventListener('mousemove', onMove);
      if (raf) cancelAnimationFrame(raf);
    };
  }, [active, strength]);
  return ref;
}

function CaseStudyPanel({ cs, index, total, isActive, onReveal, onOpenBack }) {
  const isMobile = useIsMobile();
  const tint = TINT_COLORS[cs.imageTint] || TINT_COLORS.warm;
  const articleRef = useRef(null);
  const driftRef = useMouseDrift(isActive, 16);
  const [revealed, setRevealed] = useState(false);
  useEffect(() => { if (revealed && onReveal) onReveal(); }, [revealed]);
  const isBento = index === 0 && !!cs.bgImage;
  const [bentoProgress, setBentoProgress] = useState(0);

  useEffect(() => {
    // The bento panel triggers its letter-reveal itself, once the reveal
    // animation reaches full width — not on generic scroll-visibility.
    if (isBento) return;
    const el = articleRef.current;
    if (!el) return;
    // Fires partway through the card's slide-in (not right as it first
    // peeks into view, and not only once it's already fully settled) —
    // that's the sweet spot where it's far enough into frame to be the
    // focus of attention but still has room left to visibly cascade in.
    // Then stops watching (the animation shouldn't replay on re-entry).
    const observer = new IntersectionObserver(
      ([entry]) => {
        if (entry.isIntersecting) {
          setRevealed(true);
          observer.disconnect();
        }
      },
      { threshold: 0.6 }
    );
    observer.observe(el);
    return () => observer.disconnect();
  }, [isBento]);

  // Bento-to-full-screen reveal — first case study only. p runs 0 (panel
  // half into view — its top edge is half the viewport down from the
  // top) to 1 (its top edge has reached the very top of the screen, i.e.
  // the moment sticky pinning engages), so the reveal gets more of the
  // scroll-in to play out in rather than being compressed into just the
  // final third — it was starting late enough to feel like nothing was
  // happening for most of the card's entrance. Driven by
  // getBoundingClientRect(), which reflects the panel's actual rendered
  // position regardless of sticky state, so there's no ambiguity once
  // it's pinned the way an offsetTop-based measurement would have.
  useEffect(() => {
    if (!isBento) return;
    let raf = null;
    const onScroll = () => {
      if (raf) return;
      raf = requestAnimationFrame(() => {
        raf = null;
        const el = articleRef.current;
        if (!el) return;
        const vh = window.innerHeight || 1;
        // Mobile opens earlier: starts when the panel's top edge is 3/4 of
        // the way down the screen and is fully open by 1/4 down, rather
        // than only once it reaches the very top.
        const startTop = isMobile ? vh * 0.75 : vh / 2;
        const endTop = isMobile ? vh * 0.25 : 0;
        const p = Math.max(0, Math.min(1, (startTop - el.getBoundingClientRect().top) / (startTop - endTop)));
        setBentoProgress(p);
        // Fires a little into the reveal rather than right as it starts
        // or only once it's finished — still well before the panel
        // settles, so the text visibly cascades in during the motion.
        if (p > 0.2) setRevealed(true);
      });
    };
    onScroll();
    window.addEventListener('scroll', onScroll, { passive: true });
    window.addEventListener('resize', onScroll);
    return () => {
      window.removeEventListener('scroll', onScroll);
      window.removeEventListener('resize', onScroll);
      if (raf) cancelAnimationFrame(raf);
    };
  }, [isBento, isMobile]);

  // Closing bookend on the last case study — as the footer rises into
  // view behind it, this panel shrinks back down to the same 85%-width
  // framed-card look the first case study started at. Driven by the
  // footer's own position (0 = footer not yet visible, 1 = footer fully
  // on screen) rather than this panel's position, since by the time the
  // footer is on screen this panel itself may already be mid-cover.
  const isLast = index === total - 1;
  // Driven by direct ref mutation (see below), not React state — this is
  // the most expensive thing happening on screen while the footer rises
  // (three full-viewport clip-path layers plus two text fades), all
  // stacked on top of the last card's own blurred photo layer. Routing
  // it through setState forced a full re-render of this whole component
  // on every scroll tick, on top of the paint cost of the layers
  // themselves — which was enough to visibly flicker. Mirrors the same
  // ref + rAF pattern useMouseDrift already uses for the same reason.
  const bar1Ref = useRef(null);
  const bar2Ref = useRef(null);
  const bar3Ref = useRef(null);
  const clientColRef = useRef(null);
  const metaColRef = useRef(null);
  const contentWrapRef = useRef(null);

  useEffect(() => {
    if (!isLast) return;
    let raf = null;
    const onScroll = () => {
      if (raf) return;
      raf = requestAnimationFrame(() => {
        raf = null;
        const footer = document.getElementById('contact');
        if (!footer) return;
        const vh = window.innerHeight || 1;
        const rect = footer.getBoundingClientRect();
        // Mobile's footer is shorter than the screen, so the card never
        // fully leaves: it narrows to its framed width (side bars only —
        // no bottom bar, whose red band read as extra space above the
        // footer) and its text fades, both over the footer's own arrival,
        // finishing exactly at the page bottom with the photo still visible.
        if (isMobile) {
          const pm = Math.max(0, Math.min(1, (vh - rect.top) / (rect.height || 1)));
          if (bar2Ref.current) bar2Ref.current.style.transform = `scaleX(${pm})`;
          if (bar3Ref.current) bar3Ref.current.style.transform = `scaleX(${pm})`;
          if (contentWrapRef.current) {
            contentWrapRef.current.style.clipPath = `inset(0 ${pm * sideBarMaxWidth}% 0 ${pm * sideBarMaxWidth}%)`;
          }
          const o = String(1 - pm);
          if (clientColRef.current) clientColRef.current.style.opacity = o;
          if (metaColRef.current) metaColRef.current.style.opacity = o;
          return;
        }
        const p = Math.max(0, Math.min(1, (vh - rect.top) / vh));

        // scaleY/scaleX, not clip-path: clip-path still forces a repaint
        // of the whole (near-fullscreen) layer every frame even when set
        // via a ref outside React — it's the animatable-property fallback
        // for "compositor-only", not an actual member of it. A transform
        // on an already-painted solid-colour rect is composite-only, no
        // repaint, which is what this card's closing sequence needs when
        // it's already sharing the frame with a blurred photo layer and
        // the footer's own marquee animation.
        if (bar1Ref.current) bar1Ref.current.style.transform = `scaleY(${p})`;
        if (bar2Ref.current) bar2Ref.current.style.transform = `scaleX(${p})`;
        if (bar3Ref.current) bar3Ref.current.style.transform = `scaleX(${p})`;
        const textOpacity = String(1 - p);
        if (clientColRef.current) clientColRef.current.style.opacity = textOpacity;
        if (metaColRef.current) metaColRef.current.style.opacity = textOpacity;
        // The bars visually cover the photo because they're opaque and
        // painted above it — but the client-name/meta text sits above the
        // bars too (same z-index, later in the DOM), so it was never
        // actually covered, just fading in place while the "window" around
        // it narrowed, leaving the text looking like it hung off the edge
        // of a now-narrower frame. Clipping the text/thumbnail wrapper to
        // the same, still-open width keeps it visually inside whatever's
        // left of the frame instead of floating outside it. This wrapper
        // has no blurred image or filter in it — just text and a small
        // thumbnail — so clip-path's repaint cost here is negligible,
        // unlike it was on the full-bleed photo layer.
        if (contentWrapRef.current) {
          contentWrapRef.current.style.clipPath =
            `inset(0 ${p * sideBarMaxWidth}% ${p * 10}% ${p * sideBarMaxWidth}%)`;
        }
      });
    };
    onScroll();
    window.addEventListener('scroll', onScroll, { passive: true });
    window.addEventListener('resize', onScroll);
    return () => {
      window.removeEventListener('scroll', onScroll);
      window.removeEventListener('resize', onScroll);
      if (raf) cancelAnimationFrame(raf);
    };
  }, [isLast, isMobile]);

  // Opening bookend in reverse — as the first case study is scrolled
  // back up and out of view, its text fades out the same way the last
  // card's fades out as the footer arrives, just mirrored. Driven by
  // this card's OWN top edge: once un-pinned by scrolling back up past
  // it, a sticky element's rect.top grows from 0 as it's pushed back
  // down the screen, which is the real moment it's being left behind.
  // Before the card has ever actually been reached, though, rect.top
  // sits at some large positive "not scrolled to yet" value that would
  // clamp to the exact same 1 as a genuine exit — hasEnteredRef guards
  // against reading that early, large-but-unrelated value as an exit.
  const [openBackProgress, setOpenBackProgress] = useState(0);
  const hasEnteredRef = useRef(false);

  useEffect(() => {
    if (!isBento) return;
    let raf = null;
    const onScroll = () => {
      if (raf) return;
      raf = requestAnimationFrame(() => {
        raf = null;
        const el = articleRef.current;
        if (!el) return;
        const vh = window.innerHeight || 1;
        const top = el.getBoundingClientRect().top;
        if (top <= 0) hasEnteredRef.current = true;
        // Compressed into a third of a viewport-height of upward scroll
        // (the same distance the forward entry reveal uses) rather than
        // a full one, so the fade is noticeable much sooner after the
        // card starts un-pinning instead of needing a long scroll-up.
        const exitRange = vh / 3;
        const p = hasEnteredRef.current ? Math.max(0, Math.min(1, top / exitRange)) : 0;
        setOpenBackProgress(p);
        if (onOpenBack) onOpenBack(p);
      });
    };
    onScroll();
    window.addEventListener('scroll', onScroll, { passive: true });
    window.addEventListener('resize', onScroll);
    return () => {
      window.removeEventListener('scroll', onScroll);
      window.removeEventListener('resize', onScroll);
      if (raf) cancelAnimationFrame(raf);
    };
  }, [isBento]);

  // On mobile, the smallest (starting) state is a fixed 20px margin each
  // side, converted to a percentage of the real viewport width — not a
  // floor on the open end, which always goes all the way to literal
  // 100% (full-bleed, no margin) on both mobile and desktop.
  const vw = typeof window !== "undefined" ? window.innerWidth : 375;
  const startSide = isMobile ? 100 - (20 / vw) * 100 : 92.5;

  // Everything besides the client name's own letter-stagger (the index
  // label, title and tags) fades in as a block on the bento panel's
  // initial entrance, keyed to the same `revealed` trigger — rather than
  // just appearing instantly while the name is still cascading in.
  const bentoEntranceFade = isBento
    ? { opacity: revealed ? 1 : 0, transition: "opacity 700ms ease-out" }
    : {};

  // How much of each bar is covering (1 = fully covering/framed, 0 = open/
  // revealed) — starts at its smallest margin and opens linearly to
  // full-bleed as bentoProgress runs 0→1. The last panel's bars are the
  // footer's own red, not the page background, so the shrink reads as
  // revealing the footer behind it rather than the page.
  let coverFraction = 0, barColor = "var(--bg)";
  if (isBento) {
    coverFraction = 1 - bentoProgress;
  } else if (isLast) {
    // Open (p=0) starting point — the scroll effect above takes over
    // from here via direct ref mutation (scaleY/scaleX), not re-renders.
    coverFraction = 0;
    barColor = "var(--accent)";
  }
  // Side bars' max width (the fully-covered, coverFraction=1 state) —
  // same 92.5%/mobile-20px-margin starting point as the bento panel's own
  // open margin, just expressed as how much of each edge the bar needs to
  // be able to cover rather than where the card's edge itself sits.
  const sideBarMaxWidth = 100 - startSide;

  return (
    <article
      id={cs.id}
      ref={articleRef}
      style={{
        position: "sticky",
        top: 0,
        height: `100${VH}`,
        minHeight: 640,
        overflow: "hidden",
        display: "flex",
        alignItems: isMobile ? "stretch" : "center",
        justifyContent: "center",
        background: cs.bgImage ? (tint.dark || "#120808") : tint.bg,
        zIndex: index + 1,
        // No shadow on the last panel — that "rising card" shadow is for
        // one case study sliding over the previous one; the footer rises
        // over this one instead, and shouldn't show a shadow of its own.
        boxShadow: (index > 0 && index !== total - 1) ? "0 -20px 60px -10px rgba(0,0,0,0.4)" : "none",
        ...(cs.bgImage && {
          "--ink":      "#F4F1EC",
          "--ink-soft": "rgba(244,241,236,0.75)",
          "--ink-faint":"rgba(244,241,236,0.5)",
          "--line":     "#F4F1EC",
        }),
      }}
    >
      {/* Colour gradient backdrop */}
      <div style={{
        position: "absolute",
        inset: "-10%",
        background: `radial-gradient(ellipse at 30% 40%, ${tint.solid} 0%, ${tint.stripe} 45%, ${tint.bg} 100%)`,
        filter: "blur(80px) saturate(1.1)",
        opacity: cs.bgImage ? 0.30 : 1,
      }} />

      {/* Photo texture — scrolls with the card's own sticky frame rather
          than being pinned to the viewport. (It used to use
          background-attachment:fixed for a "frame reveals a stationary
          backdrop" effect during the slide-in, but a fixed background on
          the same element as the mouse-drift transform below is a known
          conflict: the browser can't cheaply composite a viewport-fixed
          background on a transformed/sticky-descendant layer, so it fell
          back to repainting the full blurred layer on every scroll
          frame — that's what was flickering on the last, busiest card.)
          Oversized via the negative inset (so the mouse-drift transform
          below never pulls a hard edge into frame) and nudged by
          useMouseDrift for a slight parallax reaction to the pointer. */}
      {cs.bgImage && (
        <div ref={driftRef} style={{
          position: "absolute",
          inset: "-5%",
          backgroundImage: `url("${cs.bgImage}")`,
          backgroundSize: "cover",
          backgroundPosition: "center",
          filter: "blur(14px) saturate(0.75)",
          opacity: 0.85,
          zIndex: 1,
          willChange: "transform",
          transition: "transform 600ms cubic-bezier(0.2, 0.8, 0.2, 1)",
        }} />
      )}

      {/* Dark overlay */}
      {cs.bgImage && (
        <div style={{
          position: "absolute", inset: 0,
          background: tint.overlay || "rgba(16,5,5,0.45)",
          zIndex: 1,
          pointerEvents: "none",
        }} />
      )}

      {/* Edge vignette */}
      <div style={{
        position: "absolute", inset: 0,
        background: cs.bgImage
          ? "linear-gradient(to right, rgba(16,5,5,0.5) 0%, rgba(16,5,5,0) 30%, rgba(16,5,5,0) 70%, rgba(16,5,5,0.5) 100%)"
          : "linear-gradient(to right, rgba(244,241,236,0.55) 0%, rgba(244,241,236,0) 30%, rgba(244,241,236,0) 70%, rgba(244,241,236,0.55) 100%)",
        pointerEvents: "none",
      }} />

      {/* Bento bars — solid, page-coloured strips over the photo, each
          sized to its own fully-covering max (10vh-equivalent bottom
          strip, sideBarMaxWidth-wide side strips) and scaled down from
          there with a transform rather than clip-path. clip-path still
          repaints the whole layer it's set on every frame even when
          driven outside React; scaleX/scaleY on an already-painted solid
          rect is composite-only, which is what keeps this cheap while
          it's sharing the frame with the blurred photo layer and (on the
          last card) the footer's own marquee animation arriving behind
          it. Growing from 0 to 1 is what "closes" the last case study as
          the footer arrives; shrinking from 1 to 0 is what "opens" the
          first one. No bottom strip on the sides — the panel's bottom
          edge stays below the fold for the whole move. */}
      {(isBento || isLast) && (
        <>
          {!(isLast && isMobile) && <div ref={bar1Ref} style={{
            position: "absolute", left: 0, bottom: 0, width: "100%", height: "10%",
            background: barColor,
            transformOrigin: "bottom",
            transform: `scaleY(${coverFraction})`,
            willChange: "transform",
            zIndex: 2,
            pointerEvents: "none",
          }} />}
          <div ref={bar2Ref} style={{
            position: "absolute", left: 0, top: 0, width: `${sideBarMaxWidth}%`, height: "100%",
            background: barColor,
            transformOrigin: "left",
            transform: `scaleX(${coverFraction})`,
            willChange: "transform",
            zIndex: 2,
            pointerEvents: "none",
          }} />
          <div ref={bar3Ref} style={{
            position: "absolute", right: 0, top: 0, width: `${sideBarMaxWidth}%`, height: "100%",
            background: barColor,
            transformOrigin: "right",
            transform: `scaleX(${coverFraction})`,
            willChange: "transform",
            zIndex: 2,
            pointerEvents: "none",
          }} />
        </>
      )}

      {/* Three-column composition: client | thumbnail | meta. Clipped to
          the same still-open width as the bars (see the isLast scroll
          effect above, and bentoEntranceFade's coverFraction below) so
          the text doesn't just fade in place while sitting outside a
          frame that's visually narrowed around it — it needs to actually
          disappear at the same edge the bars are closing in from. */}
      <div ref={contentWrapRef} style={{
        position: "relative",
        zIndex: 2,
        width: "100%",
        height: isMobile ? "100%" : undefined,
        display: isMobile ? "flex" : "grid",
        flexDirection: isMobile ? "column" : undefined,
        gridTemplateColumns: isMobile ? undefined : "1fr auto 1fr",
        alignItems: "center",
        gap: isMobile ? 16 : "clamp(16px, 3vw, 40px)",
        padding: isMobile ? "56px 20px 40px" : "0 48px",
        ...((isBento || isLast) && {
          clipPath: `inset(0 ${coverFraction * sideBarMaxWidth}% ${coverFraction * 10}% ${coverFraction * sideBarMaxWidth}%)`,
        }),
      }}>
        {/* Left / Top: client name — vertically centred in the space
            above the thumbnail on mobile. Fades out on its own (not the
            thumbnail, which stays at full opacity): last card as soon as
            the closing bars start moving, first card as it's scrolled
            back up and out of view — the same closing/opening-reversed
            fade, just scoped to text instead of the whole composition. */}
        <div ref={clientColRef} style={{
          flex: isMobile ? 1 : undefined,
          display: isMobile ? "flex" : undefined,
          flexDirection: isMobile ? "column" : undefined,
          justifyContent: isMobile ? "center" : undefined,
          alignItems: isMobile ? "center" : undefined,
          width: isMobile ? "100%" : undefined,
          textAlign: isMobile ? "center" : "left",
          ...(isLast && { opacity: 1 }),
          ...(isBento && { opacity: 1 - openBackProgress }),
        }}>
          {!isMobile && (
            <div className="mono" style={{
              color: "var(--ink-soft)",
              marginBottom: 32,
              fontSize: 13,
              lineHeight: "17.05px",
              letterSpacing: "1.32px",
              ...bentoEntranceFade,
            }}>
              {cs.num} / {String(total).padStart(2, "0")}
            </div>
          )}
          <h3 style={{
            fontFamily: "var(--font-display)",
            fontSize: isMobile ? "48px" : "clamp(48px, 7vw, 112px)",
            lineHeight: 0.95,
            fontWeight: 200,
            letterSpacing: "-0.022em",
            color: "var(--ink)",
          }}>
            {renderStaggeredLetters(cs.client, revealed, 0, { tracking: "-0.022em" })}
          </h3>
        </div>

        {/* Middle: thumbnail */}
        <a
          href={cs.href && !cs.locked ? cs.href : "#"}
          onClick={(e) => { if (!cs.href || cs.locked) e.preventDefault(); }}
          className="case-thumb"
          style={{
            display: "block",
            width: isMobile ? "min(85vw, 380px)" : "clamp(360px, 36vw, 560px)",
            aspectRatio: isMobile ? "1/1" : "4/3",
            position: "relative",
            cursor: (cs.href && !cs.locked) ? "pointer" : "default",
            overflow: "hidden",
            boxShadow: isLast ? "none" : "0 24px 60px -20px rgba(0,0,0,0.3)",
            alignSelf: isMobile ? "center" : undefined,
            flexShrink: isMobile ? 0 : undefined,
            margin: isMobile ? "0 auto" : "0 48px",
          }}
        >
          <image-slot
            id={"cs-" + cs.id}
            placeholder={cs.imageLabel}
            fit={cs.thumbFit || "cover"}
            src={cs.thumbSrc}
            shape="rect"
            style={{ width: "100%", height: "100%", display: "block", background: cs.thumbBg || "var(--bg-alt)" }}
          ></image-slot>
          {cs.locked ? (
            <div className="case-badge" style={{
              position: "absolute",
              bottom: 16, right: 16,
              fontFamily: "var(--font-mono)",
              fontSize: 12,
              lineHeight: "17.05px",
              letterSpacing: "1.32px",
              textTransform: "uppercase",
              color: "rgba(244,241,236,0.75)",
              background: "rgba(26,26,26,0.85)",
              padding: "10px 14px",
              display: "flex",
              alignItems: "center",
              gap: 7,
            }}>
              <svg width="11" height="13" viewBox="0 0 11 13" fill="none" xmlns="http://www.w3.org/2000/svg">
                <rect x="1" y="5.5" width="9" height="7" rx="1.2" stroke="#F4F1EC" strokeWidth="1.4"/>
                <path d="M3 5.5V3.5a2.5 2.5 0 0 1 5 0v2" stroke="#F4F1EC" strokeWidth="1.4" strokeLinecap="round"/>
              </svg>
              Available on request
            </div>
          ) : cs.href && (
            <div className="case-badge" style={{
              position: "absolute",
              bottom: 16, right: 16,
              fontFamily: "var(--font-mono)",
              fontSize: 12,
              lineHeight: "17.05px",
              letterSpacing: "1.32px",
              textTransform: "uppercase",
              color: "rgba(244,241,236,0.75)",
              background: "rgba(26,26,26,0.85)",
              padding: "10px 14px",
              display: "flex",
              alignItems: "center",
              gap: 7,
            }}>
              {cs.protected && (
                <svg width="10" height="12" viewBox="0 0 10 12" fill="none" xmlns="http://www.w3.org/2000/svg">
                  <rect x="0.7" y="5" width="8.6" height="6.6" rx="1.1" stroke="#F4F1EC" strokeWidth="1.3"/>
                  <path d="M2.5 5V3.5a2.5 2.5 0 0 1 5 0V5" stroke="#F4F1EC" strokeWidth="1.3" strokeLinecap="round"/>
                </svg>
              )}
              SEE WORK →
            </div>
          )}
        </a>

        {/* Right / Bottom: title + tags — vertically centred in the
            space below the thumbnail on mobile. Same text-only fade as
            the client name on the left. */}
        <div ref={metaColRef} style={{
          flex: isMobile ? 1 : undefined,
          display: isMobile ? "flex" : undefined,
          flexDirection: isMobile ? "column" : undefined,
          justifyContent: isMobile ? "center" : undefined,
          alignItems: isMobile ? "flex-start" : undefined,
          // Mobile: same width as the square thumbnail above and centred
          // like it, so the text starts on the thumbnail's left edge; the
          // title's own 28ch max-width keeps it from running the full width.
          width: isMobile ? "min(85vw, 380px)" : undefined,
          alignSelf: isMobile ? "center" : undefined,
          // Desktop: extra space between the thumbnail and the title, so
          // titles wrap sooner (the thumbnail stays centred — this is
          // inside the column, not on the thumbnail's own margin).
          paddingLeft: isMobile ? undefined : 48,
          textAlign: isMobile ? "left" : "right",
          ...(isLast && { opacity: 1 }),
          ...(isBento && { opacity: 1 - openBackProgress }),
        }}>
          <h4 style={{
            // Geist Regular, not the serif --font-display the client name
            // and page headings use — a deliberate, fixed choice for this
            // title specifically, matching the client-marquee's own
            // recent switch to Geist.
            fontFamily: "'Geist', system-ui, sans-serif",
            fontSize: "clamp(20px, 2.1vw, 29px)",
            lineHeight: 1.25,
            fontWeight: 400,
            letterSpacing: "-0.3px",
            color: "var(--ink)",
            marginBottom: isMobile ? 12 : 32,
            // Mobile: the text starts 7.5vw in (the thumbnail's left edge)
            // and stops at three-quarters of the way across the screen.
            maxWidth: isMobile ? "67.5vw" : "32ch",
            marginLeft: isMobile ? 0 : "auto",
            marginRight: isMobile ? 0 : undefined,
            ...bentoEntranceFade,
          }}>
            {cs.title}
          </h4>
          {!isMobile && (
            <div className="mono" style={{
              color: "var(--ink-soft)",
              display: "flex",
              flexDirection: "column",
              gap: 8,
              fontSize: 13,
              lineHeight: "17.05px",
              letterSpacing: "1.32px",
              ...bentoEntranceFade,
            }}>
              {cs.tags.map(t => (
                <div key={t}>{t}</div>
              ))}
            </div>
          )}
        </div>
      </div>

      {/* Bottom meta — no "Scroll" cue on the last card, nothing to
          scroll to within the stack anymore. */}
      {index < total - 1 && (
        <div style={{
          position: "absolute",
          bottom: 32, left: 32, right: 32,
          display: "flex",
          justifyContent: "flex-end",
          alignItems: "end",
          zIndex: 3,
        }}>
          <div className="mono" style={{ color: "var(--ink-soft)", fontSize: 13, lineHeight: "17.05px", letterSpacing: "1.32px" }}>
            Scroll ↓
          </div>
        </div>
      )}
    </article>
  );
}

// ─────────────── CONTACT ───────────────

function Contact() {
  const isMobile = useIsMobile();
  // Big name — the same split "Elspeth" / "Belden" construction and size
  // as the hero; shared by the mobile and desktop footer layouts.
  const nameHeading = (
    <h2 style={{
        fontFamily: "var(--font-name)",
        // Kept on one line on mobile too, sized so "Elspeth" + the
        // signature image + "Belden" fill the available width edge to
        // edge — the ratio (100vw minus the 20px side padding, divided
        // by the measured width-per-font-size of this exact string +
        // image combo in Perfektta) solves for the font-size that does
        // that at any mobile viewport.
        // (6.068 rather than 6.008 since mobile's scribble is drawn
        // taller — at the letters' ascender height — and so wider.)
        // Mobile: (100vw − 36px) fills 2px past each 20px margin — about
        // 1% bigger than an exact fit (wrapper below pulls out by 2px).
        fontSize: isMobile ? "calc((100vw - 36px) / 6.068)" : "clamp(58px, 14.5vw, 270px)",
        lineHeight: 0.88,
        fontWeight: 200,
        letterSpacing: "-0.022em",
        margin: 0,
        color: "var(--ink)",
        whiteSpace: "nowrap",
        display: "flex",
        alignItems: "center",
        justifyContent: "space-between",
        width: "100%",
      }}>
        <span style={{ whiteSpace: "nowrap" }}>{renderStaggeredLetters("Elspeth", true, 0, { tracking: "-0.022em" })}</span>
        {/* Mobile matches the letters' ascender height (0.82em), nudged up
            to sit on the letters rather than the centre of the line box. */}
        <AnimatedHair style={isMobile ? { height: "0.82em", transform: "translateY(-0.1em)" } : undefined} />
        <span style={{ whiteSpace: "nowrap" }}>{renderStaggeredLetters("Belden", true, 0, { tracking: "-0.022em" })}</span>
      </h2>
  );
  return (
    <section id="contact" style={{
      position: "relative",
      // Above the case-study stack (max z-index 5) so its solid red
      // covers the last card's blurred layers, which bleed a little past
      // the card's own bottom edge despite its overflow:hidden — rather
      // than touching those layers directly, which also soften every
      // card's top/side edges.
      zIndex: 20,
      // Pulls the footer up 1px to overlap the card beneath it, covering
      // the sub-pixel rounding seam that vh-based heights (92vh hero,
      // 100vh cards, 90vh footer, all rounding independently) can leave
      // between sections at certain viewport heights.
      marginTop: "-1px",
      // Mobile: only as tall as its content (fixed 48px gaps between
      // blocks) — no viewport min-height, so any spare screen above it
      // shows the bottom of the last case-study card instead.
      height: isMobile ? undefined : `90${VH}`,
      padding: isMobile ? "56px 20px 24px" : "90px 32px 44px",
      display: "flex",
      flexDirection: "column",
      justifyContent: isMobile ? "flex-start" : "space-between",
      gap: isMobile ? 48 : undefined,
      overflow: "hidden",
      background: "var(--accent)",
      "--ink": "#F4F1EC",
      "--ink-soft": "#F4F1EC",
      "--ink-faint": "rgba(244,241,236,0.65)",
      "--line-faint": "rgba(244,241,236,0.3)",
    }}>
      {/* Scrolling client marquee — now part of the footer module's
          own height rather than a separate section above it. */}
      <div style={{ borderBottom: "1px solid var(--line-faint)", paddingBottom: isMobile ? 48 : 40 }}>
        {/* .mono's own defaults (12px, 0.12em tracking) are close but not
            this label's own spec — sized and tracked to match exactly
            (13px / 1.44px, not 0.12em, which only happens to equal 1.44px
            at 12px) rather than nudging the shared utility class itself. */}
        <div className="mono" style={{ color: "var(--ink-soft)", marginBottom: isMobile ? 24 : 32, fontSize: 13, lineHeight: "18.6px", letterSpacing: "1.44px" }}>
          I'VE ALSO WORKED WITH
        </div>
        {/* On mobile, two rows in opposite directions, each a separate
            slice of the list so no client appears in both, at different
            speeds so they never line up. Desktop keeps the single row with
            the full client list. */}
        {isMobile ? (
          <div style={{ display: "flex", flexDirection: "column", gap: 16 }}>
            {renderClientMarqueeRow(PAST_CLIENTS.slice(0, 6), "client-scroll", 24, -10)}
            {renderClientMarqueeRow(PAST_CLIENTS.slice(6, 11), "client-scroll-reverse", 20, -4)}
          </div>
        ) : (
          renderClientMarqueeRow(PAST_CLIENTS, "client-scroll")
        )}
      </div>

      {/* Mobile (Figma 208:2329): "Let's talk", then LinkedIn + CV side
          by side (36px apart) with Email beneath (24px gaps), and the name
          64px below. Labels 13px at 65%, values 12px underlined. */}
      {isMobile && (() => {
        const item = (label, link) => (
          <div className="mono" style={{ color: "var(--ink-soft)" }}>
            <div style={{ paddingBottom: 6, color: "var(--ink-faint)", fontSize: 13, lineHeight: "18.6px", letterSpacing: "1.44px" }}>{label}</div>
            {link}
          </div>
        );
        return (
          <div style={{ display: "flex", flexDirection: "column" }}>
            <div style={{ display: "flex", flexDirection: "column", gap: 24 }}>
              <div className="mono" style={{ color: "var(--ink-soft)", fontSize: 13, lineHeight: "18.6px", letterSpacing: "1.44px", whiteSpace: "nowrap" }}>
                Let's talk
              </div>
              <div style={{ display: "flex", gap: 36, alignItems: "flex-start" }}>
                {item("LINKEDIN", <RollingLink href="https://www.linkedin.com/in/elspethbelden/" target="_blank" rel="noopener">/in/elspethbelden ↗</RollingLink>)}
                {item("CV", <RollingLink href="assets/Elspeth-Belden-CV.pdf" download>Download ↓</RollingLink>)}
              </div>
              {item("EMAIL", <RollingLink href="mailto:elspethbelden@gmail.com">elspethbelden@gmail.com</RollingLink>)}
            </div>
            <div style={{ paddingTop: 64, margin: "0 -2px" }}>
              {nameHeading}
            </div>
          </div>
        );
      })()}

      {/* Contact info + name, grouped so the small-caps links sit
          directly above the big name, both pinned to the bottom of
          the section via the outer space-between. Link styling matches
          the case-study footers: bracketed mono label, mono value with
          an underline, no separate display-font treatment. Desktop only;
          mobile uses the Figma layout above. */}
      {!isMobile && <div>
        <div style={{
          display: "flex",
          flexDirection: isMobile ? "column" : "row",
          justifyContent: "space-between",
          alignItems: isMobile ? "flex-start" : "flex-end",
          gap: isMobile ? 36 : 32,
          marginBottom: isMobile ? 48 : 72,
        }}>
          <div className="mono" style={{ color: "var(--ink-soft)", alignSelf: isMobile ? undefined : "flex-start" }}>
            Let's talk
          </div>
          <div className="mono" style={{ color: "var(--ink-soft)" }}>
            <div style={{ marginBottom: 6, color: "var(--ink-faint)" }}>EMAIL</div>
            <RollingLink href="mailto:elspethbelden@gmail.com">elspethbelden@gmail.com</RollingLink>
          </div>
          {/* LinkedIn + CV share a row on mobile; on desktop this wrapper
              is display:contents, so both stay direct items of the row above. */}
          <div style={isMobile ? { display: "flex", gap: 36 } : { display: "contents" }}>
            <div className="mono" style={{ color: "var(--ink-soft)" }}>
              <div style={{ marginBottom: 6, color: "var(--ink-faint)" }}>LINKEDIN</div>
              <RollingLink href="https://www.linkedin.com/in/elspethbelden/" target="_blank" rel="noopener">/in/elspethbelden ↗</RollingLink>
            </div>
            <div className="mono" style={{ color: "var(--ink-soft)" }}>
              <div style={{ marginBottom: 6, color: "var(--ink-faint)" }}>CV</div>
              <RollingLink href="assets/Elspeth-Belden-CV.pdf" download>Download ↓</RollingLink>
            </div>
          </div>
        </div>

        {nameHeading}
      </div>}

      <style>{`
        @keyframes client-scroll {
          from { transform: translateX(0); }
          to { transform: translateX(-50%); }
        }
        @keyframes client-scroll-reverse {
          from { transform: translateX(-50%); }
          to { transform: translateX(0); }
        }
      `}</style>
    </section>
  );
}

// ─────────────── APP ───────────────

function App() {
  return (
    <>
      <HeroWall />
      <PullQuote />
      <SelectedWork />
      <Contact />
    </>
  );
}

ReactDOM.createRoot(document.getElementById("root")).render(<App />);
