:root {
  --ground: #062314;
  --panel: rgba(4, 22, 13, 0.86);
  --cream: #F6EEDC;
  --sage: #BFD6BC;
  --red: #E8452C;
  --yellow: #F2B705;
  --blue: #1B6CA8;

  --edge: rgba(246, 238, 220, 0.22);
  --column: 34rem;
  --safe-top: max(1.15rem, env(safe-area-inset-top));
  --safe-bottom: max(1.15rem, env(safe-area-inset-bottom));
}

*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  background: var(--ground);
  color: var(--cream);
  font: 400 17px/1.55 Karla, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

::selection {
  background: var(--blue);
  color: var(--cream);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 3px;
}

a { color: var(--cream); }

/* --- foliage ------------------------------------------------------------ */

.foliage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.frond {
  position: absolute;
  width: auto;
  will-change: transform;
}

/* The two vines run across the top and the bottom. */
.frond-vine-top {
  width: 165vw;
  left: -32vw;
  top: -42vw;
  filter: brightness(0.66) saturate(0.92);
}

.frond-vine-bottom {
  width: 175vw;
  left: -38vw;
  bottom: -62vw;
  transform: scaleY(-1);
  filter: brightness(0.6) saturate(0.9);
}

/* Leaves break in from the edges and corners, and run off-screen. */
.frond-monstera-right {
  width: 64vw;
  top: -8vw;
  right: -30vw;
  transform: rotate(22deg);
  filter: brightness(0.95) saturate(1.02);
}

.frond-monstera-left {
  width: 58vw;
  top: 26vh;
  left: -33vw;
  transform: rotate(-28deg);
  filter: brightness(0.56) saturate(0.85);
}

.frond-banana {
  width: 52vw;
  bottom: 18vh;
  right: -30vw;
  transform: rotate(-46deg);
  filter: brightness(0.46) saturate(0.78);
}

.frond-palm {
  width: 82vw;
  bottom: -22vh;
  left: -30vw;
  transform: rotate(26deg);
  filter: brightness(0.8) saturate(0.95);
}

/* Keeps text legible over everything above. */
.scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(78% 24% at 68% 0%, rgba(242, 183, 5, 0.09), transparent 72%),
    radial-gradient(108% 28% at 46% 0%, rgba(27, 108, 168, 0.15), transparent 72%),
    radial-gradient(76% 48% at 50% 50%, rgba(3, 18, 10, 0.74) 4%, rgba(3, 18, 10, 0.44) 58%, rgba(4, 22, 13, 0.08) 100%),
    linear-gradient(180deg, rgba(3, 14, 8, 0.52) 0%, rgba(4, 20, 12, 0.22) 26%, rgba(4, 20, 12, 0.24) 66%, rgba(3, 14, 8, 0.64) 100%);
}

/* --- shell -------------------------------------------------------------- */

.shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: var(--safe-top) 1.25rem var(--safe-bottom);
}

.masthead {
  padding: 0.35rem 0 0;
}

.wordmark {
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
  color: var(--cream);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: var(--column);
  margin: 0 auto;
  padding: 2rem 0;
}

.footpath {
  display: flex;
  justify-content: center;
  padding-top: 1rem;
}

.upload-link {
  background: none;
  border: 0;
  padding: 0.75rem 1rem;
  min-height: 44px;
  color: var(--sage);
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-thickness: 1px;
}

.upload-link:hover { color: var(--cream); }

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* --- the button --------------------------------------------------------- */

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.orb {
  display: grid;
  place-items: center;
  width: 152px;
  height: 152px;
  padding: 0;
  border: 3px solid var(--red);
  border-radius: 50%;
  background: var(--cream);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  transition: background-color 180ms ease, transform 180ms ease;
  -webkit-tap-highlight-color: transparent;
}

.orb > * { grid-area: 1 / 1; }

.orb:active { transform: scale(0.97); }

.orb-bars {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 56px;
}

.orb-bars i {
  display: block;
  width: 5px;
  height: var(--h, 40%);
  border-radius: 3px;
  background: var(--ground);
}

.orb-stop {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--cream);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 160ms ease, transform 160ms ease;
}

.orb.is-live {
  background: var(--red);
  border-color: var(--cream);
}

.orb.is-live .orb-bars { opacity: 0; }

.orb.is-live .orb-stop {
  opacity: 1;
  transform: scale(1);
}

.orb[disabled] {
  opacity: 0.55;
  cursor: default;
}

/* Fixed height, so idle and listening occupy exactly the same space. */
.stage-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  height: 5.6rem;
  margin-top: 1.5rem;
}

.orb-label {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  font-size: 1.45rem;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
}

.meter {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  opacity: 0;
  transition: opacity 220ms ease;
}

.meter.is-live { opacity: 1; }

.meter i {
  display: block;
  width: 5px;
  height: 100%;
  border-radius: 3px;
  background: var(--sage);
  transform: scaleY(0.08);
  transform-origin: center;
}

.blocked {
  max-width: 21rem;
  margin: 0;
  text-align: center;
  color: var(--cream);
}

/* --- thinking, nothing found, error ------------------------------------- */

.panel-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.75rem;
  text-align: center;
}

.calm-line {
  margin: 0;
  max-width: 22rem;
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1.4;
  color: var(--cream);
}

.again {
  min-height: 48px;
  padding: 0.7rem 1.6rem;
  border: 2px solid var(--cream);
  border-radius: 6px;
  background: none;
  color: var(--cream);
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  font-size: 1.1rem;
}

.again:hover {
  background: var(--cream);
  color: var(--ground);
}

/* --- results ------------------------------------------------------------ */

.results {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.results-heading {
  width: 100%;
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  font-size: clamp(2rem, 8vw, 2.7rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--cream);
}

.cards {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
}

.card {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 6px;
  padding: 1.35rem;
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}

.card-name {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--cream);
}

.card-sci {
  margin: 0.3rem 0 0;
  font-style: italic;
  color: var(--sage);
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.95rem;
}

.pill {
  padding: 0.35rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 4px;
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.3;
}

/* Blue morpho: not one blue but a sheen that shifts with the angle. The gradient
   is three times the width of the pill, so only part of it shows at a time and the
   colour appears to travel across the tab rather than cycle through it. */
.pill-confident {
  border-color: transparent;
  color: var(--cream);
  background-image: linear-gradient(110deg, #101C6B, #1B6CA8, #2FD3E8, #5B3FD6, #101C6B);
  background-size: 300% 100%;
  background-position: 0% 50%;
  box-shadow: inset 0 1px 0 rgba(246, 238, 220, 0.38);
  animation: morpho 6s ease-in-out infinite alternate;
}

@keyframes morpho {
  from { background-position: 0% 50%; }
  to { background-position: 100% 50%; }
}

.pill-likely {
  border-color: #2FD3E8;
  color: #2FD3E8;
}

.pill-possible {
  border-color: var(--red);
  color: #F4735F;
}

.pill-sound {
  border-color: rgba(246, 238, 220, 0.55);
  color: var(--cream);
}

.card-note {
  margin: 1rem 0 0;
  color: var(--cream);
}

/* --- the print ---------------------------------------------------------- */

.plate {
  margin: 0 0 1.4rem;
}

.print {
  position: relative;
  display: block;
  padding: 10px 10px 30px;
  background: var(--cream);
  border-radius: 0;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.5), 0 3px 8px rgba(0, 0, 0, 0.4);
  transform: rotate(var(--tilt, -1.5deg));
}

.print img {
  display: block;
  width: 100%;
  height: 210px;
  object-fit: cover;
  background: #DED3BC;
  filter: sepia(0.55) saturate(0.85) contrast(1.05);
}

/* two short strips of tape, opposite corners */
.print::before,
.print::after {
  content: "";
  position: absolute;
  width: 78px;
  height: 21px;
  background: linear-gradient(90deg,
    rgba(246, 238, 220, 0.2),
    rgba(246, 238, 220, 0.46) 18%,
    rgba(246, 238, 220, 0.46) 82%,
    rgba(246, 238, 220, 0.2));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
}

.print::before {
  top: -10px;
  left: -19px;
  transform: rotate(-38deg);
}

.print::after {
  bottom: -10px;
  right: -19px;
  transform: rotate(-38deg);
}

.plate-caption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin-top: 1.15rem;
  font-size: 0.9rem;
  color: var(--sage);
}

.plate-caption em { font-style: italic; }

.plate-caption a {
  color: var(--sage);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.plate-caption a:hover { color: var(--cream); }

/* alternating tilt, card to card */
.card:nth-child(odd) .print { --tilt: -1.6deg; }
.card:nth-child(even) .print { --tilt: 1.9deg; }

[hidden] { display: none !important; }

/* --- wider screens ------------------------------------------------------ */

@media (min-width: 700px) {
  .shell { padding-inline: 2rem; }

  .frond-vine-top { width: 108vw; left: -4vw; top: -56vw; }
  .frond-vine-bottom { width: 118vw; left: -9vw; bottom: -66vw; }
  .frond-monstera-right { width: 38vw; top: -6vw; right: -13vw; }
  .frond-monstera-left { width: 34vw; top: 22vh; left: -15vw; }
  .frond-banana { width: 30vw; bottom: 12vh; right: -13vw; }
  .frond-palm { width: 44vw; bottom: -16vh; left: -13vw; }

  .print img { height: 280px; }
  .card { padding: 1.75rem; }
}

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

  .pill-confident {
    animation: none;
    background-position: 50% 50%;
  }
}

.footpath.is-hidden { visibility: hidden; }
