/* 小津助手 v2.1 — 工坊 (js/views/workshop.js): scene header + bento home (A's AI 生图 hero, B's illustrated
   tiles, C's daily-challenge strip) and the four tool sub-pages. Owned by the 工坊 view developer.
   Tokens only; the inline illustrations take their fills from the classes below so dark mode follows.
   Compatibility: no color-mix(), :has(), nesting, @container, @layer, dvh. */

/* ---------- illustration fills (token-coloured) ---------- */
#view-workshop svg .f-surface { fill: var(--surface); }
#view-workshop svg .f-line { fill: var(--line-strong); }
#view-workshop svg .f-ink-2 { fill: var(--text-2); }
#view-workshop svg .f-primary { fill: var(--primary); }
#view-workshop svg .f-primary-soft { fill: var(--primary-soft-press); }
#view-workshop svg .f-teal { fill: var(--teal); }
#view-workshop svg .f-teal-l { fill: var(--code-func); }
#view-workshop svg .f-amber { fill: var(--amber); }
#view-workshop svg .f-amber-soft { fill: var(--amber-soft); }
#view-workshop svg .f-amber-soft-2 { fill: var(--amber); opacity: .4; }
#view-workshop svg .f-rose { fill: var(--rose); }
#view-workshop svg .f-rose-soft { fill: var(--rose-soft); }
#view-workshop svg .f-life { fill: var(--life-ink); }
#view-workshop svg .f-sky { fill: var(--teal-soft); }
#view-workshop svg .f-orange { fill: var(--workshop-ink); }
#view-workshop svg .f-code { fill: var(--code-bg); }
#view-workshop svg .f-kw { fill: var(--code-keyword); }
#view-workshop svg .f-fn { fill: var(--code-func); }
#view-workshop svg .f-str { fill: var(--code-string); }
#view-workshop svg .f-num { fill: var(--code-number); }
#view-workshop svg .s-surface { stroke: var(--surface); }
#view-workshop svg .s-ink { stroke: var(--text); }
#view-workshop svg .s-ink-3 { stroke: var(--text-3); }
#view-workshop svg .s-orange { stroke: var(--workshop-ink); }
#view-workshop svg .s-orange-2 { stroke: var(--workshop-text); }

/* Keep the root's own layers (the overlay top bar) inside it, under the sub-pages (z-index 2). */
#view-workshop > .view-root { isolation: isolate; }
.ws-hero .ws-pill { position: absolute; top: calc(var(--safe-top) + 12px); right: var(--page-x); z-index: 2; max-width: calc(100% - 2 * var(--page-x)); }

/* Status-bar scrim: has height only with a safe-area inset (iOS standalone / notch), shows once scrolled.
   The scene header is the page title, so there is no compact top bar (DESIGN-v21 §2 / FOUNDATION §4). */
#view-workshop .ws-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  height: var(--safe-top);
  background: var(--bg-elev);
  box-shadow: 0 1px 0 var(--line);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease-out);
}
#view-workshop .ws-bar.is-scrolled { opacity: 1; }

/* ---------- header: the weather scene ---------- */
.ws-hero {
  display: flex;
  flex-direction: column;
  min-height: calc(var(--safe-top) + 176px);
  padding: calc(var(--safe-top) + 40px) var(--page-x) 24px;
}
.ws-title { color: var(--scene-ink, var(--text)); font-size: var(--fs-3xl); font-weight: var(--fw-bold); line-height: var(--lh-tight); }
.ws-sub { margin-top: 4px; color: var(--scene-ink-2, var(--text-2)); font-size: var(--fs-base); line-height: var(--lh-wrap); }
[data-ink="light"] .ws-title, [data-ink="light"] .ws-sub { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18); }
.ws-home { margin-top: -28px; }
.ws-list { position: relative; display: flex; flex-direction: column; gap: var(--sp-3); }

/* ---------- A: the AI 生图 hero card ---------- */
.ws-feature {
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
  text-align: left;
  color: var(--text);
}
.ws-feature-art {
  position: relative;
  display: block;
  height: 148px;
  background-color: var(--workshop-soft);
  background-image: radial-gradient(circle, var(--line-strong) 1px, var(--bg-fade) 1.6px);
  background-size: 16px 16px;
  background-position: 6px 6px;
}
.ws-prompt {
  position: absolute;
  left: 14px;
  top: 26px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 47%;
  max-width: 190px;
  padding: 10px 12px 12px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  transform: rotate(-3deg);
}
.ws-prompt-label { display: inline-flex; align-items: center; gap: 4px; color: var(--workshop-text); font-size: var(--fs-xs); font-weight: var(--fw-semibold); line-height: var(--lh-ui); }
.ws-prompt-label .icon { width: 14px; height: 14px; }
.ws-prompt-text { color: var(--text); font-size: var(--fs-sm); line-height: var(--lh-wrap); }
.ws-frame {
  position: absolute;
  display: block;
  padding: 5px 5px 14px;
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}
.ws-frame svg { display: block; width: 100%; height: 100%; border-radius: 4px; }
.ws-frame.is-back { right: 92px; top: 30px; width: 78px; height: 92px; transform: rotate(-7deg); }
.ws-frame.is-front { right: 14px; top: 14px; width: 100px; height: 118px; transform: rotate(5deg); }
.ws-feature.is-pressed .ws-frame.is-front, .ws-feature:active .ws-frame.is-front { transform: rotate(8deg) translateY(-2px); }
.ws-frame.is-front { transition: transform var(--dur-slow) var(--ease-spring); }
@media (max-width: 374px) {
  .ws-prompt { width: 50%; }
  .ws-frame.is-back { right: 76px; width: 66px; height: 80px; }
  .ws-frame.is-front { width: 88px; height: 106px; }
}
.ws-feature-body { display: flex; align-items: center; gap: var(--sp-3); padding: 14px var(--sp-4) 16px; }
.ws-feature-title { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: var(--lh-tight); }
.ws-feature-sub { display: block; margin-top: 4px; color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh-wrap); }

/* ---------- B: illustrated tiles in C's bento rhythm ---------- */
.ws-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.ws-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  padding: 6px 6px 12px;
  text-align: left;
  color: var(--text);
}
.ws-tile-art {
  position: relative;
  display: block;
  width: 100%;
  height: 92px;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--tone-soft, var(--surface-2));
}
.ws-tile-art svg { display: block; width: 100%; height: 100%; transition: transform var(--dur-slow) var(--ease-spring); }
.ws-tile.is-pressed .ws-tile-art svg, .ws-tile:active .ws-tile-art svg { transform: translateY(-2px); }
.ws-tile-title { display: block; margin: 10px 8px 0; font-size: var(--fs-lg); font-weight: var(--fw-semibold); line-height: var(--lh-ui); }
.ws-tile-sub { display: block; min-height: 39px; margin: 2px 8px 0; color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh-wrap); }
.ws-tile-tag { margin: 8px 8px 0; }
.ws-tile-tag .icon { width: 13px; height: 13px; }

/* ---------- C: the daily-challenge strip ---------- */
.ws-strip {
  display: flex;
  align-items: stretch;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-4);
  text-align: left;
  color: var(--text);
}
.ws-strip-main { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.ws-strip-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.ws-strip-title { display: block; margin-top: 10px; font-size: var(--fs-base); font-weight: var(--fw-semibold); line-height: var(--lh-wrap); overflow-wrap: anywhere; }
.ws-strip-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-top: 12px; }
.ws-streak { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); font-size: var(--fs-sm); line-height: var(--lh-ui); }
.ws-streak .icon { width: 16px; height: 16px; color: var(--text-3); }
.ws-streak.is-on { color: var(--amber-text); font-weight: var(--fw-semibold); }
.ws-streak.is-on .icon { color: var(--amber); --dt: .35; }
.ws-strip-go {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-full);
  background: var(--amber);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  box-shadow: var(--lip);
}
[data-theme="dark"] .ws-strip-go { color: var(--text-inverse); }
.ws-strip-art { flex: none; width: 92px; height: 78px; align-self: center; }
.ws-strip-art svg { display: block; width: 100%; height: 100%; }
@media (max-width: 359px) { .ws-strip-art { display: none; } }

/* ---------- shared sub-page bits ---------- */
.ws-intro-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.ws-intro-art { position: relative; flex: none; width: 76px; height: 60px; overflow: hidden; border-radius: var(--r-md); background: var(--tone-soft, var(--surface-2)); }
.ws-intro-art svg { display: block; width: 100%; height: 100%; }
.ws-intro { margin: 0; color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh-wrap); }
.ws-go { margin-top: var(--sp-4); }
.ws-card { padding: var(--sp-4); }
.ws-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.ws-actions.is-stacked { flex-direction: column; margin-top: var(--sp-4); }
.ws-error {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

/* ---------- 圆桌讨论 ---------- */
.ws-debate .textarea, .ws-image .textarea { min-height: 88px; }
.debate-models .chip .icon { width: 16px; height: 16px; }
.debate-result { margin-top: var(--sp-2); }
.collapse + .collapse { border-top: 1px solid var(--line); }
.collapse-head .row-chevron { transition: transform var(--dur) var(--ease-out); }
.collapse-head[aria-expanded="true"] .row-chevron { transform: rotate(180deg); }
.collapse-body { padding: 0 var(--sp-4) var(--sp-4); }

/* ---------- AI 生图 ---------- */
.img-compose {
  margin-top: var(--sp-3);
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.img-compose-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh-wrap); }
.img-compose .chip-scroll { margin: 0 calc(-1 * var(--sp-3)); padding: 5px var(--sp-3); }
.img-label { margin-top: var(--sp-3); color: var(--text-3); font-size: var(--fs-xs); font-weight: var(--fw-semibold); line-height: var(--lh-ui); }
.img-auto-off { margin-top: var(--sp-3); }
.img-note { margin-top: var(--sp-2); }
.img-quick { margin-top: var(--sp-4); }
.img-hint { font-weight: var(--fw-regular); }
.img-expire { display: flex; align-items: flex-start; gap: 4px; margin: 0 0 var(--sp-3); }
.img-expire .icon { flex: none; width: 14px; height: 14px; margin-top: 3px; }
.gallery { display: grid; gap: var(--sp-4); }
@media (min-width: 600px) { .gallery { grid-template-columns: 1fr 1fr; } }
.gen-card { margin: 0; overflow: hidden; border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-1); }
.gen-img { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 1 / 1; background: var(--surface-2); }
.gen-img img { width: 100%; height: 100%; object-fit: cover; -webkit-touch-callout: default; }
.gen-img.is-loading .skeleton { position: absolute; top: 0; right: 0; bottom: 0; left: 0; height: auto; border-radius: 0; }
.gen-wait { position: relative; color: var(--text-2); font-size: var(--fs-sm); }
.gen-img.is-error, .gen-img.is-broken { flex-direction: column; gap: var(--sp-3); padding: var(--sp-5); }
.gen-card figcaption { padding: var(--sp-3) var(--sp-4) var(--sp-3); }
.gen-prompt { color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh-wrap); }
.gen-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }

/* ---------- 每日编程挑战 ---------- */
.ch-back { margin: var(--sp-2) 0 0 calc(-1 * var(--sp-2)); }
.ch-card {
  position: relative;
  margin-top: var(--sp-3);
  padding: var(--sp-4);
  overflow: hidden;
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.ch-art { float: right; width: 64px; height: 54px; margin: -2px -4px 8px 12px; }
.ch-art svg { display: block; width: 100%; height: 100%; }
.ch-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ch-status { clear: both; }
.ch-title { margin-top: var(--sp-3); font-size: var(--fs-xl); font-weight: var(--fw-semibold); line-height: var(--lh-wrap); }
.ch-brief { margin-top: var(--sp-2); color: var(--text-2); line-height: var(--lh-prose); }
.ch-status { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--line); font-size: var(--fs-sm); line-height: var(--lh-ui); }
.ch-done { display: inline-flex; align-items: center; gap: 4px; color: var(--teal-text); font-weight: var(--fw-semibold); }
.ch-done .icon { width: 16px; height: 16px; --dt: .2; }
.ch-streak { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); }
.ch-streak .icon { width: 16px; height: 16px; }
.ch-streak.is-on { color: var(--amber-text); font-weight: var(--fw-semibold); }
.ch-streak.is-on .icon { color: var(--amber); --dt: .35; }
.hint-group .row { --row-inset: calc(var(--sp-4) + 22px + var(--sp-3)); }
.hint-row { align-items: flex-start; font-size: var(--fs-sm); line-height: var(--lh-prose); }
.hint-no {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--amber-soft);
  color: var(--amber-text);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}

/* ---------- 文档助手 ---------- */
.doc-head { display: flex; align-items: center; gap: var(--sp-3); margin: var(--sp-4) 0 var(--sp-3); }
.doc-head-main { flex: 1; min-width: 0; }
.doc-kicker { color: var(--text-3); font-size: var(--fs-xs); line-height: var(--lh-ui); }
.doc-name { font-size: var(--fs-xl); font-weight: var(--fw-semibold); line-height: var(--lh-wrap); }
.doc-form .field + .field { margin-top: var(--sp-4); }
.doc-model { margin-top: var(--sp-4); }
.doc-output { margin-top: var(--sp-2); }
.doc-error { margin-top: var(--sp-3); }

@media (prefers-reduced-motion: reduce) {
  .ws-frame.is-front, .ws-tile-art svg { transition: none; }
  .ws-feature.is-pressed .ws-frame.is-front, .ws-feature:active .ws-frame.is-front { transform: rotate(5deg); }
  .ws-tile.is-pressed .ws-tile-art svg, .ws-tile:active .ws-tile-art svg { transform: none; }
}
