/* =========================================================
   Courses page (loads after style.css and reuses its theme)
   1. Helpers
   2. Header cart button
   3. Page intro, search & filters
   4. Course cards
   5. Course details
   6. Pop-up header (phone "Select" sheet)
   7. Phone bottom sheet
   8. "Coming soon" / "could not load" panels
   The course list itself comes from the database (js/courses.js).
   ========================================================= */

/* ---------- 1. Helpers ---------- */
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
body.locked { overflow: hidden; }
.view { padding: 28px 0 72px; }

/* ---------- 2. Header cart button ---------- */
.nav-right { display: flex; align-items: center; gap: 8px; order: 2; }
.nav-links { order: 1; margin-left: auto !important; margin-right: 12px !important; }
.nav-links a[aria-current="page"] { color: var(--ink); }
@media (max-width: 760px) { .nav-links { margin: 0 !important; } }

/* ---------- 3. Page intro, search & filters ---------- */
.courses-hero {
  position: relative; overflow: hidden;
  padding: 40px 20px 28px; border-radius: var(--r-xl);
  background:
    radial-gradient(60% 70% at 80% 0%, rgba(156,192,255,.22), transparent 70%),
    linear-gradient(180deg, #0B1636 0%, var(--cobalt) 80%, #2A52C4 130%);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 40px 80px -30px rgba(27,63,160,.6);
}
.courses-title {
  margin: 0; max-width: 15ch; font-size: clamp(38px, 6.4vw, 72px);
  line-height: .98; font-weight: 700; text-wrap: balance;
}

.toolbar {
  display: grid; grid-template-columns: 1fr; gap: 10px;
  padding: 10px; border-radius: var(--r-lg);
  background: rgba(6,11,24,.35);
}
.search {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  height: 58px; padding: 0 20px; border-radius: var(--pill);
  background: #FFFFFF; color: var(--btn-ink);
}
.search .icon { stroke: #5B6780; width: 20px; height: 20px; }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
  font: 400 16px var(--font-body); color: var(--btn-ink);
}
.search input::placeholder { color: #8892A6; }
.search:focus-within { box-shadow: 0 0 0 3px rgba(156,192,255,.6); }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.select {
  position: relative; display: flex; flex-direction: column; justify-content: center; min-width: 0;
  height: 58px; padding: 0 40px 0 18px; border-radius: var(--pill);
  background: rgba(255,255,255,.08); border: 1px solid var(--glass-border);
}
.select::after {   /* chevron */
  content: ""; position: absolute; right: 18px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); transform: rotate(45deg);
  pointer-events: none;
}
.select__label { font: 500 10px var(--font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--accent-hi); }
.select select {
  appearance: none; -webkit-appearance: none; width: 100%; border: 0; outline: 0; padding: 0;
  background: transparent; color: var(--ink); cursor: pointer;
  font: 500 15px var(--font-body);
}
.select select option { background: var(--space-2); color: var(--ink); }
.select:focus-within { border-color: var(--accent-hi); }
@media (min-width: 860px) {
  .courses-hero { padding: 64px 56px 40px; }
  .toolbar { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
}
@media (max-width: 420px) { .filters { grid-template-columns: 1fr; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.results-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 36px 0 16px; }
.results-count { margin: 0; font: 500 12px var(--font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }

/* ---------- 4. Course cards ---------- */
.course-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) { .course-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 980px) { .course-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.course-card {
  display: flex; flex-direction: column; padding: 8px; border-radius: var(--r-lg);
  text-decoration: none; color: inherit;
  transition: transform .2s ease, border-color .2s ease;
}
.course-card:hover { transform: translateY(-4px); border-color: rgba(156,192,255,.4); }
.course-card:hover .circle-btn { background: var(--accent); border-color: transparent; transform: rotate(45deg); }

.course-cover {
  position: relative; overflow: hidden; height: 150px; padding: 16px; border-radius: 22px;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.course-cover--pharma {
  background:
    radial-gradient(70% 90% at 85% 110%, rgba(156,192,255,.6), transparent 60%),
    linear-gradient(160deg, #13286E 0%, #2D5BD8 100%);
}
.course-cover--physio {
  background:
    radial-gradient(70% 90% at 85% 110%, rgba(130,220,255,.45), transparent 60%),
    linear-gradient(160deg, #0B1A45 0%, #1B3FA0 60%, #3B7BD9 100%);
}
.course-cover::before {   /* soft ring, echoing the hero */
  content: ""; position: absolute; right: -60px; bottom: -110px; width: 220px; height: 220px;
  border-radius: 50%; border: 1px solid rgba(255,255,255,.22);
  box-shadow: 0 0 0 30px rgba(255,255,255,.03);
}

.course-body { display: flex; flex-direction: column; flex: 1; padding: 16px 12px 10px; }
/* Course name bold, line below normal */
.course-name { margin: 0; font-family: var(--font-display); font-size: 24px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
.course-sub { margin: 4px 0 0; font-family: var(--font-body); font-size: 15px; font-weight: 400; color: var(--ink-soft); }
.course-meta { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 14px 0 0; padding: 0; }
.course-meta li {
  padding: 4px 10px; border-radius: var(--pill); background: rgba(255,255,255,.07);
  font-size: 12px; color: var(--ink-soft);
}
.course-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 18px; }
.price { margin: 0; font: 700 22px var(--font-display); color: var(--ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.price s, .buy__price s { margin-left: 6px; font-size: .6em; font-weight: 500; color: var(--muted); }

.empty { margin-top: 8px; padding: 36px 24px; border-radius: var(--r-lg); text-align: center; }
.empty__title { margin: 0; font: 700 22px var(--font-display); color: var(--ink); }
.empty p { margin: 6px 0 18px; }
.empty .text-link { cursor: pointer; }

/* ---------- 5. Course details ---------- */
.back-link {
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 20px;
  padding: 10px 18px; border-radius: var(--pill);
  border: 1px solid var(--glass-border); background: var(--glass-bg);
  color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 500;
}
.back-link:hover { background: var(--glass-bg-hi); }

.detail-grid { display: grid; grid-template-columns: 1fr; gap: 20px; align-items: start; }
.detail-main { display: grid; gap: 16px; min-width: 0; }
/* Phone: Buy now card sits below About this course.
   Desktop: the same card moves to the right-hand column and stays in view. */
@media (min-width: 940px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr) 360px; column-gap: 28px; row-gap: 16px; }
  .detail-main { display: contents; }
  .detail-main > * { grid-column: 1; min-width: 0; }
  .detail-main > .buy { grid-column: 2; grid-row: 1 / span 4; align-self: start; position: sticky; top: 100px; }
}

.detail-hero {
  position: relative; overflow: hidden; padding: 36px 22px 32px; border-radius: var(--r-xl);
  background:
    radial-gradient(60% 90% at 90% 120%, rgba(156,192,255,.55), transparent 60%),
    linear-gradient(160deg, #0B1636 0%, var(--cobalt) 70%, var(--cobalt-2) 110%);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.15);
}
.detail-hero::before {
  content: ""; position: absolute; right: -90px; bottom: -200px; width: 380px; height: 380px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.18); box-shadow: 0 0 0 50px rgba(255,255,255,.025), 0 0 0 51px rgba(255,255,255,.08);
}
.detail-hero > * { position: relative; }
/* Course name bold, line below normal */
.detail-name { margin: 0; font-size: clamp(40px, 7vw, 76px); line-height: .95; font-weight: 700; letter-spacing: -.045em; }
.detail-sub { margin: 10px 0 0; font-family: var(--font-body); font-size: clamp(18px, 2.4vw, 22px); font-weight: 400; color: rgba(255,255,255,.82); }
@media (min-width: 860px) { .detail-hero { padding: 56px 48px 48px; } }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; }
.stat:last-child { grid-column: 1 / -1; }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } .stat:last-child { grid-column: auto; } }
.stat { margin: 0; padding: 18px; border-radius: var(--r-md); min-width: 0; }
.stat dd { margin: 0; }
.stat__value { margin-top: 10px !important; font: 700 19px/1.25 var(--font-display); color: var(--ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat__note { margin-top: 2px !important; font-size: 13px; color: var(--muted); }

.detail-block { padding: 26px 22px; border-radius: var(--r-lg); }
@media (min-width: 860px) { .detail-block { padding: 36px; } }
.detail-about { margin: 0; max-width: 62ch; font-size: 17px; font-weight: 300; }
.learn { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
@media (min-width: 700px) { .learn { grid-template-columns: 1fr 1fr; } }
.learn li {
  position: relative; padding: 12px 14px 12px 42px; border-radius: 16px;
  background: rgba(255,255,255,.05); border: 1px solid var(--rule); color: var(--ink); font-size: 15px;
}
.learn li::before {
  content: ""; position: absolute; left: 14px; top: 50%; width: 16px; height: 16px; margin-top: -8px;
  border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 4px rgba(47,107,255,.2);
}
.learn li::after {
  content: ""; position: absolute; left: 19px; top: 50%; width: 5px; height: 8px; margin-top: -6px;
  border-right: 1.5px solid #fff; border-bottom: 1.5px solid #fff; transform: rotate(45deg);
}

.related { margin-top: 20px; }
.course-grid--small { grid-template-columns: 1fr; }
@media (min-width: 640px) { .course-grid--small { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Buy box */
.buy { padding: 26px 22px; border-radius: var(--r-lg); }
.buy__price { margin: 8px 0 0; font: 700 44px/1 var(--font-display); color: var(--ink); letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.buy__save { margin: 8px 0 22px; font-size: 14px; color: var(--accent-hi); }
.btn--block { width: 100%; justify-content: space-between; border: 0; cursor: pointer; }
.buy__list { list-style: none; margin: 22px 0 0; padding: 18px 0 0; border-top: 1px solid var(--rule); display: grid; gap: 8px; font-size: 14px; }
.buy__list li { padding-left: 20px; position: relative; }
.buy__list li::before { content: ""; position: absolute; left: 2px; top: .6em; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-hi); }

/* ---------- 6. Pop-up header (used by the phone "Select" sheet) ---------- */
.drawer__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.drawer__head .circle-btn { cursor: pointer; }
.drawer__title { margin: 0; font: 700 24px var(--font-display); letter-spacing: -.03em; color: var(--ink); }

/* ---------- 7. Phone: single "Select" button + bottom sheet ---------- */
.select-btn { display: none; }
@media (max-width: 759px) {
  .filters { display: none; }
  .select-btn {
    position: relative; display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
    width: 100%; height: 58px; padding: 0 44px 0 20px; border-radius: var(--pill); cursor: pointer; text-align: left;
    background: rgba(255,255,255,.08); border: 1px solid var(--glass-border); color: var(--ink);
  }
  .select-btn::after {   /* chevron pointing up: the sheet comes from below */
    content: ""; position: absolute; right: 20px; top: 50%; width: 8px; height: 8px; margin-top: -2px;
    border-left: 1.5px solid var(--ink); border-top: 1.5px solid var(--ink); transform: rotate(45deg);
  }
  .select-btn__value { font: 500 15px var(--font-body); }
  .select-btn.is-set { border-color: var(--accent-hi); }
}
.sheet-backdrop { position: fixed; inset: 0; z-index: 44; background: rgba(4,7,15,.6); opacity: 0; transition: opacity .25s ease; }
.sheet-backdrop.is-open { opacity: 1; }
.sheet {
  position: fixed; z-index: 45; left: 0; right: 0; bottom: 0;
  max-height: 80vh; overflow-y: auto;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  border-radius: 28px 28px 0 0; background: rgba(10,16,34,.96);
  transform: translateY(100%); transition: transform .26s cubic-bezier(.2,.8,.2,1);
}
.sheet.is-open { transform: translateY(0); }
.sheet__grip { display: block; width: 44px; height: 5px; margin: 0 auto 14px; border-radius: 3px; background: rgba(255,255,255,.25); }
.sheet__group { margin: 18px 0 10px; font: 500 14.3px var(--font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--accent-hi); }
.sheet__opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-opt {
  min-height: 48px; padding: 10px 14px; border-radius: 16px; cursor: pointer; text-align: left;
  background: rgba(255,255,255,.06); border: 1px solid var(--glass-border); color: var(--ink);
  font: 500 15px var(--font-body);
}
.sheet-opt--all { width: 100%; }
.sheet-opt.is-active { background: #FFFFFF; color: var(--btn-ink); border-color: transparent; }

/* Desktop: search + one "Courses" dropdown fill the bar */
.filters { grid-template-columns: 1fr; }
@media (min-width: 760px) { .toolbar { grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr); } }
/* Phone sheet: All / 1st term / 2nd term in one row per subject */
.sheet__opts { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* WhatsApp badge on the Buy now button */
.btn__arrow--wa { background: #25D366; color: #fff; }
.btn__arrow--wa svg { display: block; }

/* "About this course" sits in the third stat box (where "Updated" was) */
.stat__about { margin-top: 10px !important; font-size: 15px; font-weight: 300; line-height: 1.5; color: var(--ink); }

/* Phone: About sits in the third box. PC: third box is "Updated", About is its own box below. */
.stat--updated, .detail-block--about { display: none; }
@media (min-width: 940px) {
  .stat--updated { display: block; }
  .detail-block--about { display: block; }
  .stat--about { display: none; }
}

/* Course cover photo (set "image" in js/courses.js); empty = "Coming soon" */
.course-cover--photo { padding: 0; background: #0B1636; }
.course-cover--photo::before { display: none; }
.course-cover--photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.course-cover__soon {
  position: relative; font: 700 30px/1 var(--font-display); letter-spacing: -.03em; color: #fff;
}
.detail-hero--photo { background-size: cover; background-position: center; background-repeat: no-repeat; }

/* Log in button sits right after the links (same spacing as other pages) */
@media (min-width: 761px) { .nav-links { margin-right: 0 !important; } }

/* ---------- 8. "Courses are coming soon" / "could not load" panels ---------- */
/* The blue panel itself is .join-panel from style.css (same as the home page) */
.soon { padding: 28px 0 72px; }
.soon-panel {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: min(560px, 72vh);
}
.soon-title {
  margin: 0 0 20px; max-width: 12ch;
  font-size: clamp(40px, 7vw, 76px); line-height: .98; font-weight: 700; text-wrap: balance;
}
.soon-title em { display: block; }
.soon-text { margin: 0 auto 10px; max-width: 44ch; font-size: 17px; font-weight: 300; color: rgba(255,255,255,.82); }
.soon-text--bn { margin-bottom: 30px; font-size: 16px; color: rgba(255,255,255,.7); }
.soon .hero-actions { margin-top: 0; }
.soon button.text-link { cursor: pointer; }

@media (max-width: 600px) {
  .soon { padding-top: 16px; }
  .soon-text { font-size: 16px; }
  .soon .hero-actions { flex-direction: column; width: 100%; }
  .soon .hero-actions .btn { justify-content: space-between; width: 100%; max-width: 320px; }
}
