/* =============================================================================
   YGT Article Tools Toolbar — article-tools.css
   Scoped under .ygt-at-* to avoid collisions with the theme.
   The FOUC shield (.ygt-speed-read, .ygt-toc, .ygt-tr-switcher hide) is in
   the inline wp_head style; this file handles the toolbar + panel aesthetics.
   ============================================================================= */

/* ---------------------------------------------------------------------------
   CSS custom properties — scoped to the toolbar wrapper
   --------------------------------------------------------------------------- */
.ygt-at-wrap {
  --at-orange:        #f26522;
  --at-orange-dark:   #c2410c;
  --at-orange-tint:   #fff7ed;
  --at-orange-tint2:  #ffedd5;
  --at-orange-border: #fed7aa;
  --at-border:        #e6e6e6;
  --at-bg:            #ffffff;
  --at-surface:       #f9f9f9;
  --at-text:          #1a1a1a;
  --at-muted:         #6b7280;
  --at-shadow-md:     0 4px 16px rgba(0,0,0,.10);
  --at-transition:    220ms ease;
  --at-toolbar-h:     52px;
  --at-radius-chip:   100px;
}

/* ---------------------------------------------------------------------------
   Sticky wrapper
   --------------------------------------------------------------------------- */
.ygt-at-wrap {
  /* v1: non-sticky to avoid conflicting with the theme's own sticky header and
     the awkward "tall sticky block" when a large panel (Speed Read) is open.
     Sticky can be reintroduced later by making ONLY the toolbar row sticky. */
  position: relative;
  z-index: 200;
  background: #ffffff;
  transition: box-shadow var(--at-transition);
}

.ygt-at-wrap.ygt-at-stuck {
  box-shadow: 0 2px 12px rgba(0,0,0,.10);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: rgba(255,255,255,.93);
}

/* ---------------------------------------------------------------------------
   Toolbar row
   --------------------------------------------------------------------------- */
.ygt-at-toolbar {
  height: var(--at-toolbar-h);
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--at-border);
  /* overflow visible so the lang dropdown is never clipped */
  overflow: visible;
}

/* Left chips scroll horizontally on narrow screens; the lang pill stays
   outside this scroller so its dropdown is never overflow-clipped. */
.ygt-at-scroll {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 0 1 auto;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}
.ygt-at-scroll::-webkit-scrollbar { display: none; }

/* Spacer pushes lang pill to the right */
.ygt-at-spacer {
  flex: 1 1 auto;
  min-width: 8px;
}

/* ---------------------------------------------------------------------------
   Chip buttons
   --------------------------------------------------------------------------- */
.ygt-at-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
  height: 34px;
  padding: 0 13px;
  border-radius: var(--at-radius-chip);
  border: 1.5px solid var(--at-border);
  background: var(--at-bg);
  color: var(--at-text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background var(--at-transition),
    border-color var(--at-transition),
    color var(--at-transition);
  user-select: none;
  line-height: 1;
}

.ygt-at-chip:hover {
  border-color: var(--at-orange);
  color: var(--at-orange-dark);
  background: var(--at-orange-tint);
}

.ygt-at-chip[aria-expanded="true"],
.ygt-at-chip.ygt-at-active {
  background: var(--at-orange);
  border-color: var(--at-orange);
  color: #ffffff;
}

.ygt-at-chip:focus-visible {
  outline: 2px solid var(--at-orange);
  outline-offset: 2px;
}

/* Chip icon */
.ygt-at-chip-icon {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  flex-shrink: 0;
}
.ygt-at-chip-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* Chip chevron */
.ygt-at-chip-chevron {
  display: inline-flex;
  align-items: center;
  opacity: .7;
  transition: transform var(--at-transition);
  flex-shrink: 0;
}
.ygt-at-chip-chevron svg {
  width: 11px;
  height: 11px;
  display: block;
}
.ygt-at-chip[aria-expanded="true"] .ygt-at-chip-chevron {
  transform: rotate(180deg);
  opacity: 1;
}

/* ---------------------------------------------------------------------------
   Language chip (right-aligned, has its own dropdown)
   --------------------------------------------------------------------------- */
.ygt-at-lang-wrap {
  position: relative;
  flex-shrink: 0;
}

.ygt-at-lang-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 11px;
  border-radius: var(--at-radius-chip);
  border: 1.5px solid var(--at-border);
  background: var(--at-bg);
  color: var(--at-muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--at-transition), color var(--at-transition);
  white-space: nowrap;
  line-height: 1;
}
.ygt-at-lang-chip:hover {
  border-color: var(--at-orange);
  color: var(--at-orange-dark);
}
.ygt-at-lang-chip:focus-visible {
  outline: 2px solid var(--at-orange);
  outline-offset: 2px;
}
.ygt-at-lang-chip svg {
  width: 12px;
  height: 12px;
  opacity: .7;
  flex-shrink: 0;
}

/* Language dropdown */
.ygt-at-lang-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--at-bg);
  border: 1px solid var(--at-border);
  border-radius: 8px;
  box-shadow: var(--at-shadow-md);
  min-width: 140px;
  overflow: hidden;
  z-index: 300;
  /* hidden by default */
  display: none;
}
.ygt-at-lang-dropdown.ygt-at-open {
  display: block;
}

/* ---------------------------------------------------------------------------
   Collapsible panels — collapsed by default, animated open
   --------------------------------------------------------------------------- */
.ygt-at-panel {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition:
    max-height 240ms ease,
    opacity 200ms ease;
  /* Panels sit directly under the toolbar inside the sticky wrap */
}

.ygt-at-panel.ygt-at-panel-open {
  /* 800px is generous; real content is always shorter */
  max-height: 800px;
  opacity: 1;
}

/* The Language panel wraps the translate switcher, whose OWN dropdown opens
   downward as an absolutely-positioned menu. Let it escape the panel's overflow
   clip once the panel is open so the language list is never cut off. */
#ygt-at-panel-lang.ygt-at-panel-open {
  overflow: visible;
}

/* ---------------------------------------------------------------------------
   Listen panel — wraps the existing .ygt-tts element
   --------------------------------------------------------------------------- */
.ygt-at-listen-panel-inner {
  border-bottom: 1px solid var(--at-border);
  padding: 10px 0 12px;
}

/* Ensure the TTS player element itself doesn't add extra outer margin */
.ygt-at-listen-panel-inner .ygt-tts {
  margin: 0 !important;
  padding: 0 !important;
  display: block !important; /* un-hide it once inside our panel */
}

/* ---------------------------------------------------------------------------
   Summary / Speed Read panel — wraps the existing .ygt-speed-read element
   --------------------------------------------------------------------------- */
.ygt-at-summary-panel-inner {
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--at-border);
}

/* Let the existing Speed Read box render naturally inside the panel */
.ygt-at-summary-panel-inner .ygt-speed-read {
  display: block !important;
  margin-top: 0 !important;
}

/* ---------------------------------------------------------------------------
   Contents / TOC panel — wraps the existing nav.ygt-toc element
   --------------------------------------------------------------------------- */
.ygt-at-toc-panel-inner {
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--at-border);
}

.ygt-at-toc-panel-inner .ygt-toc {
  display: block !important;
  margin-top: 0 !important;
}

/* ---------------------------------------------------------------------------
   Language panel — wraps the existing .ygt-tr-switcher
   --------------------------------------------------------------------------- */
.ygt-at-lang-panel-inner {
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--at-border);
}

.ygt-at-lang-panel-inner .ygt-tr-switcher {
  display: block !important;
  margin-top: 0 !important;
}

/* ---------------------------------------------------------------------------
   Trending banner slim-down (.ygt-breaking stays in place, just restyled)
   --------------------------------------------------------------------------- */
.ygt-breaking {
  font-size: 12.5px !important;
  padding-top: 6px !important;
  padding-bottom: 6px !important;
  line-height: 1.3 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ygt-breaking .ygt-breaking__label--trending,
.ygt-breaking .ygt-breaking__label {
  font-size: 11px !important;
  padding: 2px 8px !important;
}

/* ---------------------------------------------------------------------------
   Mobile (< 768px)
   --------------------------------------------------------------------------- */
@media (max-width: 767px) {
  .ygt-at-chip {
    height: 38px;
    padding: 0 12px;
    font-size: 13px;
    /* Larger tap target */
    min-width: 40px;
    justify-content: center;
  }

  /* Prevent any horizontal overflow from our wrapper on mobile */
  .ygt-at-wrap {
    max-width: 100%;
    overflow: visible;
  }

  .ygt-at-toolbar {
    gap: 4px;
    padding-right: 2px;
  }

  .ygt-at-scroll {
    /* Momentum scrolling on iOS */
    -webkit-overflow-scrolling: touch;
  }

  .ygt-at-lang-dropdown {
    /* On very narrow screens ensure dropdown doesn't overflow viewport */
    right: 0;
    max-width: calc(100vw - 20px);
  }
}

/* ---------------------------------------------------------------------------
   Reduced motion
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .ygt-at-panel {
    transition: none;
  }
  .ygt-at-chip,
  .ygt-at-chip-chevron,
  .ygt-at-wrap,
  .ygt-at-lang-chip {
    transition: none;
  }
}
