/* ============================================================
   CKB-WEB-MOBILE-RESPONSIVE-R1 — V1 Mobile Responsive Prototype
   Parent: CKB-WEB-HOME-VISUAL-BALANCE-R2-R2
   Scope: responsive navigation, mobile brand recognition, Gallery,
          Programme list, Calendar, detail/service/form and Footer QA.
   Protected desktop visual language remains unchanged above 1240px.
   ============================================================ */

/* 1) Compact navigation mode follows the same breakpoint as the visible MENU trigger. */
@media (max-width: 1240px) {
  .mobile-root-nav {
    display: grid;
    gap: 0;
    padding: 18px 0 34px;
  }
  .mobile-root-nav > button,
  .mobile-root-nav > a {
    min-height: 54px;
    border: 0;
    border-bottom: 1px solid var(--curtain-line);
    background: transparent;
    color: #fff;
    padding: 15px 0;
    text-align: left;
    cursor: pointer;
    font-size: clamp(30px, 4.5vw, 48px);
    line-height: 1;
    font-weight: 600;
    letter-spacing: -.035em;
  }
  .mobile-root-nav > button:focus-visible,
  .mobile-root-nav > a:focus-visible,
  .mobile-root-meta button:focus-visible,
  .curtain-back:focus-visible,
  .curtain-close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 4px;
  }
  .mobile-root-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 24px;
    color: var(--curtain-muted);
  }
  .mobile-root-meta button {
    min-height: 44px;
    border: 0;
    background: transparent;
    color: inherit;
    padding: 8px 0;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
  }
  .mobile-root-meta .lang-divider-mobile {
    color: rgba(255,255,255,.42);
    font-size: 15px;
  }
  .curtain-detail { display: none; }
  .nav-curtain.show-detail .mobile-root-nav { display: none; }
  .nav-curtain.show-detail .curtain-detail { display: block; }
  .nav-curtain.show-detail .curtain-back { visibility: visible; }
}

/* Tablet MENU state: same root/detail navigation model as phone, but with calmer scale. */
@media (max-width: 1240px) and (min-width: 861px) {
  .nav-curtain-inner { padding-top: 24px; }
  .curtain-topline { grid-template-columns: 48px 1fr 48px; }
  .mobile-root-nav { max-width: 860px; }
  .mobile-root-nav > button,
  .mobile-root-nav > a { font-size: clamp(34px, 4vw, 46px); padding: 16px 0; }
  .curtain-heading-row { display: block; padding: 38px 0 24px; }
  .curtain-heading-row h2 { font-size: clamp(58px, 7.5vw, 88px); }
  .curtain-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 38px 56px; padding: 20px 0 38px; }
  .curtain-link { font-size: clamp(23px, 2.7vw, 30px); }
}

/* 2) Phone header: keep complete institutional identity visible instead of seal-only. */
@media (max-width: 860px) {
  :root { --header-h: 78px; }
  .site-header {
    width: calc(100vw - 24px) !important;
    height: var(--header-h);
    gap: 10px;
  }
  .brand-lockup {
    min-width: 0;
    flex: 1 1 auto;
    gap: 0 !important;
  }
  .brand-lockup-full,
  .brand-lockup-full-dark {
    width: clamp(182px, 55vw, 238px) !important;
    max-width: 100%;
    max-height: 50px !important;
    height: auto;
    object-fit: contain;
    object-position: left center;
  }
  .brand-lockup-full { display: block !important; }
  .brand-lockup-full-dark { display: none !important; }
  .brand-lockup-seal-only { display: none !important; }
  .site-header-shell.is-curtain .brand-lockup-full { display: none !important; }
  .site-header-shell.is-curtain .brand-lockup-full-dark { display: block !important; }
  .site-header-shell.is-curtain .brand-lockup-seal-only { display: none !important; }
  .header-right { flex: 0 0 auto; margin-left: auto !important; gap: 0 !important; }
  .mobile-menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    min-height: 44px;
    padding: 10px 7px;
    font-size: 16px;
    line-height: 1;
    font-weight: 600;
    letter-spacing: -.01em;
  }
  .mobile-menu-trigger:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
  }
  .language-switch { display: none !important; }

  .nav-curtain { inset: var(--header-h) 0 0; }
  .nav-curtain-inner { width: calc(100vw - 24px); padding: 16px 0 28px; min-height: calc(100dvh - var(--header-h)); }
  .curtain-topline { grid-template-columns: 44px minmax(0,1fr) 44px; padding-bottom: 14px; }
  .curtain-mode { font-size: 10px; letter-spacing: .14em; }
  .curtain-close, .curtain-back { min-width: 44px; min-height: 44px; padding: 6px; }
  .mobile-root-nav { padding-top: 10px; }
  .mobile-root-nav > button,
  .mobile-root-nav > a {
    min-height: 58px;
    padding: 15px 0;
    font-size: clamp(30px, 9.6vw, 46px);
  }
  .curtain-heading-row { padding: 26px 0 16px; }
  .curtain-heading-row h2 { font-size: clamp(46px, 13vw, 68px); line-height: .92; }
  .curtain-intro { margin-top: 12px; font-size: 16px; line-height: 1.4; }
  .curtain-grid { grid-template-columns: 1fr; gap: 24px; padding: 12px 0 34px; }
  .curtain-group-label { margin-bottom: 14px; }
  .curtain-link { min-height: 44px; display: inline-flex; align-items: center; font-size: 25px; line-height: 1.15; padding: 7px 0; }
  .curtain-footer { display: grid; gap: 20px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .curtain-footer p { line-height: 1.5; }
}

/* Very narrow phones: protect MENU and brand from colliding. */
@media (max-width: 340px) {
  .brand-lockup-full,
  .brand-lockup-full-dark { width: 182px !important; }
  .mobile-menu-trigger { min-width: 50px; padding-inline: 4px; }
}

/* 3) Mobile Gallery: one readable card with a deliberate next-card peek. */
@media (max-width: 860px) {
  .hero { padding-top: 34px !important; }
  .gallery-heading { width: calc(100vw - 24px); margin-bottom: 13px; }
  .gallery-swipe-hint { font-size: 11px; letter-spacing: .085em; }
  .gallery-viewport {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 7vw;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    padding: 0 7vw 12px;
  }
  .gallery-track { gap: 18px; align-items: flex-start; }
  .poster-link {
    flex: 0 0 84vw !important;
    width: 84vw;
    max-width: 620px;
    scroll-snap-align: center;
    scroll-snap-stop: always;
  }
  .poster-link[data-clone="true"] { display: none !important; }
  .poster-copy { padding-top: 13px; gap: 5px; }
  .poster-date { font-size: 12px !important; line-height: 1.25; }
  .poster-title { font-size: 21px !important; line-height: 1.15; overflow-wrap: anywhere; }
  .poster-meta { font-size: 11px !important; line-height: 1.35; letter-spacing: .05em !important; overflow-wrap: anywhere; }
}

/* Reduced motion must not strand off-screen Gallery items on desktop. */
@media (prefers-reduced-motion: reduce) {
  .gallery-viewport {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }
  .gallery-track { transform: none !important; }
  .poster-link { scroll-snap-align: start; }
  .poster-link[data-clone="true"] { display: none !important; }
  .gallery-viewport::before,
  .gallery-viewport::after { display: none !important; }
}

/* 4) Programme list: mobile becomes an editorial vertical record, not a squeezed desktop row. */
@media (max-width: 860px) {
  .upcoming,
  .calendar-agenda { width: calc(100vw - 24px); padding: 66px 0 92px; }
  .section-heading { gap: 12px 18px; padding-bottom: 18px; }
  .section-heading h2 { font-size: clamp(36px, 10vw, 42px) !important; }
  .event-row {
    min-height: 0;
    grid-template-columns: 68px minmax(0,1fr) 24px !important;
    grid-template-areas:
      "date type arrow"
      "date title arrow"
      "date meta arrow" !important;
    gap: 4px 16px !important;
    align-items: start;
    padding: 20px 0;
  }
  .event-row time {
    grid-area: date;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding-top: 1px;
  }
  .event-row time span { font-size: 31px; line-height: .92; }
  .event-row time small { font-size: 11px; line-height: 1; }
  .event-type { grid-area: type; min-height: 16px; padding-top: 1px; }
  .event-row h3 { grid-area: title; margin: 0; padding: 3px 0 0 !important; font-size: 21px !important; line-height: 1.15; overflow-wrap: anywhere; }
  .event-meta { grid-area: meta; margin-top: 5px; text-align: left !important; line-height: 1.4; }
  .event-arrow { grid-area: arrow; align-self: center; justify-self: end; }
}

/* 5) Calendar: fixed navigation targets + long-month-safe title + readable month grid. */
@media (max-width: 860px) {
  .calendar-main { width: calc(100vw - 24px); }
  .calendar-hero { padding: 30px 0 22px !important; }
  .calendar-title-row { width: 100%; gap: 14px !important; }
  .calendar-title-cluster {
    width: 100% !important;
    max-width: 520px;
    grid-template-columns: 38px minmax(0,1fr) 38px !important;
    column-gap: 8px !important;
  }
  .calendar-title-cluster .month-controls button {
    width: 38px !important;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    font-size: 18px !important;
  }
  .calendar-title-cluster h1 {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    text-align: center;
    font-size: clamp(25px, 7.2vw, 36px) !important;
    line-height: 1 !important;
    letter-spacing: -.032em !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
  }
  .calendar-quick-controls { width: 100%; display: grid; grid-template-columns: auto minmax(0,1fr); gap: 8px; }
  .calendar-today { min-width: 76px; padding-inline: 12px; }
  .calendar-month-jump { min-width: 0; }
  .calendar-month-select { width: 100%; min-width: 0 !important; font-size: 14px; }
  .calendar-lede { margin-top: 12px !important; font-size: 16px !important; line-height: 1.48 !important; }
  .ongoing-panel { padding: 18px 0 !important; }
  .ongoing-item { grid-template-columns: 78px minmax(0,1fr) 20px !important; gap: 12px !important; min-height: 48px; }
  .ongoing-item time { font-size: 14px !important; }
  .ongoing-item strong { font-size: 17px !important; line-height: 1.2; overflow-wrap: anywhere; }
  .ongoing-item span { font-size: 10px !important; }
  .month-grid-section { padding-top: 16px !important; overflow-x: clip; }
  .month-grid { width: 100%; min-width: 0; }
  .weekday { min-height: 34px !important; padding: 9px 2px !important; font-size: 10px !important; letter-spacing: .045em !important; }
  .day { min-height: 58px !important; padding: 7px 5px !important; }
  .day > span { font-size: 15px !important; }
  .day i { left: 6px !important; bottom: 9px !important; width: 7px !important; height: 7px !important; }
  .day small { display: none !important; }
  .calendar-day-panel { padding: 40px 0 90px !important; scroll-margin-top: calc(var(--header-h) + 14px); }
  .calendar-day-event {
    grid-template-columns: 66px minmax(0,1fr) 24px !important;
    grid-template-areas: "time title arrow" "time meta arrow" !important;
    gap: 5px 14px !important;
    min-height: 88px;
    padding: 16px 0;
  }
  .calendar-day-event > span { font-size: 15px; }
  .calendar-day-event strong { font-size: 19px; line-height: 1.15; overflow-wrap: anywhere; }
  .calendar-day-event small { font-size: 10px; letter-spacing: .06em; line-height: 1.35; overflow-wrap: anywhere; }
}

/* Extra safety for 320px class devices. */
@media (max-width: 340px) {
  .calendar-title-cluster h1 { font-size: 24px !important; }
  .calendar-title-cluster { grid-template-columns: 36px minmax(0,1fr) 36px !important; column-gap: 6px !important; }
  .calendar-title-cluster .month-controls button { width: 36px !important; min-width: 36px; }
  .weekday { font-size: 9px !important; }
  .day { min-height: 54px !important; padding-inline: 4px !important; }
}

/* 6) Detail + service/form surfaces: protect long copy, touch targets and on-screen keyboard widths. */
@media (max-width: 860px) {
  .detail-main,
  .service-main,
  .partner-main { width: calc(100vw - 24px) !important; }
  .detail-main { padding: 32px 0 92px; }
  .detail-back { min-height: 44px; display: inline-flex; align-items: center; margin-bottom: 34px; }
  .detail-hero { gap: 10px; padding-bottom: 32px; }
  .detail-kicker { padding-top: 0; }
  .detail-hero h1 { font-size: clamp(38px, 10.8vw, 58px) !important; line-height: .98 !important; overflow-wrap: anywhere; }
  .detail-facts { margin-top: 28px; gap: 20px; }
  .detail-facts strong { font-size: 17px; }
  .detail-media-copy { padding-top: 34px; gap: 26px; }
  .detail-lede { font-size: clamp(21px, 6.2vw, 27px); line-height: 1.3; overflow-wrap: anywhere; }
  .registration-panel h2 { font-size: 30px; }
  .registration-body { font-size: 16px; }
  .detail-cta { min-height: 44px; display: inline-flex; align-items: center; }

  .service-main,
  .partner-main { padding: 34px 0 92px; }
  .service-hero { gap: 12px; padding-bottom: 32px; }
  .service-hero h1 { font-size: clamp(42px, 12vw, 62px) !important; line-height: .97; overflow-wrap: anywhere; }
  .service-hero > p { font-size: 16px; line-height: 1.5; }
  .service-block { padding-block: 26px !important; }
  .service-block h2 { font-size: 29px; }
  .service-block p { font-size: 17px; }
  .service-link { min-height: 44px; display: inline-flex; align-items: center; }
  .service-form { padding-top: 38px; }
  .form-grid { gap: 20px; }
  .form-grid label { font-size: 11px; }
  .form-grid input,
  .form-grid select,
  .form-grid textarea { min-width: 0; font-size: 16px !important; padding: 13px 0; }
  .form-actions { gap: 16px; margin-top: 28px; }
  .primary-button { min-height: 50px; }

  .institutional-card,
  .institutional-card:nth-child(odd),
  .institutional-card:nth-child(even) {
    grid-template-columns: minmax(96px, 32vw) minmax(0,1fr) !important;
    gap: 18px;
  }
  .institutional-card span { overflow-wrap: anywhere; }
}

/* 7) Footer: clean vertical reading order on phones, larger actionable links. */
@media (max-width: 860px) {
  .site-footer-modern .site-footer-inner { width: calc(100vw - 24px); padding-top: 42px; }
  .footer-brandline h2 { margin-bottom: 30px; font-size: 28px; line-height: 1.12; }
  .footer-modern-grid { gap: 30px; }
  .footer-modern-col p { font-size: 16px; }
  .footer-contact-actions > a,
  .footer-newsletter-cta { min-height: 44px; display: inline-flex; align-items: center; font-size: 13px; }
  .footer-social-icon { width: 42px !important; height: 42px !important; }
  .site-footer-modern .footer-bottom { margin-top: 36px; }
  .site-footer-modern .footer-legal a { min-height: 40px; display: flex; align-items: center; line-height: 1.35; }
}
@media (max-width: 380px) {
  .site-footer-modern .footer-legal { grid-template-columns: 1fr !important; gap: 4px !important; }
}

/* Universal long-text and focus safety for narrow screens. */
@media (max-width: 860px) {
  h1, h2, h3, p, a, button, strong, small, span { overflow-wrap: break-word; }
  a:focus-visible,
  button:focus-visible,
  input:focus-visible,
  textarea:focus-visible,
  select:focus-visible { outline-offset: 3px; }
}

/* Final breakpoint authority: MENU replaces the six-item desktop nav through 1240px. */
@media (max-width: 1240px) {
  .main-nav { display: none !important; }
  .mobile-menu-trigger { display: inline-flex !important; }
}
