/* Longleaf Guide UI enhancements (scoped) */

[data-longleaf-guide] {
  --llg-shadow: 0 14px 30px rgba(28, 36, 36, 0.12);
  --llg-border: rgba(28, 36, 36, 0.12);
  --llg-surface: rgba(255, 255, 255, 0.92);
  --llg-surface-solid: #ffffff;
}

[data-longleaf-guide] main {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  [data-longleaf-guide] main {
    scroll-behavior: auto;
  }
}

/* Improve tap targets and readability */
[data-longleaf-guide] a {
  text-underline-offset: 3px;
}

[data-longleaf-guide] article p,
[data-longleaf-guide] article li {
  line-height: 1.75;
}

[data-longleaf-guide] article h2 {
  scroll-margin-top: 6rem;
}

/* Reading progress (injected) */
.llg-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 70;
  background: transparent;
}

.llg-progress__bar {
  height: 100%;
  width: 0%;
  background: var(--accent, #A34A1F);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.02);
}

/* Mobile bar (injected) */
.llg-mobile-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--llg-surface) 85%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--llg-border);
}

@supports not (backdrop-filter: blur(10px)) {
  .llg-mobile-bar {
    background: var(--llg-surface-solid);
  }
}

.llg-mobile-bar__inner {
  max-width: 64rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.llg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: var(--primary, #2A4849);
  color: var(--primary-text-contrast, #FAF8F5);
  font-weight: 800;
  letter-spacing: 0.01em;
}

.llg-btn:focus {
  outline: none;
}

.llg-btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(163, 74, 31, 0.35);
}

.llg-btn--secondary {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

/* Reserve space so the mobile bar doesn't cover content */
@media (max-width: 1023px) {
  [data-longleaf-guide] main {
    padding-bottom: 84px;
  }
}

@media (min-width: 1024px) {
  .llg-mobile-bar {
    display: none;
  }
}

/* Modal (injected) */
.llg-modal[hidden] {
  display: none !important;
}

.llg-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: end center;
  padding: 12px;
}

.llg-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
}

.llg-modal__panel {
  position: relative;
  width: 100%;
  max-width: 42rem;
  max-height: min(80vh, 680px);
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--llg-border);
  background: var(--llg-surface-solid);
  box-shadow: var(--llg-shadow);
}

.llg-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--llg-border);
}

.llg-modal__title {
  font-weight: 900;
  color: var(--primary, #2A4849);
}

.llg-modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  border: 1px solid var(--llg-border);
  background: rgba(42, 72, 73, 0.06);
  color: var(--primary, #2A4849);
}

.llg-modal__close:focus-visible {
  box-shadow: 0 0 0 3px rgba(163, 74, 31, 0.35);
  outline: none;
}

.llg-modal__body {
  overflow: auto;
  padding: 10px 12px 14px;
}

.llg-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--llg-border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.02);
  color: var(--text, #1C2424);
}

.llg-search input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
}

.llg-topic-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.llg-topic {
  display: grid;
  gap: 2px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--llg-border);
  background: rgba(255, 255, 255, 0.9);
}

.llg-topic a {
  color: var(--primary, #2A4849);
  font-weight: 800;
}

.llg-topic a:hover {
  text-decoration: underline;
}

.llg-topic[aria-current="page"] {
  border-color: color-mix(in srgb, var(--accent, #A34A1F) 45%, var(--llg-border));
  box-shadow: 0 10px 24px rgba(163, 74, 31, 0.12);
}

.llg-topic__path {
  font-size: 12px;
  color: rgba(28, 36, 36, 0.62);
}
