/*
Theme Name: Kewei Oil Painting Gallery
Theme URI: https://example.com
Author: Kewei Wang
Author URI: https://example.com
Description: 一个为油画作品设计的极简瀑布流画廊主题，支持 21:9 宽屏展示与全屏大图浏览。
Version: 1.0.0
Text Domain: kewei-gallery
*/

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #05070b;
  color: #f5f5f5;
}

/* 主内容与底部一体，避免被撑到页面最底部 */
.kg-site-body {
  display: block;
  min-height: 0;
  flex: 0 0 auto;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  opacity: 0.85;
}

.kg-site-header {
  position: sticky;
  top: 0;
  z-index: 900;
  padding: 16px 4vw 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(5, 7, 11, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
}

body.admin-bar .kg-site-header {
  top: 32px;
}

@media (max-width: 782px) {
  body.admin-bar .kg-site-header {
    top: 46px;
  }
}

/* 工具栏：隐藏左侧 WordPress 图标与右侧通知铃铛 */
#wpadminbar #wp-admin-bar-wp-logo,
#wpadminbar #wp-admin-bar-notifications {
  display: none !important;
}

.kg-site-header-left {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
}

.kg-site-header-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kg-site-logo {
  flex-shrink: 0;
  height: 2.8em;
  line-height: 0;
  display: flex;
  align-items: center;
}

.kg-site-logo a,
.kg-site-logo img {
  display: block;
  height: 100%;
  width: auto;
  max-height: 2.8em;
  object-fit: contain;
}

.kg-site-logo a {
  line-height: 0;
}

.kg-site-title {
  font-size: 1.4rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.kg-site-desc {
  font-size: 0.9rem;
  color: #999;
}

@media (max-width: 640px) {
  .kg-site-title {
    font-size: 1.1rem;
    letter-spacing: 0.08em;
  }

  .kg-site-desc {
    font-size: 0.75rem;
  }

  .kg-site-header-left {
    gap: 10px;
  }

  .kg-site-logo,
  .kg-site-logo a,
  .kg-site-logo img {
    max-height: 2.4em;
  }
}

.kg-site-header-nav .kg-nav-list {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 22px;
  margin: 0;
  padding: 4px 0 0 32px;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
}

.kg-site-header-nav .kg-nav-list::-webkit-scrollbar {
  display: none;
}

.kg-nav-list a {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #ddd;
  white-space: nowrap;
  font-family: inherit;
}

.kg-nav-list a:hover {
  color: #fff;
}

.kg-site-header-nav .menu-item {
  position: relative;
}

.kg-site-header-nav .sub-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin: 6px 0 0;
  padding: 6px 10px;
  list-style: none;
  background: rgba(5, 7, 11, 0.98);
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  display: none;
  min-width: 150px;
}

.kg-site-header-nav .sub-menu li {
  padding: 4px 0;
}

.kg-site-header-nav .sub-menu a {
  letter-spacing: 0.08em;
  text-transform: none;
  font-size: 0.72rem;
}

.kg-site-header-nav .menu-item:hover > .sub-menu,
.kg-site-header-nav .menu-item:focus-within > .sub-menu {
  display: block;
}

.kg-main {
  padding: 0 0 24px;
  flex: none;
}

/* 网站底部：紧贴正文/相关内容下方，不贴页面最底 */
.kg-site-footer {
  margin-top: 12px;
  padding: 18px 4vw 22px;
  background: rgba(5, 7, 11, 0.98);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.kg-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  text-align: center;
}

.kg-footer-nav {
  width: 100%;
}

.kg-footer-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.kg-footer-list a {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: #aaa;
  text-decoration: none;
}

.kg-footer-list a:hover {
  color: #fff;
}

.kg-footer-info {
  font-size: 0.8rem;
  color: #888;
  line-height: 1.6;
}

.kg-footer-copyright {
  margin-bottom: 4px;
}

.kg-footer-extra {
  color: #777;
}

.kg-footer-extra a {
  color: #999;
  text-decoration: none;
}

.kg-footer-extra a:hover {
  color: #fff;
}

@media (max-width: 640px) {
  .kg-site-footer {
    margin-top: 16px;
    padding: 16px 12px 20px;
  }

  .kg-footer-list {
    gap: 6px 16px;
  }

  .kg-footer-list a,
  .kg-footer-info {
    font-size: 0.75rem;
  }
}

/* 右下角：回到顶部按钮 */
.kg-back-to-top {
  position: fixed;
  right: 18px;
  bottom: 22px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(8, 11, 20, 0.9);
  color: #f5f5f5;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  z-index: 950;
}

.kg-back-to-top:hover {
  background: rgba(20, 26, 40, 0.98);
}

.kg-back-to-top.kg-back-to-top--visible {
  display: flex;
}

/* 首页顶部：21:9 横屏大图 */
.kg-hero {
  width: 100%;
  margin-bottom: 24px;
}

.kg-hero a {
  display: block;
}

.kg-hero-image-wrap {
  position: relative;
  width: 100%;
  background: #0b0f18;
  aspect-ratio: 21 / 9;
  overflow: hidden;
}

.kg-hero-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.kg-hero-caption {
  padding: 16px 4vw 8px;
}

.kg-hero-title {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: 0.05em;
}

.kg-hero-date {
  margin-top: 4px;
  font-size: 0.85rem;
  color: #888;
}

/* 自定义顶部大图：叠字与视频 */
.kg-hero-custom .kg-hero-media-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 21 / 9;
  background: #0b0f18;
  overflow: hidden;
}

.kg-hero-custom .kg-hero-media-wrap .kg-hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.kg-hero-custom .kg-hero-video-wrap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.kg-hero-custom .kg-hero-video-wrap .wp-custom-header,
.kg-hero-custom .kg-hero-video-wrap video {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  object-fit: cover;
}

.kg-hero-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  pointer-events: none;
}

.kg-hero-custom .kg-hero-title {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 4vw, 2.8rem);
  font-weight: 600;
  color: #fff;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.6);
}

.kg-hero-subtitle {
  font-size: clamp(0.8rem, 2vw, 1rem);
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.6;
  max-width: 720px;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.5);
}

.kg-grid {
  padding: 0 4vw;
  column-count: 1;
  column-gap: 16px;
  max-width: 100%;
}

@media (min-width: 768px) {
  .kg-grid {
    column-count: 2;
  }
}

@media (min-width: 1200px) {
  .kg-grid {
    column-count: 3;
  }
}

@media (min-width: 1600px) {
  .kg-grid {
    column-count: 4;
  }
}

/* 小屏手机（iPhone / Galaxy 等）优化 */
@media (max-width: 640px) {
  .kg-hero-caption {
    padding: 12px 16px 6px;
  }

  .kg-hero-title {
    font-size: 1.25rem;
  }

  .kg-hero-custom .kg-hero-title {
    font-size: clamp(1.3rem, 6vw, 2rem);
  }

  .kg-hero-subtitle {
    font-size: 0.8rem;
    padding: 0 8px;
  }

  .kg-grid {
    padding: 0 10px;
    column-count: 2;
    column-gap: 10px;
  }

  .kg-card {
    margin-bottom: 10px;
    border-radius: 8px;
  }

  .kg-card-meta {
    padding: 8px 9px 10px;
  }

  .kg-card-title {
    font-size: 0.85rem;
  }

  .kg-card-date {
    font-size: 0.7rem;
  }

  .kg-single {
    padding: 12px 14px 32px;
  }

  .kg-single-title {
    font-size: 1.15rem;
  }

  .kg-single-content {
    font-size: 0.9rem;
  }

  .kg-back-to-top {
    right: 14px;
    bottom: 18px;
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
}

.kg-card {
  margin: 0 0 16px;
  break-inside: avoid;
  background-color: #0b0f18;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.kg-card-thumb-wrap {
  position: relative;
  width: 100%;
  background: radial-gradient(circle at top, #3a4b7a 0, #05070b 60%);
  max-height: 80vh;
  overflow: hidden;
}

/* 管理员：悬停时显示“修改”按钮 */
.kg-thumb-edit {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  padding: 6px 12px;
  font-size: 12px;
  line-height: 1.2;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.kg-card-thumb-wrap:hover .kg-thumb-edit {
  opacity: 1;
}

.kg-thumb-edit:hover {
  background: rgba(0, 0, 0, 0.85);
}

.kg-card-thumb {
  width: 100%;
  display: block;
  aspect-ratio: 21 / 9;
  object-fit: cover;
  transform: translateZ(0);
}

/* 瀑布流：按原图比例（横/竖/方），不强制统一比例 */
.kg-card-thumb-masonry {
  width: 100%;
  height: auto;
  aspect-ratio: unset;
  object-fit: cover;
  vertical-align: top;
}

/* 竖向卡片：高度不超过一屏，按比例缩小不裁切 */
.kg-card--portrait .kg-card-thumb-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  max-height: 80vh;
  background: #0b0f18;
}

.kg-card--portrait .kg-card-thumb-masonry {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
}

/* 下方瀑布流：竖向 3:4（仅保留用于非首页若有用到） */
.kg-card-thumb-portrait {
  aspect-ratio: 3 / 4;
}

.kg-card-meta {
  padding: 12px 14px 14px;
}

.kg-card-title {
  font-size: 0.95rem;
  margin: 0 0 4px;
}

.kg-card-date {
  font-size: 0.75rem;
  color: #777;
}

/* 瀑布流中的广告位：与作品卡片同结构，正方比例 */
.kg-card-ad {
  margin: 0 0 16px;
  break-inside: avoid;
}

.kg-card-ad-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b0f18;
  overflow: hidden;
}

.kg-card-ad-wrap .adsbygoogle {
  width: 100%;
  height: 100%;
  min-height: 200px;
}

.kg-card-ad-label {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  z-index: 1;
}

/* 无限滚动：哨兵与加载提示 */
.kg-infinite-sentinel {
  height: 1px;
  width: 100%;
  margin-top: 24px;
  visibility: hidden;
  pointer-events: none;
}

.kg-infinite-loading {
  text-align: center;
  padding: 24px 16px 32px;
  color: #888;
  font-size: 0.9rem;
}

.kg-infinite-loading[aria-hidden="true"] {
  display: none;
}

.kg-single {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 4vw 40px;
}

.kg-single-image-wrap {
  position: relative;
  cursor: zoom-in;
}

.kg-single-image {
  width: 100%;
  max-height: 80vh;
  object-fit: contain;
  background-color: #020307;
}

.kg-single-title {
  margin: 16px 0 8px;
  font-size: 1.4rem;
}

.kg-single-meta {
  font-size: 0.85rem;
  color: #999;
  margin-bottom: 16px;
}

.kg-single-edit {
  margin-left: 0.5em;
}

.kg-single-edit a {
  color: #7aa3d4;
  text-decoration: none;
}

.kg-single-edit a:hover {
  text-decoration: underline;
}

.kg-single-content {
  font-size: 0.95rem;
  line-height: 1.7;
  color: #ddd;
}

.kg-single-content p {
  margin-bottom: 1em;
}

/* 正文内图片：可点击放大，悬停显示放大镜 */
.kg-single-content .kg-content-img-wrap {
  position: relative;
  display: inline-block;
  cursor: pointer;
  max-width: 100%;
}

.kg-single-content .kg-content-img-wrap img {
  display: block;
  max-width: 100%;
  height: auto;
  vertical-align: top;
}

.kg-single-content .kg-content-img-zoom-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.kg-single-content .kg-content-img-wrap:hover .kg-content-img-zoom-icon {
  opacity: 1;
}

.kg-single-content .kg-content-img-zoom-icon::before {
  content: "";
  width: 48px;
  height: 48px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.kg-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(2, 3, 7, 0.96);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.kg-lightbox--active {
  display: flex;
}

.kg-lightbox-image {
  max-width: 96vw;
  max-height: 96vh;
  object-fit: contain;
}

.kg-lightbox-close {
  position: fixed;
  top: 18px;
  right: 24px;
  font-size: 28px;
  color: #fff;
  cursor: pointer;
}

.kg-lightbox-hint {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  color: #aaa;
}

/* 管理员首页裁切弹窗 */
.kg-crop-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.kg-crop-modal--open {
  display: flex;
}

.kg-crop-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
}

.kg-crop-modal-box {
  position: relative;
  width: 100%;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #111;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.kg-crop-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.95rem;
}

.kg-crop-ratio-select {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.kg-crop-ratio-select span {
  color: #999;
  font-size: 0.85rem;
}

.kg-crop-ratio-btn {
  padding: 4px 10px;
  font-size: 0.8rem;
  color: #aaa;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  cursor: pointer;
}

.kg-crop-ratio-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.kg-crop-ratio-btn.active {
  color: #fff;
  background: #2a4a7a;
  border-color: #35608a;
}

.kg-crop-modal-close {
  padding: 4px 8px;
  font-size: 20px;
  line-height: 1;
  color: #999;
  background: none;
  border: none;
  cursor: pointer;
}

.kg-crop-modal-close:hover {
  color: #fff;
}

.kg-crop-modal-body {
  position: relative;
  z-index: 0;
  flex: 1;
  min-height: 360px;
  height: 65vh;
  width: 100%;
  overflow: hidden;
  background: #0a0a0a;
}

.kg-crop-modal-crop-wrap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* 裁切区域内的图片由 Cropper.js 控制，先限制在容器内以便裁切框可见 */
.kg-crop-modal-crop-wrap img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  margin: 0 auto;
}

.kg-crop-modal-crop-wrap .cropper-container {
  width: 100% !important;
  height: 100% !important;
}

/* 强制显示 Cropper 裁切框与手柄（避免被主题或 Cropper 默认样式覆盖） */
.kg-crop-modal-crop-wrap .cropper-view-box,
.kg-crop-modal-crop-wrap .cropper-drag-box {
  outline: 2px solid rgba(0, 200, 255, 0.95) !important;
  outline-offset: -2px;
  visibility: visible !important;
  opacity: 1 !important;
}
.kg-crop-modal-crop-wrap .cropper-point {
  width: 10px !important;
  height: 10px !important;
  background: #00c8ff !important;
  border-radius: 50%;
  opacity: 1 !important;
  visibility: visible !important;
}
.kg-crop-modal-crop-wrap .cropper-line {
  background: rgba(0, 200, 255, 0.6) !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.kg-crop-modal-foot {
  position: relative;
  z-index: 10;
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #111;
}

.kg-crop-modal-foot button {
  padding: 8px 16px;
  font-size: 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  pointer-events: auto;
}

.kg-crop-modal-cancel {
  color: #999;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.kg-crop-modal-cancel:hover {
  color: #fff;
}

.kg-crop-modal-save {
  color: #fff;
  background: #2a4a7a;
  border: none;
}

.kg-crop-modal-save:hover:not(:disabled) {
  background: #35608a;
}

.kg-crop-modal-save:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
