/* Spiritual Workout: white chalk on a dark board. No JavaScript. */

:root {
  --bg: #0b0c0d;
  --bg-raise: #111314;
  --chalk: #ece9e2;
  --chalk-2: #bdb9b0;
  --chalk-3: #8a867f;
  --rule: rgba(236, 233, 226, 0.14);
  --rule-strong: rgba(236, 233, 226, 0.32);
  --dust: 0 0 1px rgba(236, 233, 226, 0.35), 0 0 14px rgba(236, 233, 226, 0.08);

  --serif: "EB Garamond", Garamond, Georgia, "Times New Roman", serif;
  --caps: "Cinzel", "Trajan Pro", Georgia, serif;

  --measure: 38rem;
  --gutter: clamp(1rem, 4vw, 2rem);

  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 60% at 50% 18%, rgba(236, 233, 226, 0.035), transparent 70%),
    var(--bg);
  color: var(--chalk);
  font-family: var(--serif);
  font-size: clamp(1.0625rem, 0.98rem + 0.35vw, 1.25rem);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Fine chalkboard grain over everything. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.4 -.45'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3 {
  font-family: var(--caps);
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 1.15;
  margin: 0;
  text-shadow: var(--dust);
}

p { margin: 0; }

a {
  color: var(--chalk);
  text-decoration-line: underline;
  text-decoration-color: var(--rule-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: text-decoration-color 0.2s ease, color 0.2s ease;
}

a:hover { text-decoration-color: var(--chalk); }

:focus-visible {
  outline: 1.5px dashed var(--chalk);
  outline-offset: 4px;
  border-radius: 2px;
}

.kicker {
  font-family: var(--caps);
  font-size: 0.75rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--chalk-3);
}

/* ---------- Hero ---------- */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: clamp(1.5rem, 5vh, 3.5rem) var(--gutter) clamp(3rem, 8vh, 5rem);
}

.hero-art {
  display: block;
  width: min(100%, 46vh, 440px);
  height: auto;
  margin-bottom: clamp(1rem, 3vh, 2rem);
}

@media (prefers-reduced-motion: no-preference) {
  .hero-art { animation: appear 1.6s ease-out both; }
  .hero > :not(.hero-art) { animation: appear 1.2s 0.5s ease-out both; }
  .subhero { animation: appear 1.2s ease-out both; }
}

@keyframes appear {
  from { opacity: 0; filter: blur(3px); }
  to { opacity: 1; filter: blur(0); }
}

.hero h1,
.subhero h1 {
  font-size: clamp(2.1rem, 1.4rem + 3.6vw, 4rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  margin: 0.6rem 0 0.5rem;
}

.lede {
  font-style: italic;
  font-size: 1.15em;
  color: var(--chalk-2);
}

.jump {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 2rem;
  margin-top: 2rem;
  font-family: var(--caps);
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.jump a {
  text-decoration: none;
  color: var(--chalk-2);
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--rule-strong);
}

.jump a:hover {
  color: var(--chalk);
  border-bottom-color: var(--chalk);
}

/* ---------- Sections ---------- */

.section {
  max-width: 54rem;
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 5.5rem) var(--gutter);
  border-top: 1px solid var(--rule);
}

.section-head {
  text-align: center;
  margin-bottom: clamp(2.5rem, 6vw, 4rem);
}

.section-head h2 {
  font-size: clamp(1.7rem, 1.2rem + 2vw, 2.6rem);
  margin-top: 0.6rem;
}

/* ---------- Daily workout ---------- */

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

.set {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 1.5rem 2.5rem;
  padding: clamp(2rem, 5vw, 3rem) 0;
}

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

.set-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  gap: 0.35rem;
}

.set-num {
  font-family: var(--caps);
  font-size: 3rem;
  line-height: 1;
  color: var(--chalk);
  text-shadow: var(--dust);
}

.set-when {
  font-family: var(--caps);
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--chalk-3);
}

.set-body { max-width: var(--measure); }

.set-body h3 {
  font-size: clamp(1.3rem, 1.1rem + 0.8vw, 1.65rem);
  margin-bottom: 1.25rem;
}

.prayers p { color: var(--chalk); }

/* A small chalk cross between prayers. */
.prayers p + p::before {
  content: "";
  display: block;
  width: 11px;
  height: 16px;
  margin: 1.3rem 0 1.1rem;
  opacity: 0.45;
  background:
    linear-gradient(var(--chalk), var(--chalk)) center 4px / 11px 1.5px no-repeat,
    linear-gradient(var(--chalk), var(--chalk)) center / 1.5px 16px no-repeat;
}

.set-note {
  color: var(--chalk-2);
  margin-bottom: 1.5rem;
}

.set-note em { color: var(--chalk); }

.button {
  display: inline-block;
  font-family: var(--caps);
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--chalk);
  padding: 0.85rem 1.4rem;
  border: 1.5px solid var(--rule-strong);
  border-radius: 2px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.button::after { content: " \2197"; }
.button.internal::after { content: " \2192"; }

.button:hover {
  border-color: var(--chalk);
  background-color: rgba(236, 233, 226, 0.05);
}

/* ---------- Resources ---------- */

.shelves {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(2rem, 5vw, 3.5rem) clamp(2rem, 6vw, 4.5rem);
}

.shelf h3 {
  font-size: 0.85rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--chalk-2);
  padding-bottom: 0.75rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}

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

.shelf li {
  display: flex;
  flex-direction: column;
  padding: 0.8rem 0;
}

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

.shelf li > a {
  font-size: 1.12em;
  line-height: 1.35;
  width: fit-content;
}

.shelf li > a::after {
  content: " \2197";
  font-size: 0.8em;
  color: var(--chalk-3);
}

.shelf li > span {
  font-size: 0.86em;
  color: var(--chalk-3);
  margin-top: 0.15rem;
}

/* ---------- Prayer to St. Michael ---------- */

.closing-prayer {
  max-width: 34rem;
  margin: 0 auto;
  text-align: center;
  font-size: clamp(1.2rem, 1.05rem + 0.6vw, 1.45rem);
  line-height: 1.75;
  text-shadow: var(--dust);
}

.closing-prayer::before {
  content: "";
  display: block;
  width: 13px;
  height: 20px;
  margin: 0 auto 1.75rem;
  opacity: 0.55;
  background:
    linear-gradient(var(--chalk), var(--chalk)) center 5px / 13px 1.5px no-repeat,
    linear-gradient(var(--chalk), var(--chalk)) center / 1.5px 20px no-repeat;
}

/* Set line by line, as on a prayer card, with a large initial and a closing Amen. */
.closing-prayer .line {
  display: block;
  text-wrap: balance;
}

.closing-prayer .line:first-child::first-letter {
  font-family: var(--caps);
  font-size: 2.3em;
  line-height: 1;
  padding-right: 0.04em;
}

.closing-prayer .amen {
  margin-top: 1.4rem;
  font-family: var(--caps);
  font-size: 0.8em;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

/* ---------- Rosary invitation (home) ---------- */

.invite {
  max-width: var(--measure);
  margin: clamp(2.5rem, 6vw, 3.5rem) auto 0;
  padding: clamp(1.75rem, 5vw, 2.5rem) clamp(1.25rem, 5vw, 2.5rem);
  text-align: center;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: rgba(236, 233, 226, 0.02);
}

.invite-beads {
  display: block;
  width: 187px;
  max-width: 100%;
  height: auto;
  margin: 0 auto 1.5rem;
  overflow: visible;
}

.invite-beads line { stroke: var(--chalk-3); stroke-width: 1; opacity: 0.7; }
.invite-beads circle { fill: var(--chalk-2); }
.invite-beads .big { fill: var(--chalk); }

.invite h3 {
  font-size: clamp(1.4rem, 1.2rem + 0.8vw, 1.75rem);
  margin: 0.6rem 0 0.75rem;
}

.invite-text {
  color: var(--chalk-2);
  margin-bottom: 1.6rem;
}

/* ---------- Rosary page ---------- */

.crumb {
  padding: 1.25rem var(--gutter) 0;
  font-family: var(--caps);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.crumb a {
  color: var(--chalk-3);
  text-decoration: none;
}

.crumb a:hover { color: var(--chalk); }

.subhero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: clamp(2.5rem, 7vh, 4rem) var(--gutter) clamp(3rem, 8vh, 4.5rem);
}

.subhero::before {
  content: "";
  display: block;
  width: 17px;
  height: 26px;
  margin-bottom: 1.6rem;
  opacity: 0.6;
  background:
    linear-gradient(var(--chalk), var(--chalk)) center 7px / 17px 1.5px no-repeat,
    linear-gradient(var(--chalk), var(--chalk)) center / 1.5px 26px no-repeat;
}

.subhero h1 { margin: 0.6rem 0 0.5rem; }

.subhero-intro {
  max-width: 34rem;
  margin-top: 1.5rem;
  color: var(--chalk-2);
}

.guide {
  display: grid;
  grid-template-columns: minmax(0, 23rem) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

.guide-figure { margin: 0; }

@media (min-width: 761px) and (min-height: 640px) {
  .guide-figure {
    position: sticky;
    top: 1.5rem;
  }
}

.rosary-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 0 6px rgba(236, 233, 226, 0.12));
}

.rosary-svg .chain { fill: none; stroke: var(--chalk-3); stroke-width: 1; opacity: 0.7; }
.rosary-svg .bead { fill: var(--chalk-2); }
.rosary-svg .bead.big { fill: var(--chalk); }
.rosary-svg .medal ellipse { fill: var(--bg); stroke: var(--chalk); stroke-width: 1.5; }
.rosary-svg .medal .medal-inner { fill: none; stroke-width: 0.8; stroke-opacity: 0.55; }
.rosary-svg .crux path { fill: none; stroke: var(--chalk); stroke-width: 3; }
.rosary-svg .leader { stroke: var(--chalk-3); stroke-width: 1; stroke-dasharray: 2 3; }
.rosary-svg .marker circle { fill: var(--bg); stroke: var(--chalk-2); stroke-width: 1; }

.rosary-svg text {
  font-family: var(--caps);
  text-anchor: middle;
  dominant-baseline: central;
}

.rosary-svg .marker text { fill: var(--chalk); font-size: 13px; font-weight: 600; }
.rosary-svg .decade-num { fill: var(--chalk-3); font-size: 13px; letter-spacing: 0.08em; }

.rosary-svg :is(.bead, .medal, .crux, .marker) { transition: opacity 0.25s ease; }

/* Point at a step and its beads light up on the diagram. */
:where(.guide:has(.step:hover, .step:focus-within)) :is(.bead, .medal, .crux, .marker) { opacity: 0.2; }

.guide:has(.step-1:hover, .step-1:focus-within) .s1,
.guide:has(.step-2:hover, .step-2:focus-within) .s2,
.guide:has(.step-3:hover, .step-3:focus-within) .s3,
.guide:has(.step-4:hover, .step-4:focus-within) .s4,
.guide:has(.step-5:hover, .step-5:focus-within) .s5,
.guide:has(.step-6:hover, .step-6:focus-within) .s6,
.guide:has(.step-7:hover, .step-7:focus-within) .s7 { opacity: 1; }

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.75rem;
  margin-top: 1.1rem;
  font-family: var(--caps);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--chalk-3);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--chalk-2);
}

.swatch-big {
  width: 14px;
  height: 14px;
  background: var(--chalk);
}

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

.step {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 1.1rem;
  padding: 1.35rem 0;
}

.step:first-child { padding-top: 0; }
.step + .step { border-top: 1px dashed var(--rule); }

.step-num {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin-top: 0.1rem;
  border: 1px solid var(--chalk-2);
  border-radius: 50%;
  font-family: var(--caps);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.step:hover .step-num,
.step:focus-within .step-num {
  background: var(--chalk);
  color: var(--bg);
}

.step h3 {
  font-size: clamp(1.1rem, 1rem + 0.4vw, 1.3rem);
  margin: 0.2rem 0 0.45rem;
}

.step p { color: var(--chalk-2); }

.step .step-note {
  margin-top: 0.5rem;
  font-style: italic;
  color: var(--chalk-3);
}

.mystery-sets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(2rem, 5vw, 3.5rem) clamp(2rem, 6vw, 4.5rem);
}

.mystery-set h3 {
  font-size: clamp(1.15rem, 1rem + 0.5vw, 1.35rem);
  margin: 0.55rem 0 0.9rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.mystery-set ol {
  margin: 0;
  padding-left: 2.2rem;
  list-style: upper-roman;
}

.mystery-set li { padding: 0.3rem 0; }

.mystery-set li::marker {
  font-family: var(--caps);
  font-size: 0.8em;
  color: var(--chalk-3);
}

.mysteries-note {
  max-width: var(--measure);
  margin: clamp(2rem, 5vw, 3rem) auto 0;
  text-align: center;
  font-style: italic;
  color: var(--chalk-3);
}

.section-hint {
  margin-top: 0.9rem;
  font-style: italic;
  color: var(--chalk-3);
}

.hint-hover { display: none; }

@media (hover: hover) {
  .hint-hover { display: inline; }
  .hint-touch { display: none; }
}

/* Each mystery is a button that opens its panel (HTML popover, no script). */
.mystery {
  position: relative;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--chalk);
  text-align: left;
  cursor: pointer;
  text-decoration-line: underline;
  text-decoration-color: var(--rule-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: text-decoration-color 0.2s ease;
}

.mystery:hover { text-decoration-color: var(--chalk); }

/* Hover preview of the painting, beside the list, on devices with a pointer. */
.peek { display: none; }

@media (hover: hover) and (min-width: 900px) {
  .peek {
    display: block;
    position: absolute;
    z-index: 5;
    top: 50%;
    left: calc(100% + 0.75rem);
    width: 15rem;
    padding: 0.4rem;
    background: var(--bg);
    border: 1px solid var(--rule-strong);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translate(-6px, -50%);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s 0.2s;
  }

  .mystery-set:nth-child(even) .peek {
    left: auto;
    right: calc(100% + 0.75rem);
    transform: translate(6px, -50%);
  }

  .mystery:hover .peek,
  .mystery:focus-visible .peek {
    opacity: 1;
    visibility: visible;
    transform: translate(0, -50%);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s;
  }

  .peek img {
    display: block;
    width: 100%;
    height: auto;
  }
}

/* The panel: painting, description, Scripture and fruit. */
.mystery-pop {
  width: min(58rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 0;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--bg);
  color: var(--chalk);
  overflow: hidden;
}

.mystery-pop:popover-open {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
}

.mystery-pop::backdrop {
  background: rgba(4, 5, 5, 0.82);
  backdrop-filter: blur(3px);
}

html:has(.mystery-pop:popover-open) { overflow: hidden; }

.pop-art {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 2rem);
  object-fit: contain;
  padding: 1.25rem;
}

.pop-body {
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 3rem clamp(1.5rem, 4vw, 3rem) 2.5rem 1rem;
}

.pop-body h3 {
  font-size: clamp(1.45rem, 1.2rem + 1vw, 2rem);
  margin: 0.6rem 0 1.1rem;
}

.pop-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-family: var(--caps);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--chalk-2);
}

.pop-credit {
  margin-top: 1.1rem;
  font-size: 0.8em;
  color: var(--chalk-3);
}

.pop-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  background: var(--bg);
  color: var(--chalk-2);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.pop-close:hover {
  border-color: var(--chalk);
  color: var(--chalk);
}

.pop-close svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

@media (prefers-reduced-motion: no-preference) {
  .mystery-pop:popover-open { animation: pop-in 0.35s ease-out; }
  .mystery-pop:popover-open::backdrop { animation: fade-in 0.35s ease-out; }
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
}

@keyframes fade-in {
  from { opacity: 0; }
}

@media (max-width: 700px) {
  .mystery-pop:popover-open {
    display: flex;
    flex-direction: column;
  }

  .pop-art {
    flex: none;
    max-height: 42dvh;
    padding: 1rem 1rem 0;
  }

  .pop-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    padding: 0.75rem 1.25rem 1.75rem;
  }
}

.prayer-texts {
  max-width: var(--measure);
  margin: 0 auto;
}

.prayer-text {
  padding: 1.6rem 0.9rem;
  margin: 0 -0.9rem;
  border-radius: 2px;
  scroll-margin-top: 1.5rem;
  transition: background-color 0.4s ease;
}

.prayer-text + .prayer-text { border-top: 1px dashed var(--rule); }

.prayer-text h3 {
  font-size: 0.85rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--chalk-2);
  margin-bottom: 0.7rem;
}

.prayer-text:target { background: rgba(236, 233, 226, 0.05); }
.prayer-text:target h3 { color: var(--chalk); }

.versicle { margin-top: 0.8rem; }
.versicle + .versicle { margin-top: 0.15rem; }

.vr {
  font-family: var(--caps);
  font-size: 0.8em;
  color: var(--chalk-3);
  margin-right: 0.35em;
}

.footer .back {
  font-family: var(--caps);
  font-style: normal;
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--chalk-2);
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--rule-strong);
}

.footer .back:hover {
  color: var(--chalk);
  border-bottom-color: var(--chalk);
}

@media (max-width: 760px) {
  .guide { grid-template-columns: 1fr; }

  .guide-figure {
    width: 100%;
    max-width: 20rem;
    margin: 0 auto;
  }
}

/* ---------- Footer ---------- */

.footer {
  border-top: 1px solid var(--rule);
  padding: 3rem var(--gutter) 4rem;
  text-align: center;
  font-style: italic;
  color: var(--chalk-3);
}

.credit {
  font-size: 0.8em;
  font-style: normal;
  color: var(--chalk-3);
  opacity: 0.8;
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
  .set {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .set-meta {
    flex-direction: row;
    align-items: baseline;
    text-align: left;
    gap: 0.9rem;
  }

  .set-num { font-size: 2.2rem; }

  .shelves,
  .mystery-sets { grid-template-columns: 1fr; }
}
