/* css/pages/own_rail.css */

:root {
  /* Warm & Energetic Theme: Gold/Orange/Green */
  --rail-primary: #fffbeb; /* Warm cream background */
  --rail-secondary: #fce7f3; /* Soft warm secondary */
  --rail-accent: #d97706; /* Strong Amber/Gold */
  --rail-text: #451a03; /* Warm dark brown text */
  --rail-gradient: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  --rail-highlight: #f59e0b; /* Bright Orange-Gold */
  --rail-safe-green: #10b981; /* Reassuring Green */

  /* Retaining some updated vars for compatibility if needed */
  --healing-pink: #f472b6;
  --healing-blue: #10b981; /* Mapped to Green now */
}

.main-content {
  animation: fadeIn 1s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes rollIn {
  from {
    opacity: 0;
    transform: translateX(-50px) rotate(-10deg);
  }
  to {
    opacity: 1;
    transform: translateX(0) rotate(0);
  }
}

/* --- Background Effects (Golden Journey) --- */
/* --- Background Effects (Golden Journey - Persistent Trail) --- */
.background-rail-track {
  position: absolute; /* Changed from fixed to absolute to stick to the page */
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 100%; /* Will cover the wrapper */
  pointer-events: none;
  z-index: 0; /* Behind content but accessible for visuals */
}

/* The actual trail being drawn */
.background-rail-progress {
  width: 100%;
  height: 0;
  background: linear-gradient(
    to bottom,
    var(--rail-secondary),
    var(--rail-highlight),
    var(--rail-accent)
  );
  box-shadow:
    0 0 15px var(--rail-highlight),
    0 0 30px var(--rail-accent);
  border-radius: 2px;
  position: relative;
  transition: height 0.1s linear;
}

/* Glowing Head - hidden by default until drawing starts */
.background-rail-progress::after {
  content: "";
  position: absolute;
  bottom: -15px;
  left: -13px;
  width: 30px;
  height: 30px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 0 30px 10px var(--rail-highlight);
  z-index: 2;
  opacity: 0;
  transform: scale(0.5);
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

/* Show head when drawing active */
.background-rail-progress.is-drawing::after {
  opacity: 1;
  transform: scale(1);
}

/* Finale Message */
.rail-finale-message {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: white; /* Or transparent/gold text */
  padding: 1rem 2rem;
  border-radius: 50px;
  color: var(--rail-accent);
  font-weight: bold;
  font-size: 1.5rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  text-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.2);
  border: 2px solid var(--rail-highlight);
}

.rail-finale-message.animate-fly-away {
  animation: flyAwayMessage 4s forwards ease-in-out;
}

@keyframes flyAwayMessage {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.5);
  }
  10% {
    opacity: 1;
    transform: translate(-50%, -50px) scale(1.1);
  }
  20% {
    transform: translate(-50%, -60px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -300px) scale(0.8);
    filter: blur(5px);
  }
}

#ember-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  pointer-events: none;
  overflow: hidden;
}

.ember {
  position: absolute;
  bottom: -20px;
  background: radial-gradient(circle, #fff, var(--rail-highlight));
  border-radius: 50%;
  opacity: 0;
  animation: riseUp linear infinite;
}

@keyframes riseUp {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.5);
  }
  20% {
    opacity: 0.8;
    transform: translateY(-100px) scale(1);
  }
  80% {
    opacity: 0.5;
  }
  100% {
    opacity: 0;
    transform: translateY(-100vh) scale(0.2);
  }
}

/* --- Existing Styles --- */

@media (max-width: 900px) {
  .background-rail-track {
    display: none;
  } /* Hide rail on small screens */
}

.chapter-hero {
  text-align: center;
  padding: 5rem 2rem;
  background: var(--rail-gradient);
  border-radius: 40px;
  margin-bottom: 4rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(245, 158, 11, 0.15);
}

.hero-icon-wrap {
  font-size: 4rem;
  color: var(--rail-accent);
  margin-bottom: 2rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-15px);
  }
}

h1 {
  font-size: 3rem;
  color: var(--rail-text);
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

h1 span {
  display: block;
  font-size: 1.5rem;
  color: var(--rail-accent);
  margin-top: 0.5rem;
  font-weight: 400;
}

.line {
  width: 60px;
  height: 4px;
  background: var(--rail-accent);
  margin: 2rem auto;
  border-radius: 2px;
}

.hero-subtitle {
  font-size: 1.2rem;
  color: var(--rail-accent);
  margin-bottom: 2rem;
  display: inline-block;
  animation: rollIn 1.2s cubic-bezier(0.23, 1, 0.32, 1);
}

.content-body {
  max-width: 900px;
  margin: 0 auto;
  line-height: 2;
  color: var(--rail-text);
}

.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}

/* Content Cards */
.content-card {
  background: white;
  padding: 3.5rem;
  border-radius: 30px;
  box-shadow: 0 10px 40px rgba(217, 119, 6, 0.08); /* Warm Amber Shadow */
  margin-bottom: 4rem;
  border: 1px solid rgba(254, 243, 199, 0.8); /* Warm border */
  position: relative;
  overflow: hidden;
}

/* Specific Card Adjustments */
.lead-card {
  background: white;
  /* Special styling for intro card if needed */
}

/* Reset or adjust internal headings */
.content-card h2 {
  margin-top: 0;
  padding-top: 0;
  border-left: 6px solid var(--rail-highlight); /* Bright Orange */
  padding-left: 1.5rem;
}

/* Adjust Text sizes inside cards */
.lead-text-content {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--rail-accent);
  margin-bottom: 3rem;
  line-height: 2;
  text-align: center;
}


.highlight-box {
  background: var(--rail-primary);
  padding: 3rem;
  border-radius: 20px;
  margin: 3rem 0;
  color: var(--rail-text);
  font-weight: 500;
  text-align: center;
  position: relative;
  overflow: visible; /* Allow particles to fly out */
  cursor: pointer;
  transition: transform 0.1s;
  user-select: none;
  box-shadow: 0 0 0 rgba(245, 158, 11, 0);
  border: 2px solid transparent;
}

/* Pulse animation to invite clicking */
.highlight-box:not(.clicked-once) {
    animation: gentlePulse 2s infinite;
}

@keyframes gentlePulse {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); border-color: rgba(245, 158, 11, 0.1); }
    70% { box-shadow: 0 0 0 15px rgba(245, 158, 11, 0); border-color: rgba(245, 158, 11, 0.4); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); border-color: rgba(245, 158, 11, 0.1); }
}

.highlight-box:active {
    transform: scale(0.98);
}

.highlight-box::after {
    content: "クリックして可能性を解放！";
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: var(--rail-accent);
    opacity: 0.7;
    transition: opacity 0.3s;
}

.highlight-box.clicked-once::after {
    opacity: 0;
}

/* Burst Particles */
.burst-particle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: var(--rail-highlight);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10;
}

h3 {
  font-size: 1.6rem;
  margin: 4rem 0 2rem;
  color: var(--rail-accent);
  text-align: center; /* Center H3s inside cards for balance */
}

/* Canvas Box & Particles */
.canvas-box {
  background: white;
  border: 2px dashed var(--rail-highlight);
  border-radius: 30px;
  padding: 3rem;
  margin: 4rem 0;
  text-align: center;
  position: relative;
  overflow: hidden;
  cursor: crosshair;
}

.canvas-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--rail-highlight); /* Gold particles */
  border-radius: 50%;
  pointer-events: none;
  animation: particleFade 1s forwards;
  z-index: 5;
}

@keyframes particleFade {
  to {
    opacity: 0;
    transform: translateY(-20px) scale(0);
  }
}

/* Strategy Cards */
.mountain-strategy {
  display: flex;
  gap: 2rem;
  margin: 3rem 0;
  flex-wrap: wrap;
  justify-content: center;
}

.strategy-card {
  flex: 1;
  min-width: 250px;
  background: white;
  padding: 2rem;
  border-radius: 20px;
  border: 2px solid transparent;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.03);
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
  cursor: pointer;
  overflow: visible; /* Allow badge to peek out */
  margin-top: 15px; /* Space for the badge */
}

.strategy-card:hover {
  transform: translateY(-10px);
  border-color: var(--rail-highlight);
  box-shadow: 0 15px 35px rgba(245, 158, 11, 0.2);
}

.card-visual {
  position: relative;
  height: 100px; /* Space for icon and animation */
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1rem;
  overflow: hidden; /* Keep animation contained within the visual area, not the whole card */
  border-radius: 10px; /* Optional: rounds corners of the animation area */
}

.strategy-icon {
  font-size: 3rem;
  color: var(--rail-accent);
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

/* Hide icon when animating */
.strategy-card.is-active .strategy-icon {
  opacity: 0;
  transform: scale(0.5);
}

/* Animation Stage */
.animation-stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.strategy-card.is-active .animation-stage {
  opacity: 1;
}

/* Common Elements */
.mountain {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 30px solid transparent;
  border-right: 30px solid transparent;
  border-bottom: 50px solid #a8a29e; /* Stone Gray */
  z-index: 1;
}

.mountain::after {
  /* Snow cap */
  content: "";
  position: absolute;
  top: 6px;
  left: -12px;
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 15px solid white;
}

.path-head {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--rail-highlight);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--rail-highlight);
  z-index: 10;
  opacity: 0; /* Hidden by default */
}

/* --- Specific Animations --- */

/* 1. Avoid (Go Around) */
#card-avoid.is-active .path-head {
  animation: anim-avoid 2s ease-in-out forwards;
}

@keyframes anim-avoid {
  0% {
    opacity: 1;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) scale(1);
  }
  20% {
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
  }
  40% {
    bottom: 20px;
    left: 20%;
    transform: translateX(0);
  } /* Swerve Left */
  60% {
    bottom: 40px;
    left: 20%;
  }
  80% {
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
  } /* Back to center behind mtn */
  100% {
    opacity: 0;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) scale(0.5);
  }
}

/* 2. Drill (Tunnel Through) */
#card-drill.is-active .path-head {
  animation: anim-drill 2s cubic-bezier(0.5, 0, 0.2, 1) forwards;
}

#card-drill.is-active .tunnel-hole {
  position: absolute;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 16px;
  background: #444;
  border-radius: 50%;
  z-index: 2;
  opacity: 0;
  animation: appear-hole 0.1s linear 0.7s forwards;
}

@keyframes anim-drill {
  0% {
    opacity: 1;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
  }
  30% {
    bottom: 25px;
  } /* Hit mountain base */
  35% {
    bottom: 25px;
    transform: translateX(-52%);
  } /* Shake */
  40% {
    bottom: 25px;
    transform: translateX(-48%);
  }
  45% {
    bottom: 25px;
    transform: translateX(-50%) scale(1.2);
  } /* Power up */
  100% {
    bottom: 90px;
    opacity: 0;
  } /* Blast through */
}

@keyframes appear-hole {
  to {
    opacity: 1;
  }
}

.debris-particles {
  position: absolute;
  bottom: 30px;
  left: 50%;
  width: 4px;
  height: 4px;
  background: transparent;
  box-shadow:
    -10px 10px 0 #888,
    10px 5px 0 #888,
    0 15px 0 #888;
  opacity: 0;
  transform: translateX(-50%);
}

#card-drill.is-active .debris-particles {
  animation: debris-scatter 0.5s ease-out 0.7s forwards;
}

@keyframes debris-scatter {
  0% {
    opacity: 1;
    transform: translateX(-50%) scale(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) scale(2) translateY(20px);
  }
}

/* 3. Climb (Go Over) */
#card-climb.is-active .path-head {
  animation: anim-climb 2.5s linear forwards;
}

@keyframes anim-climb {
  0% {
    opacity: 1;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
  }
  15% {
    bottom: 10px;
    left: 50%;
  }
  /* Climb Left Face */
  40% {
    bottom: 40px;
    left: 35%;
  }
  /* Summit */
  50% {
    bottom: 65px;
    left: 50%;
    transform: translateX(-50%) scale(1.2);
    box-shadow: 0 0 20px white;
  }
  /* Down Right Face */
  70% {
    bottom: 40px;
    left: 65%;
    transform: translateX(0);
  }
  90% {
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
  }
  100% {
    bottom: 0;
    left: 50%;
    opacity: 0;
    transform: translateX(-50%);
  }
}

/* Badge Style moved here for context */
.strategy-card .badge {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--rail-accent);
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.strategy-card h4 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: var(--rail-text);
  font-weight: bold;
}

.strategy-card p {
  font-size: 0.9rem;
  color: #666;
  line-height: 1.6;
}

/* Quote Section */
.quotes-container {
  margin: 6rem 0;
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.quote-item {
  background: linear-gradient(
    145deg,
    #ffffff,
    #fffbeb
  ); /* Subtle warm gradient */
  padding: 4rem 3rem 3rem; /* More top padding for the quote mark */
  border-radius: 20px;
  border-left: 8px solid var(--rail-highlight); /* Gold accent line */
  box-shadow: 0 15px 40px rgba(217, 119, 6, 0.1); /* Warm shadow */
  position: relative;
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
}

.quote-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 25px 50px rgba(217, 119, 6, 0.15);
}

.quote-item::before {
  content: "“";
  position: absolute;
  top: -10px;
  left: 20px;
  font-size: 8rem;
  color: var(--rail-highlight); /* Gold quote mark */
  opacity: 0.2;
  font-family: serif;
  line-height: 1;
}

.quote-text {
  font-size: 1.2rem;
  font-weight: 500;
  line-height: 2;
  margin-bottom: 2rem;
  color: #451a03; /* Deep brown */
  font-family:
    "YakuHanJP", "Hiragino Mincho ProN", serif; /* Serif for elegance */
  position: relative;
  z-index: 2;
}

.quote-author {
  text-align: right;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--rail-accent);
  margin-top: 1rem;
  font-family: sans-serif; /* Contrast prompt */
}

.quote-author::before {
  content: "― ";
}

/* Footer Nav */
.footer-navigation {
  margin-top: 6rem;
  padding-top: 3rem;
  border-top: 1px solid var(--rail-secondary);
  display: flex;
  justify-content: center;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: var(--rail-text);
  font-weight: 700;
  padding: 1.2rem 3rem;
  background: white;
  border-radius: 50px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.back-link:hover {
  background: var(--healing-blue);
  color: white;
  transform: scale(1.05);
}

/* --- Flip Cards for Destiny vs Life --- */
.flip-card-container {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 3rem 0;
  flex-wrap: wrap;
}

.flip-card {
  background-color: transparent;
  width: 250px;
  height: 200px;
  perspective: 1000px; /* Remove if you don't want the 3D effect */
  cursor: pointer;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s;
  transform-style: preserve-3d;
  box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
  border-radius: 15px;
}

.flip-card:hover .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.flip-card-front {
  background: white;
  border: 2px solid var(--rail-highlight);
  color: var(--rail-text);
}

.flip-card-front i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--rail-accent);
}

.flip-card-front h3 {
    margin: 0;
    font-size: 1.5rem;
}

.flip-card-back {
  background: var(--rail-gradient);
  color: var(--rail-text);
  transform: rotateY(180deg);
  border: 2px solid var(--rail-accent);
}

.flip-card-back h3 {
    font-size: 1.2rem;
    margin: 0 0 0.5rem 0;
    color: var(--rail-accent);
}

.flip-card-back p {
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.4;
}

/* --- Cosmos & Earth Possibility Effect --- */
#cosmos-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: black;
    z-index: 9999;
    opacity: 0;
    pointer-events: none; /* transparent to clicks when hidden */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 1s ease-in-out;
}

#cosmos-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Stars background effect */
#cosmos-overlay::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(white, rgba(255,255,255,.2) 2px, transparent 3px),
        radial-gradient(white, rgba(255,255,255,.15) 1px, transparent 2px),
        radial-gradient(white, rgba(255,255,255,.1) 2px, transparent 3px);
    background-size: 550px 550px, 350px 350px, 250px 250px;
    background-position: 0 0, 40px 60px, 130px 270px;
}

.cosmos-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
}

/* CSS Earth */
.cosmos-earth {
    width: 250px; /* Made slightly larger for better impact */
    height: 250px;
    border-radius: 50%;
    /* Use the generated image with gradient fallback */
    background: 
        url('../../images/earth.png') no-repeat center center / 110%, 
        radial-gradient(circle at 30% 30%, #4facfe, #00f2fe, #0093E9, #00468c 80%, #001233 100%);
    
    box-shadow: 
        inset -30px -30px 80px rgba(0,0,0,0.8), /* Shadow side correction */
        0 0 40px rgba(79, 172, 254, 0.4), /* Outer Atmosphere glow */
        0 0 80px rgba(79, 172, 254, 0.1);
    position: relative;
    transform: scale(0);
    transition: transform 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#cosmos-overlay.active .cosmos-earth {
    transform: scale(1); /* Pop in */
}

/* Text Burst Elements */
.cosmos-word {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    color: #fff;
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 20px var(--rail-highlight);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
}
