/* FindJuris Custom Styles */

:root {
  --serif: "Playfair Display", Georgia, serif;
  --body-serif: "Lora", Georgia, serif;
  --sans: "Inter", -apple-system, sans-serif;
}

body {
  font-family: var(--body-serif);
  background: #f5f1e8;
  color: #1a1a1a;
  position: relative;
  overflow-x: hidden;
}

/* Paper texture overlay - larger crosshatch pattern */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 12px,
      rgba(139, 90, 43, 0.04) 12px,
      rgba(139, 90, 43, 0.04) 13px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 12px,
      rgba(139, 90, 43, 0.04) 12px,
      rgba(139, 90, 43, 0.04) 13px
    );
  pointer-events: none;
  opacity: 0.7;
  z-index: 1;
}

/* Canvas for particle effects and drawing */
#particle-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto; /* Allow interactions for drawing */
  z-index: 0;
  /* Custom ink pen cursor from SVG file (32x32, hotspot at pen tip) */
  cursor:
    url("/static/cursor-pen-32.svg") 1 31,
    auto;
}

.content-wrapper {
  position: relative;
  z-index: 2;
  pointer-events: none; /* Allow clicks to pass through to canvas */
}

/* Re-enable pointer events for interactive elements */
.content-wrapper * {
  pointer-events: auto;
}

/* Show ink pen cursor on writable areas */
body {
  cursor:
    url("/static/cursor-pen-32.svg") 1 31,
    auto;
}

/* Normal cursor for non-writable elements */
button,
a,
input,
textarea,
select,
.btn-primary,
.btn-secondary,
.search-box,
.result-card,
.case-detail-content,
header,
footer {
  cursor: default !important;
}

/* Pointer cursor for clickable elements */
button,
a,
.btn-primary,
.btn-secondary {
  cursor: pointer !important;
}

/* Text cursor for text input areas */
textarea,
input[type="text"],
input[type="search"] {
  cursor: text !important;
}

/* Handwriting animation for logo */
.signature-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  margin-bottom: 20px;
}

.signature-text {
  display: flex;
  align-items: center;
  gap: 0;
}

.signature-text svg {
  height: 68px;
  width: auto;
}

.signature-text svg path {
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-width: 2;
  stroke: #1a1a1a;
  fill: none;
}

.letter-animate path {
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.magnifier-icon {
  width: 50px;
  height: 50px;
  opacity: 0;
  animation: fadeIn 0.6s ease-out 2.5s forwards;
  stroke-width: 2;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

/* Harvard-style typography */
.harvard-title {
  font-family: var(--serif);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.harvard-subtitle {
  font-family: var(--sans);
  font-weight: 300;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.7rem;
}

.search-box {
  background: white;
  border: 2px solid #1a1a1a;
  box-shadow: 6px 6px 0 #1a1a1a;
  transition: box-shadow 0.2s ease;
}

.search-box:focus-within {
  box-shadow: 8px 8px 0 #1a1a1a;
}

.result-card {
  background: #fffef9;
  border-left: 5px solid #1a1a1a;
  border-top: 2px solid #e5dcc8;
  border-right: 2px solid #e5dcc8;
  border-bottom: 2px solid #e5dcc8;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  position: relative;
}

.result-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 20px 20px 0;
  border-color: transparent #e5dcc8 transparent transparent;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.result-card:hover {
  border-left-width: 10px;
  box-shadow: 8px 8px 0 rgba(139, 90, 43, 0.1);
  transform: translateX(4px) translateY(-2px);
  background: #ffffff;
}

.result-card:hover::after {
  opacity: 1;
}

/* Color-coded relevance badges */
.relevance-high {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%) !important;
  color: white !important;
  border-color: #059669 !important;
}

.relevance-medium {
  background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%) !important;
  color: white !important;
  border-color: #d97706 !important;
}

.relevance-low {
  background: linear-gradient(135deg, #6b7280 0%, #9ca3af 100%) !important;
  color: white !important;
  border-color: #6b7280 !important;
}

.case-number {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.3;
}

.case-meta {
  font-family: var(--sans);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #666;
}

.case-description {
  font-family: var(--body-serif);
  line-height: 1.7;
  color: #333;
}

.editorial-line {
  width: 100%;
  height: 2px;
  background: #1a1a1a;
  margin: 48px 0;
}

.stats-badge {
  font-family: var(--sans);
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid #1a1a1a;
  padding: 6px 14px;
  background: white;
  color: #1a1a1a;
  display: inline-block;
}

.btn-primary {
  background: #1a1a1a;
  color: white;
  border: 2px solid #1a1a1a;
  font-family: var(--sans);
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 0.85rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: white;
  transform: translate(-50%, -50%);
  transition:
    width 0.6s ease,
    height 0.6s ease;
}

.btn-primary:hover::before {
  width: 300px;
  height: 300px;
}

.btn-primary:hover {
  color: #1a1a1a;
  transform: translateY(-3px) scale(1.02);
  box-shadow: 6px 6px 0 #1a1a1a;
}

.btn-primary span {
  position: relative;
  z-index: 1;
}

.btn-primary:active {
  transform: translateY(-1px);
  box-shadow: 3px 3px 0 #1a1a1a;
}

.btn-secondary {
  background: white;
  color: #1a1a1a;
  border: 1px solid #1a1a1a;
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #1a1a1a;
  color: white;
}

/* Clear drawing button - hidden by default, slides in when needed */
#clear-scribbles-btn {
  max-width: 0;
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  overflow: hidden;
  padding: 0 !important;
  margin: 0;
  border: none;
  pointer-events: none;
}

#clear-scribbles-btn.visible {
  max-width: 200px;
  opacity: 1;
  transform: translateX(0);
  padding: 0.5rem 1rem !important;
  margin-left: 0.5rem;
  border: 1px solid #1a1a1a;
  pointer-events: auto;
}

/* Newspaper-style layout */
.editorial-header {
  border-top: 2px solid #1a1a1a;
  border-bottom: 2px solid #1a1a1a;
  padding: 20px 0;
  margin-bottom: 56px;
}

/* Premium loading animation */
.loading-bar-container {
  width: 300px;
  height: 3px;
  background: #e5dcc8;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  border-radius: 2px;
}

.loading-bar {
  height: 100%;
  background: linear-gradient(90deg, #1a1a1a 0%, #4a4a4a 50%, #1a1a1a 100%);
  background-size: 200% 100%;
  animation: loading-slide 2s ease-in-out infinite;
  width: 40%;
  border-radius: 2px;
}

@keyframes loading-slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(850%);
  }
}

.progress-message {
  opacity: 1;
  transition: opacity 0.4s ease;
  font-weight: 500;
}

.progress-detail {
  opacity: 0.7;
  transition: opacity 0.4s ease;
}

/* Fade in animation */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.6s ease-out;
  animation-fill-mode: backwards; /* Prevents flash during delay */
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Tablets and below (768px) */
@media (max-width: 768px) {
  /* Logo scaling */
  .signature-container {
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
  }

  .signature-text svg {
    height: 42px; /* Smaller on mobile */
  }

  .magnifier-icon {
    width: 34px;
    height: 34px;
  }

  /* Typography scaling */
  .harvard-title {
    font-size: 1.75rem !important; /* Scale down */
  }

  .harvard-subtitle {
    font-size: 0.65rem;
  }

  .case-number {
    font-size: 1.25rem;
  }

  /* Content padding */
  .content-wrapper {
    padding-left: 1rem;
    padding-right: 1rem;
    padding-top: 2rem;
    padding-bottom: 2rem;
  }

  /* Search box */
  .search-box {
    padding: 1.5rem !important;
    box-shadow: 4px 4px 0 #1a1a1a;
  }

  .search-box:focus-within {
    box-shadow: 5px 5px 0 #1a1a1a;
  }

  /* Buttons */
  .btn-primary {
    padding: 0.875rem 2rem !important;
    font-size: 0.75rem;
  }

  .btn-secondary {
    padding: 0.5rem 0.875rem !important;
    font-size: 0.65rem;
  }

  /* Editorial header */
  .editorial-header {
    padding: 14px 0;
    margin-bottom: 32px;
  }

  /* Result cards */
  .result-card {
    padding: 1rem !important;
    margin-bottom: 1rem !important;
  }

  .result-card:hover {
    transform: none; /* Disable hover transform on mobile */
  }

  /* Loading bar */
  .loading-bar-container {
    width: 200px;
  }

  /* Stats badges */
  .stats-badge {
    font-size: 0.6rem;
    padding: 4px 10px;
  }

  /* Case detail page */
  .case-detail-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
  }

  .metadata-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .metadata-item {
    padding: 0.75rem;
  }

  .case-detail-content {
    font-size: 0.95rem;
    line-height: 1.7;
  }

  .info-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .info-label {
    width: auto;
  }

  /* Back button on case page - remove sticky positioning */
  .back-button {
    position: static;
    margin-bottom: 0;
  }

  /* Make all navigation buttons same height on mobile */
  .case-nav-header .back-button,
  .case-nav-header #lang-en-case,
  .case-nav-header #lang-pt-case {
    height: 40px;
    padding: 0 1rem !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* Small phones (480px and below) */
@media (max-width: 480px) {
  .signature-text svg {
    height: 36px;
  }

  .magnifier-icon {
    width: 28px;
    height: 28px;
  }

  .harvard-title {
    font-size: 1.5rem !important;
  }

  .btn-primary {
    padding: 0.75rem 1.5rem !important;
  }

  .loading-bar-container {
    width: 150px;
  }

  .case-detail-content {
    font-size: 0.9rem;
  }
}

/* ============================================
   SHARED COMPONENT STYLES
   ============================================ */

/* Hidden state utility */
.hidden-force {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

/* Fade-in animation for case page */
.fade-in {
  animation: fadeIn 0.6s ease-out;
}

/* Case detail specific */
.case-detail-content {
  line-height: 1.9;
  font-size: 1.05rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.case-detail-content p {
  margin-bottom: 1.5rem;
}

.info-row {
  display: flex;
  padding: 0.75rem 0;
  border-bottom: 1px solid #e5e7eb;
}

.info-label {
  font-family: var(--sans);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #666;
  width: 150px;
  flex-shrink: 0;
}

.info-value {
  font-family: var(--body-serif);
  color: #1a1a1a;
}

.case-detail-header {
  border-bottom: 3px solid #1a1a1a;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
}

.metadata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.metadata-item {
  padding: 1rem;
  background: white;
  border: 1px solid #e5dcc8;
  border-left: 3px solid #1a1a1a;
}

/* Case page navigation header */
.case-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 1rem;
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Desktop: Keep sticky behavior */
@media (min-width: 769px) {
  .back-button {
    position: sticky;
    top: 20px;
    z-index: 10;
  }
}

/* ============================================
   AI SUMMARY STYLES
   ============================================ */

.ai-summary-container {
  animation: slideInDown 0.6s ease-out;
  animation-fill-mode: backwards;
  animation-delay: 0.3s;
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#ai-summary-content {
  min-height: 40px;
  line-height: 1.8;
}

#ai-summary-content p {
  margin-bottom: 1rem;
}

#ai-summary-content p:last-child {
  margin-bottom: 0;
}

/* Typing indicator animation */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4f46e5;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Mobile responsive for AI summary */
@media (max-width: 768px) {
  .ai-summary-container {
    padding: 1.5rem !important;
    margin-bottom: 2rem !important;
  }

  .ai-summary-container h3 {
    font-size: 1.25rem !important;
  }

  #ai-summary-content {
    font-size: 0.9rem;
  }
}
