/* =========================================================================
   WedFilmMentor — "warm studio"
   Cream paper ground · clay tactile buttons · Fraunces + Figtree · soft grain
   ========================================================================= */

:root {
  --cream:        #FAF4EA;
  --cream-deep:   #F3E9D8;
  --paper:        #FFFDF9;
  --ink:          #322A22;
  --ink-soft:     #6E6356;
  --ink-faint:    #9C9081;
  --clay:         #D4664A;
  --clay-deep:    #BB5238;
  --clay-tint:    #F7E3DA;
  --butter:       #F4E7C9;
  --butter-deep:  #EBD7AC;
  --line:         #E8DDC9;
  --good:         #7C8B5E;

  --shadow-sm: 0 1px 2px rgba(80, 54, 30, 0.06), 0 2px 6px rgba(80, 54, 30, 0.05);
  --shadow-md: 0 2px 4px rgba(80, 54, 30, 0.06), 0 10px 24px rgba(80, 54, 30, 0.10);
  --shadow-lg: 0 6px 14px rgba(80, 54, 30, 0.10), 0 24px 48px rgba(80, 54, 30, 0.14);

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-pill: 999px;

  --display: "Fraunces", Georgia, serif;
  --body: "Figtree", -apple-system, BlinkMacSystemFont, sans-serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* the `hidden` attribute must win over display rules (e.g. .topbar-right { display:flex }) */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% -10%, var(--cream) 0%, var(--cream-deep) 100%);
  background-attachment: fixed;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* warm grain + glow atmosphere */
.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0.5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
}
.glow {
  position: fixed; top: -30vh; left: 50%; transform: translateX(-50%);
  width: 90vw; height: 70vh; z-index: 0; pointer-events: none;
  background: radial-gradient(circle, rgba(244, 200, 130, 0.35) 0%, rgba(250, 244, 234, 0) 60%);
  filter: blur(20px);
}

/* ---------------- top bar ---------------- */
.topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem clamp(1.1rem, 4vw, 2.4rem);
}
.brand { display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none; color: var(--ink); }
.brand-mark { color: var(--clay); font-size: 1.05rem; transform: translateY(1px); }
.brand-name { font-family: var(--display); font-weight: 600; font-size: 1.18rem; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 0.9rem; }
.whoami { color: var(--ink-faint); font-size: 0.85rem; }
.link-btn {
  background: none; border: none; color: var(--ink-soft); font-family: var(--body);
  font-size: 0.85rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
  padding: 0.3rem;
}
.link-btn:hover { color: var(--clay-deep); }

/* buy-me-a-coffee button (topbar) */
.coffee-btn {
  font-family: var(--body); font-size: 0.85rem; font-weight: 500; cursor: pointer;
  color: var(--clay-deep); background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-pill); padding: 0.4rem 0.9rem; box-shadow: var(--shadow-sm);
  transition: transform 0.16s var(--ease), box-shadow 0.18s var(--ease), border-color 0.18s var(--ease);
}
.coffee-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: var(--clay); }

/* modal (coffee) */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: 1.2rem; background: rgba(50, 42, 34, 0.38); backdrop-filter: blur(3px);
  animation: fade 0.2s var(--ease);
}
.modal-card {
  position: relative; width: 100%; max-width: 26rem; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.6rem; box-shadow: var(--shadow-lg);
  animation: rise 0.35s var(--ease) both;
}
.modal-card h3 { font-family: var(--display); font-weight: 600; font-size: 1.5rem; margin: 0.35rem 0 0.5rem; }
.modal-card > p { color: var(--ink-soft); margin-bottom: 1.1rem; }
.modal-close {
  position: absolute; top: 0.7rem; right: 0.9rem; background: none; border: none; cursor: pointer;
  font-size: 1.5rem; line-height: 1; color: var(--ink-faint);
}
.modal-close:hover { color: var(--ink); }
.coffee-presets { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.coffee-preset {
  font-family: var(--body); font-size: 0.95rem; font-weight: 600; cursor: pointer; flex: 1; min-width: 4rem;
  color: var(--ink); background: var(--cream); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 0.7rem 0.5rem; transition: transform 0.16s var(--ease), border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.coffee-preset:hover { transform: translateY(-2px); border-color: var(--clay); background: var(--clay-tint); }
.coffee-custom { display: flex; align-items: center; gap: 0.5rem; background: var(--cream); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 0.3rem 0.3rem 0.3rem 0.9rem; }
.coffee-custom:focus-within { border-color: var(--clay); }
.coffee-currency { color: var(--ink-soft); font-weight: 600; }
.coffee-custom input { flex: 1; min-width: 0; border: none; background: none; outline: none; font-family: var(--body); font-size: 1rem; color: var(--ink); }
.coffee-custom .btn { padding: 0.6rem 1.1rem; }

/* ---------------- layout ---------------- */
#app {
  position: relative; z-index: 1; flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  width: 100%; max-width: 760px; margin: 0 auto;
  padding: 0 clamp(1.1rem, 4vw, 2rem);
}
.view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.view.is-active { display: flex; }
/* welcome/onboarding can grow + scroll the page if ever taller than the viewport */
.view-welcome.is-active, .view-onboarding.is-active { overflow-y: auto; }

/* ---------------- typography ---------------- */
.eyebrow {
  text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.72rem;
  font-weight: 600; color: var(--clay-deep);
}
.display {
  font-family: var(--display); font-weight: 500; letter-spacing: -0.02em;
  font-size: clamp(2.3rem, 7vw, 3.6rem); line-height: 1.02; color: var(--ink);
  margin: 0.7rem 0 0;
}
.display-sm { font-size: clamp(1.9rem, 5.5vw, 2.7rem); }
.lede { font-size: clamp(1.02rem, 2.4vw, 1.18rem); color: var(--ink-soft); max-width: 32rem; margin-top: 1.1rem; }
.lede strong { color: var(--ink); font-weight: 600; }
.lede-sm { font-size: 1.02rem; }
.fineprint { color: var(--ink-faint); font-size: 0.88rem; margin-top: 1.4rem; }

.visually-hidden, .welcome-inner .visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
}

/* ---------------- welcome ---------------- */
.view-welcome { justify-content: center; }
.welcome-inner { padding: clamp(1.5rem, 6vh, 4rem) 0 5rem; }

.signup { margin-top: 2rem; max-width: 30rem; }
.field {
  display: flex; gap: 0.5rem; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 0.4rem 0.4rem 0.4rem 1.2rem; box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}
.field:focus-within { border-color: var(--clay); box-shadow: var(--shadow-md); }
.field input {
  flex: 1; border: none; background: none; font-family: var(--body);
  font-size: 1rem; color: var(--ink); outline: none; min-width: 0;
}
.field input::placeholder { color: var(--ink-faint); }
.form-error { color: var(--clay-deep); font-size: 0.85rem; margin-top: 0.6rem; }

/* ---------------- buttons ---------------- */
.btn {
  font-family: var(--body); font-weight: 600; font-size: 0.95rem;
  border: none; border-radius: var(--r-pill); cursor: pointer;
  padding: 0.85rem 1.5rem; display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem; white-space: nowrap;
  transition: transform 0.16s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}
.btn-primary {
  background: linear-gradient(180deg, var(--clay) 0%, var(--clay-deep) 100%);
  color: #fff; box-shadow: 0 2px 0 var(--clay-deep), var(--shadow-md);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 0 var(--clay-deep), var(--shadow-lg); }
.btn-primary:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--clay-deep), var(--shadow-sm); }
.btn-primary:disabled { opacity: 0.6; cursor: default; transform: none; }
.btn-soft {
  background: var(--paper); color: var(--ink); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); flex-direction: column; align-items: flex-start; gap: 0.15rem;
  padding: 0.9rem 1.2rem; text-align: left; flex: 1;
}
.btn-soft:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--clay); }
.ea-title { font-weight: 600; }
.ea-price { font-size: 0.82rem; color: var(--ink-faint); font-weight: 500; }

/* ---------------- onboarding ---------------- */
.view-onboarding { justify-content: center; }
.onboarding-inner { padding: clamp(1.5rem, 6vh, 4rem) 0 5rem; }
.level-cards { display: grid; gap: 0.9rem; margin-top: 2rem; }
@media (min-width: 620px) { .level-cards { grid-template-columns: repeat(3, 1fr); } }
.level-card {
  font-family: var(--body); text-align: left; cursor: pointer;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 1.3rem 1.2rem; display: flex; flex-direction: column; gap: 0.35rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s var(--ease), box-shadow 0.22s var(--ease), border-color 0.22s var(--ease), background 0.22s var(--ease);
}
.level-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--clay); }
.level-card.selected { background: var(--clay-tint); border-color: var(--clay); }
.level-emoji { font-size: 1.5rem; }
.level-title { font-family: var(--display); font-weight: 600; font-size: 1.18rem; }
.level-sub { color: var(--ink-soft); font-size: 0.9rem; }

/* ---------------- chat ---------------- */
.view-chat { padding-bottom: 0; }
.chat-shell { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.messages {
  flex: 1; min-height: 0; overflow-y: auto; padding: 1rem 0 1.5rem;
  display: flex; flex-direction: column; gap: 1.1rem; scroll-behavior: smooth;
}
.msg { display: flex; }
.msg-mentor { justify-content: flex-start; }
.msg-user { justify-content: flex-end; }
.bubble {
  max-width: 88%; padding: 0.95rem 1.2rem; border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); animation: rise 0.45s var(--ease) both;
}
.msg-mentor .bubble {
  background: var(--paper); border: 1px solid var(--line);
  border-bottom-left-radius: 7px;
}
.msg-user .bubble {
  background: linear-gradient(180deg, var(--butter) 0%, var(--butter-deep) 100%);
  color: var(--ink); border-bottom-right-radius: 7px;
}
.bubble p { margin: 0 0 0.6rem; }
.bubble p:last-child { margin-bottom: 0; }
.bubble strong { font-weight: 700; }
.bubble em { font-style: italic; }
.bubble ul, .bubble ol { margin: 0.4rem 0 0.6rem 1.1rem; }
.bubble li { margin-bottom: 0.3rem; }
.bubble code { background: var(--cream-deep); padding: 0.1rem 0.35rem; border-radius: 6px; font-size: 0.9em; }
.bubble .bubble-h { font-family: var(--display); font-weight: 600; font-size: 1.05rem; margin: 0.8rem 0 0.25rem; }
.bubble .bubble-h:first-child { margin-top: 0; }
.intro .bubble { background: transparent; border: none; box-shadow: none; color: var(--ink-soft); padding-left: 0; }

/* typing indicator */
.typing .bubble { display: inline-flex; gap: 5px; align-items: center; }
.typing .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint);
  animation: blink 1.3s infinite both;
}
.typing .dot:nth-child(2) { animation-delay: 0.18s; }
.typing .dot:nth-child(3) { animation-delay: 0.36s; }

/* cards inside chat */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 1.3rem; box-shadow: var(--shadow-md); animation: rise 0.45s var(--ease) both;
}
.card-eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.68rem; font-weight: 700; color: var(--clay-deep); }
.card h3 { font-family: var(--display); font-weight: 600; font-size: 1.4rem; margin: 0.4rem 0 0.5rem; }
.card p { color: var(--ink-soft); margin-bottom: 1rem; }
.card-paywall { background: linear-gradient(180deg, var(--paper), var(--clay-tint)); }
.card-store { background: linear-gradient(180deg, var(--paper), var(--butter)); }
.card-store .store-name { color: var(--ink); margin-bottom: 0.35rem; }
.card-store .store-lead { color: var(--ink-soft); margin-bottom: 0.7rem; }
.card-store .store-code {
  color: var(--ink);
  font-size: 1.18rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 1rem;
}
.card-store .store-code-tag {
  font-style: italic;
  font-weight: 700;
  color: var(--clay-deep);
}
.card-store .store-code-price { font-size: 0.9rem; font-weight: 500; color: var(--ink-soft); white-space: nowrap; }
.escalation-lead { color: var(--ink-soft); }
.escalation-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; }

/* composer */
/* Opaque background that masks messages scrolling behind the composer. It reuses the body's
   FIXED page gradient, so it lines up pixel-for-pixel with the page (no hard edge, no side seams). */
/* No background needed: messages scroll inside their own area, so nothing renders behind the
   composer. Transparent = the page shows through seamlessly, no seam. */
.composer { padding: 0.9rem 0 1.4rem; background: transparent; }
.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.7rem; }
.chip {
  font-family: var(--body); font-size: 0.84rem; color: var(--ink-soft);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 0.45rem 0.9rem; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform 0.16s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease);
  animation: rise 0.4s var(--ease) both;
}
.chip:hover { transform: translateY(-2px); border-color: var(--clay); color: var(--ink); }
.composer-form {
  display: flex; align-items: flex-end; gap: 0.5rem;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 0.5rem 0.5rem 0.5rem 1.1rem; box-shadow: var(--shadow-md);
  transition: border-color 0.2s var(--ease);
}
.composer-form:focus-within { border-color: var(--clay); }
.composer-form textarea {
  flex: 1; border: none; background: none; resize: none; font-family: var(--body);
  font-size: 1rem; color: var(--ink); outline: none; line-height: 1.5; max-height: 160px;
  padding: 0.45rem 0;
}
.composer-form textarea::placeholder { color: var(--ink-faint); }
.btn-send { width: 44px; height: 44px; padding: 0; border-radius: 50%; flex-shrink: 0; }
.composer-hint { color: var(--ink-faint); font-size: 0.8rem; margin-top: 0.55rem; text-align: center; min-height: 1.1em; }

/* always-available "ask Arran directly" block under the composer — same buttons as the popup card */
.ask-arran { margin-top: 0.5rem; padding-bottom: 0.2rem; }
.ask-arran-label { color: var(--ink-faint); font-size: 0.8rem; text-align: center; margin-bottom: 0.5rem; }

/* ---------------- entrance animation ---------------- */
.stagger > * { opacity: 0; animation: rise 0.7s var(--ease) forwards; }
.stagger > .s1 { animation-delay: 0.05s; }
.stagger > .s2 { animation-delay: 0.15s; }
.stagger > .s3 { animation-delay: 0.27s; }
.stagger > .s4 { animation-delay: 0.4s; }
.stagger > .s5 { animation-delay: 0.52s; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .stagger > * { opacity: 1; }
}
