/* Word Viewer — pages on the app canvas. The pages stay white paper in dark mode (like Word and Google Docs). */

.wv-doc { zoom: var(--wv-zoom, 1); padding: 24px 12px 56px; min-width: min-content; }
.wv-doc .docx-wrapper, .wv-sheet { background: transparent; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 0; }
.wv-doc .docx-wrapper > section.wv-page, .wv-page {
  background: #fff; color: #111; color-scheme: light; flex: none;
  box-shadow: 0 1px 2px rgb(16 24 40 / .10), 0 8px 28px rgb(16 24 40 / .10);
  margin: 0 auto 24px; border-radius: 2px;
}
html[data-theme="dark"] .wv-page { box-shadow: 0 1px 2px rgb(0 0 0 / .5), 0 10px 30px rgb(0 0 0 / .45); }
.wv-doc section.docx { overflow: hidden; }
.wv-doc img { max-width: 100%; }
.wv-doc a { color: #1155cc; }

/* Flowing documents (RTF, ODT, older .doc text): one long sheet that fits the screen. */
.wv-flow {
  width: min(816px, 100%); min-height: 60vh; box-sizing: border-box;
  padding: clamp(24px, 6vw, 72px) clamp(20px, 7vw, 90px);
  font-family: Carlito, Calibri, Arimo, Arial, sans-serif; font-size: 11pt; line-height: 1.45;
}
.wv-flow p { margin: 0 0 .55em; }
.wv-flow h1, .wv-flow h2, .wv-flow h3, .wv-flow h4 { font-family: inherit; color: #1f3864; margin: 1em 0 .4em; line-height: 1.25; }
.wv-plain p { white-space: pre-wrap; }
.wv-plain .wv-blank { margin: 0; }
.wv-odt-table { border-collapse: collapse; margin: .6em 0; }
.wv-odt-table td { border: 1px solid #c8c8c8; padding: 4px 8px; vertical-align: top; }
.wv-notice { max-width: 816px; margin: 0 auto 16px; }

/* Reading view: one continuous white sheet whose text wraps to the screen (headers/footers hidden). */
.wv-doc.wv-reflow { min-width: 0; }
.wv-reflow .docx-wrapper { display: block; background: #fff; color-scheme: light; max-width: 46rem; margin: 0 auto; border-radius: 4px; box-shadow: 0 1px 2px rgb(16 24 40 / .10), 0 8px 28px rgb(16 24 40 / .10); }
.wv-reflow .docx-wrapper > section.wv-page {
  width: auto !important; min-height: 0 !important; padding: 18px clamp(16px, 4vw, 40px) !important;
  margin: 0 !important; box-shadow: none !important; border-radius: 0; overflow: visible;
}
.wv-reflow .docx-wrapper > section.wv-page + section.wv-page { border-top: 1px dashed #e2e8f0; }
.wv-reflow section.wv-page > header, .wv-reflow section.wv-page > footer { display: none; }
.wv-reflow section.wv-page > article { columns: auto !important; column-count: auto !important; }
.wv-reflow table { display: block; max-width: 100%; overflow-x: auto; }
.wv-reflow img, .wv-reflow svg { max-width: 100% !important; height: auto !important; }
.wv-reflow p { overflow-wrap: anywhere; }
.wv-reflow [class$="-tab-stop"] { word-spacing: 1.5em !important; }  /* tabs are drawn with huge word-spacing */
@media (max-width: 640px) { .wv-reflow .docx-wrapper { border-radius: 0; } .wv-doc.wv-reflow { padding: 0 0 32px; } }

/* Comments: a small icon you can tap (the popover is docx-preview's). */
.wv-doc .docx-comment-ref {
  display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin: 0 2px;
  vertical-align: middle; border-radius: 6px; cursor: pointer; color: #b45309; background: #fef3c7;
  font-size: 0; line-height: 0;
}
.wv-doc .docx-comment-ref .icon { width: 14px; height: 14px; }
.wv-doc .docx-comment-ref:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.wv-doc .docx-comment-ref.is-open + .docx-comment-popover { display: block; }
.wv-doc .docx-comment-popover {
  font: 13px/1.45 var(--font-sans); color: #1f2937; background: #fffbeb; border: 1px solid #fcd34d;
  border-radius: 8px; padding: 8px 10px; box-shadow: 0 8px 24px rgb(16 24 40 / .15); max-width: 280px; white-space: normal;
}
.wv-doc .docx-comment-author { font-weight: 600; }
.wv-doc .docx-comment-date { font-size: 11px; color: #6b7280; margin-bottom: 4px; }
.wv-hide-comments .docx-comment-ref, .wv-hide-comments .docx-comment-popover { display: none !important; }

/* Tracked changes: shown by default; "final" hides deletions and shows insertions as normal text. */
.wv-doc ins { color: #15803d; text-decoration: underline; text-decoration-color: #22c55e; background: none; }
.wv-doc del { color: #b91c1c; }
.wv-final del { display: none; }
.wv-final ins { color: inherit; text-decoration: none; }

/* Find + read aloud */
.wv-hit { background: #fde68a; color: inherit; border-radius: 2px; padding: 0; }
.wv-hit.is-current { background: #fb923c; box-shadow: 0 0 0 2px #ea580c; }
.wv-reading { background: color-mix(in srgb, var(--app-accent, #4f46e5) 14%, transparent); border-radius: 3px; }

/* Side panel: headings and comments */
.wv-outline, .wv-comment-list { list-style: none; margin: 0; padding: 0; }
.wv-outline-item, .wv-comment-item {
  display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--text); font: inherit;
  font-size: .9rem; line-height: 1.35; padding: .5rem .6rem .5rem calc(.6rem + var(--lvl, 0) * .9rem);
  border-radius: var(--radius-sm); cursor: pointer; min-height: 40px;
}
.wv-outline-item:focus-visible, .wv-comment-item:focus-visible { outline: 2px solid var(--focus); }
@media (hover: hover) { .wv-outline-item:hover, .wv-comment-item:hover { background: var(--app-accent-softer, var(--surface-2)); } }
.wv-outline li:has(> [style*="--lvl: 0"]) .wv-outline-item, .wv-outline-item[style*="--lvl:0"] { font-weight: 600; }
.wv-comment-item { display: grid; gap: .15rem; padding-left: .6rem; }
.wv-comment-item strong { font-weight: 600; font-size: .85rem; }
.wv-comment-item span { color: var(--text-soft); font-size: .85rem; }
.wv-side-title { font-size: .8rem; font-weight: 600; color: var(--text-soft); text-transform: none; margin: 1rem .6rem .3rem; }
.wv-side-empty { color: var(--text-soft); font-size: .88rem; line-height: 1.5; padding: .4rem .6rem; margin: 0; }

/* Document details dialog */
.wv-details { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0; font-size: .95rem; }
.wv-details dt { color: var(--text-soft); }
.wv-details dd { margin: 0; overflow-wrap: anywhere; }

/* Read-aloud bar */
.wv-reader {
  position: absolute; left: 50%; bottom: calc(var(--app-status-h, 28px) + 12px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem .45rem .9rem; z-index: 6;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow-lg);
  font-size: .9rem; white-space: nowrap;
}
.wv-reader .icon { color: var(--app-accent); }

@media (max-width: 640px) {
  .wv-doc { padding: 12px 8px 40px; }
  .wv-doc .docx-wrapper > section.wv-page, .wv-page { margin-bottom: 12px; }
}

@media print {
  @page { margin: 0; }
  .wv-doc { zoom: 1 !important; padding: 0 !important; }
  .wv-page { box-shadow: none !important; margin: 0 !important; border-radius: 0 !important; break-after: page; }
  .wv-page:last-child { break-after: auto; }
  .wv-notice, .wv-reader, .docx-comment-ref, .docx-comment-popover, .wv-hit { all: unset; }
  .wv-notice, .wv-reader, .docx-comment-ref, .docx-comment-popover { display: none !important; }
}
