/* ============================================================
   Sivakumar — Personal Portfolio
   Projects page only. Loaded AFTER css/style.css, so it reuses the
   shared dark-sunset tokens (--bg, --accent, --line, --muted, etc.),
   .float-card, .btn, .tag and the shared header/footer — this file
   only adds what's specific to the "chapters" story layout.
   Sections: Hero, Ember particles, Chapter nav, Quest path + nodes,
   Chapters (word/sigil/intro), Evolution visual, Project cards,
   Closing, Responsive.
   ============================================================ */

/* ---------- Hero ---------- */
.saga-hero { padding: 4rem 0 3rem; text-align: left; }
.saga-hero .lead { margin-top: 1rem; }
.scroll-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 2.4rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.4rem 0;
}
.scroll-indicator:hover { color: var(--accent); }
.scroll-arrow {
  width: 20px; height: 20px;
  animation: scrollBounce 1.6s ease-in-out infinite;
}
.scroll-arrow path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes scrollBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

/* ---------- The saga wrapper + ember particles ---------- */
.saga { position: relative; padding: 1rem 0 2rem; }
.ember-canvas { position: absolute; inset: 0; z-index: 0; pointer-events: none; }

/* ---------- Sticky chapter nav (desktop only) ---------- */
.chapter-nav {
  position: fixed;
  left: max(1.2rem, calc((100vw - 1100px) / 2 - 180px));
  top: 50%;
  transform: translateY(-50%);
  z-index: 60;
  display: none;
  flex-direction: column;
  gap: 1.1rem;
  width: 160px;
}
.chapter-nav-item {
  display: block;
  padding: 0.5rem 0.7rem;
  border-left: 2px solid var(--line);
  color: var(--muted);
  transition: border-color 0.25s ease, color 0.25s ease, transform 0.25s ease;
}
.chapter-nav-item:hover { color: var(--accent); transform: translateX(3px); }
.chapter-nav-item.is-active { border-left-color: var(--accent); color: var(--accent); transform: translateX(3px); }
.chapter-nav-num {
  display: block;
  font-family: "Playfair Display", serif;
  font-size: 1.1rem;
  font-weight: 700;
}
.chapter-nav-label { display: block; font-size: 0.74rem; line-height: 1.3; margin-top: 0.15rem; }

/* ---------- Quest path + nodes + orb ---------- */
.saga-path-col { position: relative; z-index: 1; }
.quest-path-svg { position: absolute; inset: 0; z-index: 0; overflow: visible; pointer-events: none; }
.quest-path-line {
  fill: none;
  stroke: url(#questGradient);
  stroke-width: 2.5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(245, 184, 61, 0.45));
}
@media (prefers-reduced-motion: reduce) {
  .quest-path-line { stroke-dasharray: none !important; stroke-dashoffset: 0 !important; }
}

.quest-node {
  position: absolute;
  width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--level-line);
  z-index: 1;
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.quest-node.is-active {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 6px rgba(245, 184, 61, 0.25);
  animation: nodePulse 1.6s ease-in-out infinite;
}
@keyframes nodePulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(245, 184, 61, 0.25); }
  50%      { box-shadow: 0 0 0 10px rgba(245, 184, 61, 0.12); }
}

.quest-orb {
  position: absolute;
  top: 0; left: 0;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #ffe27a;
  box-shadow: 0 0 10px 4px rgba(245, 184, 61, 0.8), 0 0 22px 10px rgba(255, 138, 61, 0.4);
  z-index: 2;
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .quest-node.is-active { animation: none; }
  .quest-orb { display: none; }
}

/* ---------- Chapters: faded word + sigil + intro ---------- */
.chapter-section {
  position: relative;
  padding: 6rem 0 1rem;
  /* Height is content-driven (auto), so this only ever clips the
     large decorative background word horizontally on very narrow
     screens — it never affects vertical scrolling. */
  overflow-x: hidden;
}
.chapter-section:first-of-type { padding-top: 2rem; }

.chapter-word {
  position: absolute;
  top: -0.5rem; left: 50%;
  /* --parallax is set continuously by projects.js as the page scrolls;
     kept as a separate custom property (rather than JS overwriting the
     whole `transform`) so it composes with the centering translateX
     instead of replacing it. */
  transform: translateX(-50%) translateY(var(--parallax, 0px));
  font-family: "Playfair Display", serif;
  font-size: clamp(3.6rem, 13vw, 10rem);
  font-weight: 700;
  color: rgba(245, 184, 61, 0.05);
  -webkit-text-stroke: 1px rgba(245, 184, 61, 0.14);
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  z-index: 0;
  will-change: transform;
}

.chapter-intro {
  position: relative;
  z-index: 1;
  max-width: 700px;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.chapter-intro.is-visible { opacity: 1; transform: translateY(0); }

.chapter-sigil { width: 88px; height: 88px; color: var(--accent); margin-bottom: 1.2rem; transform: scale(0.6); transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1); }
.chapter-intro.is-visible .chapter-sigil { transform: scale(1); }
.chapter-sigil-svg {
  width: 100%; height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
  opacity: 0.9;
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: sigilSpin 44s linear infinite;
}
@keyframes sigilSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .chapter-sigil-svg { animation: none; }
}

.chapter-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.6rem;
}
.chapter-realm { font-style: italic; color: var(--muted); margin: 0.4rem 0 1rem; }
.chapter-lead { color: var(--muted); font-size: 1.02rem; max-width: 620px; }

/* ---------- Evolution visual (Chapter 3 intro) ---------- */
.evolution-visual {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.8rem;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.evolution-visual.is-visible { opacity: 1; transform: translateY(0); }
.evolution-emblem { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.evolution-emblem .chapter-sigil-svg { width: 52px; height: 52px; }
.evolution-emblem span {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
}
.evolution-arrow { width: 130px; height: 20px; color: var(--accent); flex-shrink: 0; }
.evolution-arrow path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.evolution-arrow path:first-child {
  stroke-dasharray: 160;
  stroke-dashoffset: 160;
  transition: stroke-dashoffset 1.2s ease 0.3s;
}
.evolution-visual.is-visible .evolution-arrow path:first-child { stroke-dashoffset: 0; }
@media (prefers-reduced-motion: reduce) {
  .evolution-arrow path:first-child { stroke-dashoffset: 0; transition: none; }
}

/* ---------- Project cards ---------- */
.project-grid { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 3.4rem; margin-top: 2.6rem; }

.project-card {
  position: relative;
  width: min(440px, 47%);
  padding: 1.8rem 2rem;
  opacity: 0;
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.project-card.side-left { margin-right: auto; transform: perspective(900px) translateX(-46px) translateY(26px) rotateY(9deg); }
.project-card.side-right { margin-left: auto; transform: perspective(900px) translateX(46px) translateY(26px) rotateY(-9deg); }
.project-card.is-visible { opacity: 1; transform: perspective(900px) translateX(0) translateY(0) rotateY(0deg); }
.project-card.is-featured { width: min(560px, 64%); padding: 2.2rem 2.4rem; }

/* Thin animated gold shimmer border on hover/focus */
.project-card::before {
  content: "";
  position: absolute;
  inset: -1.5px;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(120deg, transparent 15%, var(--accent) 45%, var(--accent-dark) 55%, transparent 85%);
  background-size: 260% 100%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.project-card:hover::before, .project-card:focus-within::before {
  opacity: 1;
  animation: shimmerMove 2.6s linear infinite;
}
@keyframes shimmerMove {
  0% { background-position: 0% 0; }
  100% { background-position: 260% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .project-card { opacity: 1 !important; transform: none !important; transition: opacity 0.5s ease; }
  .project-card:hover::before, .project-card:focus-within::before { animation: none; opacity: 0.9; }
}

.project-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.9rem; }
.project-icon { width: 30px; height: 30px; color: var(--accent); flex-shrink: 0; }
.project-number {
  font-family: "Playfair Display", serif;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--ink);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
}
.project-card h3 { margin: 0 0 0.3rem; font-size: 1.35rem; }
.project-subtitle { color: var(--muted); font-family: "Inter", sans-serif; font-weight: 500; font-size: 0.9em; }
.project-company { color: var(--accent); font-weight: 600; margin: 0 0 0.4rem; }
.project-role { color: var(--muted); font-size: 0.92rem; margin: 0 0 0.9rem; }
.role-label {
  display: inline-block;
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--accent); background: var(--accent-soft);
  padding: 0.15rem 0.5rem; border-radius: 999px; margin-right: 0.4rem;
}
.project-desc { color: var(--muted); margin: 0 0 1.1rem; }
.project-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag-pill {
  font-size: 0.72rem; font-weight: 600;
  color: var(--accent);
  border: 1px solid rgba(245, 184, 61, 0.4);
  background: transparent;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
}

.project-badge {
  position: absolute;
  top: -14px; left: 1.6rem;
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: var(--ink);
  font-size: 0.72rem; font-weight: 700;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(255, 106, 43, 0.35);
}
.project-badge .project-icon { width: 13px; height: 13px; color: var(--ink); }

/* ---------- Closing ---------- */
.saga-closing { padding: 3rem 0 4rem; }
.quest-continues-card {
  text-align: center;
  padding: 3rem 2rem;
  max-width: 640px;
  margin: 0 auto;
}
.quest-continues-card h2 { margin-bottom: 0.8rem; }
.quest-continues-card p { color: var(--muted); max-width: 480px; margin: 0 auto 1.8rem; }
.quest-continues-actions { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (min-width: 1500px) {
  /* Only appears once the viewport is wide enough that the left gutter
     ((100vw - 1100px) / 2) comfortably exceeds the nav's own 160px
     width, so it never overlaps the centered content column. */
  .chapter-nav { display: flex; }
}

@media (max-width: 780px) {
  .saga-path-col { padding-left: 2.6rem; }
  .chapter-word { font-size: clamp(2.6rem, 22vw, 5rem); left: 1.2rem; transform: none; text-align: left; }
  .project-card,
  .project-card.is-featured,
  .project-card.side-left,
  .project-card.side-right {
    width: 100%;
    margin: 0;
    transform: translateY(26px);
  }
  .project-card.is-visible { transform: translateY(0); }
}
