/*
 * 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.
 */

/* Base layer: pointer cursor for all interactive button-like elements */
@layer base {
  button:not(:disabled),
  [role="button"]:not(:disabled),
  input[type="submit"]:not(:disabled),
  input[type="button"]:not(:disabled) {
    cursor: pointer;
  }
}

/* Prose typography styles for markdown content */
.prose {
  color: var(--tw-prose-body);
  line-height: 1.75;
}

.prose :where(p):not(:where([class~="not-prose"] *)) {
  margin-top: 1.25em;
  margin-bottom: 1.25em;
}

.prose :where(p):first-child {
  margin-top: 0;
}

.prose :where(h1):not(:where([class~="not-prose"] *)) {
  color: var(--tw-prose-headings);
  font-weight: 700;
  font-size: 2em;
  margin-top: 0;
  margin-bottom: 0.875em;
  line-height: 1.1;
}

.prose :where(h2):not(:where([class~="not-prose"] *)) {
  color: var(--tw-prose-headings);
  font-weight: 600;
  font-size: 1.5em;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  line-height: 1.25;
}

.prose :where(h3):not(:where([class~="not-prose"] *)) {
  color: var(--tw-prose-headings);
  font-weight: 600;
  font-size: 1.25em;
  margin-top: 1.25em;
  margin-bottom: 0.5em;
  line-height: 1.4;
}

.prose :where(h4):not(:where([class~="not-prose"] *)) {
  color: var(--tw-prose-headings);
  font-weight: 600;
  margin-top: 1.25em;
  margin-bottom: 0.5em;
  line-height: 1.5;
}

.prose :where(strong):not(:where([class~="not-prose"] *)) {
  color: var(--tw-prose-bold);
  font-weight: 600;
}

.prose :where(a):not(:where([class~="not-prose"] *)) {
  color: var(--tw-prose-links);
  text-decoration: underline;
  font-weight: 500;
}

.prose :where(a):not(:where([class~="not-prose"] *)):hover {
  opacity: 0.8;
}

.prose :where(ul):not(:where([class~="not-prose"] *)) {
  list-style-type: disc;
  margin-top: 1em;
  margin-bottom: 1em;
  padding-left: 1.5em;
}

.prose :where(ol):not(:where([class~="not-prose"] *)) {
  list-style-type: decimal;
  margin-top: 1em;
  margin-bottom: 1em;
  padding-left: 1.5em;
}

.prose :where(li):not(:where([class~="not-prose"] *)) {
  margin-top: 0.375em;
  margin-bottom: 0.375em;
}

.prose :where(li > ul, li > ol):not(:where([class~="not-prose"] *)) {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

.prose :where(blockquote):not(:where([class~="not-prose"] *)) {
  font-style: normal;
  border-left: 3px solid #6b7280;
  margin-top: 1em;
  margin-bottom: 1em;
  padding-left: 1em;
  color: var(--tw-prose-body);
}

.prose :where(blockquote p):not(:where([class~="not-prose"] *)) {
  margin-top: 0;
  margin-bottom: 0;
}

.prose :where(blockquote p + p):not(:where([class~="not-prose"] *)) {
  margin-top: 0.5em;
}

.prose :where(code):not(:where([class~="not-prose"] *)) {
  color: var(--tw-prose-code);
  background-color: var(--color-inline-code-bg);
  padding: 0.2em 0.4em;
  border-radius: 0.25rem;
  font-size: 0.875em;
  font-weight: 500;
}

.prose :where(pre):not(:where([class~="not-prose"] *)) {
  color: var(--tw-prose-pre-code);
  background-color: var(--tw-prose-pre-bg);
  overflow-x: auto;
  font-size: 0.875em;
  line-height: 1.7;
  margin-top: 1.5em;
  margin-bottom: 1.5em;
  border-radius: 0.5rem;
  padding: 1em 1.25em;
}

.prose :where(pre code):not(:where([class~="not-prose"] *)) {
  background-color: transparent;
  border-width: 0;
  border-radius: 0;
  padding: 0;
  font-weight: inherit;
  color: inherit;
  font-size: inherit;
  font-family: inherit;
  line-height: inherit;
}

.prose :where(hr):not(:where([class~="not-prose"] *)) {
  border-color: var(--tw-prose-hr);
  border-top-width: 1px;
  margin-top: 2em;
  margin-bottom: 2em;
}

.prose :where(table):not(:where([class~="not-prose"] *)) {
  width: 100%;
  table-layout: auto;
  text-align: left;
  margin-top: 1.5em;
  margin-bottom: 1.5em;
  font-size: 0.875em;
  line-height: 1.7;
}

.prose :where(thead):not(:where([class~="not-prose"] *)) {
  border-bottom-width: 1px;
  border-bottom-color: var(--tw-prose-th-borders);
}

.prose :where(thead th):not(:where([class~="not-prose"] *)) {
  color: var(--tw-prose-headings);
  font-weight: 600;
  vertical-align: bottom;
  padding-right: 0.75em;
  padding-bottom: 0.75em;
  padding-left: 0.75em;
}

.prose :where(tbody tr):not(:where([class~="not-prose"] *)) {
  border-bottom-width: 1px;
  border-bottom-color: var(--tw-prose-td-borders);
}

.prose :where(tbody td):not(:where([class~="not-prose"] *)) {
  vertical-align: baseline;
  padding: 0.75em;
}

/* Prose small variant */
.prose-sm {
  font-size: 0.875rem;
  line-height: 1.7;
}

.prose-sm :where(p):not(:where([class~="not-prose"] *)) {
  margin-top: 1em;
  margin-bottom: 1em;
}

.prose-sm :where(h2):not(:where([class~="not-prose"] *)) {
  font-size: 1.25em;
  margin-top: 1.25em;
  margin-bottom: 0.5em;
}

.prose-sm :where(h3):not(:where([class~="not-prose"] *)) {
  font-size: 1.1em;
  margin-top: 1em;
  margin-bottom: 0.4em;
}

/* Source link superscript icons for citation links */
.source-link {
  font-size: 0.7em;
  line-height: 1;
  vertical-align: super;
  margin-left: 1px;
}

.source-link a {
  color: var(--tw-prose-links, #60a5fa);
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 150ms ease;
}

.source-link a:hover {
  opacity: 1;
  text-decoration: none;
}

/* Mobile responsive adjustments */
@media (max-width: 640px) {
  .prose :where(h1):not(:where([class~="not-prose"] *)) {
    font-size: 1.5em;
  }

  .prose :where(h2):not(:where([class~="not-prose"] *)) {
    font-size: 1.25em;
    margin-top: 1.25em;
  }

  .prose :where(h3):not(:where([class~="not-prose"] *)) {
    font-size: 1.1em;
    margin-top: 1em;
  }

  .prose :where(p):not(:where([class~="not-prose"] *)) {
    margin-top: 0.875em;
    margin-bottom: 0.875em;
  }

  .prose :where(ul, ol):not(:where([class~="not-prose"] *)) {
    padding-left: 1.25em;
  }

  .prose :where(pre):not(:where([class~="not-prose"] *)) {
    padding: 0.75em 1em;
    font-size: 0.8em;
    margin-top: 1em;
    margin-bottom: 1em;
  }
}

/* Hide scrollbar for scroll area component */
.scrollbar-hide {
  -ms-overflow-style: none; /* IE and Edge */
  scrollbar-width: none; /* Firefox */
}

.scrollbar-hide::-webkit-scrollbar {
  display: none; /* Chrome, Safari and Opera */
}

/* Scroll Area Fade Effects - Register custom properties for animation */
@property --fade-start-opacity {
  syntax: '<number>';
  initial-value: 1;
  inherits: false;
}

@property --fade-end-opacity {
  syntax: '<number>';
  initial-value: 1;
  inherits: false;
}

@property --fade-start-y-opacity {
  syntax: '<number>';
  initial-value: 1;
  inherits: false;
}

@property --fade-end-y-opacity {
  syntax: '<number>';
  initial-value: 1;
  inherits: false;
}

/* Scroll Area Fade Effects */
.scroll-fade-y {
  --fade-start-opacity: 1;
  --fade-end-opacity: 1;
  --fade-size: 24px;

  mask-image:
    linear-gradient(to bottom,
      hsl(0 0% 0% / var(--fade-start-opacity)),
      black var(--fade-size),
      black calc(100% - var(--fade-size)),
      hsl(0 0% 0% / var(--fade-end-opacity))
    );
  -webkit-mask-image:
    linear-gradient(to bottom,
      hsl(0 0% 0% / var(--fade-start-opacity)),
      black var(--fade-size),
      black calc(100% - var(--fade-size)),
      hsl(0 0% 0% / var(--fade-end-opacity))
    );

  transition: --fade-start-opacity 300ms ease-out, --fade-end-opacity 300ms ease-out;
}

/* Update fade opacity when scrolled - fade appears when there's overflow */
[data-overflow-y-start] .scroll-fade-y {
  --fade-start-opacity: 0;
  --fade-start-y-opacity: 0;
}

[data-overflow-y-end] .scroll-fade-y {
  --fade-end-opacity: 0;
  --fade-end-y-opacity: 0;
}

/* Pull-to-refresh indicator */
.pull-to-refresh-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
}

.pull-to-refresh-icon {
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: var(--color-theme-secondary, #1f2937);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--color-theme-tertiary, #374151);
  transition: transform 0.1s ease-out;
}

.pull-to-refresh-icon svg {
  width: 1.25rem;
  height: 1.25rem;
}
