/* ═══════════════════════════════════════════════
   Drift or Sink — Paper / Stationery Theme
   ═══════════════════════════════════════════════ */

/* --- Tokens --- */
:root {
  /* Navy gradient endpoints */
  --color-deep: #0f172a;
  --color-deep-end: #1e293b;

  /* Paper surfaces */
  --color-parchment: #fdfbf7;
  --color-antique: #f0ece2;
  --color-ink: #2c2418;
  --color-ink-muted: #7a7060;

  /* Sea / accent */
  --color-foam: hsl(160, 35%, 65%);
  --color-gold: hsl(40, 55%, 62%);
  --color-gold-dim: hsl(40, 40%, 38%);
  --color-wave-1: hsl(200, 50%, 25%);
  --color-wave-2: hsl(210, 45%, 20%);
  --color-wave-3: hsl(195, 40%, 30%);

  /* Text on dark bg */
  --color-text: hsl(200, 20%, 88%);
  --color-text-muted: hsl(200, 15%, 55%);

  /* Typography */
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;

  /* Timing */
  --transition-view: 600ms cubic-bezier(0.22, 1, 0.36, 1);
  --transition-fast: 200ms ease;

  /* Paper shadow */
  --shadow-paper:
    0 1px 3px rgba(0, 0, 0, 0.06),
    0 4px 12px rgba(0, 0, 0, 0.04);
  --shadow-paper-hover:
    0 2px 6px rgba(0, 0, 0, 0.08),
    0 8px 24px rgba(0, 0, 0, 0.06);
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  font-weight: 300;
  color: var(--color-text);
  background: linear-gradient(170deg, var(--color-deep) 0%, var(--color-deep-end) 100%);
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════════
   Views — transitions (rising effect)
   ═══════════════════════════════════════════════ */
.view {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity var(--transition-view),
    transform var(--transition-view);
  pointer-events: none;
}

.view.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  z-index: 10;
}

/* ═══════════════════════════════════════════════
   Buttons — base (48px min touch target)
   ═══════════════════════════════════════════════ */
.btn {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  min-height: 48px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible {
  box-shadow: 0 0 0 2px var(--color-foam);
}

/* Primary — "Enter the sea" */
.btn--primary {
  margin-top: 2.5rem;
  padding: 0.9rem 2.8rem;
  background: linear-gradient(135deg, var(--color-gold-dim), var(--color-gold));
  color: var(--color-deep);
  font-weight: 500;
}

.btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px hsla(40, 55%, 62%, 0.3);
}

.btn--primary:active {
  transform: translateY(0);
}

/* Ghost — "Write" / "Discover" / "Return" */
.btn--ghost {
  padding: 0.8rem 2.4rem;
  background: transparent;
  color: var(--color-foam);
  border: 1px solid hsla(160, 35%, 65%, 0.25);
  backdrop-filter: blur(4px);
}

.btn--ghost:hover {
  background: hsla(160, 35%, 65%, 0.08);
  border-color: hsla(160, 35%, 65%, 0.45);
}

.btn--ghost:active {
  background: hsla(160, 35%, 65%, 0.14);
}

/* Release — premium seafoam-to-gold */
.btn--release {
  padding: 0.8rem 2rem;
  background: linear-gradient(135deg, var(--color-gold-dim) 0%, var(--color-gold) 100%);
  color: var(--color-deep);
  font-weight: 500;
  border: 1px solid hsla(40, 55%, 62%, 0.15);
}

.btn--release:disabled {
  opacity: 0.3;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.btn--release:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px hsla(40, 55%, 62%, 0.35);
}

.btn--release:not(:disabled):active {
  transform: translateY(0);
}

/* Back arrow */
.btn--back {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: hsla(215, 30%, 15%, 0.6);
  color: var(--color-foam);
  border: 1px solid hsla(160, 35%, 65%, 0.15);
  border-radius: 50%;
  backdrop-filter: blur(8px);
  z-index: 20;
}

.btn--back:hover {
  background: hsla(215, 30%, 15%, 0.85);
}

/* ═══════════════════════════════════════════════
   Onboarding
   ═══════════════════════════════════════════════ */
.onboarding-content {
  max-width: 440px;
  padding: 2.5rem;
  text-align: center;
}

.onboarding-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  color: var(--color-foam);
  margin-bottom: 2rem;
  letter-spacing: 0.01em;
}

.onboarding-text p {
  font-size: 1.05rem;
  line-height: 1.75;
  margin-bottom: 0.75rem;
  color: var(--color-text);
}

.onboarding-guarantee {
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.onboarding-privacy-link {
  display: block;
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-decoration: none;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.onboarding-privacy-link:hover {
  opacity: 1;
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════
   Sea / Idle — ambient waves (SVG-based)
   ═══════════════════════════════════════════════ */
.sea-ambient {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.wave {
  position: absolute;
  left: 0;
  width: 200%;
  height: 120px;
  background-repeat: repeat-x;
  background-size: 50% 100%;
}

/* Wave 1 — top layer, fastest */
.wave--1 {
  bottom: 0;
  opacity: 0.15;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 120' preserveAspectRatio='none'%3E%3Cpath d='M0,60 C200,100 400,20 600,60 C800,100 1000,20 1200,60 L1200,120 L0,120Z' fill='hsl(200,50%25,25%25)'/%3E%3C/svg%3E");
  animation: wave-drift 8s linear infinite;
}

/* Wave 2 — middle, medium speed */
.wave--2 {
  bottom: -10px;
  opacity: 0.10;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 120' preserveAspectRatio='none'%3E%3Cpath d='M0,40 C150,80 350,10 600,50 C850,90 1050,20 1200,40 L1200,120 L0,120Z' fill='hsl(210,45%25,20%25)'/%3E%3C/svg%3E");
  animation: wave-drift 12s linear infinite reverse;
  height: 140px;
}

/* Wave 3 — back layer, slowest */
.wave--3 {
  bottom: -20px;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 120' preserveAspectRatio='none'%3E%3Cpath d='M0,80 C300,30 500,100 700,50 C900,0 1100,70 1200,80 L1200,120 L0,120Z' fill='hsl(195,40%25,30%25)'/%3E%3C/svg%3E");
  animation: wave-drift 18s linear infinite;
  height: 160px;
}

@keyframes wave-drift {
  0% {
    background-position-x: 0;
  }

  100% {
    background-position-x: 50%;
  }
}

.idle-content {
  text-align: center;
  z-index: 1;
}

.idle-tagline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.2rem, 3.5vw, 1.6rem);
  color: var(--color-foam);
  opacity: 0.8;
  margin-bottom: 3rem;
  letter-spacing: 0.01em;
}

.idle-actions {
  display: flex;
  gap: 1.2rem;
  justify-content: center;
}

/* ═══════════════════════════════════════════════
   Write — mobile keyboard handling (flexbox)
   ═══════════════════════════════════════════════ */
#view-write {
  align-items: stretch;
}

.write-content {
  width: 100%;
  max-width: 560px;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 5rem 2rem 2rem;
  margin: 0 auto;
}

.write-paper-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--color-parchment);
  border-radius: 6px;
  box-shadow: var(--shadow-paper);
  transform: rotate(-0.6deg);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
  overflow: hidden;
}

.write-paper-wrapper:focus-within {
  box-shadow: var(--shadow-paper-hover);
  transform: rotate(0deg);
}

.write-textarea {
  flex: 1;
  min-height: 0;
  width: 100%;
  resize: none;
  border: none;
  outline: none;
  padding: 1.5rem 1.5rem 0.5rem;
  background: transparent;
  color: var(--color-ink);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.1rem;
  line-height: 1.6;
  caret-color: var(--color-gold-dim);
}

.write-textarea::placeholder {
  color: var(--color-ink-muted);
  font-style: italic;
  opacity: 0.6;
}

.write-signature {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0.5rem 1.5rem 1.5rem;
  gap: 0.4rem;
  color: var(--color-ink-muted);
  font-family: var(--font-display);
  font-style: italic;
}

.signature-prefix {
  font-size: 1.1rem;
  opacity: 0.7;
}

.write-pseudonym {
  background: transparent;
  border: none;
  border-bottom: 1px solid hsla(40, 30%, 50%, 0.15);
  outline: none;
  color: var(--color-ink);
  font-family: inherit;
  font-style: inherit;
  font-size: 1.1rem;
  width: 160px;
  padding: 0 4px;
  transition: border-bottom-color var(--transition-fast);
}

.write-pseudonym:focus {
  border-bottom-color: var(--color-gold);
}

.write-pseudonym::placeholder {
  color: hsla(200, 15%, 55%, 0.4);
}

/* Release actions container */
.write-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-top: 1.5rem;
  flex-shrink: 0;
  border-top: 1px solid hsla(40, 30%, 50%, 0.12);
}

/* Let it Drift — Hero action */
.btn--drift {
  flex: 2;
  padding: 0.8rem 2rem;
  background: linear-gradient(135deg, var(--color-gold-dim) 0%, var(--color-gold) 100%);
  color: var(--color-deep);
  font-weight: 500;
  border: 1px solid hsla(40, 55%, 62%, 0.15);
  box-shadow: 0 4px 12px hsla(40, 55%, 62%, 0.2);
}

.btn--drift:disabled {
  opacity: 0.3;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.btn--drift:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px hsla(40, 55%, 62%, 0.35);
}

/* Let it Sink — Discreet ghost action with tooltip */
.btn--sink {
  flex: 1;
  padding: 0.8rem 1.2rem;
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid hsla(200, 15%, 55%, 0.2);
  font-size: 0.85rem;
  font-style: italic;
  position: relative;
}

.btn--sink:disabled {
  opacity: 0.3;
  cursor: default;
}

.btn--sink:not(:disabled):hover {
  background: hsla(200, 15%, 55%, 0.05);
  color: var(--color-text);
  border-color: hsla(200, 15%, 55%, 0.4);
}

/* Tooltip */
.btn--sink .tooltip {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(5px);
  background: var(--color-deep-end);
  color: var(--color-foam);
  padding: 0.6rem 1rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-style: italic;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  border: 1px solid hsla(160, 35%, 65%, 0.1);
  z-index: 100;
}

.btn--sink .tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: var(--color-deep-end) transparent transparent transparent;
}

.btn--sink:hover .tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ═══════════════════════════════════════════════
   Release Animation — "The Departure"
   ═══════════════════════════════════════════════ */
.release-content {
  text-align: center;
}

.release-icon {
  margin-bottom: 2rem;
}

.letter-icon {
  width: 64px;
  height: 64px;
  color: var(--color-foam);
}

/* Animation variants */
.mode-drifting .letter-icon {
  animation: letter-depart 2.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.mode-sinking .letter-icon {
  animation: letter-sink 2.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes letter-depart {
  0% {
    transform: translateY(0) scale(1) rotate(0deg);
    opacity: 1;
  }

  20% {
    transform: translateY(-10px) scale(1.08) rotate(1deg);
    opacity: 1;
  }

  100% {
    transform: translateY(-300px) scale(0.2) rotate(-12deg);
    opacity: 0;
  }
}

@keyframes letter-sink {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
    color: var(--color-foam);
  }

  20% {
    transform: translateY(5px) scale(0.98);
    opacity: 1;
    color: var(--color-foam);
  }

  100% {
    transform: translateY(150px) scale(0.8);
    opacity: 0;
    color: #000;
    /* Get darker */
  }
}

.release-text {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--color-text-muted);
  animation: release-fade 2.8s ease-in forwards;
}

@keyframes release-fade {

  0%,
  60% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

/* ═══════════════════════════════════════════════
   Discover — parchment message card
   ═══════════════════════════════════════════════ */
.discover-content {
  max-width: 520px;
  padding: 2rem;
  text-align: center;
}

/* Real user message — off-white parchment */
.discover-message {
  margin-bottom: 3rem;
  padding: 2rem 2.25rem;
  background: var(--color-parchment);
  border-radius: 6px;
  box-shadow: var(--shadow-paper);
  transform: rotate(1.2deg);
  animation: paper-arrive 0.8s ease-out;
}

.discover-message .discover-text {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--color-ink);
  border: none;
  margin: 0;
  padding: 0;
  quotes: none;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
}

.discover-message .discover-pseudonym {
  margin-top: 1.5rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--color-ink-muted);
  font-style: italic;
  text-align: right;
}

/* Empty state (quotes) — antique sepia-tinted paper */
.discover-empty {
  margin-bottom: 3rem;
  padding: 2rem 2.25rem;
  background: var(--color-antique);
  border-radius: 6px;
  box-shadow: var(--shadow-paper);
  transform: rotate(-1.5deg);
  border: 1px solid hsla(35, 30%, 70%, 0.3);
  animation: paper-arrive 0.8s ease-out;
}

.discover-empty .discover-text {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--color-ink);
  border: none;
  margin: 0;
  padding: 0;
  quotes: none;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
}

.discover-empty .discover-pseudonym {
  margin-top: 1.5rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--color-ink-muted);
  font-style: italic;
  text-align: right;
}

.discover-quote-label {
  margin-top: 1.5rem;
  font-size: 0.75rem;
  color: var(--color-ink-muted);
  opacity: 0.5;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  text-align: center;
}

@keyframes paper-arrive {
  from {
    opacity: 0;
    transform: translateY(8px) rotate(0deg) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) rotate(var(--paper-rotate, 1.2deg)) scale(1);
  }
}

.discover-message {
  --paper-rotate: 1.2deg;
}

.discover-empty {
  --paper-rotate: -1.5deg;
}

/* ═══════════════════════════════════════════════
   Consent bar
   ═══════════════════════════════════════════════ */
.consent-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 1rem 2rem;
  background: hsla(215, 50%, 8%, 0.88);
  backdrop-filter: blur(12px);
  border-top: 1px solid hsla(160, 35%, 65%, 0.1);
  animation: slide-up 0.4s ease-out;
}

.consent-bar[hidden] {
  display: none;
}

.consent-text {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  max-width: 460px;
}

.consent-link {
  color: var(--color-foam);
  text-decoration: none;
  opacity: 0.8;
  transition: opacity var(--transition-fast);
}

.consent-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.consent-actions {
  display: flex;
  gap: 0.6rem;
  flex-shrink: 0;
}

.btn--consent {
  padding: 0.5rem 1.4rem;
  min-height: 48px;
  font-size: 0.8rem;
  background: transparent;
  color: var(--color-foam);
  border: 1px solid hsla(160, 35%, 65%, 0.25);
  border-radius: 999px;
}

.btn--consent:hover {
  background: hsla(160, 35%, 65%, 0.08);
  border-color: hsla(160, 35%, 65%, 0.45);
}

@keyframes slide-up {
  from {
    transform: translateY(100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ═══════════════════════════════════════════════
   Language Switcher
   ═══════════════════════════════════════════════ */
.lang-switcher {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.8rem;
  background: hsla(215, 30%, 15%, 0.4);
  backdrop-filter: blur(8px);
  border: 1px solid hsla(160, 35%, 65%, 0.1);
  border-radius: 999px;
  transition: all var(--transition-fast);
}

.lang-switcher:hover {
  background: hsla(215, 30%, 15%, 0.7);
  border-color: hsla(160, 35%, 65%, 0.2);
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: 0.5rem 0.6rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.lang-btn:hover {
  color: var(--color-foam);
}

.lang-btn.active {
  color: var(--color-foam);
  pointer-events: none;
}

.lang-sep {
  color: hsla(200, 15%, 55%, 0.3);
  font-size: 0.7rem;
  user-select: none;
}

/* Adjust for consent bar */
#consent-bar:not([hidden])~.lang-switcher {
  bottom: 5rem;
}

/* ═══════════════════════════════════════════════
   Responsive — mobile-first
   ═══════════════════════════════════════════════ */
@media (max-width: 480px) {
  .onboarding-content {
    padding: 2rem 1.5rem;
  }

  .write-content {
    padding: 4.5rem 1.25rem 1.25rem;
  }

  .write-textarea {
    padding: 1.25rem;
    font-size: 1rem;
  }

  .idle-actions {
    flex-direction: column;
    align-items: center;
  }

  .discover-content {
    padding: 1.5rem;
  }

  .discover-message,
  .discover-empty {
    padding: 1.5rem 1.5rem;
  }

  .consent-bar {
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    text-align: center;
  }

  .consent-text {
    font-size: 0.78rem;
  }
}

/* Taller viewports — let waves breathe */
@media (min-height: 700px) {
  .wave--1 {
    height: 160px;
  }

  .wave--2 {
    height: 180px;
  }

  .wave--3 {
    height: 200px;
  }
}

/* ═══════════════════════════════════════════════
   Honeypot Support
   ═══════════════════════════════════════════════ */
.hp-field {
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
  height: 0;
  width: 0;
  z-index: -1;
  pointer-events: none;
}