/* Unwritten — screenwriting app styles */

:root {
  --bg: #14161a;
  --panel: #1d2026;
  --panel-2: #242830;
  --border: #333843;
  --text: #e8e6e0;
  --muted: #9aa0ab;
  --accent: #e2b34a;
  --accent-dark: #b8902f;
  --danger: #d16060;
  --ok: #6fbf82;
  --paper: #fdfcf7;
  --ink: #1a1a1a;
  --mono: 'Courier New', Courier, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------- nav */
nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1.2rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
nav .brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--accent);
  letter-spacing: 0.06em;
}
nav .brand:hover { text-decoration: none; }
nav .spacer { flex: 1; }
nav a.navlink { color: var(--text); font-size: 0.92rem; }
nav .user-badge { color: var(--muted); font-size: 0.88rem; }

/* ---------------------------------------------------------- layout */
main.page {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.2rem 3rem;
  flex: 1;
}
h1 { font-size: 1.5rem; margin: 0.4rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 0.6rem; color: var(--accent); }
p.lead { color: var(--muted); }

.flash {
  padding: 0.6rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}
.flash.error { background: #3a2226; border: 1px solid var(--danger); }
.flash.success { background: #223a2a; border: 1px solid var(--ok); }

/* ---------------------------------------------------------- buttons + forms */
.btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  font-family: var(--sans);
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1508; font-weight: 600; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 0.25rem 0.6rem; font-size: 0.8rem; }

form.auth {
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
form.auth label { font-size: 0.88rem; color: var(--muted); }
form.auth input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 1rem;
}
form.auth input:focus { outline: none; border-color: var(--accent); }

/* ---------------------------------------------------------- script cards */
ul.script-list { list-style: none; padding: 0; margin: 0; }
ul.script-list li {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}
ul.script-list .title { font-weight: 600; flex: 1; min-width: 10rem; }
ul.script-list .meta { color: var(--muted); font-size: 0.82rem; }
.badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge.public { border-color: var(--ok); color: var(--ok); }

/* ---------------------------------------------------------- editor */
.editor-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.editor-topbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.8rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
#script-title {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  min-width: 8rem;
  flex: 1;
}
#script-title:hover, #script-title:focus { border-color: var(--border); outline: none; }
.save-status { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.save-status.saved { color: var(--ok); }
.save-status.pending { color: var(--accent); }
.save-status.error { color: var(--danger); }

.toolbar {
  display: flex;
  gap: 0.35rem;
  padding: 0.4rem 0.8rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
}
.toolbar .group {
  display: flex;
  gap: 0.35rem;
  padding-right: 0.6rem;
  margin-right: 0.3rem;
  border-right: 1px solid var(--border);
  flex-wrap: wrap;
}
.toolbar .group:last-child { border-right: none; }
.toolbar button {
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.toolbar button:hover { border-color: var(--accent); color: var(--accent); }

.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
}
.sidebar {
  width: 220px;
  min-width: 160px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 0.6rem;
}
.sidebar h3 {
  margin: 0.2rem 0 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
#scene-list { list-style: none; margin: 0; padding: 0; }
#scene-list li {
  padding: 0.35rem 0.45rem;
  font-size: 0.78rem;
  font-family: var(--mono);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#scene-list li:hover { background: var(--panel-2); color: var(--accent); }
#scene-list li.scene-empty { color: var(--muted); cursor: default; }
#scene-list li.scene-empty:hover { background: none; color: var(--muted); }

.pane { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pane-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0.3rem 0.8rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
#editor {
  flex: 1;
  width: 100%;
  resize: none;
  border: none;
  outline: none;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.55;
  padding: 1rem 1.2rem;
}
.preview-wrap {
  flex: 1;
  overflow-y: auto;
  background: #2a2d33;
  border-left: 1px solid var(--border);
  padding: 1.2rem 0.8rem;
}

/* ---------------------------------------------------------- screenplay preview (paper) */
.script-paper {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.35;
  max-width: 620px;
  margin: 0 auto;
  padding: 3rem 3.2rem 3rem 4rem;
  box-shadow: 0 2px 14px rgba(0,0,0,0.45);
  border-radius: 2px;
  min-height: 400px;
}
.fp-titlepage { text-align: center; padding: 4rem 0 6rem; }
.fp-title { font-weight: 700; text-decoration: underline; margin-bottom: 2rem; }
.fp-byline { margin: 0.8rem 0; }
.fp-contact { text-align: left; font-size: 0.9em; margin-top: 3rem; }
.fp-scene { font-weight: 700; margin: 1.4em 0 0.7em; text-transform: uppercase; }
.fp-action { margin: 0.7em 0; white-space: pre-wrap; }
.fp-character { margin: 0.9em 0 0; padding-left: 38%; text-transform: uppercase; }
.fp-paren { margin: 0; padding-left: 28%; max-width: 60%; }
.fp-dialogue { margin: 0 0 0.15em; padding-left: 18%; max-width: 75%; }
.fp-transition { text-align: right; margin: 0.9em 0; text-transform: uppercase; }
.fp-centered { text-align: center; margin: 0.9em 0; }
.fp-lyrics { padding-left: 18%; font-style: italic; }
.fp-section { color: #7a6a3f; font-weight: 700; margin: 1.2em 0 0.3em; }
.fp-synopsis { color: #8a8a8a; font-style: italic; margin: 0.3em 0; }
.fp-pagebreak { border: none; border-top: 2px dashed #bbb; margin: 2em 0; }

/* Reader page uses the same paper full-page */
.reader-wrap { padding: 1.5rem 0.8rem 3rem; }

/* ---------------------------------------------------------- guide */
.guide-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.guide-table th, .guide-table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.7rem;
  text-align: left;
  vertical-align: top;
}
.guide-table th { background: var(--panel); color: var(--accent); }
.guide-table code, .example {
  font-family: var(--mono);
  background: var(--panel-2);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  white-space: pre-wrap;
  display: inline-block;
}
pre.example {
  display: block;
  padding: 0.8rem 1rem;
  overflow-x: auto;
}

/* ---------------------------------------------------------- mobile */
.mobile-tabs { display: none; }

@media (max-width: 820px) {
  .sidebar { display: none; }
  .mobile-tabs {
    display: flex;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
  }
  .mobile-tabs button {
    flex: 1;
    padding: 0.55rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-size: 0.9rem;
    cursor: pointer;
  }
  .mobile-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

  /* One pane at a time on phones */
  .workspace[data-mobile-pane="write"] .pane.preview-pane { display: none; }
  .workspace[data-mobile-pane="preview"] .pane.write-pane { display: none; }

  .script-paper { padding: 1.5rem 1rem 1.5rem 1.4rem; font-size: 12px; }
  .fp-character { padding-left: 25%; }
  .fp-dialogue { padding-left: 10%; max-width: 90%; }
  .fp-paren { padding-left: 18%; max-width: 75%; }

  .toolbar { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .toolbar .group { flex-wrap: nowrap; }
  #editor { font-size: 16px; /* prevents iOS zoom-on-focus */ }
  ul.script-list li { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
}
