/* In-app document viewer — keeps fullscreen/homescreen users on-site */

body.hq-doc-overlay-open {
  overflow: hidden;
  touch-action: none;
}

.hq-doc-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--hq-z-modal, 10002);
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.hq-doc-overlay[hidden] {
  display: none !important;
}

.hq-doc-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: var(--hq-overlay-heavy, rgba(0, 0, 0, 0.7));
}

.hq-doc-overlay__panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: min(960px, 100%);
  height: 100dvh;
  max-height: 100dvh;
  background: var(--hq-white, #fff);
  color: var(--hq-text-default, #1a1a1a);
  box-shadow: var(--hq-shadow-xl, 0 12px 40px rgba(0, 0, 0, 0.25));
}

.hq-doc-overlay__header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  min-height: 3.25rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--hq-brown-deep, #4f3e2c);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.hq-doc-overlay__close {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  margin: 0;
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

.hq-doc-overlay__close:hover,
.hq-doc-overlay__close:focus {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.hq-doc-overlay__close-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.hq-doc-overlay__title {
  flex: 1 1 auto;
  margin: 0;
  min-width: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
}

.hq-doc-overlay__download {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 4px;
  background: var(--hq-orange, #ff9500);
  color: #fff !important;
  text-decoration: none !important;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.hq-doc-overlay__download i {
  font-weight: 400;
  font-size: 1em;
  line-height: 1;
}

.hq-doc-overlay__download:hover,
.hq-doc-overlay__download:focus {
  filter: brightness(1.05);
  color: #fff !important;
}

.hq-doc-overlay__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
  padding: 0.55rem 0.85rem;
  background: #ece7e1;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.hq-doc-overlay__toolbar[hidden] {
  display: none !important;
}

.hq-doc-overlay__nav {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.45rem 0.7rem;
  border: 1px solid rgba(79, 62, 44, 0.25);
  border-radius: 4px;
  background: #fff;
  color: var(--hq-brown-deep, #4f3e2c);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.hq-doc-overlay__nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.hq-doc-overlay__page {
  flex: 1 1 auto;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--hq-brown-deep, #4f3e2c);
}

.hq-doc-overlay__body {
  position: relative;
  z-index: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #f3f1ee;
}

.hq-doc-overlay__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  padding: 12px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* PDF pages: no vertical/horizontal scrolling — only side-swipe page turns. */
.hq-doc-overlay__scroll--pdf {
  overflow: hidden;
  touch-action: none;
  align-items: center;
  overscroll-behavior: none;
}

.hq-doc-overlay__canvas {
  display: block;
  max-width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.hq-doc-overlay__frame {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}

.hq-doc-overlay__image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}

.hq-doc-overlay__hint {
  flex-shrink: 0;
  margin: 0;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  color: rgba(0, 0, 0, 0.65);
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.hq-doc-overlay__fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 1.25rem 1.25rem 0.5rem;
  text-align: center;
}

.hq-doc-overlay__fallback p {
  margin: 0;
  max-width: 22rem;
  line-height: 1.45;
}

@media (max-width: 767px) {
  .hq-doc-overlay__panel {
    width: 100%;
  }

  .hq-doc-overlay__title {
    font-size: 0.9rem;
  }

  .hq-doc-overlay__header {
    padding: max(0.65rem, env(safe-area-inset-top)) 0.75rem 0.65rem;
  }

  .hq-doc-overlay__close-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .hq-doc-overlay__nav span {
    display: none;
  }

  .hq-doc-overlay__toolbar {
    padding-bottom: max(0.55rem, env(safe-area-inset-bottom, 0px));
  }
}

@media (min-width: 768px) {
  .hq-doc-overlay__panel {
    width: min(960px, calc(100vw - 48px));
    height: min(900px, calc(100dvh - 48px));
    max-height: calc(100dvh - 48px);
    margin: auto 0;
    border-radius: 6px;
    overflow: hidden;
  }
}
