/* =====================================================================
   MIdS — Course Detail  ·  Refactored UI stylesheet
   ---------------------------------------------------------------------
   Scope: all rules are prefixed with `.cd-*` or nested under `.cd-page`
          so nothing here leaks into the shared navbar / footer / other
          pages.  Works alongside Tailwind (loaded first) + Alpine.
   ===================================================================== */

/* ── Prompt font (system fallback if offline) ─────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@400;500;600;700;800&display=swap');

/* ── MIdS design tokens (requirement 11 & 12) ─────────────────────── */
.cd-page {
  --cd-primary:   #5B4BDB;   /* brand primary (one design system) */
  --cd-secondary: #22C7E8;   /* accent */
  --cd-success:   #22C55E;   /* Success   */
  --cd-warning:   #F59E0B;   /* Warning   */
  --cd-danger:    #EF4444;   /* Danger    */
  --cd-surface:   #F8FAFC;   /* Page background */

  --cd-radius:      18px;    /* Standard card radius (req 10)  */
  --cd-radius-hero: 20px;    /* Hero banner radius (req 1)     */
  --cd-shadow-sm:   0 8px 24px rgba(15,23,42,.08);
  --cd-shadow-md:   0 12px 28px rgba(15,23,42,.12);
  --cd-transition:  .25s cubic-bezier(.4, 0, .2, 1);   /* req 10 */

  font-family: 'Prompt', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  line-height: 1.7;                                    /* req 12 */
}

/* Section rhythm (req 9) */
.cd-page section { scroll-margin-top: 5rem; }
.cd-page h1, .cd-page h2, .cd-page h3, .cd-page h4 { font-weight: 700; }

/* ── Reusable card (req 10) ───────────────────────────────────────── */
.cd-card {
  border-radius: var(--cd-radius);
  box-shadow: var(--cd-shadow-sm);
  transition: transform var(--cd-transition), box-shadow var(--cd-transition);
}
.cd-card--hover:hover,
.cd-card--hover:focus-within {
  transform: translateY(-4px);
  box-shadow: var(--cd-shadow-md);
}

/* ── 1. Hero banner (responsive heights) ──────────────────────────── */
.cd-hero {
  position: relative;
  border-radius: var(--cd-radius-hero);
  overflow: hidden;
  box-shadow: var(--cd-shadow-md);
}
/* Show the FULL banner (poster-style images) — no cropping.
   Natural aspect ratio, width-constrained, with a sensible max height
   so very tall images don't dominate the viewport. */
.cd-hero__img {
  width: 100%;
  height: auto;
  max-height: 82vh;
  object-fit: contain;
  display: block;
  background: #0f172a;        /* letterbox fill if ratio differs */
}

.cd-hero__overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: clamp(1rem, 4vw, 2rem);
  background: linear-gradient(to top, rgba(2,6,23,.62) 0%, rgba(2,6,23,.22) 55%, transparent 100%);
}

/* ── 5. Tabs (Bootstrap-pill look, built with Tailwind + this) ────── */
.cd-pill {
  border: 1px solid transparent;
  border-radius: 999px;
  transition: background-color var(--cd-transition), color var(--cd-transition), box-shadow var(--cd-transition);
  white-space: nowrap;
}
.cd-pill[aria-selected="true"] {
  background: var(--cd-primary);
  color: #fff;
  box-shadow: 0 4px 12px -2px rgba(37,99,235,.45);
}
.cd-pill[aria-selected="false"]:hover {
  background: rgba(37,99,235,.10);
  color: var(--cd-primary);
}
/* Tab panel enter transition (req 5) */
.cd-tabpanel { animation: cd-fade-up .25s ease both; }
@keyframes cd-fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 6. Schedule timeline ─────────────────────────────────────────── */
.cd-timeline { position: relative; padding-left: 1.75rem; }
.cd-timeline::before {
  content: "";
  position: absolute;
  left: .45rem; top: .4rem; bottom: .4rem;
  width: 2px;
  background: linear-gradient(var(--cd-primary), var(--cd-secondary));
  opacity: .25;
}
.cd-timeline__dot {
  position: absolute;
  left: -1.45rem; top: .35rem;
  width: 14px; height: 14px;
  border-radius: 999px;
  background: #cbd5e1;
  box-shadow: 0 0 0 4px #fff;
}
/* Highlight the round that is open for registration (req 6) */
.cd-timeline__item--open .cd-timeline__dot {
  background: var(--cd-success);
  box-shadow: 0 0 0 4px #fff, 0 0 0 7px rgba(34,197,94,.25);
  animation: cd-pulse 2s ease-in-out infinite;
}
@keyframes cd-pulse {
  0%,100% { transform: scale(1);   }
  50%     { transform: scale(1.15); }
}

/* ── 13. Mobile sticky "ลงทะเบียน" bar ────────────────────────────── */
.cd-mobile-cta {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(8px);
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -4px 16px -6px rgba(15,23,42,.15);
}
@media (min-width: 1024px) { .cd-mobile-cta { display: none; } }

/* ── 14. Accessibility: visible focus ring (WCAG AA) ──────────────── */
.cd-page a:focus-visible,
.cd-page button:focus-visible,
.cd-page [role="tab"]:focus-visible,
.cd-page input:focus-visible {
  outline: 3px solid var(--cd-primary);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  .cd-card, .cd-pill, .cd-tabpanel,
  .cd-timeline__item--open .cd-timeline__dot { animation: none !important; transition: none !important; }
}
