/* style.css
   Pixel Lattice CMS — light-first editorial theme.
   Black / White / Accent (#E900B8). Plus Jakarta Sans.
*/

@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");

:root {
  --black: #000000;
  --white: #ffffff;
  --accent: #e900b8;

  --ink: #0a0a0a;
  --ink-soft: #4a4a4a;
  --ink-faint: #8a8a8a;

  --surface: #ffffff;
  --surface-off: #fafafa;
  --surface-raised: #ffffff;
  --border: #e8e8e8;
  --border-strong: #d8d8d8;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --transition: 150ms ease;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--surface-off);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }

a { color: inherit; text-decoration: none; }

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Focus states — accessibility */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- App Shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--white);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar__brand {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.topbar__brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: var(--space-5) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  color: var(--ink-soft);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.nav-item:hover {
  background: var(--surface-off);
  color: var(--ink);
}

.nav-item.is-active {
  background: var(--ink);
  color: var(--white);
}

.nav-item__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.main {
  flex: 1;
  min-width: 0;
  padding: var(--space-6);
}

.main--tight {
  max-width: 920px;
  margin: 0 auto;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), border-color var(--transition), opacity var(--transition);
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn--primary {
  background: var(--ink);
  color: var(--white);
}
.btn--primary:hover { background: #1a1a1a; }

.btn--accent {
  background: var(--accent);
  color: var(--white);
}
.btn--accent:hover { opacity: 0.92; }

.btn--secondary {
  background: var(--white);
  color: var(--ink);
  border-color: var(--border-strong);
}
.btn--secondary:hover { background: var(--surface-off); }

.btn--ghost {
  background: transparent;
  color: var(--ink-soft);
}
.btn--ghost:hover { background: var(--surface-off); color: var(--ink); }

.btn--danger {
  background: var(--white);
  color: #c22;
  border-color: #f0d0d0;
}
.btn--danger:hover { background: #fff5f5; }

.btn--sm { padding: 6px 12px; font-size: 12.5px; }

/* ---------- Inputs ---------- */

.field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }

.field__label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.input, .textarea, .select {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: var(--white);
  width: 100%;
  transition: border-color var(--transition);
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  outline: none;
}

.textarea { resize: vertical; min-height: 90px; font-family: inherit; }

/* ---------- Cards ---------- */

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.card--clickable { cursor: pointer; transition: box-shadow var(--transition), border-color var(--transition); }
.card--clickable:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge--draft { background: #f2f2f2; color: #666; }
.badge--published { background: #eafbf0; color: #16824a; }
.badge--archived { background: #fdeeee; color: #b83232; }

/* ---------- Page Header ---------- */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
  flex-wrap: wrap;
}

.page-header h1 { font-size: 22px; }
.page-header__subtitle { color: var(--ink-faint); margin-top: var(--space-1); font-size: 13px; }

/* ---------- Stat cards ---------- */

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.stat-card__value { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.stat-card__label { color: var(--ink-faint); font-size: 12.5px; margin-top: var(--space-1); font-weight: 500; }

/* ---------- Empty / Loading states ---------- */

.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-5);
  color: var(--ink-faint);
}
.empty-state h3 { color: var(--ink); margin-bottom: var(--space-2); font-size: 16px; }

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #f6f6f6 37%, #f0f0f0 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ---------- Toast ---------- */

.toast-stack {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 100;
}

.toast {
  background: var(--ink);
  color: var(--white);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  animation: toast-in 180ms ease;
}
.toast--error { background: #c22; }
.toast--success { background: #16824a; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Login ---------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-off);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-6);
  box-shadow: var(--shadow-md);
}

.login-card__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  justify-content: center;
  margin-bottom: var(--space-6);
  font-weight: 800;
  font-size: 16px;
}

.login-error {
  color: #c22;
  font-size: 12.5px;
  margin-top: -8px;
  margin-bottom: var(--space-4);
}

/* ---------- Utility ---------- */

.text-faint { color: var(--ink-faint); }
.text-soft { color: var(--ink-soft); }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.hidden { display: none !important; }

/* ---------- Article list rows ---------- */

.article-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
  cursor: pointer;
  flex-wrap: wrap;
}

.article-row__title {
  font-weight: 700;
  font-size: 15px;
  margin: 2px 0;
}

.article-row__actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ---------- Editor ---------- */

.editor-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-3);
  position: sticky;
  top: 60px;
  background: var(--surface-off);
  padding: var(--space-3) 0;
  z-index: 10;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--white);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 6px;
}

.editor-toolbar__btn {
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink-soft);
  transition: background var(--transition), color var(--transition);
}
.editor-toolbar__btn:hover { background: var(--surface-off); color: var(--ink); }

#f-content {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

#content-preview :is(h1, h2, h3, h4) { margin: 1em 0 0.4em; }
#content-preview p { margin: 0 0 1em; }
#content-preview ul, #content-preview ol { margin: 0 0 1em; padding-left: 1.4em; }
#content-preview blockquote { border-left: 3px solid var(--accent); padding-left: 1em; color: var(--ink-soft); margin: 0 0 1em; }
#content-preview pre { background: var(--surface-off); padding: 12px; border-radius: var(--radius-md); overflow-x: auto; }
#content-preview img { max-width: 100%; border-radius: var(--radius-md); }

/* ---------- Tag input ---------- */

.tag-input {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  background: var(--white);
}

.tag-input__tags { display: flex; flex-wrap: wrap; gap: 6px; }

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-off);
  border-radius: var(--radius-pill);
  padding: 4px 6px 4px 12px;
  font-size: 12.5px;
  font-weight: 600;
}
.tag-chip button {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--ink-faint);
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 50%;
}
.tag-chip button:hover { background: var(--border); color: var(--ink); }

.tag-input__field {
  border: none;
  outline: none;
  flex: 1;
  min-width: 120px;
  padding: 4px;
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: var(--space-4);
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

/* ---------- Image uploader & Media ---------- */

.image-uploader {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: var(--white);
}
.image-uploader:hover, .image-uploader--active {
  border-color: var(--accent);
  background: #fdf2fa;
}
.image-uploader__label { color: var(--ink-soft); font-size: 13.5px; }
.image-uploader__status { margin-top: var(--space-2); font-size: 12.5px; color: var(--ink-faint); }

.media-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: var(--radius-md);
  background: var(--surface-off);
}
.media-card__name {
  margin-top: 8px;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- AI assist ---------- */

.ai-assist-btn {
  color: var(--accent);
}
.ai-assist-btn:hover { background: #fdf2fa; }

/* ---------- Accessibility: skip link ---------- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--white);
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-md) 0;
  z-index: 300;
}
.skip-link:focus {
  left: 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .sidebar { width: 72px; padding: var(--space-4) var(--space-2); }
  .nav-item span.nav-item__label { display: none; }
  .main { padding: var(--space-4); }
}
