/* ==========================================================
   Feed T-Rex — jungle page
   Same soft type + palette as the site, deeper jungle greens for the UI that floats over the scene.
   ========================================================== */

.trex-page {
  --jungle: #2f4a36;
  --jungle-deep: #1f3326;
  --leaf: #8fb37a;
  --glass: rgba(255, 253, 248, 0.94);
  --anger: 0.1;
  background: var(--bg) url("../assets/doodles.svg") 0 0 / 1400px auto repeat;
}

.trex-page .site-header,
.trex-page .site-header.is-scrolled {
  background: rgba(243, 246, 241, 0.95);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-bottom-color: var(--line);
}

.site-nav a[aria-current="page"] {
  color: var(--ink);
  background: var(--surface);
}

.jungle {
  position: relative;
  height: calc(100svh - var(--header-h));
  min-height: 520px;
  overflow: hidden;
  background: #a7b597;
  isolation: isolate;
}

.jungle-canvas,
.jungle-canvas canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.jungle-canvas canvas {
  opacity: 0;
  transition: opacity 1.2s ease;
  touch-action: manipulation;
}

.jungle.is-ready .jungle-canvas canvas {
  opacity: 1;
}

/* soft lens vignette, warming toward red as the T-Rex gets angrier */
.jungle-vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(24, 34, 22, 0.42) 100%);
}

.jungle-vignette::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 45%, transparent 50%, rgba(150, 40, 20, 0.5) 100%);
  opacity: calc((var(--anger) - 0.4) * 1.2);
  transition: opacity 0.6s ease;
}

.jungle-flash {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, rgba(255, 240, 220, 0.0) 30%, rgba(120, 30, 14, 0.7) 100%);
  opacity: 0;
}

.jungle-flash.is-on {
  animation: rex-flash 1.6s ease-out;
}

@keyframes rex-flash {
  0% {
    opacity: 0;
  }
  12% {
    opacity: var(--flash, 0.35);
  }
  100% {
    opacity: 0;
  }
}

/* ---------- copy + status ---------- */

.jungle-head {
  position: absolute;
  top: 20px;
  left: var(--gutter);
  z-index: 2;
  max-width: 380px;
  padding: 14px 18px 16px;
  border-radius: 20px;
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--line), 0 18px 40px -26px rgba(20, 30, 20, 0.5);
  pointer-events: none;
}

.jungle-kicker {
  margin: 0 0 2px;
  color: var(--sage-deep);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.jungle-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 1.1rem + 1.6vw, 2.4rem);
  font-variation-settings: "SOFT" 100, "WONK" 0;
  font-weight: 600;
  line-height: 1.05;
  color: var(--jungle-deep);
}

.jungle-head p:last-child {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 0.875rem;
  line-height: 1.5;
}

.rex-status {
  position: absolute;
  top: 20px;
  right: var(--gutter);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rex-mood {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--line);
}

.rex-mood-label {
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rex-mood-bar {
  position: relative;
  width: 96px;
  height: 8px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: #e3e8df;
}

.rex-mood-bar i {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #8fb37a, #e6b25a 55%, #c4502f);
  background-size: 96px 100%;
  transform: scaleX(0.1);
  transform-origin: left center;
  transition: transform 0.4s ease;
}

.rex-mood-word {
  min-width: 56px;
  color: var(--ink);
  font-weight: 800;
  font-size: 0.875rem;
}

.sound-toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  cursor: pointer;
}

.sound-toggle svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sound-toggle .sound-cone {
  fill: currentColor;
  stroke: none;
}

.sound-toggle .sound-off,
.sound-toggle[aria-pressed="false"] .sound-waves {
  display: none;
}

.sound-toggle[aria-pressed="false"] .sound-off {
  display: inline;
}

/* ---------- verdict ---------- */

.rex-verdict {
  position: absolute;
  top: 80px;
  right: var(--gutter);
  z-index: 3;
  display: grid;
  justify-items: center;
  gap: 2px;
  max-width: min(440px, calc(100% - 32px));
  padding: 14px 22px 16px;
  border-radius: 22px;
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--line), 0 24px 50px -24px rgba(20, 30, 20, 0.55);
  text-align: center;
  opacity: 0;
  transform: translateY(-12px) scale(0.96);
  transform-origin: top right;
  transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  pointer-events: none;
}

.rex-verdict.is-in {
  opacity: 1;
  transform: none;
}

.rex-verdict strong {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-variation-settings: "SOFT" 100;
  line-height: 1.1;
}

.rex-verdict[data-mood="happy"] strong {
  color: #3f6b4f;
}

.rex-verdict[data-mood="angry"] strong {
  color: #b5462a;
  letter-spacing: 0.02em;
}

.rex-verdict span {
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

/* ---------- the tray ---------- */

.feed-tray {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 3;
  width: min(1180px, calc(100% - 32px));
  padding: 12px 14px 10px;
  border-radius: 24px;
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--line), 0 30px 60px -30px rgba(20, 30, 20, 0.6);
  transform: translateX(-50%);
}

.feed-tray-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 8px;
}

.feed-tray-title {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 800;
  font-size: 0.9375rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-tray-link {
  flex: none;
  color: var(--sage-deep);
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
}

.feed-tray-link:hover {
  text-decoration: underline;
}

.feed-items {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}

.feed-card {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  min-width: 210px;
  max-width: 280px;
  padding: 10px 12px;
  border: 0;
  border-radius: 16px;
  background: #f4f7f1;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  scroll-snap-align: start;
  transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, opacity 0.3s ease;
}

.feed-card:hover:not(:disabled) {
  background: #e9f0e5;
  transform: translateY(-2px);
  box-shadow: inset 0 0 0 1px var(--line-strong), 0 10px 20px -14px rgba(20, 30, 20, 0.5);
}

.feed-card:focus-visible {
  outline: 2px solid var(--jungle);
  outline-offset: 2px;
}

.jungle.is-busy .feed-card:not(:disabled) {
  cursor: progress;
  opacity: 0.6;
}

.feed-card:disabled {
  cursor: default;
  opacity: 0.55;
}

.feed-card-dot {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.08);
}

.feed-card-text {
  display: grid;
  flex: 1;
  min-width: 0;
}

.feed-card-text strong {
  overflow: hidden;
  font-size: 0.9375rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-card-text small {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-card-tag {
  flex: none;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.feed-card[data-state="cooked"] .feed-card-tag {
  background: #dcebd3;
  color: #2f5a3a;
}

.feed-card[data-state="raw"] .feed-card-tag {
  background: #f7e4c8;
  color: #8a5a1c;
}

.feed-card[data-state="burnt"] .feed-card-tag {
  background: #e3dcd7;
  color: #4a3a32;
}

.feed-card[data-state="drink"] .feed-card-tag {
  background: #dbe9f2;
  color: #2f5470;
}

.feed-card.was-spat:disabled .feed-card-tag {
  background: #f3d5cc;
  color: #a2401f;
}

.model-credit {
  margin: 4px 4px 0;
  color: var(--ink-soft);
  font-size: 0.6875rem;
  text-align: right;
}

.model-credit a {
  color: inherit;
}

.poke-button:focus {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  z-index: 4;
  width: auto !important;
  height: auto !important;
  padding: 10px 18px !important;
  overflow: visible !important;
  clip: auto !important;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-weight: 700;
  white-space: nowrap;
  transform: translate(-50%, -50%);
}

/* ---------- loader ---------- */

.jungle-loader {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: radial-gradient(ellipse at 50% 40%, #c3cfb2, #9aab8b);
  color: var(--jungle-deep);
  transition: opacity 0.9s ease, visibility 0.9s;
}

.jungle.is-ready .jungle-loader {
  opacity: 0;
  visibility: hidden;
}

.jungle-loader-mark svg {
  width: 44px;
  height: 44px;
  fill: var(--jungle);
  animation: rex-step 1.4s ease-in-out infinite;
}

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

.jungle-loader-bar {
  position: relative;
  width: 200px;
  height: 6px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: rgba(31, 51, 38, 0.18);
}

.jungle-loader-bar i {
  position: absolute;
  inset: 0;
  background: var(--jungle);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.25s ease;
}

.jungle-loader-text {
  font-weight: 700;
  font-size: 0.9375rem;
}

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  .jungle-head {
    top: 12px;
    left: 12px;
    max-width: calc(100% - 132px);
    padding: 10px 14px;
  }

  .jungle-head p:last-child,
  .rex-mood-label,
  .jungle-kicker {
    display: none;
  }

  .rex-status {
    top: 12px;
    right: 12px;
    flex-direction: column;
    align-items: flex-end;
  }

  .rex-mood {
    min-height: 36px;
    padding: 0 12px;
  }

  .rex-mood-bar {
    width: 56px;
  }

  .rex-verdict {
    top: 112px;
    right: 10px;
    left: 10px;
    max-width: none;
    padding: 10px 16px 12px;
    transform-origin: top center;
  }

  .rex-verdict strong {
    font-size: 1.4rem;
  }

  .rex-verdict span {
    font-size: 0.875rem;
  }

  .feed-tray {
    bottom: 10px;
    width: calc(100% - 20px);
    padding: 10px 10px 8px;
    border-radius: 20px;
  }

  .feed-card {
    min-width: 180px;
  }

  .model-credit {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .jungle-loader-mark svg {
    animation: none;
  }

  .jungle-canvas canvas,
  .rex-verdict {
    transition: none;
  }
}
