/* Intro-Startseite.
   Liegt bewusst in einer eigenen Datei (samt js/vibe.js, vibe/ und dem
   Abschnitt <section class="vibe"> in index.html). Nutzt ausschließlich Raster, Farben,
   Schriftgrößen und Easing der restlichen Seite (siehe style.css). */

/* The home page has two states (js/vibe.js, html.vibe-on):
   - intro (vibe-on): the pictures fill the screen, fixed above the overview;
     the page does not scroll.
   - overview (no vibe-on): the intro is gone — no scrolling back up to it.
   A swipe, a key or a click on "work" cross-fades from the first to the
   second (html.vibe-out); the wordmark fades back into the intro. */
.vibe {
  position: relative;
  height: 100vh;
  overflow: hidden;
  /* never a bare background: a photo (chosen at random by the inline script
     in index.html) lies under everything from the first paint on; black only
     without it */
  background-color: #000;
  transition: opacity 1s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@media (max-width: 700px) {
  .vibe {
    /* the bar stays out, so the visible height is the small one */
    height: 100svh;
  }
}

html.vibe-on .vibe {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1;
}

html:not(.vibe-on) .vibe {
  display: none;
}

.vibe.is-hidden,
html.vibe-out .vibe {
  opacity: 0;
}

/* no scrolling while the intro is up (desktop: the page, mobile: its
   scroller) */
html.vibe-on {
  overflow: hidden;
}

/* No visible scrollbar on the home page (desktop). A classic scrollbar would
   appear only once the overview takes over and narrow the page by its width —
   everything would shift left for a moment, and the grid (--real-vw,
   js/real-vw.js) would follow late. Without it the intro runs to the very
   edge and nothing moves; the overview still scrolls by wheel, trackpad and
   keys. */
@media (min-width: 701px) {
  html.home {
    scrollbar-width: none;
  }

  html.home::-webkit-scrollbar {
    display: none;
  }
}
html.vibe-on .home-scroll {
  overflow: hidden;
}

/* the overview waits invisibly behind the intro and fades in as it leaves */
html.vibe-on .archive {
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s cubic-bezier(0.22, 0.61, 0.36, 1);
}

html.vibe-on.vibe-out .archive {
  opacity: 1;
}

/* the picture layer: sits under the fixed header, wordmark and bottom line */
.vibe-stage {
  position: absolute;
  inset: 0;
  cursor: pointer;
  /* its own stacking context at the very bottom: however high the pictures'
     z-index climbs inside, nothing in here can ever reach above the
     labels (bottom line 2, header/wordmark 10, cursor 11) */
  z-index: 0;
  isolation: isolate;
  /* the seed photo (chosen in the head of index.html) under everything */
  background-image: var(--vibe-seed, none);
  background-size: cover;
  background-position: center;
}

.vibe-stage:focus-visible {
  outline-offset: -6px;
}

/* every medium starts and ends on column edges of the 12-column grid:
   --c is its first column, --n the number of columns it spans. They always
   stand centred on the screen; the new one fades in over the previous. */
.vibe-item {
  position: absolute;
  margin: 0;
  left: calc(var(--margin) + (var(--c) - 1) * (var(--col) + var(--gutter)));
  width: calc(var(--n) * var(--col) + (var(--n) - 1) * var(--gutter));
  opacity: 0;
  /* plain, soft fade — same easing as the sheet and the end-of-page fade in
     style.css */
  transition: opacity 1.2s cubic-bezier(0.22, 0.61, 0.36, 1);
  pointer-events: none;
}

.vibe-item img,
.vibe-item video {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}

/* a video lies invisibly over its still and appears once it plays; no browser
   controls anywhere */
.vibe-item video.vibe-video {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.vibe-item video.vibe-video.is-playing {
  opacity: 1;
}

.vibe-item video::-webkit-media-controls,
.vibe-item video::-webkit-media-controls-start-playback-button {
  display: none !important;
  -webkit-appearance: none;
}

.vibe-item.is-in {
  opacity: 1;
}

/* opening sequence: js/vibe.js sets each medium's fade time inline, along a
   curve (short at the start, as long as the normal fade at the end) */

.vibe-item.is-out {
  opacity: 0;
  transition: opacity 0.9s ease;
}

/* the full-screen moment: one medium fills the whole picture layer
   (the only place where cropping happens) */
.vibe-item.is-full {
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}

/* bottom line: the description, white with a tight shadow on the letters */
.vibe-bar {
  position: absolute;
  left: 0;
  right: 0;
  /* above the links row (a 24px line plus 8px of air) */
  bottom: calc(var(--margin) + 32px);
  z-index: 2;
  font-size: var(--size-small);
  line-height: 1.5;
  color: #fff;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.5), 0 1px 6px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

/* a short paragraph as a centred block on the page's centre axis (columns
   2–11, wide enough for two lines), growing upward from the bottom edge */
/* The text as a film poster's credit block: small capitals, set tight, a solid
   rectangle with a straight edge on both sides — also in the last line.
   Desktop: as many of the middle columns as it needs to read as a block
   (--vibe-cols, centred), not edge to edge. */
/* Suisse Int'l has no Japanese glyphs — system fonts only, no Japanese webfont */
/* a hyphen is a place to break a line: not inside this word */
.vibe-keep {
  white-space: nowrap;
}

.vibe-ja {
  white-space: nowrap;
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
}

.vibe-desc {
  /* centred on the middle axis, with a fixed width tuned to the text, so it
     breaks the same way on every desktop screen: three full lines, none ending
     on a dash or slash. A change to the text needs a new width.
     Tablets have their own width below, phones are fitted by script. */
  grid-column: 1 / -1;
  justify-self: center;
  width: min(832px, 100%);
  margin: 0;
  font-size: 9.5px;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-align: justify;
  text-align-last: justify;
  text-transform: uppercase;
  -webkit-hyphens: none;
  hyphens: none;
}


/* e-mail · instagram: on the centre line at the right edge — the same axis
   as the wordmark and "work · contact" */
.vibe-foot {
  display: contents;
}

/* e-mail · instagram: centred beneath the text, in the bottom row */
.vibe-links {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--margin);
  justify-content: center;
  z-index: 2;
  display: flex;
  margin: 0;
  color: #fff;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.5), 0 1px 6px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.vibe-links a {
  /* Regular, like the wordmark */
  font-weight: 400;
  color: #fff;
  text-decoration: none;
  text-transform: lowercase;
  pointer-events: auto;
}



.vibe-links a:nth-of-type(2) {
  order: 2;
}

/* the middle dot between the two: a character on the container, not part of a
   link (shared separator rule in style.css) */
.vibe-links::after {
  font-weight: 400;
}

.vibe-links a:hover {
  opacity: 0.6;
}


/* The fixed chrome (wordmark, "work · contact", the dot) lies above the
   pictures: white while the intro covers the screen (class set by js/vibe.js;
   js/chrome.js reads it). Before the script has run it is already white. */
html.vibe-white {
  --ink: #fff;
}

/* Desktop: while the intro is on screen, the wordmark (left) and "work ·
   contact" (right) stand on the centre line, and glide up into the top row as
   the overview fades in (class vibe-chrome set by js/vibe.js). */
@media (min-width: 701px) {
  .site-nav {
    transition: transform 0.9s cubic-bezier(0.22, 0.61, 0.36, 1);
  }

  .wordmark-fixed {
    transition: transform 0.9s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.2s ease;
  }

  html.vibe-chrome .wordmark-fixed {
    /* top row: 24px padding + half of a 24px line = 36px */
    transform: translateY(calc(50vh - 36px));
  }

  /* "work · contact" is flush right on every sub page; on the intro it keeps its
     old place, left of the right edge (--intro-dx, measured by js/vibe.js) */
  html.vibe-chrome .site-nav {
    transform: translate(var(--intro-dx, 0px), calc(50vh - 36px));
  }
}

/* windows too narrow for the three lines: four */
@media (min-width: 701px) and (max-width: 871px) {
  .vibe-desc {
    width: min(628px, 100%);
  }
}

@media (max-width: 700px) {
  /* The text (second sentence, a few words more) as a capitals block, and
     beneath it hello@chrisnakahara.com • instagram centred on the middle
     axis — white with a soft shadow on the photos, no blur. */
  .vibe-bar {
    right: auto;
    left: 0;
    width: 100%;
    bottom: calc(var(--margin) + 26px);
  }

  /* A film poster's credit block: small capitals, set tight, a solid
     rectangle with a straight edge on both sides — also in the last line —
     narrower than the screen and centred. */
  /* no grid on mobile: a plain block, centred between the two margins */
  .vibe-bar {
    display: block;
    padding-inline: var(--margin);
  }

  .vibe-desc {
    /* from margin to margin, like every other element on the phone */
    width: 100%;
    margin-inline: auto;
    font-size: 9.5px;
    line-height: 1.2;
    letter-spacing: 0.02em;
    text-align: justify;
    text-align-last: justify;
    text-transform: uppercase;
    -webkit-hyphens: none;
    hyphens: none;
  }

  .vibe-links {
    left: 0;
    right: 0;
    top: auto;
    transform: none;
    bottom: var(--margin);
    justify-content: center;
    font-size: var(--size-small);
    line-height: 1.5;
  }


  /* Full screen. A FIXED layer at the screen edge makes Safari paint a flat
     strip of its average colour over the bars — the photo itself stops at the
     edge. And the large viewport height (lvh) does not cover the whole screen
     either. So on the intro the picture layer is ordinary page content,
     taller than the visible part: --vibe-pad-top reaches up under the status
     bar (the page begins below it; js/vibe.js scrolls it down by exactly this
     much and holds it), --vibe-pad-bottom reaches down under the browser bar.
     Nothing can scroll it away: the page is static (touch-action none,
     below). Its text keeps its place on the visible screen. */
  html.vibe-on {
    --vibe-pad-top: 80px;
    --vibe-pad-bottom: 160px;
    overflow: visible;
    overscroll-behavior: none;
  }

  html.vibe-on .home-scroll {
    position: relative;
    inset: auto;
    height: calc(100vh + var(--vibe-pad-top) + var(--vibe-pad-bottom));
    height: calc(100svh + var(--vibe-pad-top) + var(--vibe-pad-bottom));
    overflow: hidden;
    scroll-snap-type: none;
  }

  html.vibe-on .vibe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    overflow: hidden;
  }

  .vibe-bar {
    bottom: calc(var(--vibe-pad-bottom) + var(--margin) + 26px);
  }

  .vibe-links {
    bottom: calc(var(--vibe-pad-bottom) + var(--margin));
  }

  /* the intro is static: no scrolling, no browser gestures on the picture
     layer — swipes and taps both show the next medium (js/vibe.js) */
  .vibe-stage {
    touch-action: none;
  }

  /* The wordmark stays in its place at the top. "work · contact" stands at the
     right edge, at the middle of the screen's height, while the intro is up
     and glides up into the header row when "work" or "contact" is pressed
     (class vibe-chrome, removed by js/vibe.js). */
  .site-nav {
    transition: transform 0.9s cubic-bezier(0.22, 0.61, 0.36, 1);
  }

  html.vibe-chrome .site-nav {
    /* down from the header row to the middle of the screen, still at the
       right margin */
    transform: translateY(calc(50svh - 28px - env(safe-area-inset-top, 0px)));
  }

  /* "work · contact": the intro is the only place where "work" is needed on
     the home page — it leads to the overview, like the swipe */
  html.vibe-on .site-nav a[href="/work/"] {
    display: inline;
  }

  html.vibe-on .site-nav::after {
    display: block;
  }
}

/* cursor indicator (desktop with a mouse): an inverting circle follows the
   pointer over the picture layer, the normal cursor is hidden there. The
   circle itself is the clock: full at first, eaten away clockwise until the
   next medium arrives (js/vibe.js restarts the animation with every new
   timer). No extra line around it. */
.vibe-cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 11;
  /* the same dot as the theme toggle in the header */
  width: var(--dot);
  height: var(--dot);
  mix-blend-mode: difference;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.vibe-cursor svg {
  display: block;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

/* a circle of radius 5 drawn with a stroke 10 wide is a filled disc; its
   dash offset eats it away like a pie (circumference 2π·5 = 31.42) */
.vibe-ring-progress {
  fill: none;
  stroke: #fff;
  stroke-width: 10;
  stroke-dasharray: 31.42;
  stroke-dashoffset: 0;
}

@keyframes vibe-ring {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: 31.42;
  }
}

/* after the fast opening sequence the dot pulses softly — a hint that it can
   be clicked */
.vibe-cursor.is-pulsing svg {
  animation: vibe-pulse 0.55s ease-in-out 2;
}

@keyframes vibe-pulse {
  0%,
  100% {
    transform: rotate(-90deg) scale(1);
  }

  50% {
    transform: rotate(-90deg) scale(1.4);
  }
}

.vibe-cursor.is-on {
  opacity: 1;
}

/* no normal pointer anywhere while the intro is up — not over the picture
   layer, not over links or the wordmark: the circle is the only cursor. It
   returns as soon as the intro starts to leave (then the circle flies off). */
html.vibe-cursor-active.vibe-on:not(.vibe-out),
html.vibe-cursor-active.vibe-on:not(.vibe-out) * {
  cursor: none !important;
}

@media (prefers-reduced-motion: reduce) {
  /* no running clock: the circle stays full */
  .vibe-ring-progress {
    animation: none !important;
  }

  /* simple cross-fades only (style.css switches all transitions off, so the
     fade is switched back on here) */
  .vibe-item,
  .vibe-item.is-in,
  .vibe-item.is-out {
    transition-duration: 0.8s !important;
  }
}

/* The light/dark toggle (css/style.css) is not needed on the intro — it has
   no light and dark. It keeps its place (so "work · contact" does not shift)
   but stays invisible, and fades in as the overview takes over. */
.theme-toggle {
  transition: opacity 0.9s cubic-bezier(0.22, 0.61, 0.36, 1);
}

html.vibe-on:not(.vibe-out) .theme-toggle {
  opacity: 0;
  pointer-events: none;
}

/* it appears as the cursor circle arrives from the intro */
html.vibe-out .theme-toggle {
  transition: opacity 0.3s ease 0.65s;
}

/* leaving for another page ("contact"): the intro fades away while the nav
   glides up, then the page changes */
html.vibe-away .vibe {
  opacity: 0;
}

/* The slim position marker on the right edge (js/vibe.js): white, inverted by
   the blend so it reads on the light page and on photos alike. */
.scroll-cue {
  position: fixed;
  top: 0;
  /* the size of a classic Safari scrollbar: a 15px track with a 9px thumb */
  right: 3px;
  width: 9px;
  height: 100vh;
  z-index: 20;
  mix-blend-mode: difference;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.scroll-cue.is-on {
  opacity: 1;
}

.scroll-cue span {
  display: block;
  width: 100%;
  border-radius: 5px;
  background: #fff;
}
