/* ==========================================================================
   Beril — 2.5D Living Botanical Art Stylesheet
   Pure full-bleed canvas artwork; automatic Istanbul-time Dual Atmosphere
   (Altın Saat: 06:00–19:00 | Yıldızlı Gece: 19:00–06:00)
   ========================================================================== */

:root {
  --font-serif: "Cormorant Garamond", "Georgia", "Palatino Linotype", "Book Antiqua", serif;
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Golden Hour default tokens */
  --bg-fallback: #f5e3d0;
  --ink-primary: #453028;
  --ink-accent: #b07f47;

  --letter-backdrop: rgba(48, 32, 24, 0.36);
  --letter-bg: rgba(254, 249, 242, 0.94);
  --letter-border: rgba(206, 165, 108, 0.52);
  --letter-inner-line: rgba(206, 165, 108, 0.28);
  --letter-title: #4d2c28;
  --letter-text: #563e34;
  --letter-muted: #937058;
  --letter-shadow: 0 28px 70px rgba(64, 38, 24, 0.24), 0 2px 10px rgba(255, 244, 224, 0.4) inset;
}

html[data-theme="night"] {
  --bg-fallback: #10182b;
  --ink-primary: #f5ece2;
  --ink-accent: #e5c383;

  --letter-backdrop: rgba(6, 10, 22, 0.58);
  --letter-bg: rgba(18, 26, 44, 0.92);
  --letter-border: rgba(226, 192, 128, 0.38);
  --letter-inner-line: rgba(226, 192, 128, 0.22);
  --letter-title: #f8d8d2;
  --letter-text: #e6ddd3;
  --letter-muted: #bfa98e;
  --letter-shadow: 0 32px 80px rgba(2, 6, 16, 0.65), 0 1px 12px rgba(240, 212, 152, 0.14) inset;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-fallback);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 1s ease, color 0.8s ease;
  touch-action: manipulation;
}

.stage-root {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.botanical-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}

/* Subtle fine-art paper texture overlay */
.paper-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.045;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.9'/%3E%3C/svg%3E");
}

/* ==========================================================================
   Accessible Hit-Target Synced Over the Hanging Botanical Envelope on Canvas
   ========================================================================== */

.envelope-hotspot {
  position: absolute;
  z-index: 8;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  outline: none;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
  -webkit-tap-highlight-color: transparent;
}

.envelope-hotspot.ready {
  opacity: 1;
  pointer-events: auto;
}

.envelope-hotspot:focus-visible,
.letter-close:focus-visible {
  outline: 2px solid var(--ink-accent);
  outline-offset: 4px;
}

/* ==========================================================================
   Expandable Love Letter Modal
   ========================================================================== */

.letter-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--letter-backdrop);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.6s ease;
}

.letter-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.letter-paper {
  position: relative;
  width: 100%;
  max-width: 470px;
  max-height: min(82dvh, 620px);
  overflow-y: auto;
  padding: 34px 34px 28px;
  border-radius: 18px;
  border: 1px solid var(--letter-border);
  background: var(--letter-bg);
  box-shadow: var(--letter-shadow);
  color: var(--letter-text);
  transform: translateY(22px) scale(0.96);
  transition:
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.6s ease,
    border-color 0.6s ease,
    color 0.6s ease;
  user-select: text;
  -webkit-user-select: text;
}

.letter-backdrop.open .letter-paper {
  transform: translateY(0) scale(1);
}

/* Delicate inset gold stationery border */
.letter-paper__filigree {
  position: absolute;
  inset: 10px;
  border-radius: 11px;
  border: 1px solid var(--letter-inner-line);
  pointer-events: none;
}

.letter-paper__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.letter-paper__eyebrow {
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--ink-accent);
}

.letter-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--letter-muted);
  cursor: pointer;
  outline: none;
  transition: background-color 0.25s ease, color 0.25s ease, transform 0.2s ease;
}

.letter-close:hover {
  background: rgba(196, 152, 98, 0.14);
  color: var(--ink-primary);
}

.letter-close:active {
  transform: scale(0.92);
}

.letter-paper__title {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(1.7rem, 4vw, 2.05rem);
  font-weight: 500;
  color: var(--letter-title);
  margin-bottom: 18px;
  line-height: 1.2;
}

.letter-paper__body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-family: var(--font-serif);
  font-size: clamp(1.06rem, 2.4vw, 1.18rem);
  line-height: 1.72;
  color: var(--letter-text);
}

.letter-paper__footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--letter-inner-line);
}

.letter-paper__date {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--letter-muted);
}

.letter-paper__sig-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.letter-paper__signature {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--letter-title);
}

.letter-paper__rose-mark {
  font-size: 0.92rem;
  color: var(--ink-accent);
}

@media (max-width: 540px) {
  .letter-paper {
    padding: 26px 24px 22px;
  }
}
