/* fontion 插件文件站（Eliza 樣板，template.html.erb）的樣式：沿用 fontion 的 Carbon 色票。 */
:root {
  --bg: #ffffff;
  --layer: #f4f4f4;
  --ink: #161616;
  --ink-2: #525252;
  --ink-3: #6f6f6f;
  --line: #e0e0e0;
  --accent: #0f62fe;
  --accent-soft: #edf5ff;
  --danger: #da1e28;
  --sidebar-w: 264px;
  --font: "Chiron Hei HK", "IBM Plex Sans TC", -apple-system, "Segoe UI", "Microsoft JhengHei", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 16px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.75 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 側欄 ─────────────────────────────────────────────────────────────── */
.sidebar_box {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  overflow-y: auto;
  padding: 20px 16px 32px;
  background: var(--layer);
  border-right: 1px solid var(--line);
  z-index: 999;
}
.doc-switchers { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.capsule {
  display: inline-block;
  padding: 1px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--bg);
}
.lang-switcher .current, .version-switcher .current {
  border-color: var(--accent);
  color: var(--accent) !important;
  font-weight: 600;
}
.disabled { color: var(--ink-3); font-size: 12px; }
#sidebar { display: flex; flex-direction: column; }
#sidebar a {
  padding: 6px 10px;
  border-left: 2px solid transparent;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.5;
}
#sidebar a:hover { background: #e8e8e8; color: var(--ink); text-decoration: none; }

.sidebar_box { display: flex; flex-direction: column; }
.sidebar-foot {
  margin-top: auto;
  padding-top: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo { width: 28px; height: 28px; flex: none; }
.back-app {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 13px;
  background: var(--bg);
}
.back-app .material-symbols-outlined { font-size: 16px; }
.back-app:hover { color: var(--ink); text-decoration: none; background: #e8e8e8; }

.mobile-bar { display: none; }

.hamburger {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}

/* ── 內容 ─────────────────────────────────────────────────────────────── */
#content {
  margin-left: var(--sidebar-w);
  max-width: 860px;
  padding: 32px 40px 96px;
}
#MainTitle { font-size: 30px; line-height: 1.3; margin: 8px 0 12px; font-weight: 700; }
#content > hr { border: none; border-top: 1px solid var(--line); margin: 0 0 20px; }

.page-toc {
  margin: 0 0 28px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: var(--layer);
  font-size: 14px;
}
.page-toc ol { margin: 0; padding-left: 18px; }
.page-toc .toc-h3 { padding-left: 16px; }
.page-toc a { color: var(--ink-2); }

.doc-body h2 { font-size: 22px; margin: 40px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.doc-body h3 { font-size: 17px; margin: 28px 0 8px; }
.doc-body p, .doc-body ul, .doc-body ol { margin: 10px 0; }
.doc-body li { margin: 3px 0; }
.doc-body blockquote {
  margin: 16px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}
.doc-body blockquote p { margin: 4px 0; }

.doc-body table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 14px; display: block; overflow-x: auto; }
.doc-body th, .doc-body td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.doc-body th { background: var(--layer); font-weight: 600; white-space: nowrap; }

.doc-body code { font-family: var(--mono); font-size: 0.88em; background: var(--layer); padding: 1px 5px; border-radius: 3px; }
.doc-body pre {
  margin: 14px 0;
  padding: 14px 16px;
  overflow-x: auto;
  border-radius: 6px;
  background: #272822;
  line-height: 1.55;
}
.doc-body pre code { background: none; padding: 0; font-size: 13px; color: #f8f8f2; }
.doc-body img { max-width: 100%; }

/* ── 手機 ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .hamburger { display: inline-flex; align-items: center; justify-content: center; }
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    inset: 0 0 auto 0;
    height: 56px;
    padding: 0 8px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    z-index: 1000;
  }
  .sidebar_box { transform: translateX(-100%); transition: transform 0.2s ease; padding-top: 72px; }
  .sidebar_box.active { transform: none; }
  #content { margin-left: 0; padding: 64px 16px 64px; }
  #MainTitle { font-size: 24px; }
  .doc-body h2, .doc-body h3 { scroll-margin-top: 68px; }
}

/* 外站連結：尾端加上箭頭圖示 */
a.ext-link::after {
  content: "";
  display: inline-block;
  width: 0.72em;
  height: 0.72em;
  margin-left: 0.2em;
  vertical-align: 0.02em;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 2h6v6M10 2L2 10'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 2h6v6M10 2L2 10'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* 教學影片縮圖：整張可點，中央顯示播放鈕 */
a.video-thumb {
  position: relative;
  display: block;
  margin: 16px 0;
  border-radius: 10px;
  overflow: hidden;
  line-height: 0;
}
a.video-thumb img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
}
a.video-thumb.ext-link::after {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 6.5v11l9-5.500z' fill='white'/%3E%3C/svg%3E") center / 44px no-repeat;
  -webkit-mask: none;
          mask: none;
  transition: background-color 0.15s;
}
a.video-thumb.ext-link:hover::after {
  background-color: rgba(0, 0, 0, 0.8);
}

/* ── 表面：按鈕、卡片共用一組輕薄陰影（外框＋短投影），大陰影只留給 hover ── */
:root {
  --surface-warm: #fcfbf9;
  --shadow-base: 0 0 0 1px #00000014, 0 1px 2px #0000001f;
  --shadow-hover: 0 3px 6px #00000012, 0 0 0 1px #00000014;
  --shadow-media: 0 2px 8px #0000001a, 0 1px 2px -1px #00000014, 0 0 0 1px #00000014;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* 按鈕 */
.back-app, .hamburger, .capsule {
  border: 0;
  background: #fff;
  box-shadow: var(--shadow-base), inset 0 .75px 0 #fff3;
  transition: box-shadow 300ms var(--ease), background-color 150ms;
}
.back-app, .hamburger { border-radius: 6px; }
.back-app { padding: 4px 8px; }
.back-app:hover { background: #fff; box-shadow: var(--shadow-hover); }
.lang-switcher .current, .version-switcher .current {
  box-shadow: 0 0 0 1px var(--accent), 0 1px 2px #0000001f;
}

/* 卡片：目錄、引言 */
.page-toc, .doc-body blockquote {
  border: 0;
  border-radius: 8px;
  background: var(--surface-warm);
  box-shadow: var(--shadow-base);
}
.page-toc { padding: 14px 18px; }
.doc-body blockquote { padding: 10px 16px; }
.doc-body pre { border-radius: 8px; box-shadow: var(--shadow-base); }

/* 圖片與影片縮圖 */
.doc-body img:not(.no-frame) { border-radius: 8px; box-shadow: var(--shadow-media); }
a.video-thumb { border-radius: 8px; box-shadow: var(--shadow-base); transition: box-shadow 300ms var(--ease); }
a.video-thumb img { box-shadow: none; border-radius: 0; }
@media (hover: hover) {
  a.video-thumb:hover { box-shadow: var(--shadow-hover); }
}

/* 鍵盤焦點：外觀調整後仍要看得到 */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* 小花 logo 彩蛋（assets/script/watering.js）：靠近時隱藏系統游標，被水打到時晃一下 */
html.fx-watering, html.fx-watering * { cursor: none !important; }
.sidebar-logo { transform-origin: 50% 100%; }
.sidebar-logo.fx-watered { animation: fx-bloom 600ms var(--ease); }
@keyframes fx-bloom {
  0%   { transform: scale(1) rotate(0); }
  30%  { transform: scale(1.15, .92) rotate(-6deg); }
  60%  { transform: scale(.96, 1.08) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}
