/* ===================================================================
   FREE CAMBRIDGE OPEN CLASSES — landing page styles
   Brand variables mirror content/styles/mainstyles.css so this page
   can be dropped into the main site's design system unchanged.
   =================================================================== */

:root {
  /* Brand colours */
  --primary-color: #e81123;
  --primary-color-dim: rgba(232, 17, 35, 0.1);
  --primary-dark: #b30d1b;
  --secondary-color: #10b981;
  --secondary-dark: #059669;
  --secondary-light: #d1fae5;

  /* Status colours (used for the disabled-button state) */
  --status-full: #6b7280;
  --status-full-bg: #f3f4f6;

  /* Neutrals */
  --text-dark: #0f172a;
  --text-secondary: #374151;
  --text-faint: #6b7280;
  --background: #ffffff;
  --background-alt: #f9fafb;
  --background-dark: #f3f4f6;
  --border-color: #e5e7eb;

  /* Shadow */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.12);

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;
  --spacing-2xl: 4rem;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.85rem;
  --radius-xl: 1.25rem;

  /* Transitions - custom ease-out (not the built-in CSS ease), so
     interactions feel intentional rather than soft. Used for entrances and
     hover/press feedback; nothing here is a looping/constant animation. */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --transition-fast: 150ms var(--ease-out);
  --transition-base: 220ms var(--ease-out);

  /* Typography */
  --font-family:
    "Lexend", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  --font-size-4xl: 2.5rem;

  --max-width: 1120px;
}

/* ===================================================================
   RESET & BASE
   =================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-family);
  color: var(--text-dark);
  background: var(--background);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.2;
  font-weight: 600;
}

p {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
}

button {
  font-family: inherit;
}

img {
  max-width: 100%;
  display: block;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

/* Focus visibility — kept strong and consistent everywhere */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--primary-color);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 0 0 var(--radius-md) 0;
  z-index: 1000;
  font-weight: 500;
}

.skip-link:focus {
  left: 0;
}

/* ===================================================================
   BUTTONS
   =================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-lg);
  border: 2px solid transparent;
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    background var(--transition-fast);
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0) scale(0.97);
}

.btn-primary {
  background: var(--primary-color);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: #ef606c;
  color: #fff;
  box-shadow: 0 6px 16px rgba(232, 17, 35, 0.18);
}

.btn-primary:disabled {
  background: var(--status-full-bg);
  color: var(--status-full);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--secondary-color);
  color: #fff;
}

.btn-secondary:hover {
  background: var(--secondary-dark);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-dark);
}

.btn-outline:hover {
  border-color: var(--text-dark);
}

.btn-lg {
  padding: 0.9rem 2rem;
  font-size: var(--font-size-lg);
}

.btn-full {
  width: 100%;
}

/* ===================================================================
   MY BOOKING BAR (persistent reminder once a booking exists)
   ------------------------------------------------------------------
   Sits below the site navbar (from mainstyles.css / navigation.js).
   =================================================================== */

.my-booking-bar {
  background: var(--secondary-light);
  border-bottom: 1px solid var(--secondary-color);
  animation: fade-rise-in 300ms var(--ease-out) both;
}

.my-booking-bar[hidden] {
  display: none;
}

.my-booking-bar-inner {
  padding: 0.6rem var(--spacing-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.my-booking-bar-inner p {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--secondary-dark);
}

.btn-sm {
  padding: 0.4rem 1rem;
  font-size: var(--font-size-xs);
}

/* ===================================================================
   BOOKING PAGE (single-page numbered form, Google-Forms-style banner)
   =================================================================== */

.booking-page {
  padding: var(--spacing-xl) 0 var(--spacing-2xl);
}

.booking-container {
  max-width: 640px;
}

.booking-card {
  background: var(--background);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* ---- top banner (same card, same width - not a separate hero section) ---- */

.booking-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-lg);
  height: 240px;
  padding: 0 var(--spacing-lg);
  background: var(--background-alt);
}

.booking-banner svg,
.booking-banner img {
  width: 200px;
  height: 200px;
  object-fit: contain;
  flex-shrink: 0;
}

.booking-banner-text {
  max-width: 260px;
}

.booking-banner-eyebrow {
  color: var(--primary-color);
  font-weight: 700;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}

.booking-banner-tagline {
  color: var(--text-dark);
  font-weight: 600;
  font-size: var(--font-size-lg);
  line-height: 1.35;
}

.booking-body {
  padding: var(--spacing-xl) var(--spacing-lg);
}

.booking-header {
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-lg);
  border-bottom: 3px solid var(--primary-color);
}

.booking-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.booking-header-top h1 {
  font-size: var(--font-size-2xl);
  color: var(--text-dark);
}

.free-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--secondary-light);
  color: var(--secondary-dark);
  font-size: var(--font-size-xs);
  font-weight: 700;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  white-space: nowrap;
}

.booking-subtitle {
  margin-top: 0.4rem;
  color: var(--text-faint);
  font-size: var(--font-size-sm);
}

/* ---- form sections ---- */

#booking-form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.form-section-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.2rem;
}

.form-section-header h2 {
  font-size: var(--font-size-base);
  color: var(--text-dark);
}

.section-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--secondary-color);
  color: #fff;
  font-size: var(--font-size-xs);
  font-weight: 700;
  flex-shrink: 0;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-row label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-dark);
}

.field-hint {
  font-weight: 400;
  color: var(--text-faint);
}

.field-hint-block {
  display: block;
  font-size: var(--font-size-sm);
  margin-top: -0.25rem;
}

.field-placeholder {
  color: var(--text-faint);
  font-size: var(--font-size-sm);
  font-style: italic;
}

.optional-tag {
  font-weight: 400;
  color: var(--text-faint);
}

/* ---- subject checkboxes (choose one or more) ---- */

.subject-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.subject-fieldset legend {
  padding: 0;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-dark);
}

.subject-checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.subject-checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  transition:
    border-color var(--transition-fast),
    background var(--transition-fast),
    transform var(--transition-fast);
}

.subject-checkbox-item:active {
  transform: scale(0.98);
}

.subject-checkbox-item:has(:checked) {
  border-color: var(--secondary-color);
  background: var(--secondary-light);
  color: var(--secondary-dark);
  font-weight: 600;
}

.subject-checkbox-item input {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}

/* ---- inputs & selects with a leading icon ---- */

.input-icon-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon-group > i {
  position: absolute;
  left: 0.85rem;
  color: var(--text-faint);
  font-size: var(--font-size-sm);
  pointer-events: none;
}

.input-icon-group input,
.input-icon-group .custom-select-trigger {
  width: 100%;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem 0.65rem 2.5rem;
  font-size: var(--font-size-base);
  font-family: inherit;
  color: var(--text-dark);
  background: var(--background);
}

.input-icon-group input:focus-visible,
.input-icon-group .custom-select-trigger:focus-visible {
  border-color: var(--primary-color);
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}

/* ---- custom dropdown trigger (pattern matches Test Builder's filter
   dropdowns: content/test-builder/scripts/test-builder-ui.js) ---- */

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  cursor: pointer;
  text-align: left;
  transition: transform var(--transition-fast);
}

.custom-select-trigger:active:not(:disabled) {
  transform: scale(0.98);
}

.custom-select-trigger:disabled {
  color: var(--text-faint);
  background: var(--background-dark);
  cursor: not-allowed;
}

.custom-select-value.is-placeholder {
  color: var(--text-faint);
}

.custom-select-chevron {
  font-size: 0.7rem;
  color: var(--text-faint);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.custom-select-trigger[aria-expanded="true"] .custom-select-chevron {
  transform: rotate(180deg);
}

/* ---- custom dropdown panel (appended to <body>, fixed-positioned under its trigger) ---- */

.custom-select-panel {
  background: var(--background);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  padding: 0.3rem;
  transform-origin: top center;
  animation: custom-select-in 200ms var(--ease-out) both;
}

@keyframes custom-select-in {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.custom-select-option {
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  cursor: pointer;
}

.custom-select-option:hover,
.custom-select-option:focus {
  background: var(--background-alt);
  outline: none;
}

.custom-select-option.active {
  background: var(--primary-color-dim);
  color: var(--primary-color);
  font-weight: 600;
}

.custom-select-option.disabled {
  color: var(--text-faint);
  cursor: not-allowed;
  opacity: 0.6;
}

@media (prefers-reduced-motion: reduce) {
  .custom-select-panel {
    animation: none;
  }
}

.form-row-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-sm);
}

.form-row-checkbox {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.6rem;
}

.form-row-checkbox input {
  margin-top: 0.2rem;
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}

.form-row-checkbox label {
  font-weight: 400;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* Shared entrance for elements that pop into existence via the `hidden`
   attribute (form-error, selected-classes-summary, my-booking-bar) - a CSS
   animation on an element replays automatically when it goes from
   display:none to visible, so no JS timing is needed for any of these. One
   keyframe kept consistent across all three for a cohesive motion language
   instead of three ad hoc "just appears" moments. */
@keyframes fade-rise-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-error {
  background: #fef2f2;
  color: var(--primary-color);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  font-size: var(--font-size-sm);
  animation: fade-rise-in 240ms var(--ease-out) both;
}

.form-trust-note {
  text-align: center;
  color: var(--text-faint);
  font-size: var(--font-size-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

/* ---- class selects, one per selected subject ---- */

.class-selects-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* Staggered entrance for the per-subject session rows - rebuilt fresh into
   the DOM each time renderClassSelects() runs, so a CSS animation here
   replays on every re-render with no JS involved. Checking several subjects
   at once shows several rows together; a light cascade (rather than all
   popping in on the same frame) reads as more intentional. Kept to 4 steps -
   the largest level (IGCSE) offers 4 subjects. */
.subject-class-row {
  animation: fade-rise-in 260ms var(--ease-out) both;
}

.subject-class-row:nth-child(1) {
  animation-delay: 0ms;
}
.subject-class-row:nth-child(2) {
  animation-delay: 40ms;
}
.subject-class-row:nth-child(3) {
  animation-delay: 80ms;
}
.subject-class-row:nth-child(4) {
  animation-delay: 120ms;
}

/* ---- selected-classes summary (shown once at least one session is picked) ---- */

.selected-classes-summary {
  background: var(--background-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem var(--spacing-md);
  animation: fade-rise-in 240ms var(--ease-out) both;
}

.summary-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.selected-classes-list,
.success-classes-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: left;
}

.selected-class-row,
.success-class-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  font-size: var(--font-size-sm);
}

.selected-class-subject,
.success-class-subject {
  font-weight: 700;
  color: var(--text-dark);
}

.selected-class-datetime,
.success-class-datetime {
  color: var(--text-secondary);
}

/* ---- confirmation (replaces the form once booked) ---- */

/* This is the highest-emotion moment on the page (a free class just got
   booked), so unlike the other dynamic elements above it gets a deliberate
   fade+rise rather than the bare-minimum treatment - worth the small amount
   of extra JS. hidden -> display:none can't be transitioned directly, so
   script.js toggles .is-visible one frame after removing [hidden] (see
   showSuccess()) rather than relying on the free "replays on display change"
   trick used elsewhere on this page. */
.booking-success {
  text-align: center;
  opacity: 0;
  transform: scale(0.97) translateY(4px);
  transition:
    opacity 320ms var(--ease-out),
    transform 320ms var(--ease-out);
}

.booking-success.is-visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.success-icon {
  font-size: 2.75rem;
  margin-bottom: 0.5rem;
  display: inline-block;
  animation: success-icon-pop 420ms var(--ease-out) 80ms both;
}

@keyframes success-icon-pop {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  70% {
    transform: scale(1.08);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.success-heading {
  font-size: var(--font-size-xl);
  color: var(--text-dark);
  margin-bottom: 0.25rem;
}

.success-lede {
  color: var(--text-secondary);
  font-size: var(--font-size-base);
}

.success-card {
  background: var(--background-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  margin: var(--spacing-md) 0;
}

.success-subject {
  font-weight: 700;
  font-size: var(--font-size-lg);
  color: var(--text-dark);
}

.success-datetime {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  margin-top: 0.25rem;
}

.success-note {
  color: var(--text-faint);
  font-size: var(--font-size-sm);
  margin-bottom: var(--spacing-md);
}

.success-actions {
  display: flex;
  gap: var(--spacing-sm);
}

.success-actions .btn {
  flex: 1;
}

/* Site footer is injected by /content/scripts/footer.js into
   #footer-container and styled by mainstyles.css - nothing to add here. */

/* ===================================================================
   RESPONSIVE
   =================================================================== */

@media (max-width: 640px) {
  .booking-banner {
    flex-direction: column;
    height: auto;
    padding: var(--spacing-lg) var(--spacing-md);
    text-align: center;
  }

  .booking-banner svg,
  .booking-banner img {
    width: 150px;
    height: 150px;
  }

  .booking-banner-text {
    max-width: none;
  }

  .booking-header-top h1 {
    font-size: var(--font-size-xl);
  }

  .booking-body {
    padding: var(--spacing-lg) var(--spacing-md);
  }

  .form-row-group {
    grid-template-columns: 1fr;
  }

  .btn-lg {
    width: 100%;
  }

  .success-actions {
    flex-direction: column;
  }
}

/* Reduced motion - covers every animation/transition-based entrance added
   above. Content still appears immediately in every case (none of it relies
   on a persistent hidden base state outside the animation/transition
   itself), just without the motion. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .btn,
  .custom-select-trigger,
  .subject-checkbox-item {
    transition: none;
  }
  .form-error,
  .selected-classes-summary,
  .my-booking-bar,
  .subject-class-row,
  .success-icon {
    animation: none;
  }
  .booking-success {
    transition: none;
  }
}
