/* UCF55 — couche mobile portrait v56
   Cette feuille arrive en dernier pour stabiliser les nombreux modules hérités
   sans modifier la mise en page desktop. */

#ucfOrientationGuard {
  position: fixed;
  inset: 0;
  z-index: 2400;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 22px max(24px, env(safe-area-inset-bottom));
  color: #f6f8fb;
  background:
    radial-gradient(circle at 50% 25%, rgba(208, 29, 48, .20), transparent 34%),
    linear-gradient(145deg, #15222d 0%, #080d14 52%, #190a11 100%);
  text-align: center;
}

#ucfOrientationGuard[hidden] { display: none !important; }

.ucf-orientation-card {
  width: min(100%, 360px);
  padding: 30px 24px 26px;
  border: 1px solid #8f3442;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(28, 40, 51, .96), rgba(9, 14, 21, .98));
  box-shadow: 0 22px 80px rgba(0, 0, 0, .58), inset 0 1px rgba(255, 255, 255, .10);
}

.ucf-orientation-mark {
  width: 72px;
  height: 104px;
  display: grid;
  place-items: center;
  margin: 0 auto 22px;
  border: 2px solid #f04452;
  border-radius: 14px;
  color: #ff5c68;
  font-size: 36px;
  line-height: 1;
  box-shadow: 0 0 0 7px rgba(240, 68, 82, .08), 0 0 30px rgba(220, 32, 52, .20);
}

.ucf-orientation-kicker {
  margin: 0 0 9px;
  color: #ff6872;
  font: 800 10px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .18em;
}

.ucf-orientation-card h1 {
  margin: 0;
  font: 900 clamp(24px, 7vw, 34px)/1.05 Arial, sans-serif;
  letter-spacing: -.03em;
}

.ucf-orientation-card h1 span { color: #ff3e4d; }

.ucf-orientation-card p:not(.ucf-orientation-kicker) {
  margin: 17px 0 0;
  color: #c2ccd5;
  font-size: 13px;
  line-height: 1.55;
}

.ucf-orientation-foot {
  display: block;
  margin-top: 22px;
  color: #8295a4;
  font: 700 9px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .12em;
}

@media (max-width: 820px) {
  :root {
    --ucf-mobile-max: 430px;
    --ucf-portrait-ratio: 9 / 16;
    --ucf-mobile-header: 96px;
    --header-h: 96px;
    --footer-h: calc(70px + env(safe-area-inset-bottom, 0px));
    --ucf-mobile-gutter: clamp(10px, 3.4vw, 15px);
    --ucf-portrait-frame-height: max(
      calc(100svh - var(--header-h) - var(--footer-h) - 24px),
      calc(min(100vw, var(--ucf-mobile-max)) * 16 / 9)
    );
  }

  html,
  body {
    width: 100%;
    min-width: 0;
    min-height: 100%;
    overflow: hidden !important;
    -webkit-text-size-adjust: 100%;
  }

  body {
    background:
      radial-gradient(circle at 50% -10%, rgba(150, 20, 32, .26), transparent 32%),
      #060a0f;
  }

  body.ucf-landscape-lock { overflow: hidden !important; }

  .app-shell {
    width: 100%;
    max-width: var(--ucf-mobile-max);
    height: 100dvh;
    min-height: 100dvh;
    max-height: none;
    margin: 0 auto;
    display: grid;
    grid-template-rows: var(--header-h) minmax(0, 1fr) var(--footer-h);
    overflow: hidden;
  }

  /* En-tête : une ligne d'identité, puis trois divisions lisibles. */
  .site-header {
    grid-row: 1;
    position: relative;
    z-index: 60;
    width: 100%;
    height: var(--header-h) !important;
    min-height: var(--header-h) !important;
    padding: max(7px, env(safe-area-inset-top)) 12px 0 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 55px 40px;
    gap: 0;
    align-items: stretch;
    background: linear-gradient(120deg, #16232d 0%, #080d13 58%, #190d13 100%);
    border-bottom: 1px solid #b9323e;
    box-shadow: 0 4px 18px rgba(0, 0, 0, .45);
  }

  .site-header::after {
    left: 12px;
    right: 12px;
    width: auto;
    bottom: -2px;
    height: 1px;
  }

  .site-header .brand {
    grid-column: 1;
    grid-row: 1;
    width: auto;
    min-width: 0;
    height: 55px;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
  }

  .site-header .brand-emblem {
    width: 44px !important;
    height: 44px !important;
    flex: 0 0 44px;
  }

  .site-header .brand-wordmark {
    min-width: 0;
    overflow: hidden;
  }

  .site-header .brand-wordmark strong {
    display: block;
    overflow: hidden;
    font-size: clamp(15px, 4.6vw, 20px) !important;
    line-height: .90;
    letter-spacing: -.7px;
    text-overflow: clip;
    white-space: nowrap;
  }

  .site-header .brand-wordmark small {
    display: block;
    padding-top: 5px;
    overflow: hidden;
    font-size: 6.5px !important;
    letter-spacing: .14em;
    text-overflow: clip;
    white-space: nowrap;
  }

  .site-header .brand-meta,
  .site-header .brand-divider,
  .site-header .header-roundel { display: none !important; }

  .site-header .header-tools {
    grid-column: 2;
    grid-row: 1;
    height: 55px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 5px !important;
  }

  .site-header .header-tools .icon-button {
    width: 34px !important;
    height: 38px !important;
    min-width: 34px !important;
    border-radius: 9px;
    background: #0d1821;
    border-color: #3c4c58;
  }

  .site-header .header-tools .icon-button > svg {
    width: 18px !important;
    height: 18px !important;
  }

  .site-header #notificationToggle { display: none !important; }

  .site-header .top-navigation {
    grid-column: 1 / -1;
    grid-row: 2;
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    height: 40px !important;
    min-height: 0;
    padding: 3px 0 5px !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 5px !important;
    align-items: stretch;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .site-header .top-navigation::before { display: none !important; }

  .site-header .top-navigation .top-nav-item {
    width: 100%;
    max-width: none;
    height: 32px;
    min-height: 32px;
    padding: 2px 3px !important;
    gap: 2px;
    border-radius: 8px;
    font-size: 9px !important;
    line-height: 1.05;
    letter-spacing: .01em;
    white-space: nowrap;
  }

  .site-header .top-navigation .top-nav-item > svg {
    width: 15px !important;
    height: 15px !important;
  }

  .site-header .top-navigation .top-nav-item > span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* header-navigation.css utilise des sélecteurs #id + !important : on les
     neutralise explicitement pour que la navigation reste dans la grille. */
  #siteHeader #topNavigation {
    position: static !important;
    inset: auto !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 100% !important;
    max-width: none !important;
    flex: none !important;
    margin: 0 !important;
    height: 40px !important;
    min-height: 0 !important;
    padding: 3px 0 5px !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 5px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
    align-self: stretch !important;
  }

  #siteHeader #topNavigation .top-nav-item.bottom-item {
    width: 100% !important;
    height: 32px !important;
    min-height: 32px !important;
    max-width: none !important;
    padding: 2px 3px !important;
    gap: 2px !important;
    border: 1px solid #31434f !important;
    border-radius: 8px !important;
    background: linear-gradient(#16232c, #0b121a) !important;
    font-size: 9px !important;
    line-height: 1.05 !important;
    white-space: nowrap !important;
  }

  #siteHeader #topNavigation .top-nav-item.bottom-item.active {
    border-color: #e64e56 !important;
    background: linear-gradient(#40171e, #1a0d13) !important;
    box-shadow: inset 0 0 0 1px rgba(171, 42, 52, .48) !important;
  }

  #siteHeader #topNavigation .top-nav-item.bottom-item > svg {
    width: 15px !important;
    height: 15px !important;
    max-width: 15px !important;
    max-height: 15px !important;
  }

  #siteHeader #topNavigation .top-nav-item.bottom-item > span {
    display: block !important;
    max-width: 100% !important;
    font-size: 9px !important;
    line-height: 1.05 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Le corps garde un vrai cadre vertical 9:16, mais reste scrollable. */
  .body-grid,
  body[data-ucf-route="terminal"] #bodyGrid {
    grid-row: 2;
    width: 100%;
    height: 100% !important;
    min-height: 0 !important;
    max-width: var(--ucf-mobile-max);
    display: block !important;
    padding: 12px var(--ucf-mobile-gutter) 18px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #92313a transparent;
  }

  .body-grid > .main-column,
  body[data-ucf-route="terminal"] #bodyGrid > #mainContent {
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: auto !important;
    overflow: visible !important;
    display: block !important;
  }

  .body-grid > .sidebar { display: none !important; }

  .body-grid > .main-column > [hidden] { display: none !important; }

  .body-grid > .main-column > :is(
    .home-content:not([hidden]),
    .ucf-pages:not([hidden]),
    .ucf-lore:not([hidden]),
    .ucf-creator-portal:not([hidden]),
    .ucf-staff-portal:not([hidden]),
    .ucf-creator-profile:not([hidden]),
    .ucf-radio-page:not([hidden]),
    .module-surface:not([hidden])
  ) {
    width: 100%;
    height: auto !important;
    min-height: var(--ucf-portrait-frame-height) !important;
    max-height: none !important;
    overflow: visible !important;
  }

  #homeContent:not([hidden]) {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
    padding: 0 0 12px !important;
  }

  /* L'accueil vidéo est le cadre de référence exact 9:16. */
  body[data-ucf-route="terminal"] #homeContent:not([hidden]) {
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    display: block !important;
  }

  #ucfAccueilTransmission {
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: var(--ucf-portrait-ratio);
    border-radius: 14px;
  }

  #ucfAccueilVideo {
    height: calc(100% - var(--ucf-crt-tool-h, 55px)) !important;
  }

  .ucf-crt-home-tools {
    height: 55px;
    gap: 8px;
    padding: 6px 9px;
  }

  .ucf-crt-home-tools button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 39px;
    padding: 8px 9px;
    font-size: 9px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Portail : hiérarchie lisible en une colonne avant les cartes secondaires. */
  .home-content .home-hero { min-height: 0 !important; }
  .home-content .home-hero-core {
    grid-template-columns: 1fr !important;
    gap: 14px;
    padding: 18px 15px 15px;
  }

  .home-content .hero-insignia { display: none; }
  .home-content .hero-copy h1 { font-size: clamp(28px, 8vw, 39px) !important; }
  .home-content .hero-introduction { font-size: 13px; line-height: 1.55; }
  .home-content .hero-buttons { grid-template-columns: 1fr !important; gap: 8px; }
  .home-content .hero-buttons :is(button, a) { min-height: 45px; }
  .home-content .hero-data-line,
  .home-content .hero-bottom-line {
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 9px 11px;
    font-size: 8px;
    line-height: 1.35;
  }

  .home-content .home-module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
  }

  .home-content .home-module {
    min-height: 145px;
    padding: 11px;
  }

  .home-content .home-module strong { font-size: 12px; }
  .home-content .home-module small { font-size: 9px; line-height: 1.35; }
  .home-content .home-teaser-grid { grid-template-columns: 1fr !important; gap: 8px; }

  .category-filter {
    min-height: 52px;
    height: auto;
    margin-bottom: 10px;
    padding: 5px;
    display: flex !important;
    gap: 6px;
    overflow-x: auto !important;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x proximity;
  }

  .filter-button {
    min-height: 40px;
    height: auto;
    padding: 8px 12px;
    scroll-snap-align: start;
    font-size: 10px;
  }

  .section-intro { padding: 14px; margin-bottom: 10px; }
  .section-intro h1 { font-size: 22px; }
  .section-intro p { font-size: 12px; line-height: 1.45; }

  .event-grid {
    grid-template-columns: 1fr !important;
    grid-auto-rows: auto !important;
    gap: 10px;
  }

  .event-card { min-height: 0 !important; padding: 12px; gap: 10px; }
  .event-top { min-height: 0; gap: 10px; }
  .poster-wrap,
  .module-art {
    width: 96px;
    height: 132px;
    flex-basis: 96px;
  }

  .event-title { font-size: 15px; }
  .event-desc { font-size: 11px; line-height: 1.48; }
  .event-actions { gap: 6px; flex-wrap: wrap; }
  .event-actions .subtle-button { min-height: 39px; font-size: 10px; }
  .event-primary { min-height: 43px; }

  /* Pages, lore, créateurs et radio s'empilent au lieu de se comprimer. */
  .ucf-pages:not([hidden]),
  .ucf-lore:not([hidden]),
  .ucf-creator-portal:not([hidden]),
  .ucf-staff-portal:not([hidden]),
  .ucf-radio-page:not([hidden]) { padding-bottom: 10px; }

  .ucf-pages-head,
  .ucf-lore-header,
  .creator-portal-heading,
  .radio-page-header {
    padding: 14px !important;
    gap: 10px;
  }

  .ucf-pages-head h1,
  .ucf-lore-header h1,
  .creator-portal-heading h1,
  .radio-page-header h1 { font-size: 23px !important; line-height: 1.08; }

  .ucf-pages-head p,
  .ucf-lore-header p,
  .creator-portal-heading p { display: block !important; font-size: 11px !important; line-height: 1.48; }
  .ucf-pages-stage,
  .creator-portal-stage,
  #radioPageHost { height: auto !important; min-height: 0 !important; overflow: visible !important; padding: 10px !important; }
  .ucf-pages-cards,
  .creator-portal-grid { grid-template-columns: 1fr !important; grid-auto-rows: auto !important; height: auto !important; overflow: visible !important; gap: 9px !important; }
  .ucf-doc-card,
  .ucf-creator-card { min-height: 0 !important; max-height: none !important; height: auto !important; padding: 12px !important; }
  .ucf-doc-card p { display: block !important; font-size: 12px !important; line-height: 1.5; }
  .creator-card-content { min-height: 62px; gap: 10px; }
  .creator-avatar { width: 56px !important; height: 56px !important; flex-basis: 56px !important; }
  .creator-card-description h2 { font-size: 16px !important; }
  .creator-card-description p { font-size: 10px !important; line-height: 1.35; }
  .creator-access { min-height: 40px; font-size: 10px !important; }
  .creator-portal-footer { flex-wrap: wrap; min-height: 0; padding: 11px; }
  .creator-portal-footer span { font-size: 8px; }
  .creator-portal-footer button { min-height: 38px; }

  .ucf-lore-tabs { overflow-x: auto; padding: 0 10px 9px; }
  .ucf-lore-stage { min-height: 0 !important; height: auto !important; overflow: visible !important; padding: 10px !important; }
  .ucf-lore-footer { flex-wrap: wrap; gap: 8px; padding: 10px; }
  .ucf-lore-controls { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .ucf-lore-controls button { min-height: 40px; }

  .staff-stage { display: grid !important; grid-template-columns: 1fr !important; gap: 10px; padding: 10px; }
  .staff-founder-card { grid-template-columns: 104px minmax(0, 1fr) !important; min-height: 0; }
  .staff-content { padding: 11px !important; gap: 6px !important; }
  .staff-content h2 { font-size: 18px !important; }
  .staff-content p { font-size: 10px !important; line-height: 1.4 !important; }
  .staff-actions { flex-wrap: wrap; gap: 5px; }
  .staff-actions button { min-height: 36px; font-size: 9px !important; }
  .staff-info-grid { grid-template-columns: 1fr !important; gap: 8px; }

  .module-surface:not([hidden]) {
    min-height: var(--ucf-portrait-frame-height) !important;
    height: var(--ucf-portrait-frame-height) !important;
    overflow: hidden !important;
  }

  .module-surface .module-titlebar { min-height: 45px; }
  .module-titlebar strong { min-width: 0; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
  .module-surface iframe { width: 100%; height: calc(100% - 45px) !important; min-height: 0; }

  .ucf-creator-profile:not([hidden]) {
    height: var(--ucf-portrait-frame-height) !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  .creator-profile-head { padding: 8px !important; gap: 6px !important; }
  .creator-profile-actions { gap: 4px !important; }
  .creator-profile-actions button { min-height: 36px; padding: 5px 6px !important; font-size: 9px !important; }

  /* Navigation basse : cinq destinations fixes, le reste reste dans le drawer. */
  .site-footer {
    grid-row: 3;
    position: relative !important;
    z-index: 70;
    width: 100%;
    height: var(--footer-h) !important;
    min-height: var(--footer-h) !important;
    padding: 4px 6px env(safe-area-inset-bottom, 0px) !important;
    display: block !important;
    background: linear-gradient(#121b23, #05080c);
    border-top: 1px solid #b6333d;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, .55);
  }

  .site-footer .footer-right { display: none !important; }
  .site-footer .bottom-navigation {
    width: 100% !important;
    height: 100%;
    padding: 0 !important;
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 4px;
  }

  .site-footer .bottom-item {
    display: none !important;
    min-width: 0;
    min-height: 53px !important;
    padding: 5px 2px !important;
    border: 1px solid transparent;
    border-radius: 10px;
    color: #bdc9d5;
    font-size: 9px !important;
    line-height: 1.05;
    white-space: nowrap;
  }

  .site-footer .bottom-item:nth-child(1),
  .site-footer .bottom-item:nth-child(4),
  .site-footer .bottom-item:nth-child(5),
  .site-footer .bottom-item:nth-child(6),
  .site-footer .bottom-item:nth-child(8) { display: flex !important; }

  .site-footer .bottom-item svg { width: 20px !important; height: 20px !important; }
  .site-footer .bottom-item span { font-size: 9px !important; letter-spacing: 0 !important; }
  .site-footer .bottom-item.active,
  .site-footer .bottom-item.mobile-menu-active { color: #fff; background: #2c141a; border-color: #a83a45; }

  .modal-backdrop { z-index: 1000; padding: 12px !important; }
  .modal-window { width: 100% !important; max-width: 100% !important; max-height: calc(100dvh - 24px) !important; border-radius: 15px; }
  .modal-window :is(input, textarea, select) { font-size: 16px !important; }
  .search-drawer { top: var(--header-h) !important; width: 100% !important; max-width: var(--ucf-mobile-max); padding: 13px; }
  .search-input-wrap input { min-width: 0; font-size: 16px; }
  .toast { right: 12px; left: 12px; bottom: calc(var(--footer-h) + 12px); max-width: none; }
}

@media (max-width: 375px) {
  :root {
    --ucf-mobile-header: 91px;
    --header-h: 91px;
    --footer-h: calc(67px + env(safe-area-inset-bottom, 0px));
  }

  .site-header { grid-template-rows: 52px 36px; }
  .site-header .brand,
  .site-header .header-tools { height: 52px; }
  .site-header .brand-emblem { width: 39px !important; height: 39px !important; flex-basis: 39px; }
  .site-header .brand-wordmark strong { font-size: 14px !important; }
  .site-header .brand-wordmark small { font-size: 5.5px !important; }
  .site-header .top-navigation,
  #siteHeader #topNavigation { height: 36px !important; }
  .site-header .top-navigation .top-nav-item { height: 29px; min-height: 29px; font-size: 8px !important; }
  .site-header .top-navigation .top-nav-item > svg { width: 13px !important; height: 13px !important; }
  .site-header .header-tools .icon-button { width: 31px !important; min-width: 31px !important; height: 35px !important; }
  .home-content .home-module { min-height: 136px; padding: 9px; }
  .poster-wrap,
  .module-art { width: 88px; height: 124px; flex-basis: 88px; }
}

@media (max-width: 900px) and (orientation: landscape) and (max-height: 600px) {
  #ucfOrientationGuard:not([hidden]) { display: grid !important; }
}

@media (prefers-reduced-motion: reduce) {
  #ucfOrientationGuard *,
  #ucfMobileDrawer * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
