/* Inside Hemanth: the opening scroll journey. Positions are written by journey.js each frame.
   Type and colour follow the rest of the site (styles.css): Inter/Helvetica/Arial, mono eyebrows,
   #f4f7fa text, #a6afbc muted, #168bff blue, #8fcbff ice, on #050608. */

/* Phone screens have two heights: with the browser's toolbars showing (small) and with them
   tucked away while scrolling (large). Browsers without the small/large units (before Safari 15.4
   and Chrome 108) use 100vh, which they already treat as the large height; journey.js then
   measures the small one. */
:root { --vh-small: 100vh; --vh-large: 100vh; }
@supports (height: 100svh) {
  :root { --vh-small: 100svh; --vh-large: 100lvh; }
}

.journey {
  position: relative;
  height: var(--vh-small);
  background: var(--bg);
  color: var(--text);
}

.journey-stage {
  position: sticky;
  top: 0;
  /* As tall as the screen with the toolbars tucked away, so no gap ever opens below it. */
  height: var(--stage-h, var(--vh-large));
  overflow: hidden;
  isolation: isolate;
}

.journey-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 600ms var(--ease);
}
.journey.is-ready .journey-canvas { opacity: 1; }

.journey-poster {
  position: absolute;
  top: 0;
  right: 6vw;
  height: var(--frame-h, var(--vh-small));
  width: auto;
  max-width: none;
  display: block;
  /* Feathered on every side but the top, so the plate never shows a hard edge. */
  -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent 100%), linear-gradient(to right, transparent 0, #000 12%, #000 88%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to bottom, #000 72%, transparent 100%), linear-gradient(to right, transparent 0, #000 12%, #000 88%, transparent 100%);
  mask-composite: intersect;
}

[data-hidden] { visibility: hidden; }
html.js:not(.journey-static) .journey-poster { display: none; }
/* Browsers that can run the journey don't paint the static photo first either: a moment later it
   would give way to the journey's own framing of it. Without scripts it shows as before, and if
   the scripts never arrive it comes back with the loading screen's fallback. */
@supports (aspect-ratio: 1) {
  html:not(.journey-static) .journey-poster { visibility: hidden; animation: poster-failsafe 0s linear 15s forwards; }
}
@keyframes poster-failsafe { to { visibility: visible; } }

/* ---------- Hero: the opening copy, set to the left of the face ---------- */
.journey-hero {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--frame-h, var(--vh-small));
  will-change: transform, opacity;
}
.story-opening { padding-top: clamp(8rem, 17vh, 12rem); padding-bottom: 8rem; position: relative; z-index: 3; }
.story-opening .eyebrow { display: flex; align-items: center; gap: .75rem; color: #b8c1cc; margin-bottom: 2rem; }
.story-opening h1 { max-width: 8.5em; font-size: clamp(4rem, 8.2vw, 8.7rem); }
/* On short laptop windows the heading gives way, so the buttons stay inside the frame. */
.story-opening h1 { font-size: min(clamp(4rem, 8.2vw, 8.7rem), (var(--frame-h, var(--vh-small)) - clamp(8rem, 17vh, 12rem) - 15.75rem) / 2.94); }
.story-positioning { margin-top: 1.8rem; color: #e1e7ef; font-size: clamp(.9rem, 1.2vw, 1.2rem); }
.hero-direct { font-size: .78rem; min-height: 44px; display: inline-flex; align-items: center; gap: .6rem; }
@media (max-width: 600px) { .hero-direct { font-size: .65rem; } }
@media (min-width: 1800px) {
  .story-opening { padding-top: 19vh; }
  .story-opening h1 { font-size: min(8.7rem, (var(--frame-h, var(--vh-small)) - 19vh - 15.75rem) / 2.94); }
}
@media (max-width: 860px) {
  .story-opening { padding-top: calc(var(--header-height) + 2.5rem); }
  .story-opening h1 { font-size: clamp(3.4rem, 10vw, 6rem); }
}
@media (max-width: 600px) {
  .story-opening { padding-top: calc(var(--header-height) + 2rem); }
  .story-opening .eyebrow { font-size: .46rem; margin-bottom: 1.2rem; max-width: 85%; }
  .story-opening h1 { font-size: clamp(2.5rem, 10.9vw, 4rem); line-height: 1; max-width: 9em; }
  .story-positioning { font-size: .73rem; margin-top: 1.1rem; }
  .story-opening .hero-actions { margin-top: 1rem; }
  .story-opening .hero-actions .button { min-height: 44px; font-size: .7rem; padding: .55rem .8rem; gap: .8rem; }
}
@media (max-height: 600px) and (orientation: landscape) {
  .story-opening { padding-top: calc(var(--header-height) + 1rem); }
  .story-opening h1 { font-size: clamp(2rem, 10vh, 3.8rem); }
  .story-opening .eyebrow { margin-bottom: .65rem; }
  .story-positioning { margin-top: .5rem; font-size: .7rem; }
  .story-opening .hero-actions { margin-top: .5rem; }
}

/* ---------- Thoughts ---------- */
.journey-thought {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  font: 400 clamp(1.125rem, 1.07rem + .3vw, 1.3125rem)/1.2 var(--mono);
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ice);
  text-shadow: 0 0 14px rgb(22 139 255 / .9), 0 0 42px rgb(22 139 255 / .55);
  pointer-events: none;
  white-space: nowrap;
  will-change: transform, opacity, filter;
}

/* ---------- Project cards ---------- */
.journey-cards {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--frame-h, var(--vh-small));
  perspective: 1400px;
  pointer-events: none;
}

.journey-cards-title {
  position: absolute;
  left: 0;
  top: 0;
  text-align: center;
  width: min(90vw, 44rem);
  text-shadow: 0 3px 24px #000;
  will-change: transform, opacity;
}
.journey-cards-title h2 { margin: 0; font-size: clamp(2rem, 4.8vw, 4.75rem); line-height: 1.1; letter-spacing: -.055em; }
.journey-cards-title p { margin: .65rem 0 0; color: #c0cede; font-size: .8rem; }

.journey-card {
  --scan: 100%;
  --focus: 0;
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: clamp(1rem, .6rem + 1.4vw, 1.75rem);
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
  border: 1px solid rgb(143 203 255 / calc(.22 + var(--focus) * .3));
  background:
    radial-gradient(120% 80% at 50% 0%, rgb(22 139 255 / calc(.12 + var(--focus) * .1)), transparent 60%),
    linear-gradient(180deg, rgb(10 13 18 / .92), rgb(5 6 8 / .95));
  box-shadow: 0 0 calc(30px + var(--focus) * 30px) rgb(22 139 255 / calc(.16 + var(--focus) * .14));
  clip-path: inset(0 0 var(--scan) 0);
  transform-origin: 0 0;
  pointer-events: auto;
  overflow: hidden;
}
.journey-card::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - var(--scan));
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--ice), transparent);
  box-shadow: 0 0 18px 2px rgb(22 139 255 / .8);
  opacity: calc(var(--scan) / 100% * 4);
  pointer-events: none;
}
.journey-card-kind { color: var(--ice); font: 400 .6875rem/1.6 var(--mono); letter-spacing: .13em; text-transform: uppercase; }
.journey-card-title { font-size: clamp(1.25rem, .9rem + 1.1vw, 1.9rem); font-weight: 500; line-height: 1.15; letter-spacing: -.035em; }
.journey-card-lead .journey-card-title { font-size: clamp(1.45rem, 1rem + 1.3vw, 2.15rem); }
.journey-card-text {
  flex-shrink: 0;
  font-size: clamp(.8125rem, .79rem + .1vw, .875rem);
  line-height: 1.6;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.journey-card-lead .journey-card-text { font-size: clamp(.9375rem, .91rem + .15vw, 1.0625rem); }
.journey-card-status {
  margin-top: auto;
  padding-top: .75rem;
  border-top: 1px solid var(--line);
  color: var(--ice);
  font: .6875rem/1.7 var(--mono);
}
.journey-card:hover { border-color: var(--blue); }
.journey-card:focus-visible { outline: 2px solid var(--ice); outline-offset: -4px; }

/* The lead card shows how the system works once the camera brings it close. */
.journey-card-flow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .4rem;
  margin: .5rem 0 0;
  padding: 0;
  list-style: none;
  opacity: var(--focus);
  transform: translateY(calc((1 - var(--focus)) * 6px));
}
.journey-card-flow li {
  position: relative;
  padding-top: .7rem;
  font-size: .72rem;
  line-height: 1.3;
  color: var(--muted);
}
.journey-card-flow li::before {
  content: "";
  position: absolute;
  left: 0;
  right: -.4rem;
  top: .2rem;
  height: 1px;
  background: linear-gradient(90deg, var(--blue), rgb(22 139 255 / .15));
}
.journey-card-flow li::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ice);
  box-shadow: 0 0 8px var(--blue);
}
.journey-card-flow li:last-child::before { right: 0; }
.journey-card-flow b { display: block; color: var(--text); font-weight: 500; }

/* ---------- Closing line ---------- */
.journey-final {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: min(calc(100% - var(--gutter) * 2), 1440px);
  height: var(--frame-h, var(--vh-small));
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 2rem;
  will-change: transform, opacity;
}
.journey-final-line {
  font-size: clamp(2.5rem, 5.6vw, 6rem);
  line-height: 1.03;
  letter-spacing: -.055em;
  text-shadow: 0 3px 28px rgb(0 0 0 / .6);
}
.journey-final-line em { font-style: normal; color: var(--ice); }
@media (max-width: 860px) { .journey-final-line { font-size: clamp(2.5rem, 7.5vw, 4.6rem); } }
@media (max-width: 600px) {
  .journey-final-line { font-size: clamp(2.2rem, 8.8vw, 3rem); }
  .journey-final .button { min-height: 44px; font-size: .7rem; padding: .55rem .8rem; gap: .8rem; }
}
@media (max-height: 600px) and (orientation: landscape) {
  .journey-final { gap: 1rem; }
  .journey-final-line { font-size: 2.4rem; }
}

/* ---------- Progress and loading ---------- */
/* Fixed to the screen's lower edge, so it follows a phone's toolbar as it hides and returns. */
.journey-progress {
  position: fixed;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: #222a35;
  transition: opacity .3s;
}
.journey-progress span {
  display: block;
  height: 100%;
  background: var(--blue);
  transform: scaleX(0);
  transform-origin: 0 50%;
}
html:not(.is-journey) .journey-progress { opacity: 0; }

/* Loading runs along the lower edge of the fixed header. */
.journey-load {
  --load: 0;
  position: absolute;
  left: 0;
  top: calc(var(--header-height) + 1px);
  height: 2px;
  width: 100%;
  background: var(--blue);
  transform: scaleX(var(--load));
  transform-origin: 0 50%;
  transition: opacity 500ms var(--ease) 200ms;
}
.journey.is-loaded .journey-load { opacity: 0; }

/* ---------- Portrait screens: the face sits in the upper part, the copy below it ---------- */
@media (max-aspect-ratio: 28/25) {
  .journey-hero, .journey-final { display: flex; flex-direction: column; justify-content: flex-end; }
  .story-opening, .journey-final { padding: 0 0 max(2.5rem, calc(env(safe-area-inset-bottom) + 1.5rem)); }
  .story-opening .eyebrow { margin-bottom: 1.2rem; }
  .story-positioning { margin-top: 1.1rem; }
  .story-opening .hero-actions { margin-top: 1.25rem; }
  /* Below the chin there is about a quarter of the screen on squarer windows. */
  .story-opening h1 { font-size: max(2.5rem, min(clamp(4rem, 8.2vw, 8.7rem), var(--frame-h, var(--vh-small)) * .217 - 11.4vw - 4.9rem)); }
  .journey-final { gap: 1.5rem; }
  .journey-card-text { -webkit-line-clamp: 3; }
}
@media (max-aspect-ratio: 28/25) and (max-width: 860px) {
  .story-opening h1 { font-size: max(2.5rem, min(clamp(3.4rem, 10vw, 6rem), var(--frame-h, var(--vh-small)) * .217 - 11.4vw - 4.9rem)); }
}
@media (max-aspect-ratio: 28/25) and (max-width: 600px) {
  .story-opening h1 { font-size: clamp(2.5rem, 10.9vw, 4rem); }
  .story-opening .hero-actions { margin-top: 1rem; }
}
@media (max-width: 719px) {
  .journey-card:not(.journey-card-lead) .journey-card-text { display: none; }
  .journey-card:not(.journey-card-lead) .journey-card-title { font-size: 1.05rem; }
}

/* ---------- Static mode: reduced motion, no WebGL, or load failure ---------- */
html.journey-static .journey { height: auto; min-height: var(--vh-small); }
html.journey-static .journey-stage { position: relative; height: var(--vh-small); }
html.journey-static .journey-canvas,
html.journey-static .journey-cards,
html.journey-static .journey-final,
html.journey-static .journey-thought,
html.journey-static .journey-progress,
html.journey-static .journey-load { display: none; }
html.journey-static .journey-poster { display: block; }
html.journey-static .journey-hero { opacity: 1 !important; transform: none !important; visibility: visible; }
@media (max-aspect-ratio: 28/25) {
  html.journey-static .journey-poster { right: 50%; transform: translateX(50%); height: calc(var(--vh-small) * .62); }
}

/* CPU fallback (no WebGL): flat surfaces instead of large blurred shadows, which a
   software compositor would have to re-rasterise every frame. The header keeps the
   solid backing the earlier film used during its guided scroll for the same reason. */
.journey[data-renderer="cpu"] .journey-card {
  box-shadow: none;
  background: rgb(10 13 18 / .96);
}
.journey[data-renderer="cpu"] .journey-card::after { box-shadow: none; }
.journey[data-renderer="cpu"] .journey-thought { text-shadow: 0 0 8px rgb(22 139 255 / .9); }
html.is-journey:has(.journey[data-renderer="cpu"]) .site-header { backdrop-filter: none; background: rgb(5 6 8 / .98); }

@media (forced-colors: active) {
  .journey-card { border-color: CanvasText; }
  .journey-progress span, .journey-load { background: Highlight; }
}
@media print {
  .journey, .journey-stage { height: auto !important; position: relative !important; }
  .journey-canvas, .journey-poster, .journey-thought, .journey-cards, .journey-final,
  .journey-progress, .journey-load { display: none !important; }
  .journey-hero { position: relative; height: auto; opacity: 1 !important; transform: none !important; visibility: visible; }
  .story-opening { padding-block: 2rem; }
}

/* First-visit hint: a quiet prompt to scroll, on the opening frame only, until the visitor moves. */
/* Fixed to the lower edge of what is visible, so a phone's toolbar never covers it. */
.journey-hint {
  position: fixed; left: 50%; bottom: max(1.1rem, calc(env(safe-area-inset-bottom) + .6rem)); z-index: 4;
  display: flex; align-items: center; gap: .8rem; margin: 0; transform: translateX(-50%);
  font: .6875rem/1.6 var(--mono); letter-spacing: .12em; text-transform: uppercase; white-space: nowrap;
  color: #c7cfd9; text-shadow: 0 1px 10px rgba(0, 0, 0, .8); pointer-events: none;
  opacity: 0; transition: opacity .5s var(--ease);
}
.journey.is-ready .journey-hint { opacity: 1; transition: opacity .9s var(--ease) 1.6s; }
.journey.has-scrolled .journey-hint, html.is-touring .journey-hint, html.journey-static .journey-hint { opacity: 0; transition: opacity .3s var(--ease); }
.journey-hint-track { position: relative; flex: none; width: 1px; height: 2.1rem; overflow: hidden; background: rgba(244, 247, 250, .32); }
.journey-hint-track::after {
  content: ""; position: absolute; left: 0; top: -45%; width: 1px; height: 45%; background: #4aa3ff; box-shadow: 0 0 6px #168bff;
  animation: journey-hint-drop 1.9s cubic-bezier(.45, 0, .2, 1) infinite;
}
@keyframes journey-hint-drop { to { top: 100%; } }
.journey-hint .hint-touch { display: none; }
@media (pointer: coarse) {
  .journey-hint .hint-touch { display: inline; }
  .journey-hint .hint-wheel { display: none; }
}
/* Portrait and short screens: the opening copy sits at the bottom, so the hint gets compact and low. */
@media (max-aspect-ratio: 28/25), (max-height: 600px) {
  .journey-hint { bottom: max(.65rem, calc(env(safe-area-inset-bottom) + .35rem)); gap: .6rem; font-size: .625rem; }
  .journey-hint-track { height: 1.05rem; }
}
/* Short landscape screens (a phone on its side): the buttons reach the lower edge, so the hint
   moves under the face, on the right. */
@media (max-height: 600px) and (min-aspect-ratio: 28/25) {
  .journey-hint { left: auto; right: max(1.25rem, calc(env(safe-area-inset-right) + .75rem)); transform: none; }
}
@media (prefers-reduced-motion: reduce) { .journey-hint-track::after { animation: none; top: 30%; } }

/* ---------- Loading screen: the previous site's, for the journey's images ----------
   Shown from the first paint in browsers that can run the journey, until its images are in.
   It never traps anyone: no-script visitors, the static page and reduced motion skip it, and
   if the scripts never arrive it steps aside by itself after 15 seconds. */
.experience-loader {
  position: fixed; z-index: 120; top: 0; left: 0; right: 0; bottom: 0;
  display: none; overflow-y: auto; overscroll-behavior: contain;
  /* 99% opaque: Safari 26 clips fully opaque full-screen overlays at its floating toolbar. */
  padding: 2rem; background: rgb(5 6 8 / .99); color: var(--text);
}
@supports (aspect-ratio: 1) {
  .experience-loader { display: flex; animation: loader-failsafe 0s linear 15s forwards; }
}
@keyframes loader-failsafe { to { visibility: hidden; display: none; } }
html.journey-static .experience-loader, html.loader-done .experience-loader { display: none; }
/* Arriving at a place on the page (Back to portfolio, a link to a section) skips it outright. */
html:has(:target) .experience-loader { display: none; }
html.loader-leaving .experience-loader { opacity: 0; visibility: hidden; transition: opacity .6s var(--ease), visibility 0s .6s; }
html.is-loading, html.is-loading body { overflow: hidden; }
/* The words come in after a moment, so a quick (cached) load never flashes them. */
.loader-inner { width: min(100%, 480px); margin: auto; animation: loader-in .5s var(--ease) .5s both; }
@keyframes loader-in { from { opacity: 0; transform: translateY(8px); } }
.loader-logo { width: 65px; height: auto; color: #168bff; margin-bottom: 3rem; }
.loader-inner .eyebrow { color: #9aaabd; font-size: .58rem; }
.loader-inner h2 { font-size: clamp(2.8rem, 8vw, 4.8rem); line-height: 1.05; letter-spacing: -.055em; margin: 1rem 0 2rem; }
.loader-meter { display: flex; align-items: center; gap: 1rem; }
.loader-bar { flex: 1; height: 3px; background: #24282f; overflow: hidden; }
.loader-bar > span { display: block; height: 100%; background: #168bff; transform: scaleX(var(--load, 0)); transform-origin: 0 50%; transition: transform .35s var(--ease); }
.loader-meter output { font: .72rem/1 var(--mono); width: 3.5rem; text-align: right; color: #8fcbff; }
.loader-status { font-size: .8rem; color: #a6afbc; margin-top: 1rem; min-height: 2.8em; }
.loader-directions { display: flex; gap: 1.5rem; margin-top: 1.35rem; font-size: .79rem; color: #d2dce8; }
.loader-directions span { display: flex; align-items: center; gap: .5rem; }
.loader-directions b { font-size: 1.1rem; color: #8fcbff; font-weight: 400; }
.loader-directions .dir-touch { display: none; }
@media (pointer: coarse) {
  .loader-directions .dir-touch { display: flex; }
  .loader-directions .dir-wheel { display: none; }
}
.loader-skip { background: transparent; border: 0; padding: 0; margin-top: 2rem; min-height: 44px; color: #f4f7fa; }
.loader-note { margin-top: 2rem; color: #858e9c; font: .62rem/1.7 var(--mono); }
@media (max-width: 600px) { .loader-directions { flex-direction: column; gap: .35rem; } }
/* Short screens (a phone on its side): the same screen, closer together. */
@media (max-height: 560px) {
  .experience-loader { padding: 1.25rem 2rem; }
  .loader-logo { width: 44px; margin-bottom: 1.1rem; }
  .loader-inner h2 { font-size: clamp(2rem, 9vh, 2.8rem); margin: .6rem 0 1.1rem; }
  .loader-status { margin-top: .6rem; min-height: 0; }
  .loader-directions { flex-direction: row; gap: 1.5rem; margin-top: .7rem; }
  .loader-skip { margin-top: .6rem; }
  .loader-note { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="full"]) .experience-loader { display: none; }
  .loader-bar > span { transition: none; }
  .loader-inner { animation: none; }
}
@media (forced-colors: active) { .loader-bar > span { background: Highlight; } }
@media print { .experience-loader { display: none !important; } }
