/* Horarium prototype: the hour's landscape fills the screen, quietening as it rises; the hour and the prayer sit in
   the calm above the hills. Brand values live in tokens.css. Red only for rubrics.
   Theme tokens (--ground, --ink, --muted, --rub, --hair): day by default, night at Matins and Compline; the scene
   moves them smoothly when an hour change crosses between the two. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overflow-x: clip; }
body { overflow-x: clip; }
.scroller, .rest { overflow-wrap: break-word; }
.js .screen { touch-action: pan-y; }
body { margin: 0; background: var(--vellum); color: var(--lampblack); font: 400 1.125rem/1.5 var(--font-text); font-kerning: normal; font-variant-ligatures: common-ligatures; }
h1, h2, h3, p, ol { margin: 0; padding: 0; }
ol { list-style: none; }
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { text-decoration-color: var(--rub); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
[hidden] { display: none !important; }
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -100px; z-index: 20; padding: 10px 16px; background: var(--lampblack); color: var(--vellum); }
.skip:focus { top: 8px; }

:root {
  --app-h: calc(100svh - var(--dd-bar-h, 0px));
  --land-frac: .32;                        /* the hills fill about the lower third of a phone */
  --calm-gap: 76px;                        /* air between the content and the hills, for the sky to regain its colour */
  --sink: 0px;                             /* the land no longer settles while reading */
  --ground: var(--vellum); --ink: var(--lampblack); --muted: var(--stone); --rub: var(--rubric); --hair: rgb(28 26 23 / .18); --halo: transparent; --now: #7A5A1E;
  --col: min(100% - 40px, 28rem);
}

@media (min-aspect-ratio: 5/4) { :root { --land-frac: .40; --calm-gap: 40px; } }
/* Each hour's text colours, chosen from that hour's sky where the text sits (the scene reads these too).
   Pale skies take ink with a deep oxblood rubric; dark skies take vellum with a light coral rubric. --ground is the
   hour's sky tone: the fallback behind the canvas, the Begin label, and the colour of the halo. --now is the gold
   of the clock's-hour marker: deep on pale skies, light on dark ones (the scene holds it to 3:1 like the strokes). */
[data-hour="matins"]   { --ground: #050F22; --ink: #F3EEE2; --muted: #D9D3C6; --rub: #E8806C; --halo: rgb(5 15 34 / .6);    --hair: rgb(243 238 226 / .22); --read-weight: 400; --now: #E2C07A; }
[data-hour="lauds"]    { --ground: #ECE8F0; --ink: #1C1A17; --muted: #302B25; --rub: #6A170F; --halo: rgb(236 232 240 / .6); --hair: rgb(28 26 23 / .2); --now: #7A5A1E; }
[data-hour="prime"]    { --ground: #EEF4FB; --ink: #1C1A17; --muted: #302B25; --rub: #6E1810; --halo: rgb(238 244 251 / .6); --hair: rgb(28 26 23 / .2); --now: #7A5A1E; }
[data-hour="terce"]    { --ground: #EEF4FB; --ink: #1C1A17; --muted: #302B25; --rub: #6E1810; --halo: rgb(238 244 251 / .6); --hair: rgb(28 26 23 / .2); --now: #7A5A1E; }
[data-hour="sext"]     { --ground: #F4F8FC; --ink: #1C1A17; --muted: #3F3931; --rub: #7E1C13; --halo: rgb(244 248 252 / .6); --hair: rgb(28 26 23 / .2); --now: #7A5A1E; }
[data-hour="none"]     { --ground: #F0F3F7; --ink: #1C1A17; --muted: #302B25; --rub: #6E1810; --halo: rgb(240 243 247 / .6); --hair: rgb(28 26 23 / .2); --now: #7A5A1E; }
[data-hour="vespers"]  { --ground: #261B38; --ink: #F3EEE2; --muted: #ECE7DC; --rub: #F6B3A3; --halo: rgb(38 27 56 / .6); --hair: rgb(243 238 226 / .22); --read-weight: 400; --now: #E2C07A; }
[data-hour="compline"] { --ground: #0B1830; --ink: #F3EEE2; --muted: #ECE7DC; --rub: #F6B3A3; --halo: rgb(11 24 48 / .6); --hair: rgb(243 238 226 / .22); --read-weight: 400; --now: #E2C07A; }

/* Text sits on the picture with a soft, wide halo in the sky's own tone: felt, not seen */
.js .screen, .js .top, .js .rest > *, .js .reading { text-shadow: 0 0 .35em var(--halo), 0 0 1.1em var(--halo); }
/* These blocks take an hour's colours on their own while the light changes, so they resolve them themselves */
:where(.js .top, .js .rest > *, .js .reading) { color: var(--ink); }
/* The name and gloss keep the same box whatever the hour, so the sky under them turns as one block */
.js .rest .now, .js .rest .gloss { align-self: stretch; justify-self: stretch; }
.js .dial__stroke { box-shadow: 0 0 10px var(--halo); }

/* The mark: eight strokes, the hour's stroke in Rubric */
.mk rect { fill: var(--ink); }
.no-js .mk--bar rect[data-i="1"], .mk--bar rect.is-on { fill: var(--rub); }

/* Screen */
.screen { position: relative; scroll-margin-top: var(--dd-bar-h, 0px); background: var(--ground); color: var(--ink); }
.screen:focus { outline: 0; }
.js .screen { transition: none; }
/* While the page turns between day and night the scene drives every colour; nothing may lag behind it */
.is-turning, .is-turning * { transition-property: opacity, transform, visibility !important; }
.js .screen { display: flex; flex-direction: column; height: var(--app-h); min-height: 520px; overflow: hidden; }

.top { position: relative; z-index: 1; display: grid; justify-items: center; gap: 2px; padding: clamp(14px, 2.4svh, 28px) 20px 0; text-align: center; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 400; }
.mk--bar { width: 22px; height: 22px; }
.brand .caps { font-size: .875rem; letter-spacing: .36em; padding-left: .36em; }
.about { color: var(--muted); font-size: 1rem; font-style: italic; }
.about__long { }
@media (max-width: 419px) { .about__long { display: none; } }
.about a { display: inline-block; padding-block: 12px; margin-block: -12px; color: var(--ink); }

.stage { position: relative; z-index: 1; width: var(--col); margin-inline: auto; }
.js .stage { display: grid; }
.js .stage { flex: 1; min-height: 0; margin-bottom: calc(var(--app-h) * var(--land-frac) + var(--calm-gap)); }
/* While reading, the column runs down over the sky; its bottom fade dissolves lines just above the cypress tips */
.js .reading { margin-bottom: calc(16px - var(--calm-gap)); }
.js .rest, .js .reading { grid-area: 1 / 1; min-width: 0; min-height: 0; }

/* Rest: the hour, the day, the dial, Begin */
.rest { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(4px, 1.4svh, 14px); padding-block: clamp(14px, 3svh, 32px) 4px; text-align: center; }
.now { color: var(--rub); font-size: clamp(1.875rem, 5.2svh, 3rem); letter-spacing: .24em; padding-left: .24em; }
.gloss { color: var(--muted); font-size: clamp(1.125rem, 2.6svh, 1.25rem); font-style: italic; letter-spacing: .02em; }
/* Now: <Hour> rides the gloss line; its 44px target overhangs the line instead of making it taller */
.gloss .gloss__now { margin: -10px -10px -10px 6px; font-style: normal; vertical-align: baseline; }
.day { display: inline-flex; align-items: stretch; gap: 12px; margin-top: 4px; text-align: left; line-height: 1.3; }
.day__band { flex: none; width: 3px; background: var(--season-red); }
.day__label { display: block; color: var(--muted); font-size: 1rem; }
.day__feast { display: block; font-size: 1rem; text-wrap: balance; }

.contents { width: 100%; max-width: 18rem; margin: 20px auto 8px; text-align: left; }
.contents li { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--hair); }
.contents a { display: inline-flex; align-items: center; min-height: 44px; }
.contents span { align-self: center; color: var(--muted); font-style: italic; }

.dial { margin-block: clamp(22px, 4.2svh, 40px) clamp(4px, 1.6svh, 18px); translate: 0 clamp(0px, 30svh - 172px, 20px); }
.dial__ring { --d: clamp(160px, calc(var(--app-h) * .23), 248px); position: relative; width: var(--d); height: var(--d); margin: 0 auto; }
.dial__h { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; padding: 0; border: 0; background: none; color: inherit; cursor: pointer; transform: rotate(var(--a)) translateY(calc(var(--d) * -.38)); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
/* A light stroke: thinner and a little longer than before, nearer the weight of the type beside it */
.dial__stroke { position: absolute; left: 50%; top: 50%; width: calc(var(--d) * .045); height: calc(var(--d) * .2); background: var(--ink); transform: translate(-50%, -50%); transition: transform .2s var(--ease-out); }
.dial__h:hover .dial__stroke { transform: translate(-50%, -50%) scaleY(1.08); }
.dial__h[aria-current="true"] .dial__stroke { background: var(--rub); }
/* The clock's hour: a gold dot just beyond its stroke */
.dial__h.is-now::after { content: ""; position: absolute; left: 50%; top: calc(50% - var(--d) * .1 - 12px); width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%; background: var(--now); }
.dial__h:focus-visible { outline-offset: -2px; }
/* Names sit just past each stroke's outer end, upright, their near edge towards the dial */
.dial__name { --r: calc(var(--d) * .48 + 16px); position: absolute; left: calc(50% + sin(var(--a)) * var(--r)); top: calc(50% - cos(var(--a)) * var(--r));
  translate: calc(-50% + sin(var(--a)) * 50%) calc(-50% - cos(var(--a)) * 50%); color: var(--muted); font-size: .875rem; font-style: italic; line-height: 1;
  white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .2s var(--ease-out); }
.dial__name.is-q { opacity: 1; }
.dial__h:focus-visible + .dial__name { opacity: 1; color: var(--ink); }
@media (hover: hover) { .dial__h:hover + .dial__name { opacity: 1; color: var(--ink); } }
.dial__ring .begin { width: calc(var(--d) * .44); }

/* Short screens: a smaller dial and tighter rhythm so the hour keeps its air above and below */
@media (max-height: 780px) {
  :root { --calm-gap: 48px; }
  .dial__ring { --d: clamp(144px, calc(var(--app-h) * .23), 248px); }
  .rest { gap: 4px; padding-block: 10px 0; }
  .now { font-size: 1.875rem; }
  .dial { margin-block: clamp(6px, 20svh - 112px, 22px) 0; }
}

/* Wide, short screens: the hour on the left, the dial on the right */
@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  :root { --col: min(100% - 64px, 46rem); }
  .js .rest { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "now dial" "gloss dial" "day dial"; align-content: center; justify-items: start; column-gap: clamp(48px, 7vw, 96px); row-gap: 10px; text-align: left; }
  .js .rest .now { grid-area: now; align-self: end; padding-left: 0; font-size: clamp(3.75rem, 8svh, 4.5rem); }
  /* The header hangs from the same column edges as the hour and the dial below it */
  .js .top { display: flex; align-items: center; justify-content: space-between; width: var(--col); margin-inline: auto; padding-inline: 0; }
  .js .is-reading .top { width: min(var(--col), 28rem); }
  /* The painting is drawn larger here, so its cypresses rise higher; the prayer's fade ends above their tips */
  .js .reading { margin-bottom: calc(max(4.3vw, var(--app-h) * var(--land-frac) * .16) + 8px - var(--calm-gap)); }
  .js .rest .gloss { grid-area: gloss; }
  .js .rest .day { grid-area: day; align-self: start; margin-top: 8px; }
  .js .rest .dial { grid-area: dial; margin: 0; translate: none; }
  .js .dial__ring { --d: clamp(168px, calc(var(--app-h) * .3), 224px); }
  .js .reading { width: min(100%, 28rem); justify-self: center; }
}

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 22px; border: 1px solid var(--ink); background: var(--ground); color: var(--ink); font: inherit; font-size: 1rem; font-variant-caps: all-small-caps; letter-spacing: .14em; cursor: pointer; touch-action: manipulation; transition: opacity .2s var(--ease-out); }
/* Begin: a quiet word in the still centre of the dial. The whole centre is the target. */
.begin { position: absolute; left: 50%; top: 50%; display: grid; place-items: center; width: 132px; aspect-ratio: 1; min-width: 44px; padding: 0;
  border: 0; border-radius: 50%; background: none; color: var(--ink); cursor: pointer; transform: translate(-50%, -50%);
  font: 400 1rem/1 var(--font-display); letter-spacing: .16em; text-transform: uppercase; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: opacity .2s var(--ease-out); }
/* The word's box holds the word and its rule, evened for the trailing letter space; the focus ring draws round it */
.begin span { margin: 6px -20px 0; padding: 4px 4px 10px calc(4px + .16em); }
.begin:hover { opacity: .72; }
.begin:active { opacity: .55; }
.begin:focus-visible { outline: 0; }
.begin:focus-visible span { outline: 2px solid var(--ink); }
.begin::after { content: ""; position: absolute; left: 50%; top: calc(50% + .95em); width: 2.6em; margin-left: -1.3em; border-top: 1px solid currentColor; opacity: .7; }
.btn--quiet { padding: 0 10px; border-color: transparent; background: transparent; }
.btn { white-space: nowrap; }
/* While reading, the small concept line steps aside to give the prayer the room (the footer and board still say it) */
.js .is-reading .about { display: none; }
@media (max-width: 359px) { .reading__bar .btn { padding: 0 6px; letter-spacing: .08em; } .reading__bar { margin-inline: -6px; } }
.btn--quiet:hover { border-color: var(--hair); }
.no-js .begin-row { display: none; }

/* Reading */
.reading { display: flex; flex-direction: column; }
.reading__bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-inline: -10px; }
.reading__right { display: flex; gap: 2px; }
.no-js .reading__bar { display: none; }
.no-js .reading { margin-top: 48px; padding-top: 40px; border-top: 1px solid var(--hair); }
.lang__box { width: 13px; height: 13px; border: 1px solid var(--ink); }
.lang[aria-pressed="true"] .lang__box { background: var(--ink); }
.js .scroller { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; scrollbar-width: thin; scrollbar-color: rgb(28 26 23 / .25) transparent;
  -webkit-mask-image: linear-gradient(transparent, #000 36px, #000 calc(100% - 64px), transparent);
          mask-image: linear-gradient(transparent, #000 36px, #000 calc(100% - 64px), transparent); }
.scroller:focus-visible { outline-offset: -2px; }
.js .scroller__in { padding: 20px 2px calc(var(--app-h) * .18); }

/* Rest and reading trade places: out first, then in; opacity and a few pixels of travel, 300ms each */
.js .rest, .js .reading { transition: opacity .3s var(--ease-out), transform .3s var(--ease-out), visibility 0s linear .3s; }
.js .reading { opacity: 0; visibility: hidden; transform: translateY(10px); }
.js .is-reading .rest { opacity: 0; visibility: hidden; transform: translateY(-10px); }
.js .is-reading .reading { opacity: 1; visibility: visible; transform: none; transition: opacity .3s var(--ease-out) .18s, transform .3s var(--ease-out) .18s, visibility 0s; }
.js .screen:not(.is-reading) .rest { transition: opacity .3s var(--ease-out) .18s, transform .3s var(--ease-out) .18s, visibility 0s; }

/* The prayer */
.hour { scroll-margin-top: calc(var(--dd-bar-h, 0px) + 16px); }
.no-js .hour { width: var(--col); margin: 0 auto; }
.no-js .hour + .hour { margin-top: 48px; padding-top: 48px; border-top: 1px solid var(--hair); }
.hour__head { margin: 8px 0 22px; text-align: center; }
.hour__title { color: var(--rub); font: 400 1.25rem/1.3 var(--font-display); letter-spacing: .22em; padding-left: .22em; text-transform: uppercase; }
.hour__title:focus { outline: 0; }
.hour__title:focus-visible { outline: 2px solid var(--ink); }
.hour__la { margin-top: 4px; color: var(--rub); font-style: italic; }
.rub { margin: 18px 0 6px; color: var(--rub); font-size: 1rem; font-style: italic; }
.rub-h { margin: 30px 0 4px; color: var(--rub); font-size: 1.125rem; font-weight: 400; font-variant-caps: all-small-caps; letter-spacing: .08em; }
.rub-h__ref { font-style: italic; font-variant-caps: normal; letter-spacing: 0; }
.rub-h + .rub { margin-top: 0; }
.vr p { padding-left: 1.4em; text-indent: -1.4em; font-size: var(--read-size); font-weight: var(--read-weight, 500); }
.vr__m { display: inline-block; width: 1.4em; text-indent: 0; color: var(--rub); font-family: var(--font-text), "Segoe UI Symbol", "Noto Sans Symbols", serif; }
.text { margin-top: 8px; }
/* The prayer: one step larger than before, and a little firmer on pale skies */
:root { --read-size: clamp(1.25rem, 1.19rem + .25vw, 1.5rem); }
.text p { margin-bottom: .5em; font-size: var(--read-size); font-weight: var(--read-weight, 500); line-height: 1.5; }
/* The initial sinks exactly two lines: the third line starts at the margin again. A float no taller than two lines
   (3em of the text) where initial-letter is not supported. */
.text--initial [data-l] > p:first-child::first-letter { float: left; margin: .02em .1em 0 0; color: var(--rub); font-family: var(--font-display); font-size: 3.7em; line-height: .78; }
@supports (initial-letter: 2) or (-webkit-initial-letter: 2) {
  .text--initial [data-l] > p:first-child::first-letter { float: none; margin: 0 .12em 0 0; font-size: inherit; line-height: inherit; -webkit-initial-letter: 2; initial-letter: 2; }
}
.text--gloria { margin-top: 4px; }
.js [data-l="la"] { display: none; }
.js.is-latin [data-l="en"] { display: none; }
.js.is-latin [data-l="la"] { display: block; }
.no-js [data-l="la"] { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--hair); }
.end { position: relative; margin: 40px 0 8px; padding-top: 22px; text-align: center; font-style: italic; }
.end::before { content: ""; position: absolute; left: calc(50% - 20px); top: 0; width: 40px; border-top: 1px solid var(--gilt); }
/* The parting line fades in when the end is reached */
.js .end { min-height: 3em; opacity: 0; transform: translateY(6px); transition: opacity .6s var(--ease-out), transform .6s var(--ease-out); }
.js .end.is-shown { opacity: 1; transform: none; }
/* The two ways on from the end appear with the parting line */
.choices { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin: 4px -10px 0; visibility: hidden; opacity: 0; transition: opacity .6s var(--ease-out), visibility 0s .6s; }
.choices.is-shown { visibility: visible; opacity: 1; transition: opacity .6s var(--ease-out) .2s, visibility 0s; }
.no-js .end [data-l] { display: block; }
.no-js .end [data-l="la"] { margin: 6px 0 0; padding: 0; border: 0; }

/* The landscape: a still, then the live canvas over it */
.land { pointer-events: none; }
.js .land { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.still { width: 100%; image-rendering: pixelated; }
.js .still { position: absolute; inset: 0; height: 100%; object-fit: cover; object-position: 50% 100%; transition: visibility 0s .4s; }
.no-js .still { height: auto; margin-top: 24px; }
.scene { position: absolute; left: 0; bottom: 0; max-width: none; image-rendering: pixelated; opacity: 0; transition: opacity .3s var(--ease-out); }
.no-js .scene { display: none; }
.land.is-live .scene { opacity: 1; }
.land.is-live .still { visibility: hidden; }

/* Footer, below the screen */
.foot { --ink: var(--lampblack); --muted: var(--stone); --hair: rgb(28 26 23 / .18); max-width: 46rem; margin: 0 auto; padding: 40px 24px 40px; border-top: 1px solid var(--hair); color: var(--muted); font-size: 1rem; text-align: center; }
.foot p + p { margin-top: 8px; }
.foot__small { font-size: .875rem; }
.foot a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* The haptic switch: rendered (a hidden control may not tick) but invisible, out of the way, out of the tab order */
.tapper { position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; margin: 0; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; pointer-events: none; }
.tapper input { margin: 0; }
/* Only with ?haptic=test: a plain button that fires the tick straight from a tap */
.haptic-test { position: fixed; left: 12px; bottom: 12px; z-index: 30; min-height: 44px; padding: 0 16px; border: 1px solid #1C1A17; background: #F3EEE2; color: #1C1A17; font: 500 1rem var(--font-text); }
/* Only with ?embed=1 (the studio's project page frames the app): no studio bar, no footer; the screen is the whole frame */
html.embed:root { --dd-bar-h: 0px; }
.embed .dd-bar, .embed .foot, .embed .about { display: none; }
@media (max-width: 500px) { html.embed { scrollbar-width: none; } html.embed::-webkit-scrollbar { display: none; } }
.embed .scroller { scrollbar-width: none; } .embed .scroller::-webkit-scrollbar { display: none; }
