/* Straight2Kindle: serial intertitle cards. Projection black, silver-screen lettering, one cinema red. */

@font-face {
  font-family: "Bodoni Moda";
  src: url("bodoni-moda.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Bodoni Moda";
  src: url("bodoni-moda-italic.woff2") format("woff2");
  font-weight: 400 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url("hanken-grotesk.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --black: #0D0C0A;     /* projection black: the ground */
  --raised: #17150F;    /* field stock */
  --white: #EDE8DC;     /* silver-screen lettering */
  --dim: #ABA497;       /* secondary lettering, 7.9:1 on black */
  --hair: #4A463D;      /* decorative hairlines only, never text */
  --red: #B3192B;       /* cinema red: primary action fill, 5.5:1 under white */
  --red-deep: #8E1221;
  --red-text: #FF5A4E;  /* cinema-red tint, only for errors and invalid fields, 6.3:1 on black */

  --display: "Bodoni Moda", "Didot", "Bodoni 72", serif;
  --text: "Hanken Grotesk", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --fs-sm: 0.875rem;
  --fs-body: 1.0625rem;
  --fs-lead: 1.1875rem;
  --fs-h2: clamp(1.75rem, 1.2rem + 2vw, 2.5rem);
  --fs-tbc: clamp(2.6rem, 1.4rem + 6.2vw, 6rem);

  --gutter: 16px;
  --frame-inset: 9px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--hair) var(--black); }

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  background: var(--black);
  color: var(--white);
  font: 400 var(--fs-body)/1.55 var(--text);
  overflow-wrap: anywhere;
  caret-color: var(--white);
}
/* film grain over the whole document, too faint to cost contrast */
body::after {
  content: ""; position: absolute; inset: 0; z-index: 50; pointer-events: none;
  background: url("grain.svg"); opacity: 0.1;
}

::selection { background: var(--white); color: var(--black); }
:focus-visible { outline: 2px solid var(--white); outline-offset: 3px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

h1, h2 { margin: 0; text-wrap: balance; }
h2 {
  font: italic 500 var(--fs-h2)/1.1 var(--display);
  letter-spacing: -0.01em;
}
p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; }

a { color: var(--white); text-decoration-color: var(--dim); text-decoration-thickness: 2px; text-underline-offset: 4px; }
a:hover { text-decoration-color: var(--white); }

/* states are classes on <main>: setup/ready and has-items/empty */
.ready .setup-only,
.setup .ready-only,
.has-items .empty-only,
.empty .has-only { display: none !important; }

/* ---------- top bar ---------- */
.bar {
  display: flex; align-items: baseline; justify-content: space-between; gap: 4px 16px; flex-wrap: wrap;
  max-width: 1120px; margin: 0 auto; padding: 14px var(--gutter);
}
.wordmark {
  font: italic 600 1.375rem/1 var(--display); letter-spacing: 0.005em;
  color: var(--white); text-decoration: none;
}
.bar-note { font-size: var(--fs-sm); color: var(--dim); }

/* ---------- the intertitle card ---------- */
.card {
  position: relative;
  margin: 0 var(--gutter);
  padding: 44px 26px 48px;
  border: 1.5px solid var(--white);
  outline: 1px solid var(--white);
  outline-offset: calc(var(--frame-inset) * -1);
  background:
    url("corner-tl.svg") left 14px top 14px / 26px no-repeat,
    url("corner-tr.svg") right 14px top 14px / 26px no-repeat,
    url("corner-bl.svg") left 14px bottom 14px / 26px no-repeat,
    url("corner-br.svg") right 14px bottom 14px / 26px no-repeat,
    var(--black);
}
/* the studio mark sits on the frame, the way intertitles carried their maker's monogram */
.monogram {
  position: absolute; left: 50%; bottom: 0; transform: translate(-50%, 50%);
  padding: 0 12px; background: var(--black);
  font: italic 600 0.9375rem/1 var(--display); letter-spacing: 0.06em; color: var(--white);
}

.title-card { text-align: center; }
.title-card h1 { font-family: var(--display); font-style: italic; font-weight: 500; letter-spacing: -0.02em; }
.tbc { display: block; font-size: var(--fs-tbc); line-height: 0.95; }
.tbc-on { display: block; margin-top: 0.35em; font-size: max(1.625rem, calc(var(--fs-tbc) * 0.42)); line-height: 1.1; font-weight: 400; color: var(--white); }
.lede { max-width: 44ch; margin: 18px auto 0; font-size: var(--fs-lead); line-height: 1.5; }

/* ---------- forms ---------- */
.signup { max-width: 560px; margin: 28px auto 0; text-align: left; }
.fields { display: grid; gap: 14px; }
label { display: block; font-weight: 600; line-height: 1.5rem; }
input {
  display: block; width: 100%; min-height: 50px; margin-top: 6px; padding: 12px 14px;
  border: 1.5px solid var(--white); border-radius: 0;
  background: transparent; color: var(--white);
  font: 400 var(--fs-body)/1.3 var(--text);
}
input::placeholder { color: var(--dim); opacity: 1; }
input:hover { background: var(--raised); }
input:focus-visible { border-color: var(--white); outline-offset: 2px; }
input[aria-invalid="true"] { border: 2px solid var(--red-text); }
.hint { margin-top: 6px; font-size: var(--fs-sm); color: var(--dim); }

.field-error:empty, .form-error:empty, .notice:empty, .flash:empty, .recover-result:empty { display: none; }
.field-error:not(:empty) { margin-top: 6px; color: var(--red-text); font-weight: 600; }
.form-error:not(:empty) { margin-top: 14px; padding: 10px 14px; border: 1px solid var(--red-text); color: var(--red-text); font-weight: 600; }
.notice:not(:empty), .flash:not(:empty), .recover-result:not(:empty) {
  margin: 0 0 18px; padding: 12px 16px; border: 1px solid var(--white); font-weight: 600; text-align: left;
}
.recover-result:empty + .recover-note { display: none; }

/* in the title card the fields are drawn in the card's own line, and the red outweighs them */
.title-card input { min-height: 56px; }

/* controls sit above the grain layer so their fills stay clean */
input, .primary, .secondary { position: relative; z-index: 60; }

/* ---------- buttons ---------- */
.primary, .secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 12px 26px; border-radius: 0; cursor: pointer;
  font: 700 var(--fs-body)/1.2 var(--text); letter-spacing: 0.01em; text-decoration: none; text-align: center;
}
.primary { border: 0; background: var(--red); color: var(--white); }
.primary:hover, .primary:active { background: var(--red-deep); }
.secondary { border: 1px solid var(--white); background: transparent; color: var(--white); }
.secondary:hover, .secondary:active { background: var(--raised); }
a.primary { color: var(--white); }
.signup .primary { width: 100%; margin-top: 4px; min-height: 56px; padding-inline: 34px; font-size: var(--fs-lead); }
.text-button {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px;
  border: 0; background: none; cursor: pointer; color: var(--white);
  font: 600 var(--fs-sm)/1.2 var(--text);
  text-decoration: underline; text-decoration-color: var(--dim); text-decoration-thickness: 2px; text-underline-offset: 4px;
}
.text-button:hover { text-decoration-color: var(--white); }
@media (prefers-reduced-motion: no-preference) {
  .primary, .secondary { transition: background-color 160ms cubic-bezier(.16, 1, .3, 1); }
  input { transition: border-color 160ms cubic-bezier(.16, 1, .3, 1); }
}

/* ---------- disclosures ---------- */
details summary {
  display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; list-style: none;
  font-weight: 600;
}
details summary::-webkit-details-marker { display: none; }
details summary::after {
  content: ""; flex: none; width: 8px; height: 8px; margin-left: auto;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}
details[open] summary::after { transform: translateY(2px) rotate(225deg); }
@media (prefers-reduced-motion: no-preference) {
  details summary::after { transition: transform 200ms cubic-bezier(.16, 1, .3, 1); }
}
.where { max-width: 560px; margin: 14px auto 0; text-align: left; color: var(--white); }
.where summary { font-size: var(--fs-sm); text-decoration: underline; text-decoration-color: var(--dim); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.where summary:hover { text-decoration-color: var(--white); }
.where ul { padding: 0 0 6px 18px; font-size: var(--fs-sm); color: var(--dim); }
.where li + li { margin-top: 4px; }
.fine { max-width: 560px; margin: 10px auto 0; font-size: var(--fs-sm); color: var(--dim); text-align: left; }
@media (min-width: 960px) { .fine { max-width: 64ch; text-align: center; } }

/* ---------- scenes between cards ---------- */
.scene { max-width: 680px; margin: 0 auto; padding: 0 var(--gutter); }
.scene, .small-card { margin-top: 96px; }
/* the cut between scenes: a short ornamented rule */
.scene::before {
  content: ""; display: block; width: 160px; height: 16px; margin: 0 auto 40px;
  background: url("cut.svg") center / contain no-repeat;
}
.scene h2 { text-align: center; margin-bottom: 28px; }

.steps { list-style: none; counter-reset: step; }
.steps li {
  counter-increment: step;
  display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); column-gap: 14px; align-items: baseline;
  padding: 14px 0; border-top: 1px solid var(--hair);
}
.steps li:last-child { border-bottom: 1px solid var(--hair); }
.steps li::before {
  content: counter(step);
  font: italic 500 2rem/1 var(--display); color: var(--white); text-align: center;
}
.steps li > * { grid-column: 2; }

.example-note { text-align: center; font-size: var(--fs-sm); color: var(--dim); }
/* the time-skip intertitle: "A week later…" is its own card before the scene it introduces */
.timeskip { margin: 0 0 28px; padding: 40px 24px 46px; text-align: center; }
.scene .timeskip h2 { margin: 0 0 10px; font: italic 400 max(1.625rem, calc(var(--fs-tbc) * 0.42))/1.15 var(--display); }
.library { list-style: none; border-top: 1px solid var(--hair); }
.library li {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 16px;
  padding: 14px 0; border-bottom: 1px solid var(--hair);
}
.library .file { font-weight: 600; }
.library li:first-child .file { color: var(--white); }
.library li:first-child .when { color: var(--white); }
.library .when { font-size: var(--fs-sm); color: var(--dim); white-space: nowrap; font-variant-numeric: tabular-nums; }

.faq details { border-top: 1px solid var(--hair); padding: 6px 0; }
.faq details:last-child { border-bottom: 1px solid var(--hair); }
.faq details p { padding: 2px 0 12px; color: var(--dim); max-width: 60ch; }

/* ---------- lost-link card ---------- */
.small-card { max-width: 680px; padding: 44px 26px 52px; text-align: center; }
@media (min-width: 712px) { .small-card { margin-left: auto; margin-right: auto; } }
.small-card h2 { margin-bottom: 12px; }
.small-card > p { max-width: 46ch; margin-left: auto; margin-right: auto; color: var(--white); }
.recover-form { max-width: 520px; margin: 22px auto 0; text-align: left; }
.inline { display: grid; gap: 10px; margin-top: 6px; }
.inline input { margin-top: 0; }
.recover-result:not(:empty) { max-width: 520px; margin: 18px auto 0; }
.recover-note { max-width: 520px; margin: 10px auto 0; font-size: var(--fs-sm); color: var(--dim); text-align: left; }

/* ---------- colophon ---------- */
.colophon {
  max-width: 1120px; margin: 96px auto 0; padding: 28px var(--gutter) 40px;
  border-top: 1px solid var(--hair); font-size: var(--fs-sm); color: var(--dim); text-align: center;
}
.colophon p + p { margin-top: 4px; }
.colophon a { display: inline-block; min-height: 44px; line-height: 44px; color: var(--white); }

/* ---------- manage ---------- */
.manage { max-width: 720px; margin: 0 auto; padding: 8px 0 0; }
.manage > :not(.card) { margin-left: var(--gutter); margin-right: var(--gutter); }
.manage > * + * { margin-top: 40px; }
.manage > .flash { margin-top: 8px; }
.manage .card h1, .page-head h1, .notfound h1 {
  font: italic 500 clamp(2.1rem, 1.5rem + 3vw, 3.25rem)/1.05 var(--display); letter-spacing: -0.015em;
}
.manage .card { text-align: left; }
.manage .card h1 { text-align: center; }
.manage .card .chapters-to { text-align: center; }
.chapters-to { margin-top: 12px; color: var(--dim); }
.kindle { color: var(--white); font-weight: 600; }
.manage .card h2 { margin-top: 36px; font-size: 1.625rem; }
.intro { margin-top: 8px; color: var(--white); }
.manage .steps { margin-top: 18px; }
.manage .steps li::before { font-size: 1.625rem; }
.manage .steps li p { margin: 0; }
.copy-row { display: grid; gap: 10px; margin-top: 10px; }
.sender, .link {
  display: block; padding: 12px 14px; border: 1px solid var(--dim); background: var(--raised);
  font: 500 var(--fs-body)/1.4 var(--mono); color: var(--white); overflow-wrap: anywhere;
  user-select: all; -webkit-user-select: all;
}
.link { font-size: var(--fs-sm); }
.copy { display: none; }
.js .copy { display: inline-flex; }
.copy-status { display: block; min-height: 1.4em; margin-top: 4px; font-size: var(--fs-sm); font-weight: 600; color: var(--white); }
.steps li > .copy-status, .steps li > .copy-row { grid-column: 2; }
.ready-form { margin-top: 28px; }
.ready-form .primary { width: 100%; }

.page-head { text-align: center; }
.page-head + .bookmark { margin-top: 28px; }
.bookmark { padding: 18px 20px; border: 1px solid var(--white); }
.bookmark h2 { font-size: 1.375rem; margin-bottom: 6px; }
.bookmark p { color: var(--white); }

.stories-block h2 { margin-bottom: 14px; font-size: 1.625rem; }
.stories { list-style: none; border-top: 1px solid var(--hair); }
.story {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; align-items: start;
  padding: 18px 0; border-bottom: 1px solid var(--hair);
}
.story-title { font-weight: 700; font-size: var(--fs-lead); line-height: 1.3; }
.story-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 2px; font-size: var(--fs-sm); color: var(--dim); }
.story-meta .site { color: var(--white); font-weight: 600; }
.status { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: var(--fs-sm); font-weight: 600; }
/* shape and words both carry the state: ok = filled dot, pending = ring, error = red diamond */
.status::before { content: ""; flex: none; width: 10px; height: 10px; border: 1.5px solid var(--white); border-radius: 50%; }
.status.ok::before { background: var(--white); }
.status.error { color: var(--red-text); }
.status.error::before { border-color: var(--red-text); background: var(--red-text); border-radius: 0; transform: rotate(45deg); }
.empty-note { color: var(--dim); }

.add h2, .manage-link h2 { font-size: 1.625rem; margin-bottom: 6px; }
.count { color: var(--dim); font-size: var(--fs-sm); margin-bottom: 16px; }
.manage-link .hint { margin-top: 8px; }

/* ---------- 404 ---------- */
.notfound { max-width: 640px; margin: 32px auto 0; }
.notfound .card { text-align: center; padding-top: 56px; padding-bottom: 60px; }
.notfound .card > p { margin-top: 14px; color: var(--white); }
.notfound .actions { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 28px; }
.notfound .actions a:not(.primary) { display: inline-block; min-height: 44px; line-height: 44px; }

/* ---------- the iris: a card closes like a film transition before the next scene ---------- */
@media (prefers-reduced-motion: no-preference) {
  .card.is-irising { animation: iris-out 420ms cubic-bezier(.7, 0, .84, 0) forwards; }
}
@keyframes iris-out {
  from { clip-path: circle(110% at 50% 46%); }
  to { clip-path: circle(0% at 50% 46%); }
}

/* ---------- phones: whole card, button included, clears the fold ---------- */
@media (max-width: 599px) {
  .title-card { padding-top: 36px; padding-bottom: 40px; }
  .lede { margin-top: 14px; font-size: var(--fs-body); }
  .signup { margin-top: 22px; }
  .fields { gap: 10px; }
  .scene, .small-card { margin-top: 72px; }
  .sender { font-size: var(--fs-sm); }
  .steps li > .copy-row, .steps li > .copy-status { grid-column: 1 / -1; }
  .library li { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 599px) and (max-height: 700px) {
  :root { --fs-tbc: 2.35rem; }
  .title-card { padding-top: 44px; }
  .hint { margin-top: 4px; }
}

/* ---------- wider screens ---------- */
@media (min-width: 600px) {
  :root { --gutter: 32px; }
  .card { padding: 56px 48px 60px; }
  .inline { grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; }
  .copy-row { grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; }
}
@media (min-width: 960px) {
  /* bar text and the card frame share one edge: 1120px max, gutter on narrower screens */
  .bar { max-width: none; padding-inline: max(var(--gutter), calc((100% - 1120px) / 2)); }
  .title-card {
    margin: 8px max(var(--gutter), calc((100% - 1120px) / 2)) 0;
    min-height: min(calc(100svh - 96px), 860px); display: flex; flex-direction: column; justify-content: center;
    padding: 64px 72px 72px;
  }
  .signup { max-width: 860px; }
  .fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; column-gap: 12px; align-items: start; }
  /* the button lines up with the inputs: one label line plus the input's top margin above it */
  .signup .primary { width: auto; margin-top: calc(1.5rem + 6px); }
  .where { max-width: 860px; margin-left: auto; margin-right: auto; }
  .manage { padding-top: 16px; }
}
