/* harrysergeev.com — interaction layer: spotlight, link icons, light mode (test),
   theater details on phones, trailer window, sound button, background photo.
   Values come from tokens.css. Motion is off for visitors who ask for less motion. */

/* ---------- Light mode (test) ----------
   Only used when <html data-theme="light"> is set by the dark/light switch or ?theme=light. */
:root { color-scheme: dark; }
:root[data-theme="light"] {
  --color-bg: #f4f4f2;         /* white with the faintest warmth, not cream */
  --color-fg: #000;            /* true black for reading */
  --color-muted: #6b6b6b;
  --color-placeholder: #e4e4e1;
  --bg-video-opacity: .65;           /* same as dark mode */
  color-scheme: light;
}
/* Videos and photos behind the text: lifted and softened so dark footage turns into a
   light grey wash and black text stays readable on it. */
:root[data-theme="light"] .bg-video video { filter: grayscale(.25) brightness(1.3) contrast(.72); }
/* The play page in light mode: the top of the page stays a dark stage (photo on black,
   white text) exactly like dark mode, and fades into the light page as the photo fades.
   A dark photo washed onto white turned everything grey, and black text on it looked faded. */
:root[data-theme="light"] .bg-image.scroll-fade { opacity: var(--fade, 1); }
/* the black under the photo is a layer inside it, not its background (Safari would paint its bars black) */
:root[data-theme="light"] .bg-image.scroll-fade::before { content: ""; position: absolute; inset: 0; z-index: -1; background: #000; }
:root[data-theme="light"] .bg-image.scroll-fade img { opacity: var(--bg-video-opacity); }   /* same as dark mode */
/* The black is there from the first moment (the page never shows light first and then
   darkens); only the photo on it lights up slowly, once it has loaded, as in dark mode. */
:root[data-theme="light"] .bg-image.scroll-fade { animation: none; }
:root[data-theme="light"] .bg-image.scroll-fade img { animation: stage-in var(--bg-video-fade) var(--ease-out) both, drift 30s ease-in-out infinite alternate; }
:root[data-theme="light"].stage-lit .bg-image.scroll-fade img { animation: drift 30s ease-in-out infinite alternate; }
:root[data-theme="light"].js .bg-image.scroll-fade img:not(.loaded) { animation-play-state: paused; }
/* The name stays white over the photo; once the page scrolls, its corner shadow turns
   light like the page, so the name turns dark. The play text starts white too and turns
   black when the first chapter number reaches the middle of the screen (fun.js sets .read-top). */
:root[data-theme="light"]:not(.scrolled) .reading .site-header,
:root[data-theme="light"].read-top .reading .play-body,
:root[data-theme="light"] .reading main > .page-title,
:root[data-theme="light"] .reading .split {
  --color-bg: #000;
  --color-fg: #fff;
  --color-muted: #a3a3a3;
  color: var(--color-fg);
  text-shadow: 0 0 24px rgba(0, 0, 0, .3);
}
:root[data-theme="light"] .reading .play-body,
:root[data-theme="light"] .reading .site-header .name { color: var(--color-fg); transition: color var(--page-in) var(--ease), text-shadow var(--page-in) var(--ease); }
/* Menus stay black in light mode: light mode is only for reading the play */
:root[data-theme="light"] .menu,
:root[data-theme="light"] .menu-shown .site-header {
  --color-bg: #000;
  --color-fg: #fff;
  --color-muted: #a3a3a3;
  color: var(--color-fg);
}

/* Text over background videos keeps a faint dark halo, so it stays readable on the
   brightest frames (e.g. Billy Milligan) without dimming the video. */
.bg-video ~ main, .bg-video ~ .site-header { text-shadow: 0 0 24px rgba(0, 0, 0, .3); }
:root[data-theme="light"] .bg-video ~ main, :root[data-theme="light"] .bg-video ~ .site-header { text-shadow: none; }
.bg-video ~ main .trailer { text-shadow: none; }
html { transition: background-color var(--page-in) var(--ease); }
body { transition: color var(--page-in) var(--ease); }

/* Turning the lights on or off: the light page grows out of the bottom-right corner,
   where the button and its corner shadow sit, as a soft circle with a long gradual edge,
   and shrinks back into it when the lights go off. The page is switched in one go
   underneath (no colour fades) and its picture is revealed through the circle (fun.js).
   The circle is a mask whose size grows (no animated custom property), which iPhone
   Safari handles reliably. While it runs, the page colour that Safari paints its bars
   from stays the old one (fun.js holds it on <html> and the new colour is on <body>),
   so the bars change once, at the end, instead of flashing at the start. */
.theme-switching, .theme-switching *, .theme-switching *::before, .theme-switching *::after { transition: none !important; }
.theme-switching body { background-color: var(--color-bg); }
.theme-switching body, .theme-switching body * { view-transition-name: none !important; }
.theme-switching::view-transition-old(root), .theme-switching::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
.theme-switching.theme-on::view-transition-new(root),
.theme-switching.theme-off::view-transition-old(root) {
  -webkit-mask-image: radial-gradient(closest-side, #000 15%, rgba(0, 0, 0, .88) 30%, rgba(0, 0, 0, .62) 50%, rgba(0, 0, 0, .32) 70%, rgba(0, 0, 0, .1) 88%, transparent);
  mask-image: radial-gradient(closest-side, #000 15%, rgba(0, 0, 0, .88) 30%, rgba(0, 0, 0, .62) 50%, rgba(0, 0, 0, .32) 70%, rgba(0, 0, 0, .1) 88%, transparent);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
.theme-switching.theme-on::view-transition-new(root) { animation: theme-reveal var(--menu-in) var(--ease-in-out) both; }
.theme-switching.theme-off::view-transition-old(root) { z-index: 1; animation: theme-reveal var(--menu-out) var(--ease-in-out) reverse both; }
@keyframes theme-reveal {
  from { -webkit-mask-size: 0 0; mask-size: 0 0; -webkit-mask-position: var(--tx) var(--ty); mask-position: var(--tx) var(--ty); }
  to {
    -webkit-mask-size: var(--td) var(--td); mask-size: var(--td) var(--td);
    -webkit-mask-position: calc(var(--tx) - var(--td) / 2) calc(var(--ty) - var(--td) / 2);
    mask-position: calc(var(--tx) - var(--td) / 2) calc(var(--ty) - var(--td) / 2);
  }
}

/* ---------- Play page: "turn lights on / off" in the bottom-right corner ----------
   Appears as soon as the play's description has scrolled away, stays fully visible until
   the second chapter begins, then stays dimmed until the end of the page (full again on
   hover). It fades in and out exactly like the name's corner shadow at the top. */
.read-mode {
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: 25;
  padding: 0 var(--gutter) 18px;
  visibility: hidden;
  transition: visibility 0s var(--page-in);
}
.read-mode.on { visibility: visible; transition: none; }
.read-mode button {
  font: inherit;
  font-size: var(--type-small);
  line-height: 1;
  padding: 14px 0;          /* 44 px tall click area */
  border: 0;
  background: none;
  color: var(--color-fg);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--page-in) var(--ease), color var(--fast) var(--ease);
}
.read-mode.on button { opacity: 1; }
.read-mode.on.dim button { opacity: .4; }
.read-mode button:hover { color: var(--color-muted); }
.read-mode.on.dim:hover button { opacity: 1; color: var(--color-fg); }
/* On phones it sits over the text, so it gets the name's corner shadow (style.css,
   .site-header::before), mirrored into the bottom-right corner: same shape, same fade */
@media (max-width: 900px) {
  .read-mode::before {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    z-index: -1;
    width: min(100vw, 640px);
    height: 230px;
    background: radial-gradient(farthest-side at 100% 100%,
      color-mix(in srgb, var(--color-bg) 88%, transparent),
      color-mix(in srgb, var(--color-bg) 74%, transparent) 30%,
      color-mix(in srgb, var(--color-bg) 45%, transparent) 55%,
      color-mix(in srgb, var(--color-bg) 18%, transparent) 78%,
      transparent);
    opacity: 0;
    transform-origin: 100% 100%;
    transition: opacity var(--page-in) var(--ease), transform var(--page-in) var(--ease);
    pointer-events: none;
  }
  .read-mode.on::before { opacity: 1; }
  /* Dimmed (after chapter 2): the same shadow, same strength, shrinks into the corner to
     half its size, so it covers less of the play. */
  .read-mode.on.dim::before { transform: scale(.5); }
}
.menu-open .read-mode { visibility: hidden; }

/* While the trailer plays, the background video rests and disappears */
.trailer-open .bg-video { opacity: 0 !important; }

/* ---------- Spotlight (mouse only) ----------
   A soft pool of light that follows the mouse, like a follow spot on a dark stage.
   It sits behind the text and never covers it; the normal arrow stays. */
.spotlight {
  position: fixed;
  top: 0;
  left: 0;
  z-index: -1;
  width: 0;
  height: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--page-in) var(--ease);
}
.spotlight::before {
  content: "";
  position: absolute;
  left: -420px;
  top: -420px;
  width: 840px;
  height: 840px;
  border-radius: 50%;
  /* a wide, gradual pool: brightest in the middle, fading out slowly with no visible rim */
  background: radial-gradient(closest-side, rgba(255, 255, 255, .12), rgba(255, 255, 255, .075) 25%, rgba(255, 255, 255, .04) 50%, rgba(255, 255, 255, .015) 75%, transparent);
}
.spotlight.on { opacity: 1; }
/* The open menu covers the page with black, so the light moves on top of it there.
   "screen" only brightens, so the white menu words stay as they are. */
.menu-open .spotlight { z-index: 70; mix-blend-mode: screen; }
:root[data-theme="light"] .spotlight::before { background: radial-gradient(closest-side, rgba(0, 0, 0, .05), rgba(0, 0, 0, .032) 25%, rgba(0, 0, 0, .017) 50%, rgba(0, 0, 0, .006) 75%, transparent); }

/* ---------- Links that leave the site: white, underlined, with a small arrow ----------
   The same pattern marks the email button (copy icon) and downloads (arrow down). */
main a[href^="http"]:not(.trailer),
a.accent, a.link,
.copy-email, .copy-email.link,
a[download] {
  color: var(--color-fg);
  text-decoration: underline;
  text-decoration-thickness: max(1px, .055em);
  text-underline-offset: .1em;
  transition: color var(--fast) var(--ease);
}
main a[href^="http"]:not(.trailer):hover,
a.accent:hover, a.link:hover,
.copy-email:hover, .copy-email.link:hover,
a[download]:hover { color: var(--color-muted); }
main a[href^="http"]:not(.trailer)::after,
a.accent::after, a.link::after,
.copy-email::after,
a[download]::after {
  content: "";
  display: inline-block;
  width: .72em;
  height: .72em;
  margin-left: .2em;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
  vertical-align: -.02em;
}
main a[href^="http"]:not(.trailer), a.accent, a.link {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23000' stroke-width='1.6'%3E%3Cpath d='M2.5 9.5l7-7M4 2.5h5.5V8'/%3E%3C/svg%3E");
}
.copy-email {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23000' stroke-width='1.4'%3E%3Crect x='3.7' y='3.7' width='7.3' height='7.3'/%3E%3Cpath d='M8.3 1H1v7.3'/%3E%3C/svg%3E");
}
a[download] {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23000' stroke-width='1.6'%3E%3Cpath d='M6 1v8M2.5 5.5L6 9l3.5-3.5M1.5 11h9'/%3E%3C/svg%3E");
}
/* ---------- Productions with a film: small film icon after the name ---------- */
.nav-list .has-film > a::after {
  content: "";
  display: inline-block;
  width: .72em;
  height: .58em;
  margin-left: .35em;
  background: currentColor;
  -webkit-mask: var(--film) center / contain no-repeat;
  mask: var(--film) center / contain no-repeat;
  --film: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 14' fill='none' stroke='%23000' stroke-width='1.5'%3E%3Crect x='.75' y='.75' width='16.5' height='12.5'/%3E%3Cpath d='M7 4.2v5.6L11.6 7z' fill='%23000' stroke='none'/%3E%3C/svg%3E");
  vertical-align: .02em;
}

/* ---------- Trailer: still picture that opens the player ---------- */
.trailer {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--color-placeholder);
  color: #fff;
}
.trailer img { width: 100%; height: 100%; object-fit: cover; opacity: .82; transition: opacity var(--page-in) var(--ease), transform var(--menu-in) var(--ease-out); }
.trailer:hover img, .trailer:focus-visible img { opacity: 1; transform: scale(1.03); }
.trailer-play {
  position: absolute;
  left: 20px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: var(--weight-bold);
  font-size: var(--type-label);
  line-height: var(--type-label-lh);
}
.trailer-play svg { width: 18px; height: 18px; fill: currentColor; }
.trailer + p { margin-top: -6px; }
.trailer-dialog {
  width: calc(100vw - 2 * var(--gutter));
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  background: none;
  overflow: visible;
}
.trailer-dialog::backdrop { background: rgba(0, 0, 0, .92); }
.trailer-dialog[open] { animation: fade-in var(--page-in) var(--ease) both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.trailer-frame { position: relative; aspect-ratio: 16 / 9; max-height: calc(100vh - 120px); margin: 0 auto; background: #000; }
.trailer-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.trailer-close {
  position: absolute;
  right: 0;
  top: -34px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: #fff;
  font: inherit;
  font-size: var(--type-small);
  cursor: pointer;
}
.trailer-close:hover { color: var(--color-muted); }

/* ---------- Theater on phones: description opens under the selected name ---------- */
.detail-inline .nav-list .current .summary { padding-bottom: 20px; }
.detail-inline .nav-list .current > .detail { margin: 0 0 48px; }
.detail-inline .split { row-gap: 0; }
.detail { transition: opacity var(--page-in) var(--ease), transform var(--page-in) var(--ease-out); }
.detail.opening { opacity: 0; transform: translateY(-12px); transition: none; }
/* Until fun.js has moved it into the list, the description waits unseen, so it isn't
   drawn once in the wrong place and then blinks out (phones only, only with JavaScript). */
@media (max-width: 900px) { .js .split > .detail { opacity: 0; transition: none; } }

/* ---------- Sound button for background videos (only for videos with sound) ---------- */
.sound-toggle {
  position: fixed;
  right: var(--gutter);
  bottom: 18px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--color-fg);
  font: inherit;
  font-size: var(--type-small);
  line-height: 1;
  cursor: pointer;
}
.sound-toggle:hover { color: var(--color-muted); }
.sound-toggle .eq { display: flex; align-items: flex-end; gap: 2px; height: 12px; }
.sound-toggle .eq i { width: 2px; height: 3px; background: currentColor; }
.sound-toggle[aria-pressed="true"] .eq i { animation: eq .9s ease-in-out infinite alternate; }
.sound-toggle[aria-pressed="true"] .eq i:nth-child(2) { animation-delay: -.3s; animation-duration: .7s; }
.sound-toggle[aria-pressed="true"] .eq i:nth-child(3) { animation-delay: -.6s; animation-duration: 1.1s; }
.sound-toggle[aria-pressed="true"] .eq i:nth-child(4) { animation-delay: -.15s; animation-duration: .8s; }
@keyframes eq { from { height: 2px; } to { height: 12px; } }
.menu-open .sound-toggle { visibility: hidden; }

/* ---------- Background photo (e.g. the play page), same look as the videos ---------- */
.bg-image img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; animation: drift 30s ease-in-out infinite alternate; }
/* On the play page the photo fades out with scrolling (fun.js sets --fade from 1 to 0) */
.bg-image.scroll-fade img { opacity: var(--fade, 1); }
@keyframes drift {
  from { transform: scale(1.04); }
  to { transform: scale(1.1) translate(-1%, -.5%); }
}

/* ---------- Less motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .bg-image img, .sound-toggle .eq i, .trailer-dialog[open] { animation: none !important; }
  .detail, .trailer img { transition: none; }
  .spotlight { display: none; }
}

/* The play's other languages (en, de, ru next to the title) dim on hover like other links */
.nav-list .work-aside a { transition: color var(--fast) var(--ease); }
.nav-list .work-aside a:hover { color: var(--color-muted); }

/* The description moved into the list on phones keeps body-text links, not list-size ones */
.nav-list .detail a { display: inline; font-size: inherit; line-height: inherit; }
.nav-list .detail a.trailer { display: block; }
/* The trailer picture fades in over its placeholder once it has loaded */
.js .trailer img:not(.loaded) { opacity: 0; }
.nav-list .detail a:not(.trailer):hover { color: var(--color-muted); }
