/* "Hârtie caldă": the site's own pages. The editor brings its own styles. */
:root {
  --paper: #f7f0e4;
  --sheet: #fffaf1;
  --rule: #e3d6c3;
  --ink: #2b2420;
  --muted: #6b5d50;
  --accent: #9a4a1c;
  --accent-dark: #7a3912;
  --sage: #3f4d2d;
  --sage-tint: #e8ecdd;
  --tint: #f0e4d2;
  --danger: #8a2a1a;
  --serif: 'Literata Variable', 'Literata', Georgia, serif;
  --sans: 'Nunito Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
/* The editor's reading modes change the paper and the ink; the bar above it follows. */
:root[data-theme='sepia'] { --sheet: #f6ead2; --tint: #e6d3ae; }
/* A mode that changes an ink changes the tint it is written on as well, or the two end up the same shade. */
:root[data-theme='night'] { --sheet: #2a2420; --tint: #3d3530; --accent-dark: #f0b888; --sage: #b9c79a; --sage-tint: #333d28; --danger: #f0a090; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); font-family: var(--sans); }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
h1, h2 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; }
.wrap { max-width: 44rem; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; padding: 0.75rem 1.5rem; background: var(--sheet); border-bottom: 1px solid var(--rule); }
.brand { font-size: 1.0625rem; color: var(--ink); text-decoration: none; }
/* The name: "wri" heavy, "them" light, in small letters, so it is read as "write them". */
.wordmark { font-weight: 300; letter-spacing: 0.01em; white-space: nowrap; }
.wordmark b { font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.card { display: block; background: var(--sheet); border: 1px solid var(--rule); border-radius: 1rem; padding: 1rem 1.25rem; color: var(--ink); text-decoration: none; }
a.card:hover, a.card:focus-visible { border-color: var(--accent); color: var(--ink); }
.card h2 { font-size: 1.125rem; }
.card.current { border: 2px solid var(--accent); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.chip { display: inline-flex; align-items: center; min-height: 1.625rem; padding: 0 0.625rem; border-radius: 0.8125rem; border: 1px solid #c9b9a2; color: #5a4a3c; font-size: 0.75rem; font-weight: 700; }
.chip.good { border: 0; background: var(--sage-tint); color: var(--sage); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 3rem; padding: 0 1.5rem; border: 0; border-radius: 1.5rem; background: var(--accent); color: var(--sheet); font: 700 1rem var(--sans); text-decoration: none; cursor: pointer; }
.button:hover { background: var(--accent-dark); color: var(--sheet); }
.button.quiet { min-height: 2.75rem; padding: 0 1.25rem; background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.field { display: flex; flex-direction: column; gap: 0.375rem; }
.field label { font-size: 0.8125rem; font-weight: 700; color: var(--muted); }
.field input[type='email'], .field input[type='password'], .field input[type='text'], .field select { min-height: 3rem; padding: 0 1rem; border: 1.5px solid #b8a58a; border-radius: 0.75rem; background: #fffdf8; color: var(--ink); font: 1rem var(--sans); }
.error { color: var(--danger); font-size: 0.875rem; font-weight: 600; }
.login { max-width: 24rem; margin: 0 auto; padding: 5rem 1.5rem 3rem; }
.login h1 { font-size: 2rem; margin: 0.75rem 0 2rem; }
.providers { margin-top: 1.5rem; }
.providers .divider { margin: 0; text-align: center; }

/* The writing page */
.toolbar { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.toolbar button, .modes button { min-width: 2.75rem; min-height: 2.75rem; padding: 0 0.5rem; border: 0; border-radius: 0.625rem; background: transparent; color: var(--ink); font: 600 1rem var(--serif); cursor: pointer; }
.toolbar button:hover, .modes button:hover { background: var(--tint); }
.toolbar button[aria-pressed='true'], .modes button[aria-pressed='true'] { background: var(--tint); color: var(--accent-dark); }
.modes { display: flex; gap: 0.25rem; }
.modes button { font: 700 0.8125rem var(--sans); }
/* Wide enough for the longest everyday state, so the bar does not shift while typing. */
.status { display: inline-block; min-width: 8.5rem; font-size: 0.8125rem; font-weight: 700; color: var(--sage); }
.status[data-state='unsaved'], .status[data-state='saving'] { color: var(--muted); }
.status[data-state='error'], .status[data-state='conflict'] { color: var(--danger); }
/* Below the bar even when the page is scrolled, so a save problem is never out of sight. */
.banner { margin: 1rem auto 0; max-width: 42rem; padding: 0.875rem 1rem; border-radius: 0.75rem; background: #f6dcd3; color: #6e2012; font-size: 0.9375rem; }
.banner[hidden] { display: none; }
.notice-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }
.link-button { padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* A second row of the fixed bar: the writing tools, always in the same place. */
.subbar { flex-basis: 100%; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.subbar .toolbar { justify-content: center; }
.subbar .banner { margin: 0; width: 100%; }
.toolbar button:disabled { opacity: 0.5; cursor: progress; }
.head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.inline-form .field { flex: 1 1 14rem; }
fieldset { border: 1px solid var(--rule); border-radius: 1rem; padding: 1rem 1.25rem; margin: 0; }
legend { padding: 0 0.5rem; font-size: 0.8125rem; font-weight: 700; color: var(--muted); }

/* Managing a book */
.flash { max-width: 44rem; margin: 1rem auto 0; padding: 0.75rem 1rem; border-radius: 0.75rem; background: var(--sage-tint); color: var(--sage); font-size: 0.9375rem; font-weight: 600; }
.card .title-link { color: var(--ink); text-decoration: none; }
.card .title-link:hover, .card .title-link:focus-visible { color: var(--accent); }
details.options { margin-top: 0.75rem; }
details.options summary { cursor: pointer; font-size: 0.8125rem; font-weight: 700; color: var(--muted); }
details.options[open] summary { margin-bottom: 0.75rem; }
.button.danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); min-height: 2.75rem; padding: 0 1.25rem; }
.button.danger:hover { background: var(--danger); color: var(--sheet); }
/* Cutting a cover to the shape of the page: the picture behind a frame, moved and sized by the author. */
.cover-crop-frame { width: min(100%, 16rem); height: auto; border: 1px solid var(--rule); border-radius: 0.375rem; background: var(--tint); cursor: grab; touch-action: none; }
.cover-crop-frame:active { cursor: grabbing; }
.cover-crop input[type='range'] { flex: 1 1 8rem; min-width: 6rem; }
.cover-preview { max-width: 10rem; border-radius: 0.375rem; border: 1px solid var(--rule); }
.book-head { display: flex; align-items: center; gap: 1rem; }
.cover-thumb { width: 4.5rem; height: auto; flex: none; border-radius: 0.375rem; border: 1px solid var(--rule); }
.field input[type='file'] { font: 0.9375rem var(--sans); }

/* Chapter history */
.revision-text { font-family: var(--serif); font-size: 1rem; line-height: 1.6; }
.revision-text p { margin: 0 0 0.75rem; white-space: pre-line; }
.chip.warn { border: 0; background: #f6dcd3; color: #6e2012; }
.subbar #conflict-actions { background: transparent; padding: 0; text-align: center; font-weight: 700; }
.revision-text figure { margin: 0 0 0.75rem; }
.revision-text img { display: block; max-width: 12rem; max-height: 12rem; border-radius: 0.5rem; border: 1px solid var(--rule, #e3d6c3); }
.revision-text figcaption { font-family: inherit; font-size: 0.8125rem; color: var(--muted, #6b5d50); margin-top: 0.25rem; }

/* Error pages */
.error-page { padding-top: 4rem; text-align: center; align-items: center; }

/* The account page */
.account-links { display: flex; align-items: center; gap: 1rem; }
.account-links a { color: var(--ink); font-weight: 700; }
.account-links a[aria-current='page'] { color: var(--accent); }
/* A card is a block; one that stacks its parts needs saying so again. */
.card.stack { display: flex; }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.storage-bar { width: 100%; height: 0.75rem; accent-color: var(--accent); }

/* Beta readers: the author's page of notes, and the pages a reader sees */
.chapter-of-notes { font: 700 0.8125rem var(--sans); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: 0.5rem 0 0; }
.note-excerpt { margin: 0; padding-left: 0.75rem; border-left: 3px solid var(--rule); color: var(--muted); font-family: var(--serif); font-size: 0.9375rem; }
.note-body { margin: 0; white-space: pre-line; }
.card.resolved { opacity: 0.6; }
.field textarea { padding: 0.75rem 1rem; border: 1.5px solid #b8a58a; border-radius: 0.75rem; background: #fffdf8; color: var(--ink); font: 1rem var(--sans); resize: vertical; }
.reading-text { font-family: var(--serif); font-size: 1.125rem; line-height: 1.7; }
.reading-block { position: relative; padding-right: 2.75rem; border-radius: 0.5rem; }
.reading-block.noted { background: var(--tint); }
.reading-block > p, .reading-block > blockquote, .reading-block > figure { margin: 0 0 1rem; }
.reading-block h1, .reading-block h2, .reading-block h3 { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; }
.reading-block img { max-width: 100%; height: auto; }
.reading-block .underline { text-decoration: underline; }
.reading-block .verse { margin: 0 0 1rem 1.5rem; }
.reading-block .verse .line { display: block; padding-left: 1.5em; text-indent: -1.5em; }
.reading-block figure { text-align: center; }
.reading-block figcaption { font: 0.875rem var(--sans); color: var(--muted); }
.reading-block hr.scene-break { border: 0; text-align: center; margin: 1.5rem 0; }
.reading-block hr.scene-break::before { content: '* * *'; color: var(--muted); }
.note-mark { position: absolute; top: 0; right: 0; width: 2.5rem; height: 2.5rem; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1rem; cursor: pointer; }
.note-mark:hover, .note-mark:focus-visible { background: var(--tint); color: var(--accent); }
.own-note { margin: -0.25rem 0 1rem; padding: 0.5rem 0.75rem; border-radius: 0.5rem; background: var(--tint); font: 0.875rem var(--sans); white-space: pre-line; }

/* The notebook of a book */
.entry-name { font: 600 1.125rem var(--serif); margin: 0; }

/* The look of the page, in a book's settings */
.look-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }

/* The language of the site, at the foot of every page. */
.site-footer { max-width: 42rem; margin: 2.5rem auto 1.5rem; padding: 1rem 1.25rem 0; border-top: 1px solid var(--rule); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1.5rem; }
.language-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; font-size: 0.875rem; color: var(--muted); }
.language-form select { width: auto; min-width: 9rem; padding: 0.375rem 0.625rem; font-size: 0.875rem; }
.language-form.sends-itself button { display: none; }
.legal-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; font-size: 0.875rem; }
.agreement { margin: 0; }
.agree { align-items: flex-start; flex-wrap: nowrap; }
.agree input { margin-top: 0.2rem; }

/* The terms and the privacy policy: long texts, set to be read */
.legal { max-width: 42rem; margin: 0 auto; padding: 3rem 1.25rem 1rem; line-height: 1.6; }
.legal .brand { display: inline-block; margin-bottom: 1.5rem; text-decoration: none; }
.legal h1 { font-size: 2rem; margin: 0 0 0.25rem; }
.legal h2 { font-size: 1.25rem; margin: 2.25rem 0 0.5rem; }
.legal p, .legal ul, .legal dl { margin: 0 0 0.875rem; }
.legal ul { padding-left: 1.25rem; }
.legal li { margin-bottom: 0.375rem; }
.legal dt { font-weight: 700; margin-top: 0.875rem; }
.legal dd { margin: 0.125rem 0 0; }
.legal-summary { margin-top: 1.5rem; padding: 1rem 1.25rem; background: var(--sheet); border: 1px solid var(--rule); border-radius: 1rem; }
.legal-summary h2 { margin-top: 0; }
.legal-summary p:last-child, .legal-summary ul:last-child { margin-bottom: 0; }
.legal-table { overflow-x: auto; margin-bottom: 0.875rem; }
.legal-table table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.legal-table th, .legal-table td { text-align: left; vertical-align: top; padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 1px solid var(--rule); }
.legal-table code { font-size: 0.875rem; white-space: nowrap; }

/* Under a finger: what is pressed is about 44 points tall, as in the phone apps. The room is taken
   from the space around each one, so nothing on the page moves. */
body { overflow-wrap: break-word; }
a.small, .link-button, .legal-links a, .account-links a, .topbar .brand { display: inline-block; padding-block: 0.75rem; margin-block: -0.75rem; }
details > summary { padding-block: 0.75rem; margin-block: -0.5rem; }
.card .title-link { display: block; padding-block: 0.625rem; margin-block: -0.625rem; }
.field input[type='file'] { padding-block: 0.625rem; width: 100%; }
/* A group of fields is never wider than the page, whatever is in it. */
fieldset { min-width: 0; }
.cover-crop input[type='range'] { min-height: 2.75rem; }
/* Sixteen points: a phone enlarges the whole page when a smaller one is touched. */
.language-form select { min-height: 2.75rem; font-size: 1rem; }

/* On a phone */
@media (max-width: 40rem) {
  .wrap { padding: 1.5rem 1.25rem 3rem; }
  .topbar { padding: 0.5rem 1.25rem; }
  h1 { font-size: 1.75rem; }
  .login { padding-top: 3rem; }
  .login h1 { font-size: 1.75rem; }
  /* The main thing to do on a page spans it, as in the apps. */
  main .button:not(.quiet):not(.danger) { width: 100%; }

  /* The writing page keeps the text in sight: two thin rows instead of five. The tools are one
     row that scrolls sideways, as above the keyboard in the apps; the account is a page back. */
  .topbar:has(.subbar) { padding: 0.375rem 0.75rem; gap: 0.125rem 0.5rem; }
  .topbar:has(.subbar) > .brand, .topbar:has(.subbar) > .account-links { display: none; }
  .topbar:has(.subbar) > .row { order: 1; flex: 1 1 100%; justify-content: space-between; gap: 0.25rem 0.75rem; }
  .topbar:has(.subbar) .status { min-width: 0; }
  .topbar:has(.subbar) > .subbar { order: 2; flex: 1 1 0; min-width: 0; align-items: stretch; }
  .topbar:has(.subbar) > .modes { order: 3; flex: 0 0 auto; gap: 0; }
  /* A warning about the text takes the whole row, above the tools' share of it. */
  .topbar > .subbar:has(.banner:not([hidden])) { flex-basis: 100%; }
  .subbar .toolbar { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent); padding-right: 1.25rem; }
  .subbar .toolbar::-webkit-scrollbar { display: none; }
  .subbar .toolbar button { flex: 0 0 auto; white-space: nowrap; }
  .topbar:has(.subbar) > .modes button { min-width: 0; padding: 0 0.4375rem; font-size: 0.75rem; }
}
