/* =========================================================
   editor.css — Notion-style full-page note editor
   ========================================================= */

.editor-page {
  position: fixed; inset: 0; z-index: 500;
  background: var(--bg);
  display: flex; flex-direction: column;
  min-height: 0;
}

/* ---------- top bar ---------- */
.ed-topbar {
  height: 50px; flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg);
}
.ed-icbtn {
  width: 32px; height: 32px; display: grid; place-items: center;
  border: none; background: transparent; color: var(--text-2);
  border-radius: var(--radius-sm); transition: background var(--speed), color var(--speed);
}
.ed-icbtn:hover { background: var(--bg-hover); color: var(--text); }
.ed-crumb {
  font-size: 13.5px; font-weight: 550; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw;
}
.ed-spacer { flex: 1; }
.ed-status { font-size: 11.5px; color: var(--text-3); min-width: 54px; text-align: right; }
.ed-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text);
  font-size: 12.5px; font-weight: 550; transition: background var(--speed), border-color var(--speed);
}
.ed-btn:hover { background: var(--bg-hover); border-color: var(--text-3); }
.ed-btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.ed-btn--primary:hover { filter: brightness(1.05); border-color: var(--accent); }

/* ---------- scroller + document column ---------- */
.ed-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.ed-doc { max-width: 760px; margin: 0 auto; padding: 40px 28px 45vh; position: relative; }

/* ---------- title ---------- */
.ed-title {
  display: block; width: 100%; border: none; outline: none; resize: none;
  background: transparent; color: var(--text);
  font-family: var(--font-ui); font-size: 38px; font-weight: 760;
  letter-spacing: -.02em; line-height: 1.18; padding: 0; margin: 0 0 8px;
  overflow: hidden;
}
.ed-title.is-static { white-space: pre-wrap; word-break: break-word; }
.ed-title::placeholder { color: var(--text-3); }

/* ---------- ProseMirror body ---------- */
.ed-body { font-size: 16px; line-height: 1.6; color: var(--text); }
.ed-prose { outline: none; min-height: 40px; }
.ed-prose > * + * { margin-top: 2px; }
.ed-prose p { margin: 3px 0; }
.ed-prose h1 { font-size: 1.85em; font-weight: 720; letter-spacing: -.02em; line-height: 1.3; margin: .7em 0 .15em; }
.ed-prose h2 { font-size: 1.45em; font-weight: 680; letter-spacing: -.015em; line-height: 1.3; margin: .6em 0 .1em; }
.ed-prose h3 { font-size: 1.2em; font-weight: 660; line-height: 1.3; margin: .5em 0 .08em; }
.ed-prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.ed-prose strong { font-weight: 700; }
.ed-prose ul, .ed-prose ol { padding-left: 1.55em; margin: 3px 0; }
.ed-prose li { margin: 2px 0; }
.ed-prose li > p { margin: 0; }
.ed-prose blockquote {
  border-left: 3px solid var(--text-3); margin: 6px 0; padding: 2px 0 2px 14px; color: var(--text-2);
}
.ed-prose code {
  background: var(--bg-sunken); border: 1px solid var(--border-soft);
  padding: 1px 5px; border-radius: 5px; font-family: var(--font-mono);
  font-size: .85em; color: var(--accent);
}
.ed-prose pre {
  background: var(--bg-sunken); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 14px 16px; margin: 8px 0; overflow-x: auto;
}
.ed-prose pre code { background: none; border: none; padding: 0; color: var(--text); font-size: 13px; line-height: 1.6; }
.ed-prose hr {
  border: none; border-top: 2px solid var(--border); margin: 18px 0;
}
.ed-prose ::selection { background: var(--accent-soft); }

/* placeholder */
.ed-prose .is-empty::before {
  content: attr(data-placeholder);
  color: var(--text-3); float: left; height: 0; pointer-events: none;
}

/* task list */
.ed-prose ul[data-type="taskList"] { list-style: none; padding-left: .2em; }
.ed-prose ul[data-type="taskList"] li { display: flex; align-items: flex-start; gap: 9px; }
.ed-prose ul[data-type="taskList"] li > label { margin-top: .28em; flex-shrink: 0; user-select: none; }
.ed-prose ul[data-type="taskList"] li > div { flex: 1; min-width: 0; }
.ed-prose ul[data-type="taskList"] input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.ed-prose ul[data-type="taskList"] li[data-checked="true"] > div { color: var(--text-3); text-decoration: line-through; }

/* tables */
.ed-prose .tableWrapper { overflow-x: auto; margin: 10px 0; }
.ed-prose table { border-collapse: collapse; width: 100%; table-layout: fixed; }
.ed-prose table td, .ed-prose table th {
  border: 1px solid var(--border); padding: 7px 10px; vertical-align: top;
  min-width: 80px; position: relative;
}
.ed-prose table th { background: var(--bg-sunken); font-weight: 650; text-align: left; }
.ed-prose table .selectedCell::after {
  content: ""; position: absolute; inset: 0; background: var(--accent-soft); pointer-events: none;
}
.ed-prose table p { margin: 0; }
.ed-prose .column-resize-handle {
  position: absolute; right: -2px; top: 0; bottom: 0; width: 4px;
  background: var(--accent); cursor: col-resize;
}
.ed-prose.resize-cursor { cursor: col-resize; }

/* ---------- video page cover + built-in properties ---------- */
.ed-cover { width: 100%; height: 28vh; min-height: 160px; max-height: 320px; overflow: hidden; background: var(--bg-sunken); }
.ed-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ed-props { margin: 4px 0 14px; border-bottom: 1px solid var(--border-soft); padding-bottom: 12px; }
.ed-props__toggle {
  display: inline-flex; align-items: center; gap: 6px; border: none; background: transparent;
  color: var(--text-3); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  padding: 4px 0; margin-bottom: 4px;
}
.ed-props__toggle:hover { color: var(--text-2); }
.ed-props__chev { transition: transform var(--speed); display: inline-block; }
.ed-props.is-collapsed .ed-props__chev { transform: rotate(-90deg); }
.ed-props.is-collapsed .ed-props__body { display: none; }
.ed-props__body { display: flex; flex-direction: column; gap: 2px; }
.ed-prop { display: flex; gap: 12px; font-size: 13.5px; padding: 3px 0; }
.ed-prop__k { width: 150px; flex-shrink: 0; color: var(--text-3); display: flex; gap: 7px; }
.ed-prop__v { color: var(--text); min-width: 0; display: flex; align-items: center; gap: 7px; }
.ed-prop__avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--bg-sunken); }
.ed-cover.is-channel { height: 22vh; min-height: 130px; }
.ed-prop__link { color: var(--accent); text-decoration: none; font-weight: 550; }
.ed-prop__link:hover { text-decoration: underline; }

/* ---------- custom properties (per item) ---------- */
.ed-cprops { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 16px; }
.ed-cprop { display: flex; align-items: flex-start; gap: 10px; min-height: 30px; }
.ed-cprop__name {
  width: 160px; flex-shrink: 0; border: none; background: transparent; text-align: left;
  color: var(--text-3); font-size: 13px; padding: 5px 6px; border-radius: 5px; display: flex; gap: 6px; align-items: center;
}
.ed-cprop__name:hover { background: var(--bg-hover); color: var(--text-2); }
.ed-cprop__val { flex: 1; min-width: 0; display: flex; align-items: center; }
.ed-pv-input, .ed-pv-date {
  width: 100%; max-width: 360px; border: 1px solid transparent; background: transparent; color: var(--text);
  font-size: 13.5px; padding: 5px 7px; border-radius: 5px; font-family: inherit;
}
.ed-pv-input:hover, .ed-pv-date:hover { background: var(--bg-sunken); }
.ed-pv-input:focus, .ed-pv-date:focus { background: var(--bg-sunken); border-color: var(--accent); outline: none; }
.ed-pv-check { width: 16px; height: 16px; accent-color: var(--accent); margin: 6px; cursor: pointer; }
.ed-pv-select {
  border: none; background: transparent; color: var(--text); font-size: 13.5px; padding: 5px 8px;
  border-radius: 5px; text-align: left; min-width: 120px;
}
.ed-pv-select:hover { background: var(--bg-sunken); }
.ed-pv-empty { color: var(--text-3); }
.ed-pv-multi { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; padding: 3px 0; }
.ed-pv-chip {
  display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--text);
  border-radius: 4px; padding: 2px 4px 2px 8px; font-size: 12.5px;
}
.ed-pv-chip button { border: none; background: transparent; color: var(--text-3); font-size: 13px; line-height: 1; padding: 0 2px; }
.ed-pv-chip button:hover { color: var(--accent); }
.ed-pv-add { border: 1px dashed var(--border); background: transparent; color: var(--text-3); border-radius: 5px; padding: 3px 8px; font-size: 12px; }
.ed-pv-add:hover { color: var(--text); border-color: var(--text-3); }
.ed-cprop__add {
  align-self: flex-start; border: none; background: transparent; color: var(--text-3);
  font-size: 13px; padding: 6px; border-radius: 5px; margin-top: 2px;
}
.ed-cprop__add:hover { background: var(--bg-hover); color: var(--text-2); }

/* ---------- embedded video card ---------- */
.ed-vcard {
  position: relative;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--bg-elevated); margin: 10px 0;
  max-width: 100%; width: 440px; user-select: none;
  transition: border-color var(--speed), box-shadow var(--speed);
}
.ed-vcard__resize {
  position: absolute; right: 0; top: 0; bottom: 0; width: 10px; cursor: col-resize;
  z-index: 2;
}
.ed-vcard__resize::after {
  content: ""; position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 36px; border-radius: 3px; background: var(--text-3); opacity: 0; transition: opacity var(--speed);
}
.ed-vcard:hover .ed-vcard__resize::after { opacity: .5; }
.ed-vcard:hover { border-color: var(--text-3); }
.ed-vcard.ProseMirror-selectednode { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.ed-vcard--context { margin: 0 0 18px; }
.ed-vcard__thumb { position: relative; display: block; aspect-ratio: 16/9; background: var(--bg-sunken); }
.ed-vcard__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ed-vcard__dur {
  position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.82); color: #fff;
  font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px;
}
.ed-vcard__play {
  position: absolute; inset: 0; margin: auto; width: 46px; height: 46px;
  display: grid; place-items: center; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; font-size: 17px; opacity: 0; transition: opacity var(--speed);
}
.ed-vcard__thumb:hover .ed-vcard__play { opacity: 1; }
.ed-vcard__body { display: flex; gap: 10px; padding: 11px 12px; }
.ed-vcard__avatar { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; object-fit: cover; background: var(--bg-sunken); }
.ed-vcard__avatar.is-ph { display: grid; place-items: center; font-weight: 700; color: var(--text-2); }
.ed-vcard__meta { min-width: 0; flex: 1; }
.ed-vcard__title { font-weight: 600; font-size: 13.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ed-vcard__channel { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.ed-vcard__stats { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

/* ---------- slash menu ---------- */
.ed-slash {
  position: absolute; z-index: 30; width: 280px; max-height: 320px; overflow-y: auto;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 6px;
}
.ed-slash__item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 7px 9px; border: none; background: transparent; border-radius: var(--radius-sm);
  text-align: left; color: var(--text);
}
.ed-slash__item.is-sel { background: var(--bg-hover); }
.ed-slash__ico {
  width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center;
  border: 1px solid var(--border-soft); border-radius: 6px; background: var(--bg);
  font-size: 15px; font-weight: 600; color: var(--text-2);
}
.ed-slash__txt { display: flex; flex-direction: column; min-width: 0; }
.ed-slash__txt b { font-size: 13.5px; font-weight: 600; }
.ed-slash__txt small { font-size: 11.5px; color: var(--text-3); }

/* ---------- bubble (selection) toolbar ---------- */
.ed-bubble {
  position: absolute; z-index: 35;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 9px; box-shadow: var(--shadow-pop); padding: 4px 6px;
}
.ed-bubble__row { display: flex; align-items: center; gap: 2px; flex-wrap: nowrap; }
.ed-bb {
  min-width: 28px; height: 28px; padding: 0 7px; border: none; background: transparent;
  color: var(--text); border-radius: 6px; font-size: 13.5px; display: grid; place-items: center;
  transition: background var(--speed);
}
.ed-bb:hover { background: var(--bg-hover); }
.ed-bb.is-on { background: var(--accent-soft); color: var(--accent); }
.ed-bb__sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.ed-bb__label { font-size: 11px; color: var(--text-3); padding: 0 2px; font-weight: 700; }
.ed-sw {
  width: 20px; height: 20px; border-radius: 5px; border: 1px solid var(--border);
  display: grid; place-items: center; font-size: 11px; font-weight: 700; line-height: 1;
  background: var(--bg); color: var(--text-3);
}
.ed-sw.fg { font-weight: 800; }
.ed-sw:hover { outline: 2px solid var(--accent-soft); }

/* ---------- table toolbar ---------- */
.ed-tabletb {
  position: absolute; z-index: 30; display: flex; gap: 3px; padding: 4px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow-pop);
}
.ed-ttb {
  height: 26px; padding: 0 9px; border: none; background: transparent; color: var(--text);
  border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.ed-ttb:hover { background: var(--bg-hover); }
.ed-ttb.is-danger { color: var(--accent); }

/* ---------- block drag handle ---------- */
.ed-handle {
  position: absolute; left: 0; z-index: 25; display: grid; place-items: center;
  width: 26px; height: 28px; border-radius: 6px; color: var(--text-3);
  cursor: grab; user-select: none; transition: background var(--speed), color var(--speed);
}
.ed-handle:hover { background: var(--bg-hover); color: var(--text); }
.ed-handle:active { cursor: grabbing; }
.ed-handle__grip { pointer-events: none; display: grid; place-items: center; }
.ed-handle__grip svg { fill: currentColor; }
body.ed-dragging, body.ed-dragging * { cursor: grabbing !important; }
.ed-dropline { position: absolute; z-index: 26; height: 3px; border-radius: 2px; background: var(--accent); pointer-events: none; }

.ed-blockmenu {
  position: absolute; z-index: 36; min-width: 180px; padding: 6px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-pop);
}
.ed-blockmenu__item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 9px;
  border: none; background: transparent; border-radius: var(--radius-sm); text-align: left;
  color: var(--text); font-size: 13.5px;
}
.ed-blockmenu__item:hover { background: var(--bg-hover); }
.ed-blockmenu__item.is-danger { color: var(--accent); }
.ed-blockmenu__ico { width: 20px; text-align: center; color: var(--text-3); }
.ed-blockmenu__div { height: 1px; background: var(--border-soft); margin: 5px 4px; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .ed-handle { display: none; }
  .ed-doc { padding: 24px 16px 45vh; }
  .ed-title { font-size: 30px; }
  .ed-crumb { max-width: 30vw; }
  .ed-btn span { display: none; }
  .ed-bubble__row { flex-wrap: wrap; max-width: 92vw; }
}

/* =========================================================
   ANIMATION LAYER — editor (added)
   ========================================================= */
@keyframes ed-in     { from { opacity:0; transform:scale(.975);} to { opacity:1; transform:none; } }
@keyframes ed-rise   { from { opacity:0; transform:translateY(12px);} to { opacity:1; transform:none; } }
@keyframes ed-pop    { from { opacity:0; transform:translateY(6px) scale(.97);} to { opacity:1; transform:none; } }

/* page enters with a soft scale/fade */
.editor-page { animation: ed-in .3s cubic-bezier(.2,.8,.2,1); }

/* one-shot reveal of the document header (cover → title → props) on open.
   Only these structural blocks animate — the prose body is left untouched so
   typing never re-triggers motion. */
.ed-cover  { animation: ed-rise .45s cubic-bezier(.2,.8,.2,1) both; }
.ed-title  { animation: ed-rise .45s cubic-bezier(.2,.8,.2,1) .06s both; }
.ed-props  { animation: ed-rise .45s cubic-bezier(.2,.8,.2,1) .12s both; }

/* floating menus pop in */
.ed-slash, .ed-bubble, .ed-blockmenu, .ed-tabletb { animation: ed-pop .16s cubic-bezier(.2,.8,.2,1); }

/* toolbar / handle / card micro-interactions */
.ed-icbtn:active, .ed-btn:active { transform: scale(.94); }
.ed-icbtn, .ed-btn { transition: background var(--speed), color var(--speed), border-color var(--speed), transform var(--speed); }
.ed-slash__item, .ed-blockmenu__item { transition: background var(--speed), padding-left var(--speed); }
.ed-slash__item:hover, .ed-blockmenu__item:hover { padding-left: 13px; }
.ed-bb { transition: background var(--speed), transform var(--speed); }
.ed-bb:active { transform: scale(.9); }
.ed-vcard { transition: border-color var(--speed), box-shadow var(--speed), transform var(--speed); }
.ed-vcard:hover { transform: translateY(-2px); }
.ed-vcard__thumb img { transition: transform .5s cubic-bezier(.2,.8,.2,1); }
.ed-vcard:hover .ed-vcard__thumb img { transform: scale(1.04); }

@media (prefers-reduced-motion: reduce) {
  .editor-page, .ed-cover, .ed-title, .ed-props,
  .ed-slash, .ed-bubble, .ed-blockmenu, .ed-tabletb { animation-duration: .01ms !important; }
}
