/* The original handwriting remains the centre of the reading experience. */
.guestbook-reader {
  --reader-paper: #f6f1e5;
  --reader-ink: #2a2118;
  --reader-muted: #6b5f50;
  --reader-line: rgba(107, 95, 80, .25);
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: var(--reader-paper);
  color: var(--reader-ink);
  color-scheme: light;
  font-family: var(--font-sans, 'Outfit', sans-serif);
  line-height: 1.5;
  overscroll-behavior: contain;
}

.guestbook-reader[open] { display: flex; flex-direction: column; }
.guestbook-reader::backdrop { background: rgba(42, 33, 24, .65); }
.guestbook-reader *, .guestbook-reader *::before, .guestbook-reader *::after { box-sizing: border-box; }
.guestbook-reader [hidden] { display: none !important; }

.guestbook-reader__header,
.guestbook-reader__footer {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-inline: max(28px, env(safe-area-inset-left)) max(28px, env(safe-area-inset-right));
}

.guestbook-reader__header {
  min-height: 82px;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: 12px;
  border-bottom: 1px solid var(--reader-line);
}

.guestbook-reader__header h2 {
  margin: 0;
  color: inherit;
  font-family: var(--font-serif, 'Cormorant Garamond', Georgia, serif);
  font-size: clamp(24px, 2.8vw, 36px);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -.025em;
  text-wrap: balance;
}

.guestbook-reader__button {
  display: inline-flex;
  min-height: 44px;
  min-width: 44px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--reader-ink);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  letter-spacing: .02em;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}

.guestbook-reader__button:disabled { color: var(--reader-muted); opacity: .42; cursor: default; }
.guestbook-reader__button:focus-visible,
.guestbook-reader summary:focus-visible,
.guestbook-reader__viewport:focus-visible,
.guestbook-reader__text:focus-visible {
  outline: 2px solid var(--reader-ink);
  outline-offset: -3px;
}
.guestbook-reader:focus-visible { outline: 2px solid var(--reader-line); outline-offset: -2px; }
.guestbook-reader__cross { position: relative; width: 16px; height: 16px; }
.guestbook-reader__cross::before, .guestbook-reader__cross::after {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  width: 1px;
  height: 16px;
  background: currentColor;
  transform: rotate(45deg);
}
.guestbook-reader__cross::after { transform: rotate(-45deg); }

.guestbook-reader__body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.guestbook-reader__viewport {
  --guestbook-scan-width: 1400px;
  position: relative;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #a89a84 #e9e1d2;
  scrollbar-width: thin;
  background: #e9e1d2;
  touch-action: auto;
  -webkit-overflow-scrolling: touch;
}
.guestbook-reader__canvas {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 22px;
}
.guestbook-reader__image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  visibility: hidden;
  box-shadow: 0 3px 16px rgba(42, 33, 24, .12);
}
.guestbook-reader.is-loaded .guestbook-reader__image { visibility: visible; }
.guestbook-reader.is-zoomed .guestbook-reader__canvas {
  width: max(100%, calc(var(--guestbook-scan-width) + 44px));
  height: auto;
  min-height: 100%;
}
.guestbook-reader.is-zoomed .guestbook-reader__image {
  width: var(--guestbook-scan-width);
  height: auto;
  max-width: none;
  max-height: none;
}
.guestbook-reader__feedback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 32px;
  pointer-events: none;
}
.guestbook-reader__status {
  max-width: 38ch;
  margin: 0;
  color: var(--reader-muted);
  font-size: 14px;
  text-align: center;
}
.guestbook-reader__retry { border-color: var(--reader-line); pointer-events: auto; }
.guestbook-reader.is-loaded .guestbook-reader__feedback { display: none; }

.guestbook-reader__transcription {
  flex: 0 0 auto;
  min-width: 0;
  border-top: 1px solid var(--reader-line);
  background: var(--reader-paper);
}
.guestbook-reader__transcription summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 20px;
  color: var(--reader-ink);
  font-size: 13px;
  cursor: pointer;
  list-style: none;
  touch-action: manipulation;
}
.guestbook-reader__transcription summary::-webkit-details-marker { display: none; }
.guestbook-reader__disclosure {
  display: block;
  width: 7px;
  height: 7px;
  margin-top: -4px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg);
}
.guestbook-reader__transcription[open] .guestbook-reader__disclosure { margin-top: 3px; transform: rotate(225deg); }
.guestbook-reader__text {
  max-height: 32dvh;
  overflow: auto;
  padding: 0 max(28px, calc((100% - 68ch) / 2)) 24px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.guestbook-reader__page-title {
  margin: 0 0 10px;
  font-family: var(--font-serif, 'Cormorant Garamond', Georgia, serif);
  font-size: 25px;
  font-weight: 500;
  line-height: 1.25;
}
.guestbook-reader__transcript {
  max-width: 68ch;
  margin: 0;
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.guestbook-reader__footer {
  min-height: 76px;
  padding-top: 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--reader-line);
}
.guestbook-reader__navigation { display: flex; align-items: center; gap: 22px; min-width: 0; }
.guestbook-reader__counter { margin: 0; color: var(--reader-muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.guestbook-reader__arrow {
  position: relative;
  display: block;
  width: 21px;
  height: 1px;
  background: currentColor;
}
.guestbook-reader__arrow::after {
  content: '';
  position: absolute;
  top: -3px;
  right: 0;
  width: 7px;
  height: 7px;
  border-top: 1px solid currentColor;
  border-right: 1px solid currentColor;
  transform: rotate(45deg);
}
.guestbook-reader__arrow--previous { transform: rotate(180deg); }
.guestbook-reader__zoom { border-color: var(--reader-line); min-width: 116px; }
.guestbook-reader__sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

@media (hover: hover) {
  .guestbook-reader__button:hover:not(:disabled) { background: rgba(201, 154, 75, .12); }
  .guestbook-reader__transcription summary:hover { background: rgba(201, 154, 75, .08); }
}

@media (max-width: 600px) {
  .guestbook-reader__header, .guestbook-reader__footer {
    gap: 8px;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .guestbook-reader__header { min-height: 72px; padding-top: max(10px, env(safe-area-inset-top)); padding-bottom: 10px; }
  .guestbook-reader__header h2 { max-width: 14ch; font-size: 25px; }
  .guestbook-reader__close { padding-inline: 10px; gap: 9px; }
  .guestbook-reader__canvas { padding: 12px 8px; }
  .guestbook-reader.is-zoomed .guestbook-reader__canvas { width: max(100%, calc(var(--guestbook-scan-width) + 16px)); }
  .guestbook-reader__footer { min-height: 70px; }
  .guestbook-reader__navigation { gap: 7px; }
  .guestbook-reader__direction { display: none; }
  .guestbook-reader__previous, .guestbook-reader__next { padding-inline: 10px; }
  .guestbook-reader__zoom { min-width: 109px; padding-inline: 10px; }
  .guestbook-reader__text { max-height: 35dvh; padding: 0 22px 22px; }
  .guestbook-reader__transcript { font-size: 14px; line-height: 1.7; }
}

@media (max-height: 480px) and (orientation: landscape) {
  .guestbook-reader__header { min-height: 56px; padding-block: 6px; }
  .guestbook-reader__header h2 { font-size: 24px; }
  .guestbook-reader__footer { min-height: 56px; padding-block: 6px; }
  .guestbook-reader__canvas { padding-block: 10px; }
  .guestbook-reader__transcription summary { min-height: 44px; }
}
