/* =====================================================
   Module : Chemise à onglets — LudoCom
   Three.js + CSS3DRenderer
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;600;700&family=Playfair+Display:ital,wght@0,400;0,700;1,400&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Plein écran ── */
html {
    height: 100%;
    height: 100dvh;
}
body {
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background: #000000;
    font-family: 'Caveat', cursive;
}

/* Image de fond : img + object-fit:cover, le plus fiable cross-browser */
#bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    overflow: hidden;
}
#bg img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
}

/* ── Conteneur scène ── */
#scene-container {
    position: fixed;
    inset: 0;
    z-index: 1;
}

/* Canvas WebGL (derrière) */
#scene-3d {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 1;
    background: transparent !important;
}

/* Div CSS3DRenderer (par-dessus le canvas) */
#scene-css {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}

/* ── Pages DOM (CSS3DObject) ── */
#pages-pool {
    display: none; /* Masqué avant montage par Three.js */
}

.page-dom {
    /* Taille injectée par JS */
    position: relative;
    background: transparent;
}

.page-inner {
    position: absolute;
    inset: 0;
    padding: 44px 38px 44px 52px;
    overflow: hidden;
}

/* Texture papier vieilli + lignes + plis */
.page-texture {
    position: absolute;
    inset: 0;
    z-index: 0;
    filter: url(#paper-warp);
    background-color: #f5e9d0;
    background-image:
        /* Plis diagonaux */
        linear-gradient(127deg,
            transparent 40%,
            rgba(0,0,0,0.038) 41.5%, rgba(255,255,255,0.08) 43%,
            transparent 44.5%
        ),
        linear-gradient(178deg,
            transparent 54%,
            rgba(0,0,0,0.025) 55.5%, rgba(255,255,255,0.055) 57%,
            transparent 58.5%
        ),
        linear-gradient(52deg,
            transparent 25%,
            rgba(0,0,0,0.020) 26.5%, rgba(255,255,255,0.038) 28%,
            transparent 29.5%
        ),
        /* Bosses de surface */
        radial-gradient(ellipse at 22% 38%, rgba(255,255,255,0.07) 0%, transparent 30%),
        radial-gradient(ellipse at 75% 72%, rgba(0,0,0,0.04)       0%, transparent 26%),
        /* Marge rouge */
        linear-gradient(90deg,
            transparent 54px,
            rgba(185,60,60,0.20) 54px, rgba(185,60,60,0.20) 55px,
            transparent 55px
        ),
        /* Lignes réglées */
        repeating-linear-gradient(180deg,
            transparent 0px, transparent 31px,
            rgba(160,115,60,0.12) 31px, rgba(160,115,60,0.12) 32px
        ),
        /* Base parchemin */
        linear-gradient(165deg, #fdf6e8 0%, #f5e8cc 45%, #eeddbf 80%, #e8d4b0 100%);
}

/* Brunissement des coins */
.page-inner::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 0%   0%,   rgba(100,60,10,0.10) 0%, transparent 28%),
        radial-gradient(ellipse at 100% 100%, rgba(100,60,10,0.10) 0%, transparent 28%),
        radial-gradient(ellipse at 0%   100%, rgba(100,60,10,0.07) 0%, transparent 22%),
        radial-gradient(ellipse at 100% 0%,   rgba(100,60,10,0.06) 0%, transparent 18%);
}

.contenu-titre {
    font-family: 'Caveat', cursive;
    font-size: 1.85rem;
    font-weight: 700;
    color: #1e0e04;
    margin-bottom: 10px;
    line-height: 1.25;
    position: relative;
    z-index: 1;
}

.contenu-body {
    font-size: 1.2rem;
    color: #160a00;
    line-height: 2.0;
    position: relative;
    z-index: 1;
}

.page-num {
    position: absolute;
    bottom: 18px;
    right: 34px;
    font-family: 'Playfair Display', serif;
    font-size: 0.9rem;
    font-style: italic;
    color: #9a7050;
    z-index: 1;
}

/* ── Onglets HTML (superposés, position absolue) ── */
#chemise-tabs {
    position: fixed;
    z-index: 10;
    display: flex;
    flex-direction: column;
    width: 50px;
    pointer-events: all;
    font-size: 0;      /* annule les anonymous flex items issus des espaces Twig */
    line-height: 0;
}

.onglet-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-lr;
    text-decoration: none;
    font-family: 'Caveat', cursive;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #4a3015;
    cursor: pointer;
    padding: 10px 6px;
    position: relative;
    white-space: nowrap;
    border-radius: 6px 0 0 6px;  /* après rotate(180deg) → arrondis à droite (côté extérieur) */
    border-left: 1px solid rgba(140,95,40,0.3);
    background: linear-gradient(270deg, #d8c99a 0%, #e5d5aa 40%, #deccaa 100%);
    transform: rotate(180deg);
    transition: background 0.15s, box-shadow 0.15s, filter 0.15s;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.32);
}

.onglet-tab:not(.actif):hover {
    background: linear-gradient(270deg, #e2d4aa 0%, #eedec0 100%);
    color: #1a0e04;
    box-shadow: 3px 3px 10px rgba(0,0,0,0.42);
    filter: brightness(1.08);
}

.onglet-tab.actif {
    background: linear-gradient(270deg, #e6d7b6 0%, #f2e6ce 60%, #f5e9d0 100%);
    color: #0e0600;
    font-weight: 700;
    border-left: none;
    box-shadow: none;
}

/* Trait d'encre sur l'onglet actif */
.onglet-tab.actif::before {
    content: '';
    position: absolute;
    top: 12px;
    width: 2px;
    height: 20px;
    background: rgba(100,60,15,0.35);
    border-radius: 1px;
}

/* ── Filtre SVG papier froissé (invisible) ── */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ── Bouton gyroscope iOS ── */
#gyro-btn {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    padding: 12px 24px;
    background: rgba(200, 168, 96, 0.92);
    color: #1a0800;
    font-family: 'Caveat', cursive;
    font-size: 1.1rem;
    font-weight: 700;
    border: none;
    border-radius: 24px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.5);
    cursor: pointer;
    backdrop-filter: blur(6px);
    white-space: nowrap;
}

/* ══════════════════════════════════════════
   Responsive mobile
══════════════════════════════════════════ */

/* Tablette / petit laptop */
@media (max-width: 768px) {
    #chemise-tabs {
        width: 42px;
    }
    .onglet-tab {
        font-size: 0.88rem;
        padding: 8px 5px;
        min-height: 44px; /* tap target iOS */
    }
    .contenu-titre { font-size: 1.5rem; }
    .contenu-body  { font-size: 1.05rem; line-height: 1.9; }
}

/* Smartphone portrait */
@media (max-width: 480px) {
    #chemise-tabs {
        width: 36px;
    }
    .onglet-tab {
        font-size: 0.78rem;
        padding: 6px 4px;
        letter-spacing: 0.02em;
    }
    .contenu-titre { font-size: 1.25rem; }
    .contenu-body  { font-size: 0.95rem; line-height: 1.8; }
    .page-inner    { padding: 32px 24px 32px 36px; }
}
