:root {
  --paper: #f7f6f1;
  --grid-line: #c9dbea;
  --ink: #16283f;
  --ink-soft: #5c7691;
  --pen-red: #a82f26;
  --pen-red-soft: rgba(168, 47, 38, 0.14);
  --graphite: #8d96a1;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  min-height: 100%;
}

body {
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 27px,
      var(--grid-line) 28px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 27px,
      var(--grid-line) 28px
    ),
    var(--paper);
  background-blend-mode: multiply;
  font-family: "Inter", sans-serif;
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(24px, 6vw, 64px) 16px
    calc(clamp(64px, 12vw, 136px) + env(safe-area-inset-bottom));
  position: relative;
}

/* Subtle paper grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
  opacity: 0.45;
  pointer-events: none;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(
    ellipse at 50% 0%,
    rgba(247, 246, 241, 0) 0%,
    rgba(247, 246, 241, 0.4) 68%,
    rgba(247, 246, 241, 0.78) 100%
  );
  pointer-events: none;
}

.page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 740px;
}

.eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: clamp(1.35rem, 4vw, 2rem);
  letter-spacing: 0.04em;
  color: var(--ink);
  text-align: center;
  margin-bottom: 8px;
}
.eyebrow span {
  color: var(--pen-red);
}
.intro {
  max-width: 560px;
  margin: 0 auto 34px;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.6;
  text-align: center;
}

/* ===== HERO: STAMP ===== */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 30px;
}

.stamp {
  position: relative;
  width: clamp(210px, 46vw, 280px);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-7deg) scale(1);
  opacity: 1;
}

.stamp.animate {
  animation: slam 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
@keyframes slam {
  0% {
    transform: rotate(-22deg) scale(2.4);
    opacity: 0;
  }
  70% {
    transform: rotate(-6deg) scale(0.94);
    opacity: 1;
  }
  100% {
    transform: rotate(-7deg) scale(1);
    opacity: 1;
  }
}

.stamp-ring,
.stamp-ring-2 {
  position: absolute;
  inset: 0;
  border-radius: 44% 56% 47% 53% / 56% 44% 56% 44%;
  border: 4px solid var(--pen-red);
}
.stamp-ring-2 {
  inset: 10px;
  border-width: 2px;
  border-radius: 47% 53% 44% 56% / 44% 56% 47% 53%;
  opacity: 0.7;
}

.stamp-text {
  position: relative;
  text-align: center;
  color: var(--pen-red);
  line-height: 1;
}
.stamp-text .label {
  font-family: "Inter", sans-serif;
  font-weight: 800;
  font-size: clamp(0.7rem, 1.6vw, 0.85rem);
  letter-spacing: 0.32em;
  display: block;
  margin-bottom: 6px;
}
.stamp-text .num {
  font-family: "JetBrains Mono", monospace;
  font-weight: 800;
  font-size: clamp(3.6rem, 12vw, 5rem);
  display: block;
}
.stamp-text .year {
  font-family: "JetBrains Mono", monospace;
  font-weight: 600;
  font-size: clamp(0.85rem, 2vw, 1rem);
  letter-spacing: 0.2em;
  display: block;
  margin-top: 4px;
}

.stamp-of {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.85rem;
  color: var(--graphite);
  margin-top: 16px;
}

.note {
  display: inline-block;
  font-family: "Caveat", cursive;
  font-weight: 600;
  font-size: clamp(1.3rem, 3.4vw, 1.7rem);
  color: var(--ink);
  transform: rotate(-1.5deg);
  margin: 16px 0 2px;
  text-align: center;
}
.date-wrap {
  text-align: center;
}
.note b {
  color: var(--pen-red);
}

.date-note {
  font-family: "Caveat", cursive;
  font-size: 1.1rem;
  color: var(--ink-soft);
  text-align: center;
  margin-bottom: 8px;
}

/* Perforation, like tearing a sheet from a calendar pad */
.perforation {
  position: relative;
  height: 26px;
  margin: 26px 0 32px;
}
.perforation::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 0;
  border-top: 2px dashed var(--grid-line);
}
.perforation .hole {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 0 0 2px var(--grid-line);
}
.perforation .hole:nth-child(1) {
  left: 6%;
}
.perforation .hole:nth-child(2) {
  left: 18%;
}
.perforation .hole:nth-child(3) {
  left: 30%;
}
.perforation .hole:nth-child(4) {
  left: 42%;
}
.perforation .hole:nth-child(5) {
  left: 54%;
}
.perforation .hole:nth-child(6) {
  left: 66%;
}
.perforation .hole:nth-child(7) {
  left: 78%;
}
.perforation .hole:nth-child(8) {
  left: 90%;
}

/* ===== GRID ===== */
.grid-wrap {
  background: rgba(255, 255, 255, 0.62);
  border: 1.5px solid var(--grid-line);
  border-radius: 16px;
  padding: clamp(16px, 3.2vw, 28px);
  box-shadow:
    0 24px 50px -20px rgba(22, 40, 63, 0.22),
    0 2px 10px rgba(22, 40, 63, 0.06);
}

.weeks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 8px 8px;
  row-gap: 22px;
}

.week {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  border: 1.5px solid var(--grid-line);
  color: var(--ink-soft);
  background: transparent;
  transition: transform 0.15s ease;
}

.week .month-tag {
  position: absolute;
  top: -19px;
  left: 0;
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--pen-red);
  text-transform: uppercase;
  white-space: nowrap;
}
.week.month-start {
  border-left: 2.5px solid var(--pen-red);
}

.week.past {
  background: rgba(141, 150, 161, 0.24);
  border-color: transparent;
  color: var(--ink-soft);
}
.week.past.month-start {
  border-left: 2.5px solid var(--pen-red);
}
.week.past::after {
  content: "✓";
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: 0.56rem;
  color: var(--graphite);
}

.week.future {
  color: rgba(92, 118, 145, 0.55);
}

.week.current {
  color: var(--ink);
  font-weight: 800;
  font-size: 0.8rem;
  border-color: transparent;
  background: var(--pen-red-soft);
}
.week.current svg {
  position: absolute;
  inset: -24%;
  width: 148%;
  height: 148%;
  overflow: visible;
  pointer-events: none;
}
.week.current svg path {
  fill: none;
  stroke: var(--pen-red);
  stroke-width: 3.2;
  stroke-linecap: round;
  transform-origin: center;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.82;
  }
}
@media (prefers-reduced-motion: reduce) {
  .week.current svg path {
    animation: none;
  }
  .stamp.animate {
    animation: none;
  }
}

.week:hover {
  transform: translateY(-1px);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 22px;
  margin-top: 30px;
  font-family: "Inter", sans-serif;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--grid-line);
  flex-shrink: 0;
}
.swatch.past {
  background: rgba(141, 150, 161, 0.35);
  border-color: transparent;
}
.swatch.current {
  border-color: var(--pen-red);
  border-width: 2px;
  background: var(--pen-red-soft);
}
.swatch.future {
  background: transparent;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 34px;
  padding: 22px 0;
  border-top: 1.5px dashed var(--grid-line);
  border-bottom: 1.5px dashed var(--grid-line);
  font-family: "JetBrains Mono", monospace;
}
.stat {
  text-align: center;
  min-width: 0;
  padding: 0 clamp(8px, 2vw, 18px);
}
.stat + .stat {
  border-left: 1px solid var(--grid-line);
}
.stat .n {
  font-size: clamp(1.3rem, 3vw, 1.6rem);
  font-weight: 800;
  color: var(--ink);
  display: block;
}
.stat .l {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: block;
  margin-top: 3px;
}
.stat.accent .n {
  color: var(--pen-red);
}

@media (max-width: 420px) {
  .stats-row {
    padding: 18px 0;
  }
  .stat {
    padding: 0 6px;
  }
  .stat .l {
    font-size: 0.58rem;
    letter-spacing: 0.06em;
    line-height: 1.35;
  }
  .weeks-grid {
    grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
    gap: 6px;
    row-gap: 20px;
  }
  .week {
    font-size: 0.6rem;
  }
  .week .month-tag {
    font-size: 0.56rem;
    top: -17px;
  }
}

/* ===== BUY ME A COFFEE ===== */
.bmc-btn {
  position: fixed;
  right: clamp(14px, 3vw, 24px);
  bottom: clamp(14px, 3vw, 24px);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 18px;
  background: #ffdd00;
  color: #16283f;
  border: 2px solid #16283f;
  border-radius: 999px;
  font-family: "Inter", sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 10px 24px -8px rgba(22, 40, 63, 0.35);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}
.bmc-btn:hover,
.bmc-btn:focus-visible {
  transform: translateY(-2px) rotate(-1deg);
  box-shadow: 0 14px 28px -8px rgba(22, 40, 63, 0.42);
}
.bmc-btn:focus-visible {
  outline: 3px solid var(--pen-red);
  outline-offset: 3px;
}
.bmc-btn .cup {
  font-size: 1.1rem;
  line-height: 1;
}

@media (max-width: 420px) {
  .bmc-btn {
    padding: 10px 14px;
    font-size: 0.78rem;
  }
}

/* ===== FLOATING CAT GIF ===== */
.cat-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 8;
  cursor: pointer;
  will-change: transform;
}
.cat-flip {
  transition: transform 0.15s linear;
}
.cat-wrapper.flip .cat-flip {
  transform: scaleX(-1);
}

.cat-body-wrap {
  position: relative;
  display: inline-block;
}

.cat-img {
  display: block;
  width: clamp(70px, 11vw, 110px);
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 8px 12px rgba(22, 40, 63, 0.28));
  animation: cat-bob 2.4s ease-in-out infinite;
}
@keyframes cat-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.cat-body-wrap.bounce .cat-img {
  animation:
    cat-bob 2.4s ease-in-out infinite,
    cat-bounce 0.35s ease;
}
@keyframes cat-bounce {
  0% {
    transform: scale(1, 1);
  }
  30% {
    transform: scale(1.14, 0.84);
  }
  60% {
    transform: scale(0.9, 1.12);
  }
  100% {
    transform: scale(1, 1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cat-img {
    animation: none !important;
  }
}

.cat-bubble {
  position: absolute;
  top: -6px;
  left: 50%;
  background: #fff;
  color: var(--pen-red);
  font-family: "Caveat", cursive;
  font-weight: 700;
  font-size: 1.3rem;
  padding: 3px 12px;
  border-radius: 12px;
  border: 1.5px solid var(--pen-red);
  opacity: 0;
  transform: translate(-50%, 0) scale(0.9);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
  pointer-events: none;
  white-space: nowrap;
}
.cat-bubble.show {
  opacity: 1;
  transform: translate(-50%, -10px) scale(1);
}
