/* Custom TLP styles, flattened from app/assets/stylesheets/*.scss.
   Bootstrap + Bootstrap Icons are loaded from CDN in the layout. */

/* ---- Highlight marks ---- */
mark[class^="highlight-"],
mark[class*=" highlight-"] {
  padding: 0 2px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
}
mark[class^="highlight-"]:hover,
mark[class*=" highlight-"]:hover {
  opacity: 0.8;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}
.highlight-yellow { background-color: rgba(255, 235, 59, 0.4); }
.highlight-green  { background-color: rgba(76, 175, 80, 0.3); }
.highlight-blue   { background-color: rgba(33, 150, 243, 0.3); }
.highlight-pink   { background-color: rgba(233, 30, 99, 0.3); }
.highlight-purple { background-color: rgba(156, 39, 176, 0.3); }
.highlight-orange { background-color: rgba(255, 152, 0, 0.3); }

/* ---- Highlight toolbar ---- */
.highlight-toolbar {
  display: none;
  position: absolute;
  z-index: 1000;
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  gap: 4px;
}
.highlight-toolbar::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid white;
}
.highlight-color-btn {
  width: 32px; height: 32px;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.highlight-color-btn:hover { border-color: #333; transform: scale(1.1); }
.highlight-color-btn:focus { outline: none; border-color: #000; }
.highlight-color-btn--yellow { background-color: #FFEB3B; }
.highlight-color-btn--green  { background-color: #4CAF50; }
.highlight-color-btn--blue   { background-color: #2196F3; }
.highlight-color-btn--pink   { background-color: #E91E63; }
.highlight-color-btn--purple { background-color: #9C27B0; }
.highlight-color-btn--orange { background-color: #FF9800; }

/* ---- Highlight popover ---- */
.highlight-popover {
  display: none;
  position: absolute;
  z-index: 1000;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  min-width: 160px;
}
.highlight-popover::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid white;
}
.highlight-popover__section { padding: 12px; }
.highlight-popover__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #6c757d;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}
.highlight-popover__colors { display: flex; gap: 6px; justify-content: center; }
.highlight-popover__color-btn {
  width: 24px; height: 24px;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.highlight-popover__color-btn:hover { border-color: #333; transform: scale(1.15); }
.highlight-popover__color-btn:focus { outline: none; border-color: #000; }
.highlight-popover__color-btn--yellow { background-color: #FFEB3B; }
.highlight-popover__color-btn--green  { background-color: #4CAF50; }
.highlight-popover__color-btn--blue   { background-color: #2196F3; }
.highlight-popover__color-btn--pink   { background-color: #E91E63; }
.highlight-popover__color-btn--purple { background-color: #9C27B0; }
.highlight-popover__divider { height: 1px; background-color: #e9ecef; }
.highlight-popover__delete-btn {
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  color: #dc3545;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.2s ease;
  border-radius: 0 0 8px 8px;
}
.highlight-popover__delete-btn:hover { background-color: #fff5f5; }
.highlight-popover__delete-btn i { font-size: 16px; }

/* ---- Highlights management page ---- */
.highlights-list { display: flex; flex-direction: column; gap: 16px; }
.highlight-item {
  display: flex; gap: 12px; padding: 16px;
  background-color: #f8f9fa; border-radius: 8px; align-items: flex-start;
}
.highlight-item:hover { background-color: #e9ecef; }
.highlight-item__color {
  width: 4px; min-width: 4px; height: 100%; min-height: 40px;
  border-radius: 2px; flex-shrink: 0;
}
.highlight-item__color--yellow { background-color: #FFEB3B; }
.highlight-item__color--green  { background-color: #4CAF50; }
.highlight-item__color--blue   { background-color: #2196F3; }
.highlight-item__color--pink   { background-color: #E91E63; }
.highlight-item__color--purple { background-color: #9C27B0; }
.highlight-item__color--orange { background-color: #FF9800; }
.highlight-item__content { flex: 1; min-width: 0; }
.highlight-item__text {
  font-size: 15px; line-height: 1.6; color: #212529;
  margin-bottom: 8px; font-style: italic;
}
.highlight-item__actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---- Reader chrome ---- */
.card-body[data-controller="highlight"] { position: relative; }

blockquote {
  border-left: 3px solid #d0d0d0;
  margin: 1.5rem 0;
  padding: 0 0 0 1.25rem;
  font-style: italic;
  color: #4a4a4a;
}
blockquote p { margin-bottom: 0; }
blockquote p:not(:last-child) { margin-bottom: 0.5rem; }

.post-reader { border: none; }
.post-reader__header {
  background-color: transparent;
  border-bottom: 1px solid #eee;
  padding: 1.5rem 1.5rem 1rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
.post-reader__nav-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  grid-column: 1 / -1;
}
.post-reader__nav { display: flex; align-items: center; justify-content: center; }
.post-reader__nav-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.25rem; font-weight: 500; width: 100%;
}
.post-reader__actions { grid-column: 1 / -1; justify-self: center; }
.post-reader__actions > .d-flex {
  flex-wrap: wrap; justify-content: center; gap: clamp(0.5rem, 2vw, 1rem);
}
.post-reader__title { font-size: clamp(2rem, 1.5rem + 1vw, 2.5rem); line-height: 1.2; }
.post-reader__meta { letter-spacing: 0.02em; }
.post-reader__body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  font-size: 1.25rem; line-height: 1.6; color: #1a1a1a; word-break: break-word;
}
.post-reader__body p { margin-bottom: 1.5rem; }
.post-reader__body h2, .post-reader__body h3, .post-reader__body h4 {
  margin-top: 2.5rem; margin-bottom: 1.25rem; line-height: 1.3;
}
.post-reader__body ul, .post-reader__body ol { padding-left: 1.5rem; margin-bottom: 1.5rem; }
.post-reader__body li + li { margin-top: 0.5rem; }
.post-reader__body img, .post-reader__body video {
  max-width: 100%; height: auto; border-radius: 0.5rem;
  margin: 1.5rem 0; box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.08);
}
.post-reader__body pre {
  padding: 1rem 1.25rem; background-color: #0d1117; color: #f0f6fc;
  border-radius: 0.5rem; overflow: auto; margin: 1.5rem 0;
  font-size: 0.95rem; line-height: 1.6;
}
.post-reader__body code {
  background-color: rgba(13, 17, 23, 0.08);
  padding: 0.15rem 0.35rem; border-radius: 0.35rem; font-size: 0.95em;
}
.post-reader__body a {
  text-decoration: underline;
  text-decoration-thickness: 0.075em;
  text-decoration-color: rgba(13, 110, 253, 0.4);
  text-underline-offset: 0.15em;
}
.post-reader__body a:hover { text-decoration-color: rgba(13, 110, 253, 1); }
.post-reader__body hr { margin: 2.5rem 0; opacity: 0.3; }
.post-reader .card-body { background-color: #fafaf7; }
.post-reader__original-link { color: inherit; }
.post-reader__original-link:hover { color: #0d6efd; }
.post-reader__footer {
  background-color: transparent; border-top: 1px solid #eee; padding: 1rem 1.5rem;
}

@media (max-width: 767.98px) {
  .post-reader__body { font-size: 1.125rem; line-height: 1.55; }
  .highlight-toolbar { width: auto; max-width: 90vw; }
  .highlight-color-btn { width: 28px; height: 28px; }
  .highlight-popover { min-width: 180px; }
  .highlight-item { flex-direction: column; gap: 12px; }
}

@media (min-width: 992px) {
  .post-reader__header {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
  }
  .post-reader__nav-row { display: contents; }
  .post-reader__nav--prev { grid-column: 1; grid-row: 1; justify-content: flex-start; }
  .post-reader__nav--next { grid-column: 3; grid-row: 1; justify-content: flex-end; }
  .post-reader__nav-btn { width: auto; }
  .post-reader__actions {
    grid-column: 2; grid-row: 1; display: flex !important; justify-content: center;
  }
}

/* ---- Reading progress bar ---- */
.reading-progress {
  position: fixed; top: 0; left: 0;
  width: 0%; height: 3px;
  background: linear-gradient(90deg, #7c6caf, #5b8bd4);
  z-index: 1060;
  transition: width 0.1s linear;
}
