/* /funcionalidades/documentos/ — a document open in the workspace. Three
   scenes (pantallas-escenas.js): 0 Marta writes a new task and the footer
   says Saving…; 1 saved — the resting state; 2 Version history, with an
   older version chosen. The typing is a width that grows in steps; the
   counts before and after her task are both in the markup. */

.pn-frame[data-screen="documents"] {
  --dc-accent: #467557;
  --dc-primary: #2c2822;
}

.pn-frame[data-screen="documents"] .pn-body.is-module.is-flush {
  flex-direction: row;
  background: #fff;
}

/* ---------- the workspace tree ---------- */

.pn-frame[data-screen="documents"] .dc-side {
  display: flex;
  flex: 0 0 192px !important;
  flex-direction: column;
  border-right: 1px solid var(--ac-line);
  background: #fff;
  font-size: 11px;
}

.pn-frame[data-screen="documents"] .dc-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 38px;
  padding: 0 10px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--ac-line);
  color: var(--ac-dim);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.pn-frame[data-screen="documents"] .dc-i { width: 13px; height: 13px; flex-shrink: 0; }
.pn-frame[data-screen="documents"] .dc-chev { width: 11px; height: 11px; flex-shrink: 0; color: var(--ac-dim); }

.pn-frame[data-screen="documents"] .dc-search {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 7px 7px 0;
  padding: 6px 8px;
  border: 1px solid var(--ac-line);
  border-radius: 7px;
  color: var(--ac-dim);
  font-size: 10px;
}

.pn-frame[data-screen="documents"] .dc-search span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pn-frame[data-screen="documents"] .dc-tree { display: flex; flex-direction: column; gap: 2px; padding: 8px 7px 0; }

.pn-frame[data-screen="documents"] :is(.dc-root, .dc-node) {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 7px;
  border-radius: 6px;
  color: var(--ac-mut);
}

.pn-frame[data-screen="documents"] :is(.dc-root, .dc-node) span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pn-frame[data-screen="documents"] .dc-root { color: var(--ac-ink); font-weight: 500; }
.pn-frame[data-screen="documents"] .dc-root.is-on { background: rgb(44 40 34 / 0.08); color: var(--dc-primary); }
.pn-frame[data-screen="documents"] .dc-branch { display: flex; flex-direction: column; gap: 2px; padding-left: 12px; }
.pn-frame[data-screen="documents"] .dc-node.is-doc { padding-left: 17px; }
.pn-frame[data-screen="documents"] .dc-node.is-doc.is-on { background: #f1f1f3; color: var(--ac-ink); font-weight: 500; }

.pn-frame[data-screen="documents"] .dc-rule { display: block; height: 1px; margin: 10px 7px; background: var(--ac-line); }
.pn-frame[data-screen="documents"] .dc-views { display: flex; flex-direction: column; gap: 2px; padding: 0 7px; }
.pn-frame[data-screen="documents"] .dc-views .dc-node { min-height: 29px; }

/* ---------- the editor ---------- */

.pn-frame[data-screen="documents"] .dc-editor {
  display: flex;
  flex: 1 1 auto !important;
  flex-direction: column;
  min-width: 0;
  background: #fff;
}

.pn-frame[data-screen="documents"] .dc-chrome {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 10px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--ac-line);
}

.pn-frame[data-screen="documents"] .dc-chrome-btn {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 6px;
  color: var(--ac-mut);
}

.pn-frame[data-screen="documents"] .dc-chrome-btn.is-danger { color: var(--ac-bad); }
.pn-frame[data-screen="documents"] .dc-ti { width: 12px; height: 12px; }
.pn-frame[data-screen="documents"] .dc-doc-i { width: 13px; height: 13px; flex-shrink: 0; color: var(--ac-mut); }

.pn-frame[data-screen="documents"] .dc-title {
  flex: 1;
  overflow: hidden;
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pn-frame[data-screen="documents"] .dc-folder { color: var(--ac-dim); font-size: 9.5px; white-space: nowrap; }

.pn-frame[data-screen="documents"] .dc-people { display: flex; align-items: center; padding: 0 4px; }

.pn-frame[data-screen="documents"] .dc-person {
  display: grid;
  width: 21px;
  height: 21px;
  place-items: center;
  margin-left: -5px;
  border: 2px solid #fff;
  border-radius: 99px;
  background: #f1f1f3;
  box-shadow: 0 0 0 1px var(--dc-c);
  color: var(--ac-ink);
  font-size: 8px;
  font-weight: 600;
}

.pn-frame[data-screen="documents"] .dc-person:first-child { margin-left: 0; }
.pn-frame[data-screen="documents"] .dc-chrome-acts { display: flex; align-items: center; gap: 1px; margin-left: 4px; }

.pn-frame[data-screen="documents"] .dc-toolbar {
  display: flex;
  align-items: center;
  gap: 1px;
  height: 35px;
  padding: 3px 7px 0;
  box-sizing: border-box;
  border-bottom: 1px solid var(--ac-line);
}

.pn-frame[data-screen="documents"] .dc-tool {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 4px;
  color: var(--ac-ink);
}

.pn-frame[data-screen="documents"] .dc-tool .dc-ti { width: 12px; height: 12px; }
.pn-frame[data-screen="documents"] .dc-tool-rule { width: 1px; height: 16px; margin: 0 4px; background: var(--ac-line); }

.pn-frame[data-screen="documents"] .dc-block {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 90px;
  height: 22px;
  padding: 0 4px 0 7px;
  box-sizing: border-box;
  font-size: 11px;
  font-weight: 500;
}

.pn-frame[data-screen="documents"] .dc-block .dc-ti { color: var(--ac-mut); }

.pn-frame[data-screen="documents"] .dc-scroll { flex: 1; min-height: 0; overflow: hidden; }

.pn-frame[data-screen="documents"] .dc-canvas {
  width: 717px;
  max-width: 100%;
  margin: 0 auto;
  padding: 29px 51px 45px;
  box-sizing: border-box;
}

/* The document's typography (packages/editor): 1rem text, bold headings. */
.pn-frame[data-screen="documents"] .dc-content { position: relative; color: var(--ac-ink); font-size: 12.8px; line-height: 1.6; }
.pn-frame[data-screen="documents"] .dc-content > p { margin: 0 0 4px; }

.pn-frame[data-screen="documents"] .dc-content h2 {
  margin: 22px 0 6px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
}

.pn-frame[data-screen="documents"] .dc-todos { margin: 0; padding: 0 0 0 20px; list-style: none; }
.pn-frame[data-screen="documents"] .dc-todo { position: relative; padding: 2px 0; }
.pn-frame[data-screen="documents"] .dc-todo.is-done > span { color: var(--ac-mut); text-decoration: line-through; }

.pn-frame[data-screen="documents"] .dc-box {
  position: absolute;
  top: 6px;
  left: -19px;
  display: grid;
  width: 13px;
  height: 13px;
  place-items: center;
  box-sizing: border-box;
  border: 1px solid #d4d4d8;
  border-radius: 3px;
  background: #fafafa;
}

.pn-frame[data-screen="documents"] .dc-todo.is-done .dc-box { border-color: var(--dc-primary); background: rgb(44 40 34 / 0.1); }
.pn-frame[data-screen="documents"] .dc-tick { width: 9px; height: 9px; color: var(--dc-primary); stroke-width: 3; }

.pn-frame[data-screen="documents"] .dc-callout {
  display: flex;
  gap: 10px;
  margin: 10px 0;
  padding: 10px 13px;
  border: 1px solid var(--ac-line);
  border-radius: 8px;
  background: #f4f4f5;
}

.pn-frame[data-screen="documents"] .dc-bulb { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; color: var(--dc-accent); }

.pn-frame[data-screen="documents"] .dc-bullets { margin: 0; padding-left: 21px; list-style: disc; }
.pn-frame[data-screen="documents"] .dc-bullets li { padding: 1px 0; }

.pn-frame[data-screen="documents"] .dc-figure { margin: 16px 0 0; text-align: center; }
.pn-frame[data-screen="documents"] .dc-figure svg { display: block; width: 360px; max-width: 100%; margin: 0 auto; }
.pn-frame[data-screen="documents"] .dc-figure figcaption { margin-top: 6px; color: var(--ac-mut); font-size: 11px; }

/* Someone else's cursor: their colour, a caret and their initials over it. */
.pn-frame[data-screen="documents"] .dc-caret {
  position: relative;
  display: inline-block;
  width: 0;
  height: 1.15em;
  margin-left: 1px;
  border-left: 2px solid var(--dc-c);
  vertical-align: -0.2em;
}

.pn-frame[data-screen="documents"] .dc-caret b {
  position: absolute;
  top: -15px;
  left: -1px;
  display: grid;
  width: 15px;
  height: 15px;
  place-items: center;
  box-sizing: border-box;
  border: 2px solid var(--dc-c);
  border-radius: 99px;
  background: #fff;
  color: var(--ac-ink);
  font-size: 7px;
  font-weight: 700;
  line-height: 1;
  transform: translateX(-50%);
}

/* The line Marta is writing: its width grows as she types. */
.pn-frame[data-screen="documents"] .dc-type {
  display: inline-block;
  max-width: none;
  overflow: hidden;
  vertical-align: bottom;
  white-space: nowrap;
}

.pn-frame[data-screen="documents"] .dc-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px 8px;
  min-height: 29px;
  padding: 4px 13px;
  box-sizing: border-box;
  border-top: 1px solid var(--ac-line);
  color: var(--ac-dim);
  font-size: 9.5px;
}

.pn-frame[data-screen="documents"] :is(.dc-counts, .dc-state) { display: inline-flex; align-items: center; gap: 8px; }
.pn-frame[data-screen="documents"] .dc-dot { width: 6px; height: 6px; border-radius: 99px; }
.pn-frame[data-screen="documents"] .dc-state { gap: 5px; }
.pn-frame[data-screen="documents"] .dc-state.is-saving { color: var(--ac-mut); }
.pn-frame[data-screen="documents"] .dc-state.is-saving .dc-dot { background: #f59e0b; }
.pn-frame[data-screen="documents"] .dc-state.is-saved { color: #059669; }
.pn-frame[data-screen="documents"] .dc-state.is-saved .dc-dot { background: #10b981; }
.pn-frame[data-screen="documents"] .dc-state.is-saved > i:not(.dc-dot) { color: var(--ac-dim); }
.pn-frame[data-screen="documents"] .dc-state.is-saved > :last-child { color: var(--ac-dim); }

/* Two versions of the counts and of the state share one cell each: scene 0
   is the only one before her task and still saving. */
.pn-frame[data-screen="documents"] .dc-swap { display: inline-grid; justify-items: end; }
.pn-frame[data-screen="documents"] .dc-swap > * { grid-area: 1 / 1; }
.pn-frame[data-screen="documents"] :is(.dc-counts.is-before, .dc-state.is-saving) { visibility: hidden; }
.pn-frame[data-screen="documents"][data-mk-scene="0"] :is(.dc-counts.is-before, .dc-state.is-saving) { visibility: visible; }
.pn-frame[data-screen="documents"][data-mk-scene="0"] :is(.dc-counts.is-after, .dc-state.is-saved) { visibility: hidden; }

/* ---------- version history ---------- */

.pn-frame[data-screen="documents"] .dc-overlay {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: none;
  place-items: center;
  padding: 13px;
  box-sizing: border-box;
  background: rgb(17 19 24 / 0.25);
}

.pn-frame[data-screen="documents"][data-mk-scene="2"] .dc-overlay { display: grid; }

.pn-frame[data-screen="documents"] .dc-modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--ac-line);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 24px 60px rgb(17 19 24 / 0.18);
}

.pn-frame[data-screen="documents"] .dc-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 19px 13px;
  border-bottom: 1px solid var(--ac-line);
}

.pn-frame[data-screen="documents"] .dc-modal-head p { font-size: 14px; font-weight: 650; }
.pn-frame[data-screen="documents"] .dc-close { width: 14px; height: 14px; color: var(--ac-dim); }

.pn-frame[data-screen="documents"] .dc-modal-body {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 13px;
  min-height: 0;
  padding: 16px 19px;
}

.pn-frame[data-screen="documents"] .dc-preview {
  position: relative;
  display: grid;
  align-items: start;
  overflow: hidden;
  border: 1px solid var(--ac-line);
  border-radius: 10px;
  background: #fafafa;
}

.pn-frame[data-screen="documents"] .dc-canvas.is-preview { grid-area: 1 / 1; width: auto; padding: 22px 40px; }
.pn-frame[data-screen="documents"] .dc-v6 { visibility: hidden; }

.pn-frame[data-screen="documents"] .dc-versions {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--ac-line);
  border-radius: 10px;
  font-size: 11px;
}

.pn-frame[data-screen="documents"] .dc-versions-title { padding: 10px 13px; border-bottom: 1px solid var(--ac-line); font-weight: 600; }
.pn-frame[data-screen="documents"] .dc-restore { padding: 10px; border-bottom: 1px solid var(--ac-line); }
.pn-frame[data-screen="documents"] .dc-restore .md-btn { justify-content: center; width: 100%; box-sizing: border-box; opacity: 0.6; }
.pn-frame[data-screen="documents"] .dc-ver-list { display: flex; flex-direction: column; gap: 2px; padding: 6px; }

.pn-frame[data-screen="documents"] .dc-ver {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--ac-mut);
  font-size: 9.5px;
}

.pn-frame[data-screen="documents"] .dc-ver b { font-size: 11px; font-weight: 500; }
.pn-frame[data-screen="documents"] .dc-ver.is-seven { background: rgb(44 40 34 / 0.08); color: var(--dc-primary); }

/* ---------- the motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  /* 0 — the new item appears, Marta types it, the save lands at the end. */
  .pn-frame[data-screen="documents"][data-mk-scene="0"] .dc-todo.is-new { animation: dc-in 0.25s ease-out 0.3s both; }
  .pn-frame[data-screen="documents"][data-mk-scene="0"] .dc-type { animation: dc-type 3s steps(34, end) 0.7s both; }
  .pn-frame[data-screen="documents"][data-mk-scene="0"] .dc-counts.is-before { animation: dc-off 4.2s step-end both; }
  .pn-frame[data-screen="documents"][data-mk-scene="0"] .dc-counts.is-after { animation: dc-on 4.2s step-end both; }
  .pn-frame[data-screen="documents"][data-mk-scene="0"] .dc-state.is-saving { animation: dc-off 4.6s step-end both; }
  .pn-frame[data-screen="documents"][data-mk-scene="0"] .dc-state.is-saved { animation: dc-on 4.6s step-end both; }

  /* 1 — Elena opens the history. */
  .pn-frame[data-screen="documents"][data-mk-scene="1"] .dc-history { animation: dc-press 0.34s ease 3.5s both; }

  /* 2 — the dialog; version 6 chosen at 1.3 s wakes Restore. */
  .pn-frame[data-screen="documents"][data-mk-scene="2"] .dc-overlay { animation: dc-fade 0.2s ease-out both; }
  .pn-frame[data-screen="documents"][data-mk-scene="2"] .dc-ver.is-six { animation: dc-pick 5s step-end both; }
  .pn-frame[data-screen="documents"][data-mk-scene="2"] .dc-ver.is-seven { animation: dc-unpick 5s step-end both; }
  .pn-frame[data-screen="documents"][data-mk-scene="2"] .dc-v7 { animation: dc-off 1.3s step-end both; }
  .pn-frame[data-screen="documents"][data-mk-scene="2"] .dc-v6 { animation: dc-on 1.3s step-end both; }
  .pn-frame[data-screen="documents"][data-mk-scene="2"] .dc-restore .md-btn { animation: dc-wake 5s step-end both; }
}

@keyframes dc-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes dc-type {
  from { max-width: 0; }
  to { max-width: 24em; }
}

@keyframes dc-off {
  0% { visibility: visible; }
  100% { visibility: hidden; }
}

@keyframes dc-on {
  0% { visibility: hidden; }
  100% { visibility: visible; }
}

@keyframes dc-press {
  0%, 100% { transform: none; }
  45% { transform: scale(0.88); background: #f1f1f3; }
}

@keyframes dc-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes dc-pick {
  0%, 25% { background: transparent; color: var(--ac-mut); }
  26%, 100% { background: rgb(44 40 34 / 0.08); color: var(--dc-primary); }
}

@keyframes dc-unpick {
  0%, 25% { background: rgb(44 40 34 / 0.08); color: var(--dc-primary); }
  26%, 100% { background: transparent; color: var(--ac-mut); }
}

@keyframes dc-wake {
  0%, 25% { opacity: 0.6; }
  26%, 100% { opacity: 1; }
}
