/* =========================================================
   Responsive UI refinement — preserves existing design language.
   Loaded AFTER site.*.css. Not a redesign.
   SAME DESIGN LANGUAGE + SAME CONTENT + SAME BRAND + BETTER RESPONSIVE BEHAVIOUR
   ========================================================= */

:root {
  --page-gutter: clamp(16px, 4vw, 60px);
  --content-max: 1200px;
  --nav-btn-min-h: 44px;
  --touch-min: 44px;
}

/* ---------- Fluid page gutters (keep cream/gold layout) ---------- */
.nav {
  padding-left: var(--page-gutter) !important;
  padding-right: var(--page-gutter) !important;
}

.hero,
.section,
.cta-section,
.footer,
.trust-bar,
.privacy-wrap {
  padding-left: var(--page-gutter) !important;
  padding-right: var(--page-gutter) !important;
}

/* Ultrawide: keep premium readable measure, backgrounds stay full-bleed */
@media (min-width: 1600px) {
  :root { --page-gutter: max(60px, calc((100vw - var(--content-max)) / 2)); }
}

@media (min-width: 2200px) {
  :root { --content-max: 1280px; }
}

/* ---------- Navigation: prevent logo/CTA collision ---------- */
.nav {
  gap: 12px !important;
  min-height: var(--nav-offset);
}

.nav-logo {
  font-size: clamp(15px, 2.8vw, 18px) !important;
  white-space: nowrap;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(58vw, 280px);
}

.nav-btn {
  flex: 0 0 auto;
  min-height: var(--nav-btn-min-h);
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 10px 14px !important;
  font-size: clamp(10px, 2.6vw, 11px) !important;
  white-space: nowrap;
  box-sizing: border-box;
}

@media (max-width: 360px) {
  .nav-logo {
    max-width: calc(100vw - 148px);
    font-size: 14px !important;
    letter-spacing: 0.02em !important;
  }
  .nav-btn {
    padding: 10px 12px !important;
    font-size: 10px !important;
  }
}

@media (max-width: 320px) {
  .nav-logo { max-width: calc(100vw - 136px); font-size: 13.5px !important; }
  .nav-btn { padding: 9px 10px !important; }
}

/* Desktop nav links: keep style, improve spacing near breakpoint */
@media (min-width: 901px) {
  .nav-links {
    gap: clamp(16px, 2.2vw, 32px) !important;
    flex-wrap: nowrap;
  }
  .nav-links a {
    font-size: clamp(10px, 0.85vw, 11px) !important;
    padding: 8px 0;
  }
}

/* ---------- Hero: cohesive first screen without redesign ---------- */
.hero {
  /* Prefer dynamic viewport units; keep 100vh fallback */
  min-height: calc(100vh - 60px);
  min-height: calc(100svh - 60px);
  min-height: calc(100dvh - 60px);
}

.hero-h1 {
  font-size: clamp(36px, 8.5vw, 68px) !important;
  line-height: 1.06 !important;
}

.hero-sub {
  font-size: clamp(13px, 3.4vw, 14px) !important;
  max-width: min(400px, 100%) !important;
}

.hero-actions .btn-primary,
a.btn-primary {
  min-height: 48px;
  box-sizing: border-box;
}

@media (max-width: 900px) {
  .hero {
    padding-top: clamp(28px, 6vw, 48px) !important;
    padding-bottom: clamp(28px, 6vw, 40px) !important;
    gap: clamp(20px, 4vw, 40px) !important;
    min-height: 0 !important;
    column-gap: clamp(12px, 4vw, 18px) !important;
  }

  .hero-card {
    margin-top: 4px;
  }

  .hc-inner {
    padding: clamp(18px, 4vw, 28px) !important;
  }

  .hc-num {
    font-size: clamp(26px, 7vw, 32px) !important;
  }

  .hc-price-new {
    font-size: clamp(30px, 8vw, 38px) !important;
  }

  .hero-actions {
    width: 100%;
  }
  .hero-actions .btn-primary {
    width: 100%;
    text-align: center;
  }

  .hero-photo {
    width: clamp(92px, 28vw, 140px) !important;
  }
}

@media (max-width: 360px) {
  .hero {
    column-gap: 12px !important;
  }
  .hero-h1 {
    font-size: clamp(32px, 9.2vw, 36px) !important;
  }
}

/* Short / landscape viewports: compress hero vertical rhythm */
@media (max-height: 500px) and (orientation: landscape) {
  .hero {
    padding-top: 16px !important;
    padding-bottom: 16px !important;
    gap: 12px !important;
    row-gap: 10px !important;
    min-height: 0 !important;
  }
  .hero-h1 {
    font-size: clamp(26px, 7vh, 38px) !important;
  }
  .hero-sub {
    margin-bottom: 12px !important;
    font-size: 13px !important;
  }
  .hero-card .hc-stats {
    margin-bottom: 10px !important;
  }
  .hc-inner {
    padding: 14px !important;
  }
  .hero-photo {
    width: clamp(72px, 18vw, 110px) !important;
  }
}

@media (max-width: 900px) and (max-height: 700px) {
  .hero-eyebrow { margin-bottom: 10px !important; }
  .hero-h1 { margin-bottom: 12px !important; }
  .hero-sub { margin-bottom: 16px !important; }
}

/* Low-height laptop / browser chrome */
@media (min-width: 901px) and (max-height: 700px) {
  .hero {
    min-height: 0 !important;
    padding-top: 40px !important;
    padding-bottom: 40px !important;
    gap: 40px !important;
  }
  .hero-h1 {
    font-size: clamp(42px, 5.5vh, 60px) !important;
  }
}

/* ---------- Section titles fluid ---------- */
.section-h2,
.programme-title,
.cta-h2 {
  font-size: clamp(28px, 6vw, 48px) !important;
  line-height: 1.12 !important;
}

.section {
  padding-top: clamp(48px, 7vw, 88px) !important;
  padding-bottom: clamp(48px, 7vw, 88px) !important;
}

/* ---------- Programme ---------- */
@media (max-width: 900px) {
  .prog-grid {
    gap: 0 !important;
  }
  .prog-h3 {
    font-size: clamp(20px, 5vw, 24px) !important;
  }
  .prog-item {
    font-size: clamp(13px, 3.4vw, 14px) !important;
    line-height: 1.45 !important;
  }
}

/* ---------- For-whom carousel comfort ---------- */
@media (max-width: 980px) {
  #for-whom .fw-carousel__arrow,
  .fw-carousel__arrow {
    width: var(--touch-min) !important;
    height: var(--touch-min) !important;
    min-width: var(--touch-min) !important;
    min-height: var(--touch-min) !important;
  }

  #for-whom .fw-carousel__viewport {
    width: min(86vw, 340px) !important;
  }

  #for-whom .fw-carousel__dot {
    min-width: 10px;
    min-height: 10px;
  }
}

@media (max-width: 360px) {
  #for-whom .fw-carousel__viewport {
    width: min(78vw, 286px) !important;
  }
}

/* Tablet: use extra space reasonably without redesign */
@media (min-width: 600px) and (max-width: 980px) {
  #for-whom .fw-carousel__viewport {
    width: min(70vw, 380px) !important;
  }
}

/* ---------- Reviews: readable screenshots ---------- */
@media (max-width: 980px) {
  .reviews-carousel-slide {
    flex: 0 0 min(92vw, 360px) !important;
  }
  .reviews-carousel-slide img {
    height: auto !important;
    max-height: min(70dvh, 560px) !important;
    width: 100% !important;
    object-fit: contain !important;
  }
  .reviews-carousel-prev,
  .reviews-carousel-next,
  .reviews-carousel-arrow {
    width: var(--touch-min) !important;
    height: var(--touch-min) !important;
    min-width: var(--touch-min);
    min-height: var(--touch-min);
  }
}

@media (min-width: 981px) and (max-width: 1180px) {
  .reviews-carousel-slide {
    flex: 0 0 calc((100% - 28px) / 2) !important;
  }
}

@media (min-width: 1181px) {
  .reviews-carousel-slide {
    flex: 0 0 calc((100% - 44px) / 3) !important;
  }
}

/* Reviews progress / scrubber comfort */
.reviews-carousel input[type="range"],
.reviews-progress,
[role="slider"] {
  min-height: 28px;
  touch-action: pan-y;
}

/* Decorative motion stays clipped by section; do not grow page width */
#reviews {
  overflow-x: clip;
}

/* ---------- Author ---------- */
@media (max-width: 900px) {
  .author-portrait {
    width: min(280px, 72vw) !important;
    max-width: 100% !important;
    aspect-ratio: 3 / 4 !important;
    height: auto !important;
    margin-inline: auto;
  }
  .author-portrait img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center 20% !important;
  }
  .author-bio,
  .author-text p {
    font-size: clamp(14px, 3.6vw, 16px) !important;
    line-height: 1.55 !important;
  }
}

/* ---------- CTA / Buy ---------- */
.cta-section .btn-primary,
.cta-section a.hc-cta,
#buy a[href*="monecle"],
#buy .btn-primary {
  min-height: 48px;
  box-sizing: border-box;
}

@media (max-width: 520px) {
  #buy .btn-primary,
  .cta-section .btn-primary,
  #buy a[href*="monecle"] {
    width: 100% !important;
    max-width: 100% !important;
    text-align: center;
  }
}

.cta-section {
  padding-top: clamp(56px, 8vw, 96px) !important;
  padding-bottom: clamp(56px, 8vw, 96px) !important;
}

/* ---------- Footer ---------- */
.footer-link {
  font-size: clamp(11px, 2.8vw, 13px) !important;
  line-height: 1.35 !important;
  padding: 6px 2px;
  min-height: var(--touch-min);
  display: inline-flex;
  align-items: center;
}

.footer-copy {
  font-size: clamp(11px, 2.6vw, 12px) !important;
  line-height: 1.45 !important;
  max-width: 100% !important;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.footer-links {
  flex-wrap: wrap !important;
  justify-content: center !important;
  gap: 10px 18px !important;
  row-gap: 8px !important;
}

@media (max-width: 900px) {
  .footer {
    gap: 12px !important;
    padding-top: 22px !important;
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .footer-logo {
    font-size: clamp(14px, 4vw, 15px) !important;
  }
}

/* ---------- Privacy page ---------- */
.privacy-page {
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
}

.privacy-page .privacy-wrap {
  max-width: min(760px, 100%) !important;
  padding-top: clamp(28px, 5vw, 48px) !important;
  padding-bottom: clamp(64px, 10vw, 96px) !important;
}

.privacy-page h1 {
  font-size: clamp(1.75rem, 6vw, 2.85rem) !important;
  overflow-wrap: anywhere;
}

.privacy-page h2 {
  font-size: clamp(1.3rem, 4.5vw, 1.85rem) !important;
}

.privacy-page p,
.privacy-page li {
  font-size: clamp(15px, 3.8vw, 16px) !important;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.65 !important;
}

.privacy-page a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.privacy-table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.privacy-table table,
table.privacy-table {
  min-width: 280px;
}

@media (max-width: 600px) {
  .privacy-table th,
  .privacy-table td {
    padding: 8px 10px !important;
    font-size: 14px !important;
  }
}

/* ---------- Modals: low-height + safe areas ---------- */
.review-modal,
.more-reviews-modal {
  padding-top: max(12px, env(safe-area-inset-top, 0px)) !important;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px)) !important;
  padding-left: max(12px, env(safe-area-inset-left, 0px)) !important;
  padding-right: max(12px, env(safe-area-inset-right, 0px)) !important;
}

.review-modal-dialog,
.more-reviews-modal .more-reviews-dialog,
.more-reviews-dialog {
  max-height: min(86dvh, 86vh) !important;
}

.review-modal-close,
.more-reviews-close {
  min-width: var(--touch-min);
  min-height: var(--touch-min);
}

/* ---------- Safe areas (Telegram / iOS) ---------- */
@supports (padding: max(0px)) {
  .nav {
    padding-top: max(var(--nav-safe-top, 0px), env(safe-area-inset-top, 0px)) !important;
  }
  body {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* ---------- Box model hygiene (no global overflow-x:hidden) ---------- */
.hero,
.section,
.cta-section,
#for-whom,
#reviews,
#programme,
#author,
#buy,
.footer,
.nav {
  box-sizing: border-box;
  max-width: 100%;
}

img {
  max-width: 100%;
}

.hero-photo,
.author-portrait img,
.student-avatar-photo {
  max-width: 100%;
}
