/* ============================================================
   Sakura Sounds 🌸 — pastel spring theme
   ============================================================ */

:root {
  --blush: #ffe5ec;
  --sakura: #ffc2d4;
  --petal: #ffb3c6;
  --rose: #ff8fab;
  --deep-rose: #fb6f92;
  --plum: #6d3b52;
  --plum-soft: #9d6b8c;
  --cream: #fff8f0;
  --matcha: #b7e4c7;
  --matcha-deep: #74c69d;

  --card-bg: rgba(255, 255, 255, 0.72);
  --card-border: rgba(255, 179, 198, 0.55);
  --shadow-soft: 0 10px 30px rgba(251, 111, 146, 0.18);
  --shadow-pop: 0 16px 40px rgba(251, 111, 146, 0.3);

  --font-body: "M PLUS Rounded 1c", "Quicksand", sans-serif;
  --font-accent: "Caveat", cursive;

  --ease-squish: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--plum);
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 85% -10%, #ffe0ea 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #e7f8ee 0%, transparent 55%),
    linear-gradient(160deg, var(--cream) 0%, var(--blush) 55%, #ffd9e4 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

#petal-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.view { position: relative; z-index: 2; }
.hidden { display: none !important; }

/* ---------------- Buttons ---------------- */
.btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  border: none;
  border-radius: 999px;
  padding: 0.85em 1.9em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  color: #fff;
  background: linear-gradient(135deg, var(--rose), var(--deep-rose));
  box-shadow: var(--shadow-soft);
  transition: transform 0.25s var(--ease-squish), box-shadow 0.25s ease, filter 0.2s ease;
}
.btn:hover { transform: scale(1.07) rotate(-1.5deg); box-shadow: var(--shadow-pop); filter: brightness(1.05); }
.btn:active { transform: scale(0.95); }

.btn-ghost {
  background: rgba(255, 255, 255, 0.7);
  color: var(--plum-soft);
  border: 2px solid var(--card-border);
  box-shadow: none;
  font-size: 0.85rem;
  padding: 0.55em 1.3em;
}
.btn-ghost:hover { background: #fff; }

/* ---------------- Hero / login ---------------- */
.hero-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.hero-card {
  position: relative;
  max-width: 560px;
  text-align: center;
  background: var(--card-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 2px solid var(--card-border);
  border-radius: 36px;
  padding: 3.5rem 2.5rem 2.8rem;
  box-shadow: var(--shadow-pop);
  animation: card-arrive 0.9s var(--ease-squish) both;
}

@keyframes card-arrive {
  from { opacity: 0; transform: translateY(40px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.hero-blossoms { position: absolute; inset: 0; pointer-events: none; }
.float-blossom {
  position: absolute;
  font-size: 2rem;
  filter: drop-shadow(0 4px 8px rgba(251, 111, 146, 0.35));
  animation: floaty 5s ease-in-out infinite;
}
.float-blossom.b1 { top: -24px; left: 8%;  font-size: 2.6rem; animation-delay: 0s; }
.float-blossom.b2 { top: -18px; right: 12%; animation-delay: 0.8s; }
.float-blossom.b3 { bottom: -20px; left: 18%; animation-delay: 1.6s; }
.float-blossom.b4 { bottom: -14px; right: 8%; font-size: 1.7rem; animation-delay: 2.3s; }
.float-blossom.b5 { top: 40%; left: -34px; font-size: 1.8rem; animation-delay: 3s; }

@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50%      { transform: translateY(-14px) rotate(8deg); }
}

.hero-kicker {
  font-family: var(--font-accent);
  font-size: 1.5rem;
  color: var(--deep-rose);
  margin-bottom: 0.2rem;
}

.hero-title {
  font-size: clamp(2.6rem, 7vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin-bottom: 1rem;
}
.hero-title .accent {
  font-family: var(--font-accent);
  font-weight: 700;
  color: var(--deep-rose);
  font-size: 1.15em;
}
.hero-title.small { font-size: clamp(1.8rem, 5vw, 2.6rem); }

.hero-sub {
  color: var(--plum-soft);
  line-height: 1.65;
  margin-bottom: 2rem;
  font-size: 1.02rem;
}

.hero-note {
  margin-top: 1.4rem;
  font-size: 0.8rem;
  color: var(--plum-soft);
  opacity: 0.85;
}

.setup-warning {
  margin-top: 1.2rem;
  font-size: 0.9rem;
  background: #fff3d6;
  border: 2px dashed #f2c14e;
  color: #8a6d1f;
  border-radius: 16px;
  padding: 0.8em 1em;
}
.setup-warning code { background: rgba(0,0,0,0.06); padding: 0.1em 0.4em; border-radius: 6px; }
.setup-warning a { color: var(--deep-rose); }

/* ---------------- Loading overlay ---------------- */
.loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: rgba(255, 229, 236, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.spinner-blossom {
  font-size: 4rem;
  animation: spin-bloom 1.6s linear infinite;
  filter: drop-shadow(0 6px 14px rgba(251, 111, 146, 0.4));
}
@keyframes spin-bloom {
  from { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(1.25); }
  to   { transform: rotate(360deg) scale(1); }
}
.loading-text { font-family: var(--font-accent); font-size: 1.6rem; color: var(--plum); }

/* ---------------- Dashboard layout ---------------- */
#dashboard-view {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.2rem 1.2rem 3rem;
}

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
  padding: 0.9rem 1.2rem;
  margin-bottom: 1.6rem;
  background: var(--card-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 2px solid var(--card-border);
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  position: sticky;
  top: 0.8rem;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 800; font-size: 1.15rem; }
.brand-blossom { font-size: 1.5rem; animation: floaty 4s ease-in-out infinite; display: inline-block; }
.brand-name em { font-family: var(--font-accent); font-style: normal; color: var(--deep-rose); font-size: 1.2em; }

.range-switch {
  display: flex;
  gap: 0.3rem;
  background: rgba(255, 194, 212, 0.35);
  padding: 0.3rem;
  border-radius: 999px;
}
.range-btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--plum-soft);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 0.5em 1.1em;
  cursor: pointer;
  transition: all 0.25s var(--ease-squish);
  white-space: nowrap;
}
.range-btn:hover { transform: scale(1.06); color: var(--plum); }
.range-btn.active {
  background: linear-gradient(135deg, var(--rose), var(--deep-rose));
  color: #fff;
  box-shadow: 0 4px 12px rgba(251, 111, 146, 0.4);
}

/* ---------------- Panels & section titles ---------------- */
.panel {
  background: var(--card-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 2px solid var(--card-border);
  border-radius: 28px;
  box-shadow: var(--shadow-soft);
  padding: 1.8rem 1.6rem;
  margin-bottom: 1.6rem;
  animation: panel-in 0.7s var(--ease-squish) both;
}
.panel:nth-of-type(2) { animation-delay: 0.08s; }
.panel:nth-of-type(3) { animation-delay: 0.16s; }

@keyframes panel-in {
  from { opacity: 0; transform: translateY(28px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.section-title {
  font-family: var(--font-accent);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--plum);
  position: relative;
  display: inline-block;
  margin-bottom: 0.4rem;
}
.section-title::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -6px;
  height: 8px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='8' viewBox='0 0 120 8'%3E%3Cpath d='M2 5 Q 12 1, 22 5 T 42 5 T 62 5 T 82 5 T 102 5 T 122 5' fill='none' stroke='%23ff8fab' stroke-width='2.5' stroke-linecap='round' opacity='0.65'/%3E%3C/svg%3E") repeat-x;
  background-size: 120px 8px;
}
.title-note { font-family: var(--font-body); font-size: 0.9rem; color: var(--plum-soft); font-weight: 500; }
.section-sub { color: var(--plum-soft); font-size: 0.92rem; margin-bottom: 0.8rem; }

/* ---------------- Personality card ---------------- */
.personality-card { display: flex; flex-wrap: wrap; align-items: center; gap: 1.6rem; }

.aura-badge {
  flex: 0 0 auto;
  width: 130px; height: 130px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 3.4rem;
  background: radial-gradient(circle at 30% 30%, #fff 0%, var(--sakura) 45%, var(--rose) 100%);
  box-shadow: var(--shadow-pop), inset 0 0 24px rgba(255,255,255,0.7);
  animation: aura-pulse 3.5s ease-in-out infinite;
}
@keyframes aura-pulse {
  0%, 100% { transform: scale(1); box-shadow: var(--shadow-pop), inset 0 0 24px rgba(255,255,255,0.7); }
  50%      { transform: scale(1.06); box-shadow: 0 20px 50px rgba(251,111,146,0.42), inset 0 0 30px rgba(255,255,255,0.9); }
}

.aura-text { flex: 1 1 260px; }
.aura-name { font-family: var(--font-accent); font-size: 2.4rem; color: var(--deep-rose); line-height: 1.1; }
.aura-desc { color: var(--plum-soft); line-height: 1.6; margin-top: 0.3rem; }

.aura-stats {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.8rem;
  margin-top: 0.6rem;
}
.stat-chip {
  background: rgba(255, 229, 236, 0.8);
  border: 2px solid var(--card-border);
  border-radius: 20px;
  padding: 0.9rem 1rem;
  text-align: center;
  transition: transform 0.25s var(--ease-squish);
}
.stat-chip:hover { transform: translateY(-4px) rotate(-1deg); }
.stat-value { font-size: 1.7rem; font-weight: 800; color: var(--deep-rose); }
.stat-label { font-size: 0.78rem; color: var(--plum-soft); font-weight: 500; }

/* ---------------- Charts ---------------- */
.chart-wrap { width: 100%; overflow: visible; display: flex; justify-content: center; }
#bloom-svg, #constellation-svg { width: 100%; display: block; }

/* bloom nodes */
.bloom-node { cursor: pointer; }
/* NOTE: transforms are on the group, never on petal paths — CSS
   transform-origin/box would hijack the paths' rotate() attribute */
.bloom-node .petals { transition: transform 0.3s var(--ease-squish); }
.bloom-node:hover .petals { transform: scale(1.12); }
.bloom-label {
  font-family: var(--font-body);
  font-weight: 800;
  fill: #fff;
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke;
  stroke: rgba(109, 59, 82, 0.35);
  stroke-width: 3px;
}

/* constellation */
.const-link { stroke: var(--petal); stroke-opacity: 0.55; stroke-dasharray: 4 5; animation: link-flow 30s linear infinite; }
@keyframes link-flow { to { stroke-dashoffset: -500; } }
.const-node { cursor: grab; }
.const-node:active { cursor: grabbing; }
.const-ring { fill: none; stroke: var(--rose); stroke-width: 2.5; opacity: 0.9; }
.const-label {
  font-size: 10px;
  font-weight: 700;
  fill: var(--plum);
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke;
  stroke: rgba(255, 248, 240, 0.9);
  stroke-width: 3px;
}

/* ---------------- Media lists ---------------- */
.lists-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.6rem;
}
@media (max-width: 860px) {
  .lists-grid { grid-template-columns: 1fr; }
}

.media-list { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.8rem; }

.media-item {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: rgba(255, 255, 255, 0.65);
  border: 2px solid transparent;
  border-radius: 18px;
  padding: 0.55rem 0.8rem;
  opacity: 0;
  transform: translateX(-18px);
  animation: item-in 0.5s var(--ease-squish) forwards;
  transition: transform 0.25s var(--ease-squish), border-color 0.2s ease, background 0.2s ease;
}
@keyframes item-in { to { opacity: 1; transform: translateX(0); } }
.media-item:hover {
  transform: translateX(6px) scale(1.015);
  border-color: var(--card-border);
  background: #fff;
}

.rank-badge {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.85rem; color: #fff;
  background: linear-gradient(135deg, var(--sakura), var(--rose));
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-4deg);
  box-shadow: 0 3px 8px rgba(251, 111, 146, 0.35);
}
.media-item:nth-child(1) .rank-badge,
.media-item:nth-child(2) .rank-badge,
.media-item:nth-child(3) .rank-badge {
  background: linear-gradient(135deg, var(--rose), var(--deep-rose));
}

.media-art {
  flex: 0 0 auto;
  width: 52px; height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--sakura);
  box-shadow: 0 4px 10px rgba(251, 111, 146, 0.3);
  transition: transform 0.6s ease, border-radius 0.3s ease;
}
.media-item:hover .media-art { transform: rotate(360deg); }

.media-info { min-width: 0; flex: 1; }
.media-name {
  font-weight: 700; font-size: 0.95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.media-sub {
  font-size: 0.78rem; color: var(--plum-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.genre-chips { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.25rem; }
.genre-chip {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--plum-soft);
  background: var(--blush);
  border-radius: 999px;
  padding: 0.15em 0.6em;
}

/* ---------------- Tooltip ---------------- */
.tooltip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: rgba(109, 59, 82, 0.95);
  color: var(--cream);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.5;
  border-radius: 14px;
  padding: 0.6em 0.9em;
  max-width: 240px;
  box-shadow: var(--shadow-pop);
  transform: translate(-50%, calc(-100% - 12px));
}
.tooltip strong { color: var(--sakura); font-size: 0.9rem; }

/* ---------------- Swirl transitions ---------------- */
.swirl-out { animation: swirl-out 0.35s ease-in forwards; }
@keyframes swirl-out {
  to { opacity: 0; transform: scale(0.92) rotate(1.5deg); filter: blur(3px); }
}
.swirl-in { animation: swirl-in 0.5s var(--ease-squish) both; }
@keyframes swirl-in {
  from { opacity: 0; transform: scale(0.92) rotate(-1.5deg); filter: blur(3px); }
  to   { opacity: 1; transform: scale(1) rotate(0); filter: blur(0); }
}

/* ---------------- Footer ---------------- */
.dash-footer { text-align: center; color: var(--plum-soft); font-size: 0.8rem; padding: 1rem 0 0.5rem; }

/* ---------------- Responsive ---------------- */
@media (max-width: 640px) {
  .dash-header { border-radius: 24px; justify-content: center; }
  .range-btn { font-size: 0.72rem; padding: 0.45em 0.8em; }
  .panel { padding: 1.3rem 1rem; }
  .section-title { font-size: 1.8rem; }
  .aura-name { font-size: 2rem; }
}

/* ---------------- Reduced motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
