/* ==============================================
   MIRIS.QUEST - MEMPHIS DESIGN SYSTEM
   Quest Log Sidebar Experience
   ============================================== */

/* ===== ROOT & TYPOGRAPHY ===== */
:root {
  /* Palette */
  --bg-main: #FFF8F0;
  --bg-sidebar: #F2E6D4;
  --text-primary: #2C2C3A;
  --text-body: #3A3A4A;
  --accent-red: #E8634A;
  --accent-blue: #3B82B8;
  --accent-yellow: #E8C547;
  --accent-green: #3DAA8E;
  --accent-pink: #E87BA8;
  --pattern-base: #D4C4B0;

  /* Dimensions */
  --sidebar-width: clamp(280px, 28vw, 500px);
  --main-width: clamp(auto, 72vw, calc(100% - 280px));

  /* Timings */
  --transition-fast: 200ms ease-out;
  --transition-medium: 400ms ease-out;
  --transition-slow: 600ms ease-out;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Nunito', sans-serif;
  font-size: clamp(0.95rem, 1.1vw, 1.1rem);
  line-height: 1.7;
  letter-spacing: 0.01em;
  color: var(--text-body);
  background-color: var(--bg-main);
}

/* Display font: Bungee Shade */
.hero-text,
.chapter-title {
  font-family: 'Bungee Shade', cursive;
  font-weight: 400;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Accent font: Silkscreen (pixel font) */
.inventory-label,
.xp-label,
.difficulty-rating,
.arsenal-label,
.party-class {
  font-family: 'Silkscreen', monospace;
  font-size: clamp(0.7rem, 0.9vw, 0.85rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-red);
}

/* ===== LAYOUT: CONTAINER & SIDEBAR ===== */
.container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background-color: var(--bg-sidebar);
  background-image:
    radial-gradient(circle 3px at 15% 25%, var(--accent-red) 100%, transparent 100%),
    radial-gradient(circle 4px at 42% 67%, var(--accent-blue) 100%, transparent 100%),
    radial-gradient(circle 3px at 78% 12%, var(--accent-yellow) 100%, transparent 100%),
    radial-gradient(circle 5px at 8% 78%, var(--accent-green) 100%, transparent 100%),
    radial-gradient(circle 3px at 65% 43%, var(--accent-pink) 100%, transparent 100%),
    radial-gradient(circle 4px at 35% 88%, var(--accent-blue) 100%, transparent 100%),
    radial-gradient(circle 3px at 82% 61%, var(--accent-red) 100%, transparent 100%),
    radial-gradient(polygon(0% 0%, 100% 0%, 100% 100%) 4px at 20% 40%, var(--accent-yellow) 100%, transparent 100%),
    radial-gradient(polygon(0% 0%, 100% 0%, 100% 100%) 5px at 70% 25%, var(--accent-pink) 100%, transparent 100%),
    radial-gradient(polygon(0% 0%, 100% 0%, 100% 100%) 4px at 45% 72%, var(--accent-blue) 100%, transparent 100%);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-attachment: fixed;
  z-index: 100;

  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1.5rem;
  gap: 2rem;

  /* Entry animation */
  animation: sidebar-slide-in 400ms ease-out forwards;
}

@keyframes sidebar-slide-in {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

/* Logo */
.logo {
  width: 100%;
  max-width: 120px;
  margin-bottom: 1rem;
}

.quest-scroll {
  width: 100%;
  height: auto;
  animation: logo-appear 400ms ease-out 200ms backwards;
}

@keyframes logo-appear {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ===== INVENTORY NAVIGATION ===== */
.inventory {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
  flex: 1;
}

.inventory-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  transition: all var(--transition-fast);

  animation: inventory-morph-in 200ms ease-out backwards;
}

/* Stagger each inventory item */
.inventory-item:nth-child(1) { animation-delay: 400ms + 0ms; }
.inventory-item:nth-child(2) { animation-delay: 400ms + 80ms; }
.inventory-item:nth-child(3) { animation-delay: 400ms + 160ms; }
.inventory-item:nth-child(4) { animation-delay: 400ms + 240ms; }
.inventory-item:nth-child(5) { animation-delay: 400ms + 320ms; }

@keyframes inventory-morph-in {
  from {
    opacity: 0;
    clip-path: circle(20%);
  }
  to {
    opacity: 1;
    clip-path: circle(100%);
  }
}

.inventory-icon {
  width: 48px;
  height: 48px;
  border: 2px solid var(--pattern-base);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.7);
  transition: all var(--transition-fast);
}

.inventory-item.active .inventory-icon {
  border-color: var(--accent-red);
}

.inventory-item:hover .inventory-icon {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(232, 99, 74, 0.2);
}

.inventory-icon svg {
  width: 100%;
  height: 100%;
}

.inventory-label {
  font-size: 0.7rem;
  text-align: center;
}

/* ===== XP COUNTER ===== */
.xp-counter {
  width: 90%;
  margin-top: auto;
  padding-top: 2rem;
  border-top: 1px solid var(--pattern-base);
}

.xp-label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: clamp(0.65rem, 0.85vw, 0.8rem);
}

#xp-percent {
  font-weight: 700;
  color: var(--accent-red);
}

.xp-bar {
  width: 100%;
  height: 12px;
  background-color: var(--pattern-base);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--accent-red);
}

.xp-fill {
  height: 100%;
  background: linear-gradient(
    45deg,
    var(--accent-red),
    var(--accent-red) 4px,
    rgba(255, 255, 255, 0.15) 4px,
    rgba(255, 255, 255, 0.15) 8px
  );
  background-size: 8px 100%;
  width: 0%;
  transition: width 300ms ease-out;
  border-radius: 6px;
}

/* ===== MAIN CONTENT AREA ===== */
.main-content {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  background-color: var(--bg-main);
  overflow-y: auto;
  overflow-x: hidden;
}

/* ===== CHAPTER STYLING ===== */
.chapter {
  min-height: 100vh;
  padding: 6rem 8% 4rem;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.chapter-marker {
  position: absolute;
  top: 4rem;
  right: 8%;
  width: 120px;
  height: 120px;
  opacity: 0.8;
}

.chapter-marker svg {
  width: 100%;
  height: 100%;
  animation: marker-rotate 20s linear;
}

.chapter:hover .chapter-marker svg {
  animation: marker-rotate 20s linear 0s running;
}

@keyframes marker-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Chapter 1: Origin Story */
.chapter-1 {
  background-color: var(--bg-main);
}

.chapter-bg-shape {
  position: absolute;
  top: 50%;
  left: 5%;
  width: 40vw;
  height: 40vw;
  max-width: 500px;
  max-height: 500px;
  opacity: 0;
  transform: scale(0.8) rotate(-15deg);
  animation: shape-emerge 400ms ease-out 1400ms forwards;
  pointer-events: none;
}

@keyframes shape-emerge {
  to {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.chapter-bg-shape svg {
  width: 100%;
  height: 100%;
}

.hero-text {
  font-size: clamp(2.5rem, 6vw, 5rem);
  position: relative;
  z-index: 2;
  margin-bottom: 2rem;
  opacity: 0;
  animation: hero-drop-in 60ms ease-out backwards;
  letter-spacing: 0.04em;
}

/* Stagger hero text character drop-in */
.hero-text::first-letter {
  animation: hero-drop-in 60ms ease-out 800ms backwards;
}

@keyframes hero-drop-in {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.origin-text {
  max-width: 600px;
  margin-bottom: 1.5rem;
  z-index: 2;
  position: relative;
  animation: fade-in 500ms ease-out 1400ms backwards;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Chapter 2: Active Quests */
.chapter-2 {
  background-color: var(--bg-main);
}

.chapter-title {
  font-size: clamp(2rem, 5vw, 4rem);
  margin-bottom: 3rem;
  margin-top: 0;
}

.quest-cards-container {
  display: flex;
  flex-direction: column;
  gap: 3rem;
  max-width: 700px;
}

.quest-card {
  border: 3px solid var(--accent-red);
  padding: 2rem;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-fast);
  opacity: 0;
  transform: translateX(60px);
  animation: card-slide-in 500ms ease-out forwards;
}

.quest-card.left {
  margin-left: 10%;
  animation-delay: 200ms;
}

.quest-card.right {
  margin-left: auto;
  margin-right: 10%;
  transform: translateX(-60px);
  animation-delay: 400ms;
}

@keyframes card-slide-in {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.quest-card:nth-child(3) {
  animation-delay: 600ms;
}

.quest-card:hover {
  border-color: var(--accent-red);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.quest-card-border {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 8px;
  overflow: hidden;
}

.zigzag-edge {
  width: 100%;
  height: 100%;
  animation: zigzag-wave 2s ease-in-out infinite paused;
}

.quest-card:hover .zigzag-edge {
  animation: zigzag-wave 2s ease-in-out infinite running;
}

@keyframes zigzag-wave {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(4px); }
}

.quest-title {
  font-family: 'Bungee Shade', cursive;
  font-size: clamp(1.5rem, 3vw, 2rem);
  color: var(--text-primary);
  margin-top: 1.5rem;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.difficulty-rating {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-family: 'Silkscreen', monospace;
  color: var(--accent-red);
  font-size: clamp(0.8rem, 1vw, 1rem);
}

.triangle {
  display: inline-block;
}

.quest-description {
  color: var(--text-body);
  line-height: 1.7;
}

/* Chapter 3: Arsenal */
.chapter-3 {
  background-color: var(--bg-main);
}

.arsenal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 2rem;
  max-width: 600px;
  margin-top: 2rem;
}

.arsenal-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-radius: 8px;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.arsenal-item:hover {
  transform: scale(1.05);
}

.arsenal-icon {
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.5);
  overflow: hidden;
}

.arsenal-icon svg {
  width: 100%;
  height: 100%;
  transition: clip-path var(--transition-medium);
  clip-path: circle(50%);
}

.arsenal-item[data-morph="pentagon"] .arsenal-icon svg:hover {
  clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
}

.arsenal-item[data-morph="hexagon"] .arsenal-icon svg:hover {
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.arsenal-item[data-morph="diamond"] .arsenal-icon svg:hover {
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.arsenal-item[data-morph="star"] .arsenal-icon svg:hover {
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.arsenal-label {
  text-align: center;
  font-size: clamp(0.8rem, 1vw, 0.95rem);
}

/* Chapter 4: Party Members */
.chapter-4 {
  background-color: var(--bg-main);
}

.party-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  max-width: 700px;
  margin-top: 2rem;
}

.party-card {
  background-color: rgba(255, 255, 255, 0.8);
  border: 3px solid var(--accent-red);
  padding: 2rem;
  border-radius: 8px;
  text-align: center;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.party-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(232, 99, 74, 0.15);
}

.party-avatar {
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(232, 99, 74, 0.1), rgba(59, 130, 184, 0.1));
  border: 2px solid var(--accent-red);
}

.party-avatar svg {
  width: 80px;
  height: 80px;
}

.party-class {
  font-size: clamp(0.85rem, 1vw, 1rem);
  margin: 0.5rem 0;
}

.party-bio {
  font-size: clamp(0.9rem, 1vw, 1.05rem);
  color: var(--text-body);
  line-height: 1.6;
}

/* Chapter 5: Quest Complete */
.chapter-5 {
  background-color: var(--bg-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 80vh;
}

.closing-text {
  max-width: 600px;
  margin: 2rem 0 3rem;
  font-size: clamp(1rem, 1.2vw, 1.2rem);
  line-height: 1.8;
}

.reward-items {
  display: flex;
  gap: 3rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 3rem;
}

.treasure-chest {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.treasure-chest svg {
  width: 100%;
  height: 100%;
}

.chest-lid {
  transition: transform var(--transition-medium);
  transform-origin: top center;
  transform: rotateX(0deg);
}

.treasure-chest:hover .chest-lid {
  transform: rotateX(-110deg);
}

.treasure-label {
  position: absolute;
  bottom: -28px;
  font-family: 'Silkscreen', monospace;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-red);
  opacity: 0;
  transition: opacity var(--transition-fast) 100ms;
}

.treasure-chest:hover .treasure-label {
  opacity: 1;
}

/* ===== RESPONSIVENESS ===== */
@media (max-width: 1024px) {
  .sidebar {
    width: 25vw;
  }

  .main-content {
    margin-left: 25vw;
    width: 75vw;
  }

  .chapter {
    padding: 4rem 6% 3rem;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 1.5rem;
    z-index: 50;
  }

  .logo {
    width: 80px;
    margin-bottom: 0;
  }

  .inventory {
    flex-direction: row;
    justify-content: flex-start;
    flex: none;
    gap: 1rem;
    width: auto;
  }

  .inventory-label {
    display: none;
  }

  .xp-counter {
    width: 100%;
    border-top: none;
    border-left: 1px solid var(--pattern-base);
    padding: 0 0 0 1.5rem;
    margin-top: 0;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
  }

  .chapter {
    padding: 3rem 5% 2rem;
  }

  .chapter-bg-shape {
    width: 60vw;
    height: 60vw;
  }

  .party-cards {
    grid-template-columns: 1fr;
  }

  .quest-card {
    margin-left: 0 !important;
    margin-right: 0 !important;
    transform: translateY(20px) !important;
    animation: card-slide-in-vertical 500ms ease-out forwards !important;
  }

  @keyframes card-slide-in-vertical {
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

@media (max-width: 480px) {
  .inventory-item {
    gap: 0.5rem;
  }

  .inventory-icon {
    width: 40px;
    height: 40px;
  }

  .chapter {
    padding: 2rem 4% 1.5rem;
  }

  .hero-text {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
  }

  .chapter-title {
    font-size: clamp(1.3rem, 4vw, 2rem);
  }

  .reward-items {
    gap: 1.5rem;
  }

  .treasure-chest {
    width: 80px;
    height: 80px;
  }
}

/* ===== SCROLL BEHAVIOR ===== */
.main-content::-webkit-scrollbar {
  width: 8px;
}

.main-content::-webkit-scrollbar-track {
  background: var(--bg-main);
}

.main-content::-webkit-scrollbar-thumb {
  background: var(--accent-red);
  border-radius: 4px;
}

.main-content::-webkit-scrollbar-thumb:hover {
  background: var(--accent-blue);
}
