/* =========================================================
   The living room calendar (js/room-board.js): one big window, three distances:
   year (pick a month), month (labels and photos on the days), day (picture, doodle, notes).
   ========================================================= */
.calendar-card {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-sizing: border-box;
  width: min(1180px, 96vw);
  height: min(860px, calc(100dvh - 24px));
  padding: 20px 22px 16px;
  overflow: hidden;
  border: 1px solid rgba(224, 200, 255, .3);
  border-radius: 26px;
  background: radial-gradient(circle at 16% 0, rgba(166, 92, 214, .28), transparent 50%), #1b1230;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .55);
  color: #f6efff;
}
.calendar-card .modal-close { top: 18px; right: 18px; }

.cal-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-right: 50px; }
.cal-bar h2 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 6px;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .04em;
}
.cal-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(214, 180, 255, .3);
  border-radius: 999px;
  background: rgba(150, 92, 220, .14);
  color: #f0e4ff;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: transform var(--dur-s) var(--ease-out), background-color var(--dur-s) var(--ease-out), opacity var(--dur-s) var(--ease-out);
}
.cal-btn.is-zoom { padding: 0; width: 38px; font-size: 21px; line-height: 1; }
.cal-btn:disabled { opacity: .35; cursor: default; }
@media (hover: hover) {
  .cal-btn:not(:disabled):hover { transform: scale(1.06); background: rgba(150, 92, 220, .3); }
}
.cal-btn:not(:disabled):active { transform: scale(.94); }
.cal-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.cal-hint { margin: 0; color: rgba(232, 218, 255, .55); font-size: 12px; text-align: center; }

.cal-hint.is-error { color: #ffc2d6; }

.cal-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: pan-y;
}
.cal-view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  will-change: transform, opacity;
}
.cal-view.is-settling { transition: transform 220ms var(--ease-out); }
.cal-view.is-closer { animation: calCloser 320ms var(--ease-out) both; }
.cal-view.is-further { animation: calFurther 320ms var(--ease-out) both; }
.cal-view.is-sideways { animation: top-fade-in 240ms var(--ease-out) both; }
.cal-view.is-leaving { pointer-events: none; }
.cal-view.leave-closer { animation: calLeaveCloser 320ms var(--ease-out) both; }
.cal-view.leave-further { animation: calLeaveFurther 320ms var(--ease-out) both; }
.cal-view.leave-sideways { animation: top-fade-out 200ms var(--ease-out) both; }
@keyframes calCloser { from { opacity: 0; transform: scale(.55); } }
@keyframes calFurther { from { opacity: 0; transform: scale(1.5); } }
@keyframes calLeaveCloser { to { opacity: 0; transform: scale(1.7); } }
@keyframes calLeaveFurther { to { opacity: 0; transform: scale(.6); } }

/* far: twelve months */
.cal-year-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(110px, 1fr);
  gap: 10px;
  min-height: 100%;
}
.cal-month-tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid rgba(214, 180, 255, .2);
  border-radius: 16px;
  background: rgba(255, 255, 255, .05);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform var(--dur-s) var(--ease-out), background-color var(--dur-s) var(--ease-out), border-color var(--dur-s) var(--ease-out);
}
.cal-month-tile b { font-family: "Noto Serif SC", "Songti SC", serif; font-size: 22px; font-weight: 600; }
.cal-month-tile small { color: #f1c6f2; font-size: 12px; line-height: 1.5; }
.cal-month-tile.is-now { border-color: rgba(233, 170, 255, .8); background: rgba(166, 82, 224, .22); }
@media (hover: hover) {
  .cal-month-tile:hover { transform: translateY(-2px); background: rgba(170, 110, 235, .22); }
}
.cal-month-tile:active { transform: scale(.97); }
.cal-month-tile:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* middle: the month, big squares */
.cal-view-month { display: flex; flex-direction: column; }
.cal-week { display: grid; flex: none; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; padding-bottom: 6px; color: rgba(232, 218, 255, .6); font-size: 13px; text-align: center; }
.cal-week span:first-child { color: #e79ee9; }
.cal-month-grid {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(84px, 1fr));
  gap: 6px;
}
.cal-day {
  position: relative;
  display: block;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(214, 180, 255, .12);
  border-radius: 12px;
  background: rgba(255, 255, 255, .05);
  color: #f6efff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform var(--dur-s) var(--ease-out), background-color var(--dur-s) var(--ease-out), border-color var(--dur-s) var(--ease-out);
}
.cal-day.is-blank { border: 0; background: none; cursor: default; }
.cal-day.is-today { border-color: rgba(233, 170, 255, .9); box-shadow: inset 0 0 0 1px rgba(233, 170, 255, .6); }
@media (hover: hover) {
  .cal-day:not(.is-blank):hover { transform: translateY(-2px); background: rgba(170, 110, 235, .22); }
}
.cal-day:not(.is-blank):active { transform: scale(.97); }
.cal-day:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.cal-day-no {
  position: absolute;
  left: 7px;
  top: 5px;
  z-index: 2;
  font-size: 15px;
  font-weight: 700;
}
.cal-day.is-sunday .cal-day-no { color: #eeb0ef; }
.cal-day.has-doodle:not(.has-picture) { background: #fbf7ff; }
.cal-day.has-doodle:not(.has-picture) .cal-day-no { color: #3b2a55; }
.cal-day.has-picture .cal-day-no { padding: 0 5px; border-radius: 6px; background: rgba(20, 12, 36, .72); color: #fff; }
.cal-day-picture { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 22%; }
.cal-day-tomato { position: absolute; left: 50%; top: 42%; width: min(58%, 62px); transform: translate(-50%, -50%); pointer-events: none; }
.cal-mini-doodle { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; pointer-events: none; }
/* a thin line stays a line in a small square */
.cal-mini-doodle path { stroke-width: 1.6px; vector-effect: non-scaling-stroke; }
.cal-day-label {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 4px;
  z-index: 2;
  padding: 2px 4px;
  border-radius: 6px;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  background: var(--tone, #dcc2ff);
  color: #241636;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}
.cal-day-dot { position: absolute; right: 7px; top: 9px; z-index: 2; width: 7px; height: 7px; border-radius: 50%; background: #ffc7f1; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }
[data-member="zh"] { --tone: #a9c6ff; }
[data-member="zzy"] { --tone: #9fe3de; }
[data-member="zzx"] { --tone: #f5d877; }
[data-member="zj"] { --tone: #ffc38a; }
[data-member="sxh"] { --tone: #ffb0b0; }

/* near: one day */
.cal-view-day { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(250px, 1fr); align-content: start; align-items: start; gap: 20px; }
.cal-day-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cal-frame {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid rgba(214, 180, 255, .28);
  border-radius: 14px;
  background: #fbf7ff;
}
.cal-frame-picture { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #120b22; animation: top-fade-in var(--dur-m) var(--ease-out) both; }
.cal-frame-tomato { width: 34%; }
.cal-frame-text { position: absolute; left: 0; right: 0; bottom: 8%; margin: 0; color: #3b2a55; font-family: "Noto Serif SC", "Songti SC", serif; font-size: clamp(18px, 3vw, 30px); font-weight: 600; text-align: center; }
.cal-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cal-frame.is-drawing { box-shadow: 0 0 0 2px #c08bff; }
.cal-frame.is-drawing .cal-canvas { pointer-events: auto; cursor: crosshair; touch-action: none; }
.cal-thumbs { display: flex; gap: 6px; overflow-x: auto; }
.cal-thumbs button { flex: none; width: 58px; height: 58px; padding: 0; overflow: hidden; border: 2px solid transparent; border-radius: 10px; background: #2b2047; cursor: pointer; transition: transform var(--dur-s) var(--ease-out), border-color var(--dur-s) var(--ease-out); }
.cal-thumbs button.is-on { border-color: #e9aaff; }
.cal-thumbs button:active { transform: scale(.94); }
.cal-thumbs img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 22%; }
.cal-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cal-inks { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; animation: top-fade-in var(--dur-m) var(--ease-out) both; }
.cal-inks[hidden] { display: none; }
.cal-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(214, 180, 255, .3);
  border-radius: 999px;
  background: rgba(150, 92, 220, .14);
  color: #f0e4ff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: transform var(--dur-s) var(--ease-out), background-color var(--dur-s) var(--ease-out);
}
.cal-tool svg { width: 17px; height: 17px; }
.cal-tool.is-on { background: linear-gradient(135deg, #a652e0, #d06fce); color: #fff; }
.cal-tool:active { transform: scale(.94); }
.cal-ink { width: 26px; height: 26px; padding: 0; border: 2px solid rgba(255, 255, 255, .35); border-radius: 50%; background: var(--ink); cursor: pointer; transition: transform var(--dur-s) var(--ease-out); }
.cal-ink.is-on { border-color: #fff; transform: scale(1.18); }
.cal-ink:active { transform: scale(.9); }
.cal-tool:focus-visible, .cal-ink:focus-visible, .cal-thumbs button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.cal-save { color: rgba(232, 218, 255, .65); font-size: 12px; }
.cal-day-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cal-labels { margin: 0; color: #f8d7f6; font-family: "Noto Serif SC", "Songti SC", serif; font-size: 18px; font-weight: 600; line-height: 1.5; }
.cal-notes { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.cal-note { display: flex; align-items: flex-start; gap: 8px; padding: 10px 8px 10px 14px; border-radius: 12px; background: rgba(255, 255, 255, .07); font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; animation: top-fade-in var(--dur-m) var(--ease-out) both; }
.cal-note span { flex: 1; min-width: 0; }
.cal-note-del { flex: none; display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: none; color: rgba(240, 228, 255, .6); cursor: pointer; transition: background-color var(--dur-s) var(--ease-out), color var(--dur-s) var(--ease-out); }
@media (hover: hover) {
  .cal-note-del:hover { background: rgba(255, 255, 255, .12); color: #fff; }
}
.cal-empty { padding: 12px; border: 1px dashed rgba(230, 210, 255, .26); border-radius: 12px; color: rgba(232, 218, 255, .66); font-size: 13px; text-align: center; }
.cal-form textarea { display: block; box-sizing: border-box; width: 100%; padding: 10px 12px; border: 1px solid rgba(214, 180, 255, .3); border-radius: 12px; background: rgba(12, 7, 24, .45); color: #fff; font: inherit; font-size: 14px; line-height: 1.6; resize: vertical; }
.cal-form textarea:focus { outline: 2px solid rgba(203, 150, 255, .8); outline-offset: 1px; }
.cal-form-row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.cal-form-row small { color: rgba(232, 218, 255, .6); font-size: 12px; }
.cal-form-row button, .cal-login { padding: 8px 18px; border: 0; border-radius: 999px; background: linear-gradient(135deg, #a652e0, #d06fce); color: #fff; font: inherit; font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer; transition: transform var(--dur-s) var(--ease-out), opacity var(--dur-s) var(--ease-out); }
.cal-login { align-self: flex-start; }
.cal-form-row button:disabled { opacity: .55; cursor: wait; }
@media (hover: hover) {
  .cal-form-row button:hover, .cal-login:hover { transform: scale(1.04); }
}
.cal-form-row button:active, .cal-login:active { transform: scale(.96); }
.cal-msg { margin: 0; color: #ffc2d6; font-size: 13px; }
.cal-msg:empty { display: none; }

@media (max-width: 760px) {
  .calendar-card { width: 100%; height: calc(100dvh - 24px); padding: 14px 10px 10px; border-radius: 20px; gap: 8px; }
  .calendar-card .modal-close { top: 10px; right: 10px; }
  .cal-bar { gap: 6px; padding-right: 44px; }
  .cal-bar h2 { order: -1; flex-basis: 100%; margin: 0 0 2px 4px; font-size: 18px; }
  .cal-btn { min-width: 34px; height: 34px; padding: 0 10px; font-size: 13px; }
  .cal-btn.is-zoom { width: 34px; font-size: 19px; }
  .cal-year-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(92px, 1fr); gap: 7px; }
  .cal-month-tile { padding: 10px; }
  .cal-month-tile b { font-size: 18px; }
  .cal-month-tile small { font-size: 11px; }
  .cal-week, .cal-month-grid { gap: 3px; }
  .cal-month-grid { grid-template-rows: repeat(var(--rows), minmax(78px, 1fr)); }
  .cal-day { border-radius: 8px; }
  .cal-day-no { left: 4px; top: 2px; font-size: 13px; }
  .cal-day-label { left: 2px; right: 2px; bottom: 2px; padding: 1px 2px; font-size: 10px; }
  .cal-view-day { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .cal-ink { width: 24px; height: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .cal-view, .cal-inks, .cal-note, .cal-frame-picture { animation: none !important; }
}
