/* ----------------------------------------------------
   SignalTree - Monospace Stylesheet
   ---------------------------------------------------- */

:root {
  --bg-color: #1e1e1e;
  --text-color: #d4d4d4;
  --folder-color: #e5c07b;
  --article-color: #98c379;
  --accent-color: #61afef;
  --dim-color: #5c6370;
  --border-color: #3e4452;
  --success-color: #98c379;
  --error-color: #e06c75;
  --outer-bg: #141414;
  --block-bg: rgba(255, 255, 255, 0.02);
  color-scheme: dark;
}

/* Light mode overrides */
html.light-mode-loading,
body.light-mode {
  --bg-color: #f6f6f6;
  --text-color: #24292e;
  --folder-color: #b57a13;
  --article-color: #22863a;
  --accent-color: #0366d6;
  --dim-color: #6a737d;
  --border-color: #d1d5da;
  --success-color: #22863a;
  --error-color: #d73a49;
  --outer-bg: #e5e5e5;
  --block-bg: rgba(0, 0, 0, 0.03);
  color-scheme: light;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--outer-bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border: 1px solid var(--bg-color);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--dim-color);
}

body {
  font-family: 'Courier New', Courier, Consolas, monospace;
  background-color: var(--outer-bg);
  color: var(--text-color);
  margin: 0;
  padding: 0;
  line-height: 1.6;
  font-size: 14px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.terminal-container {
  max-width: 960px;
  margin: 30px auto;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  padding: 20px;
  box-sizing: border-box;
}

/* Header & ASCII Art */
.terminal-header {
  margin-bottom: 20px;
}
.ascii-art {
  font-size: 7px;
  line-height: 1.2;
  color: var(--accent-color);
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.tagline {
  color: var(--dim-color);
  font-style: italic;
  margin-top: 8px;
}
.system-line {
  color: var(--border-color);
  user-select: none;
  font-weight: bold;
}

/* Status Bar */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  padding: 8px 0;
  font-size: 13px;
}
.status-item {
  margin: 4px 10px 4px 0;
}
.status-item .label {
  color: var(--dim-color);
}
.status-free {
  color: var(--error-color);
  font-weight: bold;
}
.status-premium {
  color: var(--success-color);
  font-weight: bold;
  text-shadow: 0 0 5px rgba(152, 195, 121, 0.4);
}

/* Buttons */
.cli-button {
  background: transparent;
  border: none;
  color: var(--accent-color);
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  padding: 2px 8px;
  transition: all 0.15s ease;
}
.cli-button:hover {
  background-color: var(--border-color);
  color: #fff;
}
.cli-button.success-btn {
  color: var(--success-color);
}
.cli-button.success-btn:hover {
  background-color: rgba(152, 195, 121, 0.15);
}
.cli-button.danger-btn {
  color: var(--error-color);
}
.cli-button.danger-btn:hover {
  background-color: rgba(224, 108, 117, 0.15);
}

/* Date controls */
.date-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 15px 0 25px 0;
  border: 1px dotted var(--border-color);
  padding: 10px;
}
.active-date-label {
  font-weight: bold;
  color: var(--text-color);
}

/* Loading state */
#status-message {
  text-align: center;
  padding: 30px;
  color: var(--dim-color);
  border: 1px dashed var(--border-color);
  margin: 20px 0;
}
.loading-pulse {
  animation: pulse 1.5s infinite ease-in-out;
}
@keyframes pulse {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}

/* ----------------------------------------------------
   Tree Hierarchical Style (inspired by X-plore)
   ---------------------------------------------------- */
.tree {
  margin: 10px 0;
  padding-left: 5px;
}

/* Details arrow removal */
.tree details > summary {
  list-style: none;
  outline: none;
}
.tree details > summary::-webkit-details-marker {
  display: none;
}

/* Tree Nodes */
.tree details {
  position: relative;
  padding-left: 20px;
  margin: 4px 0;
}

/* Vertical dotted guides */
.tree details > .category-content,
.tree details > .article-body {
  margin-left: -8px; /* Alignment shift */
  padding-left: 24px;
  border-left: 1px dotted var(--border-color);
  padding-top: 4px;
  padding-bottom: 8px;
}

/* Last child: hide vertical line overflow */
.tree details:last-child > .category-content,
.tree details:last-child > .article-body {
  border-left: none;
}

/* Horizontal branch dotted lines */
.tree details::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 12px; /* Aligns with middle of folder/article summary text */
  width: 20px;
  border-top: 1px dotted var(--border-color);
}

/* Root folder adjustment */
.tree > details {
  padding-left: 0;
}
.tree > details::before {
  display: none;
}

/* Folders / Categories style */
.category-node > summary {
  color: var(--folder-color);
  font-weight: bold;
  cursor: pointer;
  padding: 3px 6px;
  user-select: none;
}
.category-node > summary:hover {
  background-color: rgba(229, 192, 123, 0.08);
}
.category-node[open] > summary::before {
  content: "[-] 📁 ";
}
.category-node:not([open]) > summary::before {
  content: "[+] 📁 ";
}

/* Articles style */
.article-node > summary {
  color: var(--article-color);
  cursor: pointer;
  padding: 3px 6px;
  user-select: none;
}
.article-node > summary:hover {
  background-color: rgba(152, 195, 121, 0.08);
}
.article-node[open] > summary::before {
  content: "[-] 📄 ";
}
.article-node:not([open]) > summary::before {
  content: "[+] 📄 ";
}

/* Content description body */
.article-body {
  color: var(--text-color);
}
.summary-box {
  padding: 10px;
  background-color: var(--block-bg);
  border-left: 3px solid var(--accent-color);
  margin-bottom: 12px;
}
.summary-title {
  color: var(--accent-color);
  font-weight: bold;
  margin-bottom: 4px;
  font-size: 11px;
}
.summary-text {
  margin: 0;
  font-size: 13.5px;
}

/* Premium paywalled content */
.premium-title {
  color: var(--folder-color);
  font-weight: bold;
  font-size: 11px;
  margin-bottom: 6px;
}
.premium-unlocked {
  padding: 12px;
  background-color: rgba(152, 195, 121, 0.03);
  border: 1px dotted var(--success-color);
  margin-top: 10px;
}
.premium-unlocked p {
  margin: 0 0 10px 0;
}
.premium-unlocked p:last-child {
  margin-bottom: 0;
}

/* Paywall banner & fade effect */
.premium-paywall {
  border: 1px dashed var(--error-color);
  padding: 15px;
  background-color: rgba(224, 108, 117, 0.02);
  margin-top: 10px;
}

.paywalled-content-fade {
  /* Using CSS Masking with vendor prefix for maximum compatibility */
  -webkit-mask-image: linear-gradient(to bottom, black 20%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 20%, transparent 100%);
  height: 60px;
  overflow: hidden;
  margin-bottom: 15px;
  color: var(--dim-color);
  user-select: none;
}

.paywall-cta {
  text-align: center;
}
.paywall-message {
  color: var(--error-color);
  font-weight: bold;
  margin-bottom: 8px;
  font-size: 12px;
}

/* Footer info */
.terminal-footer {
  margin-top: 30px;
  font-size: 12px;
  color: var(--dim-color);
}
.footer-links {
  display: flex;
  justify-content: space-between;
  padding: 10px 0 0 0;
}
.footer-links a {
  color: var(--accent-color);
  text-decoration: none;
}
.footer-links a:hover {
  text-decoration: underline;
}

/* ----------------------------------------------------
   Modal Styles
   ---------------------------------------------------- */
.modal {
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.8);
  display: flex;
  justify-content: center;
  align-items: center;
}
.modal-content {
  background-color: var(--bg-color);
  border: 2px solid var(--border-color);
  max-width: 500px;
  width: 90%;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
}
.modal-header {
  border-bottom: 1px dotted var(--border-color);
  padding-bottom: 10px;
  margin-bottom: 15px;
}
.modal-header h3 {
  margin: 0;
  color: var(--folder-color);
  font-size: 14px;
}
.modal-body {
  margin-bottom: 20px;
}
.modal-body p {
  margin: 8px 0;
}
.code-highlight {
  color: var(--accent-color);
  font-weight: bold;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 15px;
}

@media(max-width: 600px) {
  .ascii-art {
    font-size: 4px;
  }
  .status-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .status-item {
    margin-right: 0;
  }
}
