/* The screenplay formatter page and the converter pages
   (screenplay-formatter, fdx-to-pdf, pdf-to-fdx, fountain-to-pdf).
   One stylesheet because the four carry the same tool, the same fmt-*
   elements formatter/formatter.js looks up. Light only, like the site;
   the desk the pages lie on is the one dark surface. The nav and footer
   styles live in chrome.js. See .claude/formatter-registry.md. */

:root {
  --bg: #fafaf9;
  --bg-soft: #f4f4f3;
  --surface: #ffffff;
  --ink: #18181b;
  --ink-2: #3f3f46;
  --muted: #71717a;
  --faint: #a1a1aa;
  --line: #e7e7e6;
  --line-soft: #efefee;

  /* Greenlight — MUST stay in sync with DEFAULT_THEME in chrome.js. */
  --accent: #047857;
  --accent-deep: #065f46;
  --accent-bright: #059669;
  --accent-soft: #34d399;
  --accent-wash: #e7f4ee;
  --accent-ring: rgba(4, 120, 87, 0.15);
  --accent-glow: rgba(5, 150, 105, 0.09);

  /* The desk the pages lie on: the one dark surface on the page. */
  --desk: #1c1c20;
  --desk-line: rgba(255, 255, 255, 0.1);
  --desk-ink: #f4f4f5;
  --desk-muted: #a1a1aa;
  --danger: #b91c1c;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent); color: #fff; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 28px; }

/* nav + footer styles live in chrome.js (the shared site chrome) */

/* ───────────────────── opening ───────────────────── */
.top { padding: 64px 0 34px; }
.top h1 {
  font-family: var(--serif);
  font-size: clamp(40px, 5.4vw, 66px);
  font-weight: 600; letter-spacing: -0.022em; line-height: 1.02;
  margin: 0; text-wrap: balance;
}
.top .lede {
  font-size: 19px; line-height: 1.55; color: var(--ink-2);
  margin: 20px 0 0; max-width: 58ch;
}

/* ───────────────────── the tool ───────────────────── */
.tool {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 22px; align-items: start;
}

/* left: the draft, as it was written */
.draft {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: 90px;
}
.draft.is-dropping { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.draft-top { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; font-size: 13.5px; }
.draft-label { font-size: 14px; font-weight: 600; color: var(--ink); }
.draft textarea {
  width: 100%; min-height: 330px; resize: vertical;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg);
  padding: 14px 16px;
  font-family: var(--sans); font-size: 14.5px; line-height: 1.65; color: var(--ink);
}
.draft textarea::placeholder { color: var(--faint); }
.draft textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; background: var(--surface); }
.draft.has-file textarea { display: none; }

.file-chip {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); padding: 14px 14px 14px 16px;
  font-size: 14.5px; color: var(--ink);
}
.file-chip[hidden] { display: none; }
.file-chip svg { flex: none; color: var(--accent); }
.file-chip span { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.file-chip button {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  cursor: pointer; display: grid; place-items: center;
}
.file-chip button:hover { color: var(--ink); border-color: var(--ink); }

.draft-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; font-size: 13.5px; color: var(--muted); }
.text-btn {
  font: inherit; font-weight: 600; color: var(--accent);
  background: none; border: none; padding: 4px 0; cursor: pointer;
  text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 0.2em;
}
.text-btn:hover { text-decoration-color: currentColor; }

#fmt-challenge:empty { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 14px 24px; border-radius: 999px;
  font-size: 15.5px; font-weight: 600; font-family: var(--sans);
  border: 1px solid transparent; cursor: pointer;
  transition: transform 0.15s, background 0.15s, box-shadow 0.2s, border-color 0.15s;
}
.btn-primary { background: var(--ink); color: #fff; box-shadow: 0 10px 26px -14px rgba(24,24,27,0.7); }
.btn-primary:hover { background: var(--accent); transform: translateY(-2px); box-shadow: 0 16px 34px -14px var(--accent-ring); }
.btn-primary:disabled { background: var(--faint); box-shadow: none; transform: none; cursor: default; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); background: rgba(0,0,0,0.02); }
.btn:focus-visible, .text-btn:focus-visible, .file-chip button:focus-visible, .dl:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}

.progress[hidden] { display: none; }
.progress .track { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress .fill { height: 100%; width: 30%; border-radius: 4px; background: var(--accent); transition: width 0.25s ease-out; }
.progress .fill.is-moving { width: 30%; animation: fmt-slide 1.1s ease-in-out infinite; }
@keyframes fmt-slide { from { transform: translateX(-110%); } to { transform: translateX(340%); } }
.progress p { margin: 9px 0 0; font-size: 13.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.error { margin: 0; font-size: 14px; line-height: 1.5; color: var(--danger); }
.error[hidden] { display: none; }

.fine { margin: 0; font-size: 13px; line-height: 1.55; color: var(--muted); }
.fine a { color: var(--accent); font-weight: 600; }
.fine a:hover { text-decoration: underline; }

/* right: the desk, and the pages on it */
.desk {
  background: var(--desk); color: var(--desk-ink);
  border-radius: 20px; padding: 18px 18px 20px;
  display: flex; flex-direction: column; gap: 14px;
  min-width: 0;
}
.desk-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 2px 4px 0; font-size: 13.5px; }
#fmt-caption { font-weight: 600; }
#fmt-summary { color: var(--desk-muted); font-variant-numeric: tabular-nums; text-align: right; }

.tools { display: grid; gap: 14px; padding: 2px 4px 6px; }
.tools[hidden] { display: none; }
.tools .note { margin: 0; font-size: 13.5px; line-height: 1.5; color: #fde68a; }
.tools .note[hidden] { display: none; }
.fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.field[hidden] { display: none; }
.field label, .paper legend { display: block; font-size: 12.5px; color: var(--desk-muted); margin: 0 0 6px; padding: 0; }
.field input {
  width: 100%; border-radius: 10px; padding: 10px 12px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14);
  color: var(--desk-ink); font: 14.5px var(--sans);
}
.field input::placeholder { color: #71717a; }
.field input:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
.cover-note { grid-column: 2; align-self: center; margin: 0; font-size: 13px; line-height: 1.45; color: var(--desk-muted); }
.cover-note[hidden] { display: none; }

.paper { border: none; margin: 0; padding: 0; min-width: 0; }
.paper .seg { display: inline-flex; border: 1px solid rgba(255,255,255,0.14); border-radius: 10px; padding: 3px; gap: 3px; }
.paper label { cursor: pointer; }
.paper input { position: absolute; opacity: 0; pointer-events: none; }
.paper span { display: block; padding: 7px 12px; border-radius: 7px; font-size: 13.5px; font-weight: 500; color: var(--desk-muted); white-space: nowrap; }
.paper input:checked + span { background: rgba(255,255,255,0.14); color: var(--desk-ink); }
.paper input:focus-visible + span { outline: 2px solid var(--accent-soft); outline-offset: 2px; }

.downloads { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.dl {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px; border-radius: 999px; cursor: pointer;
  font: 600 14.5px var(--sans);
  background: transparent; color: var(--desk-ink);
  border: 1px solid rgba(255,255,255,0.22);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.dl:hover { border-color: #fff; background: rgba(255,255,255,0.06); }
.dl-main { background: #fff; color: var(--ink); border-color: #fff; }
.dl-main:hover { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--ink); }
.dl:focus-visible { outline-color: var(--accent-soft); }
.saved { margin: 0; min-height: 1.4em; font-size: 13px; color: var(--accent-soft); overflow-wrap: anywhere; }
.saved:empty { display: none; }

/* Open in Scriptopus: the one action here that is not a download, and
   the only place the accent is a filled surface on the desk. */
.send { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 18px; align-items: center; padding-top: 16px; border-top: 1px solid var(--desk-line); }
.send[hidden] { display: none; }
.open-btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 22px; border-radius: 999px; cursor: pointer;
  font: 600 15px var(--sans); white-space: nowrap;
  background: var(--accent-bright); color: #fff; border: 1px solid var(--accent-bright);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.open-btn:hover { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--ink); }
.open-btn:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 3px; }
.open-btn img { width: 18px; height: 18px; filter: brightness(0) invert(1); }
.open-btn:hover img { filter: brightness(0); }
.send-note { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--desk-muted); }
.send .saved { grid-column: 1 / -1; }

/* The pages. A sheet is laid out at its real size by the script and
   scaled to the width of its page here, so its lines can never wrap
   differently from the print. */
/* Block layout on purpose: a page hides its overflow, so as a grid or
   flex item its minimum height is zero and a long script's pages were
   squeezed to share the scroller's height instead of scrolling. */
.pages {
  --fmt-scale: 0.6;
  max-height: min(78vh, 900px); overflow-y: auto;
  padding: 6px 4px 10px;
  scrollbar-color: #52525b transparent; scrollbar-width: thin;
}
.pages:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 4px; border-radius: 6px; }
.pages:empty::before {
  content: ""; display: block; margin: 0 auto; max-width: 660px; aspect-ratio: 816 / 1056;
  background: #fff; border-radius: 2px; opacity: 0.9;
}
.fmt-page + .fmt-page { margin-top: 22px; }
.fmt-page {
  position: relative; margin-left: auto; margin-right: auto; max-width: 660px; overflow: hidden;
  background: #fff; border-radius: 2px;
  box-shadow: 0 22px 44px -22px rgba(0,0,0,0.8);
  content-visibility: auto; contain-intrinsic-size: auto 700px;
}
.fmt-sheet { position: absolute; top: 0; left: 0; transform-origin: 0 0; transform: scale(var(--fmt-scale)); }

/* ───────────────────── below the tool ───────────────────── */
.section { padding: 84px 0 0; }
.section h2 {
  font-family: var(--serif);
  font-size: clamp(28px, 3.4vw, 40px); font-weight: 600; letter-spacing: -0.018em; line-height: 1.08;
  margin: 0;
}
.section .intro { font-size: 17px; line-height: 1.6; color: var(--ink-2); margin: 14px 0 0; max-width: 62ch; }
.section .intro a { color: var(--accent); font-weight: 600; }
.section .intro a:hover { text-decoration: underline; }

/* the six elements, with where each one sits on the page */
.elements { margin: 34px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 44px; }
.elements div { padding: 18px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 4px 18px; }
.elements dt { font-weight: 600; font-size: 15.5px; }
.elements dd { margin: 0; font-size: 15px; line-height: 1.55; color: var(--ink-2); }
.elements dd small { display: block; margin-top: 3px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.page-facts { margin: 22px 0 0; padding-top: 18px; border-top: 1px solid var(--line); font-size: 15px; color: var(--ink-2); max-width: 70ch; }

/* what Scriptopus is */
.pitch { margin-top: 84px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 48px 44px; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 36px; align-items: center; }
.pitch h2 { font-family: var(--serif); font-size: clamp(28px, 3.4vw, 40px); font-weight: 600; letter-spacing: -0.018em; line-height: 1.08; margin: 0; }
.pitch p { font-size: 17px; line-height: 1.6; color: var(--ink-2); margin: 16px 0 0; max-width: 54ch; }
.pitch .actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.pitch ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 14px; }
.pitch li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; font-size: 15px; line-height: 1.5; color: var(--ink-2); }
.pitch li svg { color: var(--accent); margin-top: 2px; }
.pitch li strong { color: var(--ink); font-weight: 600; }

/* questions */
.qa-list { margin: 30px 0 0; max-width: 820px; }
details.qa { border-top: 1px solid var(--line); scroll-margin-top: 96px; }
details.qa:last-child { border-bottom: 1px solid var(--line); }
details.qa summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 20px 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
}
details.qa summary::-webkit-details-marker { display: none; }
details.qa summary svg { flex: none; color: var(--muted); transition: transform 0.18s; }
details.qa[open] summary svg { transform: rotate(45deg); }
details.qa summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
details.qa .ans { padding: 0 0 22px; font-size: 16px; line-height: 1.65; color: var(--ink-2); max-width: 68ch; }
details.qa .ans p { margin: 0 0 12px; }
details.qa .ans p:last-child { margin-bottom: 0; }
details.qa .ans a { color: var(--accent); font-weight: 600; }
details.qa .ans a:hover { text-decoration: underline; }

#site-footer-space { height: 96px; }

/* ───────────────────── converter pages ─────────────────────
   A converter page is about a file, so a drop zone stands where the
   formatter's paste box is, and the box folds away under "Or paste". */
.drop {
  display: grid; justify-items: center; gap: 8px; text-align: center;
  border: 1.5px dashed #d4d4d1; border-radius: 14px; background: var(--bg);
  padding: 36px 20px 30px;
}
.draft.is-dropping .drop { border-color: var(--accent); background: var(--accent-wash); }
.draft.has-file .drop, .draft.has-file .paste { display: none; }
.drop svg { color: var(--accent); margin-bottom: 4px; }
.drop strong { font-size: 16.5px; font-weight: 600; letter-spacing: -0.01em; }
.drop span { font-size: 13.5px; line-height: 1.5; color: var(--muted); max-width: 34ch; }
.drop .btn { margin-top: 10px; padding: 11px 22px; font-size: 14.5px; background: var(--surface); }
.paste summary {
  list-style: none; cursor: pointer; display: inline-block;
  font-size: 13.5px; font-weight: 600; color: var(--accent); padding: 2px 0;
}
.paste summary::-webkit-details-marker { display: none; }
.paste summary:hover { text-decoration: underline; }
.paste summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
.paste[open] summary { margin-bottom: 10px; }
.draft .paste textarea { min-height: 220px; }

/* What comes across and what does not: two lists, two markers (a check,
   and a slashed circle), as in index.html's .boundary. */
.carry { margin: 32px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 44px; }
.carry h3 { margin: 0; padding: 0 0 12px; font-size: 15px; font-weight: 600; border-bottom: 1px solid var(--line); }
.carry ul { list-style: none; margin: 0; padding: 0; }
.carry li {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--line-soft);
  font-size: 15px; line-height: 1.55; color: var(--ink-2);
}
.carry li svg { margin-top: 3px; }
.carry .kept svg { color: var(--accent); }
.carry .left svg { color: var(--faint); }
.carry li strong { color: var(--ink); font-weight: 600; }

.steps { margin: 30px 0 0; padding: 0; list-style: none; counter-reset: step; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.steps li { counter-increment: step; padding: 20px 20px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; font-size: 15px; line-height: 1.55; color: var(--ink-2); }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 28px; height: 28px; margin-bottom: 12px; border-radius: 50%; background: var(--accent-wash); color: var(--accent-deep); font-weight: 700; font-size: 14px; }
.steps strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; }

.others { margin: 28px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.others a { display: block; padding: 16px 18px 17px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; transition: border-color 0.15s; }
.others a:hover { border-color: var(--ink); }
.others a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.others strong { display: block; font-size: 15.5px; font-weight: 600; }
.others span { display: block; margin-top: 4px; font-size: 13.5px; line-height: 1.45; color: var(--muted); }

/* ───────────────────── responsive ───────────────────── */
@media (max-width: 980px) {
  .tool { grid-template-columns: minmax(0, 1fr); }
  .draft { position: static; }
  .draft textarea { min-height: 240px; }
  .pitch { grid-template-columns: minmax(0, 1fr); padding: 38px 30px; }
}
@media (max-width: 720px) {
  .wrap { padding: 0 18px; }
  .top { padding: 44px 0 26px; }
  .top .lede { font-size: 17.5px; }
  .draft { padding: 18px; border-radius: 18px; }
  .desk { padding: 14px 12px 16px; border-radius: 18px; }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .send { grid-template-columns: minmax(0, 1fr); }
  .open-btn { justify-content: center; }
  .cover-note { grid-column: auto; }
  .pages { max-height: 76vh; }
  .fmt-page + .fmt-page { margin-top: 16px; }
  .section { padding-top: 64px; }
  .elements { grid-template-columns: minmax(0, 1fr); }
  .elements div { grid-template-columns: minmax(0, 1fr); }
  .carry { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .drop { padding: 28px 16px 24px; }
  .pitch { margin-top: 64px; padding: 30px 22px; border-radius: 20px; }
  .pitch .actions .btn { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .dl, .open-btn, details.qa summary svg, .progress .fill { transition: none; }
  .btn-primary:hover { transform: none; }
  .progress .fill.is-moving { animation: none; width: 100%; opacity: 0.55; }
}
