/* Below the first screen: the journey. Stops (close paintings) and bands (the line on the hillside). */

/* The story is told as the Planet of Lana site tells its own: crisp frames with a rough, brushed edge
   on one flat, calm night, and between them a few centred words with a small mark under the heading.
   Nothing fades or blurs into anything. */

/* a late picture shows only once it has arrived, as on the first screen */
.painting img, .hill img { opacity: 0; }
.painting img.in, .hill img.in { opacity: 1; }

/* ---- a stop: its words, then its frame ----
   On a phone the frame runs the full width, cut top and bottom. */
.stop { position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--words-gap); padding-top: var(--stop-gap); }
.words { position: relative; z-index: 2; max-width: var(--measure); padding: 0 var(--gutter); text-align: center; }
.words h2 { font-family: var(--display); font-weight: 500; font-size: var(--heading); line-height: 1.05; color: var(--filament); font-variant-numeric: lining-nums; text-wrap: balance; }
/* the mark under a heading: a brass line with a knob at its middle, like a junction on the board */
.words h2::after { content: ""; display: block; width: var(--ornament); height: 11px; margin: 0.5em auto 0; background: var(--brass); -webkit-mask: var(--mark) center / contain no-repeat; mask: var(--mark) center / contain no-repeat; }
.words p { margin-top: 1em; font-family: var(--display); font-weight: 500; font-size: var(--story); line-height: 1.45; color: var(--story-ink); text-wrap: pretty; }
.painting { position: relative; width: min(100%, var(--painting-max)); aspect-ratio: 1440 / 1858; margin: 0; }
/* where the frame is narrower than the screen it stands free, cut on all four sides */
/* The cut is made on the box inside a frame (the frame itself is what is painted in: css/reveal.css).
   Top and bottom are cut out of the picture; the two sides of a frame that stands free are the page's
   night laid over it in the same rough shape. */
.cut { position: absolute; inset: 0; overflow: clip; -webkit-mask: var(--cut-y); mask: var(--cut-y); }
.cut::before, .cut::after { content: ""; position: absolute; top: 0; bottom: 0; width: var(--edge); background: var(--night); z-index: 4; pointer-events: none; display: none; }
.cut::before { left: -1px; -webkit-mask: url("../assets/img/edge/left.webp") left top / 100% auto repeat-y; mask: url("../assets/img/edge/left.webp") left top / 100% auto repeat-y; }
.cut::after { right: -1px; -webkit-mask: url("../assets/img/edge/right.webp") right top / 100% auto repeat-y; mask: url("../assets/img/edge/right.webp") right top / 100% auto repeat-y; }
.hill .cut::before, .hill .cut::after { display: block; }
@media (min-width: 681px) { .painting .cut::before, .painting .cut::after { display: block; } }
.painting img { position: absolute; inset: 0; width: 100%; height: 100%; }
.painting canvas { position: absolute; pointer-events: none; }
/* (only its top and foot are softened: its sides are the fall's own) */
.painting canvas.fall { mix-blend-mode: screen; -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 12%, #000 80%, transparent 100%); mask-image: linear-gradient(to bottom, transparent 0, #000 12%, #000 80%, transparent 100%); }

/* the cable from the first screen carries on a little way toward the story */
#powerhouse::before { content: ""; position: absolute; left: var(--cue-x, 50%); top: 0; width: var(--cable); height: min(15vh, 150px); margin-left: calc(var(--cable) / -2); background: linear-gradient(to bottom, var(--brass), transparent); opacity: 0.8; }

/* A stop with a dark and a lit picture is dark until js/light.js lights it; then the lit picture is
   shown and the dark one put away, so the two are never seen together. Without JavaScript it is lit. */
html.js .stop:not(.lit):not(.lighting) .painting img.dark ~ img.lit { opacity: 0; }
.stop.lit .painting img.dark { visibility: hidden; }

/* from 11:10 the painting stands to one side and the words beside it */
@media (min-aspect-ratio: 11/10) {
  .stop { flex-direction: row; justify-content: center; gap: var(--gutter); padding: var(--stop-gap) var(--gutter) 0; }
  .stop .words { flex: 0 1 var(--measure-side); padding: 0; text-align: left; }
  .stop .words h2::after { margin-left: 0; -webkit-mask-position: left center; mask-position: left center; }
  .painting { flex: 0 0 auto; width: auto; height: var(--painting-side); margin: 0; }
  #cottage .words { order: 2; }
}

/* ---- the band: one small frame of dark hillside where the line is seen to set out. It stands free,
   like a plate, and shows a window two wide by one tall on its wide painting (--centre, js/band.js). The
   same painting with the far cottages' windows lit lies over it, shown only round each cottage as it lights ---- */
.band { position: relative; padding-top: var(--stop-gap); display: grid; justify-items: center; gap: var(--words-gap); }
/* (its words get their full measure, clear of the gutters, so the heading stays on one line on a wide screen) */
.band .words { width: 100%; max-width: calc(var(--measure) + 2 * var(--gutter)); }
.hill { position: relative; width: min(100% - 2 * var(--gutter), var(--band-max)); aspect-ratio: 2 / 1; }
.hill canvas.wind { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* a far cottage's light in the mist */
.far-light { position: absolute; width: 5%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(closest-side, var(--lamp-pool), var(--lamp-pool-far) 55%, transparent); mix-blend-mode: screen; opacity: 0; pointer-events: none; }
.far-light.on { opacity: 1; }
.hill .pan { position: absolute; top: 0; height: 100%; aspect-ratio: 2560 / 893; left: 50%; transform: translateX(calc(-1 * var(--centre, 50%))); }
.hill img { position: absolute; inset: 0; width: 100%; height: 100%; }
.line { position: absolute; inset: 0; pointer-events: none; }
/* poles and wire stand on the hillside: they wait for its picture (js/band.js marks the band) */
html.js .band:not(.has-hill) .line { visibility: hidden; }
.line svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.line .pole { position: absolute; }
.line .pole img { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 1; filter: var(--lamp-pole-tone); }
/* the lit picture gives only the lamp and what its light falls on; the post below stays in the night */
.line .pole img.lit { opacity: 0; filter: none; -webkit-mask-image: var(--lamp-reach); mask-image: var(--lamp-reach); }
.line .pole.on img.lit { opacity: 1; }
.line .pole .foot { position: absolute; left: 50%; top: 99.4%; width: 190%; aspect-ratio: 3 / 1; transform: translate(-50%, -50%); background: radial-gradient(closest-side, var(--ground-shadow), transparent); z-index: -1; }
/* a lit lamp's pool of light in the night air */
.line .pole .halo { position: absolute; width: 330%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(closest-side, var(--lamp-pool), var(--lamp-pool-far) 50%, transparent); mix-blend-mode: screen; opacity: 0; }
.line .pole.on .halo { opacity: 1; }
.line path { fill: none; stroke-linecap: round; stroke-width: var(--wire); stroke-dasharray: 100; stroke-dashoffset: 100; }
.line .shade { stroke: var(--ink); stroke-opacity: 0.4; stroke-width: calc(var(--wire) * 2.6); }
.line .wire { stroke: var(--mist); stroke-opacity: 0.92; }
.line .spark { fill: var(--filament); opacity: 0; filter: drop-shadow(0 0 3px var(--amber)); }

/* ---- motion ---- */
@keyframes spread-lamp { from { --reveal: 0.05; } to { --reveal: 1.3; } }
@media (prefers-reduced-motion: no-preference) {
  .painting img, .hill img { transition: opacity var(--dawn) ease-out; }
  .line .pole img.lit, .line .pole .halo { transition: opacity var(--lamp-on) ease-out; }
  .far-light { transition: opacity var(--lamp-on) ease-out; }
  .far-light.on { animation: breathe var(--breathe) ease-in-out var(--lamp-on) infinite; }
  /* the pool of light fades up with the lamp, and only then begins to waver */
  .line .pole.on .halo { animation: breathe var(--breathe) ease-in-out var(--lamp-on) infinite; }
  /* lighting: a flicker at the lamp, then its light spreading over the painting (as the valley's opening) */
  .stop.lighting .painting img.lit {
    opacity: 1;
    -webkit-mask-image: radial-gradient(circle farthest-corner at var(--lamp-x) var(--lamp-y), #000 calc(var(--reveal) * 100% - 14%), transparent calc(var(--reveal) * 100%));
    mask-image: radial-gradient(circle farthest-corner at var(--lamp-x) var(--lamp-y), #000 calc(var(--reveal) * 100% - 14%), transparent calc(var(--reveal) * 100%));
    animation: lamp-on var(--lamp-on) linear both, spread-lamp var(--light-up) cubic-bezier(0.3, 0.45, 0.3, 1) var(--lamp-on) both;
    transition: none;
  }
}
