/* ============================================================
   AeroCore Widget Styles for CorePress
   包含：作者信息、文章列表、最新评论、日历、标签云
   ============================================================ */

/* ---- CSS 变量（若 CorePress 主题未定义则使用此兜底值） ---- */
:root {
  --bg-card: #fff;
  --bg-secondary: #f1f5f9;
  --bg-hover: #e2e8f0;
  --bg-skeleton: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --text-muted: #94a3b8;
  --border-primary: #e2e8f0;
  --border-secondary: #e2e8f0;
  --border-radius: 12px;
  --border-radius-sm: 6px;
  --theme-color: #409EFF;
  --theme-color-light: #ecf5ff;
}

/* ============================================================
   作者信息小工具 .author-widget
   ============================================================ */
.author-widget {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 0;
  overflow: visible;
}

.author-widget__header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.author-widget__avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.author-widget__avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border-primary);
  object-fit: cover;
}

.author-widget__info {
  flex: 1;
  min-width: 0;
}

.author-widget__name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.author-widget__admin-badge {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.author-widget__bio {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 16px 0;
}

.author-widget__divider {
  width: 100%;
  height: 1px;
  background: var(--border-secondary);
  margin-bottom: 16px;
}

/* 热力图 */
.author-widget__heatmap {
  margin-top: 16px;
}

.author-widget__heatmap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.author-widget__heatmap-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.author-widget__heatmap-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 4px;
  margin-bottom: 12px;
}

.author-widget__heatmap-cell {
  position: relative;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border-radius: 2px;
  transition: all 0.2s;
}

.author-widget__heatmap-cell[data-tip] {
  cursor: pointer;
}

/* 热力格 tooltip */
.author-widget__heatmap-cell[data-tip]::before,
.author-widget__heatmap-cell[data-tip]::after {
  position: absolute;
  left: 50%;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.16s ease, visibility 0.16s ease, transform 0.16s ease;
  z-index: 20;
}

.author-widget__heatmap-cell[data-tip]::before {
  content: '';
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: rgba(15, 23, 42, 0.92);
  z-index: 19;
}

.author-widget__heatmap-cell[data-tip]::after {
  content: attr(data-tip);
  bottom: calc(100% + 8px);
  transform: translate(-50%, 4px);
  white-space: nowrap;
  font-size: 11px;
  line-height: 1.2;
  color: #fff;
  background: rgba(15, 23, 42, 0.92);
  border-radius: 4px;
  padding: 5px 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.24);
}

.author-widget__heatmap-cell[data-tip]:hover::before,
.author-widget__heatmap-cell[data-tip]:hover::after {
  opacity: 1;
  visibility: visible;
}

.author-widget__heatmap-cell[data-tip]:hover::after {
  transform: translate(-50%, 0);
}

.author-widget__heatmap-cell[data-tip]:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.author-widget__heatmap-cell--level-0 { background: #edf1f5; }
.author-widget__heatmap-cell--level-1 { background: #86efac; }
.author-widget__heatmap-cell--level-2 { background: #4ade80; }
.author-widget__heatmap-cell--level-3 { background: #22c55e; }

.author-widget__heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  font-size: 10px;
  color: var(--text-tertiary);
}

.author-widget__heatmap-legend-items {
  display: flex;
  gap: 3px;
}

.author-widget__heatmap-legend-item {
  width: 10px;
  height: 10px;
  border-radius: 1px;
}

.author-widget__heatmap-legend-item--level-0 { background: #edf1f5; border: 1px solid #e2e8f0; }
.author-widget__heatmap-legend-item--level-1 { background: #86efac; }
.author-widget__heatmap-legend-item--level-2 { background: #4ade80; }
.author-widget__heatmap-legend-item--level-3 { background: #22c55e; }

/* Tab 切换（纯 CSS radio 控制） */
.author-widget__tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 4px;
  border-radius: 10px;
  background: var(--bg-secondary);
}

html:not([data-theme="dark"]) .author-widget__tabs {
  background: #f2f3f5;
}

.author-widget__tab-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.author-widget__tab {
  flex: 1;
  text-align: center;
  font-size: 14px;
  line-height: 1.2;
  color: var(--text-secondary);
  padding: 7px 6px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background 0.2s, color 0.2s;
}

.author-widget__tab-radio:checked + .author-widget__tab {
  background: var(--bg-card);
  color: var(--theme-color);
  font-weight: 600;
}

/* Tab 面板 — 通过 JS 控制 is-active，也支持纯 CSS 控制 */
.author-widget__tab-panels {
  margin-top: 10px;
}

.author-widget__tab-panel {
  display: none;
}

.author-widget__tab-panel.is-active {
  display: block;
}

/* 文章列表 */
.author-widget__good-post-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-secondary);
}

.author-widget__good-post-item:last-child {
  border-bottom: none;
}

.author-widget__good-post-title {
  display: -webkit-box;
  position: relative;
  padding-left: 12px;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}

.author-widget__good-post-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.25em;
  width: 5px;
  height: 1.1em;
  border-radius: 99px;
  background: var(--theme-color);
}

.author-widget__good-post-title:hover {
  color: var(--theme-color);
}

.author-widget__good-post-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.author-widget__good-post-item--empty {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 14px 0;
}

/* 评论列表（发言） */
.author-widget__speech-item {
  background: var(--bg-secondary);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.author-widget__speech-item:last-child {
  margin-bottom: 0;
}

html:not([data-theme="dark"]) .author-widget__speech-item {
  background: #f2f3f5;
}

.author-widget__speech-title {
  display: -webkit-box;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 400;
  color: var(--theme-color);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}

.author-widget__speech-title a {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.2s;
}

.author-widget__speech-title a:hover {
  opacity: 0.85;
}

.author-widget__speech-content {
  display: -webkit-box;
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}

.author-widget__speech-item--empty {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 14px 0;
}

/* ============================================================
   文章列表小工具 .aerocore-widget-post-list
   ============================================================ */
.aerocore-widget-post-list {
  display: block;
  width: 100%;
}

.aerocore-widget-post-list .widget-post-item {
  display: flex;
  gap: 10px;
  margin: 10px 0;
  font-size: 14px;
  position: relative;
  align-items: center;
}

.aerocore-widget-post-list .widget-post-item .post-main {
  flex: 1;
  min-width: 0;
}

.aerocore-widget-post-list .widget-post-item .post-main > a {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-primary);
  text-decoration: none;
}

.aerocore-widget-post-list .widget-post-item .post-main > a:hover {
  color: var(--theme-color);
}

.aerocore-widget-post-list .widget-post-item:hover img {
  transform: scale(1.1);
}

.aerocore-widget-post-list .widget-post-item .widget-post-item-index {
  position: absolute;
  top: 10px;
  padding-right: 5px;
  left: -12px;
  text-align: right;
  width: 30px;
  background-color: #818b95;
  border-radius: 2px 8px 8px 2px;
  color: #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
  z-index: 20;
}

.aerocore-widget-post-list .widget-post-item:first-child .widget-post-item-index { background: #f56c6c; }
.aerocore-widget-post-list .widget-post-item:nth-child(2) .widget-post-item-index { background: #ffa41b; }
.aerocore-widget-post-list .widget-post-item:nth-child(3) .widget-post-item-index { background: #409eff; }

.aerocore-widget-post-list .widget-post-info {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
  text-align: right;
}

.aerocore-widget-post-list .widget-post-info a {
  color: var(--text-tertiary);
  text-decoration: none;
}

.aerocore-widget-post-list .post-thumbnail {
  width: 96px;
  height: 60px;
  flex-shrink: 0;
  border-radius: var(--border-radius-sm, 6px);
  overflow: hidden;
}

.aerocore-widget-post-list .post-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: 0.3s;
}

/* 首篇大图样式 */
.aerocore-widget-post-list .widget-post-item-first {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--border-radius-sm, 6px);
  margin-bottom: 10px;
}

.aerocore-widget-post-list .widget-post-item-first .widget-post-title-warp {
  position: absolute;
  background: rgba(0, 0, 0, 0.3);
  width: 100%;
  padding: 10px;
  bottom: 3px;
  border-radius: 0 0 var(--border-radius-sm, 6px) var(--border-radius-sm, 6px);
  overflow: hidden;
}

.aerocore-widget-post-list .widget-post-item-first .widget-post-title-warp > a {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}

.aerocore-widget-post-list .widget-post-item-first .widget-post-title-warp a {
  color: #fff;
  text-decoration: none;
}

.aerocore-widget-post-list .widget-post-item-first img {
  width: 100%;
  height: auto;
  max-height: 160px;
  object-fit: cover;
  border-radius: var(--border-radius-sm, 6px);
  overflow: hidden;
  transition: 0.3s;
}

/* 纯文字列表 */
.aerocore-widget-post-list .post-item-list {
  font-size: 15px;
  align-items: center;
  padding-bottom: 10px;
  padding-left: 8px;
  border-bottom: 1px solid var(--border-secondary, #f3f3f3);
}

.aerocore-widget-post-list .post-item-list:last-child {
  border-bottom: none;
}

.aerocore-widget-post-list .post-item-list > a {
  font-size: 14px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
  color: var(--text-primary);
  text-decoration: none;
}

.aerocore-widget-post-list .post-item-list > a:hover {
  color: var(--theme-color);
}

.aerocore-widget-post-list .post-item-list::before {
  content: '';
  width: 8px;
  background-color: #d7d7d7;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
}

/* 侧边栏容器修复 */
.aside-box .author-widget,
.aside-box .aerocore-widget-post-list,
.aside-box .aerocore-tag-cloud {
  padding: 0;
  margin: 0;
}

/* ============================================================
   最新评论小工具 .aerocore-comments
   ============================================================ */
.aerocore-comments__item {
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-secondary, #f1f5f9);
  padding-bottom: 10px;
  font-size: 14px;
}

.aerocore-comments__item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.aerocore-comments__header {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.aerocore-comments__header img {
  height: 32px;
  width: 32px;
  border-radius: 50%;
  vertical-align: middle;
  flex-shrink: 0;
}

.aerocore-comments__author-info {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  user-select: none;
}

.aerocore-comments__author-info > div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-size: 14px;
}

.aerocore-comments__date {
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.aerocore-comments__content {
  position: relative;
  padding: 10px;
  margin: 10px 0;
  background: var(--bg-secondary, #f8fafc);
  border-radius: var(--border-radius-sm, 6px);
  color: var(--text-secondary);
  font-size: 14px;
}

.aerocore-comments__content::before {
  position: absolute;
  left: 10px;
  top: -9px;
  content: "";
  width: 0;
  height: 0;
  line-height: 0;
  border: 5px solid transparent;
  border-bottom-color: var(--bg-secondary, #f8fafc);
}

.aerocore-comments__content img {
  width: 24px;
  height: 24px;
  vertical-align: middle;
}

.aerocore-comments__text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  word-wrap: break-word;
  line-height: 1.6;
}

.aerocore-comments__from {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}

.aerocore-comments__from a {
  color: var(--text-muted);
  text-decoration: none;
}

.aerocore-comments__from a:hover {
  color: var(--theme-color);
}

.aerocore-comments__empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px 0;
}

/* 评论表情图片（由 corepress_comment_face / renderFace 生成） */
.aerocore-comments__content .comment-face,
.aerocore-comments__content img {
  display: inline-block;
  width: 24px;
  height: 24px;
  vertical-align: middle;
  margin: 0 1px;
}

/* ============================================================
   日历小工具 .aerocore-calendar
   ============================================================ */
.aerocore-calendar {
  --calendar-bg: #33393b;
  --calendar-text: #f8fafc;
  --calendar-month: #ffffff;
  --calendar-muted: #7d8182;
  --calendar-dim: #505557;
  --calendar-nav-hover-bg: rgba(255, 255, 255, 0.08);
  --calendar-hover-bg: rgba(255, 255, 255, 0.1);
  --calendar-hover-text: #ffffff;
  --calendar-loading-bg: rgba(51, 57, 59, 0.72);
  --calendar-loading-text: rgba(255, 255, 255, 0.9);
  --calendar-dot-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
  position: relative;
  background: var(--calendar-bg);
  border-radius: var(--border-radius, 8px);
  padding: 20px 16px 14px;
  color: var(--calendar-text);
  overflow: hidden;
  min-height: 344px;
}

.aerocore-calendar.aerocore-calendar--light {
  --calendar-bg: #ffffff;
  --calendar-text: #334155;
  --calendar-month: #1e293b;
  --calendar-muted: #64748b;
  --calendar-dim: #cbd5e1;
  --calendar-nav-hover-bg: #f1f5f9;
  --calendar-hover-bg: #f1f5f9;
  --calendar-hover-text: #1e293b;
  --calendar-loading-bg: rgba(255, 255, 255, 0.82);
  --calendar-loading-text: #64748b;
  --calendar-dot-shadow: 0 0 0 1px rgba(15, 23, 42, 0.14);
}

html[data-theme="dark"] .aerocore-calendar {
  --calendar-bg: #33393b;
  --calendar-text: #f8fafc;
  --calendar-month: #ffffff;
  --calendar-muted: #7d8182;
  --calendar-dim: #505557;
  --calendar-nav-hover-bg: rgba(255, 255, 255, 0.08);
  --calendar-hover-bg: rgba(255, 255, 255, 0.1);
  --calendar-hover-text: #ffffff;
  --calendar-loading-bg: rgba(51, 57, 59, 0.72);
  --calendar-loading-text: rgba(255, 255, 255, 0.9);
  --calendar-dot-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.aerocore-calendar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.aerocore-calendar__month-year {
  font-size: 24px;
  font-weight: 500;
  color: var(--calendar-month);
  line-height: 1.2;
}

.aerocore-calendar__nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.aerocore-calendar__nav-btn {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--border-radius-sm, 6px);
  background: transparent;
  color: var(--calendar-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s, color 0.2s;
}

.aerocore-calendar__nav-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.aerocore-calendar__nav-btn:hover {
  color: var(--calendar-month);
  background: var(--calendar-nav-hover-bg);
}

.aerocore-calendar__nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.aerocore-calendar__weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin-bottom: 10px;
  gap: 6px 0;
  text-align: center;
}

.aerocore-calendar__weekdays div {
  font-size: 11px;
  font-weight: 600;
  color: var(--calendar-muted);
  letter-spacing: 0.08em;
}

.aerocore-calendar__days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px 0;
  min-height: 220px;
  align-content: start;
}

.aerocore-calendar__day-cell {
  position: relative;
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--calendar-text);
  user-select: none;
}

.aerocore-calendar__day-cell.is-clickable {
  cursor: pointer;
  transition: background 0.18s, color 0.18s, transform 0.18s;
}

.aerocore-calendar__day-cell.is-clickable:not(.is-today):hover {
  background: var(--calendar-hover-bg);
  color: var(--calendar-hover-text);
  transform: translateY(-1px);
}

.aerocore-calendar__day-cell.is-dimmed {
  color: var(--calendar-dim);
}

.aerocore-calendar__day-cell.is-today {
  background: #4db6ac;
  color: #fff;
}

.aerocore-calendar__day-num {
  line-height: 1;
}

/* 日历发帖热度小点 */
.aerocore-calendar__dot {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  box-shadow: var(--calendar-dot-shadow);
}

.aerocore-calendar__dot--low    { background: #ffb74d; }
.aerocore-calendar__dot--medium { background: #9575cd; }
.aerocore-calendar__dot--high   { background: #ef5350; }

/* 日历链接 */
.aerocore-calendar__day-cell a {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: inherit;
}

/* 加载遮罩 */
.aerocore-calendar__loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--calendar-loading-bg);
  color: var(--calendar-loading-text);
  font-size: 13px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s, visibility 0.2s;
}

.aerocore-calendar.aerocore-calendar--loading .aerocore-calendar__loading {
  opacity: 1;
  visibility: visible;
}

/* ============================================================
   标签云 .aerocore-tag-cloud
   ============================================================ */
.aerocore-tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.aerocore-tag-cloud__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
  font-size: 14px;
  font-weight: 400;
  transition: transform 0.2s, color 0.2s, background-color 0.2s, border-color 0.2s;
}

.aerocore-tag-cloud__item:hover {
  transform: translateY(-1px);
  border-color: var(--theme-color, #ff6b35);
  color: var(--theme-color, #ff6b35);
}

.aerocore-tag-cloud__item--level-4 {
  border-color: var(--theme-color, #ff6b35);
  color: var(--theme-color, #ff6b35);
  background: var(--bg-card);
}

.aerocore-tag-cloud__item--level-5,
.aerocore-tag-cloud__item--top {
  border-color: var(--theme-color, #ff6b35);
  color: #fff;
  background: var(--theme-color, #ff6b35);
}

.aerocore-tag-cloud__item--level-5:hover,
.aerocore-tag-cloud__item--top:hover {
  color: #fff;
  opacity: 0.92;
}

.aerocore-tag-cloud__empty {
  font-size: 13px;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .aerocore-tag-cloud {
    gap: 10px;
  }
  .aerocore-tag-cloud__item {
    padding: 6px 8px;
    border-radius: 10px;
  }
}

/* ============================================================
   跟随滚动动画
   ============================================================ */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
