/* Palette uses official LEGO colour values. */
:root {
  --night: #08080A;
  --red: #C91A09;
  --dark-red: #720E0F;
  --white: #F2F3F2;
  --lbg: #A0A5A9;
  --sky-top: #0A0B10;
  --sky-bottom: #170C0E;
  --measure: 34rem;
  --gutter: clamp(1.25rem, 4vw, 4rem);
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  font-optical-sizing: auto;
  color: var(--white);
  background: var(--night);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
/* the text scrims reach past the viewport edge; clip (not hidden) keeps sticky working */
html, body { overflow-x: clip; }
body {
  margin: 0;
  background: linear-gradient(to bottom, var(--sky-top), var(--sky-bottom)) fixed, var(--night);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--red); color: var(--white); }

#stage {
  position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100lvh;
  display: block; pointer-events: none; z-index: 0;
}

.skip { position: absolute; left: -999px; top: 0; z-index: 10; background: var(--white); color: var(--night); padding: .5rem 1rem; }
.skip:focus { left: 1rem; top: 1rem; }

/* ---------- header ---------- */
.top {
  position: fixed; inset: 0 0 auto 0; z-index: 5;
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: 1.25rem var(--gutter) 3.5rem;
  background: linear-gradient(to bottom, rgb(8 8 10 / .96) 35%, rgb(8 8 10 / 0));
  pointer-events: none;
}
.top a { pointer-events: auto; }
.mark {
  font-weight: 700; font-stretch: 92%; font-size: 1.15rem; letter-spacing: -0.01em;
  color: var(--white); text-decoration: none;
}
.top nav { display: flex; gap: clamp(.9rem, 2.4vw, 2rem); }
.top nav a { color: var(--lbg); text-decoration: none; font-size: .95rem; }
.top nav a:hover, .top nav a[aria-current="true"] { color: var(--white); }

/* ---------- progress: one brick per chapter ---------- */
.stack {
  position: fixed; left: calc(var(--gutter) * .45); top: 50%; z-index: 5; transform: translateY(-50%);
  list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column-reverse; gap: 3px;
}
.stack a {
  display: block; width: 18px; height: 9px; border-radius: 1.5px;
  background: rgb(160 165 169 / .22);
  position: relative;
  transition: background-color .3s, width .3s;
}
.stack a::after { /* studs */
  content: ''; position: absolute; top: -2px; left: 3px; width: 4px; height: 2px; border-radius: 1px 1px 0 0;
  background: inherit; box-shadow: 8px 0 0 0 currentColor; color: inherit;
}
.stack a.done { background: var(--dark-red); }
.stack a.now { background: var(--red); width: 24px; }
.stack a span { position: absolute; left: 34px; top: 50%; transform: translateY(-50%); white-space: nowrap; font-size: .8rem; color: var(--lbg); opacity: 0; transition: opacity .2s; pointer-events: none; }
.stack a:hover span, .stack a:focus-visible span { opacity: 1; }

/* ---------- chapters ---------- */
main { position: relative; z-index: 1; }
.chapter { position: relative; min-height: 190vh; padding: 0 var(--gutter); }
#home { min-height: 175vh; }
#contact { min-height: 150vh; }
.chapter--steps { min-height: auto; }
.chapter--steps .step { min-height: 120vh; }
.chapter--steps .step:last-child { min-height: 160vh; }
#gallery .step:last-child { min-height: 200vh; } /* the photo wall gets a longer look */

.copy {
  position: sticky; top: 22vh;
  max-width: var(--measure);
  padding: 1.5rem 0 2rem;
}
.chapter[data-side="right"] .copy { margin-left: auto; }
.chapter[data-side="center"] .copy { margin: 0 auto; text-align: center; top: 60vh; max-width: 40rem; }
#home .copy { top: 24vh; padding-top: 0; }

/* soft scrim behind the text so the diorama never fights legibility */
.copy::before {
  content: ''; position: absolute; inset: -7rem -10rem; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgb(8 8 10 / .88), rgb(8 8 10 / .55) 60%, rgb(8 8 10 / 0));
}

h1, h2, h3 { margin: 0; font-weight: 760; letter-spacing: -0.02em; text-wrap: balance; }
h1 {
  font-size: clamp(3.5rem, 9vw, 8.25rem); line-height: .88; font-stretch: 90%; font-weight: 720;
  letter-spacing: -0.045em; margin-bottom: 1.5rem;
}
h2 { font-size: clamp(2.25rem, 4.6vw, 3.6rem); line-height: 1; font-stretch: 90%; letter-spacing: -0.035em; margin-bottom: 1.25rem; }
h3 { font-size: clamp(1.35rem, 2.1vw, 1.7rem); line-height: 1.15; font-stretch: 88%; font-weight: 680; margin-bottom: .75rem; }
p { margin: 0 0 1rem; color: rgb(242 243 242 / .86); }
.lede { font-size: clamp(1.25rem, 1.9vw, 1.5rem); line-height: 1.35; color: var(--white); font-weight: 420; max-width: 26rem; }
.meta { font-size: .9rem; color: var(--lbg); }
.meta b { color: var(--white); font-weight: 600; }
cite { font-style: italic; }

.figure { display: flex; align-items: baseline; gap: .75rem; color: var(--lbg); font-size: .95rem; }
.num { font-size: 2.6rem; font-weight: 300; font-stretch: 90%; color: var(--white); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

a { color: var(--white); text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: .22em; }
a:hover { text-decoration-color: var(--white); }
a:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; border-radius: 2px; }
.links { display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; margin-top: 1.25rem; }
.chapter[data-side="center"] .links { justify-content: center; }

.portrait { margin: 0 0 2.6rem; width: 11.5rem; position: relative; padding: 9px; border-radius: 3px;
  background: linear-gradient(#34373D, #1B1D21 45%, #121316);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .14), inset 0 -2px 0 rgb(0 0 0 / .45), 0 22px 40px -16px rgb(0 0 0 / .95); }
/* studs along the frame's top edge */
.portrait::before { content: ''; position: absolute; left: 6px; right: 6px; top: -5px; height: 5px;
  background: radial-gradient(ellipse 4px 5px at 50% 100%, #34373D 92%, transparent) 0 0 / 13px 5px repeat-x; }
/* a red plate the frame stands on, wider than the frame so its studs show either side */
.portrait::after { content: ''; position: absolute; left: -14px; right: -14px; bottom: -17px; height: 17px; border-radius: 0 0 2px 2px;
  background: radial-gradient(ellipse 4.5px 5px at 50% 100%, #D8341F 92%, transparent) 1px 0 / 13px 5px repeat-x,
    linear-gradient(#D8341F, #C91A09 35%, #8E1206) 0 5px / 100% 12px no-repeat;
  filter: drop-shadow(0 10px 12px rgb(0 0 0 / .6)); }
.portrait img { width: 100%; aspect-ratio: 3 / 4; height: auto; object-fit: cover; display: block; border: 5px solid #ECE9E2; border-radius: 1px;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .2); filter: saturate(.95) contrast(1.03); }

.roles { margin: 1.5rem 0 0; display: grid; gap: .1rem 0; }
.roles dt { font-weight: 620; font-size: .98rem; margin-top: .7rem; }
.roles dd { margin: 0; color: var(--lbg); font-size: .95rem; }

.email { font-size: clamp(1.4rem, 3.6vw, 2.6rem); font-weight: 600; font-stretch: 85%; letter-spacing: -0.015em; }
.credits { margin-top: 3rem; font-size: .8rem; color: rgb(160 165 169 / .7); }

.loading { position: fixed; right: var(--gutter); bottom: 1.25rem; z-index: 5; font-size: .85rem; color: var(--lbg); margin: 0; transition: opacity .6s; }
.ready .loading { opacity: 0; }

/* ---------- experience ---------- */
.step--flow .copy { position: relative; top: auto; padding-top: 22vh; }
.step--flow { min-height: 0 !important; padding-bottom: 30vh; }
.jobs { list-style: none; margin: 1.5rem 0 0; padding: 0; display: grid; gap: 2.25rem; }
.job { position: relative; padding-left: 1.4rem; }
/* a 1×N plate down the left edge, studs and all: each job is one more brick */
.job::before { content: ''; position: absolute; left: 0; top: .35rem; bottom: .2rem; width: 6px; border-radius: 1.5px; background: var(--dark-red); }
.job:first-child::before { background: var(--red); }
.job h3 { margin: .9rem 0 .15rem; }
.logos { display: flex; align-items: center; gap: 1.1rem; height: 1.9rem; }
.logos img { height: 100%; width: auto; max-width: 11rem; object-fit: contain; filter: brightness(0) invert(1); opacity: .9; }
.logos img[alt="KFUPM"] { height: 72%; }
.logos img[alt="Baker Hughes"] { height: 62%; }
.logos img[alt="HUMAIN"] { height: 58%; }
.when { font-size: .92rem; color: var(--lbg); margin-bottom: .6rem; }
.areas { list-style: none; margin: .4rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.areas li { font-size: .8rem; padding: .18rem .6rem .2rem; border-radius: 3px; background: rgb(242 243 242 / .08); box-shadow: inset 0 0 0 1px rgb(242 243 242 / .12); color: rgb(242 243 242 / .85); }
.honours { margin: 2.5rem 0 0; display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; font-size: .92rem; }
.honours dt { font-weight: 620; }
.honours dd { margin: 0; color: var(--lbg); }

/* ---------- gallery ---------- */
.titles { font-size: 1.15rem; line-height: 1.5; color: var(--white); max-width: 28rem; }
.chapter--steps .step .copy > h2 + p + h3 { margin-top: 2rem; }
.prints { list-style: none; margin: 1.25rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.prints li { height: 7.5rem; }
/* a pearl-gold brick frame with a row of studs along the top, like the ones on the wall */
.prints a { display: block; height: 100%; position: relative; padding: 5px; border-radius: 3px;
  background: linear-gradient(#C9A15B, #AA7F2E 55%, #8A6524);
  box-shadow: inset 0 1px 0 rgb(255 240 200 / .5), inset 0 -2px 0 rgb(0 0 0 / .25), 0 14px 28px -12px rgb(0 0 0 / .9); }
.prints a::before { content: ''; position: absolute; left: 4px; right: 4px; top: -4px; height: 4px;
  background: radial-gradient(ellipse 3.2px 4px at 50% 100%, #C9A15B 92%, transparent) 0 0 / 10px 4px repeat-x; }
.prints img { display: block; height: 100%; width: auto; border-radius: 1px; box-shadow: 0 0 0 2px #1B1D21; transition: filter .3s; filter: saturate(.95); }
.prints a:hover img, .prints a:focus-visible img { filter: saturate(1.1) brightness(1.05); }

/* ---------- where I've been ---------- */
.map { position: relative; margin: 1.25rem 0 1rem; }
.worldmap { display: block; width: 100%; aspect-ratio: 120 / 52; cursor: crosshair; touch-action: pan-y; }
.map-label { position: absolute; margin: 0; transform: translate(-50%, calc(-100% - 10px)); pointer-events: none; white-space: nowrap;
  font-size: .82rem; font-weight: 600; padding: .15rem .55rem; border-radius: 3px; background: #3A3D42; color: var(--white); }
.map-label.been { background: var(--red); }
.regions p { margin: 0 0 .5rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .35rem; }
.regions span { font-size: .85rem; color: var(--lbg); margin-right: .3rem; min-width: 6.2rem; }
.regions span + button + span { min-width: 0; margin-left: 1rem; }
.regions button { font: inherit; font-size: .9rem; color: var(--white); background: none; border: 0; padding: .05rem .1rem; cursor: pointer;
  text-decoration: underline 2px rgb(201 26 9 / .55); text-underline-offset: .25em; }
.regions button:hover, .regions button.on { text-decoration-color: var(--red); background: rgb(201 26 9 / .18); border-radius: 2px; }
.regions button:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.chapter--steps .step .copy > h3:first-child { font-size: clamp(1.6rem, 2.6vw, 2.2rem); font-stretch: 90%; letter-spacing: -0.03em; }

.lightbox { border: 0; padding: 0; background: transparent; max-width: 92vw; max-height: 92vh; overflow: visible; }
.lightbox::backdrop { background: rgb(8 8 10 / .9); backdrop-filter: blur(4px); }
.lightbox img { display: block; max-width: 92vw; max-height: 86vh; border-radius: 4px; }
.lightbox button { position: absolute; top: -2.5rem; right: 0; background: none; border: 0; color: var(--white); font: inherit; cursor: pointer; text-decoration: underline 2px var(--red); text-underline-offset: .22em; }

/* ---------- small screens: diorama in the upper half, text flows beneath ---------- */
@media (max-width: 819px) {
  .stack { display: none; }
  .top nav a:nth-child(n+3) { display: none; }
  .chapter, #home, #contact, .chapter--steps .step, .chapter--steps .step:last-child { min-height: 0; }
  .chapter { padding-top: 56vh; padding-bottom: 46vh; }
  .chapter--steps { padding-bottom: 0; }
  .chapter--steps .step { padding-bottom: 40vh; }
  .chapter--steps .step + .step { padding-top: 0; }
  .copy, #home .copy, .chapter[data-side="center"] .copy {
    position: relative; top: auto; margin: 0; max-width: none; text-align: left; padding: 1.5rem 0 1rem;
  }
  .copy::before { inset: -3rem calc(var(--gutter) * -1) -2rem; background: linear-gradient(to bottom, rgb(8 8 10 / 0), rgb(8 8 10 / .9) 3rem, rgb(8 8 10 / .9) calc(100% - 3rem), rgb(8 8 10 / 0)); }
  .chapter[data-side="center"] .links { justify-content: flex-start; }
  h1 { font-size: clamp(3.25rem, 17vw, 5rem); }
  .step--flow .copy { padding-top: 1.5rem; }
  .honours { grid-template-columns: 1fr; gap: .1rem; }
  .honours dd { margin-bottom: .6rem; }
  .prints li { height: 6rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
