/* =============================================================================
   style2.css — 像素记忆 · 前置门（P1）全新样式
   -----------------------------------------------------------------------------
   所有新代码放这里，不再和旧 style.css 打架。
   做完后用 style2.css 替换 style.css 的前置门部分。
   ============================================================================= */

/* ---- 顶栏 ---- */
.gate .topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) 0;
  max-width: 1180px;
  margin: 0 auto;
}
.gate .topbar .logo { display: flex; align-items: center; gap: var(--sp-2); }
.gate .topbar .name { font-family: var(--font-display); font-size: var(--fs-d3); color: var(--moss); }

/* ---- 页面容器 — 撑满视口，内容垂直居中 ---- */
.gate .onboard-hero {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-6) var(--sp-8);
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.gate [hidden] { display: none !important; }

/* ---- hero 两栏（不对称 1.05fr/0.95fr）---- */
.gate .hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: var(--sp-7);
  align-items: center;
  position: relative;
}
.gate .hero-inner::before {
  content: ""; position: absolute; right: -8%; top: 2%;
  width: 480px; height: 420px; z-index: -1;
  background: radial-gradient(circle at 40% 40%, rgba(93, 112, 82, 0.10), transparent 65%);
  border-radius: 58% 42% 46% 54% / 48% 56% 44% 52%;
}

/* ---- 标题 ---- */
.gate .hero-title {
  font-size: clamp(var(--fs-d1), 3.6vw, var(--fs-hero));
  letter-spacing: 0.01em;
}
.gate .hero-title .brand { color: var(--moss); }
.gate .hero-sub { margin-top: var(--sp-4); color: var(--ink-soft); }
.gate .hero-badges { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }

/* ---- 上传区：豆板底纹 + 虚线框 ---- */
.gate .dropzone {
  margin-top: var(--sp-6);
  border: 2px dashed var(--line-strong);
  border-radius: var(--r-card);
  background: var(--surface);
  padding: var(--sp-7) var(--sp-6);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  text-align: center;
  transition: background var(--t-micro) ease-out, border-color var(--t-micro) ease-out;
  cursor: pointer;
}
.gate .dropzone:hover { background: var(--moss-tint); border-color: var(--moss); }
.gate .dropzone .dz-beads { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.gate .dropzone .dz-main { font-weight: 700; font-size: var(--fs-d3); font-family: var(--font-display); }
.gate .dropzone.dragover { border-color: var(--moss); border-style: solid; background: var(--moss-tint); }

/* ---- 拍立得堆 ---- */
.gate .shots {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: var(--sp-5) var(--sp-4);
  justify-content: center;
}
.gate .shots .polaroid { cursor: pointer; transition: transform var(--t-micro) ease-out, box-shadow var(--t-micro) ease-out; }
.gate .shots .polaroid:hover { transform: rotate(0deg) translateY(-4px); box-shadow: var(--shadow-float); z-index: 2; }
.gate .shots .polaroid img { width: 148px; height: 148px; object-fit: cover; }
.gate .shots .polaroid--mini { position: absolute; right: -12px; bottom: -22px; z-index: 1; }
.gate .shots .polaroid--mini img { width: 84px; height: 84px; image-rendering: pixelated; }
.gate .shots-hint { text-align: center; margin-top: var(--sp-5); }

/* ---- S1 二选一 ---- */
.gate .choice-cards-container {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: var(--sp-5);
  align-items: stretch;
}
.gate .choice-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: var(--sp-5);
  display: flex; flex-direction: column; gap: var(--sp-4);
}
.gate .choice-card:hover { border-color: var(--moss); }
.gate .choice-card-header { display: flex; align-items: center; gap: var(--sp-2); }
.gate .choice-card-header .card-title {
  font-family: var(--font-display); font-weight: 600;
  font-size: var(--fs-d3); line-height: 1.25;
}
.gate .thumb-row { display: flex; align-items: center; gap: var(--sp-4); }
.gate .thumb-row .polaroid img { width: 88px; height: 88px; object-fit: cover; }
.gate .choice-card .btn { align-self: flex-start; margin-top: auto; }

/* ---- AI 卡洗底由下方 S1-3 的 token 版规则负责（旧 0.28 硬编码已删）---- */
.gate .style-radio-group { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.gate .opt-row {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--line); padding-top: var(--sp-4);
}

/* ---- 按钮：照抄 gate.html，默认 .btn 大小 ---- */
.gate-replace-link {
  background: none; border: none; cursor: pointer;
  color: var(--ink-soft); font-size: var(--fs-cap);
  text-decoration: underline; text-underline-offset: 2px;
  padding: 0; margin-top: var(--sp-2);
  transition: color var(--t-micro) ease-out;
}
.gate-replace-link:hover { color: var(--ink); }

/* ---- 卡片按钮：token 默认尺寸（.btn 根因已在 style.css 修复，shrink hack 删除）---- */
.gate .choice-card .btn { align-self: flex-start; }

/* ---- 卡片内缩略图 ---- */
.gate .thumb-row .polaroid img { width: 100px; height: 100px; }

/* ---- AI 卡 badge 颜色修正 ---- */
.gate .badge--ai { background: var(--ai-mist); color: var(--surface); }
/* AI 卡内 chip active 用紫色而非绿色 */
.gate .choice-ai .chip.active { background: var(--ai-mist) !important; color: var(--surface) !important; border-color: var(--ai-mist) !important; }

/* ---- S1 修复：覆盖 style.css 冲突规则 ---- */

/* S1-1: .stage 强制 max-width:760px + flex-column，覆盖 hero 两栏 grid */
.gate .stage,
.gate.stage {
  max-width: none;
  display: block;
}
/* S1-2: .empty-hero 覆盖 style.css 的居中对齐 */
.gate .empty-hero {
  text-align: left;
  padding: 0;
  gap: 0;
}
/* S1-3: .choice-card 未限定作用域，gradient bg / inset shadow 覆盖 style2.css */
.gate .choice-card {
  background: var(--surface) !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--r-card) !important;
  box-shadow: none !important;
}
.gate .choice-card.choice-ai {
  background: linear-gradient(180deg, var(--ai-tint), transparent 42%), var(--surface) !important;
}
/* S2-5: body[data-state] 特异性覆盖 .gate 规则 */
.gate body[data-state="S0"] .choice-cards-container,
body[data-state="S0"] .gate .choice-cards-container {
  opacity: 1;
  pointer-events: auto;
  filter: none;
}

/* ---- 移动端 ---- */
@media (max-width: 900px) {
  .gate .hero-inner { grid-template-columns: 1fr; }
  .gate .hero-right { margin-top: var(--sp-5); }
  .gate .shots { margin-top: var(--sp-5); }
  .gate .choice-cards-container { grid-template-columns: 1fr; }
  .gate .topbar { padding-left: var(--sp-4); padding-right: var(--sp-4); }
}

/* =============================================================================
   B8 精修层（2026-06-11 审计修复，Fable 5）
   ============================================================================= */

/* ---- S1: 标题留场，只藏上传区和拍立得堆；卡片原位出现 ---- */
body[data-state="S1-gate"] .gate .dropzone,
body[data-state="S1-gate"] .gate .hero-right { display: none !important; }
body[data-state="S1-gate"] .gate .hero-inner { grid-template-columns: 1fr; align-items: start; }
body[data-state="S1-gate"] .gate .onboard-hero { justify-content: flex-start; padding-top: var(--sp-7); }
.gate .choice-cards-container { margin-top: var(--sp-6); }

/* ---- 工作台: 图纸纸面尺寸（F19 放宽版：吃满可用高度，无嵌套滚动条）---- */
#workspaceLayout #wsBlueprintSection .blueprint-canvas-wrap {
  max-height: none !important;
  overflow: visible !important;
}
#workspaceLayout #wsBlueprintSection canvas {
  max-width: 100%;
  height: auto !important;
  max-height: calc(100vh - 200px);
  width: auto !important;
  box-shadow: var(--shadow-rest);
  border-radius: 2px;
}

/* ---- 工作台: 数据入口归右栏，画布区不放色带（PATTERNS P2）---- */
#workspaceLayout .palette-strip { display: none !important; }

/* ---- appbar: 防按钮拉伸的二道保险 + 内容与画布列对齐 ---- */
.appbar .btn { flex: 0 0 auto; width: auto; white-space: nowrap; }

/* ---- 工作台单列断点：clamp(340px,…) 在窄屏会把右栏挤成一字一行 ---- */
@media (max-width: 1024px) {
  .workspace { grid-template-columns: 1fr; }
  .workspace .canvas-col,
  .workspace .sidebar { grid-column: 1; }
  .workspace .sidebar { position: static; }
}

/* ---- 390px 移动端：logo 不竖排、工具条单行横滚 ---- */
@media (max-width: 600px) {
  .appbar { padding: var(--sp-3) 0; gap: var(--sp-2); }
  .appbar .logo { flex: none; }
  .appbar .logo .name { font-size: var(--fs-body); white-space: nowrap; }
  .appbar .btn { padding: var(--sp-1) var(--sp-3); font-size: var(--fs-cap); }
  .canvas-bar {
    overflow-x: auto; flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .canvas-bar::-webkit-scrollbar { display: none; }
  .canvas-bar .seg-btn { padding: var(--sp-1) var(--sp-3); white-space: nowrap; }
  .canvas-bar .group, .canvas-bar .chip { flex: none; white-space: nowrap; }
  .workspace { padding-left: var(--sp-4); padding-right: var(--sp-4); }
}

/* =============================================================================
   Workflow interaction repair
   ============================================================================= */

html,
body {
  overflow-x: hidden;
}

.logo-button {
  padding: 0;
  color: inherit;
}

main.stage.gate {
  padding: 0;
}
.logo-button:focus-visible,
.export-card:focus-visible,
.gate-replace-link:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 3px;
}

.gate .choice-cards-container {
  position: relative;
  align-items: stretch;
  padding-bottom: var(--sp-5);
  margin: var(--sp-5) auto 0;
}
.gate .choice-card {
  height: 100%;
}
.gate .choice-card .btn {
  width: 100%;
  justify-content: center;
}
.gate .opt-row {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  background: var(--bg-soft);
}
.gate .opt-row__copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gate .opt-row__copy strong {
  font-size: var(--fs-sm);
  color: var(--ink);
}
.gate-replace-link--shared {
  grid-column: 1 / -1;
  justify-self: center;
  margin-top: 0;
}

/* Workspace header — full-width sticky frosted bar (learns from main-repo .topbar):
   brand left, actions right, subtle bottom border. Replaces the old centered pill. */
.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  justify-self: stretch;
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: none;
}
.appbar .spacer {
  flex: 1;
}
.canvas-bar {
  align-self: center;
  width: max-content;
  max-width: 100%;
}
.mirror-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mirror-button svg {
  width: 18px;
  height: 18px;
}

.edit-context-panel {
  width: min(100%, 980px);
  margin-top: var(--sp-3);
  padding: var(--sp-3);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--sp-4);
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--shadow-rest);
}
.edit-context-panel[hidden] {
  display: none !important;
}
.edit-context-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}
.edit-context-panel .toolbar-palette {
  max-height: 112px;
  overflow-y: auto;
}

body[data-state="S4"] #workspaceLayout.workspace {
  grid-template-columns: minmax(0, 1fr);
  max-width: none;
}
body[data-state="S4"] #workspaceLayout .sidebar {
  display: none !important;
}
body[data-state="S4"] #workspaceLayout .canvas-col {
  grid-column: 1 / -1;
}
body[data-state="S4"] #workspaceLayout .stage {
  width: 100%;
  max-width: none;
  min-height: calc(100vh - 170px);
  overflow: auto;
}
body[data-state="S4"] #workspaceLayout .board {
  width: max-content;
  max-height: none;
}
body[data-state="S4"] #workspaceLayout .board-wrap {
  flex: none;
  height: auto;
}
body[data-state="S4"] #mosaicCanvas {
  max-height: calc(100vh - 230px);
}

@media (min-width: 1100px) {
  body[data-state="S4"] .edit-context-panel {
    position: absolute;
    top: var(--sp-5);
    right: var(--sp-5);
    z-index: 12;
    width: 286px;
    max-height: calc(100% - var(--sp-6) * 2);
    margin: 0;
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  body[data-state="S4"] .edit-context-panel .toolbar-palette {
    max-height: 200px;
  }
}

#workspaceLayout #wsBlueprintSection .blueprint-canvas-wrap {
  max-height: calc(100vh - 165px) !important;
  overflow: auto !important;
}
#workspaceLayout #wsBlueprintSection canvas {
  max-height: none !important;
}

.export-card {
  appearance: none;
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
}
.export-card:disabled {
  opacity: .6;
  cursor: wait;
}

@media (min-width: 901px) {
  body[data-state="S0"],
  body[data-state="S1-gate"] {
    overflow-y: hidden;
  }
  .gate .onboard-hero {
    min-height: calc(100vh - 66px);
    max-height: calc(100vh - 66px);
    padding: var(--sp-3) var(--sp-6);
  }
  .gate .hero-inner {
    gap: var(--sp-5);
  }
  .gate .hero-title {
    font-size: clamp(2rem, 3.1vw, 3.25rem);
  }
  .gate .hero-sub {
    margin-top: var(--sp-2);
  }
  .gate .dropzone {
    margin-top: var(--sp-4);
    padding: var(--sp-5) var(--sp-6);
  }
  .gate .shots {
    gap: var(--sp-3);
  }
  .gate .shots .polaroid img {
    width: 122px;
    height: 122px;
  }
  body[data-state="S1-gate"] .gate .onboard-hero {
    padding-top: var(--sp-4);
  }
  body[data-state="S1-gate"] .gate .choice-cards-container {
    margin-top: var(--sp-5);
  }
  body[data-state="S1-gate"] .gate #emptyHero {
    gap: var(--sp-5);
  }
}

@media (max-width: 900px) {
  body[data-state="S0"],
  body[data-state="S1-gate"] {
    overflow-y: auto;
  }
  .gate .onboard-hero {
    min-height: auto;
    max-height: none;
  }
  .edit-context-panel {
    grid-template-columns: 1fr;
  }
  .appbar,
  .canvas-bar {
    width: 100%;
  }
}
