/* ═══════════════════════════════════════════════════════════════════════════
   THE HAPPINESS JAR · note reader, note index, floating music player
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── overlays ───────────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(0.9rem, calc(var(--safe-t) + 0.6rem)) max(0.9rem, calc(var(--safe-r) + 0.7rem))
    max(0.9rem, calc(var(--safe-b) + 0.6rem)) max(0.9rem, calc(var(--safe-l) + 0.7rem));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.overlay[hidden] {
  display: none;
}

.overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(64, 40, 44, 0.42);
  -webkit-backdrop-filter: blur(7px) saturate(115%);
  backdrop-filter: blur(7px) saturate(115%);
  opacity: 0;
  transition: opacity 0.34s ease;
}

.overlay.is-open .overlay-backdrop {
  opacity: 1;
}

/* ── the note ───────────────────────────────────────────────────────────── */
.note-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.note-sheet {
  position: relative;
  max-height: calc(100svh - 9.5rem - var(--safe-t) - var(--safe-b));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 2rem 1.35rem 1.6rem;
  border-radius: 3px;
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 88% 0%, rgba(255, 246, 231, 0.9) 0%, rgba(255, 246, 231, 0) 55%),
    linear-gradient(180deg, #fffdf7 0%, #fdf6ec 100%);
  box-shadow: 0 34px 60px -30px rgba(46, 26, 30, 0.6),
    inset 0 0 0 1px rgba(193, 154, 82, 0.18);
  transform-origin: 50% 0%;
  transform: perspective(1000px) rotateX(-74deg) scaleY(0.82);
  opacity: 0;
}

.overlay.is-open .note-sheet {
  animation: unfold 0.72s var(--ease-out) both;
}

@keyframes unfold {
  0%   { transform: perspective(1000px) rotateX(-74deg) scaleY(0.82); opacity: 0; }
  52%  { opacity: 1; }
  74%  { transform: perspective(1000px) rotateX(6deg) scaleY(1.005); opacity: 1; }
  100% { transform: perspective(1000px) rotateX(0) scaleY(1); opacity: 1; }
}

/* faint fold creases across the paper */
.note-sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(150, 115, 100, 0.09) 0 1px, transparent 1px) 0 50% / 100% 100% no-repeat,
    radial-gradient(120% 60% at 50% 100%, rgba(190, 150, 120, 0.1) 0%, rgba(190, 150, 120, 0) 70%);
  opacity: 0.7;
}

.note-tape {
  position: absolute;
  top: -9px;
  left: 50%;
  width: 92px;
  height: 24px;
  transform: translateX(-50%) rotate(-1.6deg);
  background: linear-gradient(180deg, rgba(240, 219, 190, 0.85), rgba(233, 208, 176, 0.72));
  box-shadow: 0 2px 6px -3px rgba(90, 60, 55, 0.4);
  clip-path: polygon(2% 0, 98% 4%, 100% 96%, 0 100%);
}

.note-kicker {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--rose);
  padding-right: 4.1rem;
}

.note-page {
  position: absolute;
  top: 1.9rem;
  right: 1.3rem;
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(122, 97, 102, 0.72);
  font-variant-numeric: tabular-nums;
}

.note-title {
  margin-top: 0.5rem;
  font-family: var(--serif);
  font-size: 1.5rem;
  line-height: 1.24;
  font-weight: 500;
  letter-spacing: -0.008em;
  color: var(--plum);
  text-wrap: balance;
}

.note-rule {
  width: 40px;
  height: 2px;
  margin: 0.85rem 0 0.95rem;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--blush-deep), rgba(240, 201, 198, 0));
}

.note-body {
  font-family: var(--serif);
  font-size: 1.04rem;
  line-height: 1.72;
  color: #4a3438;
  text-wrap: pretty;
  white-space: pre-line;
}

.note-sign,
.note-mini {
  display: none;
}

.note-bloom {
  position: absolute;
  right: 1.1rem;
  bottom: 1rem;
  width: 26px;
  height: 26px;
  opacity: 0.45;
  color: var(--gold);
}

/* ── the Akshat Collection: an excerpt from a private journal ───────────── */
.note-sheet.is-akshat {
  color: var(--espresso);
  background:
    radial-gradient(90% 60% at 12% 4%, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 58%),
    repeating-linear-gradient(180deg, rgba(139, 106, 82, 0.075) 0 1px, transparent 1px 30px),
    linear-gradient(180deg, #fcf7e9 0%, #f6eeda 100%);
  box-shadow: 0 34px 60px -28px rgba(40, 24, 18, 0.66),
    inset 0 0 0 1px rgba(120, 88, 60, 0.28),
    inset 0 0 0 6px #fbf5e6,
    inset 0 0 0 7px rgba(120, 88, 60, 0.22);
}

.note-sheet.is-akshat::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(50% 34% at 0% 0%, rgba(120, 88, 60, 0.18) 0%, rgba(120, 88, 60, 0) 70%),
    radial-gradient(46% 30% at 100% 100%, rgba(120, 88, 60, 0.16) 0%, rgba(120, 88, 60, 0) 72%);
}

.note-sheet.is-akshat .note-kicker {
  color: #8a6242;
  letter-spacing: 0.2em;
}

.note-sheet.is-akshat .note-page {
  color: rgba(90, 64, 46, 0.75);
  top: 2rem;
  font-family: var(--serif);
  font-style: italic;
  letter-spacing: 0.06em;
  text-transform: none;
  padding: 0.1rem 0.55rem;
  border: 1px solid rgba(120, 88, 60, 0.35);
  border-radius: 999px;
  background: rgba(255, 252, 242, 0.7);
}

.note-sheet.is-akshat .note-title {
  color: #3a231b;
  font-size: 1.62rem;
  font-style: italic;
  letter-spacing: 0.005em;
}

.note-sheet.is-akshat .note-rule {
  background: linear-gradient(90deg, rgba(120, 88, 60, 0.6), rgba(120, 88, 60, 0));
}

.note-sheet.is-akshat .note-body {
  color: #3c261f;
  font-size: 1.14rem;
  line-height: 1.78;
  letter-spacing: 0.002em;
}

.note-sheet.is-akshat .note-body::first-letter {
  initial-letter: 2;
  -webkit-initial-letter: 2;
  font-size: 2.5rem;
  line-height: 1;
  float: left;
  padding: 0.14em 0.1em 0 0;
  color: #6b4526;
}

.note-sheet.is-akshat .note-sign {
  display: block;
  margin-top: 1.15rem;
  font-family: var(--hand);
  font-size: 1.6rem;
  line-height: 1;
  color: #5b3a2a;
  text-align: right;
}

.note-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  flex: 0 0 auto;
}

.note-actions .btn {
  min-height: 50px;
  padding: 0 0.7rem;
  font-size: 0.92rem;
}

/* ── note index ─────────────────────────────────────────────────────────── */
.list-sheet {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 450px;
  max-height: 100%;
  border-radius: 20px;
  background: linear-gradient(180deg, #fffdf8 0%, #fdf4e9 100%);
  box-shadow: 0 34px 60px -30px rgba(46, 26, 30, 0.6);
  overflow: hidden;
  transform: translateY(18px) scale(0.985);
  opacity: 0;
}

.overlay.is-open .list-sheet {
  animation: sheet-in 0.44s var(--ease-out) both;
}

@keyframes sheet-in {
  to { transform: none; opacity: 1; }
}

.list-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.05rem 1.05rem 0.8rem 1.15rem;
  border-bottom: 1px solid rgba(192, 123, 129, 0.18);
  background: rgba(255, 252, 246, 0.9);
}

.list-head h2 {
  font-family: var(--serif);
  font-size: 1.18rem;
  font-weight: 500;
  color: var(--plum);
}

.list-head p {
  margin-top: 0.18rem;
  font-size: 0.76rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -0.35rem -0.3rem 0 0;
  border-radius: 50%;
  font-size: 1rem;
  color: var(--plum-soft);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(122, 97, 102, 0.18);
}

.list-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0.4rem 0.55rem 1rem;
}

.list-group + .list-group {
  margin-top: 0.55rem;
}

.list-group h3 {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.7rem 0.6rem 0.35rem;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rose);
}

.list-group h3 span {
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  font-size: 0.7rem;
  color: rgba(122, 97, 102, 0.8);
}

.list-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 52px;
  padding: 0.35rem 0.6rem;
  border-radius: 10px;
  text-align: left;
  transition: background-color 0.18s ease;
}

.list-item:active {
  background: rgba(248, 227, 225, 0.65);
}

.list-num {
  flex: 0 0 auto;
  width: 2rem;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: rgba(122, 97, 102, 0.75);
}

.list-name {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--serif);
  font-size: 0.94rem;
  line-height: 1.3;
  color: var(--plum);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-state {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 0.62rem;
  color: rgba(122, 97, 102, 0.55);
  border: 1px solid currentColor;
}

.list-item.is-opened .list-num {
  color: var(--rose);
}

.list-item.is-opened .list-state {
  color: #5d7350;
  background: rgba(232, 242, 224, 0.9);
  border-color: transparent;
}

.list-item.is-akshat .list-name {
  font-style: italic;
  color: var(--espresso);
}

/* ── floating music player ──────────────────────────────────────────────── */
.player {
  position: fixed;
  z-index: 50;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  max-width: 480px;
  padding: 0.55rem 0.85rem calc(0.45rem + var(--safe-b));
  border-radius: 22px 22px 0 0;
  background: rgba(255, 250, 244, 0.9);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  backdrop-filter: saturate(160%) blur(18px);
  border-top: 1px solid rgba(192, 123, 129, 0.22);
  box-shadow: 0 -14px 34px -26px rgba(70, 46, 51, 0.65);
  animation: player-in 0.55s var(--ease-out) both;
}

@keyframes player-in {
  from { transform: translateY(110%); }
  to   { transform: none; }
}

.player-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.player-art {
  position: relative;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--ivory-deep);
  box-shadow: 0 6px 14px -10px rgba(70, 46, 51, 0.8);
}

.player-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player.is-playing .player-art::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  animation: art-glow 3.4s ease-in-out infinite;
}

@keyframes art-glow {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35); }
  50%      { box-shadow: inset 0 0 0 1px rgba(255, 240, 224, 0.9); }
}

.player-meta {
  flex: 1 1 auto;
  min-width: 0;
  padding-right: 0.1rem;
}

.player-title {
  font-family: var(--serif);
  font-size: 0.86rem;
  line-height: 1.25;
  color: var(--plum);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-artist {
  margin-top: 0.08rem;
  font-size: 0.72rem;
  line-height: 1.2;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wave--player {
  flex: 0 0 auto;
  height: 15px;
  gap: 2.5px;
  opacity: 0.85;
}

.wave--player i {
  width: 2.5px;
}

.player-btn {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #fff9f4;
  background: linear-gradient(140deg, #b9707a, #8f4f5b);
  box-shadow: 0 10px 18px -12px rgba(112, 56, 66, 0.95);
  transition: transform 0.16s var(--ease-out);
}

.player-btn:active {
  transform: scale(0.94);
}

.player-btn .ico {
  width: 17px;
  height: 17px;
}

.player-btn--mute {
  width: 40px;
  height: 40px;
  color: var(--plum-soft);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(122, 97, 102, 0.2);
  box-shadow: none;
}

.player-btn--mute .ico {
  width: 18px;
  height: 18px;
}

.ico--pause,
.ico--muted {
  display: none;
}

.player.is-playing .ico--play,
.player.is-muted .ico--sound {
  display: none;
}

.player.is-playing .ico--pause,
.player.is-muted .ico--muted {
  display: block;
}

.player-progress {
  position: relative;
  height: 26px;
  margin-top: 0.15rem;
}

.seek {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 26px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  touch-action: pan-y;
}

.seek:disabled {
  opacity: 0.6;
}

.seek::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: rgba(122, 97, 102, 0.2);
}

.seek::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: rgba(122, 97, 102, 0.2);
}

.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--rose-deep);
  box-shadow: 0 1px 4px rgba(70, 46, 51, 0.45);
}

.seek::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 0;
  border-radius: 50%;
  background: var(--rose-deep);
  box-shadow: 0 1px 4px rgba(70, 46, 51, 0.45);
}

.seek-fill {
  position: absolute;
  z-index: 1;
  left: 0;
  top: 50%;
  height: 3px;
  width: var(--p, 0%);
  margin-top: -1.5px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--rose) 0%, #d29aa0 100%);
  pointer-events: none;
  transition: width 0.18s linear;
}

.player-error {
  margin-top: 0.15rem;
  font-size: 0.7rem;
  line-height: 1.4;
  color: #9a5a4a;
}

.noscript {
  position: fixed;
  inset: auto 1rem calc(1rem + var(--safe-b));
  z-index: 100;
  padding: 1rem 1.15rem;
  border-radius: 14px;
  background: #fff8ef;
  box-shadow: var(--shadow-card);
  font-size: 0.9rem;
  text-align: center;
  color: var(--plum);
}

/* ── desktop / tablet: the player becomes a little floating card ─────────── */
@media (min-width: 700px) {
  .player {
    left: auto;
    right: 20px;
    bottom: 20px;
    width: 340px;
    max-width: none;
    padding: 0.6rem 0.85rem 0.45rem;
    border-radius: 20px;
    border: 1px solid rgba(192, 123, 129, 0.22);
  }

  .note-wrap {
    max-width: 440px;
  }
}

/* a quiet nudge on the play button until the song has been started once */
.player:not(.has-started) #playBtn {
  animation: play-nudge 3.2s ease-in-out 1.2s infinite;
}

@keyframes play-nudge {
  0%, 100% { box-shadow: 0 10px 18px -12px rgba(112, 56, 66, 0.95), 0 0 0 0 rgba(192, 123, 129, 0); }
  50%      { box-shadow: 0 10px 18px -12px rgba(112, 56, 66, 0.95), 0 0 0 7px rgba(192, 123, 129, 0.14); }
}

@media (max-width: 359px) {
  .note-sheet {
    padding: 1.8rem 1.1rem 1.4rem;
  }

  .note-title {
    font-size: 1.36rem;
  }

  .player-meta {
    max-width: 7.5rem;
  }

  .wave--player {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   THE EXPANDED JAR · three extra papers and the final handwritten page
   ═══════════════════════════════════════════════════════════════════════════ */

/* paragraph blocks (used by the last page) */
.note-body p { margin: 0; }
.note-body p + p { margin-top: 0.85em; }
.note-body .note-closing { margin-top: 1.4rem; }
.note-body .note-closing p { margin: 0; }
.note-body .note-closing p + p { margin-top: 0.45rem; }
.note-body .note-final-sign {
  font-family: var(--hand);
  font-size: 1.95rem;
  line-height: 1.1;
  color: #5b3a2a;
}

/* ── the Anya collection: warm, personal, a little sunlit ───────────────── */
.note-sheet.is-anya {
  background:
    radial-gradient(120% 80% at 88% 0%, rgba(255, 255, 255, 0.75) 0%, rgba(255, 255, 255, 0) 60%),
    linear-gradient(180deg, #fffaf5 0%, #fdeee6 100%);
  box-shadow: 0 34px 60px -30px rgba(70, 36, 34, 0.55),
    inset 0 0 0 1px rgba(214, 150, 132, 0.38);
}

.note-sheet.is-anya::after {
  content: "🌻";
  position: absolute;
  right: 1rem;
  bottom: 0.7rem;
  font-size: 2.5rem;
  line-height: 1;
  opacity: 0.2;
  transform: rotate(-8deg);
  pointer-events: none;
}

.note-sheet.is-anya .note-kicker { color: #b4716a; }

.note-sheet.is-anya .note-rule {
  background: linear-gradient(90deg, #e2a08d, rgba(226, 160, 141, 0));
}

.note-sheet.is-anya .note-title {
  color: #6b3a37;
  font-style: italic;
}

.note-sheet.is-anya .note-body { color: #55383a; }

/* ── the inside-joke collection: playful paper, dashed edge ─────────────── */
.note-sheet.is-joke {
  background:
    radial-gradient(110% 70% at 10% 0%, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 58%),
    linear-gradient(180deg, #fffaea 0%, #fdf0d3 100%);
  box-shadow: 0 34px 60px -30px rgba(70, 52, 26, 0.5),
    inset 0 0 0 2px rgba(196, 150, 70, 0.28);
}

.note-sheet.is-joke::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px dashed rgba(186, 143, 66, 0.34);
  border-radius: 2px;
  pointer-events: none;
}

.note-sheet.is-joke .note-kicker { color: #a4772f; }

.note-sheet.is-joke .note-rule {
  background: linear-gradient(90deg, #d3a75a, rgba(211, 167, 90, 0));
}

.note-sheet.is-joke .note-title { color: #5c4322; }
.note-sheet.is-joke .note-body { color: #4b3a22; }

/* ── note 113: the last page of a handwritten letter ────────────────────── */
.note-sheet.is-final {
  padding-bottom: 2rem;
  background:
    repeating-linear-gradient(180deg, rgba(150, 115, 120, 0.1) 0 1px, transparent 1px 31px),
    radial-gradient(90% 55% at 0% 0%, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 60%),
    linear-gradient(180deg, #fffdf7 0%, #fdf3ea 100%);
  box-shadow: 0 34px 60px -30px rgba(60, 32, 36, 0.6),
    inset 0 0 0 1px rgba(196, 142, 146, 0.32);
}

.note-sheet.is-final::after {
  content: "♡";
  position: absolute;
  right: 1.15rem;
  bottom: 0.6rem;
  font-size: 1.5rem;
  color: var(--rose);
  opacity: 0.45;
  pointer-events: none;
}

.note-sheet.is-final .note-kicker { color: var(--rose-deep); }

.note-sheet.is-final .note-title {
  font-style: italic;
  font-size: 1.58rem;
}

.note-sheet.is-final .note-body {
  font-size: 1.06rem;
  line-height: 1.78;
}

/* ── index: quiet section markers ───────────────────────────────────────── */
.list-item.is-anya .list-num { color: #b4716a; }
.list-item.is-joke .list-num { color: #a4772f; }
.list-item.is-anya .list-name { color: #6b3a37; }
.list-item.is-joke .list-name { color: #5c4322; }
.list-item.is-final .list-name { font-style: italic; color: var(--rose-deep); }
