/**
 * StoryCraft - Base Styles
 * Variables CSS, reset, typographie et styles fondamentaux
 *
 * Made with 🌿 by Ivy — Elysia Suite
 * https://elysia-suite.com
 *
 * @version 2.1
 * @license CC BY-NC-SA 4.0
 */

/* === VARIABLES CSS === */
:root {
    /* Couleurs principales - WCAG AA compliant */
    --primary-color: #d64d7a; /* darkened from #ff6b9d for better contrast */
    --secondary-color: #2a9d8f; /* darkened from #4ecdc4 */
    --accent-color: #2980b9; /* darkened from #45b7d1 */
    --success-color: #27ae60; /* darkened from #96ceb4 */
    --warning-color: #d68910; /* darkened from #feca57 */
    --error-color: #c0392b; /* darkened from #ff7675 */

    /* Couleurs amusantes - adjusted for contrast */
    --fun-purple: #7c3aed; /* darkened from #a29bfe */
    --fun-orange: #db2777; /* darkened from #fd79a8 */
    --fun-yellow: #ca8a04; /* darkened from #fdcb6e */
    --fun-green: #5b21b6; /* darkened from #6c5ce7 */

    /* Couleurs de texte - WCAG AA compliant (4.5:1 minimum) */
    --text-primary: #1a1a2e; /* contrast 15:1 on white */
    --text-secondary: #374151; /* darkened to #374151 for 7:1 ratio on white */
    --text-muted: #6b7280; /* for less important text, still 4.5:1 */
    --text-fun: #9d174d; /* darkened for better contrast */
    --text-on-color: #ffffff; /* white text on colored backgrounds */
    --text-on-color-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); /* shadow for white text on gradients */

    /* Couleurs de fond */
    --background-primary: #f8f9ff;
    --background-secondary: #e8f4fd;
    --background-card: #ffffff;
    --background-fun: linear-gradient(
        135deg,
        #667eea 0%,
        #764ba2 20%,
        #f093fb 40%,
        #4ecdc4 60%,
        #45b7d1 80%,
        #96ceb4 100%
    );

    /* Bordures et ombres */
    --border-color: #ddd6fe;
    --shadow-light: 0 4px 15px rgba(102, 126, 234, 0.1);
    --shadow-medium: 0 8px 30px rgba(255, 107, 157, 0.15);
    --shadow-heavy: 0 15px 45px rgba(78, 205, 196, 0.2);
    --shadow-fun: 0 10px 40px rgba(255, 107, 157, 0.3);

    /* Rayons de bordure */
    --border-radius: 20px;
    --border-radius-small: 12px;
    --border-radius-large: 30px;

    /* Animations */
    --animation-duration: 0.4s;
    --bounce-duration: 0.6s;

    /* Typographie */
    --font-family: "Comic Neue", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;

    /* Espacement */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Z-index */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
}

/* === RESET CSS === */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    line-height: 1.15;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--background-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === ACCESSIBILITY HELPERS === */
.visually-hidden {
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
}

/* === NOTIFICATION SYSTEM (added) === */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 260px;
    max-width: 360px;
    padding: 14px 18px;
    background: var(--background-card);
    border-radius: 16px;
    box-shadow: var(--shadow-medium);
    border: 2px solid var(--border-color);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
    transition:
        opacity 0.3s ease,
        transform 0.3s ease;
    z-index: var(--z-tooltip);
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}
.notification.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.notification.success {
    border-color: var(--success-color);
}
.notification.error {
    border-color: var(--error-color);
}
.notification.warning {
    border-color: var(--warning-color);
}
.notification.info {
    border-color: var(--accent-color);
}
#notification-text {
    flex: 1;
}

/* === TYPOGRAPHIE === */
h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0 0 1rem 0;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

h1 {
    font-size: var(--font-size-4xl);
    font-weight: 800;
}

h2 {
    font-size: var(--font-size-3xl);
    font-weight: 700;
}

h3 {
    font-size: var(--font-size-2xl);
    font-weight: 600;
}

h4 {
    font-size: var(--font-size-xl);
    font-weight: 600;
}

h5 {
    font-size: var(--font-size-lg);
    font-weight: 500;
}

h6 {
    font-size: var(--font-size-base);
    font-weight: 500;
}

p {
    margin: 0 0 1rem 0;
    line-height: 1.6;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--animation-duration) ease;
}

a:hover {
    color: var(--fun-orange);
    text-decoration: underline;
}

/* === ÉLEMENTS DE BASE === */
img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius-small);
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    margin: 0;
}

input,
textarea,
select {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

/* === UTILITAIRES === */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.font-weight-normal {
    font-weight: 400;
}

.font-weight-bold {
    font-weight: 700;
}

/* === CONTAINER === */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* === SCROLLBARS DE BASE === */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--background-secondary);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--background-secondary, rgba(221, 214, 254, 0.1));
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--fun-orange) 100%);
    border-radius: 5px;
    border: 2px solid var(--background-secondary, transparent);
    transition: all var(--animation-duration) ease;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--fun-orange) 0%, var(--primary-color) 100%);
    box-shadow: 0 0 10px rgba(255, 107, 157, 0.4);
}

::-webkit-scrollbar-corner {
    background: var(--background-secondary, transparent);
}

/* === FOCUS STYLES === */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* === SÉLECTION DE TEXTE === */
::selection {
    background: var(--primary-color);
    color: white;
}

::-moz-selection {
    background: var(--primary-color);
    color: white;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    :root {
        --font-size-xs: 0.7rem;
        --font-size-sm: 0.8rem;
        --font-size-base: 0.9rem;
        --font-size-lg: 1rem;
        --font-size-xl: 1.1rem;
        --font-size-2xl: 1.3rem;
        --font-size-3xl: 1.6rem;
        --font-size-4xl: 2rem;

        --spacing-xs: 0.2rem;
        --spacing-sm: 0.4rem;
        --spacing-md: 0.8rem;
        --spacing-lg: 1.2rem;
        --spacing-xl: 1.6rem;
        --spacing-2xl: 2.4rem;
    }

    .container {
        padding: 0 var(--spacing-sm);
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    body {
        font-size: var(--font-size-sm);
    }
}

/* === STYLES SELECT NATIFS AMÉLIORÉS === */
select,
.form-select,
.setting-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 40px;
    cursor: pointer;
    position: relative;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2.293 4.293a1 1 0 011.414 0L6 6.586l2.293-2.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    min-height: 44px;
}

select:hover,
.form-select:hover,
.setting-select:hover {
    border-color: var(--primary-color);
}

/* Chevron via pseudo-element sur le parent ou utiliser CSS natif */
select::-ms-expand {
    display: none;
}

/* Select options styling (limited browser support but helps) */
select option {
    padding: 12px;
    background: var(--background-card);
    color: var(--text-primary);
}

/* Night mode / dark theme selects - inherit theme colors */
.night-mode select,
.night-mode .form-select,
.night-mode .setting-select,
[data-theme] select,
[data-theme] .form-select,
[data-theme] .setting-select {
    background-color: var(--background-card);
    color: var(--text-primary);
    border-color: var(--border-color);
    /* Light arrow for dark themes */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b4bec6' d='M2.293 4.293a1 1 0 011.414 0L6 6.586l2.293-2.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z'/%3E%3C/svg%3E");
}

.night-mode select:focus,
.night-mode .form-select:focus,
.night-mode .setting-select:focus,
[data-theme] select:focus,
[data-theme] .form-select:focus,
[data-theme] .setting-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.25);
}

/* === TAP TARGETS MINIMUM 44px === */
button,
.btn,
a.btn,
input[type="button"],
input[type="submit"],
input[type="reset"],
[role="button"] {
    min-height: 44px;
    min-width: 44px;
}

/* Small buttons exception with padding */
.btn-sm {
    min-height: 36px;
    padding: var(--spacing-sm) var(--spacing-md);
}

/* === PREVENT HORIZONTAL SCROLL === */
html,
body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* === PRINT STYLES === */
@media print {
    * {
        box-shadow: none !important;
        text-shadow: none !important;
    }

    a {
        text-decoration: underline;
    }

    img {
        page-break-inside: avoid;
        max-width: 100% !important;
    }

    h1,
    h2,
    h3 {
        page-break-after: avoid;
    }
}

/* Accessibility utility */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
