/* Courses page (templates/courses/list.html).

   Tokens come from styles.css; the topbar and page background from auth.css.
   Only the grid, the card, and the pagination are defined here. */

.courses-main {
  flex: 1;
  padding: 2.5rem var(--page-gutter) 4rem;
}

.courses-shell {
  width: min(100%, var(--container));
  margin: 0 auto;
  display: grid;
  gap: 3.5rem;
}

.courses-section-head {
  max-width: 760px;
  margin-bottom: 1.6rem;
}

/* The landing page's 3rem cursive label is a scene title; here it is a
   section heading beside a grid, so it steps down. */
.courses-section-head .section-label {
  font-size: 2.1rem !important;
  margin-bottom: 0.3rem;
}

.courses-section-head h1,
.courses-section-head h2 {
  font-size: clamp(1.36rem, 2.4vw, 1.84rem);
  margin: 0;
  text-wrap: balance;
}

.courses-count {
  margin: 0.6rem 0 0;
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 700;
}

.courses-empty {
  padding: 1.4rem 1.6rem;
  border-radius: 14px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  color: var(--text-body);
}

.courses-empty p {
  margin: 0;
}

/* Grid ------------------------------------------------------------------- */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.5rem;
}

/* Card ------------------------------------------------------------------- */
.course-card {
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.course-card:hover,
.course-card:focus-within {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-soft);
}

.course-card-link {
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
}

.course-card.is-enrolled {
  border-color: rgba(91, 201, 149, 0.4);
}

/* 16:9 — the same ratio courses.models.IMAGE_RECOMMENDATION promises. */
.course-media {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-1);
}

.course-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}

.course-card:hover .course-media img {
  transform: scale(1.04);
}

.course-media-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-1);
}

.course-media-empty span {
  font-family: var(--font-heading);
  font-size: 3.4rem;
  font-weight: 700;
  color: var(--brand-gold);
}

.course-price {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  z-index: 2;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: rgba(12, 8, 24, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-strong);
  color: var(--text-hi);
  font-size: 0.82rem;
  font-weight: 800;
}

.course-price.is-free {
  background: rgba(91, 201, 149, 0.22);
  border-color: rgba(91, 201, 149, 0.55);
  color: #b9f0d3;
}

/* "What you'll learn" — an overlay on the image. It appears on hover where
   a pointer exists, and on the toggle button everywhere else. Keyboard
   focus inside the card also reveals it, so nobody needs the pointer. */
.course-learn {
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: 0.85rem 1.05rem;
  overflow: auto;
  /* Still scrollable if a card's points genuinely overflow the box - just
     without the native scrollbar bar breaking the card's look. */
  scrollbar-width: none;
  -ms-overflow-style: none;
  background: rgba(12, 8, 24, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.course-card.is-open .course-learn {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.course-learn::-webkit-scrollbar {
  display: none;
}

/* The price pill sits where the first bullet ends; it steps aside. */
.course-price {
  transition: opacity 0.2s ease;
}

.course-card.is-open .course-price {
  opacity: 0;
}

@media (hover: hover) and (pointer: fine) {
  .course-card:hover .course-learn,
  .course-card:focus-within .course-learn {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  .course-card:hover .course-price,
  .course-card:focus-within .course-price {
    opacity: 0;
  }
}

.course-learn-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.35rem;
  color: var(--magenta-bright);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.course-learn-title span {
  color: var(--text-hi);
  font-size: 0.82rem;
  letter-spacing: 0;
}

.course-learn ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.28rem;
}

.course-learn li {
  position: relative;
  padding-left: 1.05rem;
  color: var(--text-hi);
  font-size: 0.84rem;
  line-height: 1.32;
}

.course-learn li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
}

.course-body {
  padding: 1.1rem 1.25rem 0.6rem;
}

.course-body h3 {
  margin: 0 0 0.4rem;
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.3;
}

.course-body p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.93rem;
  line-height: 1.5;
}

.course-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.9rem;
  margin-top: auto;
  padding: 0.9rem 1.25rem 1.2rem;
}

.course-buy {
  min-height: 42px;
  padding: 0.6rem 1.1rem;
  font-size: 0.92rem;
}

.course-buy[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.course-buy[disabled]:hover {
  transform: none;
  background: var(--coral);
}

.course-ask {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 700;
  border-bottom: 1px solid transparent;
}

.course-ask:hover {
  color: var(--magenta-bright);
  border-color: currentColor;
}

.course-enrolled {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 42px;
  padding: 0.5rem 0.95rem;
  border-radius: 10px;
  background: rgba(91, 201, 149, 0.16);
  border: 1px solid rgba(91, 201, 149, 0.5);
  color: #b9f0d3;
  font-size: 0.9rem;
  font-weight: 800;
}

.course-enrolled svg {
  width: 16px;
  height: 16px;
}

.course-learn-toggle {
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  border-bottom: 1px solid transparent;
}

.course-learn-toggle:hover,
.course-learn-toggle[aria-expanded="true"] {
  color: var(--magenta-bright);
  border-color: currentColor;
}

/* Pagination ------------------------------------------------------------- */
.course-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 2.2rem;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 42px;
  padding: 0 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-body);
  font-size: 0.92rem;
  font-weight: 700;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

a.page-link:hover {
  border-color: var(--magenta);
  color: var(--text-hi);
}

.page-link.is-current {
  background: var(--magenta);
  border-color: var(--magenta);
  color: #fff;
}

.page-link.is-disabled {
  opacity: 0.4;
  cursor: default;
}

.page-ellipsis {
  min-width: 24px;
  text-align: center;
  color: var(--text-dim);
}

@media (max-width: 575.98px) {
  .courses-main {
    padding-top: 1.6rem;
  }

  .courses-shell {
    gap: 2.6rem;
  }

  .course-grid {
    grid-template-columns: 1fr;
  }

  .page-arrow {
    flex-basis: 100%;
    order: 1;
  }
}

/* Checkout (templates/courses/checkout.html) --------------------------------
   A single deliberate column. Nothing competes with the amount and the pay
   button, because every extra choice on a payment screen is a chance to leave. */
.checkout-shell {
  width: min(100%, 560px);
  margin: 0 auto;
}

.checkout-card {
  padding: 2rem 1.9rem 1.8rem;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.checkout-card h1 {
  margin: 0 0 1.6rem;
  font-size: clamp(1.3rem, 2.4vw, 1.7rem);
  text-wrap: balance;
}

.checkout-lines {
  margin: 0 0 1.8rem;
  display: grid;
  gap: 0.1rem;
}

.checkout-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
}

.checkout-line dt {
  color: var(--text-dim);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.checkout-line dd {
  margin: 0;
  color: var(--text-hi);
  font-weight: 700;
  text-align: right;
}

.checkout-ref {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.84rem !important;
  font-weight: 600 !important;
  color: var(--text-dim) !important;
  word-break: break-all;
}

.checkout-line-total {
  border-bottom: 0;
}

.checkout-line-total dd {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  color: var(--brand-gold);
}

.checkout-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem 1.2rem;
}

.checkout-actions .button {
  min-height: 48px;
  padding: 0.75rem 1.8rem;
  font-size: 1rem;
}

.checkout-actions .button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.checkout-note {
  margin: 1.3rem 0 0;
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* The card footer's buy control is a form now; it must not add its own box. */
.course-foot form {
  margin: 0;
}

@media (max-width: 575.98px) {
  .checkout-card {
    padding: 1.5rem 1.25rem 1.4rem;
  }

  .checkout-actions .button {
    width: 100%;
  }
}

/* The landing page's cursive .section-label is a scene flourish; a payment
   screen needs the opposite signal, so checkout gets its own quiet label. */
.checkout-eyebrow {
  margin: 0 0 0.5rem;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* A Razorpay order id is 20+ unbroken characters; without an explicit min-width
   of zero the flex item refuses to shrink and overflows the card. */
.checkout-line dd {
  min-width: 0;
}

.checkout-ref {
  overflow-wrap: anywhere;
}

/* Course detail (templates/courses/detail.html) ------------------------------
   Narrower than the grid shell on purpose - this page is one column of
   reading, not a wall of cards, and a tight measure is what keeps the hero,
   the tabs, and a handful of rows inside one viewport. */
.course-detail-shell {
  width: min(100%, 860px);
  margin: 0 auto;
  display: grid;
  gap: 1.5rem;
}

.course-detail-head {
  display: flex;
  align-items: baseline;
  gap: 1.1rem;
  flex-wrap: wrap;
}

.course-detail-back {
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.course-detail-back:hover {
  color: var(--text-hi);
}

.course-detail-head h1 {
  margin: 0;
  font-size: clamp(1.3rem, 2.6vw, 1.75rem);
  text-wrap: balance;
}

/* Locked (not-enrolled) view -------------------------------------------- */
.course-locked {
  display: flex;
  align-items: flex-start;
  gap: 1.6rem;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.course-locked-media {
  flex: 0 0 300px;
  aspect-ratio: 16 / 9;
  background: var(--bg-1);
  border-radius: 18px 0 0 18px;
  overflow: hidden;
}

.course-locked-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.course-locked-body {
  flex: 1;
  min-width: 0;
  padding: 1.6rem 1.8rem 1.6rem 0;
  display: grid;
  align-content: start;
  gap: 0.7rem;
}

.course-locked-price {
  justify-self: start;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: rgba(12, 8, 24, 0.5);
  border: 1px solid var(--border-strong);
  color: var(--text-hi);
  font-size: 0.82rem;
  font-weight: 800;
}

.course-locked-price.is-free {
  background: rgba(91, 201, 149, 0.18);
  border-color: rgba(91, 201, 149, 0.5);
  color: #b9f0d3;
}

.course-locked-body p {
  margin: 0;
  color: var(--text-body);
  font-size: 0.95rem;
  line-height: 1.55;
}

.course-locked-learn {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.32rem;
}

.course-locked-learn li {
  position: relative;
  padding-left: 1.1rem;
  color: var(--text-body);
  font-size: 0.92rem;
}

.course-locked-learn li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
}

.course-locked-body form {
  margin: 0.3rem 0 0;
}

/* Hero card: the wide "upcoming class" card that opens the page. Height is
   capped by the media's aspect-ratio, not by content, so it can never grow
   into a scroll problem no matter how long a class title gets. */
.course-hero {
  display: flex;
  gap: 1.6rem;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.course-hero-media {
  flex: 0 0 280px;
  aspect-ratio: 16 / 9;
  background: var(--bg-1);
}

.course-hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.course-hero-body {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 1.8rem 1.5rem 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.5rem;
}

.course-hero-eyebrow {
  margin: 0;
  color: var(--magenta-bright);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.course-hero-body h2 {
  margin: 0;
  font-size: clamp(1.1rem, 2.2vw, 1.4rem);
  text-wrap: balance;
}

.course-hero-time {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.92rem;
  font-weight: 600;
}

.course-hero-body .button {
  justify-self: start;
  width: fit-content;
  margin-top: 0.3rem;
}

.course-hero-pending {
  width: fit-content;
  margin-top: 0.3rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px dashed var(--border-strong);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 700;
}

/* Tabs -------------------------------------------------------------------
   Scheduled and Recorded share one viewport slot instead of two stacked
   sections - that is the whole trick for keeping this page to one screen. */
.course-tab-nav {
  display: flex;
  gap: 0.4rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.course-tab-btn {
  padding: 0.7rem 1rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}

.course-tab-btn:hover {
  color: var(--text-hi);
}

.course-tab-btn.is-active {
  color: var(--text-hi);
  border-bottom-color: var(--magenta-bright);
}

.course-tab-empty {
  padding: 1.2rem 1.4rem;
  border-radius: 14px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  color: var(--text-dim);
  font-size: 0.92rem;
}

/* Rows, not cards - a card per class/lecture would blow the vertical budget
   this page is trying to protect. */
.course-schedule-list,
.course-lecture-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.5rem;
}

.course-schedule-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.course-schedule-row.is-ended {
  opacity: 0.55;
}

/* Lecture rows are taller than schedule rows on purpose - opening one grows
   it in place to hold the player, instead of navigating away or popping a
   modal. Only one row is open at a time (courses.js), so the extra height
   never stacks. */
.course-lecture-row {
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}

.course-lecture-summary {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.75rem 1rem;
}

.course-lecture-player {
  border-top: 1px solid var(--border);
}

.course-lecture-player-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}

.course-lecture-player-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Sits over the black frame until the iframe fires load, or until
   courses.js gives up waiting and swaps this for a direct-link fallback -
   without it, a slow or blocked embed is just a silent black box. */
.course-lecture-player-status {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin: 0;
  padding: 1.5rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
  background: #000;
  pointer-events: none;
}

.course-lecture-player-status a {
  pointer-events: auto;
  color: var(--magenta-bright);
  font-weight: 700;
}

.course-lecture-player-status[hidden] {
  display: none;
}

.course-schedule-date {
  flex: 0 0 auto;
  min-width: 3.4rem;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.course-schedule-title,
.course-lecture-title {
  flex: 1;
  min-width: 0;
  color: var(--text-hi);
  font-weight: 700;
  font-size: 0.94rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-schedule-time,
.course-lecture-duration {
  flex: 0 0 auto;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
}

.course-schedule-join,
.course-lecture-play {
  flex: 0 0 auto;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: var(--magenta);
  color: var(--text-hi);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.course-lecture-play {
  border: 0;
  cursor: pointer;
  font-family: var(--font-body);
}

.course-schedule-join:hover,
.course-lecture-play:hover {
  background: var(--magenta-bright);
}

.course-schedule-status {
  flex: 0 0 auto;
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 700;
}

.course-lecture-index {
  flex: 0 0 auto;
  min-width: 1.6rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 800;
}

.course-lecture-row.is-locked .course-lecture-title,
.course-lecture-row.is-locked .course-lecture-index {
  color: var(--text-dim);
}

@media (max-width: 700px) {
  .course-locked,
  .course-hero {
    flex-direction: column;
  }

  .course-locked-media,
  .course-hero-media {
    flex-basis: auto;
  }

  .course-locked-media {
    border-radius: 18px 18px 0 0;
  }

  .course-locked-body,
  .course-hero-body {
    padding: 1.2rem 1.4rem 1.4rem;
  }

  .course-schedule-row,
  .course-lecture-summary {
    flex-wrap: wrap;
  }
}
