/* Mobile-first FTU styles with big type and animated gradient */

:root {
  --bg1: #0f1020;
  --bg2: #151734;
  --brand-a: #6c7cff; /* indigo */
  --brand-b: #00d1ff; /* cyan */
  --brand-c: #7bffb1; /* mint */
  --text: #f7f8ff;
  --muted: #cbd3ff;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-rounded, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg1);
}

/* Stripe-esque animated gradient background */
.gradient-bg::before {
  content: "";
  position: fixed;
  inset: -10% -10% -10% -10%;
  background: radial-gradient(60% 80% at 20% 20%, rgba(108,124,255,0.6), transparent 60%),
              radial-gradient(50% 70% at 80% 30%, rgba(0,209,255,0.5), transparent 60%),
              radial-gradient(60% 80% at 40% 80%, rgba(123,255,177,0.35), transparent 60%),
              linear-gradient(120deg, var(--bg1), var(--bg2));
  filter: saturate(120%) blur(8px);
  transform: translateZ(0);
  animation: gradientPan 24s ease-in-out infinite alternate;
  z-index: -1;
}

@keyframes gradientPan {
  0% { transform: translate3d(-2%, -1%, 0) scale(1.05); }
  50% { transform: translate3d(2%, 2%, 0) scale(1.08); }
  100% { transform: translate3d(-1%, 1%, 0) scale(1.04); }
}

.screen {
  min-height: 100dvh;
  display: grid;
  align-items: end;
  padding: 24px max(20px, env(safe-area-inset-left)) max(28px, env(safe-area-inset-bottom));
}

/* FTU keyboard behavior: mobile-only tweaks to avoid desktop layout regressions */
@media (max-width: 640px) {
  body.ftu-page .screen {
    overflow: auto;
    min-height: 100vh;
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }
  @supports (height: 100svh) {
    body.ftu-page .screen { min-height: 100svh; }
  }
  @supports (height: 100dvh) {
    body.ftu-page .screen { min-height: 100dvh; }
  }
  body.ftu-page .content:focus-within { margin-top: 8px; }
}

.content {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.headline {
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-size: clamp(32px, 8.5vw, 64px); /* Big type like One UI */
  margin: 0 0 8px 0;
  text-shadow: 0 6px 24px rgba(0,0,0,0.25);
}

.headline .word {
  display: inline-block;
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  filter: blur(4px);
  will-change: transform, opacity, filter;
  animation: fadeUp 700ms cubic-bezier(.2,.75,.18,1.0) forwards;
}

.headline .word.dot { letter-spacing: 0; min-width: 0.2ch; }

@keyframes fadeUp {
  to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.subhead {
  margin: 0 0 16px 0;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.35;
  font-size: clamp(14px, 3.8vw, 18px);
  opacity: 0;
  transform: translateY(6px);
  animation: subFade 600ms ease forwards;
  animation-delay: 600ms; /* comes in after headline words begin */
}

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

.form { margin-top: 8px; }

.label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 10px;
}

/* Borderless field with animated underline (seamless look) */
.input-wrap,
.field {
  position: relative;
  display: flex;
  align-items: flex-start;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 10px 2px 14px 2px;
}

/* Base hairline */
.input-wrap::before,
.field::before {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: rgba(255,255,255,0.25);
  opacity: 0.6;
}

/* Gradient active underline */
.input-wrap::after,
.field::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brand-a), var(--brand-b) 60%, var(--brand-c));
  transform: scaleX(0.25);
  transform-origin: left center;
  opacity: 0;
  transition: transform 280ms cubic-bezier(.2,.75,.18,1), opacity 240ms ease;
}

.input-wrap:focus-within::after,
.field:focus-within::after,
.input-wrap.filled::after,
.field.filled::after {
  transform: scaleX(1);
  opacity: 1;
}

input[type="text"] {
  flex: 1;
  font-size: clamp(18px, 4.5vw, 22px);
  line-height: 1.3;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  caret-color: var(--text); /* ensure blinking caret is visible */
}

input::placeholder { color: rgba(255, 255, 255, 0.55); }

/* Removed decorative caret to avoid double-caret effect */

.btn {
  margin-top: 14px;
  width: 100%;
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.2px;
  background: linear-gradient(90deg, var(--brand-a), var(--brand-b) 60%, var(--brand-c));
  color: #0a0c12;
  box-shadow: 0 10px 30px rgba(0, 209, 255, 0.25);
  opacity: 0.7;
}

.btn:disabled { filter: grayscale(0.2) opacity(0.6); }
.btn.enabled { opacity: 1; }

/* Larger screens get roomier layout */
@media (min-width: 640px) {
  .screen { align-items: center; padding: 40px; }
  .headline { margin-bottom: 22px; }
}

/* Mobile: center FTU and Profile content vertically */
@media (max-width: 640px) {
  body.profile-page .screen {
    /* Use flex centering on very small screens for robustness */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    padding-top: max(40px, env(safe-area-inset-top));
    padding-bottom: max(32px, env(safe-area-inset-bottom));
  }
  body.profile-page .content {
    margin-top: 0; /* override any previous margin for true centering */
  }
}

/* Extra-narrow widths: ensure strong centering */
@media (max-width: 420px) {
  body.profile-page .screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    min-height: 100vh;
    padding-top: calc(env(safe-area-inset-top) + 16px);
    padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
  }
}

/* Dreams list layout */
.dreams {
  list-style: none;
  margin: 14px 0 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.dream {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: start;
  gap: 8px;
}

.dream .label { margin-top: 10px; font-weight: 700; color: var(--text); }


.dream textarea,
.field textarea {
  width: 100%;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 0;
  padding: 6px 0 4px 0;
  line-height: 1.5;
  font-size: clamp(18px, 4.5vw, 22px); /* match name input */
  font-family: inherit; /* ensure same font as body/input */
  outline: none;
}

/* Unify placeholder typography across inputs and textareas */
input::placeholder,
textarea::placeholder {
  color: rgba(255,255,255,0.55);
  font-family: inherit;
  font-size: inherit; /* now same as the control */
  font-style: normal; /* avoid browser italics */
  font-weight: 400; /* align with input placeholder weight */
  letter-spacing: inherit;
}

/* Home actions */
.home-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.chip { display: inline-block; padding: 12px 16px; border-radius: 999px; font-weight: 800; letter-spacing: 0.2px; text-decoration: none; color: #0a0c12; background: linear-gradient(90deg, var(--brand-a), var(--brand-b)); box-shadow: 0 10px 30px rgba(0, 209, 255, 0.25); }
.link { color: var(--muted); text-decoration: underline; font-weight: 600; }

/* Home (mobile app-like) tweaks */
body.home .screen { align-items: center; padding-top: max(56px, env(safe-area-inset-top)); padding-bottom: max(40px, env(safe-area-inset-bottom)); }
body.home .content { text-align: center; padding: 0 4px; }
body.home .headline { margin-bottom: 12px; }
body.home .subhead { margin-bottom: 22px; }
body.home .home-actions { width: 100%; display: grid; gap: 16px; margin-top: 22px; }
body.home .link { display: inline-block; margin-top: 2px; opacity: 0.9; }

/* App-like action cards */
body.home .card {
  display: grid;
  grid-template-columns: 56px 1fr 20px;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 18px;
  border-radius: 16px;
  color: var(--text);
  text-decoration: none;
  text-align: left; /* ensure left-aligned text within the card */
  background: linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.06));
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  backdrop-filter: saturate(130%) blur(8px);
  transform: translateY(2px);
  opacity: 0;
  animation: cardIn 700ms cubic-bezier(.2,.75,.18,1) forwards;
}
body.home .card.alt { background: linear-gradient(180deg, rgba(0,209,255,0.14), rgba(123,255,177,0.10)); border-color: rgba(0,209,255,0.25); }
body.home .card:active { transform: translateY(3px) scale(0.995); }
body.home .card:focus-visible { outline: 3px solid rgba(0,209,255,0.6); outline-offset: 3px; }

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

body.home .card-icon {
  width: 56px; height: 56px; border-radius: 14px;
  display: grid; place-items: center; font-size: 26px;
  background: radial-gradient(120% 120% at 30% 30%, rgba(255,255,255,0.45), rgba(255,255,255,0.12));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25);
}
body.home .card-body { display: grid; gap: 2px; text-align: left; }
body.home .card-title { font-weight: 900; letter-spacing: 0.2px; font-size: 18px; }
body.home .card-desc { color: var(--muted); font-size: 14px; line-height: 1.35; }
body.home .chev { opacity: 0.6; font-size: 20px; }

@media (min-width: 520px) {
  body.home .home-actions { grid-template-columns: minmax(260px, 420px); justify-content: center; }
}

/* FTU Welcome page: keep theme, improve placement */
.ftu-welcome .screen { align-items: center; padding-top: max(56px, env(safe-area-inset-top)); padding-bottom: max(40px, env(safe-area-inset-bottom)); }
.ftu-welcome .content { text-align: center; padding: 0 4px; }
.ftu-welcome .headline { margin-bottom: 12px; }
.ftu-welcome .subhead { margin: 0 auto; max-width: 46ch; margin-bottom: 22px; }
.ftu-welcome .btn { display: block; width: 100%; max-width: 360px; margin: 24px auto 0; }
