/* ============================================================
   JOURNAL APP — Notebook Calendar (queensjournal.app clone)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Felipa&family=Inter:wght@400;500;600&family=M+PLUS+Rounded+1c:wght@400;500&display=swap');

/* ---- Fullscreen Window ---- */

#journal-window {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}

#journal-window .window-header,
#journal-window .resize-handle {
  display: none !important;
}

#journal-window .window-content {
  padding: 0;
  overflow: hidden;
  height: 100% !important;
  position: relative;
  clip-path: polygon(0 0, calc(100% - 56px) 0, 100% 56px, 100% 100%, 0 100%);
}

/* ---- Fold Button ---- */

.journal-fold {
  position: fixed;
  top: 0;
  right: 0;
  width: 56px;
  height: 56px;
  z-index: 10001;
  cursor: pointer;
  overflow: hidden;
  transition: width 0.2s ease, height 0.2s ease;
}

.journal-fold::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #ddd 0%, #f5f5f5 100%);
  clip-path: polygon(0 0, 0 100%, 100% 100%);
}

.journal-fold::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.08);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.journal-fold:hover {
  width: 68px;
  height: 68px;
}

.journal-fold:hover::before {
  background: linear-gradient(135deg, #ccc 0%, #eee 100%);
}

.journal-fold.journal-fold-hiding {
  animation: journal-fold-btn-hide 0.3s ease-in forwards;
  pointer-events: none;
}

@keyframes journal-fold-btn-hide {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

.journal-content.journal-exiting {
  animation: journal-fold-exit 0.9s ease-in forwards;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom left, transparent 33.3%, #000 66.6%);
  mask-image: linear-gradient(to bottom left, transparent 33.3%, #000 66.6%);
  -webkit-mask-size: 300% 300%;
  mask-size: 300% 300%;
}

@keyframes journal-fold-exit {
  0%   { -webkit-mask-position: 0% 100%; mask-position: 0% 100%; }
  100% { -webkit-mask-position: 100% 0%; mask-position: 100% 0%; }
}

#journal-container {
  height: 100%;
}

/* ---- Scene & Layout ---- */

.journal-content {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(250, 249, 244);
  font-family: Inter, 'Helvetica Neue', sans-serif;
}

.notebook-scene {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 24px;
  box-sizing: border-box;
}

.notebook__layout {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---- Notebook (Book) ---- */

.notebook {
  position: relative;
  perspective: 1800px;
  width: 1156px;
  height: 782px;
}

.notebook--open .notebook__pages {
  opacity: 1;
  pointer-events: auto;
}

.notebook__pages {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  background: #fff;
  border-radius: 4px;
  box-shadow:
    0 2px 20px rgba(0, 0, 0, 0.08),
    0 0 1px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  transition: opacity 0.4s ease;
}

.notebook__page {
  flex: 1;
  background: #fff;
}

.notebook__page--left {
  border-right: none;
}

.notebook__page--right {
  border-left: none;
}

.notebook__gutter {
  display: none;
}

/* ---- Notebook Cover (3D flip) ---- */

.notebook__cover {
  position: absolute;
  top: -4px;
  left: -4px;
  width: calc(50% + 8px);
  height: calc(100% + 8px);
  transform-origin: right center;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
  pointer-events: auto;
  cursor: pointer;
}

.notebook--open .notebook__cover {
  transform: rotateY(-180deg);
  pointer-events: none;
  z-index: 0;
}

.notebook__cover-front,
.notebook__cover-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  backface-visibility: hidden;
}

.notebook__cover-front {
  background: rgb(228, 219, 201);
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.notebook__cover-back {
  background: rgb(245, 241, 232);
  transform: rotateY(180deg);
}

.notebook__elastic {
  position: absolute;
  top: 10%;
  bottom: 10%;
  right: 12px;
  width: 3px;
  background: rgb(180, 165, 140);
  border-radius: 2px;
}

/* ---- Page Content (Calendar wrapper) ---- */

.notebook__page-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.3s ease;
}

/* ---- Calendar ---- */

.calendar {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.calendar__flip-wrapper {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
  perspective: 1800px;
}

.calendar__flip-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 100%;
  background: linear-gradient(
    to right,
    transparent 0%,
    rgba(0, 0, 0, 0.03) 25%,
    rgba(0, 0, 0, 0.08) 50%,
    rgba(0, 0, 0, 0.03) 75%,
    transparent 100%
  );
  z-index: 10;
  pointer-events: none;
}

.calendar__page {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 20px 16px;
  box-sizing: border-box;
  position: relative;
  background: #fff;
}

.calendar__page--left {
  padding-right: 0;
}

.calendar__page--right {
  padding-left: 0;
}

/* Remove right border on last column of left grid to avoid double border at spine */
.calendar__grid--left .calendar__cell:nth-child(4n+4),
.calendar__grid--left .calendar__day-header:nth-child(4) {
  border-right: none;
}

/* ---- Calendar Header ---- */

.calendar__header {
  display: flex;
  align-items: baseline;
  margin-bottom: 12px;
  min-height: 40px;
}

.calendar__header--right {
  justify-content: flex-end;
}

.calendar__month {
  font-family: Felipa, Georgia, serif;
  font-size: 32px;
  font-weight: 400;
  color: rgb(60, 55, 48);
  margin: 0;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}

.calendar__month:hover {
  color: rgb(154, 138, 110);
}

.calendar__lang-wrapper {
  display: flex;
  align-items: center;
}

.calendar__lang-toggle {
  background: none;
  border: none;
  font-family: Inter, sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: rgb(154, 138, 110);
  cursor: pointer;
  padding: 4px 6px;
  transition: color 0.2s;
}

.calendar__lang-toggle:hover {
  color: rgb(100, 88, 70);
}

/* ---- Calendar Grid ---- */

.calendar__grid {
  display: grid;
  flex: 1;
  min-height: 0;
  gap: 0;
}

.calendar__grid--left {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: auto repeat(var(--rows, 5), 1fr);
}

.calendar__grid--right {
  grid-template-columns: repeat(3, 1fr) 8px;
  grid-template-rows: auto repeat(var(--rows, 5), 1fr);
}

.calendar__day-header {
  font-family: 'M PLUS Rounded 1c', 'Hiragino Kaku Gothic Pro', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: rgb(154, 138, 110);
  text-align: left;
  padding: 0 6px 8px;
  border-bottom: 1px solid rgb(228, 219, 201);
  user-select: none;
}

.calendar__day-header--empty {
  border-bottom: 1px solid rgb(228, 219, 201);
}

/* ---- Day Cells ---- */

.calendar__cell {
  position: relative;
  border-bottom: 1px solid rgb(235, 229, 216);
  border-right: 1px solid rgb(235, 229, 216);
  padding: 4px 6px;
  cursor: default;
  overflow: hidden;
  transition: background 0.15s;
}

.calendar__cell--empty-day {
  cursor: pointer;
}

.calendar__cell--empty-day:hover {
  background: rgba(228, 219, 201, 0.2);
}

.calendar__cell--has-image {
  padding: 0;
}

.calendar__cell--today {
  background: rgba(228, 219, 201, 0.25);
}

.calendar__date {
  font-family: Inter, sans-serif;
  font-size: 11px;
  font-weight: 400;
  color: rgb(120, 110, 95);
  user-select: none;
}

.calendar__cell-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---- Postage Stamp Effect ---- */

.calendar__cell-stamp-svg {
  position: absolute;
  inset: 10%;
  width: 80%;
  height: 80%;
  filter: drop-shadow(0 3px 6px rgba(43, 32, 18, 0.2));
}

.calendar__cell-stamp-paper {
  fill: #fbf1de;
  stroke: rgba(117, 92, 60, 0.35);
  stroke-width: 0.85;
}

.calendar__cell--has-image .calendar__date {
  position: relative;
  z-index: 1;
  color: rgb(120, 110, 95);
  padding: 2px 2px 0;
}

.calendar__extra-column {
  border: none;
  background: transparent;
}

/* ---- Page Flip Animation ---- */


.calendar__flip-leaf {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.645, 0.045, 0.355, 1.0);
  z-index: 6;
  pointer-events: none;
}

/* Forward: leaf on right side, hinges on left (spine) */
.calendar__flip-leaf--forward {
  right: 0;
  transform-origin: left center;
  transform: rotateY(0deg);
}

.calendar__flip-leaf--forward.flipping {
  transform: rotateY(-180deg);
}

/* Backward: leaf on left side, hinges on right (spine) */
.calendar__flip-leaf--backward {
  left: 0;
  transform-origin: right center;
  transform: rotateY(0deg);
}

.calendar__flip-leaf--backward.flipping {
  transform: rotateY(180deg);
}

.calendar__flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: #fff;
  overflow: hidden;
}

.calendar__flip-face--front {
  z-index: 2;
}

.calendar__flip-face--back {
  transform: rotateY(180deg);
  z-index: 1;
}

/* Spine shadow on the flip leaf */
.calendar__flip-face::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 24px;
  height: 100%;
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.08) 0%,
    rgba(0, 0, 0, 0.03) 40%,
    transparent 100%
  );
  pointer-events: none;
}

/* ---- Navigation Arrows ---- */

.calendar__nav-arrow {
  position: absolute;
  bottom: 12px;
  background: none;
  border: none;
  font-size: 20px;
  color: rgb(180, 168, 148);
  cursor: pointer;
  padding: 4px 10px;
  transition: color 0.2s;
  user-select: none;
  z-index: 3;
}

.calendar__nav-arrow:hover {
  color: rgb(100, 88, 70);
}

.calendar__nav-arrow--prev {
  left: 8px;
}

.calendar__nav-arrow--next {
  right: 8px;
}

/* ---- Hidden file input ---- */

.calendar__file-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

/* ---- Month Picker Overlay ---- */

.calendar__month-picker {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(250, 249, 244, 0.96);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.calendar__month-picker.visible {
  display: flex;
}

.calendar__month-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 32px;
}

.calendar__month-option {
  background: none;
  border: 1px solid rgb(228, 219, 201);
  border-radius: 4px;
  padding: 14px 18px;
  font-family: Felipa, Georgia, serif;
  font-size: 22px;
  color: rgb(60, 55, 48);
  cursor: pointer;
  transition: all 0.15s;
}

.calendar__month-option:hover {
  background: rgb(228, 219, 201);
  color: rgb(40, 36, 30);
}

.calendar__month-option--active {
  background: rgb(228, 219, 201);
  font-weight: 700;
}

/* ---- Sidebar ---- */

.notebook__sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.share-btn {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: rgb(180, 168, 148);
  transition: color 0.2s;
  padding: 8px;
}

.share-btn:hover {
  color: rgb(100, 88, 70);
}

.share-btn__icon {
  width: 18px;
  height: 18px;
}

.share-btn__label {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.05em;
  font-family: Inter, sans-serif;
}

/* ---- Credit ---- */

.notebook__credit {
  position: absolute;
  bottom: 8px;
  right: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.notebook__credit-link,
.notebook__credit-copy {
  font-family: Inter, sans-serif;
  font-size: 9px;
  color: rgb(180, 168, 148);
  text-decoration: none;
  transition: color 0.2s;
}

.notebook__credit-link:hover {
  color: rgb(100, 88, 70);
}

/* ---- Year Display ---- */

.calendar__year {
  font-family: Inter, sans-serif;
  font-size: 11px;
  font-weight: 400;
  color: rgb(180, 168, 148);
  margin-left: 8px;
}

/* ---- Responsive (inside CanOS window) ---- */

@media (max-width: 768px) {
  .journal-fold {
    width: 44px;
    height: 44px;
  }

  .journal-fold:hover {
    width: 52px;
    height: 52px;
  }

  #journal-window .window-content {
    clip-path: polygon(0 0, calc(100% - 44px) 0, 100% 44px, 100% 100%, 0 100%);
  }

  .notebook {
    width: 100%;
    height: auto;
    min-height: 360px;
  }

  .notebook__layout {
    flex-direction: column;
  }

  .notebook__sidebar {
    flex-direction: row;
    justify-content: center;
  }

  .notebook__credit {
    position: relative;
    bottom: auto;
    right: auto;
    justify-content: center;
    margin-top: 8px;
  }

  .calendar__month {
    font-size: 26px;
  }

  .calendar__page {
    padding: 12px 10px 8px;
  }

  .calendar__day-header {
    font-size: 10px;
  }

  .calendar__date {
    font-size: 10px;
  }
}
