/* Portfolio viewer: one spread at a time, as large as the screen allows. */

.viewer-body {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  background: var(--surface);
  overflow: hidden;
  font-family: var(--sans);
  font-size: var(--step--1);
}

/* ---- bar ---- */
.vbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.5rem;
  padding: 0.7rem var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  z-index: var(--z-sticky);
}
.vbar-name { font-family: var(--serif); font-size: var(--step-0); text-decoration: none; white-space: nowrap; }
.vbar-name .back { font-family: var(--sans); color: var(--muted); margin-right: 0.25rem; }
.vbar-name:hover .back { color: var(--accent); }
.vbar-title { text-align: center; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vbar-title b { font-weight: 500; color: var(--ink); }
.vbar-tools { display: flex; align-items: center; gap: 0.25rem; }
.counter { font-variant-numeric: tabular-nums; margin-right: 1.25rem; color: var(--muted); white-space: nowrap; }
.tool.lang { font-weight: 500; letter-spacing: 0.04em; }
.tool span.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.tool {
  appearance: none;
  background: none;
  border: 0;
  color: var(--ink);
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s var(--ease-out), color 0.2s var(--ease-out);
}
.tool svg { width: 1.1rem; height: 1.1rem; flex: none; }
.tool:hover { background: var(--surface); }
.tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* ---- stage ---- */
.stage {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  padding: clamp(0.75rem, 2vw, 1.5rem) clamp(2.5rem, 6vw, 5rem);
}
.spread {
  position: relative;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: zoom-in;
}
.spread img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 1px 2px oklch(0 0 0 / 0.08), 0 8px 24px oklch(0 0 0 / 0.08);
  background: var(--bg);
  user-select: none;
  -webkit-user-drag: none;
}

/* zoomed: the spread becomes a scrollable canvas */
.stage.zoomed .spread { overflow: auto; cursor: grab; align-items: flex-start; justify-content: flex-start; display: block; scrollbar-width: thin; touch-action: pan-x pan-y; }
.stage.zoomed .spread.dragging { cursor: grabbing; }
.stage.zoomed .spread img { max-width: none; max-height: none; width: var(--zoom-width, 240%); box-shadow: none; }
.stage.zoomed .edge { opacity: 0; pointer-events: none; }

.edge {
  position: absolute;
  top: 0; bottom: 0;
  width: clamp(2.5rem, 6vw, 5rem);
  display: grid;
  place-items: center;
  appearance: none;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.2s var(--ease-out);
  z-index: 1;
}
.edge:hover, .edge:focus-visible { opacity: 1; }
.edge:focus-visible { outline: none; }
.edge:focus-visible svg { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 50%; }
.edge:disabled { opacity: 0.12; cursor: default; }
.edge svg { width: 2rem; height: 2rem; }
.edge-prev { left: 0; }
.edge-next { right: 0; }

/* ---- filmstrip ---- */
.filmstrip[hidden] { display: none; }
.filmstrip {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding: 0.75rem var(--gutter);
  background: var(--bg);
  border-top: 1px solid var(--line);
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}
.filmstrip button {
  appearance: none;
  flex: none;
  border: 2px solid transparent;
  padding: 0;
  background: none;
  cursor: pointer;
  scroll-snap-align: center;
  border-radius: 3px;
  transition: border-color 0.2s var(--ease-out);
}
.filmstrip button img { height: 4.5rem; width: auto; display: block; border: 1px solid var(--line); background: var(--bg); aspect-ratio: 1200 / 849; }
.filmstrip button img.portrait { aspect-ratio: 600 / 849; }
.filmstrip button:hover { border-color: var(--line); }
.filmstrip button[aria-current="true"] { border-color: var(--accent); }

.hint {
  margin: 0;
  padding: 0.5rem var(--gutter) max(0.6rem, env(safe-area-inset-bottom));
  color: var(--muted);
  text-align: center;
  transition: opacity 0.6s var(--ease-out);
}
.hint.faded { opacity: 0; }

.outro {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.5rem 1.75rem;
  padding: 0.85rem var(--gutter);
  background: var(--bg);
  border-top: 1px solid var(--line);
  font-family: var(--serif);
  font-size: var(--step-0);
}
.outro[hidden] { display: none; }
.outro span { color: var(--muted); }
.outro a { text-decoration-color: var(--line); }
.outro a:hover { text-decoration-color: currentColor; }

/* ---- fullscreen: hide chrome ---- */
.viewer-body.is-fullscreen .vbar { display: none; }
.viewer-body.is-fullscreen .hint { display: none; }
.viewer-body.is-fullscreen { grid-template-rows: 1fr auto auto; }

/* ---- responsive ---- */
@media (max-width: 720px) {
  .vbar { grid-template-columns: 1fr auto; grid-template-areas: "name tools" "title title"; gap: 0.35rem 0.5rem; padding: 0.6rem 1rem; }
  .vbar-name { grid-area: name; }
  .vbar-tools { grid-area: tools; }
  .vbar-title { grid-area: title; text-align: left; }
  .tool span:not(.sr) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .tool { padding: 0.6rem 0.45rem; }
  .tool svg { width: 1.25rem; height: 1.25rem; }
  .vbar-tools { gap: 0; }
  .counter { margin-right: 0.35rem; }
  .stage { padding: 0.5rem 0.75rem; }
  .edge { width: 2.25rem; opacity: 0.6; }
  .edge svg { width: 1.5rem; height: 1.5rem; }
  .hint { display: none; }
  .filmstrip button img { height: 3.25rem; }
}

