/* IFRA NewScent Bot — visual chrome aligned to the IFRA toolkit
   (mist, orbs, grain, glass cards, navy app-nav). Mirrors the recipe
   used by index.html / brand-guidelines.html on the hub. */

:root {
  --darkBlue:  #0B1D3A;
  --blue:      #4472C4;
  --lav:       #A2548C;
  --lavPale:   #D9B5CF;
  --lavPaler:  #F1E4ED;
  --slate:     #708090;
  --terracotta:#D1614A;
  --amber:     #E4AC48;
  --green:     #5F8946;
  --bg:        #F9F9F6;
  --serif: 'Playfair Display', Georgia, serif;
  --sans:  'Roboto', system-ui, -apple-system, Segoe UI, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh; color: var(--darkBlue);
  font-family: var(--sans);
  display: flex; flex-direction: column;
  background: var(--bg);
  overflow-x: hidden;
}

/* ── Drifting mist / orbs / grain (same recipe as the hub) ────────── */
.mist {
  position: fixed; inset: -10%; width: 120%; height: 120%;
  background:
    radial-gradient(ellipse 60% 50% at 20% 20%, rgba(162, 84, 140, 0.22) 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 80% 30%, rgba(228, 172, 72, 0.18) 0%, transparent 55%),
    radial-gradient(ellipse 70% 55% at 50% 85%, rgba(205, 217, 239, 0.55) 0%, transparent 60%),
    radial-gradient(ellipse 45% 35% at 15% 75%, rgba(43, 129, 152, 0.16) 0%, transparent 55%);
  filter: blur(40px) saturate(115%);
  z-index: -2; pointer-events: none;
  animation: mistDrift 38s ease-in-out infinite alternate;
  will-change: transform;
}
.mist::after {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 50% 45% at 70% 60%, rgba(162, 84, 140, 0.20) 0%, transparent 55%),
    radial-gradient(ellipse 40% 35% at 30% 50%, rgba(205, 217, 239, 0.55) 0%, transparent 50%);
  filter: blur(50px) saturate(110%);
  animation: mistDriftAlt 52s ease-in-out infinite alternate-reverse;
}
.ambient {
  position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(11,29,58,0.05) 90%);
}
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.16 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.5; mix-blend-mode: overlay;
}
.orb {
  position: fixed; border-radius: 50%; pointer-events: none; z-index: -2;
  filter: blur(70px); mix-blend-mode: screen; opacity: 0.5;
  will-change: transform, opacity;
}
.orb.one   { width: 520px; height: 520px; top: -120px;  left: -80px;
  background: radial-gradient(circle, var(--lav) 0%, transparent 70%);
  animation: orbPulse 18s ease-in-out infinite alternate; }
.orb.two   { width: 460px; height: 460px; bottom: -160px; right: -60px;
  background: radial-gradient(circle, var(--terracotta) 0%, transparent 70%);
  animation: orbPulse 22s 3s ease-in-out infinite alternate-reverse; }
.orb.three { width: 380px; height: 380px; top: 38%; right: 22%;
  background: radial-gradient(circle, var(--amber) 0%, transparent 70%);
  opacity: 0.32;
  animation: orbPulse 26s 1s ease-in-out infinite alternate; }
@keyframes orbPulse {
  0%   { transform: translate3d(0,0,0) scale(1);    opacity: 0.42; }
  50%  { transform: translate3d(3%,-2%,0) scale(1.12); opacity: 0.58; }
  100% { transform: translate3d(-2%,3%,0) scale(0.96); opacity: 0.38; }
}
@keyframes mistDrift {
  0%   { transform: scale(1)    translate3d(0,0,0)        rotate(0deg); }
  50%  { transform: scale(1.08) translate3d(-2%,1.5%,0)   rotate(0.4deg); }
  100% { transform: scale(1.04) translate3d(1.5%,-1%,0)   rotate(-0.3deg); }
}
@keyframes mistDriftAlt {
  0%   { transform: scale(1)    translate3d(0,0,0); }
  100% { transform: scale(1.06) translate3d(2%,-1.5%,0); }
}

/* Brand stripe along the very top */
body::before {
  content: ''; position: fixed; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--lav) 0%, var(--blue) 50%, var(--terracotta) 100%);
  z-index: 2;
}

/* ── Dark-navy app nav (mirrors brand-guidelines.html on the hub) ─── */
.app-nav {
  position: relative; z-index: 3;
  background: var(--darkBlue); padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 14px rgba(11,29,58,0.18);
  min-height: 76px;
}
.app-nav .nav-left {
  display: flex; align-items: center; gap: 18px;
}
.app-nav a.brand {
  display: flex; align-items: center; gap: 14px;
  text-decoration: none; color: inherit;
}
.app-nav .back-toolkit {
  /* Match the right-side nav-btn but spaced as a leading back-action */
  margin-right: 4px;
}
.app-nav .logomark {
  width: 44px; height: 44px;
  background: white; border-radius: 50%; padding: 4px;
  flex-shrink: 0; box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  object-fit: contain;
}

/* Large IFRA logo above the H1 on the welcome view */
.brand-logo {
  display: block; margin: 0 auto 22px;
  max-width: 200px; width: 60%; height: auto;
  filter: drop-shadow(0 8px 18px rgba(11,29,58,0.10));
}
.login-wrap .brand-logo { margin-bottom: 22px; }
.container .brand-logo { margin-bottom: 14px; }
.app-nav .wordmark {
  color: white; font-family: var(--serif);
  font-size: 22px; font-weight: 700; line-height: 1.05;
  letter-spacing: -0.01em;
}
.app-nav .subtitle {
  color: rgba(217,181,207,0.78);
  font-size: 11px; font-weight: 300; line-height: 1.2;
  margin-top: 2px; letter-spacing: 0.02em;
}
.app-nav .nav-right {
  display: flex; align-items: center; gap: 12px;
}
.app-nav .signed-as {
  color: rgba(255,255,255,0.7); font-size: 12px;
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-nav .nav-btn {
  color: rgba(255,255,255,0.85);
  font-size: 12px; text-decoration: none;
  padding: 7px 14px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.10);
  transition: background 150ms ease; cursor: pointer;
  font-family: inherit; line-height: 1.2;
}
.app-nav .nav-btn:hover { background: rgba(255,255,255,0.18); }

/* ── Layout ───────────────────────────────────────────────────────── */
.container {
  max-width: 720px; margin: 0 auto; padding: 56px 24px 80px;
  position: relative; z-index: 1; width: 100%;
  animation: fadeUp 520ms cubic-bezier(.2,.7,.3,1) both;
}
h1 {
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(36px, 5.5vw, 56px); line-height: 1.05;
  letter-spacing: -0.02em; margin: 0 0 16px;
  background: linear-gradient(135deg, var(--darkBlue) 0%, var(--lav) 60%, var(--terracotta) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  background-size: 200% 200%;
  animation: gradientShift 14s ease-in-out infinite alternate;
}
@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}
.lede {
  font-size: 17px; line-height: 1.7; color: var(--slate);
  max-width: 620px; margin: 0 0 32px;
}

/* ── Glass card (forms, info blocks) ──────────────────────────────── */
.glass-card {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 20px;
  padding: 32px 36px;
  box-shadow: 0 10px 36px rgba(11, 29, 58, 0.08);
  position: relative; overflow: hidden;
  animation: fadeUp 520ms 60ms cubic-bezier(.2,.7,.3,1) both;
}
.glass-card::before {
  content: ''; position: absolute; top: 0; left: 10%; right: 10%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.9), transparent);
  pointer-events: none;
}
.card-title {
  font-family: var(--serif); font-weight: 700; font-size: 24px;
  margin: 0 0 6px; color: var(--darkBlue); letter-spacing: -0.01em;
}
.card-sub {
  font-size: 13.5px; color: var(--slate); margin: 0 0 22px; line-height: 1.55;
}

/* ── Form controls ────────────────────────────────────────────────── */
label {
  display: block; font-size: 11px; font-weight: 700; color: var(--lav);
  text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 8px;
}
input[type="url"], input[type="email"], input[type="text"] {
  box-sizing: border-box; width: 100%; padding: 12px 14px; font-size: 14.5px;
  color: var(--darkBlue); border: 1px solid var(--lavPale); border-radius: 8px;
  outline: none; font-family: inherit; margin-bottom: 18px;
  transition: border-color 150ms ease; background: white;
}
input:focus { border-color: var(--lav); }
button[type="submit"], button[type="button"]:not(.nav-btn) {
  width: 100%; padding: 13px 20px; border-radius: 9px; border: none;
  background: var(--darkBlue); color: white; font-family: inherit;
  font-size: 15px; font-weight: 700; cursor: pointer;
  transition: background 150ms ease, transform 100ms ease;
}
button[type="submit"]:hover, button[type="button"]:not(.nav-btn):hover { background: var(--lav); }
button[type="submit"]:active, button[type="button"]:not(.nav-btn):active { transform: translateY(1px); }
button[type="submit"]:disabled, button[type="button"]:not(.nav-btn):disabled { opacity: 0.5; cursor: not-allowed; }

.msg {
  margin-top: 16px; padding: 12px 14px; font-size: 13.5px; line-height: 1.5;
  border-radius: 8px; background: var(--lavPaler); color: var(--darkBlue);
}
.msg.err { background: #FBF1EF; color: var(--terracotta); }
.hint {
  margin-top: 18px; font-size: 11.5px; color: var(--slate); line-height: 1.5;
}
.hint-link { color: var(--lav); font-weight: 600; text-decoration: none; }
.hint-link:hover { text-decoration: underline; }

.otp-wrap {
  margin-top: 18px; padding-top: 18px;
  border-top: 1px solid var(--lavPale);
}
.otp-input {
  letter-spacing: 0.14em; text-align: center;
  font-family: 'Courier New', monospace;
  font-size: 18px; font-weight: 700;
}

/* ── Auth-state wrappers ──────────────────────────────────────────── */
.loading-wrap, .login-wrap {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 24px;
  animation: fadeUp 520ms cubic-bezier(.2,.7,.3,1) both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Result page (split-pane editor + preview) ────────────────────── */
/* When the SPA is showing the result panels, lock the body to viewport
   height and `display: contents` the intermediate wrappers so the grid
   layout below becomes a direct flex child of <body> and can fill the
   remaining height after the nav. */
body.result-page { height: 100vh; overflow: hidden; }
body.result-page #appWrap,
body.result-page #resultState { display: contents; }
.result-layout {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
  padding: 18px 24px 24px;
  position: relative; z-index: 1;
  animation: fadeUp 420ms cubic-bezier(.2,.7,.3,1) both;
}
.panel {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  box-shadow: 0 10px 36px rgba(11, 29, 58, 0.08);
  display: flex; flex-direction: column; overflow: hidden;
  min-height: 0;
}
.panel-header {
  background: var(--darkBlue); color: white;
  padding: 14px 20px; margin: 0;
  font-family: var(--sans); font-size: 13px; font-weight: 700;
  letter-spacing: 0.02em;
  display: flex; align-items: center; gap: 10px;
}
.panel textarea {
  width: 100%; flex: 1; padding: 16px;
  font-family: 'Courier New', monospace;
  border: none; resize: none; box-sizing: border-box;
  outline: none; font-size: 12px; line-height: 1.5;
  background: white;
}
.panel iframe {
  width: 100%; flex: 1; border: none; background: white;
}

/* ── Mobile ───────────────────────────────────────────────────────── */
@media (max-width: 540px) {
  .app-nav { padding: 0 12px; min-height: 64px; }
  .app-nav .nav-left { gap: 10px; }
  .app-nav .subtitle { display: none; }
  .app-nav .wordmark { font-size: 16px; }
  .app-nav .logomark { width: 32px; height: 32px; padding: 3px; }
  .app-nav .signed-as { display: none; }
  /* On narrow screens, "← Toolkit" text would crowd the brand — keep the
     arrow only. The longer label returns above 540px. */
  .app-nav .back-toolkit { font-size: 0; padding: 7px 10px; }
  .app-nav .back-toolkit::before { content: '←'; font-size: 14px; }
  .container { padding: 32px 16px; }
  .glass-card { padding: 24px 22px; }
  .result-layout { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.hidden { display: none !important; }
