/* ═══════════════════════════════════════
   THOT — blocks.css
   Page blocks: note, todo, link, file, subpages
═══════════════════════════════════════ */

/* ── BLOCK SHELL ── */
.block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-base);
}
.block:hover {
  box-shadow: var(--shadow);
}

.block-header {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--t-fast);
}
.block.open .block-header {
  border-bottom-color: var(--border);
}

.block-icon {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}
.block-label {
  flex: 1;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.block-count {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  padding: 2px 7px;
  border-radius: 10px;
  font-family: var(--font-mono);
}
.block-toggle {
  width: 15px; height: 15px;
  color: var(--muted-lt);
  transition: transform var(--t-base);
  flex-shrink: 0;
}
.block.open .block-toggle { transform: rotate(180deg); }

.block-body {
  display: none;
}
.block.open .block-body {
  display: block;
  animation: slideDown var(--t-base);
}

/* ═══════════════════════
   NOTE BLOCK
═══════════════════════ */
.note-toolbar {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.note-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  border: none;
  background: none;
  position: relative;
}
.note-tool:hover { background: var(--border); color: var(--text); }
.note-tool.active { background: var(--accent-lt); color: var(--accent); }
.note-tool svg { width: 14px; height: 14px; }

.note-tool-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 3px;
  flex-shrink: 0;
}

.note-body {
  padding: 16px;
}

.note-editor {
  min-height: 120px;
  font-size: 14px;
  line-height: 1.78;
  color: var(--text);
  outline: none;
  font-family: var(--font-sans);
  word-break: break-word;
}
.note-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--border);
  pointer-events: none;
}
.note-editor strong { font-weight: 600; }
.note-editor em { font-style: italic; }
.note-editor u { text-decoration: underline; }
.note-editor h3 { font-size: 16px; font-weight: 600; margin: 12px 0 4px; }
.note-editor ul, .note-editor ol { padding-left: 22px; margin: 6px 0; }
.note-editor li { margin: 2px 0; }

/* [[ page link ]] */
.note-editor .page-link {
  color: var(--accent);
  background: var(--accent-lt);
  padding: 1px 5px;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  font-size: 13.5px;
}
.note-editor .page-link:hover { background: var(--accent-md); }

/* Autocomplete dropdown for [[ */
.page-link-dropdown {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 400;
  width: 260px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
  animation: slideDown var(--t-fast);
}
.pld-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: background var(--t-fast);
}
.pld-item:hover, .pld-item.active { background: var(--accent-lt); color: var(--accent); }
.pld-item-space { font-size: 11px; color: var(--muted); }

/* Focus mode */
.focus-mode .sidebar,
.focus-mode .topbar,
.focus-mode .col-side,
.focus-mode .block:not(#block-note),
.focus-mode .page-meta-row,
.focus-mode .bottom-nav {
  display: none !important;
}
.focus-mode .main { background: var(--surface); }
.focus-mode .view { background: var(--surface); }
.focus-mode .page-content { max-width: 720px; margin: 0 auto; padding-top: 60px; }
.focus-mode .two-col { grid-template-columns: 1fr; }
.focus-mode .note-editor { min-height: 60vh; font-size: 15px; line-height: 1.85; }
.focus-mode-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: none;
  align-items: center;
  justify-content: flex-end;
  padding: 0 24px;
  z-index: 200;
}
.focus-mode .focus-mode-bar { display: flex; }

/* ═══════════════════════
   TODO BLOCK
═══════════════════════ */
.todo-body {
  padding: 10px 12px 12px;
}

.todo-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast);
  position: relative;
}
.todo-item:hover { background: var(--bg); }
.todo-item:hover .todo-item-actions { opacity: 1; }

.todo-check {
  width: 16px; height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: white;
  position: relative;
  transition: all var(--t-fast);
  margin-top: 1px;
}
.todo-check:hover { border-color: var(--accent); }
.todo-check:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.todo-check:checked::after {
  content: '';
  position: absolute;
  left: 3px; top: 1px;
  width: 5px; height: 8px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.todo-text {
  flex: 1;
  font-size: 13.5px;
  line-height: 1.45;
  outline: none;
  cursor: text;
  min-width: 0;
  word-break: break-word;
}
.todo-item.done .todo-text {
  text-decoration: line-through;
  color: var(--muted);
}

.todo-due {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  font-family: var(--font-mono);
}
.todo-due.overdue { color: var(--danger); }

.todo-priority {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.todo-priority.high { background: var(--prio-high-bg); color: var(--prio-high-fg); }
.todo-priority.med  { background: var(--prio-med-bg);  color: var(--prio-med-fg);  }
.todo-priority.low  { background: var(--prio-low-bg);  color: var(--prio-low-fg);  }

.todo-item-actions {
  display: flex;
  gap: 1px;
  opacity: 0;
  transition: opacity var(--t-fast);
  flex-shrink: 0;
}

.todo-add-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  color: var(--muted-lt);
  font-size: 13px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast), color var(--t-fast);
  margin-top: 3px;
}
.todo-add-row:hover { background: var(--bg); color: var(--accent); }
.todo-add-row svg { width: 13px; height: 13px; flex-shrink: 0; }

.todo-add-input {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  margin-top: 4px;
}
.todo-add-input.open { display: flex; }
.todo-add-input input {
  flex: 1;
  border: none;
  background: none;
  font-size: 13.5px;
  outline: none;
  color: var(--text);
}
.todo-add-input input::placeholder { color: var(--muted-lt); }

/* ═══════════════════════
   LINK BLOCK
═══════════════════════ */
.link-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.link-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  text-decoration: none;
  color: var(--text);
  transition: all var(--t-fast);
  position: relative;
}
.link-card:hover {
  border-color: var(--accent);
  background: var(--accent-lt);
}
.link-card:hover .link-delete { opacity: 1; }

.link-favicon {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  overflow: hidden;
}
.link-favicon img { width: 16px; height: 16px; }

.link-info { flex: 1; min-width: 0; }
.link-title {
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-url {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-delete {
  opacity: 0;
  transition: opacity var(--t-fast);
  flex-shrink: 0;
}

.link-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: var(--muted-lt);
  font-size: 12.5px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast), color var(--t-fast);
}
.link-add-row:hover { background: var(--bg); color: var(--accent); }
.link-add-row svg { width: 13px; height: 13px; }

/* ═══════════════════════
   FILE BLOCK
═══════════════════════ */
.file-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  transition: all var(--t-fast);
  position: relative;
}
.file-card:hover { border-color: var(--accent); }
.file-card:hover .file-delete { opacity: 1; }

.file-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.file-icon.pdf  { background: var(--danger-lt); }
.file-icon.doc  { background: #EAF0FE; }
.file-icon.xls  { background: #EAF5EE; }
.file-icon.img  { background: var(--warn-lt); }
.file-icon.other { background: var(--bg); border: 1px solid var(--border); }

.file-info { flex: 1; min-width: 0; }
.file-name {
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-meta {
  font-size: 10.5px;
  color: var(--muted);
}

.file-delete {
  opacity: 0;
  transition: opacity var(--t-fast);
  flex-shrink: 0;
}

.file-drop-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: all var(--t-fast);
  line-height: 1.5;
}
.file-drop-zone:hover,
.file-drop-zone.dragover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-lt);
}
.file-drop-zone input[type="file"] { display: none; }

/* ═══════════════════════
   SUBPAGES BLOCK
═══════════════════════ */
.sub-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.subpage-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  transition: all var(--t-fast);
  text-decoration: none;
  color: var(--text);
  position: relative;
}
.subpage-card:hover {
  border-color: var(--accent);
  background: var(--accent-lt);
}
.subpage-card:hover .subpage-actions { opacity: 1; }

.subpage-card-icon { font-size: 14px; flex-shrink: 0; }
.subpage-card-info { flex: 1; min-width: 0; }
.subpage-card-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subpage-card-meta { font-size: 11px; color: var(--muted); }

.subpage-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--t-fast);
}

.subpage-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: all var(--t-fast);
  background: none;
  width: 100%;
}
.subpage-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-lt);
}
.subpage-add-btn svg { width: 13px; height: 13px; }

/* ═══════════════════════
   TIMELINE BLOCK
═══════════════════════ */
.timeline-body {
  padding: 14px 16px;
}

.timeline-item {
  display: flex;
  gap: 12px;
  padding-bottom: 16px;
  position: relative;
}
.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 14px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.timeline-dot {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--surface);
  flex-shrink: 0;
  margin-top: 3px;
  position: relative;
  z-index: 1;
}
.timeline-item.current .timeline-dot { background: var(--accent); }

.timeline-info { flex: 1; min-width: 0; }
.timeline-time { font-size: 11px; color: var(--muted); font-family: var(--font-mono); margin-bottom: 2px; }
.timeline-note { font-size: 13px; color: var(--text-2); }
.timeline-restore {
  font-size: 11.5px;
  color: var(--accent);
  cursor: pointer;
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.timeline-restore:hover { text-decoration: underline; }

/* ═══════════════════════════════════════
   TODO — when grouping & chips
═══════════════════════════════════════ */
.todo-when-group {
  margin-bottom: 6px;
}
.todo-when-label {
  font-size: 10px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; padding: 8px 10px 4px;
  opacity: .75;
}
.todo-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px;
}
.todo-text {
  font-size: 13.5px; line-height: 1.45; color: var(--text);
  cursor: pointer; outline: none; word-break: break-word;
  transition: color var(--t);
}
.todo-text:hover { color: var(--accent); }
.todo-item.done .todo-text { text-decoration: line-through; color: var(--muted); }

.todo-chips {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  margin-top: 2px;
}

/* When chips */
.when-chip {
  font-size: 10.5px; font-weight: 500;
  padding: 2px 7px; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer;
  user-select: none; white-space: nowrap;
  transition: all var(--t);
}
.when-today   { background: #FEE8E4; color: var(--danger); border-color: #F0C0B4; }
.when-soon    { background: var(--warn-lt,#FFF8EC); color: var(--warn,#B07D2F); border-color: var(--warn-bd,#E8D5A0); }
.when-someday { background: var(--bg); color: var(--muted); border-color: var(--border); }
.when-chip:hover { filter: brightness(.95); }

/* ═══════════════════════════════════════
   ARCHIVE VIEW
═══════════════════════════════════════ */
.archive-view {
  padding: 32px 40px; max-width: 720px; margin: 0 auto;
}
.archive-section { margin-bottom: 32px; }
.archive-section-title {
  font-size: 11px; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

/* ═══════════════════════════════════════
   MODAL system (centralized)
═══════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(42,37,32,.32);
  backdrop-filter: blur(3px);
  z-index: 800;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity:0 } to { opacity:1 } }
@keyframes popIn  { from { opacity:0; transform:scale(.95) translateY(6px) } to { opacity:1; transform:none } }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(42,37,32,.18);
  width: 440px; max-width: calc(100vw - 32px);
  overflow: hidden;
  animation: popIn .18s ease;
}
.modal-box-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.modal-box-title {
  flex: 1; font-family: var(--font-serif);
  font-size: 20px; font-style: italic; font-weight: 400;
  color: var(--text);
}
.modal-box-body { padding: 18px 20px; }
.modal-box-footer {
  padding: 12px 20px; background: var(--surface-2);
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

.btn-modal-cancel {
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--muted);
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; transition: all var(--t);
}
.btn-modal-cancel:hover { background: var(--bg); color: var(--text); }
.btn-modal-confirm {
  padding: 8px 18px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; color: white;
  background: var(--accent); cursor: pointer; transition: background var(--t);
}
.btn-modal-confirm:hover { background: var(--accent-dk,#2d6070); }
.btn-modal-confirm.danger { background: var(--danger); }
.btn-modal-confirm.danger:hover { background: #a03020; }

/* Emoji picker grid inside modals */
.emoji-picker-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
}
.emoji-picker-btn {
  width: 34px; height: 34px; border-radius: 7px; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background var(--t);
  border: 1px solid transparent; background: none;
}
.emoji-picker-btn:hover { background: var(--bg); }
.emoji-picker-btn.selected {
  background: var(--accent-lt);
  border-color: var(--accent);
}
