/* TerraRisk AI: site styles (nav, buttons, glass panels, map page, chat, footer).
   Works together with Tailwind (TAILWIND_CDN=True in .env). Colors: ink navy + mint. */

:root {
  --ink-950: #050b14;
  --ink-900: #0a1422;
  --ink-800: #101c2e;
  --mint-300: #86efac;
  --mint-400: #4ade80;
  --teal-400: #2dd4bf;
  --sky-400: #38bdf8;
  --text: #e5edf7;
  --muted: #94a3b8;
  --line: rgba(255, 255, 255, 0.10);
  --glass: rgba(255, 255, 255, 0.05);
  --nav-h: 68px;
}

/* ---------- base ---------- */
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  background:
    radial-gradient(1200px 700px at 85% 10%, rgba(56, 189, 248, 0.16), transparent 60%),
    radial-gradient(900px 600px at 0% 100%, rgba(45, 212, 191, 0.10), transparent 60%),
    linear-gradient(180deg, var(--ink-950) 0%, var(--ink-900) 55%, #0d1f3a 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
::selection { background: rgba(74, 222, 128, 0.35); }

/* ---------- glass panels ---------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
details.glass summary { list-style: none; }
details.glass summary::-webkit-details-marker { display: none; }
details.glass summary::after { content: "+"; float: right; color: var(--mint-400); font-weight: 800; }
details.glass[open] summary::after { content: "–"; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.6rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-mint {
  background: linear-gradient(135deg, var(--mint-300), var(--teal-400));
  color: var(--ink-950);
  box-shadow: 0 8px 28px rgba(45, 212, 191, 0.30);
}
.btn-mint:hover { box-shadow: 0 10px 34px rgba(45, 212, 191, 0.45); }
.btn-sky {
  background: linear-gradient(135deg, #7dd3fc, var(--sky-400));
  color: var(--ink-950);
  box-shadow: 0 8px 28px rgba(56, 189, 248, 0.30);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--mint-400); color: #fff; }
.btn-sm { padding: 0.5rem 1.1rem; font-size: 0.9rem; }
.btn-block { display: flex; width: 100%; }

/* ---------- navbar ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 1100;
  height: var(--nav-h);
  background: rgba(5, 11, 20, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 1400px;
  height: 100%;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 800; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.7rem;
  background: linear-gradient(135deg, var(--mint-300), var(--teal-400));
  color: var(--ink-950);
  font-size: 0.85rem;
  font-weight: 800;
}
.brand-name { font-size: 1.1rem; color: #fff; }
.nav-links { display: flex; align-items: center; gap: 0.25rem; flex: 1; }
.nav-link {
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
  transition: color 0.2s, background 0.2s;
}
.nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
.nav-link.active { color: var(--mint-400); background: rgba(74, 222, 128, 0.10); }
.nav-right { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }
.nav-right form { margin: 0; }
.pill {
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.10);
  color: var(--mint-300);
  font-size: 0.85rem;
  font-weight: 700;
}
.nav-user { color: var(--text); font-weight: 600; font-size: 0.95rem; }
.nav-user:hover { color: var(--mint-400); }

@media (max-width: 900px) {
  .nav-links { display: none; }
  .nav-inner { gap: 1rem; }
  .nav-user { display: none; }
}
@media (max-width: 520px) {
  .pill { display: none; }
  .brand-name { display: none; }
}

/* ---------- landing globe ---------- */
.globe {
  position: relative;
  width: min(30rem, 80vw);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle at 42% 40%, transparent 0 14px, rgba(255, 255, 255, 0.22) 15px 16px),
    radial-gradient(circle at 35% 30%, #5eead4 0%, #0ea5e9 38%, #1e3a8a 75%, #0b1530 100%);
  box-shadow:
    inset -30px -40px 80px rgba(5, 11, 20, 0.65),
    0 0 80px rgba(56, 189, 248, 0.35),
    0 0 160px rgba(45, 212, 191, 0.15);
  animation: globe-float 7s ease-in-out infinite;
}
@keyframes globe-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
@media (prefers-reduced-motion: reduce) { .globe { animation: none; } }

/* ---------- pricing ---------- */
.is-popular {
  border-color: rgba(74, 222, 128, 0.55);
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.25), 0 20px 60px rgba(45, 212, 191, 0.18);
}
.is-unlimited {
  background: linear-gradient(160deg, rgba(56, 189, 248, 0.10), rgba(255, 255, 255, 0.04));
}

/* ---------- toasts ---------- */
.toasts {
  position: fixed;
  top: calc(var(--nav-h) + 1rem);
  right: 1rem;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 22rem;
}
.toast { padding: 0.9rem 1.1rem; border-left: 4px solid var(--mint-400); background: rgba(10, 20, 34, 0.92); }
.toast.error { border-left-color: #f87171; }

/* ---------- platform (map page) ---------- */
.pf {
  position: relative;
  height: calc(100vh - var(--nav-h));
  min-height: 520px;
  overflow: hidden;
}
.pf-map {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--ink-900);
}
.pf-search,
.pf-buffer,
.pf-run {
  position: absolute;
  z-index: 1000;
  background: rgba(10, 20, 34, 0.82);
}
.pf-search {
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(30rem, calc(100% - 9rem));
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 999px;
}
.pf-search input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 1rem;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  outline: none;
}
.pf-search input::placeholder { color: var(--muted); }
.pf-search input:focus { box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.5); }
.pf-search button {
  padding: 0.6rem 1.2rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--mint-300), var(--teal-400));
  color: var(--ink-950);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.pf-buffer {
  top: 1rem;
  right: 1rem;
  width: 16rem;
  padding: 1rem 1.1rem;
}
.pf-buffer label { display: flex; justify-content: space-between; font-weight: 700; font-size: 0.95rem; }
.pf-buffer label span { color: var(--mint-400); }
.pf-buffer input[type="range"] { width: 100%; margin: 0.75rem 0 0.4rem; accent-color: var(--mint-400); }
.pf-buffer p { margin: 0; color: var(--muted); font-size: 0.8rem; line-height: 1.4; }
.pf-run {
  right: 1rem;
  bottom: 1.5rem;
  width: 20rem;
  padding: 1.25rem;
}
.pf-run h1 { margin: 0; font-size: 1.15rem; font-weight: 800; }
.pf-status { margin: 0.4rem 0 1rem; color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.pf-status.error, .pf-status.is-error { color: #fca5a5; }
.pf-status.ok, .pf-status.is-ok, .pf-status.success { color: var(--mint-300); }
.pf-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 0.75rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  outline: none;
}
.pf-input::placeholder { color: var(--muted); }
.pf-input:focus { border-color: var(--mint-400); }
.pf-note { margin: 0.8rem 0 0; color: var(--muted); font-size: 0.85rem; }
.pf-note a { color: var(--mint-400); font-weight: 700; }

/* the chat launcher sits above the run panel on the map page */
body:has(.pf) .chat-launcher { bottom: 1.5rem; left: 1rem; right: auto; }
body:has(.pf) .chat-panel { left: 1rem; right: auto; }

@media (max-width: 760px) {
  .pf-search { left: 4rem; right: 1rem; transform: none; width: auto; }
  .pf-buffer { top: auto; bottom: 13.5rem; right: 1rem; left: 1rem; width: auto; }
  .pf-run { left: 1rem; right: 1rem; bottom: 1rem; width: auto; }
}

/* Leaflet on dark pages */
.leaflet-container { font-family: inherit; background: var(--ink-900); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--ink-800); color: var(--text); }
.leaflet-control-attribution { background: rgba(5, 11, 20, 0.6) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--sky-400) !important; }

/* ---------- chat assistant ---------- */
.chat-launcher {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1150;
  display: grid;
  place-items: center;
  width: 3.6rem;
  height: 3.6rem;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mint-300), var(--teal-400));
  color: var(--ink-950);
  box-shadow: 0 10px 30px rgba(45, 212, 191, 0.40);
  cursor: pointer;
  transition: transform 0.2s ease;
}
.chat-launcher:hover { transform: scale(1.06); }
.chat-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 5.6rem;
  z-index: 1150;
  display: flex;
  flex-direction: column;
  width: min(23rem, calc(100vw - 2.5rem));
  height: min(32rem, calc(100vh - 8rem));
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: rgba(10, 20, 34, 0.96);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.chat-panel[hidden] { display: none; }
.chat-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
}
.chat-avatar {
  display: grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mint-300), var(--teal-400));
  color: var(--ink-950);
  font-size: 0.8rem;
  font-weight: 800;
}
.chat-title { font-weight: 800; }
.chat-sub { color: var(--mint-300); font-size: 0.78rem; }
.chat-close {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.chat-close:hover { color: #fff; }
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.chat-msg {
  max-width: 85%;
  padding: 0.65rem 0.9rem;
  border-radius: 1rem;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.chat-msg.bot { align-self: flex-start; background: rgba(255, 255, 255, 0.07); border-bottom-left-radius: 0.3rem; }
.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--mint-300), var(--teal-400));
  color: var(--ink-950);
  border-bottom-right-radius: 0.3rem;
}
.chat-msg.typing { color: var(--muted); font-style: italic; }
.chat-links { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.chat-links a { color: var(--mint-400); font-weight: 700; font-size: 0.85rem; text-decoration: underline; }
.chat-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0 1rem 0.6rem; }
.chat-chips:empty { display: none; }
.chat-chip {
  padding: 0.35rem 0.75rem;
  border: 1px solid rgba(74, 222, 128, 0.35);
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.08);
  color: var(--mint-300);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.chat-chip:hover { background: rgba(74, 222, 128, 0.18); }
.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--line);
}
.chat-form input {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  outline: none;
}
.chat-form input:focus { border-color: var(--mint-400); }
.chat-send {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mint-300), var(--teal-400));
  color: var(--ink-950);
  cursor: pointer;
}
.chat-send:disabled { opacity: 0.5; cursor: wait; }

/* ---------- footer ---------- */
.site-footer {
  margin-top: 6rem;
  border-top: 1px solid var(--line);
  background: rgba(5, 11, 20, 0.55);
}
.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 2.5rem;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2.5rem;
}
.footer-about p { margin: 1rem 0; max-width: 26rem; color: var(--muted); line-height: 1.6; font-size: 0.95rem; }
.footer-mail { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--mint-400); font-weight: 600; }
.social { display: flex; gap: 0.6rem; margin-top: 1.2rem; }
.social a {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  transition: color 0.2s, border-color 0.2s;
}
.social a:hover { color: var(--mint-400); border-color: var(--mint-400); }
.footer-col h3 { margin: 0 0 1rem; font-size: 0.85rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #fff; }
.footer-links { display: flex; flex-direction: column; gap: 0.6rem; }
.footer-links a,
.footer-links button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
}
.footer-links a:hover,
.footer-links button:hover { color: var(--mint-400); }
.footer-bottom { border-top: 1px solid var(--line); }
.footer-bottom > div {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.2rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}
@media (max-width: 860px) {
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .footer-about { grid-column: 1 / -1; }
}
