/* ── Sky Notes ──────────────────────────────────────────────── */

:root {
  --sky-top:   #00CFFF;
  --sky-mid:   #D4AACC;
  --sky-bot:   #FFF9F0;
  --sky-text:  #3a4060;
  --sky-soft:  rgba(58, 64, 96, 0.62);
  --sky-warm:  #fde0d2;
  --sky-cool:  #d5e8f5;
  --cloud-shadow: 0 14px 28px -10px rgba(70, 80, 130, 0.18);
}

/* The .sky wrapper now hosts MorningSkyBackground (which draws the
   gradient + ambient clouds + horizon haze). No background of its own. */
.sky {
  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
}

/* Warm sunrise haze — peach-gold glow blooms up from the horizon,
   keeping the bottom area warm and legible without darkening the sky. */
.sky::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: radial-gradient(ellipse 120% 60% at 50% 110%,
    rgba(255, 200, 140, 0.45) 0%,
    rgba(255, 220, 180, 0.20) 45%,
    transparent 70%);
}

/* ── title + tagline ───────────────────────────────────────── */

.masthead {
  position: absolute;
  top: clamp(20px, 5vh, 56px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  text-align: center;
  pointer-events: none;
  color: var(--sky-text);
  user-select: none;
  text-wrap: balance;
}

.masthead h1 {
  margin: 0;
  font-family: 'Caveat', 'Quicksand', cursive;
  font-weight: 500;
  font-size: clamp(34px, 5.6vw, 64px);
  line-height: 0.95;
  letter-spacing: 0.005em;
  color: var(--sky-text);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.masthead p {
  margin: 8px 0 0;
  font-size: clamp(12px, 1.05vw, 14px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sky-soft);
  font-weight: 500;
}

/* ── cloud field ───────────────────────────────────────────── */

.field {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.cloud {
  position: absolute;
  top: var(--lane);
  left: 100%;
  width: var(--w, 260px);
  cursor: pointer;
  touch-action: none;
  animation: drift var(--dur, 160s) linear var(--delay, 0s) infinite;
  will-change: transform, left;
  z-index: 1;
  transform-origin: center 25%;
}

.cloud:hover,
.cloud.is-paused {
  animation-play-state: paused;
  z-index: 9;
}

.cloud.dragging {
  cursor: grabbing;
  z-index: 99;
  animation-play-state: paused;
}

.cloud.poofing {
  animation: poof 600ms cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
  pointer-events: none;
}

@keyframes poof {
  0%   { transform: scale(1.0) rotate(0deg);  opacity: 1;   }
  25%  { transform: scale(1.2) rotate(-6deg); opacity: 1;   }
  60%  { transform: scale(1.8) rotate(12deg); opacity: 0.5; }
  100% { transform: scale(2.5) rotate(18deg); opacity: 0;   }
}

.cloud-img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  user-select: none;
}

/* The exact inset is set inline per cloud variant (CLOUD_TEXT_INSETS in
   sky-notes.jsx, traced from the Figma cloud01–cloud11 frames). The inset
   here is only a fallback. */
.cloud-content {
  position: absolute;
  inset: 46% 20% 10% 20%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 4px;
  pointer-events: none;
  color: var(--sky-text);
}

.cloud-content .q-label {
  font-size: clamp(6px, calc(var(--w, 26vw) * 0.035), 13px);
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  opacity: 0.42;
  line-height: 1.2;
  margin-bottom: 2px;
  flex-shrink: 0;
  /* Single line by default so it never pushes the answer out of the cloud body */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}


.cloud-content .answer {
  /* Scale with the cloud itself (--w is the cloud width in vw), so text
     stays proportional to its drawn text box at any cloud size. */
  font-size: clamp(9px, calc(var(--w, 26vw) * 0.050), 22px);
  line-height: 1.32;
  font-weight: 500;
  margin: 0;
  max-width: 96%;
  text-wrap: pretty;
  opacity: 0.78;
  transition: opacity 280ms ease;
  /* clamp the preview to the lines that fit this cloud's drawn text box
     (--clamp comes from CLOUD_TEXT_AREAS in sky-notes.jsx). flex-shrink 0
     keeps the clamped block at natural height — a couple of px of
     centred spill beats a mid-line cut at the box edge. */
  flex-shrink: 0;
  display: -webkit-box;
  -webkit-line-clamp: var(--clamp, 4);
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cloud:hover .cloud-content .answer {
  opacity: 1;
}

.cloud-content .meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Caveat', cursive;
  font-size: clamp(10px, calc(var(--w, 26vw) * 0.038), 18px);
  color: var(--sky-text);
  opacity: 0.72;
  margin-top: 4px;
  flex-shrink: 0;
  line-height: 1;
}

.cloud-content .meta .dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: currentColor; opacity: 0.5;
}

@keyframes drift {
  from { left: 110%; }
  to   { left: -32%; }
}

/* "Creative" clouds ride the even lanes and drift the other way. */
.cloud.ltr { animation-name: drift-ltr; }

@keyframes drift-ltr {
  from { left: -32%; }
  to   { left: 110%; }
}

/* ── rising cloud (newly submitted note) ───────────────────── */

/* All drifting clouds pause while the new cloud's entry animation plays */
.field.paused .cloud {
  animation-play-state: paused;
}

/* Soft fog layer that dims the sky while the new cloud rises */
.rising-scrim {
  position: fixed;
  inset: 0;
  z-index: 7;
  background: rgba(240, 245, 255, 0.52);
  -webkit-backdrop-filter: blur(6px) saturate(80%);
  backdrop-filter: blur(6px) saturate(80%);
  pointer-events: none;
  animation: rising-scrim-fade 3500ms ease forwards;
}

@keyframes rising-scrim-fade {
  0%        { opacity: 0; }
  14%       { opacity: 1; }
  72%       { opacity: 1; }
  100%      { opacity: 0; }
}

/* The wrapper rises from off-screen to the upper-centre of the sky */
.rising {
  position: absolute;
  top: 14%;
  left: 50%;
  transform: translate(-50%, 90vh) scale(0.35);
  z-index: 8;
  opacity: 0;
  pointer-events: none;
  animation: rise 3500ms cubic-bezier(0.22, 0.9, 0.36, 1) forwards;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

@keyframes rise {
  0%   { transform: translate(-50%, 90vh) scale(0.35); opacity: 0; }
  16%  { opacity: 1; }
  65%  { transform: translate(-50%, 0) scale(1.04); opacity: 1; }
  100% { transform: translate(-50%, 0) scale(1); opacity: 0.88; }
}

/* Cloud image + text overlay */
.rising-cloud {
  position: relative;
  width: min(560px, 60vw);
  --w: min(560px, 60vw);
}

/* Caption rides inside the wrapper — inherits the rise movement */
.rising-caption {
  font-family: 'Caveat', cursive;
  font-size: 22px;
  color: var(--sky-text);
  opacity: 0;
  animation: caption-fade 3500ms ease-out forwards;
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
}

@keyframes caption-fade {
  0%, 12%  { opacity: 0; }
  25%, 72% { opacity: 0.88; }
  100%     { opacity: 0; }
}

/* ── add-note button ───────────────────────────────────────── */

.add-btn {
  position: fixed;
  left: 50%;
  bottom: clamp(20px, 4vh, 37px);
  transform: translateX(-50%);
  z-index: 10;
  appearance: none;
  border: 0;
  padding: 12px 24px;
  border-radius: 24px;
  background: rgba(254, 254, 254, 0.6);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
  color: #222;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 6px 20px 0 rgba(32, 22, 6, 0.08);
  transition: transform 220ms cubic-bezier(0.22, 0.9, 0.36, 1),
              box-shadow 220ms ease,
              background 220ms ease;
}

.add-btn:hover {
  transform: translateX(-50%) translateY(-2px);
  background: rgba(254, 254, 254, 0.85);
  box-shadow: 0 10px 28px 0 rgba(32, 22, 6, 0.12);
}

.add-btn:active { transform: translateX(-50%) translateY(0); }

/* ── legend ────────────────────────────────────────────────── */

.legend {
  position: fixed;
  left: clamp(16px, 2.5vw, 32px);
  bottom: clamp(20px, 4vh, 36px);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.45);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border: 0.5px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 6px 20px -8px rgba(60, 70, 110, 0.18);
  font-size: 11.5px;
  color: var(--sky-soft);
  letter-spacing: 0.02em;
  max-width: min(280px, 40vw);
}

.legend-title {
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sky-soft);
  opacity: 0.78;
  margin-bottom: 2px;
  font-weight: 600;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 9px;
  line-height: 1.25;
  color: var(--sky-text);
  font-weight: 500;
}

.legend-swatch {
  width: 18px; height: 12px;
  border-radius: 6px;
  background: var(--swatch);
  box-shadow: 0 0 0 0.5px rgba(0,0,0,0.04), 0 1px 2px rgba(60,70,110,0.08);
  flex-shrink: 0;
}

/* count chip in the corner */
.count {
  display: none;
}

.count b {
  font-family: 'Caveat', cursive;
  font-weight: 500;
  font-size: 20px;
  color: var(--sky-text);
  letter-spacing: 0;
}

/* ── modal: composer and note view ─────────────────────────── */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: radial-gradient(120% 80% at 50% 60%,
              rgba(255, 245, 235, 0.55) 0%,
              rgba(180, 195, 220, 0.5) 60%,
              rgba(120, 135, 175, 0.52) 100%);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  animation: scrim-in 280ms ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}

@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }

/* ── composer sheet (3-step wizard) ───────────────────── */

.sheet {
  width: min(664px, calc(100% - 48px));
  background: rgba(254, 254, 254, 0.5);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  backdrop-filter: blur(28px) saturate(140%);
  border: 0.5px solid rgba(254, 254, 254, 0.9);
  border-radius: 24px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  min-height: 380px;
  color: #222;
  animation: sheet-in 380ms cubic-bezier(0.22, 0.9, 0.36, 1);
}

@keyframes sheet-in {
  from { transform: translateY(14px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.step-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.step-question {
  font-size: 15px;
  font-weight: 700;
  color: #222;
  margin: 0;
  line-height: 1.4;
  text-align: center;
}

.step-area {
  width: 100%;
  flex: 1;
  min-height: 120px;
  background: #fefefe;
  border: none;
  border-radius: 13px;
  padding: 16px;
  font-family: inherit;
  font-size: 15px;
  color: #222;
  resize: none;
  outline: none;
  box-sizing: border-box;
  line-height: 1.5;
}

.step-area::placeholder { color: #aaa; }

.step-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.step-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-label {
  font-size: 15px;
  font-weight: 400;
  color: #222;
  margin: 0;
}

.step-input {
  width: 100%;
  background: #fefefe;
  border: none;
  border-radius: 13px;
  padding: 17px 16px;
  font-family: inherit;
  font-size: 15px;
  color: #222;
  outline: none;
  box-sizing: border-box;
}

.step-input::placeholder { color: #888; }

.step-consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: #444;
  cursor: pointer;
  line-height: 1.4;
}

.step-consent input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: #7ba7bc;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.step-footer {
  display: flex;
  align-items: center;
  margin-top: 24px;
  flex-shrink: 0;
}

.step-counter {
  flex: 1;
  text-align: center;
  font-size: 15px;
  color: #222;
  font-weight: 400;
  pointer-events: none;
}

.step-btn {
  appearance: none;
  border: none;
  border-radius: 24px;
  padding: 12px 16px;
  flex: 1;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 160ms ease, transform 160ms ease;
}

.step-btn.ghost {
  background: transparent;
  color: #222;
  text-align: left;
}

.step-btn.ghost:hover { opacity: 0.6; }

.step-btn.primary {
  background: #222;
  color: #fefefe;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.step-btn.primary::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(270deg, #f43f5e, #c026d3, #7c3aed, #2563eb, #0891b2, #f43f5e);
  background-size: 400% 400%;
  animation: btn-rainbow 2.4s ease infinite;
  opacity: 0;
  transition: opacity 380ms ease;
}

@keyframes btn-rainbow {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.step-btn.primary:hover:not(:disabled) { opacity: 1; }
.step-btn.primary:hover:not(:disabled)::before { opacity: 1; }
.step-btn.primary:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── note-view modal (when you click a cloud) ──────────────── */

.note-view {
  width: min(660px, 92vw);
  position: relative;
  text-align: center;
  animation: sheet-in 420ms cubic-bezier(0.22, 0.9, 0.36, 1);
}

.note-view .cloud-art {
  position: relative;
  width: 100%;
  margin: 0 auto;
  filter: drop-shadow(0 24px 40px -14px rgba(50,60,100,0.3));
}

/* Content block inside the enlarged cloud.
   Label always at top, meta always at bottom, answer fills the middle. */
.note-view .nv-content {
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  gap: 4px;
  color: var(--sky-text);
  overflow: hidden;
}

.note-view .nv-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.45;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  flex-shrink: 0;
}

.note-view .nv-answer {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-size: clamp(15px, 1.8vw, 20px);
  font-weight: 500;
  line-height: 1.4;
  text-wrap: pretty;
  overflow: hidden;
  text-align: center;
}

.note-view .nv-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Caveat', cursive;
  font-size: clamp(15px, 1.6vw, 18px);
  opacity: 0.72;
  line-height: 1;
  flex-shrink: 0;
}

.note-view .nv-meta .dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: currentColor; opacity: 0.5;
}

.note-view .x {
  position: absolute;
  top: -6px; right: -6px;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 0;
  background: rgba(255,255,255,0.95);
  color: var(--sky-text);
  font-size: 17px;
  cursor: pointer;
  display: inline-flex;
  align-items: center; justify-content: center;
  box-shadow: 0 8px 22px -8px rgba(58, 64, 96, 0.35);
}

/* ── responsive ────────────────────────────────────────────── */

/* Tablet ≤ 1000px */
@media (max-width: 1000px) {
  .scrim  { padding: 20px; }
  .sheet  { padding: 26px; min-height: 340px; }
  .step-area { min-height: 140px; }
}

/* Mobile ≤ 480px */
@media (max-width: 480px) {
  /* masthead — clamp() already scales but lift the floor */
  .masthead h1 { font-size: clamp(28px, 8.5vw, 38px); }
  .masthead p  { font-size: 11px; letter-spacing: 0.10em; }

  /* add button — larger touch target, safe-area aware */
  .add-btn {
    font-size: 14px;
    padding: 13px 22px;
    bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 16px));
  }

  /* composer modal */
  .scrim { padding: 12px 12px max(12px, env(safe-area-inset-bottom, 0px)); }
  .sheet {
    width: 100%;
    padding: 20px 16px;
    border-radius: 20px;
    min-height: 300px;
  }
  .step-question { font-size: 14px; }
  .step-area     { min-height: 110px; font-size: 14px; }
  .step-label    { font-size: 14px; }
  .step-input    { font-size: 14px; padding: 13px 14px; }
  .step-btn      { font-size: 14px; padding: 10px 12px; }
  .step-footer   { margin-top: 16px; }

  /* note-view modal — oversized cloud so text is readable; edges crop off-screen */
  .note-view { width: 140vw; flex-shrink: 0; }
  .note-view .nv-label  { font-size: 10px; }
  .note-view .nv-answer { font-size: 15px; }
  .note-view .nv-meta   { font-size: 14px; }
  .note-view .x { top: -4px; right: 15vw; width: 30px; height: 30px; font-size: 15px; }

  /* rising animation — stretch cloud to near full-width on mobile */
  .rising { top: 10%; }
  .rising-cloud { width: 140vw; --w: 140vw; flex-shrink: 0; }

  /* suppress info panels — already hidden in defaults */
  .count  { display: none; }
  .legend { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cloud, .rising, .rising-caption { animation-duration: 0.001ms !important; }
  .cloud { left: 50% !important; transform: translateX(-50%); }
}
