/* ==================================================================
   GIF 工坊 — 编辑/版画海报风（editorial riso poster）
   纸白 + 墨黑 + 深绿 + 酸性柠檬绿。平面、硬边、硬投影，无发光无玻璃。
   显示体：得意黑（自托管子集）。数据体：等宽。无外部请求。
   ================================================================== */

@font-face {
  font-family: "Smiley Sans";
  src: url("/fonts/smiley.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
}

:root {
  --paper:   oklch(0.974 0.004 150);
  --paper-2: oklch(0.945 0.007 150);
  --ink:     oklch(0.185 0.014 152);
  --ink-2:   oklch(0.40 0.014 152);
  --ink-3:   oklch(0.55 0.012 152);

  --green:       oklch(0.50 0.145 150);
  --green-press: oklch(0.42 0.145 150);
  --on-green:    oklch(0.985 0.01 150);
  --acid:        oklch(0.87 0.175 132);   /* 酸性柠檬绿，配墨黑文字 */
  --acid-press:  oklch(0.81 0.18 132);
  --error:       oklch(0.55 0.20 28);

  --line: var(--ink);
  --shadow-1: 3px 3px 0 var(--ink);
  --shadow-2: 6px 6px 0 var(--ink);

  --r: 7px;

  --ease:  cubic-bezier(0.2, 0.9, 0.25, 1);
  --snap:  cubic-bezier(0.34, 1.4, 0.5, 1);
  --dur: 180ms;

  --display: "Smiley Sans", system-ui, sans-serif;
  --ui: system-ui, -apple-system, "Segoe UI", "PingFang SC",
        "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Segoe UI Mono", Consolas, monospace;

  --z-sticky: 20;
  --z-toast: 60;
  color-scheme: light;
}

/* ----- reset ----- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--ui);
  font-size: 15px; line-height: 1.55;
  color: var(--ink); background: var(--paper);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  min-height: 100dvh; display: flex; flex-direction: column;
  overflow-x: hidden;
}
/* 极淡纸张颗粒（质感，非发光） */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: 0.035; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
img, svg, video { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -56px; z-index: var(--z-toast);
  background: var(--ink); color: var(--paper); padding: 9px 16px;
  border-radius: var(--r); text-decoration: none; font-weight: 600;
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: 12px; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
::selection { background: var(--acid); color: var(--ink); }

/* ================= 顶部 masthead ================= */
.masthead { width: 100%; max-width: 780px; margin: 0 auto; padding: clamp(26px, 5vw, 44px) 22px 0; }
.masthead__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding-bottom: 12px; border-bottom: 2px solid var(--ink); flex-wrap: wrap;
}
.brand {
  font-family: var(--display); font-size: 21px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 9px; letter-spacing: 0.01em;
}
.brand__glyph {
  display: inline-grid; place-items: center; width: 26px; height: 26px;
  background: var(--ink); color: var(--acid); border-radius: 5px;
  font-size: 12px; padding-left: 2px;
}
.masthead__tag {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-2);
}
.hero {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(3rem, 11.5vw, 5.6rem); line-height: 0.96;
  letter-spacing: -0.005em; margin-top: clamp(18px, 4vw, 30px);
}
.hero__l1, .hero__l2 { display: inline-block; }
.hero mark {
  background: var(--acid); color: var(--ink);
  padding: 0 0.12em; margin: 0 -0.04em;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
  box-shadow: var(--shadow-1);
}
.hero__sub {
  font-family: var(--mono); font-size: clamp(0.82rem, 2.4vw, 0.95rem);
  color: var(--ink-2); margin-top: 18px; letter-spacing: 0.01em;
}

/* ================= 跑马灯 ================= */
.ticker {
  margin: clamp(22px, 5vw, 36px) 0 0; padding: 9px 0;
  background: var(--ink); color: var(--acid);
  border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
  overflow: hidden; white-space: nowrap;
}
.ticker__track { display: inline-flex; will-change: transform; animation: marquee 18s linear infinite; }
.ticker__track span {
  font-family: var(--display); font-weight: 700; font-size: 16px;
  letter-spacing: 0.08em; padding-right: 0; flex: none;
}
@keyframes marquee { to { transform: translateX(-50%); } }
.ticker:hover .ticker__track { animation-play-state: paused; }

/* ================= 主区 / 面板 ================= */
.stage { width: 100%; max-width: 780px; margin: 0 auto; padding: clamp(26px, 5vw, 44px) 22px 40px; flex: 1; }
.stage:focus { outline: none; }

.panel {
  position: relative; background: var(--paper);
  border: 2px solid var(--ink); border-radius: var(--r);
  padding: clamp(20px, 4vw, 30px);
  box-shadow: var(--shadow-2);
  animation: panel-in 360ms var(--ease) both;
}
@keyframes panel-in { from { opacity: 0; transform: translate(-4px, 8px); } to { opacity: 1; transform: none; } }

/* ================= dropzone ================= */
.dropzone { border-style: dashed; background: var(--paper-2); transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.dropzone.is-dragging { background: var(--acid); border-style: solid; }
.dropzone__inner { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 15px; padding: clamp(14px, 3vw, 26px) 6px; }
.dropzone__emblem {
  display: grid; place-items: center; width: 60px; height: 60px;
  border: 2px solid var(--ink); border-radius: var(--r);
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow-1);
  transition: transform var(--dur) var(--snap);
}
.dropzone.is-dragging .dropzone__emblem { transform: translateY(-3px) rotate(-4deg); background: var(--paper); }
.dropzone__title { font-family: var(--display); font-weight: 700; font-size: clamp(1.7rem, 6vw, 2.4rem); line-height: 1.0; }
.formats { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.formats span {
  font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--ink); padding: 4px 9px; border: 1.5px solid var(--ink); border-radius: 999px;
  background: var(--paper);
}
.steps {
  list-style: none; padding: 0; margin-top: 4px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px;
  color: var(--ink-2); font-size: 13px;
}
.steps li { display: inline-flex; align-items: center; gap: 8px; }
.steps b { font-family: var(--mono); font-weight: 700; color: var(--green); font-size: 12px; }

/* ================= 按钮 ================= */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; border: 2px solid var(--ink); border-radius: var(--r);
  background: var(--paper); color: var(--ink);
  font-family: var(--display); font-size: 16px; font-weight: 700; letter-spacing: 0.01em;
  text-decoration: none; white-space: nowrap; box-shadow: var(--shadow-1);
  transition: transform 120ms var(--ease), box-shadow 120ms var(--ease), background var(--dur) var(--ease);
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--ink); }
.btn--primary { background: var(--green); color: var(--on-green); }
.btn--primary:hover { background: var(--green-press); }
.btn--ghost { background: var(--paper); }
.btn--ghost:hover { background: var(--paper-2); }
.btn--sm { padding: 7px 13px; font-size: 13.5px; box-shadow: 2px 2px 0 var(--ink); }
.btn--lg { padding: 13px 28px; font-size: 18px; }
.btn--block { width: 100%; margin-top: 6px; padding: 15px 24px; font-size: 19px; }
.btn[disabled], .btn.is-busy { cursor: not-allowed; pointer-events: none; }
.btn.is-busy { background: var(--paper-2); color: var(--ink-2); box-shadow: var(--shadow-1); transform: none; }

/* 转换中：帧条 loader */
.btn__loader { display: none; gap: 5px; align-items: center; height: 18px; }
.btn.is-busy .btn__loader { display: inline-flex; }
.btn.is-busy .btn__label { display: none; }
.btn__loader i {
  width: 5px; height: 18px; background: var(--green); display: inline-block;
  transform-origin: center; animation: frame-bar 0.9s var(--ease) infinite;
}
.btn__loader i:nth-child(2) { animation-delay: 0.1s; }
.btn__loader i:nth-child(3) { animation-delay: 0.2s; }
.btn__loader i:nth-child(4) { animation-delay: 0.3s; }
.btn__loader i:nth-child(5) { animation-delay: 0.4s; }
@keyframes frame-bar { 0%,100% { transform: scaleY(0.35); } 45% { transform: scaleY(1); } }
.btn__progress { font-family: var(--mono); font-size: 13px; color: var(--ink-2); }

/* ================= 工作区 ================= */
.workspace { display: flex; flex-direction: column; gap: 18px; }
.workspace__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.workspace__title { font-family: var(--display); font-size: 22px; font-weight: 700; }

/* 帧（缩略图）— 胶片风，硬边 */
.thumbs { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px; }
.thumb {
  position: relative; aspect-ratio: 1; border: 2px solid var(--ink); border-radius: var(--r);
  overflow: hidden; background: var(--paper-2); box-shadow: var(--shadow-1);
  transition: transform 160ms var(--ease), box-shadow 160ms var(--ease);
  animation: thumb-in 320ms var(--snap) both;
}
@keyframes thumb-in { from { opacity: 0; transform: translateY(10px) rotate(-2deg); } to { opacity: 1; transform: none; } }
.thumb:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.thumb.is-leaving { animation: thumb-out 220ms var(--ease) both; }
@keyframes thumb-out { to { opacity: 0; transform: scale(0.85) rotate(3deg); } }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
/* 胶片齿孔（硬色块） */
.thumb::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 8px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 5px, transparent 5px 10px);
  opacity: 0; transition: opacity 160ms var(--ease);
}
.thumb:hover::after { opacity: 0.85; }
.thumb__index {
  position: absolute; top: 0; left: 0; min-width: 22px; height: 22px; padding: 0 6px; z-index: 2;
  display: grid; place-items: center; background: var(--ink); color: var(--acid);
  border-bottom-right-radius: var(--r);
  font-family: var(--mono); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.thumb__remove {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; padding: 0; z-index: 2;
  display: grid; place-items: center; line-height: 1;
  background: var(--paper); color: var(--ink); border: 2px solid var(--ink); border-radius: 6px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.thumb__remove:hover { background: var(--error); color: var(--paper); }
.thumb__move {
  position: absolute; inset: auto 0 0 0; z-index: 2; display: flex; justify-content: space-between;
  padding: 6px; gap: 6px; opacity: 0; transition: opacity var(--dur) var(--ease);
}
.thumb:hover .thumb__move, .thumb:focus-within .thumb__move { opacity: 1; }
@media (hover: none) { .thumb__move { opacity: 1; } }
.thumb__move button {
  width: 28px; height: 28px; padding: 0; display: grid; place-items: center;
  background: var(--acid); color: var(--ink); border: 2px solid var(--ink); border-radius: 6px;
  transition: transform 120ms var(--snap);
}
.thumb__move button:hover:not(:disabled) { transform: scale(1.12); }
.thumb__move button:disabled { opacity: 0.3; }

.addmore {
  align-self: start; padding: 9px 16px; background: var(--paper); color: var(--ink);
  border: 2px dashed var(--ink); border-radius: var(--r);
  font-family: var(--display); font-size: 15px; font-weight: 700;
  transition: background var(--dur) var(--ease), transform 120ms var(--ease);
}
.addmore:hover { background: var(--acid); transform: translate(-1px, -1px); }

/* 视频编辑 */
.video-edit { display: flex; flex-direction: column; gap: 10px; }
.video-edit__frame { border: 2px solid var(--ink); border-radius: var(--r); overflow: hidden; background: var(--ink); box-shadow: var(--shadow-1); }
.video-edit__preview { width: 100%; max-height: 340px; background: var(--ink); }
.video-edit__meta { font-family: var(--mono); color: var(--ink-2); font-size: 12.5px; }

/* ================= 选项 ================= */
.options { display: flex; flex-direction: column; border-top: 2px solid var(--ink); padding-top: 6px; }
.field { display: flex; align-items: center; gap: 14px; padding: 13px 0; flex-wrap: wrap; }
.field + .field { border-top: 1px dashed var(--ink); }
.field__label { flex: 0 0 64px; font-family: var(--display); font-weight: 700; font-size: 15px; }
.field__unit { font-family: var(--mono); color: var(--ink-3); font-size: 12px; }

.segmented { display: inline-flex; border: 2px solid var(--ink); border-radius: var(--r); overflow: hidden; }
.segmented button {
  padding: 7px 16px; border: none; background: var(--paper); color: var(--ink-2);
  font-family: var(--display); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums;
  border-right: 2px solid var(--ink); transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.segmented button:last-child { border-right: none; }
.segmented button:hover { background: var(--paper-2); color: var(--ink); }
.segmented button.is-active { background: var(--ink); color: var(--acid); }

.trim { display: flex; gap: 18px; flex-wrap: wrap; }
.trim label { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 13px; }
.trim input {
  width: 80px; padding: 8px 10px; border: 2px solid var(--ink); border-radius: 6px;
  background: var(--paper); color: var(--ink);
  font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right;
}
.trim input:focus { outline: 3px solid var(--green); outline-offset: 1px; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 11px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  position: relative; width: 46px; height: 26px; border-radius: 999px;
  background: var(--paper); border: 2px solid var(--ink);
  transition: background var(--dur) var(--ease);
}
.switch__track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink); transition: transform var(--dur) var(--snap), background var(--dur) var(--ease);
}
.switch input:checked + .switch__track { background: var(--green); }
.switch input:checked + .switch__track::after { transform: translateX(20px); background: var(--acid); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--green); outline-offset: 2px; }
.switch__text { font-size: 14px; }

/* ================= 结果 ================= */
.result { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.result__kicker { font-family: var(--display); font-weight: 700; font-size: 20px; }
.result__kicker mark {
  background: var(--acid); color: var(--ink); padding: 2px 12px; border: 2px solid var(--ink);
  border-radius: 999px; box-shadow: var(--shadow-1);
  display: inline-block;
}
.result.is-revealing .result__kicker mark { animation: stamp 480ms var(--snap) both; }
@keyframes stamp { from { transform: scale(0.6) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
.result__preview {
  width: 100%; display: grid; place-items: center; padding: 18px;
  border: 2px solid var(--ink); border-radius: var(--r);
  background: repeating-conic-gradient(var(--paper-2) 0% 25%, var(--paper) 0% 50%) 50% / 22px 22px;
}
.result__preview img {
  max-width: 100%; max-height: 58vh; border: 2px solid var(--ink); border-radius: 4px;
  box-shadow: var(--shadow-2); animation: pop-in 420ms var(--snap) both;
}
@keyframes pop-in { from { opacity: 0; transform: scale(0.9) translateY(8px); } to { opacity: 1; transform: none; } }
.result__meta { font-family: var(--mono); color: var(--ink-2); font-size: 13px; }
.result__actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ================= footer ================= */
.site-footer { text-align: center; font-family: var(--mono); color: var(--ink-3); font-size: 11.5px; padding: 14px 22px 28px; max-width: 780px; margin: 0 auto; }

/* ================= toast ================= */
.toast-region { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: var(--z-toast); display: flex; flex-direction: column; gap: 10px; width: min(92vw, 440px); pointer-events: none; }
.toast {
  pointer-events: auto; padding: 13px 17px; border: 2px solid var(--ink); border-radius: var(--r);
  background: var(--ink); color: var(--paper); box-shadow: var(--shadow-2);
  font-size: 13.5px; line-height: 1.45; animation: toast-in 280ms var(--snap) both;
}
.toast--error { background: var(--error); }
.toast.is-leaving { animation: toast-out 200ms var(--ease) both; }
@keyframes toast-in  { from { opacity: 0; transform: translate(-4px, 14px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ================= 响应式 ================= */
@media (max-width: 480px) {
  .masthead__bar { gap: 8px; }
  .btn--block { font-size: 17px; }
}

/* ================= 降低动效 ================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important; scroll-behavior: auto !important;
  }
  .ticker__track { animation: none; }
}
