/*
 * St Bertha Of Kent Chat - Minimalist Folio-inspired Design
 * Main font: Grenze Gotisch (with Sutterlin switch)
 */

@font-face {
  font-family: 'Sutterlin';
  src: url('fonts/volk-redis.regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

:root {
  /* Folio Palette */
  --bg-color: #FBF9F6;
  --text-color: #2A2522;
  --text-muted: #9A968F;
  --border-color: #E0DCD5;
  --accent-color: #8b2621;
  --font-main: 'Hahmlet', Georgia, serif;
  --font-buttons: 'Grenze Gotisch', serif;
}

body {
  background: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8vh 40px 15vh;
  box-sizing: border-box;
  font-family: var(--font-main);
  min-height: 100vh;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

body.sutterlin-mode {
  --font-main: 'Sutterlin', 'Grenze Gotisch', Georgia, serif;
}

/* Log In Section in the Top Right */
.login-section {
  position: absolute;
  top: 25px;
  right: 40px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  z-index: 500;
}

.btn-login {
  background: none;
  border: none;
  font-family: var(--font-buttons);
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 10px;
  transition: color 0.2s;
}

.btn-login:hover {
  color: var(--text-color);
}

.login-form-container {
  display: none;
  flex-direction: row;
  gap: 8px;
  margin-top: 5px;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  box-sizing: border-box;
  align-items: center;
}

.login-input {
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-color);
  font-family: var(--font-main);
  font-size: 11px;
  color: var(--text-color);
  padding: 2px 4px;
  width: 90px;
  outline: none;
}

.login-input:focus {
  border-bottom-color: var(--text-color);
}

.login-form-container .btn {
  padding: 4px 8px;
  font-size: 9px;
}

/* Main Layout container */
.container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  flex: 1;
}

/* Header */
.chat-header {
  text-align: center;
  margin-top: 1vh;
  margin-bottom: 2vh;
}

.chat-header h1 {
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: normal;
  margin: 0;
  letter-spacing: 0.05em;
}

.presence-indicator {
  font-family: var(--font-main);
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 5px;
  letter-spacing: 0.02em;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  transition: opacity 0.3s;
  min-height: 14px;
}

.presence-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: #8b2621;
  display: inline-block;
  animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
  0% { transform: scale(0.85); opacity: 0.5; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.85); opacity: 0.5; }
}


/* Footer */
.chat-footer {
  text-align: center;
  margin-top: 8vh;
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.2em;
  user-select: none;
}

/* Board Wrapper containing columns and SVG line overlay */
.board-wrapper {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* SVG Line Overlay */
.lines-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.lines-overlay line {
  pointer-events: stroke;
  transition: stroke-width 0.15s ease, opacity 0.15s ease;
  cursor: pointer;
}

.lines-overlay line.same-stream {
  stroke: #8b2621;
  stroke-width: 1px;
  stroke-dasharray: 2.5, 3.5;
  opacity: 0.45;
}

.lines-overlay line.same-stream.bolded {
  stroke: #8b2621;
  stroke-width: 1.2px;
  stroke-dasharray: 2.5, 3.5;
  opacity: 0.75;
}

.lines-overlay line.cross-stream {
  stroke: #8b2621;
  stroke-width: 1px;
  stroke-dasharray: 2.5, 3.5;
  opacity: 0.45;
}

.lines-overlay line.cross-stream.bolded {
  stroke: #8b2621;
  stroke-width: 1.2px;
  stroke-dasharray: 2.5, 3.5;
  opacity: 0.75;
}

/* Columns Container */
.columns-container {
  display: flex;
  justify-content: center;
  gap: 50px;
  width: 100%;
  flex: 1;
  position: relative;
  z-index: 2;
}

/* Column Wrapper */
.column-wrapper {
  flex: 1;
  max-width: 38ch;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Word Count matching Folio */
.word-count {
  font-family: system-ui, sans-serif;
  font-size: 8px;
  color: var(--text-muted);
  opacity: 0.6;
  margin-bottom: 12px;
  user-select: none;
}

/* Past Posts Feed stream */
.posts-stream {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 15px;
  max-height: 48vh;
  padding-right: 5px;
  scroll-behavior: smooth;
}

/* Hide scrollbars in streams but keep scrollable */
.posts-stream::-webkit-scrollbar {
  width: 3px;
}
.posts-stream::-webkit-scrollbar-track {
  background: transparent;
}
.posts-stream::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

/* Individual Post Paragraph block */
.post-block {
  font-size: 12px;
  line-height: 1.6;
  word-wrap: break-word;
  padding: 4px 0;
  transition: opacity 0.2s;
  cursor: pointer;
  position: relative;
  white-space: pre-wrap; /* Preserve paragraph spacing in large posts */
}

.post-block.active-post-highlight {
  font-weight: normal;
  border-left: 2px solid var(--text-color);
  padding-left: 8px;
  margin-left: -10px;
}

.post-block sup {
  font-family: system-ui, sans-serif;
  font-size: 6px;
  color: var(--text-muted);
  margin-right: 6px;
  user-select: none;
}

.post-signature {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 8px;
  font-style: italic;
}

.post-actions {
  font-size: 8px;
  color: var(--text-muted);
  margin-left: 12px;
  user-select: none;
}

.btn-edit, .btn-delete {
  cursor: pointer;
  margin-right: 8px;
  text-decoration: underline;
  transition: color 0.15s;
}

.btn-edit:hover, .btn-delete:hover {
  color: var(--text-color);
}

/* Interactive Xanadu links inside post text */
.xanadu-link {
  color: var(--text-color);
  border-bottom: 1px dashed var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  padding: 0 1px;
  transition: font-weight 0.15s, border-bottom-color 0.15s;
}

.xanadu-link.same-stream-link {
  border-bottom: 1px solid var(--text-color);
}

.xanadu-link:hover, .xanadu-link.bolded {
  font-weight: bold;
  border-bottom-color: var(--text-color);
  background-color: rgba(154, 150, 143, 0.1);
}

/* Folio editor area (typing field) */
.editor {
  width: 100%;
  min-height: 100px;
  outline: none;
  font-size: 13px;
  line-height: 1.6;
  word-wrap: break-word;
  border-top: 1px dashed var(--border-color);
  padding-top: 15px;
  box-sizing: border-box;
}

.editor:empty::before {
  content: attr(placeholder);
  color: var(--text-muted);
  opacity: 0.5;
  pointer-events: none;
  display: block;
}

/* Actions toolbar below editor */
.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 25px;
}

/* Minimalist buttons matching Folio */
.btn-post, .btn-link-action, .btn {
  background: none;
  border: 1px solid var(--border-color);
  font-family: var(--font-buttons);
  font-size: 9px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 14px;
  transition: all 0.2s;
}

.btn-link-action {
  padding: 6px 8px;
}

.btn-post:hover, .btn-link-action:hover, .btn:hover {
  color: var(--text-color);
  border-color: var(--text-color);
}

/* Fixed Controls (bottom right) */
.controls {
  position: fixed;
  bottom: 30px;
  right: 30px;
  display: flex;
  gap: 10px;
  z-index: 100;
}

/* Banner for linking mode */
.linking-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: var(--text-color);
  color: var(--bg-color);
  padding: 10px 40px;
  z-index: 500;
  display: none;
  justify-content: center;
  align-items: center;
  font-family: var(--font-main);
  font-size: 11px;
}

.banner-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  width: 100%;
}

.banner-content .btn {
  border-color: rgba(251, 249, 246, 0.4);
  color: rgba(251, 249, 246, 0.7);
}
.banner-content .btn:hover {
  border-color: #ffffff;
  color: #ffffff;
}

/* Tufte-style Tooltip Popover */
.tufte-tooltip {
  position: fixed;
  background-color: var(--bg-color);
  border: 1px solid var(--text-color);
  padding: 12px 16px;
  max-width: 280px;
  z-index: 600;
  font-family: var(--font-main);
  line-height: 1.5;
  font-size: 11px;
  margin: 0;
  display: none;
  pointer-events: auto;
}

.tooltip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed var(--border-color);
  padding-bottom: 4px;
  margin-bottom: 8px;
}

.tooltip-post-id {
  font-size: 8px;
  font-family: system-ui, sans-serif;
  color: var(--text-muted);
}

.tooltip-close {
  background: none;
  border: none;
  font-size: 11px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}
.tooltip-close:hover {
  color: var(--text-color);
}

.tooltip-body {
  color: var(--text-color);
}

.tooltip-body p {
  margin: 0;
}

.tooltip-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
}

.tufte-tooltip.arrow-bottom .tooltip-arrow {
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0 6px;
  border-color: var(--text-color) transparent transparent transparent;
}

.tufte-tooltip.arrow-top .tooltip-arrow {
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 0 6px 6px 6px;
  border-color: transparent transparent var(--text-color) transparent;
}

/* Semi-hidden Sutterlin Toggle like on marktbowen.com */
#sutterlin-toggle {
  position: fixed;
  bottom: 8px;
  right: 8px;
  background: none;
  border: none;
  font-family: serif;
  font-size: 0.45rem;
  color: var(--text-muted);
  opacity: 0.25;
  cursor: pointer;
  padding: 4px;
  z-index: 1000;
  transition: opacity 0.2s;
}

#sutterlin-toggle:hover {
  opacity: 0.85;
}

/* Mobile Navigation Tabs */
.mobile-nav {
  display: none;
}

/* Responsive Collapse Rules */
@media (max-width: 768px) {
  body {
    padding: 2vh 0 4vh;
    overflow-x: hidden;
  }
  
  .main-container {
    padding: 0;
  }

  .chat-header {
    padding: 0 20px;
  }

  .mobile-nav {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
    border-top: 1px dashed var(--border-color);
    padding-top: 8px;
    user-select: none;
  }

  .nav-tab {
    background: none;
    border: none;
    font-family: var(--font-buttons);
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 8px;
    transition: color 0.2s, border-bottom 0.2s;
    border-bottom: 1px solid transparent;
  }

  .nav-tab.active {
    color: var(--text-color);
    border-bottom: 1px solid var(--text-color);
  }
  
  .columns-container {
    flex-direction: row !important;
    gap: 0 !important;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100vw;
  }

  .columns-container::-webkit-scrollbar {
    display: none;
  }
  
  .column-wrapper {
    min-width: 100vw;
    max-width: 100vw;
    box-sizing: border-box;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    padding: 0 24px;
  }

  .posts-stream {
    max-height: 52vh;
  }

  .btn-login {
    top: 15px;
    right: 20px;
    font-size: 10px;
  }
}

/* Word Node for granular linking */
.word-node {
  position: relative;
  display: inline;
}

body.linking-active .word-node {
  cursor: crosshair;
}

body.linking-active .word-node:hover {
  background-color: rgba(139, 38, 33, 0.12);
  text-decoration: underline;
}

/* Post Actions Tooltip */
.actions-tooltip {
  position: fixed;
  background-color: var(--bg-color);
  border: 1px solid var(--text-color);
  padding: 6px 12px;
  z-index: 700;
  font-family: var(--font-buttons);
  font-size: 11px;
  display: none;
  pointer-events: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.actions-tooltip .action-link {
  cursor: pointer;
  color: var(--text-color);
  transition: color 0.15s;
}

.actions-tooltip .action-link:hover {
  color: #8b2621;
  text-decoration: underline;
}

.actions-tooltip .action-divider {
  margin: 0 6px;
  color: var(--text-muted);
  user-select: none;
}

.post-num-trigger {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}

.post-num-trigger:hover {
  text-decoration: underline;
  color: #8b2621;
}
