/* Scriptorium — the writing room. A sheet of paper floating on linen,
   set entirely in one book face, one subdued accent. Layered over the
   quiet base, same bones as Cloisonne, none of the jewels. */

@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=Courier+Prime:ital,wght@0,400;0,700;1,400&display=swap');

:root {
  /* --bg is the SHEET (the page and every surface); the linen field
     behind it is painted on body separately, below */
  --bg: #faf7ef;        /* laid paper */
  --ink: #2a2620;       /* warm near-black, never pure */
  --quiet: #8b8375;
  --link: #7d3b34;      /* oxblood, like the binding */
  --missing: #9c5b45;
  --hair: #e0d9c8;
  --accent: #5c6650;    /* moss, for the smallest things */

  --field: #e6e1d3;     /* the linen desk the page rests on */
  --fieldglow: radial-gradient(110% 70% at 50% 0%,
      rgba(255, 253, 246, .55) 0%, transparent 60%);
  --serif: 'EB Garamond', Georgia, serif;
  --mono: 'Courier Prime', 'Courier New', monospace;   /* the typewriter */
}
/* the lamplight palette. Same two-selector rule as the base skin: system
   preference (unless a light choice was made), and an explicit dark
   choice, must carry the same values — keep them in step. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #241e16;      /* the page by lamplight */
    --ink: #e6ddcb;
    --quiet: #968b78;
    --link: #c69162;    /* amber-leather */
    --missing: #b0705c;
    --hair: #3a332a;
    --accent: #8a9478;

    --field: #141110;
    --fieldglow: radial-gradient(110% 70% at 50% 0%,
        rgba(90, 70, 40, .28) 0%, transparent 60%);
  }
}
:root[data-theme="dark"] {
  --bg: #241e16;
  --ink: #e6ddcb;
  --quiet: #968b78;
  --link: #c69162;
  --missing: #b0705c;
  --hair: #3a332a;
  --accent: #8a9478;

  --field: #141110;
  --fieldglow: radial-gradient(110% 70% at 50% 0%,
      rgba(90, 70, 40, .28) 0%, transparent 60%);
}

::selection { background: color-mix(in srgb, var(--link) 22%, transparent); }

/* ------------------------------------------------------ the linen desk -- */
body {
  font: 19px/1.7 var(--serif);
  font-feature-settings: "onum" 1;   /* oldstyle figures, like a set book */
  background: var(--fieldglow) no-repeat, var(--field);
  background-attachment: fixed;
  min-height: 100vh;
}

/* -------------------------------------------------- the floating page -- */
main {
  /* a book's measure, about seventy characters, with 200px of slack for
     wide screens — the cap still yields to a narrower viewport as always */
  max-width: calc(41rem + 200px);
  margin: 6.2rem auto 7rem;
  padding: clamp(1.6rem, 5vw, 3.6rem);
  background: var(--bg);
  border-radius: 6px;
  box-shadow:
    0 0 0 1px var(--hair),
    0 24px 50px -22px rgba(30, 24, 12, .4);
}
@media (prefers-reduced-motion: no-preference) {
  main { animation: settle .45s ease-out; }
  @keyframes settle {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
  }
}

/* -------------- the chrome: running head above, colophon line below, --
   both faded to a whisper until you reach for them                      */
nav {
  position: fixed;
  top: .9rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  width: max-content;
  max-width: min(94vw, 60rem);
  flex-wrap: wrap;
  justify-content: center;
  row-gap: .15rem;
  padding: .45rem 1.2rem;
  border: none;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 0 0 1px var(--hair), 0 8px 24px -10px rgba(30, 24, 12, .35);
  font-family: var(--serif);
  font-variant: small-caps;
  text-transform: lowercase;
  font-size: .92rem;
  letter-spacing: .1em;
  opacity: .55;
  transition: opacity .25s ease;
}
nav:hover, nav:focus-within { opacity: 1; }
nav .site { color: var(--ink); font-weight: 600; letter-spacing: .14em; }
nav a:hover, nav .search-toggle:hover { color: var(--link); }
nav form.searchform input { font-variant: normal; }
nav form.searchform.open input { border-bottom-color: var(--hair); }
nav form.searchform input:focus { border-color: var(--link); }
nav details.navdrop summary:hover,
nav details.navdrop[open] summary { color: var(--link); }
nav details.navdrop .navdrop-menu { border-radius: 6px; }

footer {
  position: fixed;
  bottom: .9rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  width: max-content;
  max-width: 94vw;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: .15rem 1.2rem;
  margin: 0;
  padding: .4rem 1.2rem;
  border: none;
  border-radius: 999px;
  font-family: var(--serif);
  font-size: .8rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 0 0 1px var(--hair), 0 8px 24px -10px rgba(30, 24, 12, .35);
  opacity: .55;
  transition: opacity .25s ease;
}
footer:hover, footer:focus-within { opacity: 1; }
footer a:hover, .theme-toggle:hover { color: var(--link); }
/* while editing, the editbar owns the bottom of the screen */
body.editing footer { display: none; }

/* ------------------------------------- the chapter opening, centered -- */
p.category {
  margin: 0;
  text-align: center;
  font-family: var(--serif);
  font-variant: small-caps;
  text-transform: lowercase;
  letter-spacing: .22em;
  font-size: .85rem;
}
p.category a.wikilink { color: var(--quiet); border-bottom: none; }
p.category a.wikilink:hover { color: var(--link); }
p.category + h1.pagetitle { margin-top: .5rem; }
h1.pagetitle {
  text-align: center;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 2.1rem;
  line-height: 1.2;
  letter-spacing: .01em;
  margin: 0 0 1.6rem;
  color: var(--ink);
}
/* a short rule under the title, like a chapter head */
h1.pagetitle::after {
  content: "";
  display: block;
  width: 4.5rem;
  margin: .9rem auto 0;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 35%, transparent);
}
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 500; }
h2 { font-style: italic; font-size: 1.35rem; }
h3 { font-variant: small-caps; text-transform: lowercase; letter-spacing: .12em; font-size: 1.1rem; }
h4 { font-size: 1rem; color: var(--quiet); }

a { text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent); }
a.wikilink { border-bottom-color: color-mix(in srgb, var(--link) 30%, transparent); }
a.wikilink:hover { border-bottom-color: var(--link); }

/* a rule is a fleuron */
hr { border: none; margin: 2.6rem auto; text-align: center; }
hr::after {
  content: "\2766";   /* ❦ */
  font-size: 1.05rem;
  color: var(--quiet);
}

/* quotations as a book sets them: indented, italic, unpainted */
blockquote {
  margin: 1.4rem 2rem;
  padding: 0;
  border-left: none;
  font-style: italic;
  color: color-mix(in srgb, var(--ink) 80%, var(--quiet));
}
blockquote em, blockquote i { font-style: normal; }

img { border-radius: 3px; }
/* monospace speaks typewriter — Courier's low x-height sits in proportion
   with the Garamond around it, where Menlo shouted. tt is the old wiki's
   monospace and joins in; as a standalone quoted passage (never
   mid-sentence) it reads a point smaller than the inline code chip,
   held in 50px from the margins on both sides (base skin makes it a
   block — this just carries the typewriter face and size into it) */
pre, code, tt { font-family: var(--mono); }
code { font-size: .92em; }
pre, tt { font-size: .85em; }
tt { line-height: 1.55; }
pre {
  border: 1px solid var(--hair);
  border-radius: 4px;
  background: color-mix(in srgb, var(--ink) 3%, transparent);
  padding: .8rem 50px;
  line-height: 1.55;
}
.editform textarea { font-family: var(--mono); }

/* buttons in ink, quietly */
.editform button, .editbar button, .loginform button, .uploadform button {
  background: var(--ink);
  color: var(--bg);
  border-radius: 4px;
  padding: .3rem 1.1rem;
  font-family: var(--serif);
}
.editbar { font-family: var(--serif); }
.editbar input:focus { border-color: var(--link); }
.editform textarea { border-radius: 4px; }
.editform textarea:focus { outline: none; border-color: var(--quiet); }
h1.pagetitle.editing { text-align: left; }
h1.pagetitle.editing::after { display: none; }
.deleteform button.danger { border-radius: 4px; }

.pastbanner { border-radius: 4px; font-family: var(--serif); }

ul.hits li.createhit { border-radius: 4px; }

/* the wall, the index, the listings — all in the same quiet hand */
.wall img { border-radius: 3px; transition: box-shadow .18s ease; }
.wall a:hover img { box-shadow: 0 6px 20px rgba(30, 24, 12, .35); }
.abc, .index h2.index-letter, .calendar .month,
table.listing, ul.hits .quiet { font-family: var(--serif); }
/* listings are ledgers, not prose — set tighter than the 1.7 measure */
table.listing { line-height: 1.45; }
table.listing td { padding-right: .9rem; }
.index h2.index-letter { font-variant: small-caps; text-transform: lowercase; letter-spacing: .12em; }

/* calendar — a ledger, not a jewel case */
.calendar .month caption { font-style: italic; color: var(--ink); }
.calendar .month td.today { outline: 1px solid var(--link); border-radius: 50%; }
.calendar .month td.empty a:hover { color: var(--link); }

/* tags — set like catalogue marks, not gems */
.tag {
  text-decoration: none;
  font-family: var(--serif);
  font-variant: small-caps;
  text-transform: lowercase;
  letter-spacing: .08em;
  font-size: .9em;
  color: var(--quiet);
}
.tag:hover { color: var(--link); }
.cloud { line-height: 2; }

table.user td { border-color: var(--hair); }

/* lightbox — the room dims, the page waits */
#lightbox {
  background: color-mix(in srgb, var(--field) 92%, transparent);
  z-index: 30;
}
#lightbox figure img { box-shadow: 0 8px 40px rgba(20, 15, 8, .5); }
#lightbox figcaption { font-family: var(--serif); }

.loginform input[type=password]:focus { outline: none; border-bottom-color: var(--link); }
.uploadform textarea[name=alt] { border-radius: 4px; }

/* the editor, dressed the same — typing should look like the set page.
   (the editor reads --serif for its face; these carry the measure) */
.editor-host .cm-editor { font-size: 19px; }
.editor-host .cm-editor .cm-content {
  font-family: var(--serif);
  line-height: 1.7;
  font-feature-settings: "onum" 1;
}
.editor-host .cm-editor .cm-activeLine {
  background: color-mix(in srgb, var(--hair) 22%, transparent);
}
.editor-host .cm-editor .cm-selectionBackground,
.editor-host .cm-editor.cm-focused .cm-selectionBackground {
  background: color-mix(in srgb, var(--link) 16%, transparent);
}

/* small screens: the page fills the desk, the capsules stay legible
   (no hover on touch — the chrome keeps a readable presence) */
@media (max-width: 640px) {
  main { margin: 5rem .6rem 6rem; }
  nav, footer { max-width: 96vw; border-radius: 20px; opacity: .8; }
  footer .quiet { display: none; }
  h1.pagetitle { font-size: 1.7rem; }
}
