/* Wendleaf's website, in the Red Book: its paper and ink by day, its cover and gold by night.
   Layout: one page of a hand-kept book. The head band opens it, the foot rule closes it, and
   the sections run down it like the day page, with the light rule between them. */

@font-face { font-family: "Uncial Antiqua"; src: url("/assets/fonts/uncial-antiqua.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "IM Fell English"; src: url("/assets/fonts/im-fell-english.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "IM Fell English"; font-style: italic; src: url("/assets/fonts/im-fell-english-italic.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "IM Fell English SC"; src: url("/assets/fonts/im-fell-english-sc.woff2") format("woff2"); font-display: swap; }

:root {
  /* The Red Book by day (Glance/ThemePalette.swift). */
  --paper: #F1E7D3;
  --paper2: #E4D5B9;
  --ink: #2C1A18;
  --faded: #6B5C54;
  --orn: #6E1F24;
  --rubric: #A03808;
  --on-orn: #F1E7D3;
  --rule: color-mix(in srgb, var(--faded) 45%, transparent);
  
  --display: "Uncial Antiqua", "Iowan Old Style", Georgia, serif;
  --body: "IM Fell English", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --caps: "IM Fell English SC", "IM Fell English", Georgia, serif;

  --measure: 34rem;
  --band: clamp(30px, 4.2vw, 44px);
  color-scheme: light;
}

/* By candlelight: the Red Book's own night page. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #4A2320; --paper2: #33171A; --ink: #EADBB4; --faded: #B49C82;
    --orn: #D8AE5C; --rubric: #F88A6A; --on-orn: #33171A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #4A2320; --paper2: #33171A; --ink: #EADBB4; --faded: #B49C82;
  --orn: #D8AE5C; --rubric: #F88A6A; --on-orn: #33171A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: url("/assets/paper-grain.png") 0 0 / 192px repeat, var(--paper);
  color: var(--ink);
  font: 400 1.1875rem/1.55 var(--body);
  font-feature-settings: "liga", "dlig" 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; }
a { color: inherit; text-decoration-color: color-mix(in srgb, var(--orn) 55%, transparent); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--orn); }
:focus-visible { outline: 2px solid var(--rubric); outline-offset: 3px; border-radius: 2px; }
::selection { background: color-mix(in srgb, var(--orn) 25%, transparent); }

.wrap {
  width: 100%;
  max-width: 72rem;
  margin-inline: auto;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 16px; background: var(--paper); padding: .5rem 1rem; z-index: 60; }

/* ----- Printed marks: the app's own cut-outs, inked in the page's ornament ----- */
.mark {
  display: block;
  background: var(--orn);
  -webkit-mask: var(--m) center / contain no-repeat;
          mask: var(--m) center / contain no-repeat;
}
.band, .foot, .divider { display: flex; align-items: stretch; width: 100%; }
.band { height: var(--band); }
.band > i, .foot > i, .divider > i { display: block; background: var(--orn); flex: none; }
.band > i { -webkit-mask: var(--m) center / auto 100% no-repeat; mask: var(--m) center / auto 100% no-repeat; }
.band .l { --m: url("/assets/marks/bandLeft1.png"); aspect-ratio: 164 / 72; }
.band .r { --m: url("/assets/marks/bandRight1.png"); aspect-ratio: 164 / 72; }
.band .m { --m: url("/assets/marks/bandMiddle.png"); aspect-ratio: 129 / 72; }
.band .r0 { --m: url("/assets/marks/bandRun0.png"); flex: 1; -webkit-mask-position: right center; mask-position: right center; }
.band .r1 { --m: url("/assets/marks/bandRun1.png"); flex: 1; -webkit-mask-position: left center; mask-position: left center; }

.foot { height: calc(var(--band) * .61); }
.foot > i { -webkit-mask: var(--m) center / auto 100% no-repeat; mask: var(--m) center / auto 100% no-repeat; }
.foot .l { --m: url("/assets/marks/footLeft.png"); aspect-ratio: 124 / 44; }
.foot .r { --m: url("/assets/marks/footRight.png"); aspect-ratio: 124 / 44; }
.foot .m { --m: url("/assets/marks/footMiddle.png"); aspect-ratio: 21 / 44; }
.foot .r0 { --m: url("/assets/marks/footRun0.png"); flex: 1; -webkit-mask-position: right center; mask-position: right center; }
.foot .r1 { --m: url("/assets/marks/footRun1.png"); flex: 1; -webkit-mask-position: left center; mask-position: left center; }

.divider { height: 30px; max-width: 26rem; margin-inline: auto; }
.divider > i { -webkit-mask: var(--m) center / auto 100% no-repeat; mask: var(--m) center / auto 100% no-repeat; }
.divider .l { --m: url("/assets/marks/dividerLeft.png"); aspect-ratio: 74 / 74; }
.divider .r { --m: url("/assets/marks/dividerRight.png"); aspect-ratio: 42 / 74; }
.divider .m { --m: url("/assets/marks/dividerMiddle.png"); aspect-ratio: 85 / 74; }
.divider .r0 { --m: url("/assets/marks/dividerRun0.png"); flex: 1; -webkit-mask-position: right center; mask-position: right center; }
.divider .r1 { --m: url("/assets/marks/dividerRun1.png"); flex: 1; -webkit-mask-position: left center; mask-position: left center; }

/* ----- Masthead ----- */
.masthead { padding-block: 18px 0; }
.nav {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding-block: .9rem 0;
  font-size: 1.0625rem;
}
.nav .name { font-family: var(--display); font-size: 1.35rem; text-decoration: none; letter-spacing: .01em; }
.nav ul { list-style: none; display: flex; gap: 1.4rem; margin: 0; padding: 0; flex-wrap: wrap; }
.nav ul a { text-decoration: none; color: var(--faded); }
.nav ul a:hover, .nav ul a[aria-current] { color: var(--ink); }

/* ----- Type ----- */
h1, h2, h3 { font-weight: 400; text-wrap: balance; margin: 0; }
h2 { font-family: var(--display); font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem); line-height: 1.12; }
h3 { font-family: var(--caps); font-size: 1.3rem; letter-spacing: .02em; }
p { margin: 0; }
.lede { font-size: clamp(1.2rem, 1.05rem + .6vw, 1.45rem); line-height: 1.45; }
.faded { color: var(--faded); }
.rubric { color: var(--rubric); }
.eyebrow { font-family: var(--caps); font-size: 1.05rem; letter-spacing: .06em; color: var(--rubric); }
em, i { font-style: italic; }

/* ----- Controls: cartouches, never capsules ----- */
.cartouche {
  --cut: 10px;
  display: inline-flex; align-items: center; gap: .6rem;
  padding: .7rem 1.35rem .75rem;
  font: inherit; font-size: 1.1rem; text-decoration: none; cursor: pointer;
  clip-path: polygon(var(--cut) 0, calc(100% - var(--cut)) 0, 100% 50%, calc(100% - var(--cut)) 100%, var(--cut) 100%, 0 50%);
  background: var(--orn); color: var(--on-orn); border: 0;
}
.cartouche.ruled {
  background: transparent; color: var(--ink); position: relative; clip-path: none;
  padding-inline: 1.2rem;
}
.cartouche.ruled::before {
  content: ""; position: absolute; inset: 0;
  background: var(--faded);
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 10px 100%, 0 50%,
                     1px 50%, calc(10px + .5px) calc(100% - 1px), calc(100% - 10px - .5px) calc(100% - 1px), calc(100% - 1px) 50%, calc(100% - 10px - .5px) 1px, calc(10px + .5px) 1px, 1px 50%);
}
.cartouche small { font-size: .82em; opacity: .85; }
.cartouche .lead { width: 1.1em; height: 1.1em; background: currentColor; }

/* ----- Sections ----- */
section { padding-block: clamp(3.5rem, 2rem + 5vw, 6.5rem); }
.section-head { display: grid; gap: .8rem; max-width: var(--measure); }
.section-head.center { margin-inline: auto; text-align: center; justify-items: center; }

/* ----- Footer ----- */
.site-foot { padding-block: 3rem 2.5rem; }
.site-foot .cols { display: flex; justify-content: space-between; gap: 1.5rem 3rem; flex-wrap: wrap; align-items: baseline; padding-top: 1.4rem; color: var(--faded); font-size: 1rem; }
.site-foot ul { list-style: none; display: flex; gap: 1.4rem; margin: 0; padding: 0; flex-wrap: wrap; }
.site-foot a { text-decoration: none; }
.site-foot a:hover { color: var(--ink); }

/* ----- Prose pages (privacy, support) ----- */
.leaf { max-width: 40rem; margin-inline: auto; padding-block: 3rem 4rem; }
.leaf h1 { font-family: var(--display); font-size: clamp(2.2rem, 1.6rem + 2.4vw, 3.2rem); line-height: 1.05; }
.leaf .when { color: var(--faded); font-style: italic; margin-top: .6rem; }
.leaf h2 { font-size: 1.6rem; margin-top: 2.6rem; }
.leaf p, .leaf ul { margin-top: .9rem; }
.leaf ul { padding-left: 1.2rem; }
.leaf li { margin-top: .4rem; }
.leaf li::marker { color: var(--orn); content: "◆  "; font-size: .7em; }
.leaf .plain { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding-block: 1.2rem; margin-top: 2rem; }
.leaf .plain p:first-child { margin-top: 0; }
.leaf dt { font-family: var(--caps); font-size: 1.2rem; margin-top: 1.6rem; }
.leaf dd { margin: .35rem 0 0; }
.address { user-select: all; white-space: nowrap; }
.leaf b { font-weight: 400; font-family: var(--caps); letter-spacing: .02em; }

@media (prefers-reduced-motion: no-preference) {
  .rise { animation: rise .9s cubic-bezier(.2, .7, .2, 1) both; }
  .rise.d1 { animation-delay: .08s; } .rise.d2 { animation-delay: .16s; } .rise.d3 { animation-delay: .24s; }
  @keyframes rise { from { opacity: .001; transform: translateY(8px); } }
}
