/* =========================
   Global variables
========================= */
:root {
  --primary: #212631;
  --accent: #2b3646;
  --hover-accent: rgba(100, 129, 166, 0.8);
  --text-main: #e6e6eb;
  --glass-bg: rgba(255, 255, 255, 0.08);
  --text-shadow-outline:
    -1px -1px 0 var(--accent),
     1px -1px 0 var(--accent),
    -1px  1px 0 var(--accent),
     1px  1px 0 var(--accent);
}

/* =========================
   Base
========================= */
body {
  margin: 0;
  padding: 16px;
  color: var(--text-main);
  font-family: "Fredoka One", system-ui, sans-serif;
  background: url("/static/res/pet_background.webp") repeat;
  background-color: var(--primary);
  background-blend-mode: overlay;
  min-height: 100dvh;
}

/* =========================
   Headings
========================= */
h1 {
  text-align: center;
  font-size: 2.8rem;
  margin-bottom: 16px;
  color: white;
  letter-spacing: 0.4px;

  text-shadow: var(--text-shadow-outline);
  -webkit-text-stroke: 1px var(--accent);
}

/* =========================
   Feed container
========================= */
#hatch-feed {
  font-size: 1.2rem;
  max-width: 720px;
  margin: auto;
}

/* =========================
   Hatch cards
========================= */
.hatch-card {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  margin-bottom: 12px;
  border-radius: 16px;
  overflow: hidden;
  color: white;
  border: 2px solid rgba(var(--hatch-rgb), 0.55);
  background: var(--glass-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  -webkit-text-stroke: 0;
  transition: transform 120ms ease, box-shadow 120ms ease;
  contain: layout paint;
  transform: translateZ(0);
}

.hatch-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      135deg,
      rgba(var(--hatch-rgb), 0.5) 0%,
      rgba(var(--hatch-rgb), 0.15) 100%
    );
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: 1;
  border-radius: inherit;
  inset: -1px;
}

.hatch-card > * {
  position: relative;
  z-index: 2;
}

.hatch-card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 0 16px rgba(var(--hatch-rgb), 0.3),
    0 10px 24px rgba(0, 0, 0, 0.35);
}

/* =========================
   Hatch content
========================= */
.hatch-content {
  flex: 1;
  min-width: 0;
}

.hatch-title {
  font-size: 1.6rem;
  margin-bottom: 6px;
  color: white;
  text-shadow:
    0 1px 4px rgba(0, 0, 0, 0.8),
    0 0 12px rgba(var(--hatch-rgb), 0.35);
  -webkit-text-stroke: 0;
}

.hatch-content > div:not(.hatch-title):not(.hatch-time) {
  opacity: 0.85;
  font-size: 1.05rem;
}

.hatch-meta {
  margin-top: 4px;
}

.hatch-time {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 8px;
  font-size: 0.75rem;
  opacity: 0.7;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
}

/* =========================
   Inline icon images
========================= */
.hatch-content img {
  height: 1em;
  width: 1em;
  vertical-align: middle;
  margin-right: 4px;
  object-fit: contain;
  -webkit-text-stroke: 0;
}

/* =========================
   Animations
========================= */
@keyframes hatch-pop {
  0% {
    opacity: 0;
    transform: translateY(-20px) scale(0.9);
    filter: brightness(1.8);
  }
  50% {
    opacity: 1;
    transform: translateY(4px) scale(1.04);
    filter: brightness(1.2);
  }
  70% {
    transform: translateY(-2px) scale(0.99);
  }
  100% {
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
}

.hatch-card.live {
  animation: hatch-pop 400ms cubic-bezier(.2, .8, .2, 1);
}

@keyframes xl-pulse {
  0%   {
    box-shadow:
      0 0 8px rgba(var(--hatch-rgb), 0.3),
      0 0 0 0 rgba(var(--hatch-rgb), 0.4);
    border-color: rgba(var(--hatch-rgb), 0.55);
    filter: brightness(1);
  }
  50%  {
    box-shadow:
      0 0 24px rgba(var(--hatch-rgb), 0.6),
      0 0 48px rgba(var(--hatch-rgb), 0.25),
      inset 0 0 12px rgba(var(--hatch-rgb), 0.15);
    border-color: rgba(var(--hatch-rgb), 0.9);
    filter: brightness(1.08);
  }
  100% {
    box-shadow:
      0 0 8px rgba(var(--hatch-rgb), 0.3),
      0 0 0 0 rgba(var(--hatch-rgb), 0.4);
    border-color: rgba(var(--hatch-rgb), 0.55);
    filter: brightness(1);
  }
}

.hatch-card.xl {
  animation: xl-pulse 2s ease-in-out infinite;
}

.hatch-card.live.xl {
  animation:
    hatch-pop 400ms cubic-bezier(.2, .8, .2, 1),
    xl-pulse 2s 400ms ease-in-out infinite;
}

@keyframes shimmer {
  from { background-position: -200% 0; }
  to   { background-position: 200% 0; }
}

.hatch-card.live::after {
  content: "";
  position: absolute;
  inset: -25%;
  background:
    linear-gradient(
      120deg,
      transparent 20%,
      rgba(var(--hatch-rgb), 0.7),
      rgba(255, 255, 255, 0.3),
      rgba(var(--hatch-rgb), 0.7),
      transparent 80%
    );
  background-size: 200% 100%;
  mix-blend-mode: screen;
  opacity: 0.9;
  animation: shimmer 1.5s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
  border-radius: inherit;
}

.hatch-card.live::after {
  content: "";
  position: absolute;
  inset: -25%;
  background:
    linear-gradient(
      120deg,
      transparent 20%,
      rgba(var(--hatch-rgb), 0.7),
      rgba(255, 255, 255, 0.3),
      rgba(var(--hatch-rgb), 0.7),
      transparent 80%
    );
  background-size: 200% 100%;
  mix-blend-mode: screen;
  opacity: 0.9;
  animation: shimmer 600ms cubic-bezier(.2, .9, .2, 1);
  pointer-events: none;
  z-index: 0;
  border-radius: inherit;
}

.hatch-icon {
  height: 1.2em;
  width: 1.2em;
  vertical-align: middle;
  margin-right: 4px;
  object-fit: contain;
  -webkit-text-stroke: 0;
}
/* =========================
   Pet image
========================= */
.hatch-image {
  width: 156px;
  height: 156px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 8px;
  filter:
    drop-shadow(0 0 12px rgba(var(--hatch-rgb), 0.4))
    drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}

/* =========================
   Navigation
========================= */
.nav-fixed {
  position: fixed;
  top: 16px;
  z-index: 1000;
  font-family: "Fredoka One", sans-serif;
  user-select: none;
  text-decoration: none;
}

.nav-left {
  left: 18px;
  font-size: 22px;
  color: white;
  transition: transform 0.15s ease, text-shadow 0.15s ease;
}

.nav-left:hover {
  transform: scale(1.05);
  text-shadow: 0 0 8px var(--hover-accent);
}

.nav-right {
  right: 18px;
  display: flex;
  align-items: center;
}

.redirect-icon {
  width: clamp(36px, 4vw, 48px);
  height: clamp(36px, 4vw, 48px);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.redirect-icon:hover {
  transform: scale(1.15);
  filter: drop-shadow(0 0 8px var(--hover-accent));
}

/* =========================
   Hatch controls (sorting)
========================= */
.hatch-controls {
  max-width: 720px;
  margin: 0 auto 14px auto;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.hatch-controls button {
  padding: 6px 12px;
  border-radius: 8px;
  border: 2px solid var(--accent);
  background: var(--glass-bg);
  color: white;
  font-family: "Fredoka One", system-ui, sans-serif;
  font-size: inherit;
  cursor: pointer;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  -webkit-text-stroke: 0;
  transition:
    background 120ms ease,
    transform 120ms ease,
    box-shadow 120ms ease;
}

.hatch-controls button:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 8px var(--hover-accent);
}

.hatch-controls button.active {
  background: var(--accent);
}

#sort-dir {
  min-width: 44px;
  font-weight: bold;
}

/* =========================
   Responsive
========================= */
@media (max-width: 520px) {
  .hatch-image {
    width: 80px;
    height: 80px;
  }

  .hatch-title {
    font-size: 1.2rem;
  }

  h1 {
    font-size: 2rem;
  }
}

/* =========================
   Reduced motion
========================= */
@media (prefers-reduced-motion: reduce) {
  .hatch-card,
  .hatch-card.live,
  .hatch-card.xl,
  .hatch-card.live.xl {
    animation: none;
  }

  .hatch-card.live::after {
    animation: none;
    opacity: 0;
  }

  .hatch-card:hover {
    transform: none;
  }
}
