/* Memory Lake (#films). Owned by the films chapter (js/journal-films.js).
   The shared journal pieces (head, plates, notes, foot) are in styles-journal.css. This file sets the opener
   (the title, then the lake laid across the page like water seen from the bank, the stamp pressed on it),
   the lead-in beside the small woodblock print whose water can move, the printed programme slip, the three
   screenings (poster, story, ticket stub; they alternate sides on a wide page and stack on a phone), Shiny
   Celebi's cut-out, and the notes and sources. Every screening carries its poster with kraft corners and
   its ticket stub, plus at most one handwritten note. */

/* ---------- the opener: the title first, then a wide, low strip of the lake ---------- */
.j-head--films { display: flex; flex-direction: column; align-items: stretch; min-height: 0; }
.j-head--films .j-vignette { order: 2; height: 300px; margin: 26px calc(var(--j-pad) * -1) 0; overflow: clip; }
.j-head--films .j-head-text { display: grid; grid-template-columns: minmax(0, 11fr) minmax(0, 9fr); column-gap: 52px; align-items: end; padding-top: 112px; }
.j-head--films .j-head-text > * { grid-column: 1; }
.j-head--films .j-head-text > .j-deck { grid-column: 2; grid-row: 2 / span 2; align-self: end; max-width: none; margin: 0 0 6px !important; }
/* The painting is cropped to its water and jetty and faded out above and below, so the paper shows round it;
   its own watercolour edges finish it at either side. The scale pushes the top of the picture above the clip
   (at 1.3 from 70%, the visible part starts 16% down the mask and ends 93% down), so the fades sit inside
   the visible part and there is no straight edge. */
.j-vignette--films img {
  object-position: 50% 70%; transform: scale(1.3); transform-origin: 58% 70%;
  -webkit-mask-image: linear-gradient(180deg, transparent 17%, #000 38%, #000 72%, transparent 93%);
  mask-image: linear-gradient(180deg, transparent 17%, #000 38%, #000 72%, transparent 93%);
}
.j-head--films .j-stamp { top: 50%; right: auto; left: 34%; width: 160px; height: 160px; translate: 0 -50%; --j-stamp-r: 8deg; }
/* The wash: one loaded dab of indigo under 'Lake', kept within the word's line so that when the title wraps
   it does not run down into the line below. */
.j-head--films .j-wash--a { --x: -.16em; --y: -.12em; --s: 1.3em; --r: -4deg; --o: .44; }

/* ---------- the lead-in, beside the woodblock print of the lake ---------- */
.films-intro { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 390px); gap: 0 60px; align-items: start; margin-top: 50px; }
.films-intro-text p { max-width: 29em; text-wrap: pretty; }
.films-lake { margin-top: 38px; }
.films-lake-window { position: relative; aspect-ratio: 1470 / 630; overflow: hidden; background: #c9c2ad; }
/* The loop is the same print trimmed a little on every side, so the still is enlarged to match it and the
   water starts moving without the picture shifting. */
.films-lake-window img, .films-lake-loop { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; filter: sepia(.12) contrast(.96); }
.films-lake-window img { scale: 1.022; }
.films-lake-loop { opacity: 0; transition: opacity .7s ease; pointer-events: none; }
.films-lake.is-moving .films-lake-loop { opacity: 1; }
.films-lake .j-plate-mount { cursor: pointer; }
.films-lake.is-still .j-plate-mount { cursor: auto; }
.films-lake figcaption { display: flex; flex-wrap: wrap; align-items: center; column-gap: 12px; margin-top: 12px; }
#archive-dialog .films-stir { display: inline-flex; align-items: center; min-height: 44px; padding: 0; font: 500 16px/1.2 var(--j-sc); font-style: normal; letter-spacing: .06em; color: var(--j-place-ink); text-decoration: underline; text-decoration-color: var(--j-link-line); text-underline-offset: 3px; }
#archive-dialog .films-stir[hidden] { display: none; }
.films-stir:hover { text-decoration-color: currentColor; }
.films-note--water { left: 18%; top: -36px; --j-note-r: -4deg; }
.films-note--water .j-arrow { left: 100%; top: 6px; width: 54px; height: 40px; transform: scaleX(-1) rotate(-4deg); }
.films-lake.is-still .films-note--water { display: none; }

/* ---------- the programme slip ---------- */
.films-programme { position: relative; max-width: 700px; margin: 84px auto 0; padding: 30px 40px 22px; }
.films-programme > :not(.j-paper, .j-tape) { position: relative; z-index: 1; }
.films-programme-title { margin: 0; text-align: center; font: 500 18px/1.3 var(--j-sc); letter-spacing: .24em; color: var(--j-ink); }
.films-programme-sub { margin: 4px 0 12px !important; padding-bottom: 12px; text-align: center; font: italic 400 18px/1.4 var(--j-text); color: var(--j-ink-soft); border-bottom: 1px solid var(--j-rule); }
.films-programme ol { list-style: none; margin: 0; padding: 0; }
.films-programme li + li { border-top: 1px dotted #6b4e3a40; }
.films-programme button { display: flex; align-items: baseline; gap: 12px; width: 100%; min-height: 48px; padding: 10px 0; text-align: left; font: 400 19px/1.3 var(--j-text); color: var(--j-ink); }
.films-programme-no { flex: none; width: 1.7em; font: 700 16px/1.3 var(--j-sc); letter-spacing: .04em; color: var(--j-place-ink); }
.films-programme-year { flex: none; width: 2.6em; font: 500 16px/1.3 var(--j-sc); letter-spacing: .04em; color: var(--j-ink-soft); }
.films-programme-name { flex: 0 1 auto; min-width: 0; text-wrap: pretty; }
.films-programme-leader { flex: 1 1 18px; min-width: 18px; border-bottom: 1.5px dotted #6b4e3a88; translate: 0 -.3em; }
.films-programme-where { flex: 0 1 auto; min-width: 0; text-align: right; font: italic 400 17px/1.3 var(--j-text); color: var(--j-ink-soft); }
.films-programme button:hover .films-programme-name { text-decoration: underline; text-decoration-color: var(--j-link-line); text-underline-offset: 3px; }

/* ---------- a screening ---------- */
.films-screenings { display: grid; gap: 124px; margin-top: 118px; }
.films-screening {
  position: relative; display: grid; column-gap: 58px; align-items: start; scroll-margin-top: 96px;
  grid-template-columns: minmax(0, 40fr) minmax(0, 60fr);
  grid-template-rows: auto auto auto auto 1fr;
  grid-template-areas: "plate head" "plate text" "plate ticket" "plate source" "plate extra";
}
/* The middle screening turns the other way, so the posters walk down the page from side to side. */
.films-screening:nth-child(even) {
  grid-template-columns: minmax(0, 60fr) minmax(0, 40fr);
  grid-template-areas: "head plate" "text plate" "ticket plate" "source plate" "extra plate";
}
.films-screening > * { min-width: 0; }
.films-screening-head { grid-area: head; }
.films-poster { grid-area: plate; }
.films-screening-text { grid-area: text; }
.films-screening > .films-ticket-wrap { grid-area: ticket; }
.films-screening-source { grid-area: source; }
.films-shiny { grid-area: extra; }

.films-screening-kicker { display: flex; align-items: baseline; gap: 12px; font: 500 16px/1.3 var(--j-sc); letter-spacing: .12em; color: var(--j-place-ink); }
.films-screening-kicker::after { content: ''; order: 1; width: 34px; height: 1px; background: currentColor; opacity: .5; translate: 0 -.3em; }
.films-screening-year { order: 2; color: var(--j-ink-soft); letter-spacing: .08em; }
.films-screening-title { margin: 8px 0 0; font: 400 46px/1.04 var(--j-display); color: var(--j-ink); text-wrap: balance; outline: none; }
.j-page .films-screening-sub { margin-top: 8px; font: italic 400 21px/1.35 var(--j-text); color: var(--j-ink-soft); text-wrap: balance; }
.films-screening-text { margin-top: 22px; }
.films-screening-text p { max-width: 30em; text-wrap: pretty; }
.j-page .films-screening-aka { margin-top: 10px; font: italic 400 17.5px/1.5 var(--j-text); color: var(--j-ink-soft); }
.films-screening-source .j-source-line { margin-top: 6px !important; }

/* The poster, tipped onto the page with four small kraft corners and turned a degree or two. */
.films-poster { margin-top: 6px; }
.films-poster .j-plate-mount > img { filter: drop-shadow(0 2px 2px #4a2f1a33) drop-shadow(0 12px 16px #4a2f1a2e); }
.films-poster .j-corner { width: 20px; height: 20px; }
.films-poster .j-corner--tl { left: -5px; top: -5px; }
.films-poster .j-corner--tr { right: -5px; top: -5px; }
.films-poster .j-corner--br { right: -5px; bottom: -5px; }
.films-poster .j-corner--bl { left: -5px; bottom: -5px; }
.films-poster figcaption { margin-top: 16px; }
/* Secrets of the Jungle is scanned as a portrait poster on a white 4:3 sheet: only the poster is shown. */
.films-poster--sheet .j-plate-mount > img { aspect-ratio: 250 / 360; object-fit: cover; object-position: 50% 50%; }

/* The cinema ticket stub: tinted card, a perforation with two punched notches, every value set in type. */
.films-ticket-wrap { position: relative; width: 100%; max-width: 500px; margin-top: 30px; filter: drop-shadow(0 1px 1px #4a2f1a33) drop-shadow(0 8px 11px #4a2f1a21); }
.films-ticket {
  --stub: 104px; --notch: 9px; --bg: #e4e8d6; --line: #435d2f4d; --ink: #4f6f39;
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) var(--stub); border-radius: 4px;
  background: linear-gradient(color-mix(in srgb, var(--bg) 86%, transparent), color-mix(in srgb, var(--bg) 86%, transparent)), var(--j-paper-tile) 0 0 / 420px auto, var(--bg);
  -webkit-mask:
    radial-gradient(circle at calc(100% - var(--stub)) 0, #0000 var(--notch), #000 calc(var(--notch) + .5px)) top / 100% 51% no-repeat,
    radial-gradient(circle at calc(100% - var(--stub)) 100%, #0000 var(--notch), #000 calc(var(--notch) + .5px)) bottom / 100% 51% no-repeat;
  mask:
    radial-gradient(circle at calc(100% - var(--stub)) 0, #0000 var(--notch), #000 calc(var(--notch) + .5px)) top / 100% 51% no-repeat,
    radial-gradient(circle at calc(100% - var(--stub)) 100%, #0000 var(--notch), #000 calc(var(--notch) + .5px)) bottom / 100% 51% no-repeat;
}
.films-ticket::before { content: ''; position: absolute; inset: 6px; border: 1px solid var(--line); border-radius: 2px; pointer-events: none; }
.films-ticket--lake { --bg: #e2e4ec; --line: #3f4f8a4d; --ink: #3f4f8a; }
.films-ticket--blossom { --bg: #f4e2e7; --line: #a8405f48; --ink: #a8405f; }
.films-ticket-main { position: relative; padding: 18px 20px 14px 24px; }
.films-ticket .films-ticket-ja { padding-bottom: 9px; margin-bottom: 4px; border-bottom: 1px solid var(--line); font: 500 22px/1.35 'Hiragino Mincho ProN', 'Yu Mincho', YuMincho, 'Noto Serif JP', serif; letter-spacing: .03em; color: var(--j-ink); word-break: keep-all; overflow-wrap: normal; line-break: strict; }
.films-ticket-rows { margin: 0; }
.films-ticket-rows > div { display: grid; grid-template-columns: auto minmax(12px, 1fr) auto; align-items: baseline; column-gap: 8px; padding: 6px 0 1px; }
.films-ticket-rows > div::before { content: ''; grid-column: 2; grid-row: 1; align-self: end; margin-bottom: .4em; border-bottom: 1.5px dotted #6b4e3a80; }
.films-ticket-rows dt { grid-column: 1; grid-row: 1; font: 500 16px/1.3 var(--j-sc); letter-spacing: .05em; color: var(--j-ink-soft); }
.films-ticket-rows dd { grid-column: 3; grid-row: 1; margin: 0; max-width: 15em; font: 500 18px/1.3 var(--j-text); color: var(--j-ink); text-align: right; text-wrap: balance; font-variant-numeric: lining-nums; }
.films-ticket .films-ticket-stub { position: relative; display: grid; align-content: center; justify-items: center; gap: 2px; padding: 14px 8px; border-left: 2px dashed #6b4e3a70; text-align: center; }
.films-ticket-kind { font: 500 16px/1.15 var(--j-sc); letter-spacing: .06em; color: var(--j-ink-soft); max-width: 5em; }
.films-ticket-no { font: 400 44px/1 var(--j-display); color: var(--ink); }

/* Shiny Celebi: the artwork's white sheet multiplies away into the paper, so it reads as a cut-out, held by
   a strip of pink washi. The crop keeps a little white round the figure. */
.films-shiny { position: relative; justify-self: end; width: 200px; margin: 26px 8% 0 0; }
.films-shiny-cut { position: relative; display: block; aspect-ratio: 197 / 212; overflow: hidden; mix-blend-mode: multiply; rotate: -5deg; }
.films-shiny-cut img { position: absolute; left: -73.6%; top: -33.02%; width: 243.65%; max-width: none; height: auto; }
.films-shiny-cut .j-tape { width: 84px; height: 24px; }
.films-shiny figcaption { margin-top: 10px; font: italic 400 16px/1.5 var(--j-text); color: var(--j-ink-soft); text-wrap: pretty; }
.films-note--pink { right: calc(100% + 6px); top: 34%; --j-note-r: -5deg; }
.films-note--pink .j-arrow { left: 72%; top: 26px; width: 64px; height: 42px; transform: rotate(-4deg); }

/* ---------- notes on the programme, and every source ---------- */
.films-notes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 330px); gap: 12px 56px; align-items: start; margin-top: 120px; padding-top: 22px; border-top: 1px solid var(--j-rule); }
.films-notes-title { grid-column: 1 / -1; margin: 0; font: 500 16px/1.3 var(--j-sc); letter-spacing: .12em; color: var(--j-ink); }
.films-notes-body p { max-width: 32em; font-size: 18.5px; line-height: 1.6; text-wrap: pretty; }
.films-notes-body p + p { margin-top: .7em; }
#archive-dialog .films-notes-body .archive-note { margin-top: 1em; font-size: 16.5px; }
.films-sources-title { margin: 2px 0 2px; font: 500 16px/1.3 var(--j-sc); letter-spacing: .12em; color: var(--j-ink-soft); }
.films-sources ol { list-style: none; margin: 0; padding: 0; counter-reset: films-source; }
.films-sources li { display: flex; align-items: baseline; gap: 10px; counter-increment: films-source; }
.films-sources li::before { content: counter(films-source, lower-roman); flex: none; width: 1.6em; font: 500 16px/1.3 var(--j-sc); letter-spacing: .04em; color: var(--j-place-ink); }
/* Each source runs on as words, so a long title wraps with its arrow; the padding keeps a tall tap area. */
.films-sources li { padding: 3px 0; line-height: 1.5; }
#archive-dialog .films-sources .source-link { display: inline; min-height: 0; padding: 10px 0; font-size: 16.5px; line-height: 1.5; }

/* ---------- tablet portrait: the poster beside its title, the stub across the page ---------- */
@container journal (max-width: 879px) {
  .j-head--films .j-head-text { display: block; padding-top: 100px; margin-top: 0; }
  .j-head--films .j-head-text > .j-deck { margin: 16px 0 0 !important; max-width: 26em; }
  .j-head--films .j-vignette { height: 260px; margin: 22px calc(var(--j-pad) * -1) 0; clip-path: none; background: none; }
  .j-vignette--films img {
    object-position: 50% 70%; transform: scale(1.45); transform-origin: 58% 70%;
    /* At 1.45 the visible part runs from 22% to 91% of the mask. */
    -webkit-mask-image: linear-gradient(180deg, transparent 23%, #000 42%, #000 72%, transparent 91%);
    mask-image: linear-gradient(180deg, transparent 23%, #000 42%, #000 72%, transparent 91%);
  }
  .j-head--films .j-stamp { left: 30%; top: 50%; width: 140px; height: 140px; }

  .films-intro { grid-template-columns: minmax(0, 1fr); margin-top: 40px; }
  .films-lake { width: min(100%, 520px); margin: 34px 0 0 auto; }
  .films-note--water { right: auto; left: -4px; top: -54px; }
  .films-note--water .j-arrow { left: 100%; top: 10px; width: 56px; height: 40px; transform: rotate(8deg); }
  .films-lake:not(.is-still) { margin-top: 70px; }

  .films-programme { margin-top: 72px; padding: 28px 32px 20px; }
  .films-screenings { gap: 100px; margin-top: 100px; }
  .films-screening, .films-screening:nth-child(even) { column-gap: 32px; grid-template-rows: auto 1fr; }
  .films-screening { grid-template-columns: minmax(0, 42fr) minmax(0, 58fr); grid-template-areas: "plate head" "plate text" "ticket ticket" "source source" "extra extra"; }
  .films-screening:nth-child(even) { grid-template-columns: minmax(0, 58fr) minmax(0, 42fr); grid-template-areas: "head plate" "text plate" "ticket ticket" "source source" "extra extra"; }
  .films-screening-title { font-size: 40px; }
  .films-screening > .films-ticket-wrap { justify-self: start; margin: 34px 0 0 3%; }
  .films-screening:nth-child(even) > .films-ticket-wrap { justify-self: end; margin: 34px 3% 0 0; }
  .films-shiny { margin-top: 20px; }

  .films-notes { grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 100px; }
  .films-sources { margin-top: 18px; }
}

/* ---------- phones: the reading column ---------- */
@container journal (max-width: 599px) {
  .j-head--films .j-head-text { padding-top: 84px; }
  .j-head--films .j-vignette { height: 200px; margin-top: 18px; }
  /* At 1.75 the visible part runs from 30% to 87% of the mask. */
  .j-vignette--films img {
    transform: scale(1.75); transform-origin: 60% 70%;
    -webkit-mask-image: linear-gradient(180deg, transparent 31%, #000 47%, #000 71%, transparent 87%);
    mask-image: linear-gradient(180deg, transparent 31%, #000 47%, #000 71%, transparent 87%);
  }
  .j-head--films .j-stamp { left: 26%; width: 104px; height: 104px; }

  .films-intro { margin-top: 32px; }
  .films-lake, .films-lake:not(.is-still) { width: 100%; margin: 64px 0 0; }
  .films-note--water { left: 2px; top: -50px; font-size: 20px; }

  .films-programme { margin: 60px -6px 0; padding: 26px 18px 16px; }
  .films-programme-sub { font-size: 17px; }
  /* Each row: numeral, year and title, with the setting on its own line under the title. */
  .films-programme button { display: grid; grid-template-columns: 1.5em 2.6em minmax(0, 1fr); column-gap: 8px; row-gap: 0; font-size: 18px; }
  .films-programme-leader { display: none; }
  .films-programme-where { grid-column: 3; text-align: left; font-size: 16.5px; }

  .films-screenings { gap: 84px; margin-top: 84px; }
  .films-screening, .films-screening:nth-child(even) {
    grid-template-columns: minmax(0, 1fr); grid-template-rows: none;
    grid-template-areas: "head" "plate" "ticket" "text" "source" "extra";
  }
  .films-screening-title { font-size: 36px; }
  .j-page .films-screening-sub { font-size: 19px; }
  /* The poster with its caption beside it, and the stub pasted over the poster's lower edge, so the two read
     as one object; the story follows. */
  .films-poster { display: flex; align-items: flex-end; gap: 14px; margin-top: 24px; }
  .films-screening:nth-child(even) .films-poster { flex-direction: row-reverse; }
  .films-poster > .j-plate-mount { flex: none; width: 62%; }
  .films-poster > figcaption { flex: 1 1 0; min-width: 0; margin: 0 0 30px; }
  .films-screening:nth-child(even) .films-poster > figcaption { text-align: right; }
  #archive-dialog .films-screening > .films-ticket-wrap { position: relative; z-index: 2; justify-self: stretch; max-width: none; margin: -14px 0 0; rotate: -1.2deg; }
  #archive-dialog .films-screening:nth-child(even) > .films-ticket-wrap { rotate: 1deg; }
  .films-screening-text { margin-top: 26px; }

  /* The stub on a phone spans the column: the fields on their leaders, the tear across the foot. */
  .films-ticket {
    --stub-h: 54px;
    grid-template-columns: minmax(0, 1fr); grid-template-rows: auto var(--stub-h);
    -webkit-mask:
      radial-gradient(circle at 0 calc(100% - var(--stub-h)), #0000 var(--notch), #000 calc(var(--notch) + .5px)) left / 51% 100% no-repeat,
      radial-gradient(circle at 100% calc(100% - var(--stub-h)), #0000 var(--notch), #000 calc(var(--notch) + .5px)) right / 51% 100% no-repeat;
    mask:
      radial-gradient(circle at 0 calc(100% - var(--stub-h)), #0000 var(--notch), #000 calc(var(--notch) + .5px)) left / 51% 100% no-repeat,
      radial-gradient(circle at 100% calc(100% - var(--stub-h)), #0000 var(--notch), #000 calc(var(--notch) + .5px)) right / 51% 100% no-repeat;
  }
  .films-ticket-main { padding: 16px 16px 10px 18px; }
  .films-ticket .films-ticket-ja { font-size: 20px; }
  .films-ticket-rows dt { letter-spacing: .02em; }
  .films-ticket-rows dd { font-size: 17px; max-width: none; text-wrap: wrap; }
  /* A setting that wraps keeps its leader on the first line, level with the name. */
  .films-ticket-rows > div::before { align-self: start; margin: 15px 0 0; }
  .films-ticket .films-ticket-stub { grid-auto-flow: column; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 18px; border-left: 0; border-top: 2px dashed #6b4e3a70; }
  .films-ticket-kind { max-width: none; }
  .films-ticket-no { font-size: 32px; }

  .films-shiny { width: 170px; margin: 30px 4% 0 0; }
  .films-note--pink { font-size: 20px; }
  .films-notes { margin-top: 84px; }
  .films-notes-body p { font-size: 18px; }
}

/* ---------- a phone held sideways ---------- */
/* styles-journal.css sizes every plate to the reading window here; the lake print has no picture of its own
   size to shrink round (its window is drawn by aspect ratio), so it is marked j-plate--fluid and keeps the
   width of its column, and the
   cropped jungle poster is given its height outright. */
@media (max-height: 500px) and (orientation: landscape) {
  #archive-dialog .films-lake { width: min(100%, 440px); }
  #archive-dialog .films-poster--sheet .j-plate-mount > img { width: auto; height: calc(100dvh - 230px); }
  /* The deck moves up beside the title again, so the lake shows on the first screen. */
  .j-head--films .j-head-text { display: grid; grid-template-columns: minmax(0, 12fr) minmax(0, 9fr); column-gap: 36px; padding-top: 66px; }
  #archive-dialog .j-head--films .j-title { font-size: 54px; }
  .j-head--films .j-inwhich { font-size: 23px; }
  .j-head--films .j-head-text > .j-deck { margin: 0 0 4px !important; font-size: 17.5px; }
  #archive-dialog .j-head--films .j-vignette { height: min(220px, 46dvh); margin-top: 12px; }
}

/* Reduced motion: the lake stays a print and nothing slides. */
@media (prefers-reduced-motion: reduce) {
  .films-lake-loop { display: none; transition: none; }
  .films-note--water { display: none; }
}
