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

/* Article body: 19px on mobile (between prose-lg 18px and prose-xl 20px) */
@media (max-width: 767px) {
  .font-article.prose {
    font-size: 1.1875rem;
    line-height: 1.75;
  }
}

/* RSVP Speed Reading */
.rsvp-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgb(28, 25, 23);
  animation: rsvp-fade-in 0.2s ease-out;
}

@keyframes rsvp-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.rsvp-word-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.rsvp-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-bottom: 48px;
}

@media (max-width: 640px) {
  .rsvp-bottom {
    padding-bottom: 40px;
  }
}

.rsvp-tick {
  width: 2px;
  height: 12px;
  background: #d97706;
  margin-bottom: 4px;
}

.rsvp-word {
  display: flex;
  align-items: baseline;
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  font-size: 3rem;
  color: #e7e5e4;
  width: 90vw;
  max-width: 700px;
}

@media (max-width: 640px) {
  .rsvp-word {
    font-size: 2rem;
  }
}

.rsvp-before {
  flex: 1;
  text-align: right;
}

.rsvp-orp {
  color: #f59e0b;
  font-weight: 700;
}

.rsvp-after {
  flex: 1;
  text-align: left;
}

.rsvp-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rsvp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #57534e;
  border-radius: 9999px;
  background: transparent;
  color: #d6d3d1;
  font-size: 1.1rem;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.rsvp-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: #78716c;
}

.rsvp-play-btn {
  min-width: 48px;
  height: 48px;
}

.rsvp-close-btn {
  border: none;
  color: #78716c;
  font-size: 0.85rem;
}

.rsvp-speed {
  min-width: 90px;
  text-align: center;
  font-size: 0.85rem;
  color: #a8a29e;
  font-variant-numeric: tabular-nums;
}

.rsvp-counter {
  margin-top: 16px;
  font-size: 0.75rem;
  color: #78716c;
  font-variant-numeric: tabular-nums;
}

.rsvp-progress-track {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: #292524;
}

.rsvp-progress-bar {
  height: 100%;
  background: #d97706;
  transition: width 0.15s ease-out;
}

/* TTS Word Highlight */
::highlight(tts-word) {
  background-color: #fef3c7;
}

@media (prefers-color-scheme: dark) {
  ::highlight(tts-word) {
    background-color: #78350f;
  }
}

/* TTS Audio Player */
.tts-player {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(214, 211, 209, 0.5);
  animation: tts-fade-in 0.2s ease-out;
  max-width: calc(100vw - 32px);
}

@media (prefers-color-scheme: dark) {
  .tts-player {
    background: rgba(41, 37, 36, 0.85);
    border-color: rgba(68, 64, 60, 0.5);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
}

@keyframes tts-fade-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.tts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 9999px;
  background: transparent;
  color: #57534e;
  font-size: 1rem;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
  flex-shrink: 0;
}

@media (prefers-color-scheme: dark) {
  .tts-btn {
    color: #a8a29e;
  }
}

.tts-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  .tts-btn:hover {
    background: rgba(255, 255, 255, 0.08);
  }
}

.tts-play-btn {
  color: #d97706;
}

@media (prefers-color-scheme: dark) {
  .tts-play-btn {
    color: #f59e0b;
  }
}

.tts-close-btn {
  font-size: 0.75rem;
  color: #a8a29e;
}

.tts-speed-group {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.tts-speed-btn {
  width: 28px;
  height: 28px;
  font-size: 0.9rem;
}

.tts-speed {
  min-width: 36px;
  text-align: center;
  font-size: 0.75rem;
  color: #78716c;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  .tts-speed {
    color: #a8a29e;
  }
}

.tts-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: #d97706;
  flex-shrink: 0;
}

@keyframes tts-spin {
  to {
    transform: rotate(360deg);
  }
}

.tts-spinner {
  animation: tts-spin 1s linear infinite;
}

/* Content Editor */
.editing > * {
  cursor: pointer;
  transition: outline 0.1s;
}

.editing > *:hover {
  outline: 2px dashed #d97706;
  outline-offset: 4px;
  border-radius: 4px;
}

.editing > .block-selected {
  outline: 2px solid #ef4444;
  outline-offset: 4px;
  border-radius: 4px;
}

.editing > .block-selected:hover {
  outline: 2px solid #ef4444;
}

.editing > .block-delete-confirm,
.editing > .block-delete-confirm:hover {
  outline: none;
  cursor: default;
}

.block-removing {
  animation: block-remove 0.3s ease-out forwards;
  pointer-events: none;
}

@keyframes block-remove {
  to {
    opacity: 0;
    max-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }
}

.block-delete-confirm {
  display: flex;
  gap: 8px;
  padding: 8px 0;
}

.block-delete-confirm button {
  padding: 6px 16px;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}

.bdc-delete {
  background: #ef4444;
  color: white;
}

.bdc-delete:hover {
  background: #dc2626;
}

.bdc-cancel {
  background: #e7e5e4;
  color: #44403c;
}

.bdc-cancel:hover {
  background: #d6d3d1;
}

@media (prefers-color-scheme: dark) {
  .bdc-cancel {
    background: #44403c;
    color: #d6d3d1;
  }
  .bdc-cancel:hover {
    background: #57534e;
  }
}

.edit-done-btn {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  padding: 10px 24px;
  border-radius: 9999px;
  border: none;
  background: #d97706;
  color: white;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: background 0.15s;
}

.edit-done-btn:hover {
  background: #b45309;
}

/* Pull to Refresh */
body[data-controller~='pull-to-refresh'] {
  overscroll-behavior-y: none;
}

.ptr-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-36px);
  z-index: 9999;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  color: #78716c;
}

.ptr-indicator.ptr-ready {
  color: #d97706;
}

.ptr-spinner {
  width: 22px;
  height: 22px;
}

.ptr-indicator.ptr-refreshing .ptr-spinner {
  animation: tts-spin 0.6s linear infinite;
}
