/* Reading schedule: reading calculator */
.plan { text-align: center; font-variant-numeric: tabular-nums; }
.plan .l-en,
.plan .l-ta { display: block; }
.cmain.plan .l-sep { display: none !important; }
.plan h1 .l-ta { font-size: 0.9em; }
[data-lang-mode="both"] .plan h1 .l-ta { margin-top: 4px; font-size: 0.55em; font-weight: 400; color: var(--muted); }
.plan .clede .l-ta { margin-top: 4px; }

.plan__dial { margin-top: 32px; scroll-margin-top: 12px; }
.plan__label { font-size: 14px; color: var(--muted); }
.plan__count { display: flex; align-items: center; justify-content: center; gap: 20px; margin-top: 4px; }
.plan__count output { min-width: 2ch; font-size: clamp(76px, 22vw, 112px); font-weight: 300; line-height: 1.1; }

.plan__step {
  display: grid;
  place-items: center;
  flex: none;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 1px solid rgba(var(--ink), 0.3);
  border-radius: 50%;
  background: none;
  color: var(--fg);
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s, opacity 0.3s;
}
.plan__step svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.plan__step:disabled { opacity: 0.3; cursor: default; }
@media (hover: hover) {
  .plan__step:not(:disabled):hover { background: var(--fg); color: var(--bg); }
}

.plan__range {
  --fill: 0%;
  display: block;
  width: 100%;
  max-width: 520px;
  height: 44px;
  margin: 12px auto 0;
  background: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.plan__range::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--fg) var(--fill), rgba(var(--ink), 0.2) var(--fill));
}
.plan__range::-moz-range-track { height: 3px; border-radius: 3px; background: rgba(var(--ink), 0.2); }
.plan__range::-moz-range-progress { height: 3px; border-radius: 3px; background: var(--fg); }
.plan__range::-webkit-slider-thumb {
  width: 26px;
  height: 26px;
  margin-top: -11.5px;
  border: 0;
  border-radius: 50%;
  background: var(--fg);
  appearance: none;
  -webkit-appearance: none;
}
.plan__range::-moz-range-thumb { width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--fg); }
.plan__ends { display: flex; justify-content: space-between; max-width: 520px; margin: -4px auto 0; font-size: 13px; color: var(--muted); }

.plan__cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 28px 0 0; }
.plan__card { padding: 18px 10px; border: 1px solid rgba(var(--ink), 0.14); border-radius: 16px; background: var(--card); }
.plan__card dd { margin: 0; font-size: 22px; font-weight: 500; line-height: 1.25; }
.plan__card dt { margin-top: 6px; font-size: 13px; line-height: 1.4; color: var(--muted); }

.cmain > .plan__finish { margin-top: 20px; font-size: 15px; }
.plan__again { min-height: 44px; margin-top: 6px; padding: 0 8px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.plan__again[hidden] { display: none; }

.ptoday { margin-top: 28px; padding: 18px 10px 20px; border: 1px solid rgba(var(--ink), 0.22); border-radius: 20px; }
.ptoday { scroll-margin-top: 12px; }
.ptoday__head { display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; align-items: center; }
.cmain.plan .ptoday h2 { margin-top: 0; }
.ptoday__mark { margin-top: 22px; min-width: 190px; cursor: pointer; font-family: inherit; background: none; color: var(--fg); }
.cmain .ptoday__mark.btn--solid { background: var(--fg); color: var(--bg); }
.ptoday__mark[hidden] { display: none; }
.ptoday__lock { margin-top: 18px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.ptoday__links { display: grid; justify-items: center; gap: 2px; margin-top: 10px; }
.ptoday__links:empty { display: none; }
.ptoday__link { min-height: 40px; padding: 0 8px; border: 0; background: none; color: var(--fg); font: inherit; font-size: 14.5px; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; cursor: pointer; }
.ptoday__day { margin-top: 6px; font-size: 13.5px; line-height: 1.5; color: var(--muted); text-wrap: balance; }
.ptoday__sides { display: grid; gap: 20px; margin-top: 20px; }
.cmain.plan .ptoday h3 { margin-top: 0; font-size: 13px; font-weight: 400; line-height: 1.45; color: var(--muted); }
.ptoday ul { margin: 8px 0 0; padding: 0; list-style: none; }
.ptoday li + li { margin-top: 10px; }
.ptoday a { display: block; font-size: 20px; font-weight: 500; line-height: 1.35; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.ptoday a .l-en { font-size: 0.9em; }
[data-lang-mode="both"] .ptoday a .l-en { margin-top: 2px; font-size: 0.8em; font-weight: 400; }

.plan__note { max-width: 560px; margin-left: auto; margin-right: auto; font-size: 13px; color: var(--muted); }
.cmain > .plan__note { margin-top: 12px; line-height: 1.55; }
.cmain > .plan__answer { max-width: 560px; margin: 24px auto 0; font-size: 15px; line-height: 1.6; }
.plan__answer .l-ta { margin-top: 6px; }

@media (min-width: 640px) {
  .plan__cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ptoday { padding: 28px 24px; }
  .ptoday__sides { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Reading calendar: a page of the book. Stacked pages down the right edge, the
   gutter on the left, and a ribbon marker that lengthens as the year is read.
   A read day is stamped like the black cover with its white foil lettering. */
.pcal {
  --p-serif: "Source Serif 4", Georgia, serif;
  --p-serif-ta: "Noto Serif Tamil", "Noto Sans Tamil", serif;
  --ribbon: 34px;
  --box: 26px;
  position: relative;
  margin: 18px 7px 0 0;
  padding: 22px 10px 22px 14px;
  border: 1px solid rgba(var(--ink), 0.14);
  border-radius: 5px 16px 16px 5px;
  background: var(--card);
  box-shadow:
    inset 16px 0 16px -16px rgba(var(--ink), 0.22),
    3px 0 0 -1px var(--bg), 3px 0 0 0 rgba(var(--ink), 0.14),
    6px 0 0 -1px var(--bg), 6px 0 0 0 rgba(var(--ink), 0.09);
}

.pcal__ribbon {
  position: absolute;
  top: -1px;
  right: 10px;
  width: 15px;
  height: var(--ribbon);
  background: var(--fg);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 7px), 0 100%);
  transition: height 0.7s var(--ease-out);
}

.pcal__head { display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; align-items: center; padding-right: 18px; }
.cmain.plan .pcal h2 { margin: 0; font-family: var(--p-serif); font-size: 25px; font-weight: 400; letter-spacing: -0.01em; line-height: 1.25; }
.cmain.plan .pcal h2 .l-ta { font-family: var(--p-serif-ta); font-size: 0.86em; letter-spacing: 0; }
[data-lang-mode="both"] .cmain.plan .pcal h2 .l-ta { font-size: 0.64em; color: var(--muted); }

.pcal__turn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg);
  cursor: pointer;
}
.pcal__turn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.pcal__turn:disabled { opacity: 0.2; cursor: default; }

.pcal__week,
.pcal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.pcal__week { margin-top: 14px; font-size: 12px; color: var(--muted); }
.pcal__grid { row-gap: 4px; margin-top: 6px; }

.pcal__day {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 5px;
  min-height: 62px;
  border-radius: 12px;
  color: var(--fg);
}
.pcal__turn:focus-visible,
.pcal__num:focus-visible,
.pcal__box:focus-visible { outline: 2px solid var(--fg); outline-offset: 1px; border-radius: 8px; }

.pcal__num {
  position: relative;
  width: 26px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: inherit;
  font-family: var(--p-serif);
  font-size: 15.5px;
  line-height: 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
/* Bigger finger targets than the marks themselves */
.pcal__num::before { content: ""; position: absolute; inset: -8px -8px -2px; }
.pcal__box::before { content: ""; position: absolute; inset: -3px -8px -6px; }
.pcal__num:disabled,
.pcal__box:disabled { cursor: default; }

/* The day shown in the reading card */
.pcal__day.is-selected .pcal__num { background: var(--fg); color: var(--bg); }

.pcal__box {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: var(--box);
  height: var(--box);
  padding: 0;
  border: 1px solid rgba(var(--ink), 0.38);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pcal__box svg { width: 100%; height: 100%; fill: none; stroke: var(--bg); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pcal__box path { stroke-dasharray: 20; stroke-dashoffset: 20; }

/* Days not open yet, and days outside the plan */
.pcal__day.is-locked:not(.is-selected) .pcal__num { color: rgba(var(--ink), 0.5); }
.pcal__day.is-locked .pcal__box { border-color: rgba(var(--ink), 0.13); }
.pcal__day.is-out .pcal__num { color: rgba(var(--ink), 0.2); }
.pcal__day.is-out .pcal__box { visibility: hidden; }

.pcal__day.is-today { background: rgba(var(--ink), 0.06); }
.pcal__day.is-today .pcal__num { font-weight: 600; }
.pcal__day.is-today .pcal__box { border: 1.5px solid var(--fg); }

.pcal__day.is-done .pcal__box { border-color: var(--fg); background: var(--fg); }
.pcal__day.is-done path { stroke-dashoffset: 0; }

/* Days read one after another are joined, like a ribbon through the week */
.pcal__day.is-joined::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc((100% - 20px - 5px - var(--box)) / 2 + var(--box) / 2 - 1px);
  width: 100%;
  height: 2px;
  background: var(--fg);
}

.pcal__day.is-fresh .pcal__box { animation: pcal-stamp 0.42s var(--ease-out); }
.pcal__day.is-fresh path { animation: pcal-draw 0.36s 0.08s var(--ease-out) backwards; }
.pcal__day.is-fresh.is-joined::after { animation: pcal-join 0.4s var(--ease-out); transform-origin: left center; }
@keyframes pcal-stamp { from { transform: scale(0.72); } 55% { transform: scale(1.08); } to { transform: scale(1); } }
@keyframes pcal-draw { from { stroke-dashoffset: 20; } to { stroke-dashoffset: 0; } }
@keyframes pcal-join { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.cmain.plan .pcal__tally { margin-top: 16px; font-family: var(--p-serif); font-size: 16.5px; line-height: 1.5; }
.pcal__tally .l-ta { font-family: var(--p-serif-ta); font-size: 15px; }
.pcal__hint { margin-top: 4px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }

@media (hover: hover) {
  .pcal__box:not(:disabled):hover { border-color: var(--fg); }
}

@media (prefers-reduced-motion: reduce) {
  .pcal__ribbon { transition: none; }
  .pcal__day.is-fresh .pcal__box,
  .pcal__day.is-fresh path,
  .pcal__day.is-fresh.is-joined::after { animation: none; }
}

@media (min-width: 640px) {
  .pcal { --box: 30px; padding: 28px 22px 28px 30px; }
  .pcal__day { min-height: 74px; }
  .pcal__num { width: 30px; font-size: 17px; }
  .cmain.plan .pcal h2 { font-size: 30px; }
  .pcal__ribbon { right: 18px; width: 18px; }
}
