/* Calendar widget. One size unit, --c (about one day cell), follows the embed box (vw/vh of the
   frame), so the calendar fills a wide block or a narrow column alike. Today is a filled circle in
   the accent color (Notion red by default), as on a phone. */
:root {
  --accent-c: var(--accent, var(--accent-default));
  --on-accent: #ffffff;
  --paper-default: #ffffff;
  --line-default: rgba(55, 53, 47, 0.12);
}
@media (prefers-color-scheme: dark) {
  :root:not(.t-light) {
    --paper-default: #252525;
    --line-default: rgba(255, 255, 255, 0.1);
  }
}
:root.t-dark {
  --paper-default: #252525;
  --line-default: rgba(255, 255, 255, 0.1);
}

.cal {
  color: inherit;
}
.cal p {
  margin: 0;
}
/* A card behind the calendar when a card color is set (always for the desk page). */
.has-card .cal:not(.desk) {
  padding: calc(var(--c) * 0.45) calc(var(--c) * 0.5);
  border-radius: calc(var(--c) * 0.36);
  background: var(--tile, var(--tile-default));
  color: var(--num, inherit);
}

/* Month name, year and the arrows */
.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(var(--c) * 0.2);
  min-width: 0;
  margin-bottom: calc(var(--c) * 0.18);
}
.title {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3em;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: calc(var(--c) * 0.5);
  font-weight: 750;
  letter-spacing: -0.015em;
  line-height: 1.15;
  white-space: nowrap;
}
button.title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  cursor: pointer;
}
.yr {
  font-weight: 500;
  opacity: 0.5;
}
.navs {
  display: inline-flex;
  flex: none;
  gap: calc(var(--c) * 0.08);
  transition: opacity 0.15s ease;
}
.nav {
  position: relative;
  width: calc(var(--c) * 0.62);
  height: calc(var(--c) * 0.62);
  min-width: 22px;
  min-height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  opacity: 0.55;
  cursor: pointer;
}
.nav::before {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 30%;
  height: 30%;
  border-top: 2px solid currentColor;
  border-left: 2px solid currentColor;
  transform: translateX(15%) rotate(-45deg);
}
.nav.next::before {
  transform: translateX(-15%) rotate(135deg);
}
.nav:hover,
.nav:focus-visible {
  background: var(--line-default);
  opacity: 0.9;
}
.nav:focus-visible,
button.title:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 1px;
}
/* Arrows show on hover with a mouse; on touch screens they stay, a little faded. */
@media (hover: hover) {
  .navs {
    opacity: 0;
  }
  .w:hover .navs,
  .navs:focus-within {
    opacity: 1;
  }
}

/* The month grid */
.grid {
  display: grid;
  grid-template-columns: repeat(7, var(--c));
  grid-auto-rows: calc(var(--c) * 0.88);
  align-items: center;
  justify-items: center;
}
.wd {
  font-size: calc(var(--c) * 0.3);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.45;
}
.grid .wd {
  align-self: end;
  padding-bottom: calc(var(--c) * 0.12);
}
.d {
  display: grid;
  place-items: center;
  width: calc(var(--c) * 0.8);
  height: calc(var(--c) * 0.8);
  border-radius: 50%;
  font-size: calc(var(--c) * 0.38);
  font-weight: 550;
}
.today {
  background: var(--accent-c);
  color: var(--on-accent);
  font-weight: 750;
}

/* Month: about 7 cells wide and 8 tall (heading, letters, up to 6 weeks) */
.s-month {
  --c: min(calc((100vw - 8vmin) / 7.3), calc((100vh - 8vmin) / 7.6));
}
.s-month.has-card {
  --c: min(calc((100vw - 8vmin) / 8.3), calc((100vh - 8vmin) / 8.5));
}

/* Phone: today's weekday and big date on the left, the month on the right */
.s-phone {
  --c: min(calc((100vw - 8vmin) / 11.4), calc((100vh - 8vmin) / 7.6));
}
.s-phone.has-card {
  --c: min(calc((100vw - 8vmin) / 12.4), calc((100vh - 8vmin) / 8.5));
}
.phone {
  display: grid;
  grid-template-columns: auto auto;
  align-items: start;
  gap: calc(var(--c) * 0.9);
}
.side {
  display: grid;
  align-content: start;
  min-width: calc(var(--c) * 3);
  padding-top: calc(var(--c) * 0.05);
}
.phone .wday {
  color: var(--accent-c);
  font-size: calc(var(--c) * 0.42);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.phone .big {
  font-size: calc(var(--c) * 2.5);
  font-weight: 400;
  letter-spacing: -0.04em;
  line-height: 1;
}
.phone .d {
  font-weight: 450;
}
.phone .today {
  font-weight: 650;
}
.phone .title {
  color: var(--accent-c);
  font-size: calc(var(--c) * 0.42);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.phone .yr {
  color: inherit;
}

/* Week: one row of seven days under the month */
.s-week {
  --c: min(calc((100vw - 8vmin) / 7.3), calc((100vh - 8vmin) / 2.5));
}
.s-week.has-card {
  --c: min(calc((100vw - 8vmin) / 8.3), calc((100vh - 8vmin) / 3.3));
}
.week .title {
  display: block;
  margin-bottom: calc(var(--c) * 0.16);
  padding-left: calc(var(--c) * 0.1);
  font-size: calc(var(--c) * 0.34);
}
.row {
  display: grid;
  grid-template-columns: repeat(7, var(--c));
}
.day {
  display: grid;
  justify-items: center;
  gap: calc(var(--c) * 0.1);
}
.day .n {
  display: grid;
  place-items: center;
  width: calc(var(--c) * 0.82);
  height: calc(var(--c) * 0.82);
  border-radius: 50%;
  font-size: calc(var(--c) * 0.4);
  font-weight: 600;
}
.day.today {
  background: none;
  color: inherit;
}
.day.today .n {
  background: var(--accent-c);
  color: var(--on-accent);
  font-weight: 750;
}
.day.today .wd {
  color: var(--accent-c);
  opacity: 1;
}

/* Desk: a tear-off calendar page, the month in a colored band on top */
.s-desk {
  --h: min(calc(100vh - 8vmin), calc((100vw - 8vmin) * 1.12));
}
.desk .page {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  width: calc(var(--h) * 0.86);
  height: var(--h);
  overflow: hidden;
  border-radius: calc(var(--h) * 0.06);
  background: var(--tile, var(--paper-default));
  color: var(--num, inherit);
  box-shadow:
    0 0 0 1px var(--line-default),
    0 calc(var(--h) * 0.02) calc(var(--h) * 0.05) rgba(15, 15, 15, 0.08);
}
.band {
  justify-self: stretch;
  padding: calc(var(--h) * 0.085) calc(var(--h) * 0.04) calc(var(--h) * 0.05);
  background: var(--accent-c);
  color: var(--on-accent);
  font-size: calc(var(--h) * 0.095);
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}
/* Two binder holes on the band */
.desk .page::before,
.desk .page::after {
  content: '';
  position: absolute;
  top: calc(var(--h) * 0.026);
  width: calc(var(--h) * 0.03);
  height: calc(var(--h) * 0.03);
  border-radius: 50%;
  background: var(--bg, var(--paper-default));
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.2);
}
.desk .page::before {
  left: 28%;
}
.desk .page::after {
  right: 28%;
}
.desk .big {
  align-self: center;
  font-size: calc(var(--h) * 0.46);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}
.desk .wday {
  padding-bottom: calc(var(--h) * 0.07);
  font-size: calc(var(--h) * 0.085);
  font-weight: 650;
  opacity: 0.7;
}
.f-serif .desk .big,
.f-serif .phone .big {
  font-weight: 500;
}

@media (prefers-reduced-motion: reduce) {
  .navs {
    transition: none;
  }
}
