/* ========================================================================== 
   SURPRIA — UX polish layer (2026-08-10)
   Accessibility, mobile ergonomics, responsive resilience and interaction
   consistency. Loaded last so it can safely normalize legacy page styles.
   ========================================================================== */

:root {
    --focus-ring: 0 0 0 4px rgba(244, 165, 28, .22);
    --interactive-min: 44px;
    --mobile-gutter: 16px;
}

/* ========================================================================== 
   SURPRIA UX SYSTEM 2026
   A shared finishing layer for every customer-facing journey. It deliberately
   keeps the existing visual identity while normalising rhythm, controls,
   surfaces, feedback and responsive behaviour across legacy page styles.
   ========================================================================== */

:root {
    --ux-brand: var(--primary, #7c3aed);
    --ux-brand-strong: #6425d0;
    --ux-brand-soft: #f3edff;
    --ux-ink: #201a2b;
    --ux-muted: #6f6879;
    --ux-line: #e8e2ee;
    --ux-surface: #ffffff;
    --ux-canvas: #faf8fc;
    --ux-success: #178356;
    --ux-warning: #a75c00;
    --ux-danger: #c9364f;
    --ux-radius-sm: 10px;
    --ux-radius-md: 16px;
    --ux-radius-lg: 24px;
    --ux-shadow-sm: 0 1px 2px rgb(32 26 43 / 5%), 0 7px 24px rgb(59 35 88 / 6%);
    --ux-shadow-md: 0 18px 50px rgb(59 35 88 / 11%);
    --ux-focus: 0 0 0 4px rgb(124 58 237 / 18%);
    --ux-control-height: 46px;
    --ux-content-width: 1180px;
}

html { scroll-behavior: smooth; }

body {
    color: var(--ux-ink);
    background-color: var(--ux-canvas);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

body:not(.surprise-page) main { min-height: calc(100vh - 180px); }

.container { width: min(var(--ux-content-width), calc(100% - 40px)); }

/* Predictable keyboard navigation on every page. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus { outline: none; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--ux-brand);
    outline-offset: 3px;
    box-shadow: var(--ux-focus);
}

/* Controls share one visual language without changing their existing semantics. */
:where(.btn, button, input[type="submit"], input[type="button"]) {
    min-height: 44px;
    font-weight: 750;
    letter-spacing: -.01em;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease,
        background-color .18s ease, color .18s ease, opacity .18s ease;
}

:where(.btn, button, input[type="submit"], input[type="button"]):not(:disabled):active {
    transform: translateY(1px);
}

:where(.btn-primary, button[type="submit"]):not(.btn-light):not(.btn-dark) {
    box-shadow: 0 8px 20px rgb(124 58 237 / 20%);
}

:where(.btn-primary, button[type="submit"]):not(:disabled):hover {
    box-shadow: 0 11px 26px rgb(124 58 237 / 27%);
}

:where(button, .btn)[disabled], :where(button, .btn)[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: .55;
    box-shadow: none;
}

:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea) {
    border: 1px solid var(--ux-line);
    border-radius: var(--ux-radius-sm);
    background: var(--ux-surface);
    color: var(--ux-ink);
    transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select) {
    min-height: var(--ux-control-height);
}

:where(input, select, textarea):hover:not(:disabled) { border-color: #cfc4d9; }

:where(input, select, textarea):focus {
    border-color: var(--ux-brand);
    box-shadow: var(--ux-focus);
}

:where(input, textarea)::placeholder { color: #9b93a5; opacity: 1; }

/* Reusable surfaces: less visual noise, clearer grouping. */
:where(.event-card, .stat-card, .reaction-card, .reaction-stat-card, .account-card,
       .dashboard-next-step, .events-toolbar, .mm-panel, .checkout-card) {
    border-color: var(--ux-line);
    box-shadow: var(--ux-shadow-sm);
}

:where(.event-card, .reaction-card, .account-card, .mm-style-card) {
    transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

@media (hover: hover) {
    :where(.event-card, .reaction-card, .mm-style-card):hover {
        transform: translateY(-3px);
        border-color: #d9c9e8;
        box-shadow: var(--ux-shadow-md);
    }
}

/* Dashboard: make the next useful action visually dominant. */
.dashboard-main { padding-top: clamp(28px, 4vw, 54px); padding-bottom: 72px; }
.dashboard-welcome.dashboard-hero { margin-bottom: 24px; }
.dashboard-hero h1 { max-width: 760px; letter-spacing: -.045em; line-height: 1.06; }
.dashboard-hero-action .btn { white-space: nowrap; }
.dashboard-next-step {
    border-radius: var(--ux-radius-md);
    background: linear-gradient(135deg, #fff 0%, #fbf7ff 100%);
}
.dashboard-stats-compact { gap: 14px; }
.dashboard-stats-compact .stat-card { border-radius: var(--ux-radius-md); }
.dashboard-section-heading { align-items: end; gap: 18px; }
.events-grid { align-items: stretch; }
.event-card { border-radius: var(--ux-radius-lg); overflow: hidden; }
.event-card-content { min-width: 0; }
.event-card h2, .event-card h3 { overflow-wrap: anywhere; }
.event-card-footer { margin-top: auto; }
.event-status { font-weight: 800; letter-spacing: .015em; }
.memory-movie-callout { border-radius: 14px; }

/* Event list: one compact tool area, readable cards, accessible menus. */
.events-page-heading { gap: 24px; }
.events-toolbar { border-radius: var(--ux-radius-md); background: rgb(255 255 255 / 92%); }
.events-toolbar :where(input, select) { background-color: #fff; }
.events-results-heading { color: var(--ux-muted); }
.event-card-menu-popover { border: 1px solid var(--ux-line); border-radius: 12px; box-shadow: var(--ux-shadow-md); }
.event-progress-track { overflow: hidden; background: #eee9f2; }

/* Event details: preserve the cinematic hero while improving task scanning. */
.event-focus-hero { border-radius: clamp(20px, 3vw, 30px); box-shadow: var(--ux-shadow-md); }
.event-focus-actions { gap: 10px; }
.event-focus-actions .btn { min-width: 0; }
.event-view-title-edit { min-width: 44px; }
.event-view-container > section { scroll-margin-top: 110px; }

/* Reactions: video remains the focus, secondary metadata becomes quieter. */
.reactions-hero { border-radius: var(--ux-radius-lg); }
.reaction-featured { border-radius: var(--ux-radius-lg); overflow: hidden; box-shadow: var(--ux-shadow-md); }
.reaction-card-meta { color: var(--ux-muted); }
.reaction-card-actions { gap: 8px; }
.reaction-dialog-shell { border-radius: var(--ux-radius-lg); overflow: hidden; }

/* Memory Movie: same controls and rhythm as the rest of the creator area. */
.mm-shell { color: var(--ux-ink); }
.mm-wizard-header, .mm-wizard-progress { max-width: var(--ux-content-width); }
.mm-wizard-progress button { min-height: 58px; }
.mm-wizard-progress button[aria-current="step"],
.mm-wizard-progress button.is-active { color: var(--ux-brand-strong); }
.mm-step-heading { max-width: 760px; }
.mm-style-card { border-radius: var(--ux-radius-lg); overflow: hidden; }
.mm-style-card.is-selected { border-color: var(--ux-brand); box-shadow: var(--ux-focus), var(--ux-shadow-sm); }
.mm-choose-style, .mm-primary-action, .mm-secondary-action { min-height: 46px; }
.mm-autosave-indicator { border-radius: 999px; }

/* Authentication and account: remove dead space and make forms easier to scan. */
.auth-page main, main.auth-main { padding-block: clamp(28px, 6vw, 72px); }
.auth-card, .auth-panel { border-radius: var(--ux-radius-lg); box-shadow: var(--ux-shadow-md); }
.auth-card form, .auth-panel form { gap: 18px; }
.account-page .account-card { border-radius: var(--ux-radius-lg); }

/* Public pages: CTA consistency and clearer section rhythm. */
.home-page section, .seo-page section, .themes-page section { scroll-margin-top: 90px; }
.home-hero h1 { text-wrap: balance; }
.home-hero p, .section-heading p { text-wrap: pretty; }
.home-hero-actions, .hero-actions { gap: 12px; }
.home-hero-actions .btn, .hero-actions .btn { min-height: 50px; padding-inline: 22px; }

/* Feedback must be noticeable and understandable without colour alone. */
:where(.alert, .flash, .events-flash, [role="alert"], [role="status"]) {
    border-radius: var(--ux-radius-sm);
}

/* Tablet and mobile: prioritise primary actions and comfortable touch targets. */
@media (max-width: 900px) {
    :root { --ux-control-height: 48px; }
    .container { width: min(100% - 28px, var(--ux-content-width)); }
    .dashboard-main { padding-top: 24px; padding-bottom: 104px; }
    .dashboard-hero, .events-page-heading, .reactions-hero { align-items: stretch; }
    .dashboard-hero-action, .events-page-heading > .btn { width: 100%; }
    .dashboard-hero-action .btn, .events-page-heading > .btn { width: 100%; justify-content: center; }
    .dashboard-section-heading { align-items: flex-start; }
    .events-toolbar { position: static; }
    .event-focus-actions { width: 100%; }
    .event-focus-actions .btn { flex: 1 1 180px; justify-content: center; }
    .mm-wizard-progress { overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: none; }
    .mm-wizard-progress::-webkit-scrollbar { display: none; }
    .mm-wizard-progress button { flex: 0 0 auto; min-width: 58px; }
}

@media (max-width: 640px) {
    .container { width: min(100% - 24px, var(--ux-content-width)); }
    h1 { text-wrap: balance; }
    .dashboard-main { padding-top: 18px; }
    .dashboard-hero h1 { font-size: clamp(2rem, 10vw, 2.75rem); }
    .dashboard-stats-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-stats-compact .stat-card { min-height: 112px; padding: 16px; }
    .event-card, .reaction-card, .auth-card, .account-card { border-radius: 18px; }
    .events-toolbar :where(form, .events-filters) { width: 100%; }
    .events-toolbar :where(input, select, .btn) { width: 100%; }
    .event-focus-actions { display: grid; grid-template-columns: 1fr; }
    .event-focus-actions .btn { width: 100%; }
    .reaction-featured-actions, .reaction-card-actions { display: grid; grid-template-columns: 1fr; }
    .reaction-featured-actions .btn, .reaction-card-actions > * { width: 100%; justify-content: center; }
    .mm-step-actions { position: sticky; bottom: 0; z-index: 8; margin-inline: -12px; padding: 12px;
        background: rgb(250 248 252 / 94%); border-top: 1px solid var(--ux-line); backdrop-filter: blur(14px); }
    .mm-step-actions :where(button, .mm-primary-action, .mm-secondary-action) { min-height: 50px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

@media (prefers-contrast: more) {
    :root { --ux-line: #9b91a5; --ux-muted: #4f4758; }
    :where(.btn, button, input, select, textarea) { border-width: 2px; }
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    min-width: 320px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

img,
video {
    height: auto;
}

button,
[type="button"],
[type="submit"],
[type="reset"],
select,
label[for],
a[href] {
    -webkit-tap-highlight-color: transparent;
}

button,
[type="button"],
[type="submit"],
[type="reset"] {
    touch-action: manipulation;
}

button:not(:disabled),
[type="button"]:not(:disabled),
[type="submit"]:not(:disabled),
[type="reset"]:not(:disabled) {
    cursor: pointer;
}

:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
    outline: 3px solid rgba(244, 165, 28, .82);
    outline-offset: 3px;
}

:where(input, textarea, select):focus-visible {
    outline: none;
    border-color: var(--accent, #f4a51c);
    box-shadow: var(--focus-ring);
}

:where(button, input, textarea, select):disabled,
:where(.btn)[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: .58;
    transform: none;
    box-shadow: none;
}

:where(p, li, dd, .event-field-help, .field-help, .form-alert, .recipient-menu-note) {
    overflow-wrap: anywhere;
}

.container {
    width: min(var(--container), calc(100% - 40px));
}

/* Make modern viewport units win over 100vh on Safari/iOS. */
.dashboard-page,
.auth-page {
    min-height: 100dvh;
}

/* Sticky glass headers remain readable when backdrop-filter is unavailable. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .site-header,
    .dashboard-header,
    .auth-header {
        background: rgba(255, 250, 242, .98);
    }
}

/* Unified control ergonomics. */
:where(.form-group, .event-field, .event-view-field) :where(input:not([type="checkbox"]):not([type="radio"]), textarea, select) {
    min-height: 48px;
}

:where(textarea) {
    resize: vertical;
}

:where(input, textarea, select) {
    max-width: 100%;
}

:where(.btn, .auth-submit, .event-card-delete-button, .password-toggle, .language-popup-trigger) {
    min-height: var(--interactive-min);
}

/* Hover effects should not jump on touch screens. */
@media (hover: none) {
    .btn:hover,
    .idea-card-link:hover,
    .language-choice:hover,
    .auth-benefit:hover {
        transform: none;
    }
}

/* Dashboard / creator usability. */
.dashboard-user-dropdown,
.event-card-menu-popover {
    overscroll-behavior: contain;
}

.dashboard-user-dropdown {
    max-height: min(520px, calc(100dvh - 100px));
    overflow-y: auto;
}

.dashboard-section-heading h1,
.dashboard-section-heading h2,
.dashboard-welcome h1,
.event-form-section h2,
.auth-intro h1 {
    text-wrap: balance;
}

.event-form-actions,
.hero-actions,
.header-actions,
.auth-header-actions {
    flex-wrap: wrap;
}

/* Prevent wide content from stretching pages on small displays. */
:where(.dashboard-main, .auth-main, .event-form, .events-grid, .events-toolbar, .event-view-layout) {
    min-width: 0;
}

:where(table) {
    max-width: 100%;
}

/* Horizontal data areas remain usable rather than clipping the page. */
:where(.table-wrap, .table-responsive, .data-table-wrap) {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Public homepage: clearer CTA feedback and keyboard affordance. */
.btn {
    border: 1px solid transparent;
}

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

.btn-light:focus-visible {
    border-color: rgba(244, 165, 28, .55);
}

/* Long translations must not overflow pill/button controls. */
:where(.btn, .dashboard-nav a, .language-choice, .event-card-primary-action) {
    text-align: center;
    overflow-wrap: anywhere;
}

/* Mobile usability --------------------------------------------------------- */
@media (max-width: 680px) {
    .container,
    .dashboard-page .container {
        width: min(100% - (var(--mobile-gutter) * 2), var(--container));
    }

    .site-header,
    .dashboard-header {
        padding-top: env(safe-area-inset-top);
    }

    .hero {
        padding-top: 52px;
        padding-bottom: 78px;
    }

    .section {
        padding-top: 76px;
        padding-bottom: 76px;
    }

    .dashboard-main {
        padding-top: 28px;
    }

    /* 16px prevents Safari from zooming the viewport on form focus. */
    :where(input:not([type="checkbox"]):not([type="radio"]), textarea, select) {
        font-size: 16px !important;
    }

    :where(.btn, .auth-submit) {
        min-height: 48px;
    }

    .hero-actions,
    .event-form-actions {
        width: 100%;
    }

    .hero-actions > .btn,
    .event-form-actions > .btn,
    .event-form-actions > button {
        flex: 1 1 100%;
        width: 100%;
    }

    .dashboard-user-dropdown {
        max-height: calc(100dvh - 92px - env(safe-area-inset-bottom));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .event-card-menu-popover {
        bottom: max(14px, env(safe-area-inset-bottom));
    }

    .language-modal-card {
        padding-bottom: max(22px, env(safe-area-inset-bottom));
    }

    .auth-layout,
    .hero-grid,
    .themes-layout,
    .faq-layout,
    .experience-layout {
        gap: 38px;
    }
}

@media (max-width: 420px) {
    :root {
        --mobile-gutter: 12px;
    }

    .dashboard-welcome h1,
    .auth-intro h1 {
        font-size: clamp(2.05rem, 11vw, 2.55rem);
        letter-spacing: -.05em;
    }

    .dashboard-user-dropdown {
        left: 8px;
        right: 8px;
    }
}

/* Respect OS accessibility settings globally, including theme previews. */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}


/* ========================================================================== 
   PHASE D — expérience destinataire mobile-first
   ========================================================================== */
.surprise-public-page { min-height:100dvh; overscroll-behavior:none; }
.surprise-public-page .baby-gift-theme { min-height:100dvh; }
.surprise-public-page .baby-gift-step { min-height:100dvh; box-sizing:border-box; }
/* La preview sert uniquement à se cadrer. Pendant le compte à rebours et la
   révélation, le destinataire ne se voit plus : sa réaction reste naturelle. */
html[data-surpria-state="REACTION"] .surprise-public-page [data-step="gift"] .theme-camera,
html[data-surpria-state="REVEAL"] .surprise-public-page .theme-camera { display:none !important; }
/* La fin est automatique : le bouton d'arrêt anticipé n'est plus mis en avant. */
.surprise-public-page [data-step="reveal"] .theme-btn-danger { display:none !important; }
.surprise-public-page .theme-recording { opacity:.72; transform:scale(.9); transform-origin:center; }
@media (max-width: 720px) {
  .surprise-public-page { margin:0; padding:0; }
  .surprise-public-page .baby-gift-step { padding:max(20px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom)); }
  .surprise-public-page .theme-actions { width:100%; }
  .surprise-public-page .theme-btn { width:100%; min-height:54px; font-size:1rem; }
  .surprise-public-page .theme-camera { width:min(82vw, 360px); margin-inline:auto; }
  .surprise-public-page .theme-countdown { font-size:clamp(4rem, 24vw, 8rem); }
}

/* Final shared contract: intentionally last in this cascade. */
.surpria-skip-link {
  position: fixed;
  z-index: 10000;
  top: 10px;
  left: 12px;
  transform: translateY(-160%);
  padding: 11px 16px;
  border-radius: 10px;
  color: #fff;
  background: #201a2b;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 12px 32px rgb(32 26 43 / 28%);
  transition: transform .18s ease;
}
.surpria-skip-link:focus { transform: translateY(0); }

@media (max-width: 640px) {
  :where(.dashboard-page, .account-page, .memory-movie-page) .btn-primary,
  :where(.dashboard-page, .account-page, .memory-movie-page) button[type="submit"] {
    min-height: 50px;
  }
  .dashboard-page .event-card-footer > :where(a, button),
  .dashboard-page .event-card-footer .btn {
    min-height: 48px;
  }
}
