/*
Theme Name: ShuBoy
Theme URI: https://example.com/shuboy
Author: shuboy
Author URI: https://example.com
Description: 复古 Gameboy 风格 WordPress 主题。主页中央是一台 Gameboy 游戏机（shuboy.png 机身 + m.png 蒙版），屏幕内是仿 Windows 1.0 / NS-OS 89 的像素风博客界面。↑↓ 滚动或选择文章，←→ 上一篇/下一篇，A/Enter 确定，B 返回，START 确认，SELECT 回首页。
Version: 1.0.3
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: shuboy
Tags: blog, two-columns, custom-menu, featured-images, threaded-comments, translation-ready
*/

/* ============================================================
   Fusion Pixel 10px 像素字体（开源）
   latin 负责英文/数字/符号，zh_hans 负责简体中文
   ============================================================ */
@font-face {
  font-family: 'Fusion Pixel 10px';
  src: url(assets/fonts/fusion-pixel-10px-monospaced-latin.woff2) format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2190-21FF, U+2500-257F, U+25A0-25FF, U+2600-26FF;
}
@font-face {
  font-family: 'Fusion Pixel 10px';
  src: url(assets/fonts/fusion-pixel-10px-monospaced-zh_hans.woff2) format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
  unicode-range: U+2014-2026, U+3000-303F, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FF00-FFEF;
}

/* ============================================================
   基础
   ============================================================ */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden; overscroll-behavior: none;
  background: #232428 !important;
  touch-action: manipulation;
}
body {
  background: #232428;
  color: #ccd0d8;
  font-family: 'Fusion Pixel 10px', 'Courier New', 'IBM Plex Mono', Consolas, monospace;
  -webkit-font-smoothing: none;
}
a { color: inherit; }
img { max-width: 100%; height: auto; }
.skip-link { position: absolute; left: -999px; top: -999px; }

/* 整页铺满视口、机身居中、页面无滚动条 */
.gb-page {
  position: relative;
  z-index: 0; /* 形成层叠上下文:背景在负 z 子元素之下,气泡可透出机器透明区 */
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 56px 4px 0; /* 机身整体下移 56px */
  background: #232428 !important;
}

/* ============================================================
   Gameboy 机身：shuboy.png 底图 + m.png 蒙版
   ============================================================ */
.gb-shell {
  position: relative;
  width: min(98vw, 600px, calc((100vh - 12px) * 3 / 4));
  width: min(98vw, 600px, calc((100dvh - 12px) * 3 / 4));
  margin: 0;
  aspect-ratio: 1668 / 2224; /* 与底图、蒙版同比例 */
  background: url(assets/img/shuboy.png) no-repeat center / 100% 100%;
  box-shadow: none;
}

/* 屏幕区不再使用 CSS 蒙版：.gb-screen 本身已对齐屏幕矩形且 overflow:hidden，内容不会溢出；移除蒙版避免兼容性与渲染问题。 */

/* 屏幕窗口：对齐蒙版矩形，四周微内缩留出屏幕黑边 */
.gb-screen {
  position: absolute;
  /* 屏幕矩形精确覆盖机身图屏幕洞（shuboy.PNG 实测 x347-1321 / y256-1081），四角不留机身色块 */
  left: 20.8%;
  top: 11.5%;
  width: 58.4%;
  height: 37.1%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #efede4;
  color: #0a0a0a;
  font-family: 'Fusion Pixel 10px', 'Courier New', 'IBM Plex Mono', Consolas, monospace;
  font-size: 10px;
  line-height: 1.6;
}

/* CRT 扫描线：1x2 像素 PNG 平铺，线宽恒定、严格水平平行（不拦截交互） */
.gb-screen::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 6;
  background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAADElEQVR42mNggAJ+AAAZABAYde80AAAAAElFTkSuQmCC");
  background-repeat: repeat;
}



.os-titlebar {
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; border-bottom: 3px double #000;
  padding: 3px 8px; font-size: 12px; font-weight: 700; line-height: 1.2;
  flex: none;
}
.os-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.os-btns { font-size: 10px; letter-spacing: 3px; }

.os-menubar {
  display: flex; gap: 18px; align-items: center;
  background: #fff; border-bottom: 1px solid #000;
  padding: 2px 8px; font-size: 12px; flex: none;
}
.os-menu { cursor: pointer; text-decoration: none; padding: 0 2px; border: 1px solid transparent; }
.os-menu:hover, .os-menu:focus-visible { background: #000; color: #fff; outline: none; }

.os-content {
  flex: 1; overflow-y: auto; padding: 10px 12px 14px;
  scrollbar-width: none;
  touch-action: pan-y;
  overscroll-behavior-x: none;
}
.os-content::-webkit-scrollbar { display: none; }

/* 屏幕内容 iframe（外壳模式）：填满 .os-content */
.gb-frame-src {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* embed 内容页（机身外壳 iframe 内加载）：与屏幕同色、像素字体、隐藏滚动条 */
body.gb-embed {
  margin: 0;
  background: #efede4 !important;
  color: #0a0a0a;
  font-family: 'Fusion Pixel 10px', 'Courier New', 'IBM Plex Mono', Consolas, monospace;
  font-size: 10px;
  line-height: 1.6;
}
.gb-embed-wrap {
  min-height: 100%;
  padding: 10px 12px 14px;
  box-sizing: border-box;
}
.gb-embed ::-webkit-scrollbar { display: none; }


.os-statusbar {
  display: flex; justify-content: space-between; gap: 8px;
  background: #fff; border-top: 1px solid #000;
  padding: 2px 8px; font-size: 10px; flex: none; white-space: nowrap;
  overflow: hidden;
}
.os-statusbar span { overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   机身隐形按键热区（对应底图上的十字键 / A / B / START / SELECT）
   容器整体不拦截鼠标/触摸事件，事件可穿透到屏幕内容；
   只有按键按钮本身可点击。
   ============================================================ */
.gb-hotzones { position: absolute; inset: 0; pointer-events: none; }
.hz {
  position: absolute; border: 0; padding: 0; background: transparent;
  cursor: pointer; font-size: 0; pointer-events: auto;
}
.hz:hover { background: rgba(255,255,255,.07); outline: 1px dashed rgba(255,255,255,.45); outline-offset: -1px; }
.hz:active { background: rgba(255,255,255,.14); }

/* 十字键（按 shuboy.png 实际位置） */
.hz.up     { left: 29.0%; top: 63.3%; width: 4.4%; height: 5.6%; }
.hz.down   { left: 29.0%; top: 72.1%; width: 4.4%; height: 5.6%; }
.hz.left   { left: 21.6%; top: 68.9%; width: 7.4%; height: 3.2%; }
.hz.right  { left: 33.4%; top: 68.9%; width: 7.4%; height: 3.2%; }
.hz.center { left: 29.0%; top: 68.9%; width: 4.4%; height: 3.2%; }

/* A / B 键 */
.hz.a { left: 69.8%; top: 63.7%; width: 9.8%; height: 7.2%; }
.hz.b { left: 57.1%; top: 66.2%; width: 9.6%; height: 7.2%; }

/* START / SELECT */
.hz.start  { left: 51.6%; top: 79.7%; width: 9.1%; height: 4.3%; }
.hz.select { left: 38.6%; top: 80.0%; width: 9.4%; height: 4.5%; }

/* ============================================================
   Toast
   ============================================================ */
#gb-toast {
  position: absolute; left: 12px; right: 12px; bottom: 14px;
  background: #000; color: #fff; border: 1px solid #fff;
  padding: 6px 10px; font-size: 12px; z-index: 60; display: none;
  box-shadow: 2px 2px 0 #555;
}
#gb-toast.show { display: block; animation: gbblink .8s steps(2) 2; }
@keyframes gbblink { 50% { opacity: .55; } }

/* ============================================================
   屏幕内窗口（Windows 1.0 风格）
   ============================================================ */
.os-window {
  border: 2px solid #000; background: #fff;
  box-shadow: 3px 3px 0 rgba(0,0,0,.18);
  margin: 0 0 14px;
}
.win-titlebar {
  display: flex; justify-content: space-between; gap: 8px;
  background: #fff; border-bottom: 2px solid #000;
  padding: 3px 8px; font-size: 12px; font-weight: 700;
}
.win-titlebar .sub { font-weight: 400; font-size: 11px; color: #333; }

/* ============================================================
   NS-OS 89 文件列表
   ============================================================ */
.exec-head {
  display: grid; grid-template-columns: 32px 18px 1fr 100px; gap: 4px;
  padding: 3px 6px; border-bottom: 2px solid #000;
  font-size: 10px; font-weight: 700;
}
.exec-head span:last-child { text-align: right; }
.exec-row {
  display: grid; grid-template-columns: 32px 18px 1fr 100px; gap: 4px;
  align-items: center; padding: 2px 6px;
  color: #000; text-decoration: none; border-bottom: 1px dotted #a9a9a9;
  cursor: pointer;
}
.exec-row:hover, .exec-row.sel, .exec-row:focus-visible {
  background: #000; color: #fff; outline: none;
}
.exec-row .no { font-size: 11px; }
.exec-row .ico { text-align: center; font-size: 11px; }
.exec-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exec-row .date { text-align: right; font-size: 10px; white-space: nowrap; }

/* ============================================================
   对话框
   ============================================================ */
.dialog {
  border: 2px solid #000; background: #fff;
  max-width: 300px; margin: 4px auto 14px;
  box-shadow: 4px 4px 0 rgba(0,0,0,.22);
}
.dialog .d-title {
  display: flex; justify-content: space-between;
  background: #000; color: #fff;
  padding: 3px 8px; font-size: 12px; font-weight: 700;
}
.dialog .d-close { cursor: pointer; border: 0; background: none; color: #fff; font-size: 12px; font-family: inherit; padding: 0 2px; }
.dialog .d-close:hover { background: #fff; color: #000; }
.dialog .d-body { padding: 10px 12px 12px; font-size: 12px; }
.dialog.closed { display: none; }
.d-btn {
  background: #fff; border: 2px solid #000; box-shadow: 2px 2px 0 #000;
  padding: 4px 18px; font-family: inherit; font-size: 12px; cursor: pointer;
}
.d-btn:hover { background: #000; color: #fff; }
.d-btn:active { box-shadow: none; transform: translate(2px, 2px); }

/* ============================================================
   文章正文
   ============================================================ */
.entry-content { padding: 10px 12px 12px; font-size: 12px; }
.entry-content h1, .entry-content h2, .entry-content h3, .entry-content h4 {
  font-size: 14px; margin: 12px 0 6px; padding-bottom: 2px;
  border-bottom: 2px solid #000;
}
.entry-content h1 { font-size: 15px; }
.entry-content p { margin: 0 0 10px; }
.entry-content img, .entry-content figure img {
  border: 2px solid #000; box-shadow: 3px 3px 0 rgba(0,0,0,.18);
  image-rendering: pixelated;
}
.entry-content a { text-decoration: underline; text-decoration-thickness: 1px; }
.entry-content a:hover { background: #000; color: #fff; }
.entry-content blockquote {
  margin: 10px 0; padding: 6px 12px;
  border: 2px solid #000; border-left: 8px solid #000; background: #fff;
}
.entry-content pre {
  background: #0a0a0a; color: #d8f0d8; padding: 10px;
  border: 2px solid #000; overflow-x: auto; font-size: 11px;
}
.entry-content code { background: #e4e4e4; padding: 0 4px; }
.entry-content pre code { background: none; padding: 0; }
.entry-content ul, .entry-content ol { padding-left: 24px; }
.entry-content hr { border: 0; border-top: 3px double #000; margin: 16px 0; }
.entry-meta { padding: 6px 12px 10px; border-top: 1px dashed #999; font-size: 11px; color: #222; }
.entry-meta a:hover { background: #000; color: #fff; }

/* 上一篇/下一篇（隐藏，由按键触发） */
.post-nav { display: none; }

/* 归档 / 搜索标题 */
.arch-title {
  border: 2px solid #000; background: #fff; box-shadow: 3px 3px 0 rgba(0,0,0,.18);
  padding: 6px 10px; font-size: 13px; margin: 0 0 12px;
}
.pagination { margin: 12px 0; font-size: 12px; display: flex; gap: 14px; }
.pagination a { background: none; border: 0; box-shadow: none; padding: 0; text-decoration: none; color: inherit; }
.pagination a:hover { background: #000; color: #fff; }

/* ============================================================
   留言（评论）
   ============================================================ */
.comments-area { margin-top: 14px; }
.comment-list { list-style: none; margin: 0; padding: 8px 10px 0; }
.comment { background: #fff; border: 2px solid #000; box-shadow: 2px 2px 0 rgba(0,0,0,.16); margin: 0 0 10px; }
.comment .c-head {
  display: flex; justify-content: space-between; gap: 8px;
  background: #fff; border-bottom: 2px solid #000;
  padding: 3px 8px; font-size: 12px; font-weight: 700;
}
.comment .c-head .c-date { font-weight: 400; font-size: 11px; }
.comment .c-body { padding: 8px 10px; font-size: 12px; }
.comment .c-body p { margin: 0 0 6px; }
.comment .c-reply { font-size: 11px; }
.comment .c-reply a:hover { background: #000; color: #fff; }
.comment .awaiting { color: #8a1010; font-size: 11px; }
.children { list-style: none; margin: 0 0 0 22px; padding: 0; }
.comment-navigation { padding: 0 10px 8px; font-size: 12px; }
.comment-navigation a:hover { background: #000; color: #fff; }

#respond { border: 2px solid #000; background: #fff; box-shadow: 3px 3px 0 rgba(0,0,0,.18); margin: 0 0 14px; }
#respond .comment-reply-title {
  display: flex; border-bottom: 2px solid #000; margin: 0;
  padding: 4px 8px; font-size: 12px; font-weight: 700;
}
#respond .comment-notes, #respond .logged-in-as, #respond .form-allowed-tags { display: none; }
#respond form { padding: 10px 12px 12px; }
#respond form p { margin: 0 0 8px; }
#respond label { display: block; font-size: 11px; margin-bottom: 2px; }
#respond input[type="text"], #respond input[type="email"], #respond textarea {
  width: 100%; font-family: inherit; font-size: 12px;
  border: 2px solid #000; background: #fff;
  padding: 5px 8px; box-shadow: 2px 2px 0 rgba(0,0,0,.25);
}
#respond input:focus, #respond textarea:focus { outline: 3px solid #b9b2a2; background: #fffbe6; }
#respond .submit { margin-top: 4px; }
#respond input[type="submit"], #respond .submit {
  color: #000 !important;
  background: #fff !important;
  border: 2px solid #000 !important;
  font-family: inherit;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 560px) {
  /* 手机端画面占比最大化：机身撑满宽度，高度按机身原比例（1668:2224）自动，保持不变形 */
  .gb-page { padding: 0; }
  .gb-shell {
    width: 100vw;
    aspect-ratio: 1668 / 2224;
    /* 手机端机身整体下移 8px */
    transform: translateY(8px);
  }
  /* 手机端紧凑排版：屏幕区物理尺寸小，字号与间距整体收紧 */
  .gb-screen { font-size: 10px; line-height: 1.6; }
  .os-titlebar { font-size: 10px; padding: 2px 5px; }
  .os-menubar { font-size: 10px; gap: 10px; padding: 1px 5px; }
  .os-statusbar { font-size: 8px; padding: 1px 5px; }
  .os-statusbar span:last-child { display: none; }
  .os-content { padding: 6px 8px 8px; }
  .exec-head, .exec-row { grid-template-columns: 22px 12px 1fr 74px; gap: 2px; padding: 2px 4px; font-size: 10px; }
  .entry-content { font-size: 11px; padding: 6px 8px 8px; }
  .entry-content h1, .entry-content h2, .entry-content h3, .entry-content h4 { font-size: 12px; margin: 8px 0 4px; }
  .win-titlebar { font-size: 10px; padding: 2px 4px; gap: 6px; }
  .win-titlebar .sub { font-size: 9px; max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dialog { max-width: 100%; margin: 4px 0 10px; }
  #respond form { padding: 8px; }
  #respond input[type="submit"], #respond .submit {
    font-size: 11px !important;
    padding: 7px 16px !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ============================================================
   音乐对话框：START 键从机器背后升起（气泡位于机身图下层 z:-1,
   初始藏在机器轮廓内被机身图遮住,升起后停在机器顶部透明留白区）
   ============================================================ */
.gb-music {
  position: absolute;
  /* 无 z-index: 靠 DOM 顺序位于 .gb-shell 之前,被机身图自然盖住(机器背后) */
  left: 26%;
  right: 26%;
  top: 44px;
  pointer-events: auto;
  transform: translateY(130px);
  transition: transform .55s cubic-bezier(.19, .75, .3, 1);
}
.gb-music.show { transform: translateY(0); }
/* 动画结束后提升层级:停位在机身透明区内,默认被机身元素拦截点击 */
.gb-music.raised { z-index: 5; }
/* 气泡内容 = 独立播放器 iframe(?gbplayer=1),播放器 UI 在 iframe 内渲染 */
.gb-music-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: transparent;
  pointer-events: auto;
}
/* 气泡：白底圆角，向下小尾巴指向机器 */
.music-panel {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  background: #fff;
  border: 2px solid #cfcabc;
  border-radius: 12px;
  box-shadow: 0 5px 12px rgba(0, 0, 0, .3);
  padding: 7px 11px;
  font-size: 11px;
  color: #222;
}
.music-panel::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  transform: translateX(-50%);
  border: 9px solid transparent;
  border-top-color: #cfcabc;
  border-bottom: 0;
}
.music-panel::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #fff;
  border-bottom: 0;
  z-index: 1;
}
/* 播放/暂停：与曲目名同款像素字体（无按钮样式） */
.music-btn {
  background: none;
  color: #111;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-family: 'Fusion Pixel 10px', 'Courier New', Consolas, monospace;
  font-size: 12px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  min-width: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.music-btn:active { transform: translateY(1px); }
.music-btn img {
  width: 10px;
  height: 10px;
  display: block;
  image-rendering: pixelated;
}
.music-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  font-size: 11px;
  color: #222;
  position: relative;
}
.music-title .tt {
  display: inline-block;
  white-space: nowrap;
}
.music-title.scroll .tt {
  padding-left: 100%;
  animation: music-marquee 12s linear infinite;
}
@keyframes music-marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}
@media (max-width: 560px) {
  /* 手机端:气泡宽度直接用 vw 固定(机身=100vw,48% 居中),不依赖 JS,任何情况下都正确 */
  .gb-music { left: 26vw; width: 48vw; right: auto; top: calc((100dvh - 133.34vw) / 2 + 9.2vw - 47px); transform: translateY(140px); }
  .music-panel { gap: 6px; padding: 6px 9px; font-size: 10px; border-radius: 10px; }
  .music-btn { font-size: 11px; width: 14px; height: 14px; }
  .music-title { font-size: 10px; }
}


/* ---------- 留言验证码 ---------- */
.cf-row.cap-row { display: flex; align-items: center; gap: 6px; }
.cf-row.cap-row label { flex: 0 0 auto; }
.gb-cap {
  display: inline-block;
  padding: 2px 8px;
  background: #1b1c20;
  color: #f4f2ea;
  border: 2px solid #0e0f12;
  box-shadow: inset 0 0 0 1px #3a3c44;
  font-family: 'fusion-pixel-10px-monospaced-zh_hans', 'fusion-pixel-10px-monospaced-latin', 'Courier New', monospace;
  font-size: 18px;
  letter-spacing: 3px;
  user-select: none;
  line-height: 1.4;
}
.cf-row.cap-row input#gb-cap {
  width: 64px;
  text-align: center;
  font-family: inherit;
}
