/* ==========================================================================
   tranquil — shared design system
   ========================================================================== */

:root {
  --bg-deep: #10131f;
  --bg-mid: #171b2c;
  --bg-soft: #1e2438;

  --ink: #f2f4fb;
  --ink-soft: #c3c8dd;
  --ink-mute: #8d94b0;

  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);
  --panel: rgba(255, 255, 255, 0.045);
  --panel-hi: rgba(255, 255, 255, 0.08);

  /* Overridden per-mood by setMoodTheme() */
  --accent: #9db4d6;
  --accent-soft: rgba(157, 180, 214, 0.16);
  --accent-glow: rgba(157, 180, 214, 0.35);

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 34px;

  --shadow: 0 18px 50px -22px rgba(0, 0, 0, 0.85);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  --font: "Inter", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Georgia", "Iowan Old Style", "Palatino Linotype", serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Ambient background: two slow-drifting auroras tinted by the current mood. */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -2;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  pointer-events: none;
  transition: background 1.2s var(--ease);
}

body::before {
  width: 60vw;
  height: 60vw;
  top: -18vw;
  left: -12vw;
  background: var(--accent-glow);
  animation: drift-a 26s ease-in-out infinite alternate;
}

body::after {
  width: 52vw;
  height: 52vw;
  bottom: -20vw;
  right: -14vw;
  background: var(--accent-glow);
  opacity: 0.32;
  animation: drift-b 32s ease-in-out infinite alternate;
}

@keyframes drift-a {
  to { transform: translate3d(8vw, 6vh, 0) scale(1.15); }
}

@keyframes drift-b {
  to { transform: translate3d(-7vw, -5vh, 0) scale(1.2); }
}

/* --------------------------------------------------------------- layout --- */

.shell {
  width: min(1120px, 100% - 2.5rem);
  margin-inline: auto;
  padding-block: 1.25rem 5rem;
}

.shell--narrow { width: min(760px, 100% - 2.5rem); }

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding-block: 1.1rem;
  margin-bottom: 1.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.74rem;
  color: var(--ink-soft);
  text-decoration: none;
}

.brand__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: pulse 4.5s ease-in-out infinite;
}

@keyframes pulse {
  50% { box-shadow: 0 0 0 9px transparent; }
}

.topbar__spacer { flex: 1; }

/* ---------------------------------------------------------------- type --- */

a { color: var(--accent); text-underline-offset: 3px; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; font-weight: 600; }

h1 { font-size: clamp(2rem, 5vw, 3.1rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.3rem, 3vw, 1.8rem); letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; }

.display { font-family: var(--font-display); font-weight: 400; font-style: italic; }

.lede {
  font-size: clamp(1rem, 2vw, 1.16rem);
  color: var(--ink-soft);
  max-width: 56ch;
  margin: 0 0 1.5rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.85rem;
}

.muted { color: var(--ink-mute); }
.small { font-size: 0.84rem; }
.center { text-align: center; }

/* -------------------------------------------------------------- panels --- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(1.25rem, 3vw, 2rem);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.panel--tight { padding: 1.15rem 1.25rem; }

.grid { display: grid; gap: 1.1rem; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.stack { display: grid; gap: 1.5rem; }
.row { display: flex; gap: 0.65rem; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------- buttons --- */

.btn {
  --btn-bg: var(--panel-hi);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--btn-bg);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.62rem 1.3rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.2s var(--ease), background 0.2s, border-color 0.2s, opacity 0.2s;
}

.btn:hover { transform: translateY(-2px); background: rgba(255, 255, 255, 0.14); }
.btn:active { transform: translateY(0); }

.btn--primary {
  --btn-bg: var(--accent);
  color: #12141f;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 12px 30px -12px var(--accent-glow);
}

.btn--primary:hover { background: var(--accent); filter: brightness(1.08); }

.btn--ghost { --btn-bg: transparent; }
.btn--sm { padding: 0.4rem 0.9rem; font-size: 0.82rem; }
.btn--wide { width: 100%; justify-content: center; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink-mute);
  text-decoration: none;
  font-size: 0.86rem;
  transition: color 0.2s, gap 0.2s;
}

.back:hover { color: var(--ink); gap: 0.7rem; }

/* --------------------------------------------------------------- chips --- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.8rem;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.chip__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.pill {
  font: inherit;
  font-size: 0.84rem;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.4rem 0.95rem;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.pill:hover { color: var(--ink); border-color: var(--accent); }

.pill[aria-pressed="true"],
.pill.is-on {
  background: var(--accent);
  border-color: transparent;
  color: #12141f;
  font-weight: 600;
}

/* ------------------------------------------------------- form controls --- */

textarea, input[type="text"], select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 0.85rem 1rem;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus, input[type="text"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

textarea::placeholder, input::placeholder { color: var(--ink-mute); }

label { display: block; font-size: 0.82rem; color: var(--ink-mute); margin-bottom: 0.4rem; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* --------------------------------------------------------- card lists --- */

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.4rem;
  border-radius: var(--r-lg);
  background: var(--panel);
  border: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: transform 0.28s var(--ease), border-color 0.28s, background 0.28s;
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 120%, var(--accent-soft), transparent 70%);
  opacity: 0;
  transition: opacity 0.35s;
  pointer-events: none;
}

.card:hover { transform: translateY(-5px); border-color: var(--line-strong); }
.card:hover::after { opacity: 1; }

.card__icon { font-size: 1.7rem; line-height: 1; }
.card__title { font-weight: 600; font-size: 1.08rem; }
.card__body { color: var(--ink-soft); font-size: 0.9rem; margin: 0; }
.card__meta { color: var(--ink-mute); font-size: 0.78rem; margin-top: auto; padding-top: 0.6rem; }

/* -------------------------------------------------------------- notes --- */

.note {
  border-left: 2px solid var(--accent);
  padding: 0.35rem 0 0.35rem 0.9rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.divider { height: 1px; background: var(--line); border: 0; margin: 1.75rem 0; }

.footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--ink-mute);
  font-size: 0.8rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.footer a { color: var(--ink-soft); }

/* Crisis banner — deliberately calm, never alarming. */
.crisis {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  padding: 0.9rem 1.1rem;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------ toasts --- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  translate: -50% 0;
  z-index: 60;
  padding: 0.7rem 1.3rem;
  border-radius: 999px;
  background: rgba(20, 24, 38, 0.94);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, translate 0.35s var(--ease);
}

.toast.is-visible { opacity: 1; translate: -50% -0.5rem; }

/* --------------------------------------------------------- utilities --- */

.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: reveal 0.7s var(--ease) forwards;
}

.reveal:nth-child(2) { animation-delay: 0.07s; }
.reveal:nth-child(3) { animation-delay: 0.14s; }
.reveal:nth-child(4) { animation-delay: 0.21s; }
.reveal:nth-child(5) { animation-delay: 0.28s; }
.reveal:nth-child(6) { animation-delay: 0.35s; }

@keyframes reveal {
  to { opacity: 1; transform: none; }
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}
