/* ========== Notes page: dusk, moon, letters ========== */
html:has(.notes-body) {
  min-height: 100%;
  background:
    radial-gradient(ellipse 120% 40% at 50% 100%, rgba(196, 140, 150, 0.35), transparent 60%),
    linear-gradient(180deg, #15131f 0%, #231d31 30%, #3a2e44 62%, #574354 85%, #6b5160 100%);
  background-color: #15131f;
}

.notes-body {
  --ink: #3b3034;
  --ink-soft: #6e5e64;
  --paper: #f3ece2;
  --paper-edge: #e4d8c8;
  --sky-text: #ece3e8;
  --sky-muted: #b9aab5;
  --rose: #a7808c;

  background: transparent;
  color: var(--sky-text);
  justify-content: flex-start;
  padding: 1.25rem 1rem 4rem;
  min-height: 100vh;
}

/* drifting motes */
.notes-sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* crescent moon with the duck: kept in the corner, at the edge of vision */
.notes-moon {
  position: fixed;
  top: clamp(1.5rem, 6vh, 3.5rem);
  right: clamp(1.5rem, 6vw, 6rem);
  width: clamp(76px, 9vw, 120px);
  height: auto;
  overflow: visible;
  z-index: 0;
  pointer-events: none;
  opacity: 0.78;
  animation: moonRise 3.5s ease 0.8s both;
}

/* idle: slow drift, breathing glow, gentle sway */
.moon-drift {
  transform-box: view-box;
  transform-origin: 50% 50%;
  animation: moonDrift 10s ease-in-out infinite;
}

.moon-halo,
.moon-glow {
  animation: moonBreathe 6s ease-in-out infinite;
}

.moon-duck {
  transform-box: fill-box;
  transform-origin: 45% 100%;
  animation: duckSway 7s ease-in-out 1s infinite;
}

@keyframes moonDrift {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-9px) rotate(-5deg); }
}

@keyframes moonBreathe {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

@keyframes duckSway {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-7deg); }
  55% { transform: rotate(4deg); }
  80% { transform: rotate(-2deg); }
}

@keyframes moonRise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 0.78; transform: none; }
}

.notes-back a {
  color: var(--sky-muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(4px);
}

.notes-back a:hover {
  color: var(--sky-text);
  background: rgba(255, 255, 255, 0.12);
}

.notes-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 620px;
  margin-top: 7rem;
}

.notes-header {
  text-align: center;
  margin-bottom: 3rem;
}

.notes-title,
.notes-subtitle,
.notes-ornament {
  animation: notesFade 1.8s ease 0.5s both;
}

.notes-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(2.4rem, 8vw, 3.2rem);
  line-height: 1.05;
  color: var(--sky-text);
  margin: 0;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.35);
}

.notes-subtitle {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-variant: small-caps;
  text-transform: lowercase;
  letter-spacing: 0.18em;
  font-size: 1rem;
  color: var(--sky-muted);
  margin: 0.6rem 0 0;
}

.notes-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  margin: 1.25rem auto 0;
  color: var(--sky-muted);
  font-size: 0.7rem;
  opacity: 0.8;
}

.notes-ornament::before,
.notes-ornament::after {
  content: "";
  width: 72px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(236, 227, 232, 0.5), transparent);
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

/* the letter */
.letter {
  position: relative;
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.55), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(150, 110, 90, 0.12), transparent 50%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.25 0 0 0 0 0.2 0 0 0 0.07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--ink);
  border-radius: 3px;
  padding: clamp(2rem, 7vw, 3.25rem) clamp(1.5rem, 7vw, 3.25rem) clamp(2.5rem, 7vw, 3.5rem);
  box-shadow:
    0 0 0 1px var(--paper-edge) inset,
    0 30px 60px -20px rgba(8, 4, 16, 0.6),
    0 12px 24px -12px rgba(8, 4, 16, 0.45);
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 1.4s ease, transform 1.4s ease;
}

.letter::after {
  /* hairline stationery border */
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(140, 108, 100, 0.18);
  border-radius: 1px;
  pointer-events: none;
}

.letter::before {
  /* faint fold line */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 38%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(120, 90, 80, 0.12) 20%, rgba(120, 90, 80, 0.12) 80%, transparent);
  pointer-events: none;
}

.letter--visible {
  opacity: 1;
  transform: none;
}

.letter-date {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: 1rem;
  color: var(--ink-soft);
  text-align: right;
  margin: 0 0 1.5rem;
}

.letter-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600;
  font-size: 1.6rem;
  line-height: 1.2;
  color: var(--ink);
  margin: 0 0 1.25rem;
}

.letter-body {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.15rem;
  line-height: 1.85;
  color: var(--ink);
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  hyphens: auto;
}

.letter-body::first-letter {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 400;
  font-size: 3.4em;
  line-height: 0.8;
  float: left;
  margin: 0.08em 0.1em 0 0;
  color: var(--rose);
}

/* wax seal with the duck */
.letter-seal {
  position: absolute;
  right: clamp(1.25rem, 5vw, 2rem);
  bottom: -22px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, #a9727e, #7c4a57 60%, #5e3542);
  box-shadow:
    0 0 0 3px rgba(124, 74, 87, 0.35),
    0 6px 14px rgba(20, 8, 16, 0.45),
    inset 0 2px 3px rgba(255, 255, 255, 0.2),
    inset 0 -3px 6px rgba(0, 0, 0, 0.25);
}

.letter-seal::after {
  content: "";
  width: 24px;
  height: 29px;
  background: linear-gradient(160deg, rgba(255, 225, 230, 0.7), rgba(80, 30, 45, 0.75));
  -webkit-mask: url("duck-silhouette.png") center / contain no-repeat;
  mask: url("duck-silhouette.png") center / contain no-repeat;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.35));
}

.notes-empty {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: 1.25rem;
  text-align: center;
  color: var(--sky-muted);
  margin: 2rem 0;
}

.notes-footer {
  text-align: center;
  margin-top: 4rem;
  animation: notesFade 2s ease 0.6s both;
}

.notes-footer-line {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--sky-muted);
  margin: 0;
  opacity: 0.85;
}

@keyframes notesFade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 480px) {
  .notes-wrap { margin-top: 6.5rem; }
  .notes-moon { position: absolute; width: 58px; top: 0.7rem; right: 1.1rem; opacity: 0.72; }
  .letter::after { inset: 8px; }
  .letter-body { font-size: 1.08rem; }
}

@media (prefers-reduced-motion: reduce) {
  .moon-drift, .moon-halo, .moon-glow, .moon-duck { animation: none; }
  .notes-moon, .notes-title, .notes-subtitle, .notes-ornament, .notes-footer { animation: none; }
  .letter { opacity: 1; transform: none; transition: none; }
}

/* ========== Glitched words: unreadable until revealed ========== */
.glitch {
  position: relative;
  display: inline-block;
  font-family: 'Courier New', ui-monospace, monospace;
  font-size: 0.86em;
  letter-spacing: 0;
  line-height: 1;
  vertical-align: 0.02em;
  color: currentColor;
  opacity: 0.85;
  text-shadow: -1.5px 0 rgba(180, 70, 90, 0.55), 1.5px 0 rgba(70, 120, 160, 0.55);
  filter: blur(0.25px);
  white-space: nowrap;
  overflow-wrap: normal;
  font-variant-ligatures: none;
  user-select: none;
  -webkit-user-select: none;
  animation: glitchShift 2.4s steps(1, end) infinite;
}

@keyframes glitchShift {
  0%, 100% { transform: none; clip-path: none; }
  8% { transform: translate(-1px, 0.5px); }
  9% { transform: translate(1.5px, -0.5px); clip-path: inset(0 0 45% 0); }
  10% { transform: none; clip-path: none; }
  47% { transform: skewX(-8deg); text-shadow: -2.5px 0 rgba(180, 70, 90, 0.7), 2px 0 rgba(70, 120, 160, 0.7); }
  48% { transform: none; clip-path: inset(55% 0 0 0); }
  49% { clip-path: none; }
  73% { opacity: 0.5; }
  74% { opacity: 0.85; transform: translateX(-1px); }
  75% { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .glitch { animation: none; }
}

.glitch-cell {
  display: inline-block;
  width: 1ch;
  text-align: center;
}
