@font-face {
  font-family: "Black Han Sans";
  src: url("fonts/black-han-sans.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Gowun Batang";
  src: url("fonts/gowun-batang.woff2") format("woff2");
  font-display: swap;
}

:root {
  --wall: #2f8c75;
  --board: #0f3f34;
  --board-ink: #f3f1e6;
  --paper: #fbfaf4;
  --paper-edge: #d9d7ca;
  --ink: #1b1a17;
  --muted: #5e5c55;
  --sun: #d3121b;
  --sat: #1546b0;
  --gold: #e5b62b;
  --gold-ink: #8a6200;
  --gold-soft: #fbf0cd;
  --display: "Black Han Sans", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --text: "Gowun Batang", "AppleMyungjo", "Batang", serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --wall: #0e2f28;
    --board: #07211b;
    --board-ink: #d8d6cb;
    --paper: #e4e1d6;
    --paper-edge: #b3b0a4;
    --muted: #55534b;
    --sun: #b30f17;
    --sat: #123e9c;
    --gold: #d4a51f;
    --gold-ink: #6f4e00;
    --gold-soft: #eedfae;
  }
}

* {
  box-sizing: border-box;
}

/* 계절마다 벽 색이 바뀐다. */
:root[data-season="spring"] {
  --wall: #d96f8e;
  --board: #6b1f3d;
}

:root[data-season="summer"] {
  --wall: #1f9cb0;
  --board: #0b4552;
}

:root[data-season="fall"] {
  --wall: #c4622a;
  --board: #5a2a10;
}

:root[data-season="winter"] {
  --wall: #4a6a94;
  --board: #1c2d47;
}

@media (prefers-color-scheme: dark) {
  :root[data-season="spring"] {
    --wall: #5e2339;
    --board: #2c0d1a;
  }

  :root[data-season="summer"] {
    --wall: #0c3f4a;
    --board: #052329;
  }

  :root[data-season="fall"] {
    --wall: #4f2410;
    --board: #2a1206;
  }

  :root[data-season="winter"] {
    --wall: #172840;
    --board: #0b1523;
  }
}

/* 봄에는 꽃잎, 여름에는 물방울, 가을에는 낙엽, 겨울에는 눈 */
.season-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.season-layer span {
  position: absolute;
  top: var(--top);
  width: var(--size);
  height: var(--size);
  opacity: 0.75;
}

[data-season="spring"] .season-layer span {
  border-radius: 70% 0;
  background: #ffd3de;
}

[data-season="summer"] .season-layer span {
  border: 1.5px solid rgb(255 255 255 / 0.7);
  border-radius: 50%;
}

[data-season="fall"] .season-layer span {
  border-radius: 0 70%;
  background: #e8862a;
}

[data-season="fall"] .season-layer span:nth-child(3n) {
  background: #d9481c;
}

[data-season="fall"] .season-layer span:nth-child(3n + 1) {
  background: #f0b429;
}

[data-season="winter"] .season-layer span {
  border-radius: 50%;
  background: #fff;
}

/* 움직일 때만 종이 앞으로 보낸다. 멈춰 있으면 글자를 계속 가리기 때문이다. */
@media (prefers-reduced-motion: no-preference) {
  .season-layer {
    z-index: 2;
  }

  .season-layer span {
    top: -24px;
    animation: season-fall var(--duration) linear var(--delay) infinite;
  }

  [data-season="summer"] .season-layer span {
    top: calc(100vh + 24px);
    animation-name: season-rise;
  }
}

@keyframes season-fall {
  to {
    transform: translate(var(--drift), calc(100vh + 48px)) rotate(var(--turn));
  }
}

@keyframes season-rise {
  to {
    transform: translate(var(--drift), calc(-100vh - 48px));
  }
}

.symbols {
  position: absolute;
  width: 0;
  height: 0;
}

body {
  margin: 0;
  background: var(--wall);
  color: var(--ink);
  font-family: var(--text);
  font-synthesis: none;
  line-height: 1.6;
  word-break: keep-all;
  -webkit-text-size-adjust: 100%;
}

[data-tone="sun"] {
  --tone: var(--sun);
}

[data-tone="sat"] {
  --tone: var(--sat);
}

[data-tone="grand"] {
  --tone: var(--gold-ink);
}

.wall {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 440px);
  justify-content: center;
  align-items: start;
  gap: 72px;
  min-height: 100svh;
  padding:
    calc(env(safe-area-inset-top) + 24px)
    calc(env(safe-area-inset-right) + 16px)
    calc(env(safe-area-inset-bottom) + 32px)
    calc(env(safe-area-inset-left) + 16px);
  overflow: hidden;
  overflow: clip;
}

/* 일력 */

.calendar {
  rotate: -0.5deg;
}

.board {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: 34px 18px 14px;
  background: var(--board);
  color: var(--board-ink);
}

/* 벽에 박힌 못과 일력에 뚫린 구멍 */
.board::before,
.board::after {
  content: "";
  position: absolute;
  left: 50%;
  border-radius: 50%;
  translate: -50% 0;
}

.board::before {
  top: 9px;
  width: 16px;
  height: 16px;
  background: var(--wall);
  box-shadow: inset 0 2px 2px rgb(0 0 0 / 0.5);
}

.board::after {
  top: 12px;
  width: 8px;
  height: 8px;
  background: #c9c6b8;
  box-shadow: 0 1px 1px rgb(0 0 0 / 0.6);
}

.brand {
  margin: 0;
  font: 400 1.875rem/1 var(--display);
}

.owners {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.35;
  text-align: right;
}

.pad {
  position: relative;
}

/* 앞서 찢어 낸 장들이 남긴 자국 */
.stub {
  position: absolute;
  inset: 0 0 auto;
  z-index: 3;
  filter: drop-shadow(0 1px 0 rgb(0 0 0 / 0.28));
}

.stub::before {
  content: "";
  display: block;
  height: 11px;
  background: var(--paper);
  clip-path: polygon(
    0 0, 100% 0, 100% 62%, 96% 88%, 91% 58%, 86% 79%, 80% 49%, 75% 83%, 69% 60%, 63% 92%,
    57% 55%, 52% 76%, 46% 48%, 40% 84%, 35% 62%, 29% 95%, 23% 56%, 18% 74%, 12% 50%, 7% 86%, 3% 60%, 0 80%
  );
}

.sheets {
  position: relative;
}

.sheet {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  aspect-ratio: 4 / 5;
  padding: 24px 20px 18px;
  background: var(--paper);
  box-shadow:
    0 3px 0 -1px var(--paper-edge),
    0 6px 0 -2px var(--paper),
    0 9px 0 -3px var(--paper-edge),
    0 22px 26px -14px rgb(0 0 0 / 0.5);
}

.sheet-date {
  margin: 0;
  color: var(--tone, var(--ink));
  font-size: 1.0625rem;
}

.sheet-count {
  position: relative;
  margin: auto 0;
  color: var(--tone, var(--ink));
  font-weight: 400;
}

.sheet-number {
  display: block;
  font-family: var(--display);
  font-size: min(99cqi / var(--em-width), 60cqi);
  line-height: 1;
  white-space: nowrap;
}

.sheet-unit {
  display: block;
  margin-top: 0.15em;
  font-family: var(--display);
  font-size: clamp(1.5rem, 9.5cqi, 2.25rem);
  line-height: 1.2;
}

.sheet-foot {
  position: relative;
  padding-top: 12px;
  border-top: 1px solid var(--paper-edge);
}

/* 여우와 달팽이는 일력 아래쪽 선 위에 나란히 앉아 있다. */
.pals {
  position: absolute;
  right: 0;
  bottom: 100%;
  display: flex;
  align-items: flex-end;
  gap: 1cqi;
}

.pal-fox {
  width: 23cqi;
  height: 23cqi;
}

.pal-snail {
  width: 24cqi;
  height: 18cqi;
}

.pal-button {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.pal-button:focus-visible {
  outline: 2px solid var(--sat);
  outline-offset: 2px;
}

.pal-art {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 50% 100%;
}

/* 생일에 쓰는 꼬깔콘 */
.pal-hat {
  position: absolute;
  width: 34%;
  height: 46%;
  rotate: 10deg;
  pointer-events: none;
}

.pal-fox .pal-hat {
  top: -24%;
  left: 39%;
}

.pal-snail .pal-hat {
  top: 2%;
  left: 9%;
  width: 22%;
  height: 40%;
}

.bubble {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 4;
  width: max-content;
  max-width: 11rem;
  padding: 6px 10px;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font: 400 0.8125rem/1.35 var(--text);
  text-align: left;
}

.bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 22px;
  width: 9px;
  height: 9px;
  border-right: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
  background: var(--paper);
  translate: 0 -4px;
  rotate: 45deg;
}

.pal-snail .bubble,
.crawl-snail .bubble,
.bubble--left {
  right: 0;
  left: auto;
}

.pal-snail .bubble::after,
.crawl-snail .bubble::after,
.bubble--left::after {
  right: 22px;
  left: auto;
}

.crawl-snail .bubble--right {
  right: auto;
  left: 0;
}

.crawl-snail .bubble--right::after {
  right: auto;
  left: 22px;
}

/* 1,000일 단위 당일에는 숫자를 금박처럼 찍는다. */
[data-tone="grand"] .sheet-number {
  background: linear-gradient(180deg, #e8b31a 0%, #bd8608 55%, #8a6200 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* 1,000일 단위 당일에 숫자 옆에서 반짝이는 별 */
.sheet-sparkle {
  position: absolute;
  pointer-events: none;
}

.sheet-sparkle--one {
  top: -9cqi;
  right: 2cqi;
  width: 9cqi;
  height: 9cqi;
}

.sheet-sparkle--two {
  top: -4cqi;
  right: 13cqi;
  width: 5cqi;
  height: 5cqi;
}

.sheet-line {
  margin: 0;
  font-size: 1.0625rem;
  line-height: 1.5;
}

.sheet-since {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.sheet--leaving {
  position: absolute;
  inset: 0;
  z-index: 2;
  aspect-ratio: auto;
  box-shadow: 0 14px 28px rgb(0 0 0 / 0.3);
  transform-origin: 8% 0;
  animation: tear-off 0.9s cubic-bezier(0.5, 0, 0.85, 0.6) 0.45s both;
}

@keyframes tear-off {
  0% {
    transform: none;
  }
  22% {
    transform: translateY(3px) rotate(-2.5deg);
  }
  85% {
    opacity: 1;
  }
  100% {
    transform: translate(-26%, 190%) rotate(-24deg);
    opacity: 0;
  }
}

/* 달력과 기념일 장부 */

/* 휴대폰에서는 한 줄로 이어지고, PC에서는 두 칸으로 나뉜다. */
.front,
.side {
  display: contents;
}

.icon-notice {
  order: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: -44px;
  padding: 12px 14px;
  background: var(--paper);
  box-shadow: 0 16px 22px -14px rgb(0 0 0 / 0.45);
}

.icon-notice[hidden] {
  display: none;
}

.icon-notice p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
}

.icon-notice-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.icon-notice .icon-notice-open {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  background: var(--board);
  color: var(--board-ink);
  text-decoration: none;
}

.calendar {
  order: 1;
}

.month-perch {
  order: 2;
}

.ledger-perch {
  order: 3;
}

.records-card {
  order: 4;
  margin-top: -28px;
}

.perch {
  position: relative;
}

.paper {
  position: relative;
  padding: 20px 18px 6px;
  background: var(--paper);
  box-shadow: 0 16px 22px -14px rgb(0 0 0 / 0.45);
}

/* 달력 뒤에서 내다보는 여우 */
.perch-fox {
  position: absolute;
  bottom: calc(100% - 34px);
  left: 14px;
  width: 92px;
  height: 92px;
}

/* 장부 위를 기어가는 달팽이 */
.crawl {
  container-type: inline-size;
  position: absolute;
  inset: auto 10px 100%;
}

.crawl-snail {
  display: block;
  width: 72px;
  height: 54px;
  transform: translateX(calc(100cqi - 100%));
}

/* 성운과 가윤의 기록 */

.card {
  padding-bottom: 18px;
}

.records {
  margin: 0;
}

.record {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--paper-edge);
}

.record dt {
  font-size: 0.875rem;
  line-height: 1.35;
}

.record dd {
  margin: 0;
  font: 400 1.125rem/1.2 var(--display);
  white-space: nowrap;
}

.records-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

/* 기념일 당일의 꽃가루 */
.confetti {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  pointer-events: none;
}

.confetti span {
  position: absolute;
  top: -16px;
  width: 9px;
  height: 14px;
  background: #f08a2c;
  animation: confetti-fall 2.8s linear both;
}

.confetti span:nth-child(3n) {
  background: #c391d8;
}

.confetti span:nth-child(3n + 1) {
  background: #d3121b;
}

.confetti--grand span {
  background: #e5b62b;
}

.confetti--grand span:nth-child(3n) {
  background: #fff1b8;
}

.confetti--grand span:nth-child(3n + 1) {
  background: #b8860b;
}

@keyframes confetti-fall {
  to {
    transform: translate(var(--drift), 110vh) rotate(540deg);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .crawl-snail {
    animation: crawl 180s linear 2s forwards;
  }
}

@keyframes crawl {
  to {
    transform: none;
  }
}

.month-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 3px double var(--ink);
}

.month-head h2 {
  flex: 1;
  margin: 0;
  font: 400 1.375rem/1.2 var(--display);
}

.month-button {
  min-width: 44px;
  height: 44px;
  padding: 0 8px;
  border: 1px solid var(--paper-edge);
  border-radius: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.month-button[hidden] {
  display: none;
}

.month-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.month-button:focus-visible {
  outline: 2px solid var(--sat);
  outline-offset: 2px;
}

#month-previous,
#month-next {
  font-size: 1.5rem;
  line-height: 1;
}

.month {
  width: 100%;
  margin-bottom: 8px;
  border-collapse: collapse;
  table-layout: fixed;
}

.month th {
  padding: 8px 0 4px;
  color: var(--tone, var(--muted));
  font-size: 0.8125rem;
  font-weight: 400;
}

.month td {
  height: 56px;
  padding: 4px 0;
  text-align: center;
  vertical-align: top;
}

.date-button {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: inherit;
  font: inherit;
  overflow: visible;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.date-button:focus-visible {
  outline: 2px solid var(--sat);
  outline-offset: 1px;
}

.date-button[aria-pressed="true"] {
  box-shadow: inset 0 0 0 1.5px var(--muted);
}

.day-detail-box {
  min-height: 3.6em;
  margin-bottom: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--paper-edge);
}

.day-detail {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.day-detail-names {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.date-number {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--tone, var(--ink));
  font-size: 0.9375rem;
  line-height: 28px;
}

.date-label {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.6875rem;
  line-height: 1.15;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

/* 재미로 챙기는 날은 기념일보다 조용하게 회색으로 찍는다. */
.is-minor .date-number {
  background: var(--paper-edge);
}

.is-today .date-number {
  box-shadow: inset 0 0 0 2px var(--ink);
}

/* 일력의 빨간 날처럼 기념일은 빨갛게 찍는다. */
.is-event .date-number {
  background: var(--sun);
  color: var(--paper);
}

.is-event .date-label {
  color: var(--sun);
}

.is-today.is-event .date-number {
  box-shadow: 0 0 0 2px var(--ink);
}

.is-before .date-number {
  opacity: 0.4;
}

/* 생일 날짜에 씌우는 꼬깔콘 */
.date-hat {
  position: absolute;
  bottom: 20px;
  left: 7px;
  width: 19px;
  height: 24px;
  rotate: 12deg;
}

/* 1,000일 단위는 금색 동그라미와 별로 가장 돋보이게 한다. */
.is-grand .date-number {
  background: var(--gold);
  box-shadow:
    0 0 0 2px var(--paper),
    0 0 0 3.5px var(--gold);
  color: var(--ink);
}

.is-grand .date-label {
  color: var(--gold-ink);
  font-family: var(--display);
}

.date-sparkle {
  position: absolute;
}

.date-sparkle--one {
  top: -9px;
  right: -9px;
  width: 13px;
  height: 13px;
}

.date-sparkle--two {
  bottom: -3px;
  left: -8px;
  width: 9px;
  height: 9px;
}

.ledger-title {
  margin: 0;
  padding-bottom: 10px;
  border-bottom: 3px double var(--ink);
  font: 400 1.375rem/1.2 var(--display);
}

.progress {
  margin-top: 12px;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.progress-track {
  height: 10px;
  margin-top: 4px;
  background: var(--paper-edge);
}

.progress-fill {
  height: 100%;
  background: var(--board);
}

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

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--paper-edge);
}

.row-name {
  font: 400 1.125rem/1.35 var(--display);
}

.row-date {
  grid-row: 2;
  color: var(--tone, var(--muted));
  font-size: 0.875rem;
  line-height: 1.4;
}

.row-left {
  grid-column: 2;
  grid-row: 1 / 3;
  font: 400 1.25rem/1 var(--display);
  white-space: nowrap;
}

#upcoming .row:first-child .row-name {
  font: 400 1.75rem/1.2 var(--display);
}

#upcoming .row:first-child .row-left {
  font-size: 2.25rem;
}

.row-hat {
  width: 15px;
  height: 19px;
  margin-left: 5px;
  rotate: 12deg;
  vertical-align: -2px;
}

/* 1,000일 단위는 목록에서도 금색 띠로 표시한다. */
.row--grand {
  margin: 0 -10px;
  padding-right: 10px;
  padding-left: 10px;
  background: var(--gold-soft);
}

.row--grand .row-left {
  color: var(--gold-ink);
}

.row-sparkle {
  width: 13px;
  height: 13px;
  margin: 0 5px;
  vertical-align: 0;
}

.row--grand .row-sparkle:first-child {
  margin-left: 0;
}

.day-add {
  margin-bottom: 14px;
}

.day-add[hidden] {
  display: none;
}

.calendar-link {
  display: block;
  padding: 14px 8px;
  background: var(--board);
  color: var(--board-ink);
  font: 400 1rem/1.2 var(--display);
  text-align: center;
  text-decoration: none;
}

.calendar-link:focus-visible {
  outline: 2px solid var(--sat);
  outline-offset: 2px;
}

.calendar-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.4;
  text-align: center;
}

.minor-title {
  margin: 22px 0 2px;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 400;
}

#minor .row {
  grid-template-columns: 1fr auto 3.5rem;
  padding: 6px 0;
  color: var(--muted);
}

#minor .row-name,
#minor .row-left {
  grid-column: auto;
  grid-row: auto;
  font: 400 0.875rem/1.4 var(--text);
}

#minor .row-left {
  text-align: right;
}

#minor .row-date {
  grid-row: auto;
  font-size: 0.8125rem;
}

.past summary {
  padding: 14px 0;
  color: var(--muted);
  cursor: pointer;
}

.past summary:focus-visible {
  outline: 2px solid var(--sat);
  outline-offset: 2px;
}

.past .row:last-child {
  border-bottom: 0;
}

@media (min-width: 860px) {
  .wall {
    grid-template-columns: 440px 420px;
    gap: 64px;
    padding-top: 64px;
    padding-bottom: 64px;
  }

  .front,
  .side {
    display: grid;
    gap: 56px;
    min-width: 0;
    align-content: start;
  }

  .side {
    margin-top: 44px;
  }

  .records-card {
    margin-top: 0;
  }
}
