/* Pocket Calendar — cardboard cutout theme */

:root {
  /* gold / orange / forest-green palette */
  --page: #F3F1E6;          /* app background */
  --card: #FFFDF5;          /* calendar face */
  --kraft: #F4A261;         /* die-cut edge (orange) */
  --kraft-dark: #E08F4E;
  --accent: #6B2737;        /* maroon highlight (today pill, rings, active) */
  --accent-dark: #501C29;
  --ink: #344E41;           /* primary text (forest green) */
  --ink-soft: #3F5A4F;      /* day numbers */
  --muted: #8E9E92;         /* weekday labels (sage) */
  --faint: #C7D1C9;         /* out-of-month numbers */
  --line: rgba(52, 78, 65, 0.14);

  --card-radius: 22px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
             "Helvetica Neue", Arial, "Noto Sans", sans-serif,
             "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--page);
  color: var(--ink);
}

body {
  min-height: 100vh;
  display: flex;
}

.container {
  width: 100%;
  max-width: 960px;
  /* top-anchored, not vertically centered: a taller/shorter holiday list
     below must not shift the calendar vertically between months */
  margin: 0 auto;
  padding: 40px 16px 48px;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Calendar frame (cardboard card) --- */

.custom-calendar-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.custom-inner {
  position: relative;
  background: var(--card);
  border-radius: var(--card-radius);
  padding: 22px 20px 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(52, 78, 65, 0.12);
  /* subtle fiber texture */
  background-image:
    radial-gradient(circle at 20% 30%, rgba(52,78,65,0.03) 0, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(244,162,97,0.04) 0, transparent 40%),
    repeating-linear-gradient(115deg, rgba(52,78,65,0.02) 0px, rgba(52,78,65,0.02) 1px, transparent 1px, transparent 3px);
}

/* kraft-brown die-cut edge peeking out beneath the face */
.custom-inner::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--card-radius);
  padding: 2px;
  background: linear-gradient(160deg, var(--kraft), var(--kraft-dark));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  z-index: 0;
  pointer-events: none;
}

/* keep real content above the kraft edge */
.custom-header,
.cal-monthbar,
.fc-calendar-container { position: relative; z-index: 1; }

/* --- Header --- */

.custom-header {
  display: grid;
  /* equal side columns -> titles always centered on the card, even though
     the left group (prev) and right group (Today + next) differ in width */
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 2px 4px 16px;
}
.custom-header-titles {
  grid-column: 2;
  text-align: center;
}
#cal-prev { grid-column: 1; justify-self: start; }
.header-side-right {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 12px;
}
.custom-header .custom-month {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: 0.02em;
}
.custom-header .custom-year {
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
}

/* Header prev/next buttons */
.cal-nav-btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--ink);
  color: var(--card);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(52, 78, 65, 0.35);
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
}
.cal-nav-btn:hover {
  background: var(--kraft);
  color: var(--ink);
  box-shadow: 0 4px 10px rgba(224, 143, 78, 0.45);
}
.cal-nav-btn:active { transform: scale(0.94); }
.cal-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
  background: var(--muted);
}
.cal-nav-btn:disabled:hover { background: var(--muted); color: var(--card); }

/* Today button (pill next to the nav arrows) */
.cal-today-btn {
  flex: 0 0 auto;
  height: 38px;
  padding: 0 14px;
  border: none;
  border-radius: 999px;
  background: var(--ink);
  color: var(--card);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(52, 78, 65, 0.35);
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
}
.cal-today-btn:hover {
  background: var(--kraft);
  color: var(--ink);
  box-shadow: 0 4px 10px rgba(224, 143, 78, 0.45);
}
.cal-today-btn:active { transform: scale(0.94); }
.cal-today-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
  background: var(--muted);
}
.cal-today-btn:disabled:hover { background: var(--muted); color: var(--card); }

/* --- Month bar (below header) --- */
.cal-monthbar {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 2px;
  margin-bottom: 14px;
  /* Inset so the outer month labels (JAN/DEC) center over the calendar's
     outer day columns. The calendar is a gapless 7-col grid, so its first
     column center sits at width/14; the monthbar's first button center sits
     at pad + (width - 2·pad - 22px gaps)/24. Solving: pad = 5/154·w + 1px. */
  padding: 0 calc(100% / 30.8 + 1px);
}
.cal-monthbar button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 2px;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.cal-monthbar button:hover {
  color: var(--ink);
  background: rgba(255, 225, 105, 0.4);
}
.cal-monthbar button.is-active {
  color: var(--accent);
  background: #FFE169;
}
.cal-monthbar button.is-today {
  color: var(--ink);
  font-weight: 900;
}
.cal-monthbar button.is-today.is-active {
  color: var(--accent);
  background: #FFE169;
}

/* --- The calendar grid --- */

.fc-calendar-container { padding: 0; }

.cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  /* weekday header row (auto) + exactly 6 date rows, always */
  grid-template-rows: auto repeat(6, 1fr);
  gap: 0;
}
.cal .cal-weekdays { display: contents; }

.cal .weekday {
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 0 8px;
  text-align: center;
}

.cal .day {
  position: relative;
  padding: 8px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
  cursor: default;
}
.cal .day.has-events {
  cursor: pointer;
}
.cal .day.has-events:hover {
  background: rgba(107, 39, 55, 0.1);
  border-radius: 10px;
}

.cal .day .date {
  position: relative;
  font-size: 14px;
  font-weight: 400;
  color: var(--ink-soft);
  z-index: 1;
}

/* out-of-month overflow days */
.cal .day.is-empty .date {
  color: var(--faint);
  font-weight: 400;
}

/* today = kraft pill behind the number */
.cal .day.is-today::before {
  content: "";
  position: absolute;
  inset: 2px 6px;
  background: var(--accent);
  border-radius: 10px;
  z-index: 0;
  box-shadow: 0 3px 6px rgba(107, 39, 55, 0.45);
}
.cal .day.is-today .date {
  color: var(--card);
  font-weight: 700;
}

/* holidays: maroon outline ring around the date number */
.cal .day.has-events .date {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
}
.cal .day.is-today.has-events .date { border-color: var(--card); }

/* --- Slide-up reveal panel --- */

.cal-reveal {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: rgba(255, 253, 245, 0.97);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--card-radius);
  /* hidden by default: shifted down + invisible after the transition */
  visibility: hidden;
  transform: translateY(100%);
  transition: transform 0.45s ease-in-out, visibility 0s linear 0.45s;
  pointer-events: none;
}
.cal-reveal.is-open {
  visibility: visible;
  transform: translateY(0);
  transition: transform 0.45s ease-in-out, visibility 0s linear 0s;
  pointer-events: auto;
}

.cal-reveal-title {
  margin: 0;
  padding: 18px 56px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--card);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.cal-reveal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--ink);
  color: var(--card);
  font-size: 12px;
  line-height: 24px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(52, 78, 65, 0.35);
}
.cal-reveal-close:hover { background: var(--kraft); color: var(--ink); }

.cal-reveal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 16px 24px;
}
.cal-reveal-body .event {
  display: block;
  padding: 14px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 16px;
}
.cal-reveal-body .event:last-child { border-bottom: none; }
.cal-reveal-body .event .type {
  display: inline-block;
  margin-left: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.cal-reveal-body .empty {
  padding: 40px 8px;
  text-align: center;
  color: var(--muted);
}

/* --- Legend --- */

.legend ul {
  list-style: none;
  margin: 0;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
}
.legend b { color: var(--ink); font-weight: 700; }

.cal-reveal-key {
  flex: 0 0 auto;
  margin-top: auto;
  border-top: 1px solid var(--line);
  background: var(--card);
}

/* --- Holiday cards for the viewed month --- */

.holidays {
  width: 100%;
  max-width: 480px;
  margin: 28px auto 0;
}

.holidays-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.holidays-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.holidays-empty {
  grid-column: 1 / -1;
  padding: 24px 8px;
  text-align: center;
  color: var(--muted);
  background: var(--card);
  border-radius: var(--card-radius);
}

.holiday-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: none;
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 2px 6px rgba(52, 78, 65, 0.12);
  text-align: left;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}

.holiday-date {
  flex: 0 0 auto;
  width: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--card);
  line-height: 1.1;
}
.holiday-date b { font-size: 18px; font-weight: 700; }
.holiday-date small { font-size: 10px; opacity: 0.8; text-transform: uppercase; letter-spacing: 0.05em; }
.holiday-date.is-today { background: var(--kraft-dark); color: var(--ink); }

.holiday-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.holiday-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}
.holiday-name + .holiday-name { padding-top: 4px; border-top: 1px dashed var(--line); }
.holiday-name .type {
  display: inline-block;
  margin-left: 6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  color: var(--accent);
  background: rgba(107, 39, 55, 0.1);
  vertical-align: 2px;
}

/* --- Responsive --- */

@media screen and (max-width: 540px) {
  .cal .day .date { font-size: 13px; }
  .cal-reveal-body .event { font-size: 15px; }
  .cal-nav-btn { width: 34px; height: 34px; font-size: 13px; }
  .cal-monthbar button { font-size: 9px; padding: 5px 1px; }
  .custom-header .custom-month { font-size: 18px; }
}

@media screen and (max-width: 380px) {
  .cal .weekday { font-size: 10px; }
  .cal .day .date { font-size: 12px; }
  .cal-monthbar button { font-size: 8px; }
  .custom-inner { padding: 18px 14px 16px; }
}