/* tarot/assets/tarot.css —— 新版塔罗牌页样式 */
/* 主题变量：宣纸墨色两套，取值同 daliuren.css 的 --lr-*（变量名换成 --tr-*）；:root 白天，<html data-theme="dark"> 暗黑。
   断点：≥1010px 左右两栏，窄屏上下排。动画只动 transform / opacity；系统开启「减少动态效果」时洗牌不动、翻牌改淡入淡出。 */
:root {
  --tr-bg: #f3efe6; --tr-card: #fbf9f4; --tr-text: #2b2622; --tr-muted: #6f6458; --tr-faint: #74695c;
  --tr-line: #cfc5b2; --tr-split: #e6dfd0; --tr-tag-bg: #efe9dc; --tr-input-bg: #ffffff; --tr-input-line: #d9d1c0;
  --tr-shadow: rgba(0,0,0,.06); --tr-sub: #4a4239;
  --tr-primary: #b3361f; --tr-primary-hover: #9a2d19; --tr-on-primary: #ffffff; --tr-disabled: #b9af9f;
  --tr-accent: #b3361f; --tr-danger: #b91c1c; --tr-sel-bg: #f6e9e2; --tr-focus: #b45309;
  --tr-mask: rgba(0, 0, 0, .45);
  --tr-table: #ece5d5; --tr-slot-line: #a39780;
  --tr-back-1: #2f3a5e; --tr-back-2: #232c4a; --tr-back-gold: #d9b56b;
  --tr-rev: #8b2c1a; --tr-on-rev: #ffffff;
  --tr-center: #f6f2ea; --tr-locked: #efe9dc; --tr-ububble: #f6e2da; --tr-on-ububble: #2b2622;
  --tr-warn-fg: #7c3a06; --tr-warn-bg: #fbf1dc; --tr-warn-line: #e3c27a;
}
[data-theme="dark"] {
  --tr-bg: #16130f; --tr-card: #211d18; --tr-text: #ece4d6; --tr-muted: #aa9e8f; --tr-faint: #998c7b;
  --tr-line: #4a4238; --tr-split: #3a332a; --tr-tag-bg: #2a251f; --tr-input-bg: #16130f; --tr-input-line: #3a332a;
  --tr-shadow: rgba(0,0,0,.4); --tr-sub: #d6cbb9;
  --tr-primary: #c2452c; --tr-primary-hover: #ab3a24; --tr-on-primary: #ffffff; --tr-disabled: #4a4238;
  --tr-accent: #e0a34a; --tr-danger: #f87171; --tr-sel-bg: #33291d; --tr-focus: #e0a34a;
  --tr-mask: rgba(0, 0, 0, .6);
  --tr-table: #1b1814; --tr-slot-line: #5a5144;
  --tr-back-1: #2a3454; --tr-back-2: #1b2340; --tr-back-gold: #c9a45c;
  --tr-rev: #e0a34a; --tr-on-rev: #16130f;
  --tr-center: #1c1915; --tr-locked: #2a251f; --tr-ububble: #43261c; --tr-on-ububble: #f1e6da;
  --tr-warn-fg: #f5d58a; --tr-warn-bg: #33291a; --tr-warn-line: #8a6a1f;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--tr-bg); color: var(--tr-text); }
button { font-family: inherit; }
[hidden] { display: none !important; }

.tr-wrap { max-width: 1100px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 0 16px; }
.tr-left, .tr-right { min-width: 0; }
@media (min-width: 1010px) {
  .tr-wrap { flex-direction: row; align-items: flex-start; }
  .tr-left { flex: 0 0 calc(58% - 8px); }
  .tr-right { flex: 1 1 0; position: sticky; top: 12px; max-height: calc(100vh - 24px); display: flex; flex-direction: column; }
  .tr-tabs-card { display: flex; flex-direction: column; min-height: 0; }
  .tr-tabs-body { min-height: 0; overflow-y: auto; }
}

/* ===== 卡片、按钮、表单 ===== */
.tr-card { background: var(--tr-card); border-radius: 8px; padding: 14px; margin-bottom: 14px; box-shadow: 0 1px 3px var(--tr-shadow); outline: 1px solid var(--tr-input-line); outline-offset: -1px; }
.tr-card-h { margin: 0; font-size: 14px; font-weight: 700; color: var(--tr-sub); }
.tr-form-card { position: relative; padding-right: 52px; background-image: url(tl1.png);    background-repeat: no-repeat; background-size: auto; background-position: right top;}
.tr-theme-btn { position: absolute; top: 5px; right: 5px; width: 31px; height: 31px; border-radius: 50%; border: 1px solid var(--tr-input-line); background: var(--tr-card); color: var(--tr-text); font-size: 14px; line-height: 1; cursor: pointer; }
.tr-theme-btn:hover { border-color: var(--tr-accent); }
.tr-form { display: flex; flex-direction: column; gap: 8px; }
.tr-label { font-size: 14px; font-weight: 600; color: var(--tr-sub); }
.tr-note { font-size: 12px; font-weight: 400; color: var(--tr-muted); }
.tr-q { width: 100%; padding: 8px; font-size: 14px; font-family: inherit; line-height: 1.5; resize: vertical; background: var(--tr-input-bg); color: var(--tr-text); border: 1px solid var(--tr-input-line); border-radius: 4px; }
.tr-spreads { display: flex; flex-direction: column; gap: 6px; }
.tr-sg { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tr-sg-name { flex: 0 0 3em; font-size: 12px; color: var(--tr-muted); }
.tr-pill { position: relative; display: inline-block; }
.tr-pill input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.tr-pill span { display: inline-block; padding: 4px 11px; border: 1px solid var(--tr-input-line); border-radius: 14px; background: var(--tr-card); color: var(--tr-sub); font-size: 13px; }
.tr-pill:hover span { border-color: var(--tr-accent); }
.tr-pill input:checked + span { background: var(--tr-sel-bg); border-color: var(--tr-accent); color: var(--tr-accent); font-weight: 600; }
.tr-pill input:focus-visible + span { outline: 2px solid var(--tr-focus); outline-offset: 1px; }
.tr-sp-desc { margin: 0; font-size: 13px; color: var(--tr-muted); line-height: 1.5; min-height: 1.5em; }
.tr-ab { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 13px; color: var(--tr-sub); }
.tr-ab input { width: 9em; padding: 5px 8px; font-size: 14px; font-family: inherit; background: var(--tr-input-bg); color: var(--tr-text); border: 1px solid var(--tr-input-line); border-radius: 4px; }
.tr-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.tr-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--tr-sub); cursor: pointer; }
.tr-btn { padding: 8px 24px; border: 0; border-radius: 6px; background: var(--tr-primary); color: var(--tr-on-primary); font-size: 14px; cursor: pointer; }
.tr-btn:hover:not(:disabled) { background: var(--tr-primary-hover); }
.tr-btn:disabled { background: var(--tr-disabled); cursor: not-allowed; }
.tr-btn-sm { flex: none; padding: 3px 10px; border: 1px solid var(--tr-accent); border-radius: 5px; background: var(--tr-card); color: var(--tr-accent); font-size: 12px; cursor: pointer; }
.tr-btn-sm:hover { background: var(--tr-sel-bg); }
.tr-btn:focus-visible, .tr-btn-sm:focus-visible, .tr-theme-btn:focus-visible, .tr-tab:focus-visible, .tr-q:focus-visible, .tr-ab input:focus-visible, .tr-check input:focus-visible { outline: 2px solid var(--tr-focus); outline-offset: 1px; }

/* ===== 牌桌 ===== */
.tr-stage-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.tr-stage-tools { display: flex; gap: 6px; }
.tr-status { margin: 0 0 8px; font-size: 14px; color: var(--tr-text); min-height: 1.5em; }
.tr-stage { background: var(--tr-table); border-radius: 8px; padding: 12px 8px; min-height: 120px; }
.tr-qshow { margin: 0 auto 10px; max-width: 34em; text-align: center; font-size: 14px; color: var(--tr-sub); word-break: break-word; }
.tr-qshow::before { content: "你的问题："; color: var(--tr-muted); }

/* 牌背（原创，纯 CSS）：深蓝底、金色双线框、中央星芒 */
.tr-back-face, .tr-sh-card, .tr-pk {
  background:
    radial-gradient(circle at 50% 50%, transparent 0 18%, rgba(217,181,107,.0) 19%),
    repeating-conic-gradient(from 0deg at 50% 50%, var(--tr-back-1) 0 10deg, var(--tr-back-2) 10deg 20deg);
  border: 2px solid var(--tr-back-gold); border-radius: 6px;
  box-shadow: inset 0 0 0 3px var(--tr-back-2), inset 0 0 0 4px var(--tr-back-gold);
}
.tr-back-face::after, .tr-sh-card::after, .tr-pk::after {
  content: "✦"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--tr-back-gold); font-size: 22px; line-height: 1; text-shadow: 0 0 6px rgba(0,0,0,.5);
}

/* 洗牌 */
.tr-shuffle { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 8px 0; }
.tr-sh-stack { position: relative; width: 90px; height: 158px; margin: 8px 0 16px; }
.tr-sh-card { position: absolute; inset: 0; }
.tr-sh-card:nth-child(odd) { transform: translate(calc(var(--n) * 0.6px), calc(var(--n) * -0.8px)); }
.tr-sh-card:nth-child(even) { transform: translate(calc(var(--n) * -0.6px), calc(var(--n) * -0.8px)); }
.tr-sh-stack.is-shuffling .tr-sh-card { animation: tr-shuffle .55s ease-in-out infinite alternate; animation-delay: calc(var(--n) * -45ms); }
.tr-sh-stack.is-shuffling .tr-sh-card:nth-child(even) { animation-name: tr-shuffle-b; }
@keyframes tr-shuffle { from { transform: translate(-48px, 0) rotate(-8deg); } to { transform: translate(48px, -6px) rotate(8deg); } }
@keyframes tr-shuffle-b { from { transform: translate(48px, -4px) rotate(7deg); } to { transform: translate(-48px, 2px) rotate(-7deg); } }

/* 选牌：横向滑动的扇形牌堆，每张牌是一个按钮 */
.tr-pick-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; font-size: 13px; color: var(--tr-sub); }
.tr-pick-nav { display: inline-flex; gap: 6px; }
.tr-pick-rows { display: flex; align-items: flex-end; overflow-x: auto; scroll-snap-type: x proximity; padding: 26px 40px 14px; min-height: 160px; -webkit-overflow-scrolling: touch; }
.tr-pk { position: relative; flex: 0 0 56px; height: 98px; margin-left: -32px; padding: 0; cursor: pointer; scroll-snap-align: center;
  transform: translateY(calc(var(--d) * var(--d) * 0.012px)) rotate(calc(var(--d) * 0.4deg));
  transition: transform .18s ease, opacity .2s; }
.tr-pk:first-child { margin-left: 0; }
.tr-pk::after { font-size: 16px; }
.tr-pk:hover:not(:disabled), .tr-pk:focus-visible { transform: translateY(-16px) rotate(0deg); z-index: 3; }
.tr-pk:focus-visible { outline: 2px solid var(--tr-focus); outline-offset: 2px; }
.tr-pk.is-taken { visibility: hidden; pointer-events: none; }
.tr-pk:disabled { cursor: default; }

/* 牌阵 */
.tr-board-wrap { margin-top: 8px; }
.tr-board { position: relative; width: 100%; max-width: 640px; margin: 0 auto; }
.tr-slot { position: absolute; aspect-ratio: 300 / 527; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)); }
.tr-slot-mark { position: absolute; inset: 0; border: 1.5px dashed var(--tr-slot-line); border-radius: 6px; display: flex; align-items: center; justify-content: center; color: var(--tr-muted); font-size: 13px; font-weight: 700; }
.tr-c { position: absolute; inset: 0; padding: 0; border: 0; background: none; cursor: default; perspective: 700px; transition: transform .45s cubic-bezier(.2,.8,.2,1); }
.tr-c:not(:disabled) { cursor: pointer; }
.tr-c:focus-visible { outline: 2px solid var(--tr-focus); outline-offset: 2px; border-radius: 6px; }
.tr-flip { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .6s cubic-bezier(.3,.7,.2,1); }
.tr-c.is-flipped .tr-flip { transform: rotateY(180deg); }
.tr-back-face, .tr-front { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 6px; overflow: hidden; }
.tr-back-face { }
.tr-front { transform: rotateY(180deg); background: #1c1915; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.tr-front img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tr-front.is-rev img { transform: rotate(180deg); }
.tr-rev-badge { position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); padding: 1px 7px; border-radius: 9px; background: var(--tr-rev); color: var(--tr-on-rev); font-size: 11px; font-weight: 700; line-height: 1.5; white-space: nowrap; }
.tr-c:not(.is-flipped):not(:disabled):hover .tr-flip { transform: rotateY(-8deg) translateY(-3px); }

/* 牌位说明 */
.tr-legend { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px 12px; font-size: 13px; color: var(--tr-sub); }
.tr-legend li { display: flex; gap: 6px; line-height: 1.5; }
.tr-lg-no { flex: none; width: 1.5em; height: 1.5em; border-radius: 50%; background: var(--tr-tag-bg); color: var(--tr-sub); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.tr-lg-name { font-weight: 600; color: var(--tr-text); }
.tr-lg-hint { color: var(--tr-muted); }
.tr-lg-card { color: var(--tr-accent); font-weight: 600; }
.tr-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ===== 右栏 ===== */
.tr-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--tr-split); margin-bottom: 10px; }
.tr-tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 10px 8px; margin-bottom: -1px; font-size: 14px; font-weight: 600; color: var(--tr-muted); cursor: pointer; }
.tr-tab:hover { color: var(--tr-text); }
.tr-tab[aria-selected="true"] { color: var(--tr-accent); border-bottom-color: var(--tr-accent); }
.tr-empty, .tr-h-note { margin: 0; font-size: 13px; color: var(--tr-muted); }
.tr-h-count { font-size: 12px; color: var(--tr-muted); font-weight: 400; }
.tr-h-list, .tr-about, .tr-ov { list-style: none; margin: 8px 0 0; padding: 0; }
.tr-h-list li { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--tr-split); }
.tr-h-load { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 8px 4px; color: var(--tr-text); font-size: 13px; line-height: 1.5; cursor: pointer; }
.tr-h-load:hover { color: var(--tr-accent); }
.tr-h-load small { display: block; color: var(--tr-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-h-del { flex: none; border: 0; background: none; color: var(--tr-muted); font-size: 16px; padding: 4px 8px; cursor: pointer; }
.tr-h-del:hover { color: var(--tr-danger); }
.tr-h-load:focus-visible, .tr-h-del:focus-visible { outline: 2px solid var(--tr-focus); outline-offset: 1px; }
.tr-about li { font-size: 13px; line-height: 1.7; color: var(--tr-sub); padding: 4px 0 4px 1em; text-indent: -1em; }
.tr-about li::before { content: "· "; }
.tr-ov li { padding: 8px 0; border-bottom: 1px solid var(--tr-split); font-size: 13px; line-height: 1.6; }
.tr-ov-pos { color: var(--tr-muted); font-size: 12px; }
.tr-ov-card { font-weight: 700; color: var(--tr-text); }
.tr-ov-rev { color: var(--tr-rev); font-size: 12px; font-weight: 700; margin-left: 4px; }
.tr-ov-kw { color: var(--tr-sub); }
.tr-ov-more { margin-left: 6px; }

/* ===== 详情抽屉 ===== */
.tr-mask { position: fixed; inset: 0; background: var(--tr-mask); z-index: 50; }
.tr-drawer { position: fixed; z-index: 51; background: var(--tr-card); color: var(--tr-text); box-shadow: 0 0 24px rgba(0,0,0,.3); display: flex; flex-direction: column;
  left: 0; right: 0; bottom: 0; max-height: 86vh; border-radius: 12px 12px 0 0; }
@media (min-width: 1010px) { .tr-drawer { left: auto; top: 0; bottom: 0; width: 420px; max-height: none; border-radius: 0; } }
.tr-dr-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--tr-split); }
.tr-dr-title { margin: 0; font-size: 16px; }
.tr-dr-body { padding: 14px 16px 22px; overflow-y: auto; font-size: 14px; line-height: 1.7; }
.tr-dr-img { float: left; width: 96px; margin: 0 12px 6px 0; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.tr-dr-img.is-rev { transform: rotate(180deg); }
.tr-dr-meta { color: var(--tr-muted); font-size: 13px; }
.tr-dr-h { clear: both; margin: 14px 0 2px; font-size: 13px; font-weight: 700; color: var(--tr-accent); }
.tr-dr-p { margin: 0; }
.tr-dr-kw { margin: 2px 0 0; color: var(--tr-sub); font-size: 13px; }
.tr-dr-dim { opacity: .85; }

/* ===== 减少动态效果：洗牌不动、翻牌改淡入淡出、不飞牌 ===== */
@media (prefers-reduced-motion: reduce) {
  .tr-sh-stack.is-shuffling .tr-sh-card { animation: none; }
  .tr-c { transition: none; }
  .tr-flip { transition: none; transform: none !important; }
  .tr-back-face, .tr-front { backface-visibility: visible; -webkit-backface-visibility: visible; transform: none; transition: opacity .15s; }
  .tr-front { opacity: 0; }
  .tr-c.is-flipped .tr-front { opacity: 1; }
  .tr-c.is-flipped .tr-back-face { opacity: 0; }
  .tr-pk { transition: none; }
  .tr-c:not(.is-flipped):not(:disabled):hover .tr-flip { transform: none; }
}

/* 选中的牌飞入牌阵位的幽灵牌（tarot.js 的 fly()）；减少动态效果时不创建 */
.tr-fly { position: fixed; z-index: 60; margin: 0; pointer-events: none; transform-origin: center; transition: transform .45s cubic-bezier(.2,.8,.2,1); }
