/* Opal Interactive visual system (KB: Sistema de Marca; tokens from opal-website).
   Light-first pastel canvas, navy ink, royal blue accent, iridescent jewel tones only as
   accents, frosted glass surfaces, MuseoModerno throughout. */
:root {
  --ink: #21395b;
  --ink-soft: #4f6482;
  --muted: #81737a;
  --accent: #2e6cf0;
  --hairline: rgba(33, 57, 91, 0.16);
  --glass: rgba(255, 255, 255, 0.46);
  --glass-strong: rgba(255, 255, 255, 0.72);
  --jewel-pink: #ff9fe0;
  --jewel-sky: #a4c9fe;
  --jewel-cyan: #abedff;
  --jewel-violet: #c8a2ff;
  --grad-iris: linear-gradient(90deg, #ff9fe0 0%, #c8a2ff 34%, #a4c9fe 68%, #abedff 100%);
  --grad-opal: linear-gradient(135deg, #86c9fe 0%, #c9a0f8 50%, #f893ee 100%);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --r-lg: 24px;
  --r-md: 16px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f9f5fd; color: var(--ink);
  font: 400 14px/1.5 'MuseoModerno', ui-rounded, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }

/* Full-bleed pastel wash with soft orbs, same recipe as the Opal site background. */
.aura { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 52% at 12% 6%, rgba(255, 159, 224, 0.40), transparent 70%),
    radial-gradient(56% 46% at 90% 16%, rgba(171, 237, 255, 0.42), transparent 72%),
    radial-gradient(48% 48% at 80% 60%, rgba(215, 186, 251, 0.30), transparent 70%),
    radial-gradient(72% 50% at 28% 96%, rgba(164, 201, 254, 0.28), transparent 75%),
    linear-gradient(180deg, #fbeff8 0%, #f7f1fd 32%, #f9f6fd 64%, #ffffff 100%); }

.glass { background: var(--glass); border: 1px solid var(--hairline);
  backdrop-filter: blur(22px) saturate(1.2); -webkit-backdrop-filter: blur(22px) saturate(1.2); }
@media (prefers-reduced-transparency: reduce) {
  .glass { background: #fff; backdrop-filter: none; -webkit-backdrop-filter: none; }
}

.eyebrow { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; color: var(--accent); }
.pill { margin: 0; padding: 5px 12px; border-radius: 999px; font-size: 11px; font-weight: 500; letter-spacing: 0.04em;
  color: var(--ink-soft); background: rgba(255, 255, 255, 0.6); border: 1px solid var(--hairline); white-space: nowrap; }

/* ---------- stage ---------- */
#stage { position: fixed; inset: 0; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
canvas:active { cursor: grabbing; }

/* ---------- top bar ---------- */
#top { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); width: min(1180px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px; border-radius: 999px; z-index: 2; }
.brand { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.7); box-shadow: 0 0 0 1px var(--hairline), 0 6px 18px rgba(200, 162, 255, 0.35); flex: none; }
.brand img { display: block; animation: float 7s var(--ease) infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
.title { display: flex; align-items: baseline; gap: 10px; min-width: 0; margin-right: auto; }
h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap; }
.by { margin: 0; font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------- species list ---------- */
#list { position: fixed; top: 96px; left: max(16px, calc(50vw - 590px)); bottom: 24px; width: 232px; padding: 18px 10px 10px;
  border-radius: var(--r-lg); display: flex; flex-direction: column; gap: 10px; z-index: 1; }
#list .eyebrow { padding: 0 10px; }
#chips { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; scrollbar-width: none; min-height: 0; }
#chips::-webkit-scrollbar { display: none; }
#chips button { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 14px;
  cursor: pointer; color: var(--ink-soft); font-weight: 500; transition: background 240ms var(--ease), color 240ms var(--ease); }
#chips button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.5); }
#chips button.on { color: var(--ink); background: rgba(255, 255, 255, 0.85); box-shadow: 0 6px 20px rgba(33, 57, 91, 0.08), inset 0 0 0 1px rgba(255, 255, 255, 0.9); }
#chips button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.swatch { width: 16px; height: 16px; border-radius: 50%; background: var(--c); flex: none;
  box-shadow: inset 0 0 0 1px rgba(33, 57, 91, 0.18), inset 0 2px 3px rgba(255, 255, 255, 0.55); }
#chips button.on .swatch { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--jewel-violet); }

/* ---------- info card ---------- */
#info { position: fixed; right: max(16px, calc(50vw - 590px)); bottom: 24px; width: 348px; padding: 22px 24px 20px;
  border-radius: var(--r-lg); z-index: 1; }
#info::before { content: ''; position: absolute; left: 24px; right: 24px; top: 0; height: 2px; border-radius: 2px; background: var(--grad-iris); }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
#info h2 { margin: 6px 0 0; font-size: 34px; line-height: 1.08; font-weight: 500; letter-spacing: -0.6px; }
#cut { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.icon-btn { display: none; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0 14px; }
.stats div { padding: 10px 12px; border-radius: var(--r-md); background: rgba(255, 255, 255, 0.55); border: 1px solid rgba(255, 255, 255, 0.8); }
dt { font-size: 10px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
dd { margin: 2px 0 0; font-size: 22px; font-weight: 500; letter-spacing: -0.3px; font-variant-numeric: tabular-nums; }
#note { margin: 0 0 16px; color: var(--ink-soft); }
#controls { display: flex; gap: 10px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 9px; padding: 7px 14px 7px 8px; border-radius: 999px; cursor: pointer; font-weight: 500;
  background: rgba(255, 255, 255, 0.6); border: 1px solid var(--hairline); user-select: none; transition: border-color 240ms var(--ease); }
.switch[hidden] { display: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.track { position: relative; width: 30px; height: 18px; border-radius: 999px; background: rgba(33, 57, 91, 0.16); transition: background 240ms var(--ease); flex: none; }
.track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(33, 57, 91, 0.3); transition: transform 240ms var(--ease); }
.switch input:checked + .track { background: var(--grad-opal); box-shadow: 0 0 12px rgba(200, 162, 255, 0.55); }
.switch input:checked + .track::after { transform: translateX(12px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { margin: 14px 0 0; font-size: 12px; color: var(--muted); }

#err { position: fixed; top: 84px; left: 50%; transform: translateX(-50%); margin: 0; padding: 8px 14px; border-radius: 12px;
  color: #9b1c3c; background: rgba(255, 255, 255, 0.85); max-width: 86vw; z-index: 3; }
#err:empty { display: none; }

/* Laptops: tighter panels so the stone keeps room. */
@media (max-width: 1100px) and (min-width: 761px) {
  #list { width: 200px; }
  #info { width: 300px; }
  #info h2 { font-size: 28px; }
}

/* ---------- phones: a stacked layout, the canvas only fills the free stage ---------- */
@media (max-width: 760px) {
  body { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); height: 100dvh;
    padding: max(10px, env(safe-area-inset-top)) 0 max(10px, env(safe-area-inset-bottom)); }
  #top, #list, #stage, #info { position: relative; inset: auto; transform: none; }
  #top { left: auto; margin: 0 12px; width: auto; padding: 7px 8px 7px 8px; gap: 10px; }
  .brand { width: 32px; height: 32px; }
  .brand img { width: 22px; height: 22px; }
  h1 { font-size: 15px; }
  .by { display: none; }
  #badge { font-size: 10px; padding: 4px 10px; }

  #list { top: auto; left: auto; bottom: auto; width: auto; min-width: 0; padding: 10px 0 0; border: 0; border-radius: 0; background: none;
    backdrop-filter: none; -webkit-backdrop-filter: none; }
  #list .eyebrow { display: none; }
  #chips { flex-direction: row; overflow-x: auto; overflow-y: hidden; gap: 8px; padding: 2px 12px 4px; scroll-snap-type: x proximity;
    scroll-padding: 0 12px; }
  #chips button { flex: none; white-space: nowrap; padding: 8px 14px 8px 9px; border-radius: 999px; gap: 8px; font-size: 13px;
    background: rgba(255, 255, 255, 0.55); box-shadow: inset 0 0 0 1px var(--hairline); scroll-snap-align: center; }
  #chips button.on { box-shadow: 0 4px 14px rgba(33, 57, 91, 0.1), inset 0 0 0 1px rgba(255, 255, 255, 0.95); }
  .swatch { width: 14px; height: 14px; }

  #stage { min-height: 0; }

  /* The sheet sits outside the canvas, so no blur has to be recomputed under a live
     render every frame; a solid frosted fill reads the same on the static wash. */
  #info { right: auto; bottom: auto; width: auto; margin: 0 12px; padding: 16px 18px 14px; border-radius: 22px;
    background: var(--glass-strong); backdrop-filter: none; -webkit-backdrop-filter: none; }
  #info::before { left: 18px; right: 18px; }
  #info h2 { font-size: 26px; margin-top: 3px; }
  #cut { font-size: 11px; }
  .icon-btn { all: unset; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--ink-soft);
    background: rgba(255, 255, 255, 0.7); border: 1px solid var(--hairline); cursor: pointer; flex: none; }
  .icon-btn[aria-expanded="true"] { color: var(--accent); border-color: rgba(46, 108, 240, 0.4); }
  .stats { margin: 12px 0 10px; gap: 8px; }
  .stats div { padding: 8px 10px; }
  dd { font-size: 18px; }
  #note { display: none; margin: 0 0 12px; font-size: 13px; }
  #info.open #note { display: block; }
  .switch { padding: 6px 12px 6px 7px; font-size: 13px; }
  .hint { display: none; }
  #err { top: 70px; }
}

@media (prefers-reduced-motion: reduce) {
  .brand img { animation: none; }
  * { transition-duration: 0s !important; }
}
