/* ============================================================
   Sharing / publish-to-web
   Scoped to .share-overlay / .share-modal and .public-view (pv- = public view).
   Reuses css/style.css custom properties (light + dark) with fallbacks.
   ============================================================ */

/* ------------------------------ share modal ------------------------------ */
.share-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(15, 15, 15, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 20px 20px;
}
.share-modal {
  width: 460px;
  max-width: 100%;
  background: var(--bg-modal, #fff);
  color: var(--text, #37352f);
  border-radius: 10px;
  box-shadow: var(--shadow-popover, rgba(15, 15, 15, 0.2) 0 9px 24px);
  overflow: hidden;
  animation: share-in 0.12s ease;
}
@keyframes share-in { from { opacity: 0; transform: translateY(-6px); } }

.share-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px 12px 18px;
  border-bottom: 1px solid var(--border, #e9e9e7);
}
.share-title {
  font-size: 15px;
  font-weight: 600;
  min-width: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.share-page { color: var(--text-light, #787774); font-weight: 500; }
.share-x {
  width: 26px; height: 26px;
  border-radius: 5px;
  font-size: 13px;
  color: var(--text-light, #787774);
  flex-shrink: 0;
}
.share-x:hover { background: var(--bg-hover, rgba(0, 0, 0, 0.045)); color: var(--text, #37352f); }

.share-toggle-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
}
.share-toggle-text { flex: 1; min-width: 0; }
.share-toggle-label { font-size: 14px; font-weight: 500; color: var(--text, #37352f); }
.share-toggle-sub { font-size: 12.5px; color: var(--text-faint, #9b9a97); margin-top: 2px; }

/* switch */
.share-switch {
  position: relative;
  flex: 0 0 auto;
  width: 40px; height: 22px;
  border-radius: 11px;
  background: var(--border-strong, #d3d3d1);
  transition: background 0.15s;
}
.share-switch.on { background: var(--accent, #5b5bd6); }
.share-switch.busy { opacity: 0.6; cursor: default; }
.share-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}
.share-switch.on .share-knob { transform: translateX(18px); }

.share-body { padding: 0 18px 18px; }
.share-note {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-light, #787774);
  margin-top: 12px;
}
.share-note b { color: var(--text, #37352f); font-weight: 600; }

.share-linkrow { display: flex; gap: 8px; align-items: center; }
.share-link {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font, sans-serif);
  color: var(--text, #37352f);
  background: var(--bg-hover, rgba(0, 0, 0, 0.045));
  border: 1px solid var(--border, #e9e9e7);
  border-radius: 6px;
  outline: none;
}
.share-link:focus { border-color: var(--accent, #5b5bd6); }

.share-btn {
  font-family: var(--font, sans-serif);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--accent, #5b5bd6);
  color: #fff;
  transition: background 0.12s;
}
.share-btn:hover { background: var(--accent-hover, #0077d4); }

.share-actions { margin-top: 10px; }
.share-open {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent, #5b5bd6);
  text-decoration: none;
}
.share-open:hover { text-decoration: underline; }

/* allow-duplicate toggle (inside public share body) */
.share-dup-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text, #37352f);
  cursor: pointer;
}
.share-dup-check {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  margin-top: 1px;
  accent-color: var(--accent, #5b5bd6);
  cursor: pointer;
}

/* ---- people with access ---- */
.share-people {
  padding: 4px 18px 18px;
  border-top: 1px solid var(--border, #e9e9e7);
}
.share-section-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-faint, #9b9a97);
  margin: 14px 0 10px;
}
.share-add-row { display: flex; gap: 8px; align-items: center; }
.share-email-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font, sans-serif);
  color: var(--text, #37352f);
  background: var(--bg-hover, rgba(0, 0, 0, 0.045));
  border: 1px solid var(--border, #e9e9e7);
  border-radius: 6px;
  outline: none;
}
.share-email-input:focus { border-color: var(--accent, #5b5bd6); }
.share-perm-select,
.share-person-perm,
.share-team-select,
.share-team-perm {
  flex: 0 0 auto;
  padding: 7px 8px;
  font-size: 12.5px;
  font-family: var(--font, sans-serif);
  color: var(--text, #37352f);
  background: var(--bg-modal, #fff);
  border: 1px solid var(--border, #e9e9e7);
  border-radius: 6px;
  outline: none;
  cursor: pointer;
}
.share-perm-select:focus,
.share-person-perm:focus,
.share-team-select:focus,
.share-team-perm:focus { border-color: var(--accent, #5b5bd6); }
.share-team-select { flex: 1 1 auto; min-width: 0; }

/* --- share with a team --- */
.share-teams {
  padding: 4px 18px 18px;
  border-top: 1px solid var(--border, #e9e9e7);
}
.share-team-list { margin-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.share-team-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 6px; border-radius: 8px;
}
.share-team-row:hover { background: var(--bg-hover); }
.share-team-name { font-size: 13.5px; font-weight: 500; color: var(--text); }
.share-team-meta { font-size: 12px; color: var(--text-faint); margin-left: auto; }
.share-team-x {
  border: 0; background: transparent; color: var(--text-faint);
  cursor: pointer; font-size: 13px; line-height: 1; padding: 4px 6px; border-radius: 6px;
}
.share-team-x:hover { background: var(--bg-hover); color: var(--danger); }

.share-people-list { margin-top: 10px; max-height: 220px; overflow-y: auto; }
.share-people-empty {
  font-size: 12.5px;
  color: var(--text-faint, #9b9a97);
  padding: 6px 0;
}
.share-person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}
.share-person + .share-person { border-top: 1px solid var(--border, #e9e9e7); }
.share-person-info { flex: 1; min-width: 0; }
.share-person-name {
  font-size: 13.5px;
  color: var(--text, #37352f);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.share-person-email {
  font-size: 12px;
  color: var(--text-faint, #9b9a97);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.share-person-x {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  border-radius: 5px;
  font-size: 12px;
  color: var(--text-light, #787774);
}
.share-person-x:hover { background: var(--bg-hover, rgba(0, 0, 0, 0.045)); color: var(--text, #37352f); }

/* ---- duplicate action on the public reader ---- */
.pv-actions { margin: 4px 0 20px; }
.pv-dup-btn {
  display: inline-block;
  font-family: var(--font, sans-serif);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 6px;
  background: var(--accent, #5b5bd6);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s;
}
.pv-dup-btn:hover { background: var(--accent-hover, #0077d4); }

/* ------------------------------ public view ------------------------------ */
.public-view {
  position: absolute;
  inset: 0;
  z-index: 300;
  overflow-y: auto;
  background: var(--bg, #fff);
  color: var(--text, #37352f);
  font-family: var(--font, sans-serif);
}
.pv-loading {
  padding: 30vh 0;
  text-align: center;
  color: var(--text-faint, #9b9a97);
  font-size: 14px;
}

/* private / not-found card */
.pv-card {
  max-width: 460px;
  margin: 18vh auto 0;
  padding: 0 24px;
  text-align: center;
}
.pv-card-icon { font-size: 46px; line-height: 1; }
.pv-card-title { font-size: 22px; font-weight: 700; margin: 16px 0 8px; letter-spacing: -0.3px; }
.pv-card-text { font-size: 14px; color: var(--text-light, #787774); line-height: 1.55; }

/* cover */
.pv-cover {
  width: 100%;
  height: 30vh;
  max-height: 260px;
  min-height: 140px;
}

/* page column */
.pv-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 48px 80px;
}
.public-view.has-cover .pv-page { padding-top: 0; }
.pv-icon {
  font-size: 66px;
  line-height: 1;
  margin: 24px 0 6px;
}
.pv-icon.overlaps { margin-top: -50px; position: relative; }
.pv-title {
  font-size: 40px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.5px;
  margin: 8px 0 18px;
  word-break: break-word;
}

/* footer */
.pv-footer {
  margin-top: 60px;
  padding-top: 20px;
  border-top: 1px solid var(--border, #e9e9e7);
  font-size: 12.5px;
  color: var(--text-faint, #9b9a97);
  text-align: center;
}
.pv-card .pv-footer { border: none; margin-top: 40px; }

/* ---- read-only block content (pv-) ---- */
.pv-content {
  font-size: 16px;
  line-height: 1.55;
  color: var(--text, #37352f);
}
.pv-blank {
  color: var(--text-faint, #9b9a97);
  font-size: 14px;
  font-style: italic;
  padding: 20px 0;
}
.pv-p { padding: 3px 0; word-break: break-word; }
.pv-h1 { font-size: 28px; font-weight: 700; line-height: 1.3; margin: 26px 0 4px; letter-spacing: -0.4px; }
.pv-h2 { font-size: 22px; font-weight: 600; line-height: 1.3; margin: 18px 0 3px; }
.pv-h3 { font-size: 18px; font-weight: 600; line-height: 1.3; margin: 14px 0 2px; }
.pv-content > .pv-h1:first-child,
.pv-content > .pv-h2:first-child,
.pv-content > .pv-h3:first-child { margin-top: 0; }
.pv-row { display: flex; align-items: flex-start; gap: 8px; padding: 2px 0; }
.pv-row > div { flex: 1; min-width: 0; word-break: break-word; }
.pv-bul { width: 18px; text-align: center; flex: 0 0 18px; }
.pv-num { min-width: 20px; flex: 0 0 auto; }
.pv-tri { color: var(--text-faint, #9b9a97); font-size: 11px; line-height: 1.7; flex: 0 0 14px; }
.pv-check { flex: 0 0 18px; }
.pv-todo.done > div { color: var(--text-faint, #9b9a97); text-decoration: line-through; }
.pv-quote {
  border-left: 3px solid var(--text, #37352f);
  padding: 2px 0 2px 14px;
  margin: 8px 0;
  word-break: break-word;
}
.pv-callout {
  display: flex;
  gap: 10px;
  background: var(--bg-callout, #f1f1ef);
  border-radius: 6px;
  padding: 12px 14px;
  margin: 8px 0;
}
.pv-callout-ic { flex: 0 0 auto; }
.pv-code {
  background: var(--bg-code, #f7f6f3);
  border: 1px solid var(--border, #e9e9e7);
  border-radius: 6px;
  padding: 14px 16px;
  margin: 8px 0;
  overflow-x: auto;
}
.pv-code code, .pv-math code {
  font-family: var(--font-mono, monospace);
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre;
  color: var(--text, #37352f);
}
.pv-math {
  background: var(--bg-code, #f7f6f3);
  border: 1px solid var(--border, #e9e9e7);
  border-radius: 6px;
  padding: 12px 16px;
  margin: 8px 0;
  overflow-x: auto;
  text-align: center;
}
.pv-hr { border: none; height: 1px; background: var(--border-strong, #d3d3d1); margin: 16px 0; }

/* tables — mirror the editor's .ntable so a published table matches the app */
.pv-tablewrap { overflow-x: auto; margin: 10px 0; }
.pv-table { border-collapse: collapse; table-layout: auto; }
.pv-table.pv-table-fixed { table-layout: fixed; }
.pv-th, .pv-td {
  border: 1px solid var(--border, #e9e9e7);
  padding: 6px 9px;
  font-size: 15px;
  line-height: 1.5;
  text-align: left;
  vertical-align: top;
  min-width: 90px;
  max-width: 420px;
  word-break: break-word;
  white-space: pre-wrap;
}
/* once the table is resized the colgroup owns the widths */
.pv-table.pv-table-fixed .pv-th,
.pv-table.pv-table-fixed .pv-td { min-width: 0; max-width: none; }
.pv-th { font-weight: 600; background: var(--bg-code, #f7f6f3); }
/* cell prose should sit tight, not inherit block paragraph spacing */
.pv-th > .pv-p, .pv-td > .pv-p { padding: 0; }

/* columns — flex tracks like the editor's .col-box */
.pv-cols { display: flex; gap: 20px; margin: 10px 0; align-items: flex-start; }
.pv-col { flex: 1 1 0; min-width: 0; word-break: break-word; }
.pv-col > *:first-child { margin-top: 0; }
.pv-col > .pv-figure { margin: 6px 0; }

/* media */
.pv-figure { margin: 12px 0; }
.pv-img { max-width: 100%; border-radius: 6px; display: block; }
.pv-cap { font-size: 13px; color: var(--text-faint, #9b9a97); margin-top: 6px; }
.pv-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 6px 0;
  border: 1px solid var(--border, #e9e9e7);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text, #37352f);
  text-decoration: none;
}
.pv-file:hover { background: var(--bg-hover, rgba(0, 0, 0, 0.045)); }
.pv-file-ic { flex: 0 0 auto; }
.pv-file-name { text-decoration: underline; }
.pv-bookmark {
  display: block;
  margin: 8px 0;
  padding: 12px 14px;
  border: 1px solid var(--border, #e9e9e7);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text, #37352f);
}
.pv-bookmark:hover { background: var(--bg-hover, rgba(0, 0, 0, 0.045)); }
.pv-bm-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pv-bm-title { font-size: 14px; font-weight: 500; }
.pv-bm-desc {
  font-size: 12.5px;
  color: var(--text-light, #787774);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pv-bm-url {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-faint, #9b9a97);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pv-bm-fav { width: 14px; height: 14px; flex: 0 0 auto; border-radius: 2px; }

/* live embeds (video / map / doc / tweet …) — mirror the editor's embed frame */
.pv-embed { margin: 12px 0; }
.pv-embed-frame {
  position: relative;
  width: 100%;
  max-width: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border, #e9e9e7);
}
.pv-embed-scroll { background: var(--bg, #fff); }
.pv-embed-if { display: block; width: 100%; height: 100%; border: 0; }
.pv-embed-open {
  display: inline-block;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-faint, #9b9a97);
  text-decoration: none;
}
.pv-embed-open:hover { color: var(--accent, #5b5bd6); text-decoration: underline; }

.pv-content code {
  font-family: var(--font-mono, monospace);
  font-size: 85%;
  background: var(--bg-code, #f7f6f3);
  padding: 1px 4px;
  border-radius: 3px;
}
.pv-content a { color: var(--accent, #5b5bd6); text-decoration: underline; }

@media (max-width: 720px) {
  .pv-page { padding: 32px 20px 60px; }
  .pv-title { font-size: 32px; }
  .pv-cols { flex-direction: column; gap: 8px; }
  .share-overlay { padding: 8vh 14px 14px; }
}

/* "Shared with me" sidebar badge */
.shared-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--accent, #5b5bd6);
  color: #fff;
  opacity: .85;
}
