:root {
  --paper: #f6f1e7;
  --ink: #403a31;
  --faint: #8f8574;
  --hairline: #d8d0bf;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Cormorant Garamond', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100svh;
  overflow: hidden;
}

::selection {
  background: #e4dbc8;
}

main {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: relative;
  z-index: 1;
}

.stage {
  margin: 0;
  text-align: center;
  padding-bottom: 3.6rem;
}

.stage svg {
  display: block;
  margin: 0 auto;
  width: min(88vw, 500px);
  height: auto;
  max-height: 66svh;
  overflow: visible; /* falling petals and pollen drift past the frame */
}

.stage svg.appear {
  animation: appear 1.4s ease both;
}

@keyframes appear {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---- environmental light ------------------------------------------------ */

.atmo {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.atmo-glow {
  position: absolute;
  left: 50%;
  top: 36%;
  width: 130vmin;
  height: 130vmin;
  background: radial-gradient(circle, rgba(255, 250, 230, 0.95) 0%, rgba(255, 243, 210, 0.4) 38%, rgba(255, 243, 210, 0) 68%);
  animation: sunshift 46s ease-in-out infinite alternate;
}

.atmo-rays {
  position: absolute;
  inset: -12%;
  background: repeating-linear-gradient(72deg, rgba(255, 235, 185, 0) 0px, rgba(255, 235, 185, 0.55) 46px, rgba(255, 235, 185, 0) 118px, rgba(255, 235, 185, 0) 200px);
  mix-blend-mode: soft-light;
  opacity: 0.85;
  filter: blur(13px);
  animation: raydrift 38s linear infinite alternate;
}

.atmo-rays--2 {
  background: repeating-linear-gradient(64deg, rgba(255, 228, 170, 0) 0px, rgba(255, 228, 170, 0.35) 90px, rgba(255, 228, 170, 0) 210px);
  opacity: 0.7;
  filter: blur(18px);
  animation: raydrift 57s linear infinite alternate-reverse;
}

.atmo-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 42%, rgba(0, 0, 0, 0) 52%, rgba(92, 76, 50, 0.17) 100%);
}

@keyframes sunshift {
  from { transform: translate(-58%, -52%) scale(1); }
  to { transform: translate(-42%, -46%) scale(1.12); }
}

@keyframes raydrift {
  from { transform: translateX(-60px); }
  to { transform: translateX(60px); }
}

.stage-shadow {
  width: min(56vw, 280px);
  height: 24px;
  margin: -34px auto 10px;
  background: radial-gradient(ellipse at center, rgba(58, 44, 24, 0.28), rgba(58, 44, 24, 0) 68%);
  filter: blur(6px);
  animation: breathe 7s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scaleX(1); opacity: 0.9; }
  50% { transform: scaleX(1.07); opacity: 1; }
}

.caption {
  margin: 0;
  opacity: 0;
  transition: opacity 2.6s ease;
}

.caption.shown {
  opacity: 1;
}

.caption-line {
  margin: 0;
  font-style: italic;
  font-size: 1.06rem;
  letter-spacing: 0.05em;
}

.caption-date {
  margin: 0.4em 0 0;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: var(--faint);
}

.caption-species {
  margin: 0.65em 0 0;
  font-style: italic;
  font-size: 0.7rem;
  letter-spacing: 0.09em;
  color: var(--faint);
  opacity: 0.85;
}

.caption-words {
  margin: 1.15em auto 0;
  max-width: 34ch;
  font-style: italic;
  font-size: 0.88rem;
  line-height: 1.55;
  letter-spacing: 0.02em;
  color: var(--ink);
  opacity: 0.78;
}

.caption-next {
  margin: 1.25em 0 0;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  color: var(--faint);
  opacity: 0.62;
}

.footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(1.1rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  gap: 1.8rem;
  z-index: 2;
}

.quiet-link {
  appearance: none;
  background: none;
  border: none;
  padding: 0.7em 0.5em;
  font: inherit;
  font-size: 0.68rem;
  letter-spacing: 0.24em;
  color: var(--faint);
  cursor: pointer;
  touch-action: manipulation;
  opacity: 0;
  transition: opacity 1.8s ease, color 0.6s ease;
}

.quiet-link.shown {
  opacity: 1;
}

.quiet-link:hover {
  color: var(--ink);
}

.quiet-link:focus-visible {
  outline: 1px dotted var(--faint);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

/* ---- the garden -------------------------------------------------------- */

.garden {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--paper);
  overflow-y: auto;
  padding: 9vh 7vw calc(10vh + env(safe-area-inset-bottom, 0px));
  -webkit-overflow-scrolling: touch;
}

.garden-title {
  margin: 0 0 6vh;
  text-align: center;
  font-style: italic;
  font-size: 1rem;
  letter-spacing: 0.08em;
}

.garden-close {
  position: fixed;
  top: calc(0.9rem + env(safe-area-inset-top, 0px));
  right: 1.2rem;
}

.garden-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 132px));
  justify-content: center;
  gap: 4vh 2.5vw;
  max-width: 860px;
  margin: 0 auto;
}

.garden-day {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: block;
  font: inherit;
  color: inherit;
}

.garden-day svg {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0.85;
  transition: opacity 0.5s ease;
}

.garden-day:hover svg,
.garden-day:focus-visible svg {
  opacity: 1;
}

.garden-day:focus-visible {
  outline: 1px dotted var(--faint);
  outline-offset: 4px;
}

.garden-date {
  display: block;
  margin-top: 0.55em;
  text-align: center;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--faint);
}

.noscript {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  font-style: italic;
}

/* ---- the gate ---------------------------------------------------------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  transition: opacity 0.95s ease;
}

.gate-open {
  opacity: 0;
  pointer-events: none;
}

.gate-line {
  margin: 0;
  font-style: italic;
  font-size: 1rem;
  letter-spacing: 0.06em;
}

.gate-dots {
  display: flex;
  gap: 1rem;
}

.gate-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid var(--faint);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.gate-dot.filled {
  background-color: var(--ink);
  border-color: var(--ink);
}

.gate-pad {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 0.85rem 1.4rem;
  justify-items: center;
  align-items: center;
}

.gate-key {
  appearance: none;
  width: 3.1rem;
  height: 3.1rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: none;
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.4s ease, background-color 0.3s ease;
}

.gate-key:hover {
  border-color: var(--faint);
}

.gate-key:active {
  background-color: rgba(64, 58, 49, 0.06);
}

.gate-key:focus-visible {
  outline: none;
  border-color: var(--ink);
}

.gate:focus {
  outline: none;
}

.gate-hint {
  margin: 0;
  font-style: italic;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--faint);
  opacity: 0.8;
}

.gate-key--quiet {
  border-color: transparent;
  color: var(--faint);
  font-size: 1rem;
}

.gate-key--quiet:hover {
  border-color: transparent;
  color: var(--ink);
}

.gate-spacer {
  width: 3.1rem;
  height: 3.1rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.gate-error {
  margin: 0;
  min-height: 1.3em;
  font-style: italic;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--faint);
}

.gate-shake {
  animation: gate-shake 0.35s ease;
}

@keyframes gate-shake {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-4px); }
  65% { transform: translateX(3px); }
}

/* ---- stillness for those who ask for it -------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .caption,
  .quiet-link,
  .garden-day svg,
  .gate,
  .gate-dot,
  .gate-key {
    transition: none;
  }

  .stage svg.appear,
  .gate-shake,
  .atmo-glow,
  .atmo-rays,
  .stage-shadow {
    animation: none;
  }
}
