/* ============================================================
   ENVIRO-SMART BLOG READER — widget styles
   Layout C: header strip, hero (play + title), progress, mode
   toggle, karaoke panel, then collapsible settings.
   ============================================================ */

.ebr-card {
  --ebr-bg: #ffffff;
  --ebr-primary: var(--green-dark, #2a6b1f);
  --ebr-accent: var(--gold, #e8a020);
  --ebr-ink: var(--dark, #1a1a1a);
  --ebr-highlight: #f4c764;
  background: var(--ebr-bg);
  color: var(--ebr-ink);
  border: 1px solid rgba(42, 107, 31, 0.12);
  border-radius: 18px;
  box-shadow: 0 16px 34px rgba(23, 43, 17, 0.08);
  font-family: inherit, Segoe UI, Arial, sans-serif;
  margin: 0;
  padding: 0;
}

/* ── Header strip ─────────────────────────────────────────── */
.ebr-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 6px;
  border-bottom: 1px solid rgba(42, 107, 31, 0.08);
  margin-bottom: 12px;
}
.ebr-label {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 1.5px;
}

/* ── Hero strip: play + title ─────────────────────────────── */
.ebr-card__hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
}
.ebr-card__title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.ebr-card__title strong {
  color: #173015;
  font-size: 1.12rem;
  line-height: 1.2;
}
.ebr-status {
  color: #5a6657;
  font-size: 0.78rem;
}

/* ── Buttons (reset browser/theme padding aggressively) ──── */
.ebr-card .ebr-button,
.ebr-card .ebr-expand,
.ebr-card .ebr-back,
.ebr-card .ebr-regenerate {
  border: 1px solid rgba(42, 107, 31, 0.22);
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  padding: 0;
  margin: 0;
  line-height: 1;
}

/* Big primary play button */
.ebr-card .ebr-button {
  width: 3rem;
  height: 3rem;
  background: var(--ebr-primary);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: none;
  position: relative;
}
.ebr-card .ebr-button:hover { background: #1f5217; }
.ebr-card .ebr-button .ebr-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.ebr-card .ebr-button .ebr-icon[hidden] { display: none; }
.ebr-card .ebr-button .ebr-icon svg {
  width: 1.75rem !important;
  height: 1.75rem !important;
  display: block;
  color: #ffffff;
  stroke: currentColor;
}
.ebr-icon--loading svg { animation: ebr-spin 1s linear infinite; }
@keyframes ebr-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Settings gear button */
.ebr-card .ebr-expand {
  width: 2rem;
  height: 2rem;
  background: transparent;
  color: var(--ebr-primary);
  border: 1px solid rgba(42, 107, 31, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ebr-card .ebr-expand:hover {
  background: rgba(42, 107, 31, 0.06);
  color: #1f5217;
}
.ebr-card .ebr-expand .ebr-chevron {
  width: 1.1rem !important;
  height: 1.1rem !important;
  display: block;
  color: currentColor;
  stroke: currentColor;
  transition: transform 220ms ease;
}
.ebr-card .ebr-expand[aria-expanded="true"] {
  background: var(--ebr-primary);
  color: #ffffff;
  border-color: var(--ebr-primary);
}
.ebr-card .ebr-expand[aria-expanded="true"] .ebr-chevron { transform: rotate(45deg); }

/* ── Progress bar row ─────────────────────────────────────── */
.ebr-progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 0;
}
.ebr-card .ebr-scrub {
  flex: 1;
  width: auto;
  margin: 0;
  accent-color: var(--ebr-primary);
}
.ebr-progress {
  font-size: 0.78rem;
  color: #5a6657;
  font-variant-numeric: tabular-nums;
  min-width: 2.6rem;
  text-align: right;
}

/* ── Mode toggle row ──────────────────────────────────────── */
.ebr-mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px 0;
}
.ebr-mode-switch {
  display: inline-flex;
  background: #eef2ec;
  border: 1px solid rgba(42, 107, 31, 0.18);
  border-radius: 999px;
  padding: 3px;
}
.ebr-card .ebr-mode-btn {
  border: none;
  background: transparent;
  color: #5a6657;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
  line-height: 1.2;
}
.ebr-card .ebr-mode-btn:hover { color: var(--ebr-primary); }
.ebr-card .ebr-mode-btn.is-active {
  background: var(--ebr-primary);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.ebr-card .ebr-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  color: var(--ebr-primary);
  padding: 5px 10px;
  font-weight: 600;
  font-size: 0.78rem;
}
.ebr-card .ebr-back:hover { background: rgba(42, 107, 31, 0.06); }
.ebr-card .ebr-back svg {
  width: 0.95rem !important;
  height: 0.95rem !important;
  color: currentColor;
  stroke: currentColor;
}

/* ── Now reading karaoke ──────────────────────────────────── */
.ebr-now-reading {
  background: #173015;
  border-radius: 10px;
  color: rgba(232, 244, 226, 0.78);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.97rem;
  line-height: 1.6;
  margin: 14px 18px 0;
  padding: 14px 16px 24px;
  text-align: left;
  max-height: 11em;
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 160, 32, 0.4) transparent;
}
.ebr-now-reading[hidden] { display: none; }
.ebr-now-reading__label {
  display: block;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--ebr-accent);
  margin-bottom: 8px;
  opacity: 0.75;
}
.ebr-now-reading__body { display: block; word-spacing: 0.04em; }
.ebr-rw-word { transition: background 70ms, color 70ms, box-shadow 70ms; }
.ebr-rw-word.ebr-rw-current {
  background: var(--ebr-accent);
  color: #1a1a1a;
  border-radius: 3px;
  /* box-shadow spread mimics padding visually with zero layout impact —
     no font-weight or padding change so surrounding words never shift */
  box-shadow: 0 0 0 3px var(--ebr-accent);
}
.ebr-now-reading::-webkit-scrollbar { width: 6px; }
.ebr-now-reading::-webkit-scrollbar-thumb { background: rgba(232, 160, 32, 0.4); border-radius: 3px; }
.ebr-now-reading::-webkit-scrollbar-track { background: transparent; }

/* ── Settings drawer (gear opens this) ────────────────────── */
.ebr-controls {
  margin-top: 14px;
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(26, 26, 26, 0.08);
  background: #fafbf8;
  border-radius: 0 0 18px 18px;
  display: grid;
  gap: 12px;
}
.ebr-controls[hidden] { display: none; }
.ebr-controls label {
  display: grid;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #173015;
}
.ebr-controls select {
  background: #ffffff;
  border: 1px solid rgba(42, 107, 31, 0.22);
  border-radius: 6px;
  color: #1a1a1a;
  min-height: 2.2rem;
  padding: 0.25rem 0.45rem;
  font: inherit;
}
.ebr-card .ebr-regenerate {
  background: #fff;
  color: var(--ebr-primary);
  padding: 8px 12px;
  font-weight: 700;
  font-size: 0.85rem;
}
.ebr-card .ebr-regenerate:hover { background: rgba(42, 107, 31, 0.06); }
.ebr-controls small { color: #6a7660; font-size: 0.72rem; }

/* Add bottom padding to card when controls are closed */
.ebr-card:not(:has(.ebr-now-reading:not([hidden]))):not(:has(.ebr-controls:not([hidden]))) {
  padding-bottom: 14px;
}

/* ── Article-body word highlight (Main mode) ──────────────── */
/* Rule: never change padding, font-weight, font-size, or border on the
   highlighted span — any of those shift adjacent words horizontally.
   box-shadow is outside the layout engine (inset = inside the box),
   so it creates underlines and glows without moving anything. */
span.ebr-word.is-current,
.ebr-word.is-current {
  background: rgba(232, 160, 32, 0.18);
  border-radius: 2px;
  /* amber underline via inset shadow — zero layout impact */
  box-shadow: inset 0 -2px 0 var(--ebr-accent);
  color: #173015;
  transition: background 0.07s, box-shadow 0.07s, color 0.07s;
}
[data-ebr-segment].is-current-segment {
  background: rgba(244, 199, 100, 0.1);
  border-radius: 6px;
}
[data-ebr-segment] {
  scroll-margin-top: calc(var(--es-sticky-top, 0px) + var(--es-header-offset, 110px) + 24px);
}

@media (max-width: 1100px) {
  .ebr-card { margin-top: 0; }
}


/* Indeterminate progress bar shown while audio is being generated */
.ebr-prep-progress {
  height: 3px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
  position: relative;
  width: 100%;
}
.ebr-prep-progress[hidden] { display: none; }
/* Fill mode: used during async background generation */
.ebr-prep-progress--fill .ebr-prep-progress__bar {
  animation: none;
  left: 0;
  width: 0%;
  transition: width 0.5s linear;
}
.ebr-prep-progress__bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 35%;
  background: var(--ebr-accent, #e8a020);
  border-radius: 2px;
  animation: ebr-prep-slide 1.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes ebr-prep-slide {
  0%   { left: -35%; }
  100% { left: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .ebr-prep-progress__bar {
    animation: ebr-prep-pulse 1.6s ease-in-out infinite;
    width: 100%;
    left: 0;
  }
  @keyframes ebr-prep-pulse {
    0%, 100% { opacity: 0.35; }
    50%      { opacity: 1; }
  }
}

/* ── Mobile-inline reader (moved out of sidebar into body) ─── */
.ebr-card--mobile-inline {
    margin: 24px 0 32px;
}

/* ============================================================
   Mobile sticky mini-controller
   Big buttons, plain text labels, predictable behavior.
   Hidden by default; .is-visible slides it up from bottom.
   Only ever shown on ≤1100px viewports (set via JS).
   ============================================================ */
.ebr-mini {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    display: flex;
    align-items: stretch;
    gap: 0;
    background: var(--green-deep, #1e3d14);
    color: #fff;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.25);
    border-top: 3px solid var(--gold, #e8a020);
    transform: translateY(100%);
    transition: transform 280ms ease-out;
    pointer-events: none;
    font-family: 'Segoe UI', Arial, sans-serif;
}
.ebr-mini.is-visible {
    transform: translateY(0);
    pointer-events: auto;
}
/* Desktop never shows the mini bar */
@media (min-width: 1101px) {
    .ebr-mini { display: none !important; }
}

.ebr-mini__btn {
    background: transparent;
    color: #fff;
    border: none;
    padding: 12px 18px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 80px;
    min-height: 64px;
    font-family: inherit;
    font-weight: 700;
    transition: background-color 160ms ease;
}
.ebr-mini__btn:hover,
.ebr-mini__btn:focus-visible {
    background: rgba(255, 255, 255, 0.08);
    outline: none;
}
.ebr-mini__btn--play {
    background: var(--gold, #e8a020);
    color: var(--green-deep, #1e3d14);
}
.ebr-mini__btn--play:hover,
.ebr-mini__btn--play:focus-visible {
    background: #d28e15;
    color: var(--green-deep, #1e3d14);
}

.ebr-mini__icon {
    font-size: 1.5rem;
    line-height: 1;
}
.ebr-mini__txt {
    font-size: 0.7rem;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

.ebr-mini__center {
    flex: 1;
    min-width: 0;
    background: transparent;
    color: #fff;
    border: none;
    padding: 12px 14px 14px;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    transition: background-color 160ms ease;
}
.ebr-mini__center:hover,
.ebr-mini__center:focus-visible {
    background: rgba(255, 255, 255, 0.06);
    outline: none;
}
.ebr-mini__title {
    display: block;
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.25;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ebr-mini__sub {
    display: block;
    font-size: 0.7rem;
    color: var(--gold, #e8a020);
    letter-spacing: 0.5px;
    line-height: 1.1;
}
.ebr-mini__progress {
    display: block;
    height: 3px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}
.ebr-mini__bar {
    display: block;
    height: 100%;
    background: var(--gold, #e8a020);
    width: 0%;
    transition: width 200ms linear;
}

/* Avoid content being hidden behind the bar when it appears */
.ebr-mini.is-visible ~ * { /* not used; left as a hook */ }
@media (max-width: 1100px) {
    body.ebr-mini-visible {
        padding-bottom: 80px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ebr-mini { transition: none; }
    .ebr-mini__bar { transition: none; }
}
