/* Post Layout Styles - Translation Viewer and Related Components */

/* Translation Viewer Styles */
#translation-viewer {
  margin: 30px 0;
  font-family: inherit;
}

/* Readable margins for content */
.readable-margins {
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 20px;
}

@media (max-width: 840px) {
  .readable-margins {
    padding: 0 20px;
  }
}

.post-header {
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}


.youtube-promo {
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

/* Tab buttons */
.translation-tabs {
  display: flex;
  margin-bottom: 1px;
  border-bottom: 2px solid var(--highlight-color);
  max-width: var(--content-width);
  margin-left: auto;
  margin-right: auto;
}

.tab-btn {
  padding: 10px 24px;
  margin-right: 4px;
  background-color: var(--bg-color);
  border: 1px solid var(--highlight-color);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  color: var(--text-color);
  cursor: pointer;
  font-weight: normal;
  font-size: 1rem;
  transition: background-color 0.2s;
}

.tab-btn:hover {
  background-color: #e3d6c0;
}

.tab-btn.active {
  background-color: var(--highlight-color);
  color: var(--white);
  font-weight: bold;
}

/* Special styling for analysis tab */
.analysis-tab {
  background-color: var(--text-color);
  color: var(--bg-color);
  font-size: 1.05rem;
}

.analysis-tab:hover {
  background-color: #4d372a;
}

.analysis-tab.active {
  background-color: var(--text-color);
  color: var(--bg-color);
}

/* Translation tab styling */
.translation-tab {
  background-color: var(--sienna);
  color: var(--bg-color);
}

.translation-tab:hover {
  background-color: var(--sienna-light);
}

.translation-tab.active {
  background-color: var(--sienna);
  color: var(--white);
}

/* Resource Info / Metadata tab styling */
.metadata-tab {
  background-color: var(--sienna);
  color: var(--bg-color);
}

.metadata-tab:hover {
  background-color: var(--sienna-light);
}

.metadata-tab.active {
  background-color: var(--sienna);
  color: var(--white);
}

/* Translation Toolbar */
.translation-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  background-color: var(--bg-color-light);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 10px;
}

/* View Toggle within Translation tab */
.translation-view-toggle {
  display: flex;
  gap: 8px;
}

/* Translation Actions (Copy/Download) */
.translation-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--medium-gray);
  border-radius: 4px;
  background-color: var(--white);
  color: var(--text-color);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background-color 0.2s, border-color 0.2s;
}

.action-btn:hover {
  background-color: var(--bg-color);
  border-color: var(--highlight-color);
}

.action-btn svg {
  flex-shrink: 0;
}

.action-btn.copied {
  background-color: #d4edda;
  border-color: #28a745;
  color: #155724;
}

.view-toggle-btn {
  padding: 8px 20px;
  border: 1px solid var(--highlight-color);
  border-radius: 20px;
  background-color: var(--white);
  color: var(--text-color);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.view-toggle-btn:hover {
  background-color: #f0e8d8;
}

.view-toggle-btn.active {
  background-color: var(--highlight-color);
  color: var(--white);
  font-weight: bold;
}

/* Translation view containers */
.translation-view {
  display: none;
}

.translation-view.active {
  display: block;
}

/* Mobile notice for Both view */
.mobile-both-notice {
  display: none;
  padding: 15px;
  background-color: var(--latin-bg);
  border: 1px solid var(--highlight-color);
  border-radius: 6px;
  margin: 15px;
  text-align: center;
}

.mobile-both-notice p {
  margin: 0;
  color: var(--latin-color);
  font-size: 0.9rem;
}

/* Tab content container */
.tab-content {
  border: 1px solid var(--highlight-color);
  border-top: none;
  background-color: var(--white);
  max-width: var(--content-width);
  margin-left: auto;
  margin-right: auto;
}

/* Tab panels */
.tab-panel {
  display: none;
  padding: 15px;
}

.tab-panel.active {
  display: block;
}

/* Analysis panel without border or background */
#analysis {
  padding: 0;
  border: none;
  margin: 0;
  background-color: transparent;
}

.analysis-container {
  padding: 0;
}

/* Two-column layout for side-by-side view */
.two-columns {
  display: flex;
  max-height: 70vh;
}

.latin-column, .english-column {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.latin-column {
  border-right: 1px solid #e0e0e0;
}

.column-content {
  height: 100%;
}

/* Mobile alternative for side-by-side view */
.mobile-translation-view {
  display: none;
  padding: 15px;
  text-align: center;
}

.mobile-notice {
  background-color: #fff8e8;
  padding: 15px;
  border-radius: 6px;
  margin-bottom: 15px;
  border: 1px solid #B8860B;
}

.mobile-navigation {
  display: flex;
  justify-content: space-around;
  margin-top: 10px;
}

.mobile-nav-btn {
  padding: 10px 20px;
  background-color: #3E2C1B;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.2s;
}

.mobile-nav-btn:hover {
  background-color: #B8860B;
}

/* Column headers */
.two-columns h3, .single-column h3 {
  text-align: center;
  padding-bottom: 10px;
  margin-top: 0;
  position: sticky;
  top: 0;
  background-color: white;
  z-index: 1;
}

.latin-column h3 {
  color: var(--latin-color);
}

.english-column h3 {
  color: var(--english-color);
}

/* Chunk styling */
.chunk-section {
  position: relative;
  margin-bottom: 20px;
  padding: 10px 15px;
  border-radius: 6px;
}

.chunk-number {
  position: absolute;
  top: -8px;
  left: 10px;
  background-color: var(--highlight-color);
  color: var(--white);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
}

.latin-text {
  font-style: italic;
  color: var(--latin-color);
}

.english-text {
  color: var(--english-color);
}

/* Background colors for sections */
.chunk-section {
  background-color: var(--light-gray);
  border: 1px solid var(--border-subtle);
}

.latin-column .chunk-section,
.latin-full {
  background-color: var(--latin-bg);
  border-color: var(--latin-border);
}

.english-column .chunk-section,
.english-full {
  background-color: var(--english-bg);
  border-color: var(--english-border);
}

/* Single column layout for latin/english only views */
.single-column {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 15px;
}

/* Translation paragraph spacing */
.translation-paragraph {
  margin-bottom: 1em;
}

/* Placeholder text */
.placeholder {
  text-align: center;
  padding: 30px;
  color: #666;
  font-style: italic;
}

.placeholder-content {
  height: 18px;
  margin-bottom: 10px;
  background-color: #f0f0f0;
  border-radius: 4px;
}

/* Comments Section Styling */
.comments-section {
  margin-top: 40px;
  padding-top: 30px;
  border-top: 2px solid #B8860B;
  position: relative;
}

.comments-section::before {
  content: '';
  position: absolute;
  top: -2px;
  left: 0;
  right: 0;
  height: 10px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.05), transparent);
}

.comments-section h2 {
  font-family: 'Luxurious Roman', serif;
  color: #3E2C1B;
  margin-bottom: 15px;
  font-size: 1.5rem;
}

.discussion-intro {
  font-style: italic;
  margin-bottom: 20px;
  color: #666;
  font-size: 1.05rem;
  line-height: 1.5;
  border-left: 4px solid #B8860B;
  padding-left: 15px;
  background-color: #f8f4ea;
  padding: 10px 15px;
  border-radius: 0 4px 4px 0;
}

#disqus_thread {
  margin-top: 25px;
  padding: 15px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

/* JSON loader */
.json-loader {
  padding: 20px;
  background-color: #f9f9f9;
  border-radius: 4px;
  margin-bottom: 15px;
}

/* Mobile responsiveness - IMPROVED VERSION */
@media (max-width: 768px) {
  /* Tab navigation improvements */
  .translation-tabs {
    flex-wrap: wrap;
    justify-content: center;
  }

  .tab-btn {
    flex: 1 1 40%;
    margin: 0 2px 4px;
    padding: 10px 15px;
    font-size: 0.95rem;
    text-align: center;
  }

  /* Content area padding adjustments */
  .tab-panel {
    padding: 10px 8px;
  }

  /* Analysis full-width background */
  #analysis {
    background-color: #f9f5ea;
    padding: 15px 10px;
    margin: 0 -10px;
    width: calc(100% + 20px);
  }

  .analysis-container {
    padding: 0;
    background-color: #f9f5ea;
  }

  .post-content.analysis-content {
    background-color: #f9f5ea;
    padding: 0 5px;
  }

  /* Toolbar adjustments for mobile */
  .translation-toolbar {
    flex-direction: column;
    padding: 10px;
  }

  .translation-view-toggle {
    width: 100%;
    justify-content: center;
  }

  .translation-actions {
    width: 100%;
    justify-content: center;
  }

  .view-toggle-btn {
    padding: 6px 14px;
    font-size: 0.85rem;
  }

  .action-btn {
    padding: 5px 10px;
    font-size: 0.8rem;
  }

  .action-btn span {
    display: none;
  }

  /* Hide Both toggle on mobile, show notice instead */
  .view-toggle-btn[data-view="both"] {
    display: none;
  }

  #view-both .two-columns {
    display: none;
  }

  #view-both .mobile-both-notice {
    display: block;
  }

  /* Single column views adjustments */
  .latin-column, .english-column {
    height: auto;
    max-height: 40vh;
    padding: 5px;
  }

  .latin-column {
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 10px;
  }

  /* Chunk styling adjustments */
  .chunk-section {
    padding: 12px 8px 8px;
    margin-bottom: 15px;
  }

  .chunk-number {
    font-size: 10px;
    padding: 1px 6px;
  }

  /* Comments section adjustments */
  .comments-section {
    padding-top: 20px;
    margin-top: 30px;
  }

  .discussion-intro {
    padding: 8px 10px;
    font-size: 0.95rem;
  }

  #disqus_thread {
    padding: 10px 8px;
  }

  /* Post content adjustments for better mobile reading */
  .post-content {
    font-size: 16px;
    line-height: 1.6;
  }

  .post-content h2 {
    font-size: 1.5rem;
    margin-top: 1.5em;
  }

  .post-content h3 {
    font-size: 1.3rem;
  }

  /* Better spacing for mobile content */
  .article-summary {
    margin: 10px 0 20px;
    font-size: 1rem;
  }
}

/* Extreme narrow screens (smaller phones) */
@media (max-width: 480px) {
  /* Even more compact layout */
  .tab-btn {
    flex: 1 1 45%;
    padding: 6px 4px;
    font-size: 0.8rem;
    margin: 0 1px 3px;
  }

  /* Reduce padding further */
  .tab-panel {
    padding: 8px 5px;
  }

  /* Analysis background */
  #analysis {
    padding: 10px 8px;
  }

  /* Less margin between sections */
  .chunk-section {
    margin-bottom: 12px;
    padding: 10px 6px 6px;
  }

  /* Adjust header sizes */
  .two-columns h3, .single-column h3 {
    font-size: 1.1rem;
    padding-bottom: 6px;
  }

  /* Fix margins for content */
  .latin-text, .english-text {
    margin: 0;
    line-height: 1.4;
  }

  /* Mobile navigation buttons */
  .mobile-nav-btn {
    padding: 8px 12px;
    font-size: 0.9rem;
  }

  /* Post header adjustments */
  .post-header {
    margin-bottom: 1rem;
  }

  /* Simplified mobile notice */
  .mobile-notice p {
    font-size: 0.9rem;
    margin: 0;
  }
}

/* Fix scrolling behavior on touch devices */
@media (pointer: coarse) {
  .latin-column, .english-column, .single-column {
    -webkit-overflow-scrolling: touch;
  }
}

/* Ensure content doesn't overflow on small screens */
.post-content {
  overflow-wrap: break-word;
  word-wrap: break-word;
  max-width: 100%;
}

/* Fix for YouTube embed responsiveness */
.youtube-embed iframe {
  max-height: 56vw;
}

/* Overall page margin fix for mobile */
@media (max-width: 768px) {
  .readable-margins {
    padding: 0 15px;
  }
}

/* Metadata content styling */
.metadata-container {
  padding: 15px 10px;
  max-width: 95%;
  margin: 0 auto;
}

.metadata-table {
  table-layout: fixed;
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.metadata-section {
  background-color: var(--highlight-color);
  color: var(--white);
  text-align: left;
  padding: 8px 10px;
  font-size: 1.05rem;
}

.metadata-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 0;
  width: 75%;  /* Explicitly set content column width */
}

.translation-notes {
  background-color: var(--bg-color-light);
  padding: 15px 20px;
  border-radius: 6px;
  margin-top: 20px;
  border-left: 4px solid var(--highlight-color);
}

.translation-notes h4 {
  margin-top: 0;
  color: var(--text-color);
  margin-bottom: 12px;
}

.translation-notes p {
  margin-bottom: 12px;
  line-height: 1.5;
}

.translation-notes p:last-child {
  margin-bottom: 0;
}

/* Mobile responsiveness for metadata */
@media (max-width: 768px) {
  .metadata-table th {
    width: 40%;
  }

  .metadata-table, .metadata-table th, .metadata-table td {
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .metadata-table th {
    width: 45%;
  }

  .metadata-table, .metadata-table th, .metadata-table td {
    font-size: 0.8rem;
    padding: 6px 8px;
  }

  .translation-notes {
    padding: 12px 15px;
  }
}

/* Scroll to Top Button */
.scroll-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 48px;
  height: 48px;
  background-color: var(--highlight-color);
  color: var(--white);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s, background-color 0.2s;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.scroll-to-top:hover {
  background-color: var(--text-color);
}

@media (max-width: 768px) {
  .scroll-to-top {
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
  }
}

/* ============================================
   PRINT STYLES
   Optimized for scholarly side-by-side output
   ============================================ */
@media print {
  /* Hide UI chrome */
  .site-header,
  .site-footer,
  .translation-tabs,
  .translation-toolbar,
  .youtube-promo,
  .youtube-embed,
  .scroll-to-top,
  .mobile-both-notice,
  #analysis,
  #metadata,
  #view-latin,
  #view-english {
    display: none !important;
  }

  /* Reset page layout */
  body {
    background: white;
    color: black;
    font-size: 11pt;
    line-height: 1.5;
  }

  .wrapper {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  .page-content {
    padding: 0;
  }

  /* Post header - centered title and date */
  .post-header {
    text-align: center;
    margin-bottom: 24pt;
    padding-bottom: 12pt;
    border-bottom: 1pt solid #333;
    max-width: 100%;
  }

  .post-title {
    font-size: 18pt;
    margin-bottom: 6pt;
  }

  .post-meta {
    font-size: 10pt;
    color: #333;
  }

  /* Show translation panel */
  #translation-viewer {
    margin: 0;
  }

  .tab-content {
    border: none;
    max-width: 100%;
  }

  #translation.tab-panel {
    display: block !important;
    padding: 0;
  }

  #view-both.translation-view {
    display: block !important;
  }

  /* Two-column side-by-side layout for print */
  .two-columns {
    display: flex !important;
    max-height: none !important;
    gap: 16pt;
  }

  .latin-column,
  .english-column {
    flex: 1;
    overflow: visible;
    padding: 0;
    max-height: none !important;
    height: auto !important;
  }

  .latin-column {
    border-right: 1pt solid #999;
    padding-right: 12pt;
  }

  .english-column {
    padding-left: 12pt;
  }

  .column-content {
    height: auto;
  }

  /* Typography for print */
  .latin-text,
  .english-text {
    font-size: 10pt;
    line-height: 1.6;
    margin-bottom: 12pt;
    orphans: 3;
    widows: 3;
  }

  .latin-text {
    font-style: italic;
  }

  /* Chunk sections */
  .chunk-section {
    page-break-inside: avoid;
    break-inside: avoid;
    margin-bottom: 16pt;
    padding: 0;
    border: none;
    background: none;
  }

  .chunk-number {
    font-size: 8pt;
    color: #666;
    margin-bottom: 4pt;
  }

  /* Column headers */
  .two-columns h3 {
    font-size: 11pt;
    font-weight: bold;
    margin-bottom: 12pt;
    padding-bottom: 6pt;
    border-bottom: 0.5pt solid #ccc;
  }

  /* Links print as text */
  a {
    color: black;
    text-decoration: none;
  }

  /* Page margins */
  @page {
    margin: 0.75in;
  }

  /* Add URL after title for reference */
  .post-header::after {
    content: "bibliothecarius-modernus.github.io";
    display: block;
    font-size: 9pt;
    color: #666;
    margin-top: 6pt;
  }
}
