/* ==========================================================================
   Haleh Nobar — homepage journey
   One typeface family, one 1.5 type scale, one 12-column grid.
   ========================================================================== */

:root {
  --u: clamp(16px, .5vw + 9.8px, 19px);          /* base size; every size is u × 1.5ⁿ */
  --small: max(13px, calc(var(--u) * .78));      /* labels: never below 12 px */
  --m: 28px;                                     /* page margin */
  --col: calc((100vw - 2 * var(--m)) / 12);      /* one grid column */
  --ink: #EDEDE8;
  --dim: #A3A39C;
  --ground: #171716;
  --stage-w: min(86vw, (100vh - 270px) * 2);    /* project screen on the stage, 2:1 */
}

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

/* the ground is not flat black: a faint cool light off-centre, falling away to the edges */
html {
  background:
    radial-gradient(ellipse 70% 60% at 62% 44%, rgba(96, 124, 190, .13), transparent 70%),
    radial-gradient(ellipse 120% 100% at 50% 50%, transparent 55%, rgba(0, 0, 0, .55)),
    var(--ground);
  background-attachment: fixed;
}

body {
  margin: 0;
  color: var(--ink);
  font: 400 var(--u)/1.45 'Space Grotesk', system-ui, sans-serif;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* film grain over everything */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

p, h2 { margin: 0; font-weight: 400; }

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .3em;
  text-decoration-color: rgba(237, 237, 232, .45);
}
a:hover { text-decoration-color: var(--ink); }
a:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* skip straight to the content, for keyboard users */
.skip { position: fixed; z-index: 20; left: var(--m); top: 10px; padding: 10px 14px; background: var(--ink); color: var(--ground); text-decoration: none; transform: translateY(-160%); opacity: 0; transition: transform .2s, opacity .2s; }   /* unseen too: phones show the page above its top edge, behind the clock */
.skip:focus { transform: none; opacity: 1; }

/* ---- Type scale ---------------------------------------------------------- */

.label {
  font-family: 'Space Mono', monospace;
  font-size: var(--small);
  line-height: 1.5;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--dim);
}
.body  { font-size: var(--u); line-height: 1.45; max-width: 32ch; }
.lead  { font-size: calc(var(--u) * 1.5); line-height: 1.25; letter-spacing: -.012em; max-width: 24ch; }
/* the sentences of the method: one step up, so they belong with the image, not beside it */
.say { font-size: calc(var(--u) * 2.25); line-height: 1.14; letter-spacing: -.022em; max-width: 21ch; }
@media (max-width: 720px) { .say { font-size: calc(var(--u) * 1.5); line-height: 1.25; } }
.title { font-size: calc(var(--u) * 3.375); line-height: 1; letter-spacing: -.035em; font-weight: 500; }

.gap-1 { margin-top: calc(var(--u) * .75); }
.gap-2 { margin-top: calc(var(--u) * 1.5); }

.petrol   { color: #C4D6B2; }
.hybrid   { color: #8CBA96; }
.electric { color: #62967C; }

/* ---- Layers: windows (0) · dust (1) · text (4) · chrome (6) ------------- */

#dust {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  mix-blend-mode: screen;       /* dust floats over the project windows */
  pointer-events: none;
}

#windows { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

#track { height: 2245vh; }      /* scroll length: the scenes' stays (31.55 in all) × 0.68 screens + 1 */

/* ---- Project windows ----------------------------------------------------- */

.window {
  position: absolute;
  left: calc(50% - var(--stage-w) / 2);
  top: calc(50% - 26px - var(--stage-w) / 4);       /* must match stage() in journey.ts */
  width: var(--stage-w);
  aspect-ratio: 2 / 1;
  margin: 0;
  overflow: hidden;
  visibility: hidden;
  clip-path: inset(50% 0 50% 0);
  will-change: opacity, transform;
}
.window .screens {                 /* the screenshot; journey.ts moves and zooms it inside the frame on phones */
  position: absolute;
  inset: 0 0 auto 0;
  aspect-ratio: 2 / 1;
  transform-origin: 0 0;
  transition: transform .9s cubic-bezier(.3, .7, .2, 1);
}
.window img {
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: auto;
  transition: opacity .7s ease;
}

/* the part a note is about stays lit; the rest of the screen steps back */
.window .focus {
  position: absolute;
  z-index: 1;
  border-radius: 3px;
  box-shadow: 0 0 0 200vmax rgba(8, 8, 8, .36);
  opacity: 0;
  transition: left .8s cubic-bezier(.3, .7, .2, 1), top .8s cubic-bezier(.3, .7, .2, 1),
              width .8s cubic-bezier(.3, .7, .2, 1), height .8s cubic-bezier(.3, .7, .2, 1);
}

/* ---- Notes: under the screen, below the part they explain ---------------- */

.explain { position: fixed; inset: 0; z-index: 4; opacity: 0; visibility: hidden; pointer-events: none; }
.notes { margin: 0; padding: 0; list-style: none; }
.notes li {
  position: fixed;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .5s ease, transform .5s ease;
}
.notes li.on { opacity: 1; transform: none; transition-delay: .25s; }
.notes .label { color: var(--ink); }
.notes .note { margin-top: calc(var(--u) * .4); font-size: calc(var(--u) * 1.5); line-height: 1.22; letter-spacing: -.012em; }

/* names the project while its screen is open */
.bar {
  position: fixed;
  left: var(--m);
  right: calc(var(--m) + 12em);         /* leaves room for the counter and Top */
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 2);
  color: var(--ink);
}
.bar a { margin-left: auto; }
.bar a {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: var(--dim);
  background: none;
  border: 0;
  padding: 10px 0;
  cursor: pointer;
  text-decoration: none;
}
.bar a { color: var(--ink); }
.bar a { border-bottom: 1px solid rgba(237, 237, 232, .45); padding-bottom: 2px; }
.bar a:hover { border-color: var(--ink); }

/* leaving for a case study */
main, #windows { transition: opacity .6s ease; }
.leaving main, .leaving #windows, .leaving .chrome, .leaving #to-top { opacity: 0; }   /* only the dust is left, flying apart */

/* ---- Text scenes --------------------------------------------------------- */

.scene {
  position: fixed;
  z-index: 4;
  opacity: 0;
  visibility: hidden;
  will-change: opacity, transform;
}

/* horizontal placement on the grid */
.at-1  { left: var(--m); }
.at-5  { left: calc(var(--m) + 4 * var(--col)); }
.at-9  { right: var(--m); width: max(calc(4 * var(--col)), 280px); }
.span-4 { width: max(calc(4 * var(--col) - 24px), 280px); }
.span-5 { width: max(calc(5 * var(--col)), 280px); }

/* vertical placement */
.top    { top: 96px; }
.middle { top: 50%; margin-top: -64px; }
.bottom { bottom: 64px; }
.under-line { top: 50%; margin-top: 28px; }

.credits { left: 0; right: 0; bottom: 64px; height: 1.5em; color: var(--ink); }
.credits span { position: absolute; }
.credits span:nth-child(1) { left: var(--m); }
.credits span:nth-child(2) { left: calc(var(--m) + 4 * var(--col)); }
.credits span:nth-child(3) { left: calc(var(--m) + 8 * var(--col)); }

/* ---- Chrome -------------------------------------------------------------- */

.chrome { position: fixed; z-index: 6; inset: 0 0 auto 0; height: 64px; }
.chrome > * { position: absolute; top: 12px; }
.chrome a, .chrome button {                    /* 12 + 12 + text: a comfortable tap target */
  display: inline-block;
  padding: 12px 0;
  color: var(--ink);
  text-decoration: none;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
.chrome .home span { color: var(--dim); margin-left: 1.2em; }
.chrome button[aria-expanded="true"] { text-decoration: underline; text-underline-offset: .4em; }

/* the Work index */
#index {
  position: fixed;
  z-index: 7;
  top: 58px;
  left: calc(var(--m) + 4 * var(--col));
  right: var(--m);
  background: rgba(23, 23, 22, .96);
  border-top: 1px solid rgba(237, 237, 232, .25);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity .3s ease, transform .3s ease, visibility 0s .3s;
}
#index.open { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
#index ol { margin: 0; padding: 0; list-style: none; }
#index li {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 4fr) minmax(0, 3fr) auto;
  align-items: baseline;
  column-gap: 24px;
  padding: 16px 0;
  border-bottom: 1px solid rgba(237, 237, 232, .12);
}
#index .name { font-size: calc(var(--u) * 1.5); letter-spacing: -.012em; text-decoration: none; }
#index a.label { color: var(--ink); }
#index a:hover { text-decoration: underline; }
.chrome .home { left: var(--m); white-space: nowrap; }
.chrome nav { left: calc(var(--m) + 4 * var(--col)); display: flex; gap: calc(var(--u) * 1.6); }
.chrome .mail { left: calc(var(--m) + 8 * var(--col)); }

#loader, #to-top, #hint { position: fixed; z-index: 6; bottom: 24px; color: var(--ink); }
/* the loader: the red full stop, alone in the middle, where the dust will begin */
#loader  { left: 50%; top: 50%; bottom: auto; width: 0; height: 0; z-index: 9; transition: opacity 1.1s ease; pointer-events: none; }
#loader .ember {
  position: absolute; left: -11px; top: -11px; width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 82, 66, .95) 0, rgba(255, 82, 66, .5) 34%, rgba(255, 82, 66, .12) 58%, rgba(255, 82, 66, 0) 72%);
  animation: ember 1.8s ease-in-out infinite;
}
#loader #percent { position: absolute; left: 0; top: 30px; transform: translateX(-50%); color: var(--dim); }
@keyframes ember { 0%, 100% { transform: scale(.82); opacity: .75; } 50% { transform: scale(1.12); opacity: 1; } }

/* ---- The light of "clear" --------------------------------------------------
   When a phrase stands as real type, the ground behind it lifts: clear is lighter than unclear.
   journey.ts sets its opacity. */
#light {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0;
  background:
    radial-gradient(ellipse 62% 56% at 50% 40%, rgba(170, 186, 232, .26), rgba(120, 140, 200, .08) 55%, transparent 76%);
}
html:not(.journey) #light, .no-webgl #light { display: none; }
#to-top { right: var(--m); bottom: 12px; padding: 12px 0; background: none; border: 0; font-size: var(--small); cursor: default; display: flex; gap: 1.4em; }
#to-top .arrow { opacity: 0; transition: opacity .4s; color: var(--dim); }
#to-top.far { cursor: pointer; }
#to-top.far .arrow { opacity: 1; }
#to-top.far:hover .arrow, #to-top.far:focus-visible .arrow { color: var(--ink); }
#hint    { left: calc(var(--m) + 4 * var(--col)); display: flex; align-items: center; gap: 12px; transition: opacity .6s; }
#hint i  { position: relative; width: 56px; height: 1px; overflow: hidden; background: rgba(237, 237, 232, .2); }
#hint i::after { content: ''; position: absolute; inset: 0; background: var(--ink); transform: translateX(-100%); animation: hint 2.2s cubic-bezier(.6, 0, .2, 1) infinite; }
@keyframes hint { 60%, 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { #hint i::after { animation: none; transform: none; } }

#no-webgl { display: none; position: fixed; z-index: 6; left: var(--m); top: 70px; }
.no-webgl #no-webgl { display: block; }

/* the three phrases as real type, laid over the dust lettering by journey.js */
#sharp { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
#sharp div { position: absolute; inset: 0; opacity: 0; visibility: hidden; will-change: opacity, filter; }
#sharp span { position: absolute; white-space: pre; font-weight: 500; line-height: 1; color: var(--ink); font-kerning: normal; }
#sharp i { font-style: normal; color: #FF5242; }
.leaving #sharp { opacity: 0; transition: opacity .6s ease; }

/* ---- The visitor's own sentence (last screen) -----------------------------
   A single line to type on. What is typed forms in dust above it (journey.ts). */
#contact label.label { display: block; cursor: text; }
.tell { max-width: none; }
.tell input {
  width: min(100%, 22em);
  padding: 4px 0 6px;
  border: 0;
  border-bottom: 1px solid rgba(237, 237, 232, .45);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  letter-spacing: inherit;
  caret-color: #FF5242;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.tell input::placeholder { color: var(--dim); opacity: 1; }
.tell input:hover { border-bottom-color: rgba(237, 237, 232, .75); }
.tell input:focus { border-bottom-color: var(--ink); }
.tell input:focus-visible { box-shadow: 0 2px 0 0 var(--ink); }
.send-it { color: var(--dim); }
.tell-note { color: var(--dim); }
[hidden] { display: none !important; }
/* wide screens: the question itself stands right above the field, so the small label is only read aloud;
   this keeps the block as low as it was before the field was added */
@media (min-width: 721px) {
  html.journey #contact label.label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  html.journey #contact .tell { margin-top: 0; }
}

/* ---- The lens --------------------------------------------------------------
   A thin ring around the pointer: under it the dust comes into focus (journey.ts moves it).
   It is only drawn for a mouse or trackpad, and never takes a click. */
#lens {
  position: fixed; left: 0; top: 0; z-index: 5;
  width: 0; height: 0; opacity: 0; pointer-events: none;
}
#lens::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 44px; height: 44px; margin: -22px 0 0 -22px;       /* small: it marks the lens, it does not frame it */
  border: 1px solid rgba(237, 237, 232, .32); border-radius: 50%;
  transition: width .35s cubic-bezier(.2, .7, .2, 1), height .35s cubic-bezier(.2, .7, .2, 1), margin .35s cubic-bezier(.2, .7, .2, 1), border-color .35s ease;
}
#lens.closed::before { width: 20px; height: 20px; margin: -10px 0 0 -10px; border-color: rgba(237, 237, 232, .6); }
html:not(.journey) #lens, .no-webgl #lens { display: none; }

/* without WebGL: the phrases as plain type */
.plain { display: none; left: var(--m); top: 18vh; font-size: clamp(56px, 13vw, 210px); line-height: .95; letter-spacing: -.045em; font-weight: 500; max-width: 8em; }
.plain i { font-style: normal; color: #FF5242; }
.no-webgl .plain { display: block; }


/* ---- Phone --------------------------------------------------------------- */

@media (max-width: 720px) {
  :root { --m: 20px; }

  .scene {
    left: var(--m) !important;
    right: var(--m) !important;
    top: auto !important;
    bottom: 56px !important;
    width: auto !important;
    margin: 0 !important;
  }
  .credits { height: auto; }
  .credits span { position: static; display: block; }


  :root { --stage-w: calc(100vw - 2 * var(--m)); }
  /* a tall frame under the navigation, as tall as the note and the bar below allow; must match stage() in journey.ts */
  .window { left: var(--m); top: 88px; aspect-ratio: auto; height: clamp(var(--stage-w) * .75, 100% - 353px, var(--stage-w) * 1.2); }

  .bar { flex-wrap: wrap; row-gap: 0; bottom: 48px; }
  .bar .name { width: 100%; }
  .bar a { margin-left: 0; }

  .chrome .home span { display: block; margin: 0; }
  .chrome .home { padding-bottom: 0; line-height: 1.7; }
  .chrome nav { left: auto; right: var(--m); gap: calc(var(--u) * 1.1); }
  #index { left: var(--m); top: 70px; }
  #index li { grid-template-columns: 1fr auto; row-gap: 2px; padding: 14px 0; }
  #index li span.label:nth-of-type(2) { display: none; }
  #index li a.label { grid-row: 1; grid-column: 2; }
  .fromto { font-size: var(--u); }

  .plain { top: 16vh !important; bottom: auto !important; }

  .chrome .mail { display: none; }
  #hint { left: var(--m); }                            /* on the bottom line, beside the counter: not over the lettering */
}

/* very narrow phones: Contact is reached from the end of the page and the Work index */
@media (max-width: 380px) {
  .chrome nav { gap: calc(var(--u) * .7); }   /* every destination stays, a little closer together */
}

/* A project in order: name, then form, then what it is about (journey.ts sets --arrived) */
html.journey .project > :not(.label:first-child):not(.title) {
  opacity: var(--arrived, 0);
  transform: translateY(calc((1 - var(--arrived, 0)) * 10px));
}

/* ---- Small and in-between screens ------------------------------------------ */

/* tablets: the role would run into the navigation, so the name stands alone */
@media (min-width: 721px) and (max-width: 1000px) {
  .chrome .home span { display: none; }
}
/* the narrowest phones: all four destinations stay, set a little tighter */
@media (max-width: 380px) {
  .chrome { font-size: 12px; }
  .chrome nav { gap: 9px; letter-spacing: .02em; }
}
/* phones: one thing at a time. Each project opens with its form, its name, one line and
   the way in; the description and the numbers are told on the screens that follow and in
   the case study. The role under the name is already in the opening credits. */
@media (max-width: 720px) {
  html.journey .chrome .home span { display: none; }
  html.journey .project .body:not(:last-child),
  html.journey .project .title ~ .label { display: none; }
  /* three clear steps of type: a small label, one large line, one quiet line */
  html.journey .project .title { font-size: calc(var(--u) * 3.375); line-height: 1; letter-spacing: -.03em; }
  html.journey .project .fromto { font-size: var(--u); color: var(--dim); }
  .say { font-size: calc(var(--u) * 1.9); line-height: 1.16; }
  .reach { font-size: 7.4vw; letter-spacing: -.02em; }           /* the address is the point of the last screen */
  #contact .body { color: var(--dim); }
  .scene .label, .notes .label, .bar { font-size: 13px; }       /* labels a step larger where the screen is small */

  /* the text is part of each composition, so it is not always in the same place */
  html.journey .scene[data-scene="3"] { top: 104px !important; bottom: auto !important; }                     /* above the tangle */
  html.journey .scene[data-scene="4"] { top: auto !important; bottom: 72px !important; }                      /* below what is seen */
  html.journey .scene[data-scene="5"] { top: 104px !important; bottom: auto !important; text-align: right; padding-left: 22%; box-sizing: border-box; }   /* above the links, from the right */
  html.journey .scene[data-scene="6"] { top: calc(50% + 28px) !important; bottom: auto !important; }           /* hanging from the one path */
  html.journey .scene[data-scene="5"] .say { margin-left: auto; }

  /* a project: its name above, its form alone in the middle, what it is about below */
  html.journey .project {
    inset: 0 !important;
    width: auto !important;
    margin: 0 !important;
    box-sizing: border-box;
    padding: 100px var(--m) 76px;
    display: flex;
    flex-direction: column;
  }
  html.journey .project .fromto { margin-top: auto !important; color: var(--ink); font-size: calc(var(--u) * 1.5); }
  html.journey .project .body:not(:last-child) { display: block; color: var(--dim); max-width: 30ch; }
  html.journey .project .body ~ .body:not(:last-child) { display: none; }   /* one sentence is enough here */
}

/* short phones: a smaller name and tighter text, so name, form and description each keep their place */
@media (max-width: 720px) and (max-height: 700px) {
  html.journey .project { padding-bottom: 64px; }
  html.journey .project .title { font-size: calc(var(--u) * 2.25); }
  html.journey .project .fromto { font-size: calc(var(--u) * 1.2); }
  html.journey .project .body { font-size: 14px; line-height: 1.35; margin-top: 8px !important; }
  /* the bar under a project screen: the full project name on one line, the link on the next.
     Two short lines never climb into the note above, and nothing is cut off. */
  .bar { font-size: 12px; letter-spacing: .05em; row-gap: 2px; }
  .bar .name, .bar a { white-space: nowrap; }
}

/* ---- The plain page ----------------------------------------------------------
   What the homepage is before (or without) the journey: one readable column.
   js/start.js adds the class "journey" to <html>, and takes it away again if the
   journey does not start. Reduced-motion visitors always get this page.          */

html:not(.journey) :is(#dust, #track, #loader, #hint, #to-top, #windows, #no-webgl, .explain, #work-button) { display: none !important; }
html:not(.journey) main { display: block; max-width: 720px; padding: 72px var(--m) 80px; }
html:not(.journey) .scene { position: static !important; opacity: 1 !important; visibility: visible !important; width: auto !important; margin: 0 0 72px !important; transform: none !important; scroll-margin-top: 80px; }
html:not(.journey) .scene.plain { display: block; margin-bottom: 40px !important; }
html:not(.journey) .scene.plain ~ .scene.plain { display: none; }
html:not(.journey) #index { position: static; opacity: 1; visibility: visible; transform: none; pointer-events: auto; padding: 96px var(--m) 0; max-width: 720px; }

/* ---- From page to page -------------------------------------------------------
   Pages are not cut: the leaving page (its dust already let go, see journey.ts)
   dissolves into the arriving one, where the same dust gathers as the title.
   Browsers without view transitions simply load the page.                        */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: page-out .3s ease both; }
::view-transition-new(root) { animation: page-in .3s ease both; }   /* short: the dust carries the move, not the fade */
@keyframes page-out { to { opacity: 0; filter: blur(6px); } }
@keyframes page-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

.leaving .chrome, .leaving #to-top { transition: opacity .6s ease; }

/* phone, while the visitor types on the last screen: the field at the top, the rest steps back */
@media (max-width: 720px) {
  html.journey.telling #contact { top: 76px !important; bottom: auto !important; }
  html.journey.telling #contact > :not(label):not(.tell) { display: none; }
  /* the question in dust stands right below and asks it already; the label stays for screen readers */
  html.journey.telling #contact label.label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .tell input { width: 100%; font-size: max(17px, 1em); }      /* 16px and up: iOS does not zoom the page on focus */
}

/* the address in the navigation needs a wide window; below that it would run into "Contact"
   (it is still on the last screen and in the Work index) */
@media (max-width: 1040px) { .chrome .mail { display: none; } }
