:root {
  color-scheme: light;
  --gallery-height: 100svh;
  --paper: #f4f1ea;
  --paper-texture: url("/assets/469e392d6ac8ad71d6ac33a9bdd24d41b592c40ec98e35582c1e107edd975274.webp");
  --paper-wash: color-mix(in srgb, var(--paper) 55%, transparent);
  --paper-surface: linear-gradient(var(--paper-wash), var(--paper-wash)), var(--paper-texture);
  --ink: #3d3b35;
  --muted: #6f6a60;
  --hover: #e7e2d8;
  --focus: #645f50;
  --accent: #a44d32;
  font-family: "GHEA Narek Serif", Georgia, "Times New Roman", serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
body { margin: 0; isolation: isolate; }
body::before {
  content: "";
  position: fixed;
  inset: 0 0 -640px;
  z-index: -1;
  pointer-events: none;
  background: var(--paper-surface) var(--paper);
  background-size: 640px 640px;
  transform: translate3d(0, var(--paper-offset, 0px), 0);
}
.gallery { min-height: 100svh; }
.row { display: contents; }
.scene {
  --photo-height: min(calc(var(--gallery-height) * .52), 460px);
  --position: .08;
  --width-limit: 100%;
  height: 0;
}
.enhanced .scene { height: calc(var(--gallery-height) * 1.4); }
.enhanced .gallery:has(.scene) { padding-bottom: var(--gallery-height); overflow-anchor: none; }
.frame {
  container-type: size;
  position: fixed;
  top: 76px;
  left: max(112px, calc((100% - 1060px) / 2));
  right: max(112px, calc((100% - 1060px) / 2));
  height: calc(var(--gallery-height) - 124px);
  margin: 0;
  display: flex;
  align-items: center;
  visibility: hidden;
  pointer-events: none;
}
.composition {
  --height-limit: max(1px, calc(100cqh - var(--caption-space, 140px)));
  --width: min(var(--width-limit), var(--source-width), calc(var(--photo-height) * var(--ratio)), 640px);
  width: var(--width);
  flex-shrink: 0;
  margin: 0;
  margin-left: calc((100% - var(--width)) * var(--position));
}
:root:not(.enhanced) .gallery:not(:has(.scene:target)) .scene-1 .frame,
:root:not(.enhanced) .scene:target .frame,
.enhanced .scene.is-active .frame { visibility: visible; }
.photo {
  display: block;
  width: 100%;
  color: inherit;
  cursor: zoom-in;
  pointer-events: none;
}
.photo-area {
  --image-width: min(100%, var(--source-width), calc(min(var(--photo-height), var(--height-limit)) * var(--ratio)));
  position: relative;
  width: var(--image-width);
  margin-left: calc((100% - var(--image-width)) * var(--position));
}
.photo picture { display: block; pointer-events: auto; }
.photo img { display: block; width: 100%; height: auto; aspect-ratio: var(--ratio); }
.caption {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  margin-top: 24px;
  font-size: clamp(15px, 1.2vw, 18px);
  line-height: 1.65;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}
.photo-number { padding-top: 6px; color: var(--muted); font: 10px/1.5 monospace; letter-spacing: .08em; }
.translation { display: grid; }
.translation > span { grid-area: 1 / 1; visibility: hidden; }
:root:lang(hy) .translation > [lang="hy"],
:root:lang(en) .translation > [lang="en"] { visibility: inherit; }
.story { pointer-events: auto; }
.enhanced .photo picture { clip-path: inset(var(--photo-top, 0%) 0 var(--photo-bottom, 0%) 0); }
.enhanced .frame { overflow: clip; overflow-clip-margin: 8px; }
.scene-text .frame { justify-content: center; }
.ending { margin: 0; max-width: 100%; text-align: center; font-size: clamp(28px, 4vw, 48px); line-height: 1.4; }
.enhanced .caption > *, .enhanced .ending .story > span {
  transform: translateY(var(--text-offset, 0px));
}
.row .scene:last-child { --position: .92; }
.row-opening .scene:first-child { --position: .18; --photo-height: min(calc(var(--gallery-height) * .56), 520px); }
.row-opening .scene:last-child { --position: 1; --photo-height: min(calc(var(--gallery-height) * .42), 360px); }
.row-pair .scene:last-child { --position: .64; --photo-height: min(calc(var(--gallery-height) * .54), 500px); }
.row-single .scene:last-child { --position: .8; --photo-height: min(calc(var(--gallery-height) * .48), 440px); }
.row-offset .scene:first-child { --position: .14; --photo-height: min(calc(var(--gallery-height) * .4), 340px); }
.row-offset .scene:last-child { --position: .88; --photo-height: min(calc(var(--gallery-height) * .56), 520px); }
.row-closing .scene:first-child { --position: 0; --photo-height: min(calc(var(--gallery-height) * .48), 420px); }
.row-closing .scene:last-child { --position: .5; --photo-height: min(calc(var(--gallery-height) * .4), 340px); }
.sequence {
  position: fixed;
  z-index: 2;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  max-height: 70svh;
  overflow: auto;
  scrollbar-width: thin;
}
.sequence a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  width: 58px;
  min-height: 44px;
  padding: 0 24px 0 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 11px/1 monospace;
  letter-spacing: .08em;
  cursor: pointer;
}
.sequence a::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 50%;
  width: 18px;
  height: 1px;
  background: currentColor;
  transform: scaleX(.278);
  transform-origin: right;
  transition: transform 240ms ease;
}
.sequence a:focus-visible, .sequence a:hover, .sequence a[aria-current] { color: var(--accent); }
.sequence a[aria-current]::after { transform: scaleX(1); }
.sequence a:focus-visible { outline-offset: -3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 6px; }
.empty {
  margin: 0;
  padding: 40svh 24px 0;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  font-style: italic;
}
body:has(.viewer[open]) { overflow: hidden; }
.viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 18px 28px;
  padding-top: max(18px, env(safe-area-inset-top));
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  border: 0;
  background: var(--paper-surface) var(--paper);
  background-size: 640px 640px;
  color: inherit;
}
.viewer[open] { display: grid; grid-template-rows: 48px minmax(0, 1fr) auto 56px; gap: 16px; }
.viewer::backdrop { background: var(--paper); }
.viewer-top, .viewer-bottom { display: flex; align-items: center; }
.viewer-top { justify-content: space-between; }
.viewer-bottom { justify-content: center; gap: 28px; }
.viewer button {
  width: 44px;
  height: 44px;
  padding: 10px;
  border: 0;
  border-radius: 50%;
  color: inherit;
  cursor: pointer;
  transition: background 180ms ease;
}
.viewer button { background: transparent; }
.viewer button:hover { background: var(--hover); }
.viewer button:disabled { visibility: hidden; }
.viewer svg { display: block; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.3; }
.viewer-stage { min-height: 0; position: relative; touch-action: pan-y pinch-zoom; }
.viewer-stage picture, .viewer-stage img { display: block; width: 100%; height: 100%; }
.viewer-stage img { object-fit: contain; }
.viewer-story { margin: 0 auto; max-width: 52ch; text-align: center; font-size: 15px; line-height: 1.5; }
.counter { min-width: 64px; text-align: center; font: 12px/1.5 system-ui, sans-serif; color: var(--muted); letter-spacing: .08em; }
.image-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font: 14px/1.5 system-ui, sans-serif;
  pointer-events: auto;
}
.image-error p { margin: 0 0 8px; }
.retry, .viewer .retry {
  width: auto;
  min-width: 44px;
  height: auto;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--muted);
  border-radius: 0;
  color: inherit;
  background: var(--paper);
  font: inherit;
  cursor: pointer;
}
.retry:hover { background: var(--hover); }
.retry[aria-disabled="true"] { opacity: .6; cursor: wait; }
.failed picture { visibility: hidden; pointer-events: none; }
.scroll-cue {
  position: fixed;
  left: 24px;
  right: 24px;
  bottom: 18px;
  margin: 0;
  text-align: center;
  color: var(--muted);
  font: 12px/1.5 system-ui, sans-serif;
  pointer-events: none;
}
[hidden] { display: none !important; }


.language-switch {
  position: fixed;
  z-index: 2;
  right: max(20px, env(safe-area-inset-right));
  top: max(16px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  background: transparent;
  font: 12px/1 system-ui, sans-serif;
}
.language-switch[hidden], .sequence[hidden] { display: none; }
.language-switch button {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.language-switch button[aria-pressed="true"] { color: var(--ink); text-decoration: underline; text-underline-offset: 5px; }
.language-switch span { color: var(--muted); }
.viewer .language-switch { position: static; }

@media (max-width: 600px) {
  .frame { top: 76px; left: 24px; right: 24px; height: calc(var(--gallery-height) - 154px - env(safe-area-inset-bottom)); }
  .row .scene:first-child, .row .scene:last-child { --photo-height: calc(var(--gallery-height) * .44); --width-limit: 88%; }
  .row-opening .scene:first-child { --position: .5; --width-limit: 90%; }
  .row-opening .scene:last-child { --width-limit: 68%; }
  .row-single .scene:last-child { --width-limit: 82%; }
  .row-offset .scene:first-child { --width-limit: 65%; }
  .row-closing .scene:first-child { --width-limit: 82%; }
  .row-closing .scene:last-child { --width-limit: 66%; }
  .caption { font-size: 15px; gap: 8px; margin-top: 20px; }
  .language-switch { right: 14px; top: max(12px, env(safe-area-inset-top)); }
  .viewer { padding-inline: 14px; }
  .viewer[open] { gap: 12px; }
}

@media (max-width: 600px), (max-height: 500px) {
  .scroll-cue { bottom: calc(64px + env(safe-area-inset-bottom)); }
  .sequence {
    inset: auto 0 0;
    transform: none;
    display: flex;
    max-height: none;
    padding: 6px 16px calc(6px + env(safe-area-inset-bottom));
    background: var(--paper-surface) var(--paper);
    background-size: 640px 640px;
    border-top: 1px solid color-mix(in srgb, var(--muted) 22%, transparent);
  }
  .sequence { overscroll-behavior: contain; }
  .sequence a { flex: 1 0 44px; min-width: 44px; width: auto; padding: 0; }
  .sequence a::after { top: auto; bottom: 3px; left: calc(50% - 9px); right: auto; transform-origin: center; }
}

@media (max-width: 600px) and (max-height: 600px) {
  :root:not(.enhanced) .composition { width: 100%; margin-left: 0; }
}

@media (max-width: 600px) {
  .compact-gallery .composition { width: 100%; margin-left: 0; }
}

@media (min-width: 900px) {
  .composition {
    --caption-space: 0px;
    --photo-width: min(var(--source-width), calc(min(var(--photo-height), var(--height-limit)) * var(--ratio)), 640px);
    --text-width: clamp(210px, 20vw, 280px);
    --gap: clamp(28px, 4vw, 64px);
    --width: min(100%, calc(var(--photo-width) + var(--text-width) + var(--gap)));
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--text-width);
    gap: var(--gap);
    align-items: end;
  }
  .caption { margin: 0; }
  .photo-area { width: 100%; margin-left: 0; }
}

@media (min-width: 601px) and (max-height: 500px) {
  :root:not(.enhanced) .frame { top: 64px; left: 40px; right: 40px; height: calc(var(--gallery-height) - 148px - env(safe-area-inset-bottom)); }
  :root:not(.enhanced) .composition {
    --caption-space: 0px;
    --landscape-width: min(var(--source-width), calc(min(calc(var(--gallery-height) * .48), var(--height-limit)) * var(--ratio)));
    --width: min(100%, calc(var(--landscape-width) + 284px));
    display: grid;
    grid-template-columns: minmax(0, var(--landscape-width)) minmax(180px, 260px);
    gap: 24px;
    align-items: end;
  }
  :root:not(.enhanced) .caption { margin: 0; font-size: 15px; }
  :root:not(.enhanced) .photo-area { width: 100%; margin-left: 0; }
}

@media (min-width: 601px) {
  .short-gallery .frame { top: 64px; left: 40px; right: 40px; height: calc(var(--gallery-height) - 148px - env(safe-area-inset-bottom)); }
  .short-gallery .composition {
    --caption-space: 0px;
    --landscape-width: min(var(--source-width), calc(min(calc(var(--gallery-height) * .48), var(--height-limit)) * var(--ratio)));
    --width: min(100%, calc(var(--landscape-width) + 284px));
    display: grid;
    grid-template-columns: minmax(0, var(--landscape-width)) minmax(180px, 260px);
    gap: 24px;
    align-items: end;
  }
  .short-gallery .caption { margin: 0; font-size: 15px; }
  .short-gallery .photo-area { width: 100%; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  :root { background-position: 0 0 !important; }
  .scroll-cue { display: none; }
  .enhanced .photo picture { clip-path: none; }
  .enhanced .caption > *, .enhanced .ending .story > span { transform: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.scene-1 { --ratio: 0.75000000; --source-width: 960px; }
.scene-2 { --ratio: 0.75000000; --source-width: 960px; }
.scene-3 { --ratio: 0.75000000; --source-width: 960px; }
.scene-4 { --ratio: 0.76875000; --source-width: 984px; }
.scene-5 { --ratio: 0.75000000; --source-width: 960px; }
.scene-6 { --ratio: 0.75000000; --source-width: 960px; }
.scene-7 { --ratio: 0.75000000; --source-width: 960px; }
.scene-8 { --ratio: 0.75000000; --source-width: 960px; }
.scene-9 { --ratio: 0.75000000; --source-width: 960px; }
