/* ============================================================
   MARKFORGE — style.css
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0a0a0c;
  --bg2:        #111115;
  --bg3:        #18181e;
  --border:     #2a2a35;
  --accent:     #ff5c3a;
  --accent2:    #ffb800;
  --accent3:    #00e5a0;
  --text:       #e8e8ee;
  --text-muted: #7a7a8c;
  --text-dim:   #4a4a5a;
  --mono:       'Space Mono', monospace;
  --sans:       'Syne', sans-serif;
  --radius:     6px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ── HEADER ── */
.header {
  position: relative;
  padding: 2.5rem 2rem 2rem;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.header-inner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--sans);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.logo-mark {
  color: var(--accent);
  font-size: 1.8rem;
  display: inline-block;
  animation: spin-hex 8s linear infinite;
}
@keyframes spin-hex { to { transform: rotate(360deg); } }
.logo strong { color: var(--accent); }
.tagline {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-left: 2px solid var(--border);
  padding-left: 1.2rem;
}
.header-grid-lines {
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(90deg, var(--border) 0, var(--border) 1px, transparent 1px, transparent 60px),
    repeating-linear-gradient(0deg,  var(--border) 0, var(--border) 1px, transparent 1px, transparent 60px);
  opacity: 0.25;
  pointer-events: none;
  mask-image: linear-gradient(to bottom, transparent, rgba(0,0,0,0.5) 50%, transparent);
}

/* ── MAIN ── */
.main {
  flex: 1;
  padding: 2.5rem 2rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ── GRID ── */
.grid-container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 0;
}

/* ── PANELS ── */
.panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: relative;
}
.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.panel--input::before  { background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.panel--output::before { background: linear-gradient(90deg, var(--accent3), #00a3ff); }

/* ── PANEL HEADER ── */
.panel-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.panel-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--accent);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: rgba(255,92,58,0.1);
  border: 1px solid rgba(255,92,58,0.3);
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  white-space: nowrap;
}
.panel--output .panel-label {
  color: var(--accent3);
  background: rgba(0,229,160,0.08);
  border-color: rgba(0,229,160,0.3);
}
.panel-title {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
}
.word-counter-wrapper { display: flex; gap: 0.5rem; margin-left: auto; }
.word-badge, .char-badge {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
}
.output-stats {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--accent3);
  margin-left: auto;
}

/* ── INPUT TEXTAREA ── */
.textarea-wrapper { position: relative; }
textarea#inputText {
  width: 100%;
  min-height: 280px;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 2.2rem 1.1rem 1.1rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.8;
  resize: vertical;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}
textarea#inputText:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,92,58,0.12);
}
textarea#inputText::placeholder { color: var(--text-dim); font-style: italic; }

.clear-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 26px; height: 26px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.65rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.clear-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ── OUTPUT PLACEHOLDER ── */
.output-placeholder {
  min-height: 280px;
  background: var(--bg3);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 2rem;
}
.placeholder-icon { font-size: 2.5rem; opacity: 0.25; }

/* ── OUTPUT DISPLAY ── */
.output-display {
  min-height: 280px;
  max-height: 620px;
  overflow-y: auto;
  background: var(--bg3);
  border: 1px solid var(--accent3);
  border-radius: var(--radius);
  padding: 1.3rem 1.4rem;
  box-shadow: 0 0 0 3px rgba(0,229,160,0.08);
}

/* Frontmatter block */
.fm-block {
  border-left: 3px solid var(--accent);
  padding: 0.6rem 0.9rem;
  margin-bottom: 1.6rem;
  background: rgba(255,92,58,0.04);
  border-radius: 0 4px 4px 0;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 2;
}
.fm-dashes { color: var(--accent); font-weight: 700; display: block; }
.fm-row    { display: block; }
.fm-key    { color: var(--accent2); }
.fm-colon  { color: var(--text-dim); }
.fm-val    { color: var(--text); }
.fm-tag-item { display: block; padding-left: 1.2rem; }
.fm-tag-bullet { color: var(--text-dim); }
.fm-tag-val    { color: var(--accent3); }

/* Content body */
.content-body { font-family: var(--mono); font-size: 0.8rem; line-height: 1.85; }

.content-para {
  display: block;
  color: var(--text);
  margin-bottom: 1.2rem;
  padding-bottom: 0;
}
.content-para:last-child { margin-bottom: 0; }

.content-heading {
  display: block;
  color: var(--accent2);
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  margin: 1.6rem 0 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid rgba(255,184,0,0.2);
}

/* ── OPTIONS ROW ── */
.options-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.option-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
}
.option-item input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; }
.inline-input {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  outline: none;
  width: 120px;
  transition: border-color 0.2s;
}
.inline-input:focus { border-color: var(--accent); }

/* ── MANUAL OVERRIDES ── */
.manual-overrides {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  background: rgba(255,184,0,0.03);
  border: 1px solid rgba(255,184,0,0.15);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.override-field { display: flex; flex-direction: column; gap: 0.4rem; }
.override-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.override-hint {
  font-size: 0.6rem;
  color: var(--text-dim);
  text-transform: none;
  letter-spacing: 0;
  font-style: italic;
  margin-left: auto;
}
.override-input-wrap { position: relative; }
.override-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.2s;
}
.override-input:focus { border-color: var(--accent2); box-shadow: 0 0 0 2px rgba(255,184,0,0.1); }
.override-textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border-radius: 4px;
  outline: none;
  resize: vertical;
  min-height: 58px;
  line-height: 1.6;
  transition: border-color 0.2s;
}
.override-textarea:focus { border-color: var(--accent2); box-shadow: 0 0 0 2px rgba(255,184,0,0.1); }
.override-clear {
  position: absolute;
  top: 50%; right: 0.5rem;
  transform: translateY(-50%);
  background: none; border: none;
  color: var(--text-dim);
  cursor: pointer; font-size: 0.65rem;
  transition: color 0.2s;
}
.desc-clear { top: 0.6rem; transform: none; }
.override-clear:hover { color: var(--accent); }
.desc-counter {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--text-dim);
  text-align: right;
}
.desc-counter.warn { color: var(--accent2); }
.desc-counter.over { color: var(--accent); }

/* ── CATEGORY SECTION ── */
.category-section { display: flex; flex-direction: column; gap: 0.7rem; }
.category-label-row { display: flex; align-items: center; justify-content: space-between; }
.section-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.auto-badge {
  background: rgba(255,184,0,0.15);
  color: var(--accent2);
  border: 1px solid rgba(255,184,0,0.3);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
}
.category-grid { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.cat-btn {
  font-family: var(--mono);
  font-size: 0.68rem;
  background: var(--bg3);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}
.cat-btn:hover { color: var(--text); border-color: #3a3a4a; background: #1e1e26; }
.cat-btn.active { color: var(--accent2); border-color: rgba(255,184,0,0.5); background: rgba(255,184,0,0.08); }

/* ── TAGS PREVIEW ── */
.tags-preview-section { display: flex; flex-direction: column; gap: 0.6rem; }
.tag-count-badge {
  color: var(--accent3);
  font-size: 0.6rem;
  background: rgba(0,229,160,0.08);
  border: 1px solid rgba(0,229,160,0.2);
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
}
.tags-preview { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag-chip {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--accent3);
  background: rgba(0,229,160,0.06);
  border: 1px solid rgba(0,229,160,0.2);
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  white-space: nowrap;
}

/* ── BUTTONS ── */
.btn {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.85rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.22s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  letter-spacing: 0.03em;
  position: relative;
  overflow: hidden;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
.btn:active:not(:disabled) { transform: scale(0.97); }

.btn--generate {
  width: 100%;
  padding: 0.85rem 1.5rem;
  background: linear-gradient(135deg, var(--accent), #e03000);
  color: #fff;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 4px 24px rgba(255,92,58,0.3);
}
.btn--generate:hover:not(:disabled) { box-shadow: 0 6px 32px rgba(255,92,58,0.5); transform: translateY(-1px); }

.btn-icon { display: inline-block; transition: transform 0.4s; }
.btn--generate:hover .btn-icon { transform: rotate(180deg); }
.btn-loader {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn--generate.loading .btn-text,
.btn--generate.loading .btn-icon { display: none; }
.btn--generate.loading .btn-loader { display: block; }

.action-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.btn--copy {
  flex: 1; padding: 0.7rem 1rem;
  background: var(--bg3); color: var(--accent3);
  border: 1px solid rgba(0,229,160,0.3);
}
.btn--copy:hover:not(:disabled) { background: rgba(0,229,160,0.1); border-color: var(--accent3); }
.btn--download {
  flex: 1; padding: 0.7rem 1rem;
  background: var(--bg3); color: var(--accent2);
  border: 1px solid rgba(255,184,0,0.3);
}
.btn--download:hover:not(:disabled) { background: rgba(255,184,0,0.1); border-color: var(--accent2); }
.btn--regenerate {
  padding: 0.7rem 0.9rem;
  background: var(--bg3); color: var(--text-muted);
  border: 1px solid var(--border); font-size: 0.8rem;
}
.btn--regenerate:hover:not(:disabled) { color: var(--text); border-color: #4a4a5a; }

/* ── DIVIDER ── */
.divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 1.2rem;
  gap: 0.4rem;
}
.divider-line { width: 1px; flex: 1; background: linear-gradient(to bottom, transparent, var(--border), transparent); }
.divider-icon { font-size: 1.1rem; color: var(--accent); opacity: 0.6; padding: 0.5rem 0; font-weight: bold; }

/* ── STATS BAR ── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  margin-top: 1.5rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s, transform 0.4s;
}
.stats-bar.visible { opacity: 1; transform: none; }
.stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  border-right: 1px solid var(--border);
  padding-right: 1rem;
}
.stat-item:last-child { border-right: none; padding-right: 0; }
.stat-key { font-family: var(--mono); font-size: 0.6rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.12em; }
.stat-val { font-family: var(--mono); font-size: 0.78rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#statCategoryVal { color: var(--accent); }
#statReadTimeVal  { color: var(--accent2); }
#statViewsVal     { color: var(--accent3); }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 2rem; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.7rem 1.4rem;
  border-radius: 40px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--accent3); color: var(--accent3); }
.toast.error   { border-color: var(--accent);  color: var(--accent); }
.toast.info    { border-color: var(--accent2);  color: var(--accent2); }

/* ── LOADING ── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(10,10,12,0.85);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}
.loading-overlay.visible { opacity: 1; visibility: visible; }
.loading-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem 3rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}
.loading-spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-right-color: var(--accent2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-text { font-family: var(--mono); font-size: 0.8rem; color: var(--text-muted); letter-spacing: 0.08em; min-width: 200px; }

/* ── FOOTER ── */
.footer {
  padding: 1.2rem 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.07em;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #5a5a6a; }
::selection { background: rgba(255,92,58,0.25); }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .grid-container { grid-template-columns: 1fr; }
  .divider { flex-direction: row; padding: 0.8rem 0; }
  .divider-line { width: auto; flex: 1; height: 1px; background: linear-gradient(to right, transparent, var(--border), transparent); }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .stat-item:nth-child(2), .stat-item:nth-child(4), .stat-item:nth-child(5) { border-right: none; }
  .action-row { flex-direction: column; }
  .btn--copy, .btn--download { flex: none; width: 100%; }
  .tagline { display: none; }
}
@media (max-width: 480px) {
  .main { padding: 1.5rem 1rem; }
  .header { padding: 1.5rem 1rem 1rem; }
  .panel { padding: 1.2rem; }
  .stats-bar { grid-template-columns: 1fr; display: flex; flex-direction: column; }
  .stat-item { border-right: none; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
  .stat-item:last-child { border-bottom: none; }
}
