/**!
 * @file LessonListPanel.css
 * @desc Shared sidebar "lesson list" panel used on the dictionary, lesson,
 *       curriculum, and vocabulary view pages. ONE style, ONE behavior,
 *       reused everywhere a list of lessons appears in a side rail.
 *
 *       Markup contract:
 *
 *       <section class="ll-panel">
 *         <h3 class="ll-panel__title">Latest Lessons</h3>
 *         <ul class="ll-panel__list">
 *           <li>
 *             <a class="ll-panel__lesson" href="...">
 *               <img class="ll-panel__thumb" src="..." />
 *               <span class="ll-panel__lesson-name">...</span>
 *               <span class="ll-panel__tooltip" role="tooltip">
 *                 <span class="ll-panel__tooltip__card">
 *                   <span class="ll-panel__tooltip__image"><img/></span>
 *                   <span class="ll-panel__tooltip__body">
 *                     <span class="ll-panel__tooltip__title">...</span>
 *                     <span class="ll-panel__tooltip__intro">...</span>
 *                     <span class="ll-panel__tooltip__cta">Read lesson →</span>
 *                   </span>
 *                 </span>
 *               </span>
 *             </a>
 *           </li>
 *         </ul>
 *       </section>
 *
 *       Use --ll-brand to opt out of var(--sw-brand-color) per page if needed.
 */
/************************************************************************************************************************************/

/* ------------------------------------------------------------------ */
/* DESIGN TOKENS                                                       */
/* ------------------------------------------------------------------ */

.ll-panel {
	--ll-brand:      var(--sw-brand-color, #0e6630);
	--ll-brand-dark: #084a22;
	--ll-brand-soft: #e8f3ec;
	--ll-card:       #ffffff;
	--ll-border:     #e0e8e3;
	--ll-ink:        #14211a;
	--ll-ink-soft:   #4a5b51;
	--ll-radius:     14px;
	--ll-shadow-sm:  0 1px 2px rgba(20, 50, 30, 0.04),
	                 0 4px 14px rgba(20, 50, 30, 0.06);
}

/* ------------------------------------------------------------------ */
/* SECTION CARD                                                        */
/* ------------------------------------------------------------------ */

.ll-panel {
	background: var(--ll-card);
	border-radius: var(--ll-radius);
	box-shadow: var(--ll-shadow-sm);
	margin: 0 0 18px 0;
}

.ll-panel:last-child { margin-bottom: 0; }

.ll-panel__title {
	font-size: 0.95rem;
	font-weight: 700;
	color: var(--ll-ink);
	margin: 0;
	padding: 16px 18px 12px 18px;
	background: var(--ll-brand-soft);
	border-bottom: 1px solid var(--ll-border);
	border-radius: var(--ll-radius) var(--ll-radius) 0 0;
}

/* ------------------------------------------------------------------ */
/* LIST + LESSON LINK                                                  */
/* ------------------------------------------------------------------ */

.ll-panel__list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.ll-panel__lesson {
	position: relative;            /* anchor for hovercard tooltip */
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 14px;
	color: var(--ll-ink);
	text-decoration: none;
	font-size: 0.9rem;
	line-height: 1.35;
	border-bottom: 1px solid var(--ll-border);
	transition: background 0.12s ease;
	cursor: pointer;
}

/* Items that DO have a hovercard tooltip get the "?" help cursor so the
   user knows there's extra info available on hover. Items without a
   tooltip stay on the default pointer (hand). */
.ll-panel__lesson:has(.ll-panel__tooltip) {
	cursor: help;
}

.ll-panel__list > li:last-child .ll-panel__lesson {
	border-bottom: none;
	border-radius: 0 0 var(--ll-radius) var(--ll-radius);
}

.ll-panel__lesson:hover {
	background: var(--ll-brand-soft);
	color: var(--ll-brand-dark);
}

/* Current-lesson indicator (used on the lesson view sidebar) */
.ll-panel__lesson--current {
	background: var(--ll-brand-soft);
	color: var(--ll-brand-dark);
	font-weight: 700;
	border-left: 3px solid var(--ll-brand);
	padding-left: 11px;
	cursor: default;
}

.ll-panel__thumb {
	width: 44px;
	height: 44px;
	border-radius: 6px;
	object-fit: cover;
	flex-shrink: 0;
	background: var(--ll-brand-soft);
}

.ll-panel__thumb--placeholder {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--ll-brand);
	font-size: 1.1rem;
}

.ll-panel__lesson-name {
	flex: 1;
	min-width: 0;
	word-break: break-word;
}

/* ------------------------------------------------------------------ */
/* WIKIPEDIA-STYLE HOVERCARD TOOLTIP                                   */
/* Pops to the LEFT of the link (sidebars sit on the right of pages). */
/* Outer span is a transparent layout container that includes a 14px   */
/* right-edge "bridge" so the cursor stays inside the link's hover     */
/* area when moving from the link toward the visible card.             */
/* ------------------------------------------------------------------ */

.ll-panel__tooltip {
	position: absolute;
	right: 100%;
	top: 50%;
	transform: translateY(-50%) translateX(8px);
	width: calc(320px + 14px);
	padding-right: 14px;
	font-size: 0.86rem;
	line-height: 1.55;
	text-align: left;
	color: var(--ll-ink);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
	z-index: 100;
}

.ll-panel__tooltip__card {
	position: relative;
	display: block;
	background: var(--ll-card);
	border: 1px solid rgba(20, 50, 30, 0.1);
	border-radius: 10px;
	box-shadow: 0 14px 36px rgba(20, 50, 30, 0.18),
	            0 2px 6px rgba(20, 50, 30, 0.08);
}

/* Two-layer arrow so the white triangle sits on top of a 1px border */
.ll-panel__tooltip__card::before,
.ll-panel__tooltip__card::after {
	content: "";
	position: absolute;
	left: 100%;
	top: 50%;
	transform: translateY(-50%);
	border-top: 8px solid transparent;
	border-bottom: 8px solid transparent;
}
.ll-panel__tooltip__card::before {
	border-left: 8px solid rgba(20, 50, 30, 0.12);
}
.ll-panel__tooltip__card::after {
	border-left: 8px solid var(--ll-card);
	margin-left: -1px;
}

.ll-panel__tooltip__image {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	background: var(--ll-brand-soft);
	overflow: hidden;
	border-radius: 10px 10px 0 0;
}

.ll-panel__tooltip__image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.ll-panel__tooltip__body {
	display: block;
	padding: 13px 16px 14px 16px;
}

.ll-panel__tooltip__title {
	display: block;
	font-size: 1rem;
	font-weight: 700;
	color: var(--ll-ink);
	margin-bottom: 6px;
	line-height: 1.3;
}

.ll-panel__tooltip__intro {
	display: -webkit-box;
	-webkit-line-clamp: 5;
	-webkit-box-orient: vertical;
	overflow: hidden;
	color: var(--ll-ink-soft);
	font-size: 0.88rem;
	line-height: 1.55;
}

.ll-panel__tooltip__cta {
	display: inline-block;
	margin-top: 10px;
	font-size: 0.84rem;
	font-weight: 600;
	color: var(--ll-brand-dark);
}

@media (hover: hover) {
	.ll-panel__lesson:hover .ll-panel__tooltip {
		opacity: 1;
		visibility: visible;
		transform: translateY(-50%) translateX(0);
		transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s;
	}
	/* Don't show tooltip for the current lesson (lesson view) */
	.ll-panel__lesson--current:hover .ll-panel__tooltip {
		opacity: 0;
		visibility: hidden;
	}
}

/* Hide tooltip when the sidebar drops below the article at narrow widths */
@media (max-width: 1024px) {
	.ll-panel__tooltip { display: none; }
	.ll-panel__lesson  { cursor: default; }
}
