/* ============================================================
   Mặc Cảnh Studio — Architect & Compass Design System CSS
   Đợt A: Chuẩn hóa Type Scale, Spacing, Border Radius, Colors
   ============================================================ */

/* === TYPE SCALE (4 mức chuẩn) === */
:root {
  --nc-text-xs: 11px;      /* Micro labels, badges */
  --nc-text-sm: 12.5px;    /* Body captions, inputs */
  --nc-text-md: 13.5px;    /* Subheadings */
  --nc-text-lg: 15px;      /* Headings */
  --nc-text-xl: 17px;      /* Page titles */

  /* SPACING SCALE (bội số 4px) */
  --nc-sp-1: 4px;
  --nc-sp-2: 8px;
  --nc-sp-3: 12px;
  --nc-sp-4: 16px;
  --nc-sp-5: 20px;
  --nc-sp-6: 24px;

  /* BORDER RADIUS */
  --nc-radius-sm: 6px;
  --nc-radius-md: 10px;
  --nc-radius-lg: 14px;
  --nc-radius-pill: 999px;
}

/* === MASTER ARCHITECT PANEL === */
.nc-master-architect-panel {
  padding: var(--nc-sp-5) var(--nc-sp-6);
}

/* Status/Approval Banner */
.nc-arch-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--nc-sp-4);
  flex-wrap: wrap;
  padding: var(--nc-sp-4);
  margin-bottom: var(--nc-sp-5);
  border-radius: var(--nc-radius-lg);
}
.nc-arch-banner--pending {
  border: 1.5px solid var(--nf-primary);
  background: rgba(180,83,9,0.07);
}
.nc-arch-banner--approved {
  border: 1.5px solid rgba(5,150,105,0.35);
  background: rgba(5,150,105,0.06);
}

/* Status Badge */
.nc-arch-badge {
  font-size: var(--nc-text-xs);
  font-weight: 800;
  text-transform: uppercase;
  padding: 3px var(--nc-sp-2);
  border-radius: var(--nc-radius-pill);
  color: #fff;
}
.nc-arch-badge--pending { background: var(--nf-primary); }
.nc-arch-badge--approved { background: #059669; }

/* Synopsis Grid */
.nc-arch-synopsis-grid {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: var(--nc-sp-4);
  padding-bottom: var(--nc-sp-5);
  border-bottom: 1px solid var(--nf-line);
  margin-bottom: var(--nc-sp-5);
}

/* Section Card */
.nc-arch-section {
  background: var(--nf-surface-2);
  border: 1px solid var(--nf-line-strong);
  border-radius: var(--nc-radius-lg);
  padding: var(--nc-sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--nc-sp-3);
}
.nc-arch-section--highlight {
  border: 1.5px solid var(--nf-primary);
}

/* Section Title */
.nc-arch-section-title {
  font-size: var(--nc-text-md);
  font-weight: 700;
  color: var(--nf-ink);
  display: flex;
  align-items: center;
  gap: var(--nc-sp-2);
}

/* Input & Textarea */
.nc-arch-textarea {
  width: 100%;
  padding: var(--nc-sp-2) var(--nc-sp-3);
  font-size: var(--nc-text-sm);
  line-height: 1.55;
  border-radius: var(--nc-radius-sm);
  border: 1px solid var(--nf-line-strong);
  background: var(--nf-surface);
  color: var(--nf-ink);
  resize: vertical;
  font-family: inherit;
}
.nc-arch-textarea:focus {
  outline: 2px solid var(--nf-primary);
  outline-offset: -1px;
}
.nc-arch-textarea--small {
  font-size: var(--nc-text-xs);
  padding: 6px var(--nc-sp-2);
}

/* Sub-section Grid (World + Conflict) */
.nc-arch-sub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--nc-sp-3);
}

/* Label */
.nc-arch-label {
  font-size: var(--nc-text-xs);
  font-weight: 700;
  color: var(--nf-muted);
  display: block;
  margin-bottom: 3px;
}

/* === ARC BAR (4-Act Visual) === */
.nc-arch-arcs-bar {
  display: flex;
  gap: var(--nc-sp-3);
  margin-bottom: var(--nc-sp-5);
  flex-wrap: wrap;
}
.nc-arch-arc-card {
  flex: 1;
  min-width: 180px;
  background: var(--nf-surface-2);
  border: 1px solid var(--nf-line);
  border-radius: var(--nc-radius-md);
  padding: var(--nc-sp-3);
}
.nc-arch-arc-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--nc-sp-2);
  margin-bottom: var(--nc-sp-1);
}
.nc-arch-arc-card__name {
  font-size: var(--nc-text-sm);
  font-weight: 700;
}
.nc-arch-arc-card__range {
  font-size: var(--nc-text-xs);
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--nc-radius-pill);
  background: rgba(120,53,15,0.08);
  color: var(--nf-ink);
  white-space: nowrap;
}
.nc-arch-arc-card__subtitle {
  font-size: var(--nc-text-xs);
  font-weight: 700;
  color: var(--nf-ink);
  margin-bottom: 3px;
}
.nc-arch-arc-card__rule {
  font-size: var(--nc-text-xs);
  color: var(--nf-muted);
  line-height: 1.45;
}

/* === CHAPTER ROW (Collapsible by default) === */
.nc-arch-chap-row {
  background: var(--nf-surface);
  border: 1px solid var(--nf-line);
  border-radius: var(--nc-radius-md);
  padding: var(--nc-sp-3) var(--nc-sp-4);
  margin-bottom: var(--nc-sp-2);
  transition: box-shadow 0.15s ease;
}
.nc-arch-chap-row:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.nc-arch-chap-row__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--nc-sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--nc-sp-2);
}
.nc-arch-chap-row__left {
  display: flex;
  align-items: center;
  gap: var(--nc-sp-2);
  flex: 1;
  min-width: 260px;
}
.nc-arch-chap-row__actions {
  display: flex;
  align-items: center;
  gap: var(--nc-sp-2);
  flex-shrink: 0;
}

/* Chapter Number Badge */
.nc-arch-ch-num {
  font-size: var(--nc-text-xs);
  font-weight: 800;
  white-space: nowrap;
}

/* Chapter Title Input */
.nc-arch-chap-title {
  flex: 1;
  min-width: 180px;
  padding: 5px var(--nc-sp-2);
  font-size: var(--nc-text-md);
  font-weight: 700;
  border-radius: var(--nc-radius-sm);
  border: 1px solid var(--nf-line-strong);
  background: var(--nf-surface-2);
  color: var(--nf-ink);
  font-family: inherit;
}
.nc-arch-chap-title:focus {
  outline: 2px solid var(--nf-primary);
  outline-offset: -1px;
}

/* Status Badge */
.nc-arch-status-badge {
  font-size: var(--nc-text-xs);
  font-weight: 700;
  padding: 2px var(--nc-sp-2);
  border-radius: var(--nc-radius-pill);
  white-space: nowrap;
}
.nc-arch-status-badge--done {
  background: rgba(5,150,105,0.14);
  color: #059669;
}
.nc-arch-status-badge--draft {
  background: rgba(217,119,6,0.14);
  color: #b45309;
}
.nc-arch-status-badge--planned {
  background: rgba(100,116,139,0.12);
  color: #475569;
}

/* Value Shift Tag */
.nc-arch-value-shift {
  font-size: var(--nc-text-xs);
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--nc-radius-sm);
  background: var(--nf-surface-2);
  color: var(--nf-ink);
  white-space: nowrap;
}

/* Chapter Goal Row */
.nc-arch-goal-row {
  display: flex;
  align-items: center;
  gap: var(--nc-sp-2);
}
.nc-arch-goal-label {
  font-size: var(--nc-text-xs);
  font-weight: 700;
  color: var(--nf-muted);
  white-space: nowrap;
}
.nc-arch-chap-goal {
  flex: 1;
  padding: 5px var(--nc-sp-2);
  font-size: var(--nc-text-sm);
  border-radius: var(--nc-radius-sm);
  border: 1px solid var(--nf-line);
  background: var(--nf-surface);
  color: var(--nf-text);
  font-family: inherit;
}
.nc-arch-chap-goal:focus {
  outline: 2px solid var(--nf-primary);
  outline-offset: -1px;
}

/* === 4 MICRO BEATS GRID === */
.nc-arch-beats-grid {
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--nc-sp-2);
  margin-top: var(--nc-sp-2);
  padding-top: var(--nc-sp-2);
  border-top: 1px dashed var(--nf-line);
}
.nc-arch-beats-grid.is-expanded {
  display: grid;
}
.nc-arch-beat-card {
  background: var(--nf-surface-2);
  padding: 7px var(--nc-sp-2);
  border-radius: var(--nc-radius-sm);
  font-size: var(--nc-text-xs);
}
.nc-arch-beat-card__title {
  font-weight: 700;
  margin-bottom: 2px;
}
.nc-arch-beat-card__text {
  color: var(--nf-text);
  line-height: 1.4;
}

/* Beat Title Colors */
.nc-arch-beat-card--hook .nc-arch-beat-card__title { color: #2563eb; }
.nc-arch-beat-card--rising .nc-arch-beat-card__title { color: #d97706; }
.nc-arch-beat-card--turn .nc-arch-beat-card__title { color: #dc2626; }
.nc-arch-beat-card--cliff .nc-arch-beat-card__title { color: #7c3aed; }

/* === ARC GROUP HEADER === */
.nc-arch-arc-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--nc-sp-2) var(--nc-sp-3);
  background: var(--nf-surface-2);
  border-radius: var(--nc-radius-sm);
  margin-bottom: var(--nc-sp-2);
}
.nc-arch-arc-group-header__title {
  font-size: var(--nc-text-md);
  font-weight: 700;
  color: var(--nf-ink);
}
.nc-arch-arc-group-header__sub {
  font-size: var(--nc-text-xs);
  color: var(--nf-muted);
  margin-left: var(--nc-sp-2);
}
.nc-arch-arc-group-header__count {
  font-size: var(--nc-text-xs);
  font-weight: 700;
}

/* === COMPASS BAR (Bàn Viết) === */
.nc-compass-beat-card {
  background: var(--nf-surface-2);
  border: 1px solid var(--nf-line);
  border-radius: var(--nc-radius-sm);
  padding: var(--nc-sp-2) var(--nc-sp-3);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--nc-sp-2);
}
.nc-compass-beat-card__title {
  font-size: var(--nc-text-xs);
  font-weight: 800;
}
.nc-compass-beat-card__text {
  font-size: var(--nc-text-xs);
  color: var(--nf-text);
  margin-top: 2px;
  line-height: 1.45;
}
.nc-compass-beat-btn {
  padding: var(--nc-sp-1) var(--nc-sp-2);
  font-size: var(--nc-text-xs);
  font-weight: 700;
  border-radius: var(--nc-radius-sm);
  border: 1px solid var(--nf-line-strong);
  background: var(--nf-surface);
  color: var(--nf-ink);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.nc-compass-beat-btn:hover {
  background: var(--nf-surface-2);
  transform: translateY(-1px);
}
.nc-compass-beat-btn:active {
  transform: translateY(0);
}

/* === BUTTON REFINEMENTS === */
.nc-tree-btn {
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.nc-tree-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.nc-tree-btn:active:not(:disabled) {
  transform: translateY(0);
}

/* === RESPONSIVE === */
@media (max-width: 1024px) {
  .nc-arch-synopsis-grid {
    grid-template-columns: 1fr;
  }
  .nc-arch-sub-grid {
    grid-template-columns: 1fr;
  }
  .nc-arch-arcs-bar {
    flex-wrap: wrap;
  }
  .nc-arch-arc-card {
    min-width: 140px;
  }
}

@media (max-width: 768px) {
  .nc-arch-synopsis-grid {
    grid-template-columns: 1fr;
    gap: var(--nc-sp-3);
  }
  .nc-arch-chap-row__header {
    flex-direction: column;
    align-items: flex-start;
  }
  .nc-arch-chap-row__left {
    min-width: auto;
    width: 100%;
    flex-wrap: wrap;
  }
  .nc-arch-chap-row__actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .nc-arch-arcs-bar {
    flex-direction: column;
  }
  .nc-arch-arc-card {
    min-width: auto;
  }
  .nc-arch-beats-grid {
    grid-template-columns: 1fr 1fr;
  }
  /* Compass Bar */
  #nc-chapter-compass .nc-compass-beat-card {
    min-width: auto;
  }
  /* Dropdown */
  .nc-project-dropdown-menu {
    min-width: auto !important;
    width: calc(100vw - 32px) !important;
    max-width: 440px;
  }
  /* B4: Ẩn font controls trên mobile */
  #nc-editor-only-cluster .nc-font-size-group {
    display: none;
  }
  /* B4: Ẩn text labels trong top bar buttons */
  .nc-btn-quick-reader span:last-child,
  .nc-btn-quick-new-novel span:last-child {
    display: none;
  }
  .nc-brand-text .nc-brand-sub {
    display: none;
  }
}

@media (max-width: 480px) {
  .nc-arch-beats-grid {
    grid-template-columns: 1fr;
  }
  .nc-arch-chap-title {
    min-width: 120px;
  }
}

/* === DARK MODE CONTRAST FIX === */
[data-theme="dark"] .nc-arch-label,
[data-theme="dark"] .nc-arch-goal-label,
[data-theme="dark"] .nc-arch-arc-card__rule,
[data-theme="dark"] .nc-arch-arc-group-header__sub {
  color: rgba(255,255,255,0.6);
}
[data-theme="dark"] .nc-arch-beat-card__text,
[data-theme="dark"] .nc-compass-beat-card__text {
  color: rgba(255,255,255,0.75);
}

/* === FOCUS VISIBLE (Accessibility) === */
.nc-tree-btn:focus-visible,
.nc-compass-beat-btn:focus-visible,
.nc-arch-chap-title:focus-visible,
.nc-arch-chap-goal:focus-visible,
.nc-arch-textarea:focus-visible {
  outline: 2px solid var(--nf-primary);
  outline-offset: 2px;
}
