/* ============================================================
   The Aster Life — styles
   Dark base, purple ("purple period") accent. Buildless, no deps.
   ============================================================ */

:root {
  --bg: #0f1115;
  --text: #e8e8ea;
  --muted: rgba(232, 232, 234, 0.65);
  --accent: #8b5cf6;

  /* Motion — gentle */
  --dur: 300ms;       /* node glide / enter / exit */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1.25rem 6rem;
}

/* ---------- Welcome (always visible) ---------- */

#welcome {
  text-align: center;
  max-width: 48ch;
  margin: 2.5rem auto 0.5rem;
}
h1 {
  margin: 0 0 1rem;
  font-weight: 600;
  font-size: clamp(2rem, 6vw, 3.5rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
}
.dot { color: var(--accent); }
.welcome-copy { color: var(--muted); line-height: 1.6; }
.welcome-copy p { margin: 0 0 0.6rem; }
.welcome-copy strong { color: var(--text); }

/* ---------- Tree canvas ---------- */

#tree {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}
#connectors {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}
#connectors path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  opacity: 0.55;
}
#tree-flow {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(2rem, 7vh, 4rem);
  width: 100%;
  padding-top: 1.5rem;
}

/* ---------- Nodes ---------- */
/* Transforms are driven by JS (FLIP); hover effects deliberately avoid
   transform so they don't clobber an in-flight animation. */

.tree-node { transform-origin: center; }

.tree-node.option {
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  cursor: pointer;
  background: linear-gradient(160deg, rgba(139, 92, 246, 0.20), rgba(139, 92, 246, 0.06));
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 14px;
  padding: 0.9rem 1.25rem;
  min-width: 9rem;
  text-align: center;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease),
              background 140ms var(--ease);
}
/* Only on real hover devices - otherwise the border stays "stuck" bright after
   a tap on touch screens (which report hover: none). */
@media (hover: hover) {
  .tree-node.option:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.28);
  }
}
.tree-node.option.selected {
  background: linear-gradient(160deg, rgba(139, 92, 246, 0.5), rgba(139, 92, 246, 0.22));
  border-color: var(--accent);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.3);
}
.tree-node:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Root ("Choose your own adventure") node */
.tree-node.root {
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  border: none;
  background: var(--accent);
  border-radius: 999px;
  padding: 0.85rem 1.6rem;
  max-width: min(90vw, 24rem);
  box-shadow: 0 6px 24px rgba(139, 92, 246, 0.35);
  transition: box-shadow 140ms var(--ease), filter 140ms var(--ease);
}
@media (hover: hover) {
  .tree-node.root:hover { box-shadow: 0 10px 30px rgba(139, 92, 246, 0.5); }
}
.tree-node.root.selected { filter: brightness(1.06); }

/* ---------- Fan (a parent's children) ---------- */

.fan {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 1rem;
  max-width: min(980px, 94vw);
}
.fan.fan-cards { gap: 1.1rem; }

/* ---------- Experience cards (leaves) ---------- */

.card {
  position: relative;
  width: 230px;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
/* Gradient-only cards: the gradient fills the whole card. */
.card-bg {
  position: absolute;
  inset: 0;
  background-position: center top;
  background-repeat: no-repeat;
  background-size: cover;
}
/* Photo cards: the photo (top layer) fills the whole card with a center crop
   (not tiled). The gradient base layer sits behind it but is covered. */
.card-bg.has-photo {
  background-position: center center, center center;
  background-size: cover, cover;
}
/* The overlay sits in normal flow, so the card's height grows to fit all the
   details. It's transparent until the card is revealed (hover / tap). */
.card-overlay {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem;
  background: linear-gradient(to top, rgba(10, 10, 14, 0.95), rgba(10, 10, 14, 0.82));
  opacity: 0;
  pointer-events: none;          /* not interactive until revealed */
  transition: opacity var(--dur) var(--ease);
}

/* Visit + favorite heart share the bottom row: Visit left, heart right. */
.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.55rem;
}
.card-name { font-weight: 600; font-size: 1.05rem; }
.card-blurb { font-size: 0.85rem; color: var(--muted); line-height: 1.45; }
.card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.1rem;
}
.card-loc { display: inline-flex; align-items: center; gap: 0.35rem; }
.card-loc svg { height: 14px; width: auto; fill: var(--accent); opacity: 0.9; }

.visit {
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  transition: transform 120ms var(--ease), box-shadow 120ms;
}
.visit:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(139, 92, 246, 0.4); }
.visit:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Reveal details: hover on pointer devices, tap (.revealed) on touch */
@media (hover: hover) {
  .card:hover .card-overlay { opacity: 1; pointer-events: auto; }
}
.card.revealed .card-overlay { opacity: 1; pointer-events: auto; }

/* ---------- Mobile — vertical, left-rail tree ---------- */
/* Choices can't fan sideways on a phone, so they stack and branch off a rail
   that runs down the left edge (lines drawn in app.js). Buttons sit to the
   right of that rail, so siblings read as siblings. */
@media (max-width: 640px) {
  #welcome { margin-top: 1.5rem; }

  /* The column matches the hero button's width and is centered, so every
     button's right edge lines up with the hero's right edge. */
  #tree-flow {
    align-items: stretch;
    max-width: min(90vw, 24rem);
    margin-inline: auto;
    gap: 1.1rem;
    padding-left: 0;
  }

  /* Hero fills the column so it's the right-edge reference. */
  .tree-node.root { align-self: stretch; max-width: none; }

  /* Wide buttons: right edge aligns with the hero, left indented for the rail. */
  .tree-node.option {
    align-self: stretch;
    margin-left: 56px;
    min-width: 0;
    max-width: none;
  }

  .fan {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    width: 100%;
    max-width: none;
  }
  .fan .tree-node.option { margin-left: 56px; }

  /* Cards: one per row, filling the column width (minus the rail indent). */
  .fan.fan-cards { display: block; }
  .fan-cards .card {
    display: block;
    width: auto;
    margin: 0 0 1rem 56px;
  }
  .fan-cards .card:last-child { margin-bottom: 0; }
}

/* ---------- Favorites: heart toggle, floating button, panel ---------- */

/* Heart on each card (and reused in the panel). One icon; CSS drives the
   filled (saved) vs outline (not saved) state off aria-pressed. */
.heart {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: none;
  margin: 0;
  padding: 0.3rem;
  cursor: pointer;
  line-height: 0;
  color: var(--muted);
  border-radius: 999px;
  transition: color 140ms var(--ease), transform 140ms var(--ease);
}
.heart:hover { color: var(--accent); transform: translateY(-1px); }
.heart:active .heart-icon { transform: scale(0.85); }
.heart:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.heart[aria-pressed="true"] { color: var(--accent); }

.heart-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  transition: fill 140ms var(--ease), stroke 140ms var(--ease), transform 140ms var(--ease);
}
.heart[aria-pressed="true"] .heart-icon { fill: var(--accent); stroke: var(--accent); }

/* Floating button - the way into the saved list. Hidden until there is at
   least one favorite, then it fades in (top-right, clear of the card rows). */
.fav-fab {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.85rem 0.5rem 0.7rem;
  color: var(--text);
  background: rgba(20, 18, 30, 0.82);
  border: 1px solid rgba(139, 92, 246, 0.5);
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease),
              box-shadow 140ms var(--ease);
}
.fav-fab.show { opacity: 1; transform: none; pointer-events: auto; }
.fav-fab:hover { box-shadow: 0 10px 28px rgba(139, 92, 246, 0.4); }
.fav-fab:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.fav-fab .heart-icon { width: 20px; height: 20px; fill: var(--accent); stroke: var(--accent); }
.fav-fab-count { font-size: 0.9rem; font-weight: 600; min-width: 1ch; text-align: center; }

/* Scrim behind the panel */
.fav-scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(6, 6, 10, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
body.fav-open .fav-scrim { opacity: 1; pointer-events: auto; }

/* Slide-out panel - the repository of saved cards */
.fav-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 70;
  height: 100%;
  width: min(380px, 90vw);
  display: flex;
  flex-direction: column;
  background: #14121c;
  border-left: 1px solid rgba(139, 92, 246, 0.3);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
  transform: translateX(100%);
  transition: transform var(--dur) var(--ease);
}
body.fav-open .fav-panel { transform: none; }

.fav-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.1rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.fav-panel-title { margin: 0; font-size: 1.1rem; font-weight: 600; }
.fav-close {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem;
  line-height: 0;
  border-radius: 8px;
  transition: color 140ms var(--ease);
}
.fav-close:hover { color: var(--text); }
.fav-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.fav-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.85rem 1.1rem 1.5rem;
}
.fav-empty { margin: 1rem 0; color: var(--muted); line-height: 1.5; }

.fav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid rgba(139, 92, 246, 0.18);
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(139, 92, 246, 0.10), rgba(139, 92, 246, 0.03));
}
.fav-item-main { flex: 1; min-width: 0; }
.fav-item-name { font-weight: 600; font-size: 0.95rem; }
.fav-item-loc {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.fav-item-loc .fav-pin { fill: var(--accent); opacity: 0.9; }
.fav-item-actions { display: inline-flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.fav-visit {
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
}
.fav-visit:hover { filter: brightness(1.05); }
.fav-visit:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.fav-remove {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0.2rem;
  line-height: 0;
  border-radius: 999px;
}
.fav-remove .heart-icon { width: 22px; height: 22px; fill: var(--accent); stroke: var(--accent); }
.fav-remove:hover .heart-icon { filter: brightness(1.1); transform: scale(0.92); }
.fav-remove:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- Fireworks button (set one off on demand) ---------- */

.fx-btn {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 50;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--accent);
  background: rgba(20, 18, 30, 0.82);
  border: 1px solid rgba(139, 92, 246, 0.5);
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: color 140ms var(--ease), background 140ms var(--ease),
              box-shadow 140ms var(--ease), transform 120ms var(--ease);
}
.fx-btn:hover {
  color: #fff;
  background: rgba(139, 92, 246, 0.9);
  box-shadow: 0 10px 28px rgba(139, 92, 246, 0.5);
}
.fx-btn:active { transform: scale(0.88); }
.fx-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.fx-btn svg { width: 24px; height: 24px; display: block; }

/* ---------- Accessibility ---------- */

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; }
}
