/* Essay Display Website Styles */
/* Mobile-first responsive design */

/* Base styles and CSS reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary-color: #3a5a78;
  --secondary-color: #f8f9fa;
  --accent-color: #e63946;
  --text-color: #333;
  --light-text: #f8f9fa;
  --border-color: #dee2e6;
  --shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
  --min-touch-size: 44px;
  --touch-target-spacing: 8px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Container for consistent spacing */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent-color);
  color: white;
  padding: 8px;
  z-index: 100;
  transition: top 0.3s;
}

.skip-link:focus {
  top: 0;
}

.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;
}

/* Header styles */
header {
  background-color: var(--primary-color);
  color: var(--light-text);
  padding: 1rem 0;
  box-shadow: var(--shadow);
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

header h1 {
  font-size: 1.5rem;
  margin: 0;
}

/* Navigation */
nav {
  display: flex;
  align-items: center;
}

.nav-button {
  background: transparent;
  border: 1px solid var(--light-text);
  color: var(--light-text);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
}

.nav-button:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Main content area */
main {
  flex: 1;
  padding: 2rem 0;
}

/* Loading indicator */
.loading {
  text-align: center;
  padding: 2.5rem;
  background-color: rgba(248, 249, 250, 0.7);
  border-radius: 8px;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.loading-spinner {
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top: 4px solid var(--primary-color);
  width: 50px;
  height: 50px;
  margin: 0 auto 1.25rem;
  animation: spin 1.2s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading p {
  color: var(--primary-color);
  font-weight: 500;
  font-size: 1.1rem;
}

/* Inline loading indicator for PDF loading */
.inline-loading {
  display: inline-flex;
  align-items: center;
  font-size: 0.9rem;
  color: #666;
}

.inline-loading .mini-spinner {
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top: 2px solid var(--primary-color);
  width: 16px;
  height: 16px;
  margin-right: 8px;
  animation: spin 1s linear infinite;
}

/* Error message */
.error-message {
  text-align: center;
  padding: 2.5rem 2rem;
  background-color: #fff3f3;
  border: 1px solid #ffcdd2;
  border-radius: 8px;
  margin-bottom: 2rem;
  box-shadow: 0 2px 10px rgba(230, 57, 70, 0.1);
}

.error-message h2 {
  color: var(--accent-color);
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.error-message p {
  margin-bottom: 1.5rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.retry-button {
  background-color: var(--accent-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: var(--transition);
  font-weight: 500;
  font-size: 1rem;
}

.retry-button:hover {
  background-color: #c1272d;
  transform: translateY(-2px);
  box-shadow: 0 3px 8px rgba(230, 57, 70, 0.2);
}

.retry-button:focus {
  outline: 3px solid rgba(230, 57, 70, 0.3);
  outline-offset: 2px;
}

/* Essay list section */
.essay-list-section {
  margin-bottom: 2rem;
}

.essay-list-section h2 {
  margin-bottom: 1.5rem;
  font-size: 1.75rem;
  color: var(--primary-color);
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.essay-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

/* Essay card styles */
.essay-card {
  background-color: var(--secondary-color);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  border: 1px solid var(--border-color);
}

.essay-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.essay-card:focus-within {
  outline: 2px solid var(--primary-color);
}

.essay-card-selected {
  background-color: #e8f0f8;
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
  transition: all 0.15s ease;
}

.essay-card-content {
  padding: 1.25rem;
}

.essay-card h3 {
  margin-bottom: 0.5rem;
  color: var(--primary-color);
  font-size: 1.2rem;
}

.essay-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  color: #666;
  margin-top: 1rem;
}

.essay-card-icon {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  color: var(--primary-color);
  opacity: 0.7;
}

.no-content-message {
  text-align: center;
  padding: 2.5rem;
  background-color: var(--secondary-color);
  border-radius: 8px;
  border: 1px dashed var(--border-color);
  color: #666;
  font-style: italic;
}

/* Essay viewer section */
.essay-viewer-section {
  margin-bottom: 2rem;
}

.essay-header {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.essay-header h2 {
  color: var(--primary-color);
  font-size: 1.5rem;
  margin-right: 1rem;
  margin-bottom: 0.5rem;
}

.pdf-container {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background-color: #fff;
  position: relative;
}

.pdf-viewer {
  min-height: 400px;
  height: calc(100vh - 300px);
  max-height: 800px;
  background-color: var(--secondary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: auto;
}

/* PDF.js specific styles */
.pdf-pages-container {
  width: 100%;
  height: 100%;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
}

/* Native PDF viewer styles */
.native-pdf-viewer {
  width: 100%;
  height: 100%;
  border: none;
}

.native-controls-message {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 0.5rem;
  font-size: 0.8rem;
  text-align: center;
}

.pdf-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.pdf-error {
  padding: 2rem;
  text-align: center;
  color: var(--accent-color);
}

.pdf-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  background-color: #f1f1f1;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.control-group {
  display: flex;
  align-items: center;
  margin: 0 0.5rem;
}

.control-button {
  background-color: white;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  width: var(--min-touch-size);
  height: var(--min-touch-size);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: 0 0.25rem;
  transition: var(--transition);
  font-size: 1.1rem;
  /* Ensure touch targets are large enough */
  min-width: var(--min-touch-size);
  min-height: var(--min-touch-size);
}

.control-button:hover {
  background-color: var(--secondary-color);
  border-color: #bbb;
}

.control-button:focus {
  outline: 2px solid rgba(58, 90, 120, 0.3);
  outline-offset: 2px;
}

.control-button:active {
  background-color: #e9ecef;
}

.control-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.zoom-display,
.page-display {
  margin: 0 0.5rem;
  font-size: 0.9rem;
  min-width: 60px;
  text-align: center;
  font-weight: 500;
}

/* PDF content styling */
.pdf-page {
  margin: 1rem auto;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  background-color: white;
  position: relative;
  border-radius: 2px;
}

.pdf-page canvas {
  display: block;
  margin: 0 auto;
}

.pdf-error {
  padding: 2rem;
  text-align: center;
  color: var(--accent-color);
  max-width: 600px;
  margin: 0 auto;
}

.pdf-error h3 {
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.pdf-error p {
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.pdf-download-fallback {
  margin-top: 1.5rem;
  padding: 1rem;
  background-color: #f8f9fa;
  border-radius: 8px;
}

.download-button {
  display: inline-block;
  padding: 0.5rem 1rem;
  background-color: #4a6fa5;
  color: white;
  border-radius: 4px;
  text-decoration: none;
  margin-right: 1rem;
  transition: background-color 0.2s;
}

.download-button:hover {
  background-color: #3a5a78;
}

.pdf-fallback-message {
  padding: 1rem;
  text-align: center;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  margin: 1rem;
}

/* PDF.js specific annotations */
.pdf-annotation {
  position: absolute;
  background-color: rgba(255, 255, 0, 0.2);
  border: 1px solid rgba(255, 200, 0, 0.8);
}

/* PDF loading animation */
.pdf-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.pdf-loading .loading-spinner {
  width: 40px;
  height: 40px;
  margin-bottom: 1rem;
}

/* Progress bar for PDF loading */
.progress-container {
  width: 100%;
  max-width: 300px;
  height: 10px;
  background-color: #e9ecef;
  border-radius: 5px;
  margin-top: 1rem;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background-color: var(--primary-color);
  border-radius: 5px;
  transition: width 0.3s ease;
}

.progress-text {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.25rem;
}

/* Lazy loading placeholder for PDF pages */
.pdf-page-placeholder {
  background-color: #f1f1f1;
  border: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1rem auto;
  position: relative;
}

.pdf-page-placeholder::before {
  content: "Loading page...";
  color: #666;
  font-style: italic;
}

/* Performance monitoring indicator */
.performance-indicator {
  position: fixed;
  bottom: 10px;
  right: 10px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  z-index: 1000;
  opacity: 0.7;
  transition: opacity 0.3s;
}

.performance-indicator:hover {
  opacity: 1;
}

/* Footer */
footer {
  background-color: var(--secondary-color);
  padding: 1rem 0;
  text-align: center;
  border-top: 1px solid var(--border-color);
  font-size: 0.875rem;
}

/* Touch interaction styles */
.touch-active {
  opacity: 0.7 !important;
  transform: scale(0.98) !important;
  transition: opacity 0.15s, transform 0.15s !important;
}

/* Mobile-specific adjustments */
@media (max-width: 767px) {
  /* Increase touch target sizes on mobile */
  .nav-button,
  .retry-button,
  .control-button,
  .essay-card {
    min-height: var(--min-touch-size);
  }
  
  /* Ensure PDF controls are usable on small screens */
  .pdf-controls {
    gap: var(--touch-target-spacing);
    padding: 1rem 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
  }
  
  /* Improve spacing between controls */
  .control-button {
    margin: 0.25rem;
  }
  
  /* Make PDF viewer more usable on mobile */
  .pdf-viewer {
    min-height: 300px;
    height: calc(100vh - 250px);
  }
  
  /* Ensure essay cards are easily tappable */
  .essay-card-content {
    padding: 1.5rem 1rem;
  }
  
  /* Improve header layout on small screens */
  header .container {
    padding: 0.5rem 1rem;
  }
  
  /* Ensure breadcrumb navigation is usable on small screens */
  .breadcrumb {
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
  }
}

/* Responsive design - tablet */
@media (min-width: 768px) {
  header h1 {
    font-size: 2rem;
  }
  
  .essay-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .pdf-controls {
    padding: 1rem;
    justify-content: space-between;
  }
  
  .control-group {
    margin: 0;
  }
  
  .essay-header {
    flex-direction: row;
    align-items: center;
  }
  
  .essay-header h2 {
    margin-bottom: 0;
  }
  
  .error-message,
  .loading {
    padding: 3rem;
  }
}

/* Responsive design - desktop */
@media (min-width: 1024px) {
  .essay-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .container {
    padding: 0 2rem;
  }
  
  .pdf-viewer {
    min-height: 600px;
  }
  
  .control-button {
    width: 40px;
    height: 40px;
  }
  
  .essay-list-section h2,
  .essay-header h2 {
    font-size: 2rem;
  }
}

/* Print styles */
@media print {
  header, 
  footer,
  .pdf-controls,
  #essay-list-view {
    display: none !important;
  }
  
  .pdf-viewer {
    height: auto;
    overflow: visible;
  }
  
  .pdf-page {
    page-break-after: always;
    margin: 0;
    box-shadow: none;
  }
  
  body {
    background: white;
  }
  
  .container {
    max-width: 100%;
    padding: 0;
  }
}/* 
PDF text layer for text selection */
.pdf-text-layer {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  opacity: 0.2;
  line-height: 1.0;
  user-select: text;
  pointer-events: auto;
  cursor: text;
}

.pdf-text-layer span {
  color: transparent;
  position: absolute;
  white-space: pre;
  transform-origin: 0% 0%;
}

.pdf-text-layer span::selection {
  background-color: rgba(58, 90, 120, 0.3);
}

/* PDF annotations */
.pdf-annotation {
  position: absolute;
  background-color: rgba(255, 255, 0, 0.2);
  border: 1px solid rgba(255, 200, 0, 0.8);
  border-radius: 2px;
  pointer-events: auto;
  cursor: pointer;
}

/* PDF unsupported feature message */
.pdf-unsupported-feature {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 10px 20px;
  border-radius: 4px;
  font-size: 0.9rem;
  z-index: 100;
  max-width: 80%;
  text-align: center;
  animation: fadeOut 5s forwards;
}

@keyframes fadeOut {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}/* Naviga
tion and routing transitions */
.view-transition {
  transition: opacity 0.3s ease;
}

/* Screen reader only elements */
.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;
}

/* Active navigation state */
.nav-button.active {
  background-color: rgba(255, 255, 255, 0.2);
  font-weight: 500;
}

/* Navigation feedback styles */
.nav-button.button-pressed {
  background-color: rgba(255, 255, 255, 0.3);
  transform: scale(0.95);
  transition: all 0.15s ease;
}

.breadcrumb a.link-pressed {
  background-color: rgba(58, 90, 120, 0.1);
  padding: 2px 4px;
  border-radius: 2px;
  transform: scale(0.95);
  transition: all 0.15s ease;
}

/* Breadcrumb navigation */
.breadcrumb {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #666;
}

.breadcrumb a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb .separator {
  margin: 0 0.5rem;
  color: #999;
}