/*
  Tools for Mortals: styles.
  Two moods. Candlelight, the default for a sitting, takes its colours from
  the dark of Gijsbrechts' painted niche; daylight from his limewashed pine
  wall. The sitting page sets data-mood itself. The plain pages (privacy,
  not found) carry no data-mood and follow the device's light or dark setting.
*/

@font-face {
  font-family: 'IM Fell English';
  src: url('fonts/im-fell-english-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IM Fell English';
  src: url('fonts/im-fell-english-400-italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Alegreya Sans';
  src: url('fonts/alegreya-sans-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Alegreya Sans';
  src: url('fonts/alegreya-sans-400-italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Alegreya Sans';
  src: url('fonts/alegreya-sans-500.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}

@property --vr { syntax: '<length>'; inherits: false; initial-value: 260px; }
@property --cx { syntax: '<length>'; inherits: false; initial-value: 200px; }
@property --cy { syntax: '<length>'; inherits: false; initial-value: 260px; }

:root {
  color-scheme: light;
  --ground: #e9dfcb;
  --ground-rgb: 233, 223, 203;
  --surface: #f3ecdf;
  --ink: #2b2118;
  --ink-soft: #6a5845;
  --brass: #84601f;
  --brass-ink: #f6efe2;
  --line: rgba(43, 33, 24, .2);
  --scrim: rgba(18, 12, 8, .5);
  --fell: 'IM Fell English', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: 'Alegreya Sans', 'Gill Sans', 'Gill Sans MT', Seravek, 'Segoe UI', sans-serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--ground);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-mood]) {
    color-scheme: dark;
    --ground: #15100b;
    --ground-rgb: 21, 16, 11;
    --surface: #211a12;
    --ink: #ede3cf;
    --ink-soft: #b1a288;
    --brass: #c9a157;
    --brass-ink: #1a130c;
    --line: rgba(237, 227, 207, .17);
    --scrim: rgba(0, 0, 0, .6);
  }
}
:root[data-mood="candle"] {
  color-scheme: dark;
  --ground: #15100b;
  --ground-rgb: 21, 16, 11;
  --surface: #211a12;
  --ink: #ede3cf;
  --ink-soft: #b1a288;
  --brass: #c9a157;
  --brass-ink: #1a130c;
  --line: rgba(237, 227, 207, .17);
  --scrim: rgba(0, 0, 0, .6);
}

html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  height: 100%;
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--fell);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
*, *::before, *::after { box-sizing: border-box; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { height: 100%; display: grid; grid-template-rows: auto 1fr; overflow: hidden; }

.top {
  display: flex; justify-content: center; align-items: baseline;
  padding: .75rem 1.25rem .5rem; position: relative; z-index: 6;
}
.wordmark { font-family: var(--fell); font-style: italic; font-size: 1.1875rem; margin: 0; font-weight: 400; }
.main { position: relative; min-height: 0; overflow: hidden; }

/* "About", always to hand at the left of the name */
.about-link { position: absolute; left: .875rem; top: 50%; transform: translateY(-50%); font-size: .9375rem; min-height: 44px; padding: 0 .25rem; }

/* Two small buttons beside the name: light and sound */
.tools { position: absolute; right: .25rem; top: 50%; transform: translateY(-50%); display: flex; }
.tool {
  width: 40px; height: 44px; padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--ink-soft); display: inline-flex; align-items: center; justify-content: center;
}
.tool:hover { color: var(--ink); }
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.tool .when-on, .tool[aria-pressed="true"] .when-off { display: none; }
.tool[aria-pressed="true"] .when-on { display: inline; }
:root[data-mood="candle"] .tool .to-candle, :root[data-mood="day"] .tool .to-day { display: none; }

/* The sitting: the painting on a stage, the words in a panel */
.sitting { position: absolute; inset: 0; }
.stage { position: absolute; inset: 0; overflow: hidden; background: var(--ground); }
#painting {
  position: absolute; left: 0; top: 0; max-width: none;
  transform-origin: 0 0; will-change: transform;
  opacity: 0;
  transition: transform 2.6s cubic-bezier(.45, .05, .2, 1), opacity 1.8s ease;
  user-select: none; -webkit-user-drag: none;
}
#painting.lit { opacity: 1; }

/* Candlelight: the painting is drawn on this canvas, lit by one flame. The
   picture itself stays in place, unseen, for screen readers. */
#glow { position: absolute; inset: 0; width: 100%; height: 100%; display: none; transition: opacity .5s ease; }
.stage.glowing { touch-action: none; }
.stage.glowing #glow { display: block; }
.stage.glowing #painting, .stage.glowing #painting.lit { opacity: 0; }
.stage.glowing .vignette { display: none; }

/* A pool of light on the object being looked at */
.vignette {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle var(--vr) at var(--cx) var(--cy),
    rgba(var(--ground-rgb), 0) 0%, rgba(var(--ground-rgb), 0) 52%, rgba(var(--ground-rgb), .8) 100%);
  transition: --vr 2.6s cubic-bezier(.45, .05, .2, 1), --cx 2.6s cubic-bezier(.45, .05, .2, 1), --cy 2.6s cubic-bezier(.45, .05, .2, 1), opacity 1.4s ease;
}
.vignette.on { opacity: 1; }

.panel {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  max-height: 64%; overflow-y: auto; overscroll-behavior: contain;
  padding: 5.5rem 1.375rem 1.25rem;
  background: linear-gradient(to bottom,
    rgba(var(--ground-rgb), 0) 0,
    rgba(var(--ground-rgb), .88) 4.25rem,
    var(--ground) 6.25rem);
}
.panel-inner { max-width: 33rem; margin: 0 auto; transition: opacity .4s ease; }
.panel-inner.fading { opacity: 0; }

@media (min-width: 900px) {
  .sitting { display: grid; grid-template-columns: 1fr minmax(24rem, 30rem); }
  .stage { position: relative; inset: auto; height: 100%; }
  .panel {
    position: relative; max-height: none; height: 100%;
    background: var(--ground); border-left: 1px solid var(--line);
    padding: 3rem 2.75rem; display: flex; flex-direction: column; justify-content: center;
  }
  .panel-inner { margin: 0; width: 100%; }
}

/* Short screens: keep Begin in view on the opening screen */
@media (max-height: 700px) and (max-width: 899px) {
  .panel { max-height: 84%; padding-top: 4.25rem; padding-bottom: .9rem; }
  .panel .date { display: none; }
  .title { font-size: 1.75rem; margin-bottom: .4rem; }
  .lede { font-size: .9375rem; line-height: 1.34; margin-bottom: .7rem; }
  .work { margin-bottom: .5rem; }
  .work .t { font-size: 1.0625rem; line-height: 1.2; }
  .work .m { font-size: .875rem; }
  .controls { margin-top: .55rem; }
}

/* Words */
.date { font-family: var(--sans); font-size: .9375rem; color: var(--ink-soft); margin: 0 0 .4rem; }
h1, h2, h3 { font-weight: 400; margin: 0; }
h1:focus, h2:focus { outline: none; }
.title { font-family: var(--fell); font-size: 2.25rem; line-height: 1.08; margin-bottom: .6rem; }
.lede { font-family: var(--sans); font-size: 1rem; line-height: 1.42; color: var(--ink-soft); margin: 0 0 1.05rem; max-width: 30em; }
.page-main .title, .notfound .title { margin-bottom: 1.1rem; }
.prompt { font-family: var(--fell); font-size: 1.5rem; line-height: 1.22; margin-bottom: .7rem; }
.body { font-size: 1.125rem; line-height: 1.5; margin: 0 0 .9rem; max-width: 32em; }
.note {
  font-family: var(--sans); font-style: italic; font-size: .9375rem; line-height: 1.45;
  color: var(--ink-soft); margin: .2rem 0 .9rem;
}
.work { margin: 0 0 .85rem; }
.work .t { display: block; font-style: italic; font-size: 1.1875rem; line-height: 1.28; }
.work .m { display: block; font-family: var(--sans); font-size: .9375rem; color: var(--ink-soft); margin-top: .1rem; }

.credit {
  font-family: var(--sans); font-size: .9375rem; line-height: 1.45; color: var(--ink-soft);
  border-top: 1px solid var(--line); padding-top: .8rem; margin: .4rem 0 .6rem;
}
.credit p { margin: 0 0 .45rem; }
.credit em { font-family: var(--fell); font-size: 1.0625rem; color: var(--ink); }

.controls { display: flex; align-items: center; gap: .5rem 1.25rem; margin-top: 1rem; flex-wrap: wrap; }
.btn {
  font-family: var(--sans); font-size: 1.0625rem; font-weight: 500; letter-spacing: .01em;
  background: var(--brass); color: var(--brass-ink);
  border: 0; border-radius: 2px; padding: .65rem 1.45rem; min-height: 46px; cursor: pointer;
}
.btn:hover { filter: brightness(1.07); }
.link {
  font-family: var(--sans); font-size: 1rem; color: var(--ink-soft);
  background: none; border: 0; padding: .4rem 0; min-height: 44px; cursor: pointer;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px;
}
/* Links that sit in a row with buttons line up with them */
.controls a.link { display: inline-flex; align-items: center; }
.marks { margin-left: auto; display: flex; gap: 7px; align-items: center; }
.marks i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.marks i.on { background: var(--brass); }

.appear { animation: appear 1.2s ease both; }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }

/* Breathing */
.breath { display: none; align-items: baseline; gap: 1rem; margin: .1rem 0 .6rem; min-height: 2.6rem; }
.breathing .breath { display: flex; }
.breath-word { font-family: var(--fell); font-style: italic; font-size: 2rem; min-width: 3.5ch; }
.breath-count { display: flex; gap: 7px; }
.breath-count i { width: 16px; height: 2px; background: var(--line); }
.breath-count i.on { background: var(--brass); }

/* The about sheet */
.sheet-back {
  position: fixed; inset: 0; z-index: 20; background: var(--scrim);
  display: none; align-items: flex-end; justify-content: center;
}
.sheet-back.show { display: flex; }
.sheet {
  background: var(--surface); color: var(--ink);
  width: 100%; max-width: 38rem; max-height: 90%; overflow-y: auto; overscroll-behavior: contain;
  border-radius: 6px 6px 0 0;
  padding: 1.5rem 1.375rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  animation: rise .45s cubic-bezier(.2, .75, .2, 1) both;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h2 { font-family: var(--fell); font-size: 1.75rem; line-height: 1.15; margin-bottom: .3rem; }
.sheet h3 { font-family: var(--fell); font-size: 1.375rem; line-height: 1.2; margin: 1.6rem 0 .3rem; }
.sheet h4 { font-family: var(--sans); font-size: 1rem; font-weight: 500; margin: 1.4rem 0 .3rem; }
.sheet p { line-height: 1.5; }
.detail-fig { margin: 1.1rem 0 .4rem; }
.detail-fig img { width: 100%; display: block; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.detail-fig figcaption { font-family: var(--sans); font-size: .875rem; color: var(--ink-soft); margin-top: .45rem; }
.practices { list-style: none; padding: 0; margin: .4rem 0 0; }
.practices li { padding: .75rem 0; border-top: 1px solid var(--line); }
.practices .n { font-size: 1.1875rem; }
.practices .o { font-family: var(--sans); font-size: .9375rem; color: var(--ink-soft); }
.practices .d { font-size: 1.0625rem; line-height: 1.4; margin-top: .15rem; }
.today { font-family: var(--sans); font-size: .875rem; font-weight: 500; color: var(--brass); margin-left: .45rem; }

.fallback { padding: 2rem 1.375rem; font-family: var(--sans); color: var(--ink-soft); }

@media (prefers-reduced-motion: reduce) {
  #painting { transition: opacity .5s ease; }
  .stage.glowing #painting { transition: none; }
  .vignette { transition: opacity 1s ease; }
  .sheet { animation: none; }
  .appear { animation: none; }
  .panel-inner { transition: none; }
}

/* The page shown for an address that doesn't exist (404.html) */
.notfound { display: flex; align-items: center; justify-content: center; padding: 1.5rem 1.375rem 3rem; }
.notfound-inner { max-width: 30rem; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }

/* Plain pages (privacy) */
.page-body { height: auto; }
.page { min-height: 100%; }
.page .wordmark a { color: inherit; text-decoration: none; }
.page-main { max-width: 36rem; margin: 0 auto; padding: 1rem 1.375rem 3rem; }
.page-main .title { margin: 1rem 0 1.2rem; }
.page-main .prompt { font-size: 1.3rem; margin: 1.6rem 0 .5rem; }

/* The sittings, as plain words (sittings.html) */
.sitting-text { border-top: 1px solid var(--line); margin-top: 2rem; padding-top: .4rem; }
.sitting-text h3 { font-family: var(--fell); font-size: 1.1875rem; line-height: 1.3; margin: 1.3rem 0 .35rem; }
.fallback a { color: inherit; }
.sitting-link { font-family: var(--fell); font-size: 1.1875rem; color: var(--ink); min-height: 0; padding: 0; }
.page-main .practices { margin-top: 1.4rem; }

.sheet-links { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin-top: .8rem; }
.sheet-links .link { font-style: normal; font-size: .9375rem; }
.page-main .body a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
