/* The paper calendar: a wall calendar on a black page. The months turn like real sheets, swinging up over the wire
   binding in 3D, and the day you choose gets circled by hand with a red marker. */
:root {
  --page: #000000;          /* the page */
  --paper: #f3eee3;         /* the sheet */
  --paper-back: #e4dccb;    /* the back of a sheet */
  --ink: #1c1a17;           /* the print */
  --red: #cf3a2a;           /* Sundays, and the marker */
  --muted: rgba(28, 26, 23, 0.45);
  --wire: #b9bcc2;
  --depth: 1600px;          /* set by the script: the perspective */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--paper);
  font-family: 'Fraunces Variable', Georgia, serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 48px 20px;
}

.calendar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

/* ---------------------------------------------------------------- the arrows */
.calendar__nav {
  order: 2;
  display: flex;
  gap: 14px;
}

.calendar__arrow {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px rgba(243, 238, 227, 0.35);
  color: var(--paper);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: box-shadow 0.25s ease, background-color 0.25s ease, transform 0.35s cubic-bezier(0.34, 1.6, 0.5, 1);
}

.calendar__arrow svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: hover) and (pointer: fine) {
  .calendar__arrow:hover {
    background: rgba(243, 238, 227, 0.08);
    box-shadow: inset 0 0 0 1.5px rgba(243, 238, 227, 0.8);
    transform: translateY(-2px);
  }
}

.calendar__arrow:active {
  transform: scale(0.94);
}

.calendar__arrow:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------- the pad */
.pad {
  position: relative;
  width: min(430px, calc(100vw - 40px));
  aspect-ratio: 0.82;
  touch-action: none;
}

/* the edges of the sheets below, peeking out at the bottom */
.pad::before,
.pad::after {
  content: '';
  position: absolute;
  left: 2%;
  right: 2%;
  bottom: -5px;
  height: 20px;
  border-radius: 0 0 10px 10px;
  background: #d8cfbd;
}

.pad::after {
  left: 4%;
  right: 4%;
  bottom: -10px;
  background: #b9b09f;
}

.pad__sheets {
  position: absolute;
  inset: 0;
  z-index: 1;
  perspective: var(--depth);
  perspective-origin: 50% 0%;
}

/* a sheet: the paper, a little darker at the edges */
.sheet {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 13% 7.5% 6%;
  border-radius: 6px 6px 12px 12px;
  background:
    radial-gradient(120% 90% at 50% 40%, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 60%),
    var(--paper);
  color: var(--ink);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.9);
  transform-origin: 50% 0;
}

/* the light on a sheet while it turns, and the shadow on the one below */
.sheet__shade {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.15));
  opacity: 0;
  pointer-events: none;
}

.sheet__year {
  font-size: clamp(12px, 3.2vw, 14px);
  font-weight: 600;
  letter-spacing: 0.3em;
  color: var(--muted);
}

.sheet__month {
  margin: 0.1em 0 0.35em;
  font-size: clamp(46px, 13.5vw, 74px);
  font-style: italic;
  font-weight: 420;
  line-height: 0.95;
  letter-spacing: -0.02em;
}

.sheet__week,
.sheet__days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.sheet__week {
  padding-bottom: 0.6em;
  border-bottom: 1px solid rgba(28, 26, 23, 0.14);
  margin-bottom: 0.4em;
  font-size: clamp(11px, 3vw, 13px);
  font-weight: 650;
  letter-spacing: 0.08em;
  text-align: center;
  color: var(--muted);
}

.sheet__days {
  flex: 1;
  grid-template-rows: repeat(6, 1fr);
}

.sheet__week .is-sunday {
  color: var(--red);
}

.date {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: clamp(17px, 5vw, 23px);
  font-weight: 450;
  font-variant-numeric: lining-nums;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color 0.2s ease, transform 0.35s cubic-bezier(0.34, 1.6, 0.5, 1);
}

.date.is-sunday {
  color: var(--red);
}

@media (hover: hover) and (pointer: fine) {
  .date:hover {
    transform: translateY(-2px) rotate(-3deg);
  }
}

.date:focus-visible {
  outline: 2px dashed var(--ink);
  outline-offset: -4px;
}

/* the marker: a hand-drawn ring over the sheet */
.sheet__ink {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  stroke: var(--red);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.sheet__ink path {
  opacity: 0.92;
}

/* the back of a sheet, seen while it swings over the binding */
.flip {
  position: absolute;
  inset: 0;
  z-index: 3;
  transform-origin: 50% 0;
  transform-style: preserve-3d;
  pointer-events: none;
}

.flip .sheet {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flip__back {
  position: absolute;
  inset: 0;
  border-radius: 12px 12px 6px 6px;
  background: var(--paper-back);
  transform: rotateX(180deg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* the wire binding across the top */
.pad__wire {
  position: absolute;
  left: 4%;
  right: 4%;
  top: -14px;
  z-index: 4;
  width: 92%;
  height: 34px;
  overflow: visible;
  pointer-events: none;
}

@media (max-width: 480px) {
  .calendar {
    gap: 24px;
  }
}
