/* Old paper theme. */

:root {
  --paper: #f1e7cd;
  --ink: #3a2c1e;
  --ink-soft: #6b5640;
  --ink-faint: #9a8468;
  --accent: #7a2e1d; /* faded red ink */
  --rule: rgba(90, 64, 38, 0.25);

  --font-body: 'Noto Serif Devanagari', 'Kohinoor Devanagari', 'Mangal', serif;
  --font-hand: 'Kalam', 'Noto Serif Devanagari', cursive;

  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* Devanagari needs a bit more size and line height than Latin to stay readable. */
  font-size: 112.5%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 0 16px;
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.9;
  text-rendering: optimizeLegibility;
}

/* Generated paper, no photo: soft blotches, fibres and a lit grain, each tiling seamlessly
   (public/paper/*.svg). Multiply makes them darken the paper colour like real stains would.
   The texture scrolls with the text, so the words sit on the paper rather than above it. */
html {
  background-color: var(--paper);
  background-image: url('/paper/mottle.svg'), url('/paper/fibers.svg'), url('/paper/grain.svg');
  background-blend-mode: multiply;
}

/* Edges darken like aged paper; this one stays with the window. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(120, 85, 45, 0.18) 100%);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
}

::selection {
  background: rgba(122, 46, 29, 0.2);
}

/* Header and footer */

.masthead {
  max-width: 40rem;
  margin: 0 auto;
  padding: 3rem 0 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--rule);
}

.site-title {
  font-family: var(--font-hand);
  font-size: 3.2rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  text-decoration: none;
}

.site-tagline {
  margin: 0.25rem 0 0;
  font-family: var(--font-hand);
  color: var(--ink-soft);
}

.colophon {
  max-width: 40rem;
  margin: 3rem auto 0;
  padding: 1.5rem 0 3rem;
  border-top: 1px solid var(--rule);
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.85rem;
}

.flourish {
  display: block;
  font-size: 1.4rem;
  color: var(--ink-faint);
}

/* Content column */

.sheet {
  max-width: 40rem;
  margin: 0 auto;
  padding-top: 2rem;
}

.empty {
  text-align: center;
  color: var(--ink-soft);
}

/* Post list */

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-list li + li {
  border-top: 1px dashed var(--rule);
}

.post-list a {
  display: block;
  padding: 1.25rem 0;
  color: inherit;
  text-decoration: none;
}

.post-list h2 {
  margin: 0;
  font-family: var(--font-hand);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.5;
}

.post-list a:hover h2 {
  color: var(--accent);
}

.post-list p {
  margin: 0.25rem 0 0;
  color: var(--ink-soft);
}

time {
  font-size: 0.85rem;
  color: var(--ink-faint);
}

/* Single post */

.post-header {
  text-align: center;
  margin-bottom: 2rem;
}

.post-header h1 {
  margin: 0.25rem 0 0.5rem;
  font-family: var(--font-hand);
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1.4;
}

.tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}

.tags li {
  padding: 0 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.back {
  display: inline-block;
  margin-top: 2.5rem;
  font-family: var(--font-hand);
}

/* Post body. Also used by the CMS preview pane. */

.prose {
  font-size: 1.05rem;
  overflow-wrap: break-word;
}

.prose > :first-child {
  margin-top: 0;
}

.prose h2,
.prose h3 {
  font-family: var(--font-hand);
  font-weight: 700;
  line-height: 1.5;
  margin: 2.2rem 0 0.5rem;
}

.prose h2 {
  font-size: 1.6rem;
}

.prose h3 {
  font-size: 1.3rem;
}

.prose p {
  margin: 0 0 1.2rem;
}

.prose blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 3px solid var(--accent);
  color: var(--ink-soft);
  font-style: normal; /* italics look wrong in Devanagari */
}

.prose em {
  font-style: normal;
  color: var(--accent);
}

.prose img {
  max-width: 100%;
  height: auto;
  border: 6px solid #f7f1e1;
  box-shadow: 0 2px 8px rgba(60, 40, 20, 0.25);
  filter: sepia(0.25);
}

.prose hr {
  border: 0;
  margin: 2rem 0;
  text-align: center;
}

.prose hr::after {
  content: '❦';
  color: var(--ink-faint);
}

.prose code {
  font-size: 0.9em;
  background: rgba(90, 64, 38, 0.08);
  padding: 0.1em 0.3em;
  border-radius: 2px;
}

.prose pre {
  overflow-x: auto;
  padding: 1rem;
  background: rgba(90, 64, 38, 0.08) !important;
  line-height: 1.5;
}

@media (max-width: 480px) {
  .site-title {
    font-size: 2.6rem;
  }

  .post-header h1 {
    font-size: 1.9rem;
  }
}

/* Writing on the page. Write controls exist only for you, after unlocking with your key. */

.write-only {
  display: none;
}

.can-write .write-only {
  display: inline-block;
}

.masthead {
  position: relative;
}

.unlock-button {
  position: absolute;
  top: 1rem;
  right: 0;
  font-size: 0.95rem;
}

.ink-button,
.link-button {
  font: inherit;
  font-family: var(--font-hand);
  cursor: pointer;
}

.ink-button {
  padding: 0.3rem 1.1rem;
  border: 1.5px solid var(--ink);
  border-radius: 3px 6px 4px 7px; /* a little uneven, like a hand-drawn box */
  background: transparent;
  color: var(--ink);
  font-size: 1.05rem;
}

.ink-button:hover {
  background: rgba(58, 44, 30, 0.07);
}

.ink-button:disabled {
  opacity: 0.5;
  cursor: wait;
}

.link-button {
  padding: 0.3rem 0.5rem;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 1rem;
}

.link-button.danger {
  margin-left: auto;
  color: var(--ink-faint);
}

.new-post {
  margin-bottom: 1rem;
}

.post-footer {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 2.5rem;
}

.post-footer .back {
  margin-top: 0;
}

/* The editor is the page itself: no boxes, just ink on the paper. */

.writer input,
.writer textarea {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  outline: none;
}

.w-title {
  font-family: var(--font-hand);
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

.w-meta {
  font-family: var(--font-body);
  font-size: 0.9rem;
  text-align: center;
  color: var(--ink-soft) !important;
}

.writer ::placeholder {
  color: var(--ink-faint);
  opacity: 0.7;
}

.w-toolbar {
  display: flex;
  gap: 0.25rem;
  justify-content: center;
  margin: 1.25rem 0 1rem;
  padding: 0.4rem 0;
  border-top: 1px dashed var(--rule);
  border-bottom: 1px dashed var(--rule);
}

.w-toolbar button {
  min-width: 2.2rem;
  padding: 0 0.5rem;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

.w-toolbar button:hover {
  background: rgba(58, 44, 30, 0.07);
  color: var(--ink);
}

.w-body {
  min-height: 50vh;
  resize: none;
  overflow: hidden;
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.9;
  field-sizing: content;
}

.writer-status {
  min-height: 1.5em;
  margin: 1rem 0 0.5rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.writer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.writer-error {
  color: var(--accent);
  font-size: 0.85rem;
}

.paper-dialog {
  width: min(22rem, calc(100vw - 32px));
  padding: 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper) url('/paper/grain.svg');
  background-blend-mode: multiply;
  color: var(--ink);
  box-shadow: 0 10px 40px rgba(40, 28, 15, 0.35);
}

.paper-dialog::backdrop {
  background: rgba(40, 28, 15, 0.35);
}

.dialog-title {
  margin: 0 0 0.75rem;
  font-family: var(--font-hand);
  font-size: 1.4rem;
}

.paper-dialog input {
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.4rem 0;
  border: 0;
  border-bottom: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font: inherit;
  outline: none;
}

/* Nepali typing: the अ/A toggle and the bar of other spellings. */

.w-toolbar .translit-toggle {
  margin-left: 0.75rem;
  border: 1px solid var(--rule);
  font-weight: 600;
}

.w-toolbar .translit-toggle[aria-pressed='true'] {
  border-color: var(--ink-soft);
  color: var(--ink);
  background: rgba(58, 44, 30, 0.07);
}

.suggest-bar {
  position: sticky;
  bottom: 12px;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  margin: 1rem auto 0;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper) url('/paper/grain.svg');
  background-blend-mode: multiply;
  box-shadow: 0 4px 14px rgba(40, 28, 15, 0.18);
}

.suggest-bar[hidden] {
  display: none;
}

.suggest-bar button {
  padding: 0.1rem 0.6rem;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  cursor: pointer;
}

.suggest-bar button:hover {
  background: rgba(58, 44, 30, 0.07);
}

.suggest-bar button.current {
  color: var(--ink);
  background: rgba(58, 44, 30, 0.1);
}

.suggest-bar button.roman {
  font-family: Georgia, serif;
  font-style: italic;
}
