/* Spark Journal — Dark Theme, RTL-first */

:root {
  --bg: #0b0b1a;
  --surface: #111126;
  --surface2: #171735;
  --border: rgba(255,255,255,.07);
  --border-hover: rgba(255,255,255,.15);
  --text: rgba(255,255,255,.88);
  --dim: rgba(255,255,255,.5);
  --faint: rgba(255,255,255,.25);
  --primary: #06b6d4;
  --purple: #8b5cf6;
  --red: #ef4444;
  --green: #22c55e;
  --amber: #f59e0b;
  --violet: #a855f7;
  --radius: 10px;
  --font: 'Heebo', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--primary);
  color-scheme: dark;
}
[dir="ltr"] { --font: 'Inter', 'Heebo', system-ui, sans-serif; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.6 var(--font);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
ul, ol { list-style: none; }

/* ── Skip link ── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #000;
  padding: 8px 20px;
  border-radius: 0 0 8px 8px;
  font-weight: 700;
  font-size: 13px;
  z-index: 999;
  transition: top .2s;
}
.skip-link:focus { top: 0; }

/* ── Screen reader only ── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Focus visible ── */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius);
}
a:focus-visible { border-radius: 4px; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }

/* ── HEADER ── */
.header {
  position: sticky; top: 0; z-index: 100;
  height: 56px;
  background: rgba(11,11,26,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none;
  font-weight: 700; font-size: 16px;
}
.logo svg { flex-shrink: 0; }
[dir="rtl"] .logo-en,
[dir="ltr"] .logo-he { display: none; }

.header-actions { display: flex; align-items: center; gap: 12px; }
.count {
  font-size: 11px; font-weight: 600;
  background: var(--surface2);
  color: var(--dim);
  padding: 2px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.lang-btn {
  font-size: 12px; font-weight: 700;
  padding: 5px 14px;
  border-radius: 99px;
  border: 1px solid var(--primary);
  color: var(--primary);
  transition: background .2s, color .2s;
}
.lang-btn:hover { background: var(--primary); color: #000; }

/* ── LAYOUT ── */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 56px);
}

/* ── SIDEBAR ── */
.sidebar {
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  padding: 20px 16px;
  position: sticky; top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 20px;
}
.search-input {
  width: 100%;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font: 13px var(--font);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.search-input::placeholder { color: var(--dim); }
.search-input:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(6,182,212,.2);
}

/* Category nav */
.cat-nav { display: flex; flex-direction: column; gap: 2px; }
.cat-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 7px 10px;
  border-radius: 7px; font-size: 13px;
  color: var(--dim);
  transition: background .15s, color .15s;
}
.cat-btn:hover { background: rgba(255,255,255,.05); color: var(--text); }
.cat-btn.active { background: rgba(6,182,212,.12); color: var(--primary); font-weight: 600; }
.cat-count {
  font-size: 11px; padding: 0 6px;
  background: rgba(255,255,255,.05);
  border-radius: 99px;
  font-variant-numeric: tabular-nums;
}
.cat-btn.active .cat-count { background: rgba(6,182,212,.15); color: var(--primary); }
.cat-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; margin-inline-end: 8px; flex-shrink: 0;
}

/* Tag cloud */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11px; padding: 3px 10px;
  border-radius: 99px;
  background: rgba(255,255,255,.05);
  color: var(--dim);
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
  cursor: pointer;
}
.tag:hover { background: rgba(6,182,212,.1); color: var(--primary); border-color: rgba(6,182,212,.2); }
.tag.active { background: rgba(6,182,212,.15); color: var(--primary); border-color: var(--primary); }

/* ── MAIN ── */
.main { padding: 24px; min-width: 0; }

/* Filters bar */
.filters {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 10px 14px; margin-bottom: 16px;
  background: var(--surface); border-radius: 8px;
  font-size: 12px; color: var(--dim);
}
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(6,182,212,.1); color: var(--primary);
  padding: 3px 10px; border-radius: 99px;
  font-size: 12px;
}
.filter-x {
  font-size: 14px; line-height: 1; opacity: .6;
  cursor: pointer; padding: 0 2px;
}
.filter-x:hover { opacity: 1; }

/* Cards grid */
.cards { display: flex; flex-direction: column; gap: 10px; }

/* ── ENTRY CARD ── */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  cursor: pointer;
  transition: border-color .2s, transform .15s, box-shadow .2s;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  inset-block: 0; inset-inline-start: 0;
  width: 3px;
  background: var(--stripe, var(--primary));
  transition: width .2s;
}
.card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.card:hover::before { width: 4px; }
.card:focus-visible {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}
.card:focus-visible::before { width: 4px; }

.card-top {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px; flex-wrap: wrap;
  min-width: 0;
}
.card-title {
  font-size: 15px; font-weight: 600; color: var(--text);
  margin-bottom: 4px; line-height: 1.4;
  text-wrap: balance;
}
.card-summary {
  font-size: 13px; color: var(--dim); line-height: 1.65;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 10px;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.card-tag {
  font-size: 10px; padding: 2px 8px;
  border-radius: 99px;
  background: rgba(255,255,255,.04);
  color: var(--faint);
  transition: color .15s, background .15s;
  cursor: pointer;
}
.card-tag:hover { background: rgba(6,182,212,.1); color: var(--primary); }
.card:hover .card-tag { color: var(--dim); }
.card-date {
  font-size: 11px; color: var(--faint); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.card-arrow {
  margin-inline-start: auto;
  color: var(--faint);
  transition: color .2s, transform .2s;
  flex-shrink: 0;
}
.card:hover .card-arrow { color: var(--primary); }
[dir="rtl"] .card-arrow { transform: scaleX(-1); }

/* Category stripe colors */
.card[data-cat="system"]      { --stripe: #06b6d4; }
.card[data-cat="monitoring"]  { --stripe: #8b5cf6; }
.card[data-cat="security"]    { --stripe: #ef4444; }
.card[data-cat="deployment"]  { --stripe: #22c55e; }
.card[data-cat="performance"] { --stripe: #f59e0b; }
.card[data-cat="features"]    { --stripe: #a855f7; }
.card[data-cat="research"]    { --stripe: #ec4899; }
.card[data-cat="future-plans"]{ --stripe: #14b8a6; }
.card[data-cat="projects"]    { --stripe: #f97316; }

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 2px 9px; border-radius: 99px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
  white-space: nowrap;
}
.badge-critical { background: rgba(239,68,68,.12); color: #f87171; }
.badge-warning  { background: rgba(245,158,11,.12); color: #fbbf24; }
.badge-info     { background: rgba(6,182,212,.12); color: #22d3ee; }
.badge-success  { background: rgba(34,197,94,.12); color: #4ade80; }

/* Category label */
.cat-label { font-size: 11px; color: var(--dim); }

/* ── EMPTY STATE ── */
.empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 80px 20px; text-align: center;
  color: var(--faint);
}
.empty-title { font-size: 16px; margin-top: 16px; color: var(--dim); }
.empty-sub { font-size: 13px; margin-top: 4px; }

/* ── DRAWER ── */
.drawer[hidden] { display: none; }
.drawer {
  position: fixed; inset: 0; z-index: 200;
  display: flex;
  justify-content: flex-end;
}
[dir="rtl"] .drawer { justify-content: flex-start; }

.drawer-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.drawer-panel {
  position: relative; z-index: 1;
  width: min(640px, 100vw);
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  overflow-y: auto; padding: 28px;
  overscroll-behavior: contain;
  animation: slideIn .25s cubic-bezier(.22,1,.36,1) both;
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
[dir="rtl"] .drawer-panel {
  animation-name: slideInRTL;
}
@keyframes slideInRTL {
  from { transform: translateX(-100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.drawer-close {
  position: absolute; top: 16px; inset-inline-end: 16px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
  color: var(--dim); font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  transition: background .2s, color .2s, border-color .2s;
}
.drawer-close:hover { background: rgba(6,182,212,.15); color: var(--primary); border-color: var(--primary); }

/* Drawer head */
.drawer-head {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.drawer-title {
  font-size: 20px; font-weight: 700;
  color: var(--text); line-height: 1.3;
  margin-bottom: 10px;
  padding-inline-end: 44px;
  text-wrap: balance;
}
.drawer-meta {
  display: flex; align-items: center;
  flex-wrap: wrap; gap: 8px;
}
.drawer-tags {
  display: flex; flex-wrap: wrap; gap: 5px;
  margin-top: 10px;
}

/* ── DRAWER BODY — Rich HTML ── */
.drawer-body { font-size: 14px; line-height: 1.75; }
.drawer-body h3 {
  color: var(--primary); font-size: 15px; font-weight: 700;
  margin: 24px 0 8px; letter-spacing: .01em;
}
.drawer-body h4 {
  font-size: 14px; font-weight: 600; color: var(--text);
  margin: 16px 0 6px;
}
.drawer-body p { color: var(--dim); margin-bottom: 10px; }
.drawer-body p:last-child { margin-bottom: 0; }
.drawer-body table {
  width: 100%; border-collapse: collapse;
  font-size: 13px; margin: 12px 0;
  border-radius: 8px; overflow: hidden;
}
.drawer-body th {
  background: rgba(255,255,255,.05);
  padding: 8px 12px; font-weight: 700; font-size: 12px;
  text-align: start; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.drawer-body td {
  padding: 7px 12px; color: var(--dim);
  border-bottom: 1px solid rgba(255,255,255,.03);
  font-variant-numeric: tabular-nums;
}
.drawer-body tr:last-child td { border-bottom: none; }
.drawer-body tr:hover td { background: rgba(255,255,255,.02); color: var(--text); }
.drawer-body code {
  background: rgba(6,182,212,.08); color: var(--primary);
  font: 12px var(--mono);
  padding: 1px 5px; border-radius: 4px;
}
.drawer-body pre {
  background: #080814; border: 1px solid var(--border);
  border-radius: 8px; padding: 14px;
  font: 12px/1.6 var(--mono);
  overflow-x: auto; margin: 12px 0;
  color: rgba(255,255,255,.7);
}
.drawer-body pre code {
  background: none; padding: 0; color: inherit; font-size: inherit;
}
.drawer-body ul, .drawer-body ol {
  padding-inline-start: 20px; margin: 8px 0;
  display: flex; flex-direction: column; gap: 3px;
}
.drawer-body ul { list-style: disc; }
.drawer-body ol { list-style: decimal; }
.drawer-body li { color: var(--dim); font-size: 13px; line-height: 1.6; }
.drawer-body li::marker { color: var(--primary); }
.drawer-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* Alert boxes */
.drawer-body .alert-red,
.drawer-body .alert-green,
.drawer-body .alert-blue,
.drawer-body .alert-orange,
.drawer-body .meta-bar {
  padding: 12px 16px; border-radius: 8px; margin: 12px 0;
  font-size: 13px; line-height: 1.6;
  border-inline-start: 3px solid;
}
.drawer-body .alert-red    { background: rgba(239,68,68,.06); border-color: #ef4444; color: #fca5a5; }
.drawer-body .alert-green  { background: rgba(34,197,94,.06); border-color: #22c55e; color: #86efac; }
.drawer-body .alert-blue   { background: rgba(6,182,212,.06); border-color: #06b6d4; color: #67e8f9; }
.drawer-body .alert-orange { background: rgba(245,158,11,.06); border-color: #f59e0b; color: #fcd34d; }
.drawer-body .meta-bar     { background: rgba(139,92,246,.06); border-color: #8b5cf6; color: #c4b5fd; }

/* Executive summary */
.drawer-body .exec-summary {
  background: rgba(6,182,212,.05);
  border: 1px solid rgba(6,182,212,.15);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 16px;
}
.drawer-body .exec-summary h3 {
  color: var(--primary);
  font-size: 14px;
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.drawer-body .exec-summary p {
  color: var(--text);
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 0;
}
.drawer-body .section-divider {
  border: none;
  border-top: 1px dashed var(--border);
  margin: 20px 0;
}
.drawer-body .email-content {
  font-size: 13px;
  line-height: 1.7;
  color: var(--dim);
}

/* Embedded email content — strip inline styles that conflict */
.drawer-body .email-content h1,
.drawer-body .email-content h2 {
  color: var(--primary);
  font-size: 16px;
  font-weight: 700;
  margin: 20px 0 8px;
  border: none;
  background: none;
  padding: 0;
}
.drawer-body .email-content h3 {
  color: var(--text);
}
.drawer-body .email-content p {
  color: var(--dim);
}

/* Related entries */
.drawer-related { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.drawer-related h3 { margin-top: 0; }
.related-link { display: block; padding: 6px 0; font-size: 13px; }
.related-link:hover { color: var(--primary); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 56px; z-index: 50;
    height: auto; border-inline-end: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    flex-direction: row; flex-wrap: wrap;
    align-items: center; gap: 8px;
    overflow-x: auto;
  }
  .search-input { width: 140px; min-width: 100px; flex-shrink: 0; }
  .cat-nav {
    display: flex; flex-direction: row; gap: 4px;
    flex-wrap: nowrap; overflow-x: auto;
  }
  .cat-btn { width: auto; white-space: nowrap; padding: 5px 10px; }
  .tag-cloud { flex-wrap: nowrap; overflow-x: auto; }
  .main { padding: 16px; }
  .card { padding: 14px 16px; }
  .drawer-panel { width: 100vw; padding: 20px 16px; }
  .drawer-title { font-size: 18px; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Body no-scroll when drawer open */
body.drawer-open { overflow: hidden; }
