@font-face {
  font-family: "Digitalt";
  src:
    url("fonts/Digitalt-nGZM.otf") format("opentype"),
    url("fonts/Digitalt-04no.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --background: #111;
  --text: #f4f2ee;
  --muted: #bdb9b2;
  --line: rgba(244, 242, 238, 0.14);
  --nav: rgba(244, 242, 238, 0.22);
  --nav-hover: rgba(244, 242, 238, 0.62);
  --surface: #161616;
  --surface-strong: #111;
  --surface-soft: #1c1c1c;
  --control: #202020;
  --focus: rgba(244, 242, 238, 0.34);
  --backdrop: rgba(0, 0, 0, 0.68);
  --today: #e33b3b;
}

:root[data-theme="light"] {
  color-scheme: light;
  --background: #f4f2ee;
  --text: #151515;
  --muted: #6e6a63;
  --line: rgba(21, 21, 21, 0.12);
  --nav: rgba(21, 21, 21, 0.18);
  --nav-hover: rgba(21, 21, 21, 0.58);
  --surface: #ffffff;
  --surface-strong: #ece9e2;
  --surface-soft: #f0ede7;
  --control: #e7e2da;
  --focus: rgba(21, 21, 21, 0.22);
  --backdrop: rgba(244, 242, 238, 0.72);
  --today: #d32f2f;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  height: 100vh;
  min-height: 100vh;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: "Digitalt", Arial, Helvetica, sans-serif;
  overflow-x: hidden;
}

.calendar-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(0, 3fr) minmax(0, 1fr);
  height: 100vh;
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 0 18px;
}

.month-header {
  align-items: end;
  align-self: stretch;
  display: grid;
  gap: 14px;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  margin: 0;
}

.month-nav {
  align-items: center;
  appearance: none;
  aspect-ratio: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--nav);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: clamp(22px, 4vw, 36px);
  justify-content: center;
  line-height: 1;
  margin-bottom: clamp(12px, 3vh, 28px);
  opacity: 0.55;
  padding: 0;
  transition:
    color 160ms ease,
    opacity 160ms ease;
}

.month-nav:hover,
.month-nav:focus-visible {
  color: var(--nav-hover);
  opacity: 1;
  outline: none;
}

.month-title {
  color: var(--text);
  font-size: clamp(72px, 15vh, 148px);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 0.9;
  margin: 0;
  min-width: 0;
  text-align: center;
}

.calendar {
  align-items: center;
  display: flex;
  justify-content: center;
  margin: 0 auto;
  min-height: 0;
  width: min(100%, 860px);
}

.month-title,
.days,
.year {
  will-change: opacity, transform;
}

.slide-out-left {
  animation: slide-out-left 150ms ease-in both;
}

.slide-out-right {
  animation: slide-out-right 150ms ease-in both;
}

.slide-in-left {
  animation: slide-in-left 220ms ease-out both;
}

.slide-in-right {
  animation: slide-in-right 220ms ease-out both;
}

.days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  width: min(100%, 84vh);
}

.day {
  aspect-ratio: 1;
  align-items: center;
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: clamp(28px, 5.8vh, 58px);
  justify-content: center;
  padding: 0;
  position: relative;
}

.day:hover,
.day:focus-visible {
  color: var(--muted);
  outline: none;
}

.day.today {
  color: var(--today);
}

.day.empty {
  cursor: default;
  pointer-events: none;
}

.day.has-reminders::after {
  background: var(--text);
  border-radius: 50%;
  content: "";
  height: clamp(5px, 1vw, 8px);
  position: absolute;
  right: 22%;
  top: 22%;
  width: clamp(5px, 1vw, 8px);
}

.year {
  align-items: flex-start;
  color: var(--muted);
  display: flex;
  font-size: clamp(18px, 4vh, 42px);
  justify-content: center;
  line-height: 1;
  margin: 0;
  text-align: center;
}

.theme-toggle {
  align-items: center;
  appearance: none;
  aspect-ratio: 1;
  background: var(--control);
  border: 0;
  border-radius: 50%;
  bottom: 18px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 18px;
  justify-content: center;
  left: 18px;
  line-height: 1;
  opacity: 0.72;
  padding: 0;
  position: fixed;
  transition:
    color 160ms ease,
    opacity 160ms ease,
    transform 160ms ease;
  width: 38px;
  z-index: 4;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  color: var(--text);
  opacity: 1;
  outline: none;
  transform: scale(1.04);
}

.theme-toggle:focus-visible {
  box-shadow: 0 0 0 1px var(--focus);
}

.theme-icon::before {
  content: "☾";
}

:root[data-theme="light"] .theme-icon::before {
  content: "☀";
}

.reminder-modal {
  background: var(--surface);
  border: 0;
  border-radius: 8px;
  color: var(--text);
  padding: 0;
  transform-origin: center;
  width: min(calc(100% - 32px), 440px);
}

.reminder-modal[open] {
  animation: modal-grow-in 260ms cubic-bezier(0.2, 1.35, 0.45, 1) both;
}

.reminder-modal.is-closing {
  animation: modal-grow-out 180ms ease-in both;
}

.reminder-modal::backdrop {
  background: var(--backdrop);
}

.reminder-modal.is-closing::backdrop {
  background: rgba(0, 0, 0, 0);
}

.reminder-form {
  margin: 0;
  padding: 22px;
}

.modal-header {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.modal-title {
  font-size: clamp(26px, 6vw, 44px);
  font-weight: 400;
  line-height: 1;
  margin: 0;
}

.modal-close,
.reminder-remove,
.reminder-submit {
  appearance: none;
  background: var(--control);
  border: 0;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.modal-close {
  align-items: center;
  aspect-ratio: 1;
  display: flex;
  font-size: 26px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 36px;
}

.reminder-list {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.reminder-empty {
  color: var(--muted);
  font-size: 15px;
  margin: 0;
}

.reminder-item {
  align-items: start;
  background: var(--surface-soft);
  border-radius: 6px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 30px;
  padding: 10px;
}

.reminder-text {
  font-size: 18px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.reminder-remove {
  aspect-ratio: 1;
  color: var(--today);
  font-size: 18px;
  line-height: 1;
  padding: 0;
}

.reminder-label {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
}

.reminder-add {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.reminder-input {
  background: var(--surface-strong);
  border: 0;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 18px;
  min-width: 0;
  padding: 10px 12px;
}

.reminder-input:focus,
.modal-close:focus-visible,
.reminder-remove:focus-visible,
.reminder-submit:focus-visible {
  box-shadow: 0 0 0 1px var(--focus);
  outline: none;
}

.reminder-submit {
  padding: 10px 14px;
}

@keyframes modal-grow-in {
  0% {
    opacity: 0;
    transform: scale(0.86) translateY(10px);
  }

  65% {
    opacity: 1;
    transform: scale(1.035) translateY(0);
  }

  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modal-grow-out {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }

  to {
    opacity: 0;
    transform: scale(0.94) translateY(8px);
  }
}

@keyframes slide-out-left {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(-18px);
  }
}

@keyframes slide-out-right {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(18px);
  }
}

@keyframes slide-in-left {
  from {
    opacity: 0;
    transform: translateX(-18px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slide-in-right {
  from {
    opacity: 0;
    transform: translateX(18px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 700px) {
  html {
    height: auto;
  }

  body {
    height: auto;
    min-height: 100svh;
  }

  .calendar-shell {
    grid-template-rows: auto auto auto;
    height: auto;
    min-height: 100svh;
    padding: 22px 12px;
  }

  .theme-toggle {
    bottom: 12px;
    left: 12px;
    width: 34px;
  }

  .month-header {
    align-self: auto;
    gap: 4px;
    grid-template-columns: 28px minmax(0, 1fr) 28px;
    margin-bottom: 28px;
  }

  .month-nav {
    font-size: 25px;
    margin-bottom: 12px;
  }

  .month-title {
    font-size: clamp(58px, 19vw, 88px);
    line-height: 0.86;
  }

  .calendar {
    max-width: 100%;
  }

  .days {
    width: 100%;
  }

  .day {
    font-size: clamp(24px, 8.5vw, 36px);
  }

  .year {
    margin-top: 18px;
    align-items: center;
    font-size: clamp(12px, 2vw, 18px);
  }

  .reminder-modal {
    margin: 18px auto auto;
    max-height: calc(100svh - 36px);
    overflow: auto;
    width: min(calc(100% - 24px), 440px);
  }

  .reminder-form {
    padding: 18px;
  }

  .reminder-add {
    grid-template-columns: 1fr;
  }
}
