@font-face {
  font-family: "Archivo";
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url(./assets/fonts/Archivo.ttf) format("truetype");
}

:root {
  color-scheme: light;
  --red: #c8261c;
  --red-deep: #9e1a12;
  --red-ink: #d3261c;
  --gold: #f2c86e;
  --paper: #fbfaf6;
  --wall: #eeebe5;
  --ink: #151313;
  --ink-soft: #5a544e;
  --rule: rgba(21, 19, 19, 0.16);
  --num: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --song: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", serif;
  --text: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --gutter: clamp(20px, 5.5vw, 88px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html.motion { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--red);
  color: var(--paper);
  font-family: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, p, dl, dd, figure { margin: 0; }
img { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--paper); outline-offset: 4px; }
.year :focus-visible { outline-color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---- the board with the calendar */
.board {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr);
  align-items: center;
  gap: clamp(32px, 6vw, 110px);
  min-height: 100svh;
  padding: clamp(48px, 9svh, 96px) var(--gutter);
}
.calendar { width: min(100%, 400px); justify-self: center; }
.cal-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px 16px;
  background: var(--red-deep);
  border-bottom: 6px solid #6f110b;
  color: var(--gold);
}
.cal-year { font-family: var(--num); font-weight: 800; font-size: 1.7rem; line-height: 1; letter-spacing: 0.02em; }
.cal-gz { font-family: var(--song); font-weight: 700; font-size: 1.1rem; letter-spacing: 0.2em; }
.cal-name { font-family: var(--num); font-weight: 600; font-size: 0.8rem; letter-spacing: 0.18em; text-transform: uppercase; }
.pad { position: relative; display: grid; isolation: isolate; }
.pad > .sheet { grid-area: 1 / 1; }
.stack { position: absolute; inset: 0; z-index: -1; }
.stack span {
  position: absolute;
  inset: 0;
  background: var(--paper);
  transform: translateY(calc((var(--i) + 1) * 3px));
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.14);
  z-index: calc(-1 - var(--i));
}
.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  aspect-ratio: 3 / 4;
  padding: 20px 24px 18px;
  background: var(--paper);
  color: var(--ink);
  transform-origin: 50% 0;
}
.sheet::before,
.leaf::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: -4px;
  height: 8px;
  background: radial-gradient(circle, var(--hole, var(--red-deep)) 2.2px, transparent 2.7px) 2px 0 / 12px 8px repeat-x;
}
.sheet-top { display: flex; justify-content: space-between; font-family: var(--song); font-weight: 700; font-size: 0.95rem; }
.sheet-year { font-family: var(--num); font-weight: 700; letter-spacing: 0.08em; }
.sheet-day {
  flex: 1;
  display: grid;
  place-items: center;
  font-family: var(--num);
  font-stretch: 62%;
  font-weight: 800;
  font-size: clamp(8.5rem, 21vw, 14rem);
  line-height: 0.8;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.sheet--red .sheet-day { color: var(--red-ink); }
.sheet-week { text-align: center; font-family: var(--song); font-weight: 700; font-size: 1rem; letter-spacing: 0.12em; }
.sheet-yiji {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}
.sheet-yiji div, .leaf-yi { display: flex; align-items: center; gap: 8px; font-family: var(--song); font-weight: 700; font-size: 0.95rem; line-height: 1.3; }
.sheet-yiji dt, .leaf-yi b {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.7em; height: 1.7em;
  background: var(--red-ink);
  color: var(--paper);
  font-weight: 700;
}
.sheet-yiji div + div dt { background: var(--ink); }
.sheet-foot { margin-top: 12px; text-align: center; font-size: 0.78rem; color: var(--ink-soft); }

.side { min-width: 0; }
.kicker { font-family: var(--song); font-weight: 700; font-size: clamp(1.1rem, 1.8vw, 1.5rem); letter-spacing: 0.16em; }
.count { display: flex; align-items: baseline; gap: 0.12em; margin-top: 4px; }
.count-days {
  font-family: var(--num);
  font-stretch: 62%;
  font-weight: 800;
  font-size: clamp(9rem, 26vw, 22rem);
  line-height: 0.8;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.count-unit { font-family: var(--song); font-weight: 700; font-size: clamp(2rem, 4vw, 3.4rem); }
.count-clock {
  margin-top: clamp(10px, 2svh, 22px);
  font-family: var(--num);
  font-stretch: 75%;
  font-weight: 600;
  font-size: clamp(2rem, 4.4vw, 3.6rem);
  line-height: 1;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.side-note { margin-top: 22px; font-size: 0.95rem; color: rgba(251, 250, 246, 0.86); }
.twenty { margin-top: 6px; }
.twenty-num {
  display: block;
  font-family: var(--num);
  font-stretch: 62%;
  font-weight: 900;
  font-size: clamp(13rem, 34vw, 30rem);
  line-height: 0.78;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.twenty-cn { display: block; margin-top: 18px; font-family: var(--song); font-weight: 700; font-size: clamp(1.7rem, 3.2vw, 2.8rem); letter-spacing: 0.06em; }
.cue,
.closing-links a {
  display: inline-block;
  margin-top: 28px;
  text-decoration: none;
  background: linear-gradient(currentColor, currentColor) left bottom / 100% 1px no-repeat;
  padding-bottom: 3px;
  transition: background-size 0.45s var(--ease-out);
}
.cue:hover, .closing-links a:hover { background-size: 0 1px; }

/* ---- the year in torn pages */
.year { background: var(--wall); color: var(--ink); padding: clamp(80px, 14svh, 150px) var(--gutter); --hole: var(--wall); }
.year-head { max-width: 1320px; }
.year-title { font-family: var(--song); font-weight: 900; font-size: clamp(2.6rem, 6.4vw, 5.6rem); line-height: 1.1; letter-spacing: 0.02em; }
.year-meta { display: flex; flex-wrap: wrap; gap: 4px 24px; margin-top: 18px; font-family: var(--num); font-weight: 600; font-size: 0.9rem; letter-spacing: 0.06em; color: var(--ink-soft); }
.month { max-width: 1320px; margin-top: clamp(64px, 11svh, 120px); }
.month-title {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding-top: 14px;
  border-top: 2px solid var(--ink);
  font-family: var(--song);
  font-weight: 900;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.2;
}
.month-title small { font-family: var(--num); font-weight: 600; font-size: 0.9rem; letter-spacing: 0.06em; color: var(--ink-soft); }
.leaves {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 34px 24px;
  align-items: start;
  margin-top: 30px;
  perspective: 1400px;
}
.leaf {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 18px;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
  rotate: calc(var(--r) * 0.6deg);
  box-shadow: 0 14px 24px -16px rgba(0, 0, 0, 0.4);
  transform-origin: 50% 0;
  transition: translate 0.4s var(--ease-out), rotate 0.4s var(--ease-out);
}
.leaf-top { display: flex; justify-content: space-between; gap: 8px; font-family: var(--song); font-weight: 700; font-size: 0.82rem; }
.leaf-day {
  margin: 10px 0 12px;
  text-align: center;
  font-family: var(--num);
  font-stretch: 62%;
  font-weight: 800;
  font-size: 6.4rem;
  line-height: 0.82;
  letter-spacing: -0.02em;
}
.leaf--red .leaf-day { color: var(--red-ink); }
.leaf-yi { padding-top: 10px; border-top: 1px solid var(--rule); flex-wrap: wrap; }
.leaf-yi small { font-family: var(--text); font-weight: 400; font-size: 0.78rem; color: var(--ink-soft); }
.leaf-text { margin-top: 10px; font-size: 0.86rem; line-height: 1.75; color: var(--ink-soft); }
.leaf-photo { display: block; margin-top: 12px; background: #ddd8d0; }
.leaf-photo img { width: 100%; height: auto; }
.leaf-more { margin-top: 12px; font-size: 0.8rem; color: var(--ink-soft); transition: color 0.2s ease; }
@media (hover: hover) and (pointer: fine) {
  .leaf:hover { translate: 0 -6px; rotate: 0deg; }
  .leaf:hover .leaf-more { color: var(--red-ink); }
}
.month--quiet .quiet { margin-top: 24px; max-width: 34ch; font-family: var(--song); font-weight: 700; font-size: clamp(1.3rem, 2.4vw, 1.9rem); line-height: 1.6; color: var(--ink-soft); }

/* ---- twenty candles */
.candles { padding: clamp(90px, 16svh, 170px) var(--gutter) clamp(60px, 10svh, 110px); text-align: center; }
.candles-title { font-family: var(--song); font-weight: 900; font-size: clamp(2.4rem, 5.6vw, 4.6rem); letter-spacing: 0.06em; }
.cake {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(7px, 1.4vw, 16px);
  height: 190px;
  margin: clamp(40px, 7svh, 70px) auto 0;
  padding-bottom: 14px;
  max-width: 760px;
  border-bottom: 2px solid rgba(251, 250, 246, 0.7);
}
.candle {
  position: relative;
  width: clamp(8px, 1vw, 12px);
  height: calc(104px + var(--h) * 10px);
  background: repeating-linear-gradient(-35deg, var(--paper) 0 7px, #f4c3b9 7px 12px);
}
.candle::before { content: ""; position: absolute; left: 50%; top: -9px; width: 1.5px; height: 9px; margin-left: -0.75px; background: #2a1a14; }
.flame {
  position: absolute;
  left: 50%; bottom: calc(100% + 7px);
  width: 13px; height: 24px;
  margin-left: -6.5px;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse at 50% 72%, #fffbe6 0 22%, #ffd767 45%, #ff9a2e 78%, rgba(255, 154, 46, 0) 100%);
  transform-origin: 50% 90%;
  transition: opacity 0.25s ease calc(var(--i) * 45ms), scale 0.3s ease calc(var(--i) * 45ms);
}
.smoke {
  position: absolute;
  left: 50%; bottom: calc(100% + 8px);
  width: 4px; height: 34px;
  margin-left: -2px;
  border-radius: 4px;
  background: rgba(251, 250, 246, 0.5);
  filter: blur(3px);
  opacity: 0;
  pointer-events: none;
}
.cake.is-out .flame { opacity: 0; scale: 0.2; }
.wish {
  position: relative;
  margin-top: 40px;
  padding: 15px 32px;
  border: 2px solid var(--paper);
  background: transparent;
  font-family: var(--song);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.wish-fill {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--paper);
  color: var(--red);
  clip-path: inset(0 100% 0 0);
  transition: clip-path 0.2s ease-out;
}
.wish.is-holding .wish-fill { clip-path: inset(0 0 0 0); transition: clip-path 1.6s linear; }
.wish:active { scale: 0.98; }
.wished { margin-top: 28px; font-family: var(--song); font-weight: 900; font-size: clamp(1.8rem, 4vw, 3rem); letter-spacing: 0.06em; }

/* ---- closing */
.closing { padding: clamp(40px, 8svh, 90px) var(--gutter) 60px; text-align: center; }
.closing-line { width: min(100%, 900px); height: auto; margin: 0 auto; filter: brightness(0) invert(1); }
.closing-motto { margin-top: 34px; font-family: var(--num); font-stretch: 90%; font-weight: 600; font-size: clamp(1.2rem, 2.6vw, 2.1rem); line-height: 1.35; }
.closing-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 28px; margin-top: 16px; font-size: 0.9rem; }

/* ---- motion */
@keyframes drop { from { opacity: 0; transform: translateY(-36px) rotate(-3deg); } to { opacity: 1; transform: none; } }
@keyframes settle { from { opacity: 0; translate: 0 14px; } to { opacity: 1; translate: 0 0; } }
@keyframes tear {
  0% { transform: none; }
  14% { transform: translateY(5px) rotate(-1.2deg); }
  32% { transform: translate(-14px, -20px) rotate(-7deg); }
  100% { transform: translate(-60vw, -46vh) rotate(-52deg); opacity: 0; }
}
@keyframes flicker {
  0%, 100% { transform: rotate(-3deg) scaleY(1); }
  30% { transform: rotate(2deg) scaleY(1.08); }
  55% { transform: rotate(-1deg) scaleY(0.94); }
  80% { transform: rotate(3deg) scaleY(1.04); }
}
@keyframes smoke-rise { 0% { opacity: 0; transform: translateY(0) scaleY(0.6); } 25% { opacity: 0.8; } 100% { opacity: 0; transform: translateY(-46px) translateX(6px) scaleY(1.4); } }

html.motion .calendar { animation: drop 1s var(--ease-out) 0.1s both; }
html.motion .side:not([hidden]) > * { animation: settle 0.9s var(--ease-out) both; }
html.motion .side:not([hidden]) > :nth-child(2) { animation-delay: 0.12s; }
html.motion .side:not([hidden]) > :nth-child(n+3) { animation-delay: 0.24s; }
html.motion .sheet.is-torn { animation: tear 1.25s cubic-bezier(0.5, 0, 0.75, 0.3) both; z-index: 2; }
html.motion .sheet.is-flipping { animation: drop 0.6s var(--ease-out) both; }
html.motion .leaf { opacity: 0; transform: rotateX(-82deg); transition: opacity 0.6s ease calc(var(--i) * 80ms), transform 1s var(--ease-out) calc(var(--i) * 80ms), translate 0.4s var(--ease-out), rotate 0.4s var(--ease-out); }
html.motion .leaf.is-in { opacity: 1; transform: none; }
html.motion .cake.is-live:not(.is-out) .flame { animation: flicker calc(1.1s + var(--f) * 0.17s) ease-in-out calc(var(--i) * -0.13s) infinite; }
html.motion .cake.is-out .smoke { animation: smoke-rise 1.6s ease-out calc(var(--i) * 45ms + 0.15s) both; }
html.motion .closing-line { opacity: 0; transition: opacity 1.4s ease, filter 1.4s ease; filter: brightness(0) invert(1) blur(6px); }
html.motion .closing-line.is-in { opacity: 1; filter: brightness(0) invert(1); }

@media (max-width: 860px) {
  .board { grid-template-columns: minmax(0, 1fr); gap: 34px; padding-top: 40px; min-height: auto; }
  .calendar { width: min(86vw, 360px); }
  .side { text-align: left; }
  .count-days { font-size: clamp(8rem, 40vw, 12rem); }
  .twenty-num { font-size: clamp(11rem, 56vw, 18rem); }
  .leaves { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 26px 14px; }
  .leaf { padding: 12px 12px 14px; }
  .leaf-day { font-size: 4.6rem; }
  .leaf-text { display: none; }
  .candle { width: 7px; height: calc(84px + var(--h) * 8px); }
  .cake { gap: 6px; height: 160px; }
}
