@font-face {
  font-family: "Titan One";
  src: url("./titan-one.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  color: #fff9f1;
  background: #101b3b;
  --display-font: "Titan One", "Arial Black", system-ui, sans-serif;
  --gold: #ffe29c;
}

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100svh;
  margin: 0;
  background: url("./background.webp") center center / cover fixed no-repeat;
}

.calendar {
  width: min(100% - 2rem, 58rem);
  margin-inline: auto;
  padding-block: clamp(1.75rem, 6vh, 4.5rem) 2.5rem;
}

.calendar-heading {
  padding-inline-end: clamp(2.5rem, 12vw, 10rem);
  margin-block-end: 2.85rem;
  text-shadow: 0 2px 5px #050b20;
}

h1, h2 {
  margin: 0;
  font-family: var(--display-font);
  font-weight: 400;
}

h1 {
  font-size: clamp(1.95rem, 5.25vw, 3.7rem);
  line-height: 1.06;
}

.calendar-heading p {
  margin: 0.65rem 0 0;
  line-height: 1.45;
  font-size: clamp(0.92rem, 2.5vw, 1.08rem);
}

.board {
  position: relative;
  padding: clamp(0.65rem, 2.5vw, 1.4rem);
  border: 1px solid #af2d33;
  border-radius: 1.25rem;
  background: #c73336;
  box-shadow: 0 12px 40px #050b2070;
}

.santa, .snow {
  position: absolute;
  height: auto;
  pointer-events: none;
}

.santa {
  z-index: 2;
  width: clamp(4.5rem, 20%, 11.25rem);
  right: 0.55rem;
  top: 0;
  transform: translateY(-82%) rotate(8deg);
}

.snow {
  z-index: 3;
  width: 102%;
  max-height: 3rem;
  left: -1%;
  top: 0;
  transform: translateY(-65%);
}

.doors {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(0.35rem, 1.5vw, 1rem);
  list-style: none;
  padding: 0;
  margin: 0;
}

.door {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 0.48rem;
  background: #6651a4;
  color: inherit;
  cursor: pointer;
  perspective: 850px;
  box-shadow: inset 0 1px 8px #2c1748a6;
}

.door:disabled {
  cursor: wait;
}

.door-front, .door-inside {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: inherit;
}

.door-front {
  background: #c64046;
  box-shadow: inset 0 1px #ffffff45, 0 2px 3px #7e202b44;
  font: 400 clamp(1.5rem, 4.5vw, 2.5rem)/1 var(--display-font);
  text-shadow: 0 2px #801c26;
  transform-origin: left center;
  backface-visibility: hidden;
  transition: transform 210ms ease;
}

.door[data-state="open"] .door-front {
  background: #cf4148;
  box-shadow: inset 0 0 0 2px var(--gold);
}

.door[data-solved="true"] .door-front {
  background: #91bec2;
  color: #102d36;
  text-shadow: none;
}

.door[data-day="24"] .door-front {
  background: #f4d065;
  color: #62252a;
  text-shadow: none;
}

.door-inside img {
  width: 54%;
  height: 54%;
  object-fit: contain;
}

@media (hover: hover) {
  .door[data-state="open"]:hover .door-front {
    transform: rotateY(-96deg);
  }
}

button:focus-visible, input:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.calendar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1.25rem;
  margin-block: 1rem;
}

.calendar-actions p {
  margin: 0;
  line-height: 1.5;
  text-shadow: 0 2px 5px #050b20;
}

.action {
  min-height: 2.75rem;
  border: 1px solid var(--gold);
  border-radius: 0.6rem;
  padding: 0.55rem 0.9rem;
  color: #40231f;
  background: var(--gold);
  font: 700 1rem/1.3 system-ui, sans-serif;
  cursor: pointer;
}

.action:hover {
  background: #fff1bf;
}

.action:disabled {
  cursor: wait;
  opacity: 0.7;
}

.letters {
  margin-block-start: 1.25rem;
  padding: 1rem;
  border: 1px solid #7b88a9;
  border-radius: 0.8rem;
  background: #101b3be8;
}

.letters h2 {
  font-size: 1.2rem;
}

.letter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.7rem 0 0;
  padding: 0;
  list-style: none;
}

.letter-list li {
  display: grid;
  min-width: 3.6rem;
  gap: 0.1rem;
  justify-items: center;
  padding: 0.35rem;
  border: 1px solid #8c7854;
  border-radius: 0.45rem;
  background: #273250;
}

.letter-list small {
  color: #fff0ce;
}

.letter-list strong {
  color: var(--gold);
  font-size: 1.2rem;
}

.door-dialog {
  width: min(32rem, 100% - 1.5rem);
  max-height: calc(100dvh - 1.5rem);
  padding: 0;
  border: 0;
  overflow-y: auto;
  color: #fff9f1;
  background: transparent;
}

.door-dialog::backdrop {
  background: #05091ec7;
}

.popup-header {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
  margin-block-end: -6%;
  pointer-events: none;
}

.close {
  position: absolute;
  z-index: 2;
  inset: 2rem 0.6rem auto auto;
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  padding: 0 0 0.2rem;
  border: 1px solid #ffffff70;
  border-radius: 50%;
  background: #7b1926;
  color: #fff;
  font: 1.65rem/1 system-ui, sans-serif;
  cursor: pointer;
}

.dialog-body {
  position: relative;
  padding: 2rem clamp(1rem, 5vw, 2rem) 1.5rem;
  border: 1px solid #80262d;
  border-radius: 1rem;
  background: #a82b32;
}

.dialog-heading {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  padding-inline-end: 3rem;
}

.dialog-heading img {
  width: 3rem;
  height: 3rem;
  object-fit: contain;
}

.dialog-heading h2 {
  font-size: clamp(1.35rem, 5vw, 1.85rem);
}

.question {
  margin: 0.5rem 0 1.25rem;
  font-size: 1.12rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.phrase-letters {
  margin-block: 0 1rem;
  color: #fff0ce;
  line-height: 1.55;
}

#answer-form label {
  display: block;
  margin-block-end: 0.4rem;
  font-weight: 650;
}

.answer-row {
  display: flex;
  gap: 0.55rem;
}

.answer-row input {
  flex: 1;
  min-width: 0;
  min-height: 2.75rem;
  border: 1px solid #fff0dc;
  border-radius: 0.6rem;
  padding: 0.5rem 0.75rem;
  color: #321818;
  background: #fff9f1;
  font: inherit;
}

.feedback {
  margin: 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.feedback:not(:empty) {
  margin-block-start: 0.9rem;
  border-radius: 0.5rem;
  padding: 0.65rem 0.8rem;
  background: #771d29;
}

.feedback[data-tone="success"] {
  color: #193525;
  background: #e5f1dd;
  font-weight: 700;
}

.finale {
  margin-block-start: 1rem;
  border-block-start: 1px solid #ffffff70;
  padding-block-start: 0.8rem;
}

.finale h3, .finale p {
  margin: 0;
  line-height: 1.5;
}

.finale p {
  margin-block-start: 0.35rem;
  white-space: pre-line;
}

@media (max-width: 640px) {
  body {
    background-attachment: scroll;
  }

  .doors {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 380px) {
  .answer-row {
    flex-direction: column;
  }
}

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