/* Essay Container Styles */

/* Hide scrollbar but keep scrolling functional */
.container-overlay.is-essay.container-mode .container-card {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.container-overlay.is-essay.container-mode .container-card::-webkit-scrollbar {
  display: none; /* Chrome/Safari/Opera */
}

/* Paper/Chalkboard background treatment */
.container-overlay.is-essay .container-card {
  position: relative;
  /* Uneven paper color with subtle variations */
  background:
    radial-gradient(circle at 20% 30%, rgba(245, 235, 220, 0.3), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(240, 228, 210, 0.2), transparent 35%),
    radial-gradient(circle at 50% 50%, rgba(250, 245, 235, 0.15), transparent 50%),
    #f8f6f0;
  /* More pronounced shadows for depth */
  box-shadow:
    inset 0 0 120px rgba(0, 0, 0, 0.05),
    inset 20px 0 60px rgba(0, 0, 0, 0.02),
    inset -20px 0 60px rgba(0, 0, 0, 0.02),
    inset 0 20px 60px rgba(0, 0, 0, 0.015),
    0 40px 100px rgba(0, 0, 0, 0.25),
    0 15px 40px rgba(0, 0, 0, 0.15);
}

/* Wrapper to contain card and indicator */
.essay-container-wrapper {
  position: relative;
  width: min(1100px, 92vw);
  height: min(78vh, 780px);
}

/* Scroll indicator - positioned at bottom of wrapper */
.essay-container-wrapper .scroll-indicator {
  position: absolute;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Downward arrow inside circle */
.essay-container-wrapper .scroll-indicator::after {
  content: "↓";
  font-size: 20px;
  color: rgba(0, 0, 0, 0.7);
  line-height: 1;
}

/* Show scroll indicator when essay has more content */
.container-overlay.is-essay.has-scroll .essay-container-wrapper .scroll-indicator {
  opacity: 1;
  animation: bounce 2s ease-in-out infinite;
}

/* Dark mode indicator */
@media (prefers-color-scheme: dark) {
  .essay-container-wrapper .scroll-indicator {
    background: rgba(0, 0, 0, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  }

  .essay-container-wrapper .scroll-indicator::after {
    color: rgba(255, 255, 255, 0.8);
  }
}

html[data-theme="dark"] .essay-container-wrapper .scroll-indicator {
  background: rgba(0, 0, 0, 0.8);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] .essay-container-wrapper .scroll-indicator::after {
  color: rgba(255, 255, 255, 0.8);
}

@keyframes bounce {
  0%, 100% {
    transform: translateX(-50%) translateY(0px);
  }
  50% {
    transform: translateX(-50%) translateY(5px);
  }
}

/* Paper grain/noise texture */
.container-overlay.is-essay .container-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    /* Ruled lines */
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.02) 2px,
      rgba(0, 0, 0, 0.02) 3px
    ),
    /* Paper grain - organic noise pattern */
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 1px,
      rgba(0, 0, 0, 0.008) 1px,
      rgba(0, 0, 0, 0.008) 2px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 1px,
      rgba(0, 0, 0, 0.005) 1px,
      rgba(0, 0, 0, 0.005) 2px
    );
  pointer-events: none;
  border-radius: var(--radius);
  opacity: 0.7;
}

/* Aging marks and coffee stains */
.container-overlay.is-essay .container-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    /* Coffee stain top right */
    radial-gradient(ellipse 120px 80px at 85% 15%, rgba(139, 90, 43, 0.08), transparent 50%),
    /* Aged corner bottom left */
    radial-gradient(ellipse 100px 100px at 10% 90%, rgba(160, 120, 80, 0.06), transparent 45%),
    /* Light water mark center */
    radial-gradient(ellipse 200px 150px at 50% 50%, rgba(180, 150, 120, 0.03), transparent 60%),
    /* Small spots */
    radial-gradient(circle 15px at 30% 40%, rgba(120, 90, 60, 0.04), transparent),
    radial-gradient(circle 10px at 70% 60%, rgba(130, 100, 70, 0.03), transparent);
  pointer-events: none;
  border-radius: var(--radius);
  opacity: 0.5;
}

/* Dark mode: chalkboard effect */
@media (prefers-color-scheme: dark) {
  .container-overlay.is-essay .container-card {
    background: #1a1c1e;
    box-shadow:
      inset 0 0 100px rgba(255, 255, 255, 0.02),
      0 30px 80px rgba(0, 0, 0, 0.5);
  }

  .container-overlay.is-essay .container-card::before {
    background-image:
      repeating-linear-gradient(
        45deg,
        transparent,
        transparent 3px,
        rgba(255, 255, 255, 0.01) 3px,
        rgba(255, 255, 255, 0.01) 4px
      ),
      repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 3px,
        rgba(255, 255, 255, 0.008) 3px,
        rgba(255, 255, 255, 0.008) 4px
      );
    opacity: 0.6;
  }
}

html[data-theme="dark"] .container-overlay.is-essay .container-card {
  background: #1a1c1e;
  box-shadow:
    inset 0 0 100px rgba(255, 255, 255, 0.02),
    0 30px 80px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .container-overlay.is-essay .container-card::before {
  background-image:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 3px,
      rgba(255, 255, 255, 0.01) 3px,
      rgba(255, 255, 255, 0.01) 4px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 3px,
      rgba(255, 255, 255, 0.008) 3px,
      rgba(255, 255, 255, 0.008) 4px
    );
  opacity: 0.6;
}

.essay-content {
  max-width: 65ch; /* Optimal reading width: 60-75 characters per line */
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
  line-height: 1.75;
  color: var(--fg);
  font-family: 'Courier Prime', 'Courier New', monospace;
  position: relative;
  z-index: 1;
}

/* Headings */
.essay-content h1 {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-6);
  margin-top: var(--space-8);
  letter-spacing: 0;
  font-family: 'Courier Prime', 'Courier New', monospace;
}

.essay-content h1:first-child {
  margin-top: 0;
}

.essay-content h2 {
  font-size: clamp(1.375rem, 3vw, 1.75rem);
  font-weight: 700;
  line-height: 1.3;
  margin-top: var(--space-8);
  margin-bottom: var(--space-4);
  letter-spacing: 0;
  font-family: 'Courier Prime', 'Courier New', monospace;
}

.essay-content h3 {
  font-size: clamp(1.125rem, 2.5vw, 1.375rem);
  font-weight: 700;
  line-height: 1.4;
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
  font-family: 'Courier Prime', 'Courier New', monospace;
}

.essay-content h4,
.essay-content h5,
.essay-content h6 {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.5;
  margin-top: var(--space-4);
  margin-bottom: var(--space-3);
  font-family: 'Courier Prime', 'Courier New', monospace;
}

/* Paragraphs */
.essay-content p {
  margin-bottom: var(--space-6);
}

.essay-content p:last-child {
  margin-bottom: 0;
}

/* Lists */
.essay-content ul,
.essay-content ol {
  margin-bottom: var(--space-6);
  padding-left: 1.5rem;
}

.essay-content li {
  margin-bottom: var(--space-3);
  line-height: 1.7;
}

.essay-content li:last-child {
  margin-bottom: 0;
}

.essay-content ul {
  list-style-type: disc;
}

.essay-content ol {
  list-style-type: decimal;
}

/* Nested lists */
.essay-content li > ul,
.essay-content li > ol {
  margin-top: var(--space-3);
  margin-bottom: 0;
}

/* Blockquotes */
.essay-content blockquote {
  margin: var(--space-6) 0;
  padding-left: var(--space-6);
  border-left: 3px solid var(--muted);
  font-style: italic;
  color: var(--muted);
}

.essay-content blockquote p {
  margin-bottom: var(--space-4);
}

.essay-content blockquote p:last-child {
  margin-bottom: 0;
}

/* Links */
.essay-content a {
  color: var(--thread-questions);
  text-decoration: underline;
  text-decoration-color: rgba(246, 197, 108, 0.3);
  text-underline-offset: 2px;
  transition: text-decoration-color var(--transition);
}

.essay-content a:hover {
  text-decoration-color: var(--thread-questions);
}

/* Emphasis */
.essay-content em {
  font-style: italic;
}

.essay-content strong {
  font-weight: 600;
}

/* Code */
.essay-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--paper);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  border: var(--border);
}

.essay-content pre {
  margin: var(--space-6) 0;
  padding: var(--space-4);
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.essay-content pre code {
  background: none;
  padding: 0;
  border: none;
  font-size: 0.875rem;
}

/* Horizontal rules */
.essay-content hr {
  margin: var(--space-8) auto;
  border: none;
  border-top: var(--border);
  max-width: 60%;
  opacity: 0.5;
}

/* Images */
.essay-content img {
  max-width: 100%;
  height: auto;
  margin: var(--space-6) auto;
  border-radius: var(--radius);
}

/* Tables */
.essay-content table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-6) 0;
}

.essay-content th,
.essay-content td {
  padding: var(--space-3) var(--space-4);
  border: var(--border);
  text-align: left;
}

.essay-content th {
  font-weight: 600;
  background: var(--paper);
}

/* Responsive spacing */
@media (max-width: 640px) {
  .essay-content {
    padding: var(--space-4) var(--space-3);
  }

  .essay-content h1 {
    margin-top: var(--space-6);
  }

  .essay-content h2 {
    margin-top: var(--space-6);
  }

  .essay-content blockquote {
    padding-left: var(--space-4);
  }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .essay-content a {
    color: var(--thread-questions);
    text-decoration-color: rgba(246, 197, 108, 0.25);
  }

  .essay-content a:hover {
    text-decoration-color: var(--thread-questions);
  }
}

html[data-theme="dark"] .essay-content a {
  color: var(--thread-questions);
  text-decoration-color: rgba(246, 197, 108, 0.25);
}

html[data-theme="dark"] .essay-content a:hover {
  text-decoration-color: var(--thread-questions);
}
