/* Discretion Labs. One screen that opens up, four lines, a footer.

   The first screen is a mobile made of the two marks of the logo, hanging in morning light. The wall and its
   light are a path-traced photograph (render/mobile.py); the mobile is hung in front of it by site.js and is
   live: it turns and swings, the pointer stirs it, and scrolling pulls the camera back from the first two pieces
   to the whole of it.

   Without script, or when the visitor has asked for less motion, the same screen is one photograph of the whole
   mobile with the four lines set beside it. The live styles apply only under .film-on (set by first.js). */

:root {
  --wall: #FDFAF4;                          /* the foot of the sunlit wall in the film (measured on the photograph), so the page carries on from it */
  --rule: rgba(20, 23, 27, 0.13);
  --settle: cubic-bezier(0.3, 0.75, 0.2, 1);
}

* { box-sizing: border-box; }

html {
  background: var(--wall);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--wall);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }

a { color: inherit; text-decoration: none; }
.arrow { display: inline-block; margin-left: 0.26em; font-size: 0.86em; transition: transform 0.3s var(--settle); }
a:hover .arrow, a:focus-visible .arrow { transform: translate(0.12em, -0.12em); }
a:focus-visible { outline: 2px solid var(--blue); outline-offset: 5px; border-radius: 2px; }

/* ---------- the film ---------- */

.film { position: relative; }

.stage {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
}

/* the photograph of the whole mobile; replaced by the live one under .film-on */
.picture {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--wall) url("/assets/room/still.jpg") 62% 50% / cover no-repeat;
}

.wall, .shade, .reel, .gloss { display: none; }

/* the foot of the picture runs out into the page (under the mobile, over the wall and the shadows) */
.picture::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: auto 0 0 0;
  height: 16%;
  background: linear-gradient(to bottom, rgba(253, 250, 244, 0), var(--wall));
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  padding: var(--edge);
  padding-top: max(var(--edge), env(safe-area-inset-top));
}

.logo { display: block; line-height: 0; }
.logo img { display: block; height: 1.3rem; width: auto; }

.out { font-weight: 500; letter-spacing: -0.01em; transition: color 0.2s ease; }
.out:hover, .out:focus-visible { color: var(--blue); }

.lines {
  grid-row: 3;
  display: grid;
  gap: 0.9rem;
  padding: 0 var(--edge) clamp(1.6rem, 5vh, 3rem);
}

.line {
  max-width: 24em;
  font-size: clamp(1.05rem, 1.5vw, 1.3rem);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

.line span { display: block; color: var(--text-2); }

h1.line,
.film-on .line {
  max-width: min(15em, 44vw);              /* the words keep to the left, clear of the mobile */
  font-size: clamp(1.9rem, 3.05vw, 3.3rem);
  line-height: 1.07;
  letter-spacing: -0.037em;
  text-wrap: balance;
}

h1.line { margin-bottom: 0.5rem; }

.cue { display: none; }

/* with script and motion: the screen stays put while the film runs, and the lines take turns */
/* The scroll is the reader's own: nothing takes it over, it never snaps, and it can rest anywhere. (The
   browser's own gentle snap, scroll-snap-type: y proximity, was tried and taken out: with four resting places
   this far apart, Chrome pulled a single notch of a mouse wheel back to where it started.) What makes a free
   scroll safe is in site.js: each line holds for a whole stretch of it and the stretches meet, so wherever the
   scroll stops, one whole line is on the screen. */
.film-on .film { height: 340vh; }

.film-on .stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  min-height: 0;
}

.film-on .picture { background: var(--wall); }

/* the wall is one large photograph, moved and scaled by the script as the camera moves */
.film-on .wall {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  transform-origin: 0 0;
  opacity: 0;
  transition: opacity 0.7s ease;
  will-change: transform;
  /* the photograph ends a little above the floor; its last tenth runs out into the colour of the page (--wall).
     That fade is in the file itself (see the README), not a mask here: a mask over so large a picture is one more
     layer for the browser to keep. */
}

.film-on .lit .wall { opacity: 1; }

.film-on .shade,
.film-on .reel,
.film-on .gloss {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.film-on canvas[hidden] { display: none; }                     /* the flat drawing's canvases, while the solid renderer draws */
.film-on .shade { z-index: 1; mix-blend-mode: multiply; }     /* the flat drawing's shadows (plates.js draws its own): they darken the wall, they do not paint over it */

/* a piece can be picked up */
.film-on .stage.near { cursor: grab; }
.film-on .stage.holding { cursor: grabbing; -webkit-user-select: none; user-select: none; }
.film-on .reel { z-index: 3; }                                  /* wire and thread */
.film-on .gloss { z-index: 4; }                                 /* the mobile as lit solids, and its shadows on the wall */

.film-on .lines { display: block; position: relative; }
.film-on h1.line { max-width: 16em; margin-bottom: 0; }   /* the first frame has room for it on one line */

.film-on .line {
  position: absolute;
  left: var(--edge);
  right: var(--edge);
  bottom: clamp(4.2rem, 10vh, 5.6rem);
  opacity: 0;
  transform: translateY(0.3em);
  transition: opacity 0.26s ease, transform 0.26s ease;      /* a line leaves quickly... */
  pointer-events: none;
}

.film-on .line.on {
  opacity: 1;
  transform: none;
  transition: opacity 0.6s ease 0.3s, transform 0.85s var(--settle) 0.3s;   /* ...and the next waits for it to go */
}

.film-on .cue {
  display: flex;
  position: absolute;
  right: var(--edge);
  bottom: clamp(4.2rem, 10vh, 5.6rem);
  align-items: center;
  gap: 0.7rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  transition: opacity 0.5s ease;
}

.film-on .cue::after {
  content: "";
  width: 1px;
  height: 2.4rem;
  background: currentColor;
  opacity: 0.6;
}

.film-on .moved .cue { opacity: 0; }

/* while the film is moving, the logo and the link step aside */
.film-on .top { transition: opacity 0.5s ease; }
.film-on .playing .top { opacity: 0; pointer-events: none; }
.film-on .playing .top:focus-within { opacity: 1; pointer-events: auto; }

/* ---------- the foot of the page: one row, on the last screen ---------- */

.foot {
  grid-row: 4;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.3rem 2rem;
  padding: 0 var(--edge) 1.4rem;
  padding-bottom: max(1.4rem, env(safe-area-inset-bottom));
  font-size: 0.88rem;
  color: var(--text-2);
}

.foot a { transition: color 0.2s ease; }
.foot a:hover, .foot a:focus-visible { color: var(--ink); }

/* live: it waits under the last line and comes up when the camera has arrived */
.film-on .foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.film-on .ended .foot { opacity: 1; pointer-events: auto; }
.film-on .foot:focus-within { opacity: 1; pointer-events: auto; }

/* ---------- upright screens ---------- */

@media (max-aspect-ratio: 17/20) {
  .picture { background-image: url("/assets/room/still-tall.jpg"); background-position: 50% 30%; }
  .film-on .picture { background-image: none; }
  h1.line, .film-on .line { max-width: 13em; font-size: clamp(1.75rem, 7.6vw, 2.6rem); }
  .film-on .line { bottom: 5.8rem; }                          /* clear of the two rows of the footer */
  .film-on .cue { display: none; }
}

@media (max-width: 760px) {
  .logo img { height: 1.05rem; }
}
