/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 *
 *= require rouge
 *= require trix
 *= require actiontext
 *= require slim-select-styles
 *= require_tree ./utilities
 *= require_tree ./components
 *= require_tree ./pages
 *= require_tree ./admin
 */

/* Aspect ratio utilities for book covers */
.aspect-w-3 {
  position: relative;
}

.aspect-w-3::before {
  content: "";
  display: block;
  padding-bottom: 133.333%; /* 3:4 aspect ratio */
}

.aspect-h-4 {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Fix for nested aspect ratio */
.aspect-w-3 > * {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Animation utilities */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-fadeIn {
  animation: fadeIn 0.8s ease-out forwards;
}

.animate-slideInRight {
  animation: slideInRight 0.8s ease-out forwards;
}

.animation-delay-200 {
  animation-delay: 200ms;
}

.animation-delay-400 {
  animation-delay: 400ms;
}

/* Line clamp utilities */
.line-clamp-1 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.line-clamp-2 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.line-clamp-3 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

/* Sortable drag handle styles */
.drag-handle {
  cursor: move;
  cursor: grab;
}

.drag-handle:active {
  cursor: grabbing;
}

/* Sortable ghost and drag styles */
.sortable-ghost {
  opacity: 0.4;
}

.sortable-drag {
  opacity: 1 !important;
}

/* Link styles for prose content */
.prose a {
  color: #2563eb; /* blue-600 */
  text-decoration: underline;
  transition: color 200ms;
  word-break: break-all; /* Break long URLs */
  overflow-wrap: break-word; /* Alternative fallback */
  hyphens: auto; /* Add hyphens where appropriate */
}

.prose a:hover {
  color: #1e40af; /* blue-800 */
}

/* Post typography using Merriweather */
.post-title,
.post-body,
.prose.post-content {
  font-family: 'Merriweather', serif;
  font-optical-sizing: auto;
  font-weight: 400;
  font-style: normal;
  font-variation-settings: "wdth" 100;
}

.post-title {
  font-weight: 900;
  letter-spacing: -0.02em;
}

.post-body,
.prose.post-content {
  font-size: 1.125rem; /* 18px */
  line-height: 1.75;
  letter-spacing: 0.01em;
}

.post-body h1,
.post-body h2,
.post-body h3,
.post-body h4,
.post-body h5,
.post-body h6,
.prose.post-content h1,
.prose.post-content h2,
.prose.post-content h3,
.prose.post-content h4,
.prose.post-content h5,
.prose.post-content h6 {
  font-family: 'Merriweather', serif;
  font-weight: 700;
  font-optical-sizing: auto;
  font-style: normal;
  font-variation-settings: "wdth" 100;
  letter-spacing: -0.01em;
}

/* Bold text in articles */
.post-body strong,
.post-body b,
.prose.post-content strong,
.prose.post-content b {
  font-family: 'Merriweather', serif;
  font-weight: 700;
}

/* Italic text in articles */
.post-body em,
.post-body i,
.prose.post-content em,
.prose.post-content i {
  font-family: 'Merriweather', serif;
  font-style: italic;
}

/* Ensure good readability on all devices */
@media (min-width: 768px) {
  .post-body,
  .prose.post-content {
    font-size: 1.25rem; /* 20px on larger screens */
    line-height: 1.8;
  }
}

/* Vertical spacing for prose content */
.prose.post-content h1 {
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

.prose.post-content h2 {
  margin-top: 2.25rem;
  margin-bottom: 1rem;
}

.prose.post-content h3 {
  margin-top: 2rem;
  margin-bottom: 0.875rem;
}

.prose.post-content h4 {
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
}

.prose.post-content h5 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.prose.post-content h6 {
  margin-top: 3rem;
  margin-bottom: 0.75rem;
  font-weight: 700;
  font-size: 1.125rem;
}

.prose.post-content h6:first-child {
  margin-top: 0;
}

.prose.post-content p {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.prose.post-content p:first-of-type {
  margin-top: 0;
}

/* Tom Select Styles to match Tailwind forms */
.ts-wrapper.form-control,
.ts-wrapper.form-select {
  padding: 0 !important;
  border: none !important;
  height: auto !important;
  box-shadow: none !important;
}

.ts-wrapper .ts-control {
  background: white;
  border: 1px solid #d1d5db; /* gray-300 */
  border-radius: 0.375rem; /* rounded-md */
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); /* shadow-sm */
  padding: 0.5rem 0.75rem; /* py-2 px-3 */
  min-height: 2.5rem; /* match Tailwind form input height */
  font-size: 0.875rem; /* text-sm */
  line-height: 1.25rem;
}

.ts-wrapper.focus .ts-control {
  border-color: #6366f1; /* indigo-500 */
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1); /* focus ring */
}

.ts-wrapper .ts-control > input {
  font-size: 0.875rem; /* text-sm */
  padding: 0;
  border: none;
  background: transparent;
}

.ts-wrapper.multi .ts-control > div {
  display: inline-flex;
  align-items: center;
  background: #e0e7ff; /* indigo-100 */
  border: 1px solid #c7d2fe; /* indigo-200 */
  border-radius: 0.25rem; /* rounded */
  padding: 0.125rem 0.5rem; /* py-0.5 px-2 */
  margin: 0.125rem 0.25rem 0.125rem 0; /* spacing between items */
  font-size: 0.875rem; /* text-sm */
  color: #4338ca; /* indigo-700 */
}

.ts-wrapper.multi .ts-control > div.active {
  background: #c7d2fe; /* indigo-200 */
  border-color: #a5b4fc; /* indigo-300 */
}

.ts-wrapper .ts-dropdown {
  margin-top: 0.25rem;
  border: 1px solid #d1d5db; /* gray-300 */
  border-radius: 0.375rem; /* rounded-md */
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* shadow-lg */
  background: white;
  font-size: 0.875rem; /* text-sm */
}

.ts-wrapper .ts-dropdown .ts-dropdown-content {
  max-height: 15rem; /* max-h-60 */
  overflow-y: auto;
}

.ts-wrapper .ts-dropdown .option {
  padding: 0.5rem 0.75rem; /* py-2 px-3 */
  cursor: pointer;
}

.ts-wrapper .ts-dropdown .option.active,
.ts-wrapper .ts-dropdown .option:hover {
  background: #f3f4f6; /* gray-100 */
  color: #111827; /* gray-900 */
}

.ts-wrapper .ts-dropdown .option.selected {
  background: #e0e7ff; /* indigo-100 */
  color: #4338ca; /* indigo-700 */
}

/* Remove button plugin styles */
.ts-wrapper.plugin-remove_button .item .remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.25rem;
  padding: 0;
  width: 1rem;
  height: 1rem;
  border-radius: 9999px; /* rounded-full */
  background: #4338ca; /* indigo-700 */
  color: white;
  font-size: 0.75rem;
  line-height: 1;
  border: none;
  cursor: pointer;
}

.ts-wrapper.plugin-remove_button .item .remove:hover {
  background: #3730a3; /* indigo-800 */
}

/* Disabled state */
.ts-wrapper.disabled .ts-control {
  background: #f9fafb; /* gray-50 */
  cursor: not-allowed;
  opacity: 0.5;
}
