/* ============================================================
   FileForge — giao diện "xưởng in": giấy ngà, mực đen, đỏ dấu
   ============================================================ */

:root {
  --paper: #f5f1e8;
  --paper-dim: #ece6d7;
  --sheet: #fffdf7;
  --ink: #1c1812;
  --ink-soft: #6e6555;
  --accent: #d94f04;
  --accent-deep: #b03e02;
  --line-w: 1.5px;
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --r: 12px;
  --ease: cubic-bezier(.2, .8, .25, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
  font-size: 15.5px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  align-items: center;
}

::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 11px; }
::-webkit-scrollbar-track { background: var(--paper-dim); }
::-webkit-scrollbar-thumb { background: var(--ink); border-radius: 0; }

/* hạt giấy nhiễu rất nhẹ */
.noise {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  opacity: .5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.055'/%3E%3C/svg%3E");
}

.wrap { width: min(820px, calc(100% - 36px)); }

/* ---------------- masthead ---------------- */
.masthead { width: 100%; border-bottom: var(--line-w) solid var(--ink); background: var(--paper); }
.mast-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 46px; height: 46px;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  object-fit: cover;
  display: block;
  flex: 0 0 46px;
}
.wordmark {
  display: block;
  font-family: "Fraunces", serif; font-weight: 900;
  font-size: 24px; letter-spacing: -.02em; line-height: 1.05;
}
.brand-sub { display: block; font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.chip-local {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: "JetBrains Mono", monospace; font-size: 11px; font-weight: 700;
  letter-spacing: .08em;
  border: var(--line-w) solid var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  background: var(--sheet);
}
.chip-local i { width: 8px; height: 8px; border-radius: 50%; background: #2e9e5b; }

/* ---------------- hero ---------------- */
.hero { padding: 52px 0 34px; }
.hero-title {
  font-family: "Fraunces", serif;
  font-weight: 900;
  font-size: clamp(38px, 7vw, 62px);
  line-height: 1.06;
  letter-spacing: -.015em;
}
.hero-title em {
  font-style: italic; font-weight: 500;
  color: var(--accent);
}
.hero-sub {
  max-width: 56ch;
  margin-top: 18px;
  color: var(--ink-soft);
  font-size: 16px;
}

/* ---------------- folder tabs ---------------- */
.folder { margin-top: 6px; }
.folder-tabs { display: flex; gap: 8px; padding-left: 14px; position: relative; z-index: 2; }
.ftab {
  appearance: none;
  display: inline-flex; align-items: center; gap: 9px;
  font: inherit; font-weight: 600; font-size: 14.5px;
  color: var(--ink-soft);
  background: var(--paper-dim);
  border: var(--line-w) solid var(--ink);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  padding: 12px 22px 15px;
  cursor: pointer;
  transform: translateY(4px);
  transition: transform .18s var(--ease), background .18s, color .18s;
}
.ftab svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ftab:hover { transform: translateY(1px); color: var(--ink); }
.ftab.is-active {
  transform: translateY(var(--line-w));
  background: var(--sheet);
  color: var(--ink);
  padding-bottom: calc(15px + var(--line-w));
}

/* ---------------- sheet (tờ giấy chính) ---------------- */
.sheet {
  position: relative; z-index: 1;
  background: var(--sheet);
  border: var(--line-w) solid var(--ink);
  border-radius: 4px 16px 16px 16px;
  box-shadow: var(--shadow);
  padding: 30px 28px 28px;
}

.pane { display: none; }
.pane.is-active { display: block; animation: rise .3s var(--ease); }
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
}

.lab {
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px; font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 9px;
}

/* ---------------- input link ---------------- */
.urlrow {
  display: flex; align-items: center; gap: 10px;
  border: var(--line-w) solid var(--ink);
  border-radius: var(--r);
  background: #fff;
  padding: 2px 12px 2px 16px;
  margin-bottom: 22px;
  transition: box-shadow .15s var(--ease), transform .15s var(--ease);
}
.urlrow:focus-within {
  box-shadow: var(--shadow-sm);
  transform: translate(-1px, -1px);
}
.urlrow input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: none;
  font: inherit; font-size: 15px;
  padding: 14px 0;
  color: var(--ink);
}
.urlrow input::placeholder { color: #a99f8c; }
.svc {
  flex: none;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  background: var(--ink); color: var(--sheet);
  padding: 5px 11px; border-radius: 999px;
}

/* ---------------- format chips ---------------- */
.fmts { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 26px; }
.fmts-col { flex-direction: column; align-items: stretch; margin-bottom: 0; }
.fmt {
  appearance: none;
  display: inline-flex; align-items: center; gap: 10px;
  font: inherit; font-weight: 600; font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: var(--line-w) solid var(--ink);
  border-radius: 10px;
  padding: 10px 15px;
  cursor: pointer;
  transition: all .13s var(--ease);
}
.fmt:hover { transform: translate(-1px, -1px); box-shadow: 2px 2px 0 var(--ink); }
.fmt .ext {
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px; font-weight: 700; letter-spacing: .05em;
  color: var(--ink-soft);
  border: 1px solid currentColor;
  border-radius: 5px;
  padding: 1.5px 6px;
}
.fmt[aria-checked="true"] {
  background: var(--ink); color: var(--sheet);
  transform: none; box-shadow: none;
}
.fmt[aria-checked="true"] .ext { color: var(--sheet); }

/* ---------------- buttons ---------------- */
.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font: inherit; font-weight: 700; font-size: 15px;
  color: var(--ink);
  background: var(--sheet);
  border: var(--line-w) solid var(--ink);
  border-radius: var(--r);
  padding: 13px 22px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .13s var(--ease), box-shadow .13s var(--ease), background .13s;
  text-decoration: none;
}
.btn:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active:not(:disabled) { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: progress; transform: none; }
.btn svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.btn.busy span::after {
  content: "";
  display: inline-block; width: 13px; height: 13px; margin-left: 9px;
  vertical-align: -1.5px;
  border: 2px solid rgba(255,255,255,.45); border-top-color: #fff;
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
.btn:not(.btn-accent).busy span::after { border-color: rgba(28,24,18,.3); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

.linklike {
  appearance: none; background: none; border: 0;
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--accent); cursor: pointer;
  margin-top: 10px; padding: 4px 2px;
}
.linklike:hover { text-decoration: underline; }

/* ---------------- steps ---------------- */
.steps {
  list-style: none;
  margin-top: 26px;
  border-top: 1.5px dashed #cfc6b2;
  padding-top: 18px;
  display: grid; gap: 4px;
}
.steps li {
  display: flex; align-items: center; gap: 13px;
  padding: 7px 2px;
  font-size: 14px; font-weight: 500;
  color: var(--ink-soft);
}
.steps li b {
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px; font-weight: 700;
  width: 30px; height: 26px; flex: none;
  display: grid; place-items: center;
  border: var(--line-w) solid var(--ink);
  border-radius: 7px;
  background: #fff; color: var(--ink);
  transition: all .2s var(--ease);
}
.steps li.active { color: var(--ink); }
.steps li.active b {
  background: var(--accent); border-color: var(--accent-deep); color: #fff;
  animation: nudge .9s ease-in-out infinite alternate;
}
@keyframes nudge { from { transform: translateY(-1px); } to { transform: translateY(1px); } }
.steps li.done b { background: var(--ink); color: var(--sheet); }
.steps li.done { color: var(--ink); }
.steps li.done span { text-decoration: line-through; text-decoration-color: #b3a88f; }

/* ---------------- dropzone ---------------- */
.drop {
  position: relative;
  border: 2px dashed #a89d85;
  border-radius: var(--r);
  padding: 42px 26px 38px;
  text-align: center;
  cursor: pointer;
  outline: none;
  transition: border-color .18s, background .18s, transform .18s var(--ease);
}
.drop:hover, .drop:focus-visible { border-color: var(--ink); background: #fdfaf2; }
.drop.over { border-color: var(--accent); background: #fef6ef; transform: scale(1.008); }
.drop-arrow {
  width: 40px; height: 40px;
  stroke: var(--accent); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round;
  margin-bottom: 10px;
}
.drop-main { font-size: 16px; }
.drop-main strong { font-weight: 700; }
.drop-sub { margin-top: 8px; font-size: 13px; color: var(--ink-soft); line-height: 1.75; }
.drop .corner { position: absolute; width: 14px; height: 14px; border-color: var(--accent); border-style: solid; }
.drop::before, .drop::after,
.drop > .drop-c::before, .drop > .drop-c::after { content: none; }

/* ---------------- pipeline ---------------- */
.pipeline {
  display: grid;
  grid-template-columns: minmax(200px, 5fr) 44px minmax(180px, 4fr);
  gap: 14px;
  align-items: start;
  margin-top: 4px;
  animation: rise .3s var(--ease);
}
.manifest { list-style: none; display: grid; gap: 8px; }
.manifest li {
  display: flex; align-items: center; gap: 10px;
  border: var(--line-w) solid var(--ink);
  border-radius: 10px;
  background: #fff;
  padding: 9px 12px;
}
.mf-idx {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px; font-weight: 700; color: var(--accent);
}
.mf-txt { min-width: 0; flex: 1; }
.mf-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mf-size { font-family: "JetBrains Mono", monospace; font-size: 10.5px; color: var(--ink-soft); }
.mf-x {
  appearance: none; border: 0; background: none;
  font-size: 16px; line-height: 1;
  color: var(--ink-soft); cursor: pointer;
  padding: 2px 5px; border-radius: 6px;
}
.mf-x:hover { color: var(--accent); background: #faeade; }

.pipe-flow { display: flex; align-items: center; justify-content: center; height: 100%; padding-top: 34px; }
#flow-line {
  display: block; width: 100%;
  border-top: 2.5px dashed #b8ac93;
  transition: border-color .2s;
}
#flow-line.on {
  border-top-style: dashed;
  border-color: var(--accent);
  animation: march .5s linear infinite;
}
@keyframes march { to { background-position: 18px 0; } }
#flow-line.on {
  background-image: linear-gradient(90deg, var(--accent) 50%, transparent 50%);
  background-size: 18px 2.5px;
  background-repeat: repeat-x;
  border-color: transparent;
  height: 2.5px;
}

.quality { margin-top: 16px; }
.quality label {
  display: flex; justify-content: space-between;
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  margin-bottom: 8px;
}
.quality output { font-family: "JetBrains Mono", monospace; color: var(--accent); }
.quality input[type=range] {
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 2px; background: var(--ink);
  cursor: pointer;
}
.quality input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 4px;
}
.quality input[type=range]::-moz-range-thumb {
  width: 12px; height: 12px;
  background: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 4px;
}

#btn-conv { margin-top: 24px; }

/* ---------------- result ---------------- */
.result-sheet { margin-top: 26px; overflow: hidden; }
.result-inner { position: relative; padding: 14px 6px 8px; text-align: center; animation: rise .35s var(--ease); }
.stamp {
  position: absolute; top: -8px; right: 2%;
  width: 108px; height: 108px;
  display: grid; place-items: center;
  border: 3.5px solid var(--accent);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2.5px var(--sheet), inset 0 0 0 4.5px var(--accent);
  color: var(--accent);
  font-family: "Fraunces", serif; font-weight: 900; font-size: 30px;
  letter-spacing: .1em; text-indent: .1em;
  transform: rotate(-11deg);
  mix-blend-mode: multiply;
  opacity: 0;
  animation: thump .45s .18s var(--ease) forwards;
}
.stamp::after {
  content: ""; position: absolute; inset: 7px;
  border: 1.5px dashed var(--accent);
  border-radius: 50%;
  opacity: .7;
}
@keyframes thump {
  0% { opacity: 0; transform: rotate(-11deg) scale(1.7); }
  70% { opacity: .95; transform: rotate(-11deg) scale(.96); }
  100% { opacity: .92; transform: rotate(-11deg) scale(1); }
}
.r-kicker {
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.r-name {
  margin: 12px auto 4px; max-width: 82%;
  font-family: "JetBrains Mono", monospace; font-size: 14.5px; font-weight: 500;
  border: var(--line-w) solid var(--ink);
  background: #fff;
  border-radius: 8px;
  padding: 11px 18px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.r-meta { color: var(--ink-soft); font-size: 13px; margin: 8px 0 20px; }
.r-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; padding-bottom: 8px; }
.r-actions .btn { min-width: 170px; }

/* ---------------- err / toast ---------------- */
.err {
  margin-top: 16px;
  background: #fff;
  border: var(--line-w) solid var(--ink);
  border-left: 6px solid var(--accent);
  border-radius: 10px;
  padding: 13px 16px;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  animation: rise .25s var(--ease);
}

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 9px; justify-items: end; }
.toast {
  background: var(--sheet);
  border: var(--line-w) solid var(--ink);
  border-left-width: 5px;
  border-radius: 10px;
  padding: 11px 15px;
  font-size: 13.5px; font-weight: 500;
  max-width: 340px;
  box-shadow: 3px 3px 0 var(--ink);
  animation: rise .25s var(--ease);
  transition: opacity .3s, transform .3s;
}
.toast.bad { border-left-color: var(--accent); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------------- ticker ---------------- */
.ticker {
  margin-top: 44px;
  border-top: var(--line-w) solid var(--ink);
  border-bottom: var(--line-w) solid var(--ink);
  overflow: hidden;
  background: var(--sheet);
}
.ticker-track {
  display: inline-flex; align-items: center; gap: 26px;
  white-space: nowrap;
  padding: 11px 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px; font-weight: 700; letter-spacing: .14em;
  color: var(--ink-soft);
  animation: slide 36s linear infinite;
}
.ticker-track i { font-style: normal; color: var(--accent); }
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes slide { to { transform: translateX(-50%); } }

.foot {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 20px 0 34px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.foot-mark { font-family: "JetBrains Mono", monospace; font-weight: 700; letter-spacing: .1em; font-size: 11px; }

.sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------------- responsive ---------------- */
@media (max-width: 660px) {
  .sheet { padding: 22px 16px 20px; }
  .hero { padding: 36px 0 26px; }
  .ftab { padding: 11px 14px 14px; font-size: 13.5px; }
  .pipeline { grid-template-columns: 1fr; gap: 10px; }
  .pipe-flow { height: auto; padding: 4px 0; justify-content: stretch; }
  #flow-line { width: 100%; height: 0; border-top: none; background-image: linear-gradient(180deg, var(--accent) 50%, transparent 50%) !important; background-size: 2.5px 18px !important; background-repeat: repeat-y; background-position: center; width: 2.5px; margin: 0 auto; height: 34px; border: 0 !important; }
  .stamp { width: 84px; height: 84px; font-size: 23px; top: -14px; right: 0; }
  .foot { flex-direction: column; gap: 3px; }
  .chip-local { display: none; }
}

/* ── SEO blocks ── */
.seo { margin-top: 40px; display: grid; gap: 28px; }
.seo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.seo-card { background: var(--sheet); border: var(--line-w) solid var(--ink); border-radius: 12px; padding: 18px 16px; box-shadow: 3px 3px 0 var(--ink); }
.seo-card h2 { font-family: "Fraunces", serif; font-size: 17px; font-weight: 900; margin-bottom: 8px; }
.seo-card p { font-size: 13.5px; line-height: 1.65; color: var(--ink-soft); }
.seo-card code { font-family: "JetBrains Mono", monospace; font-size: 11.5px; background: var(--paper-dim); padding: 1px 4px; border-radius: 4px; }
.seo-how { background: var(--sheet); border: var(--line-w) solid var(--ink); border-radius: 12px; padding: 18px 20px; }
.seo-how h2, .seo-faq h2 { font-family: "Fraunces", serif; font-size: 20px; font-weight: 900; margin-bottom: 10px; }
.seo-how ol { padding-left: 18px; display: grid; gap: 6px; font-size: 14px; color: var(--ink-soft); }
.seo-how li strong, .seo-how li em { color: var(--ink); }
.seo-faq { display: grid; gap: 10px; }
.seo-faq details { background: var(--sheet); border: var(--line-w) solid var(--ink); border-radius: 10px; padding: 12px 14px; }
.seo-faq summary { font-weight: 700; font-size: 14px; cursor: pointer; list-style: none; }
.seo-faq summary::-webkit-details-marker { display: none; }
.seo-faq details[open] { box-shadow: 2px 2px 0 var(--ink); }
.seo-faq p { margin-top: 8px; font-size: 13.5px; line-height: 1.65; color: var(--ink-soft); }
@media (max-width: 760px) { .seo-grid { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .ticker-track { animation: none; }
}
