/* ============================================================
 * Rokudan — Mobile premium (mobile-first overrides)
 * Inspiré : Stripe, Linear, Notion, Apple, Framer
 *
 * Breakpoints standards :
 *   ≤ 640px  : mobile (iPhone SE → 14 Plus)
 *   641-980  : tablette
 *   981-1200 : desktop
 *   > 1200   : wide
 *
 * Cette couche s'applique APRÈS vitrine.css/base.css (load order).
 * Elle fixe les bugs mobile sans toucher au desktop existant.
 * ============================================================ */

/* ─────────── GLOBAL : prévention bugs systémiques ─────────── */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}
html, body {
  overflow-x: hidden;                    /* Stop scroll horizontal accidentel */
  max-width: 100%;
}
body {
  /* Safe-area iPhone notch / dynamic island */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
* {
  /* Pas de tap highlight bleu/gris moche sur iOS */
  -webkit-tap-highlight-color: rgba(119, 71, 255, 0.12);
}
img, video, svg, iframe {
  max-width: 100%;
  height: auto;
}
img {
  /* Évite le décalage layout pendant chargement (CLS) */
  font-style: italic;            /* alt visible si broken */
  background-repeat: no-repeat;
  background-size: cover;
  shape-margin: 0.75rem;
}

/* ─────────── ACCESSIBILITÉ : motion + contraste ─────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─────────── INPUTS : éviter zoom auto iOS ─────────── */
input, select, textarea {
  font-size: 16px !important;           /* iOS zoom kick-in si < 16px */
  -webkit-appearance: none;
  appearance: none;
}
input[type="checkbox"], input[type="radio"] {
  font-size: inherit !important;
}

/* ─────────── TOUCH TARGETS minimum 44×44 (Apple HIG) ─────────── */
@media (max-width: 980px) {
  .btn, .btn-sm, button, .nav-item, .pill, a.btn, .v-nav-links a,
  .v-nav-mobile-panel a, .tk-filter, .hist-filter, .cat-pill,
  .icon-btn, .sidebar-wallet-btn {
    min-height: 44px;
  }
  .icon-btn, .btn-icon { min-width: 44px; }
  /* Cibles tactiles plus larges pour les liens fins en footer */
  .v-footer a { display: inline-block; padding: 6px 0; }
}

/* ─────────── NAV — Burger menu premium ─────────── */
@media (max-width: 980px) {
  .v-nav-links { display: none !important; }
  .v-nav-burger { display: flex !important; }
}
@media (min-width: 981px) {
  .v-nav-burger { display: none !important; }
  .v-nav-mobile-panel { display: none !important; }
}
.v-nav-mobile-panel {
  /* Animation glide premium au lieu du brutal transform */
  position: fixed !important;
  top: 0 !important; left: 0; right: 0; bottom: 0;
  height: 100dvh !important;            /* viewport dynamique iOS */
  background: var(--cream) !important;
  padding: 88px 28px 32px !important;
  transform: translateY(-100%);
  transition: transform .35s cubic-bezier(.2,.85,.25,1) !important;
  overflow-y: auto;
  display: flex !important;
  flex-direction: column;
  gap: 4px;
  z-index: 60;
  border-bottom: 0 !important;
  box-shadow: 0 12px 40px rgba(0,0,0,.08);
  visibility: hidden;
  pointer-events: none;
}
.v-nav-mobile-panel.is-open {
  transform: translateY(0) !important;
  visibility: visible;
  pointer-events: auto;
}
/* Nav doit rester au-dessus du panel pour que le burger reste cliquable */
.v-nav { z-index: 70 !important; }
.v-nav-burger { position: relative; z-index: 71 !important; }
/* Bouton burger anime en X quand le menu est ouvert */
body.has-mobile-menu .v-nav-burger { background: transparent !important; }
body.has-mobile-menu .v-nav-burger svg path:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
  transform-origin: center;
}
body.has-mobile-menu .v-nav-burger svg path:nth-child(2) { opacity: 0; }
body.has-mobile-menu .v-nav-burger svg path:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
  transform-origin: center;
}
.v-nav-burger svg path { transition: transform .25s ease, opacity .15s ease; }
.v-nav-mobile-panel a {
  padding: 18px 0 !important;
  font-family: var(--font-display);
  font-size: clamp(24px, 6vw, 32px) !important;
  letter-spacing: -0.02em;
  color: var(--ink) !important;
  border-bottom: 1px solid var(--line-2) !important;
  display: block;
  transition: color .15s, padding-left .2s;
}
.v-nav-mobile-panel a:active { color: var(--violet); padding-left: 6px; }
.v-nav-mobile-cta {
  margin-top: auto !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 12px;
  padding-top: 24px;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}
.v-nav-mobile-cta a {
  text-align: center !important;
  padding: 16px !important;
  border-radius: 999px !important;
  font-size: 16px !important;
  font-family: var(--font-sans) !important;
  border: 1px solid var(--line) !important;
  background: var(--paper);
}
.v-nav-mobile-cta a.primary {
  background: var(--violet) !important;
  color: #fff !important;
  border-color: var(--violet) !important;
  box-shadow: var(--shadow-violet);
}

/* Body lock quand menu ouvert */
body.has-mobile-menu { overflow: hidden; }

/* ─────────── HERO mobile : tailles & espacement ─────────── */
@media (max-width: 760px) {
  .v-hero, .v-section { padding-left: 20px !important; padding-right: 20px !important; }
  .v-hero { padding-top: 48px !important; padding-bottom: 56px !important; }
  .v-hero-inner { grid-template-columns: 1fr !important; gap: 32px !important; text-align: left; }
  .v-hero h1 { font-size: clamp(32px, 8.5vw, 48px) !important; line-height: 1.05; }
  .v-hero-lead { font-size: 16px !important; line-height: 1.6 !important; }
  .v-hero-cta { flex-direction: column !important; align-items: stretch !important; gap: 12px !important; }
  .v-hero-cta .btn { width: 100% !important; justify-content: center; height: 52px; }
  .v-feature-visual { aspect-ratio: 4/5 !important; max-height: 70vh; }
  .cs-hero, .cs-hero-inner { padding: 56px 20px !important; }
  .cs-hero-inner { grid-template-columns: 1fr !important; gap: 32px !important; }
  .cs-hero h1 { font-size: clamp(30px, 8vw, 42px) !important; }
  .cs-meta { grid-template-columns: 1fr 1fr !important; gap: 16px !important; padding: 24px 0; margin-top: 24px; }
}

/* ─────────── SECTIONS : padding & headers ─────────── */
@media (max-width: 760px) {
  .v-section { padding-top: 64px !important; padding-bottom: 64px !important; }
  .v-head h2 { font-size: clamp(28px, 7vw, 40px) !important; line-height: 1.1 !important; }
  .v-head h2 br { display: none; }  /* Évite les retours qui bousillent la lecture mobile */
  .v-head p { font-size: 15px !important; line-height: 1.6 !important; }
  .v-feature-text h3 { font-size: clamp(26px, 6.5vw, 34px) !important; line-height: 1.15 !important; }
  .v-feature { grid-template-columns: 1fr !important; gap: 40px !important; margin-bottom: 64px !important; }
  .v-feature.flip .v-feature-text { order: -1 !important; }
}

/* ─────────── GRILLES auto-fit moderne ─────────── */
@media (max-width: 760px) {
  .v-bento { grid-template-columns: 1fr !important; gap: 14px !important; }
  .v-bento-card { padding: 24px !important; min-height: auto !important; }
  .v-bento-card.col-2, .v-bento-card.col-3, .v-bento-card.col-4 { grid-column: span 1 !important; }
  .v-stats { grid-template-columns: 1fr 1fr !important; gap: 14px !important; }
  .v-stat {
    text-align: center !important;
    padding: 20px 14px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
  }
  .v-stat-num { font-size: clamp(30px, 8vw, 44px) !important; margin-bottom: 10px !important; }
  .v-stat-lbl { max-width: none !important; font-size: 12px !important; line-height: 1.45 !important; }
  .v-trust-inner { flex-direction: column !important; gap: 20px !important; }
  .v-trust-logos { gap: 24px !important; justify-content: center; }
  /* Galeries cas-clients */
  .cs-gallery, .cs-gallery.three { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  .rk-gallery { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  /* Process timeline 4 colonnes → 1 */
  .cs-process { grid-template-columns: 1fr !important; gap: 36px !important; }
}
@media (max-width: 440px) {
  .cs-gallery, .cs-gallery.three { grid-template-columns: 1fr 1fr !important; }
  /* On garde 2x2 même sur petits écrans, centré */
  .v-stats { grid-template-columns: 1fr 1fr !important; gap: 12px !important; }
  .v-stat { padding: 16px 10px !important; }
  .v-stat-num { font-size: clamp(26px, 7vw, 36px) !important; }
  .v-stat-lbl { font-size: 11px !important; }
}

/* ─────────── CARTES cas / blog : harmonisation ─────────── */
@media (max-width: 760px) {
  .v-case { grid-template-columns: 1fr !important; }
  .v-case-cover { aspect-ratio: 16/9 !important; }
  .v-case-stats { grid-template-columns: 1fr !important; gap: 8px !important; }
  .blog-grid { grid-template-columns: 1fr !important; gap: 16px !important; }
  .blog-card { padding: 18px !important; }
  .blog-card-cover { aspect-ratio: 16/9 !important; }
}

/* ─────────── ARTICLE blog / case study lisibilité ─────────── */
@media (max-width: 760px) {
  .cs-content { padding: 0 !important; }
  .cs-content h2 { font-size: clamp(24px, 6.5vw, 32px) !important; margin-top: 40px !important; }
  .cs-content h3 { font-size: clamp(20px, 5.5vw, 26px) !important; margin-top: 28px !important; }
  .cs-content p { font-size: 16px !important; line-height: 1.7 !important; }
  .cs-pullquote { font-size: 19px !important; padding: 4px 0 4px 18px !important; margin: 28px 0 !important; }
}

/* ─────────── CTA section finale, sticky côté mobile ─────────── */
@media (max-width: 760px) {
  .v-cta {
    padding: 56px 28px !important;
    border-radius: 24px !important;
  }
  .v-cta h2 { font-size: clamp(28px, 7vw, 38px) !important; line-height: 1.1 !important; }
  .v-cta h2 em { display: inline; }
  .v-cta p { font-size: 15px !important; margin-top: 16px !important; line-height: 1.55 !important; }
  .v-cta-actions { flex-direction: column !important; gap: 10px !important; margin-top: 28px !important; width: 100% !important; }
  .v-cta-actions .btn { width: 100% !important; height: 52px !important; }
}

/* ─────────── FOOTER : 2 colonnes minimum mobile ─────────── */
@media (max-width: 760px) {
  .v-footer { padding: 56px 20px 0 !important; }
  .v-footer-top {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 32px 20px !important;
    padding-bottom: 32px !important;
  }
  .v-footer-brand { grid-column: 1 / -1 !important; max-width: none !important; }
  .v-footer-brand .brand-mark { width: 160px !important; height: 36px !important; }
  .v-footer-brand::after { font-size: 11px !important; }
  .v-footer h5 { margin-bottom: 14px !important; font-size: 10px !important; }
  .v-footer ul { gap: 10px !important; font-size: 14px !important; }
  .v-footer a { padding: 4px 0 !important; }
  .v-footer-bottom {
    flex-direction: column !important;
    gap: 12px !important;
    text-align: center;
  }
}
@media (max-width: 380px) {
  .v-footer-top { gap: 28px 16px !important; }
  .v-footer ul { font-size: 13px !important; }
}

/* ─────────── APP (espace client) responsive critique ─────────── */
@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr !important;
    display: block !important;
  }
  .sidebar {
    position: fixed !important;
    top: 0; left: -100%;
    width: 280px !important;
    height: 100vh !important;
    z-index: 100;
    transition: left .3s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,.1);
  }
  .sidebar.is-open { left: 0; }
  .main { padding-left: 20px !important; padding-right: 20px !important; padding-top: 16px !important; }
  .topbar {
    padding: 12px 0 !important;
    flex-wrap: wrap;
    gap: 12px;
  }
  /* Affiche un bouton burger pour ouvrir la sidebar côté app */
  .app .topbar::before {
    content: "☰";
    font-size: 22px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--surface-2);
    margin-right: auto;
    order: -1;
  }
  .breadcrumb { font-size: 13px !important; }
}

/* ─────────── TABLES → cartes empilées sur mobile ─────────── */
@media (max-width: 640px) {
  .table { display: block; }
  .table thead { display: none; }
  .table tbody, .table tr {
    display: block;
    width: 100%;
  }
  .table tr {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
  }
  .table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0 !important;
    border: 0 !important;
    font-size: 13px;
    gap: 12px;
  }
  .table td::before {
    content: attr(data-label);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--mute);
    flex-shrink: 0;
  }
}

/* ─────────── PERFS : désactive shadows lourdes mobile ─────────── */
@media (max-width: 760px) {
  .v-feature-visual,
  .v-bento-card,
  .blog-card {
    box-shadow: 0 4px 12px rgba(0,0,0,.04) !important;
  }
  /* Désactive les radial gradients en background (très coûteux mobile) */
  .v-hero::after { display: none; }
  .v-hero.dark::after { opacity: .15; }
}

/* ─────────── LIGHTBOX adaptation mobile ─────────── */
@media (max-width: 640px) {
  .rk-lightbox-overlay { padding: 8px !important; }
  .rk-lb-figure img { max-height: 75vh !important; }
}

/* ─────────── SECTIONS HERO sombres : meilleure lisibilité ─────────── */
@media (max-width: 760px) {
  .v-hero.dark { background: linear-gradient(165deg, #0a0a0a 0%, #1a1a1a 100%); padding: 56px 20px !important; }
}

/* ─────────── INPUTS de search : tactile ─────────── */
@media (max-width: 760px) {
  .input-search input { height: 48px !important; font-size: 16px !important; padding-left: 44px !important; }
  .input-search svg { left: 14px; }
}

/* ─────────── FORMULAIRES auth/contact ─────────── */
@media (max-width: 760px) {
  .auth-form .field input,
  .auth-form .field select,
  .auth-form .field textarea {
    height: 52px !important;
    border-radius: 12px !important;
  }
  .auth-form .field textarea { height: auto !important; min-height: 120px; }
  .auth-form .field-row { grid-template-columns: 1fr !important; gap: 16px !important; }
  .auth-submit, .auth-form button[type="submit"] {
    width: 100% !important;
    height: 56px !important;
    font-size: 16px !important;
    border-radius: 999px !important;
  }
}

/* ─────────── PATCHS V2 (correctifs ciblés) ─────────── */

/* Blog : la card featured "span 2" déborde sur mobile → force 1 col */
@media (max-width: 980px) {
  .blog-card[style*="grid-column"],
  .blog-card[style*="span 2"] {
    grid-column: 1 / -1 !important;
  }
  .blog-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  .blog-card {
    padding: 20px !important;
  }
  .blog-card-cover {
    aspect-ratio: 16/9 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
  }
  .blog-card h3 { font-size: 20px !important; line-height: 1.25 !important; word-wrap: break-word; }
  .blog-card p { font-size: 14px !important; line-height: 1.5 !important; }
}

/* cs-hero : NE PAS recouvrir le header v-nav.
   Sur mobile le header est ~56px → on ajoute un padding-top safe */
@media (max-width: 980px) {
  .cs-hero {
    padding-top: 100px !important;     /* assez pour ne pas coller au menu */
    padding-bottom: 48px !important;
  }
  .cs-hero::after {
    /* Radial violet trop intense, qui mange le texte → on réduit */
    opacity: .25 !important;
    width: 100% !important; right: -30% !important;
    top: -10% !important;
    height: 60% !important;
  }
  .cs-hero-inner {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }
  .cs-hero h1 {
    font-size: clamp(28px, 7.5vw, 40px) !important;
    line-height: 1.1 !important;
  }
  .cs-hero h1 em { display: inline; }
  .cs-hero p { font-size: 15px !important; }
  .cs-hero-vis { max-height: 60vh !important; }
}

/* Logo : version horizontale agrandie sur mobile (au lieu du carré seul) */
@media (max-width: 760px) {
  .v-nav .brand,
  .v-nav .brand-mark {
    height: 44px !important;
  }
  .v-nav .brand-mark {
    width: 170px !important;
    background-image: url('/assets/logo/rokudan-horizontal-violet.svg') !important;
    background-size: contain !important;
    background-position: left center !important;
    background-repeat: no-repeat !important;
  }
  /* Réduit le bouton "Réserver une démo" qui prend trop de place */
  .v-nav .v-nav-actions .btn-primary {
    padding: 0 14px !important;
    font-size: 12px !important;
    height: 36px !important;
  }
  .v-nav .v-nav-actions .btn-primary svg { display: none; }
  /* "Se connecter" caché sur petit mobile (accessible via burger) */
  .v-nav .v-nav-actions .btn-ghost { display: none !important; }
}

/* Menu : header toujours visible sur cs-hero (z-index strict) */
.v-nav {
  position: sticky !important;
  top: 0;
  z-index: 100 !important;
  background: var(--cream) !important;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.v-nav-inner {
  position: relative;
  z-index: 1;
}

/* Article cs-content : meilleur padding & ombre douce */
@media (max-width: 760px) {
  .cs-content {
    padding: 0 4px !important;
  }
  .cs-content h2 em {
    display: block; /* l'italic violet passe à la ligne pour respiration */
    margin-top: 4px;
  }
  /* Pullquote plus respirante */
  .cs-pullquote {
    margin: 32px -4px !important;
    padding: 18px 16px !important;
    background: rgba(119, 71, 255, .06);
    border-left: 4px solid var(--violet);
    border-radius: 12px;
    font-size: 17px !important;
  }
}

/* v-hero.dark : pareil, padding correct au-dessus du nav */
@media (max-width: 980px) {
  .v-hero.dark {
    padding-top: 80px !important;
    padding-bottom: 56px !important;
  }
}

/* Galeries : suppression débordement horizontal */
.cs-gallery, .rk-gallery {
  max-width: 100%;
  overflow: hidden;
}

/* Catch-all : tout élément enfant direct d'une section ne déborde pas */
@media (max-width: 980px) {
  .v-section-inner, .cs-hero-inner, .v-hero-inner {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    box-sizing: border-box;
  }
  .v-bento { padding: 0 !important; }
}
