/* ============================================================
   MY PATH PAGE — /public/css/my-path.css
   Busuu-style vertical learning path for role="user" students
   ============================================================ */

/* ── Design tokens ────────────────────────────────────────── */
:root {
  --path-max-width: 780px;
  --path-connector-size: 52px;
  --path-line-color: rgba(80, 47, 119, 0.22);
  --path-line-width: 3px;
  --card-radius: 22px;
  --card-shadow: 0 4px 24px rgba(80, 47, 119, 0.10);
  --card-shadow-hover: 0 10px 36px rgba(80, 47, 119, 0.18);
  --toggle-duration: 0.38s;
  --toggle-easing: cubic-bezier(0.4, 0, 0.2, 1);
  --locked-header-filter: grayscale(1) brightness(0.92);
  --brand-purple: #502f77;
  --brand-cyan: #00f0ff;
}

/* ── Page layout ──────────────────────────────────────────── */
.path-page {
  background: var(--background-gradient);
  min-height: 100vh;
  padding: 0 1rem 6rem;
  font-family: "Lexend Deca", "Noto Sans", Helvetica, sans-serif;
}

/* ── Hero banner ──────────────────────────────────────────── */
.path-hero {
  text-align: center;
  padding: 3rem 1rem 3.5rem;
}

.path-hero__eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand-purple);
  background: rgba(80, 47, 119, 0.08);
  border-radius: 2em;
  padding: 0.3em 1em;
  margin-bottom: 0.75rem;
}

.path-hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.9rem, 5vw, 3rem);
  font-weight: 800;
  background: linear-gradient(90deg, var(--brand-purple), #6564b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.15;
}

.path-hero__subtitle {
  margin: 0;
  font-size: 1.05rem;
  color: #6a6a8a;
}

/* ── Centering wrapper ────────────────────────────────────── */
.path-wrapper {
  max-width: var(--path-max-width);
  margin: 0 auto;
}

/* ── Track (the dashed vertical line) ────────────────────── */
.path-track {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.path-track::before {
  content: '';
  position: absolute;
  left: calc(var(--path-connector-size) / 2 - var(--path-line-width) / 2);
  top: calc(var(--path-connector-size) + 4px);
  bottom: calc(var(--path-connector-size) + 4px);
  width: var(--path-line-width);
  background: repeating-linear-gradient(
    to bottom,
    var(--path-line-color) 0,
    var(--path-line-color) 9px,
    transparent 9px,
    transparent 20px
  );
  pointer-events: none;
  z-index: 0;
}

/* ── Individual unit section ──────────────────────────────── */
.path-unit {
  display: grid;
  grid-template-columns: var(--path-connector-size) 1fr;
  gap: 1rem;
  align-items: start;
  position: relative;
  z-index: 1;
}

/* ── Connector node (circle on the line) ─────────────────── */
.unit-connector {
  width: var(--path-connector-size);
  height: var(--path-connector-size);
  border-radius: 50%;
  background: var(--unit-accent, var(--brand-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.3rem;
  color: white;
  flex-shrink: 0;
  box-shadow:
    0 0 0 4px white,
    0 0 0 7px var(--unit-accent, var(--brand-purple)),
    0 4px 14px rgba(0, 0, 0, 0.12);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
  z-index: 2;
  user-select: none;
}

.path-unit--open .unit-connector {
  transform: scale(1.12);
  box-shadow:
    0 0 0 4px white,
    0 0 0 8px var(--unit-accent, var(--brand-purple)),
    0 6px 20px rgba(0, 0, 0, 0.18);
}

.path-unit--locked .unit-connector {
  background: #bbbbd0;
  box-shadow:
    0 0 0 4px white,
    0 0 0 7px #bbbbd0,
    0 4px 12px rgba(0, 0, 0, 0.08);
  font-size: 1.1rem;
}

/* Small lock badge pinned to bottom-right of connector circle */
.unit-connector__lock-badge {
  position: absolute;
  bottom: 3px;
  right: 2px;
  width: 18px;
  height: 18px;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

/* ── Unit card ────────────────────────────────────────────── */
.unit-card {
  background:
    linear-gradient(white, white) padding-box,
    linear-gradient(to right, var(--unit-accent, #b0c2ff), var(--unit-accent-light, #e0e8ff)) border-box;
  border: 3px solid transparent;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: box-shadow 0.28s ease, transform 0.22s ease;
}

.path-unit--open .unit-card {
  box-shadow: var(--card-shadow-hover);
}

.path-unit--locked .unit-card__header {
  filter: var(--locked-header-filter);
  cursor: default;
}

.path-unit--locked .unit-card__header:hover {
  filter: var(--locked-header-filter);
}

/* ── Card header (full-bleed photo click area) ────────────── */
.unit-card__header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.4rem 1.5rem;
  width: 100%;
  /* Photo background — image set via inline style */
  background-color: var(--unit-accent, var(--brand-purple)); /* fallback */
  background-size: cover;
  background-position: center;
  min-height: 128px;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  position: relative;
  overflow: hidden;
  transition: filter 0.22s ease;
}

.unit-card__header:hover {
  filter: brightness(1.07);
}

.unit-card__header:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.7);
  outline-offset: -4px;
}


/* ── Dark gradient overlay on photo ──────────────────────── */
.unit-card__header-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    rgba(10, 6, 24, 0.72) 0%,
    rgba(10, 6, 24, 0.52) 55%,
    rgba(10, 6, 24, 0.38) 100%
  );
  pointer-events: none;
  z-index: 0;
}

/* ── Unit text info (rendered on photo) ───────────────────── */
.unit-info {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.unit-title {
  margin: 0 0 0.28rem;
  font-size: 1.12rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}

.unit-subtitle {
  margin: 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* ── Chevron (expand arrow — white on photo) ──────────────── */
.unit-chevron {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.90);
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--toggle-duration) var(--toggle-easing);
  position: relative;
  z-index: 1;
}

.path-unit--open .unit-chevron {
  transform: rotate(180deg);
}

/* Lock icon (white on photo) */
.unit-lock-icon {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.80);
  position: relative;
  z-index: 1;
}

/* ── Collapsible body — grid-template-rows trick ──────────── */
.unit-card__body-wrapper {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--toggle-duration) var(--toggle-easing);
}

.path-unit--open .unit-card__body-wrapper {
  grid-template-rows: 1fr;
}

.unit-card__body {
  overflow: hidden;
}

.unit-card__body-inner {
  padding: 0 1.5rem 1.5rem;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* ── Progress bar ─────────────────────────────────────────── */
.unit-progress-bar {
  position: relative;
  height: 7px;
  background: #ebebf5;
  border-radius: 4px;
  margin: 1rem 0 1.25rem;
  overflow: visible;
}

.unit-progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--unit-accent, var(--brand-purple)), var(--unit-accent-light, #c0c0ff));
  border-radius: 4px;
  transition: width 0.7s ease;
}

.unit-progress-bar__label {
  position: absolute;
  right: 0;
  top: -1.5rem;
  font-size: 0.72rem;
  color: #8a8aaa;
  font-weight: 700;
}

/* ── Lesson list ──────────────────────────────────────────── */
.lesson-list {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.lesson-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: #f7f6ff;
  border: 1.5px solid rgba(80, 47, 119, 0.06);
  text-decoration: none;
  color: inherit;
  transition: background 0.18s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.lesson-item--available:hover {
  transform: translateX(5px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

/* Per-unit hover tints */
.path-unit[data-unit="1"] .lesson-item--available:hover { background: #fff0f0; }
.path-unit[data-unit="2"] .lesson-item--available:hover { background: #e8faf9; }
.path-unit[data-unit="3"] .lesson-item--available:hover { background: #e6f6fb; }
.path-unit[data-unit="4"] .lesson-item--available:hover { background: #fffbea; }
.path-unit[data-unit="5"] .lesson-item--available:hover { background: #edfaf4; }
.path-unit[data-unit="6"] .lesson-item--available:hover { background: #faf3fa; }
.path-unit[data-unit="7"] .lesson-item--available:hover { background: #fff8ee; }
.path-unit[data-unit="8"] .lesson-item--available:hover { background: #eaf6fd; }

.lesson-item--locked {
  cursor: not-allowed;
  pointer-events: none;
}

.lesson-item--locked .lesson-icon {
  filter: grayscale(1);
  opacity: 0.55;
}

.lesson-item--locked::after {
  content: '';
  display: block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23aaaacc' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0110 0v4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
}

.lesson-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.lesson-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: #2a2a42;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-sub {
  font-size: 0.76rem;
  color: #8a8aaa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-status {
  font-size: 0.8rem;
  color: #b0b0cc;
  flex-shrink: 0;
}

/* ── Lesson type icons (SVG-based, replacing text pills) ──── */
.lesson-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 10px;
  flex-shrink: 0;
}

.lesson-icon--grammar    { background: #ede0ff; color: #5a1e96; }
.lesson-icon--vocabulary { background: #d8f0ff; color: #0e6fa8; }
.lesson-icon--reading    { background: #d8ffe8; color: #0e6b3c; }
.lesson-icon--idioms     { background: #fff3d8; color: #8a5a00; }

/* ── Unit CTA ─────────────────────────────────────────────── */
.unit-cta {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
}

.unit-start-btn {
  display: inline-block;
  padding: 0.7rem 2.2rem;
  background: linear-gradient(90deg, var(--unit-accent, var(--brand-purple)), var(--unit-accent-light, #b0c2ff));
  border-radius: 2em;
  color: var(--brand-purple);
  font-weight: 800;
  font-size: 0.9rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.03em;
  transition: filter 0.2s ease, transform 0.18s ease, box-shadow 0.2s ease;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
}

.unit-start-btn:hover {
  filter: brightness(1.07);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
}

.unit-coming-soon {
  margin: 0;
  text-align: center;
  color: #9a9ab8;
  font-size: 0.88rem;
  font-style: italic;
}

/* ── Toast notification ───────────────────────────────────── */
.path-toast {
  position: fixed;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--brand-purple);
  color: white;
  padding: 0.8rem 1.8rem;
  border-radius: 2em;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: "Lexend Deca", "Noto Sans", Helvetica, sans-serif;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  white-space: nowrap;
  box-shadow: 0 8px 28px rgba(80, 47, 119, 0.35);
}

.path-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── "Loading" / auth-checking state ─────────────────────── */
#path-auth-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  flex-direction: column;
  gap: 1rem;
  color: #7a7a9a;
  font-size: 1rem;
}

/* ── Mobile — ≤ 640px ─────────────────────────────────────── */
@media (max-width: 640px) {
  .unit-card__header {
    padding: 1.1rem 1.1rem;
    min-height: 110px;
    gap: 0.7rem;
  }

  .unit-title {
    font-size: 0.98rem;
  }

  .lesson-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 8px;
  }

  .unit-card__body-inner {
    padding: 0 1rem 1.2rem;
  }

  .path-hero h1 {
    font-size: 1.7rem;
  }
}

/* ── Mobile — ≤ 440px ─────────────────────────────────────── */
@media (max-width: 440px) {
  :root {
    --path-connector-size: 38px;
  }

  .unit-card__header {
    padding: 0.9rem;
    min-height: 96px;
  }

  .lesson-icon {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 7px;
  }

  .path-hero {
    padding: 2rem 1rem 2.5rem;
  }

  .path-hero h1 {
    font-size: 1.45rem;
  }

  .path-toast {
    font-size: 0.82rem;
    padding: 0.7rem 1.2rem;
    white-space: normal;
    text-align: center;
    max-width: 90vw;
  }
}
