/* ═══════════════════════════════════════════════════════════
   El Couzina — Awwwards Layer × Raïs Hamidou
   Intro, custom cursor, particles, chapters, drop caps, compass,
   magnetic, hand-drawn underlines, mouse parallax
   ═══════════════════════════════════════════════════════════ */

/* ─── Intro Screen (first-visit) ─────────────────────── */
.intro-screen {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 40%, #163554 0%, #0A1F35 60%, #061425 100%);
    color: #FFF;
    overflow: hidden;
    transition: opacity 0.7s ease, transform 0.7s ease;
    will-change: opacity, transform;
}

.intro-screen.is-leaving {
    opacity: 0;
    transform: scale(1.04);
    pointer-events: none;
}

.intro-screen[hidden] { display: none !important; }

/* Star field */
.intro-stars {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(1px 1px at 12% 20%, rgba(244, 201, 93, 0.85), transparent 60%),
        radial-gradient(1px 1px at 82% 30%, rgba(244, 201, 93, 0.7), transparent 60%),
        radial-gradient(1.5px 1.5px at 22% 60%, rgba(244, 201, 93, 0.85), transparent 60%),
        radial-gradient(1px 1px at 70% 75%, rgba(244, 201, 93, 0.6), transparent 60%),
        radial-gradient(1.5px 1.5px at 35% 88%, rgba(244, 201, 93, 0.7), transparent 60%),
        radial-gradient(1px 1px at 88% 64%, rgba(244, 201, 93, 0.55), transparent 60%),
        radial-gradient(1px 1px at 50% 14%, rgba(244, 201, 93, 0.7), transparent 60%),
        radial-gradient(1px 1px at 60% 50%, rgba(244, 201, 93, 0.5), transparent 60%),
        radial-gradient(1.5px 1.5px at 8% 75%, rgba(244, 201, 93, 0.7), transparent 60%),
        radial-gradient(1px 1px at 92% 12%, rgba(244, 201, 93, 0.6), transparent 60%);
    animation: twinkle 4s ease-in-out infinite;
    opacity: 0.85;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 0.4; }
}

/* Crescent moon decoration in intro */
.intro-crescent {
    position: absolute;
    top: 12%;
    right: 15%;
    width: 80px;
    height: 80px;
    color: rgba(244, 201, 93, 0.55);
    animation: introCrescentRise 1.4s var(--ease-out-expo) 0.2s both;
    will-change: transform, opacity;
}

@keyframes introCrescentRise {
    from { opacity: 0; transform: translateY(40px) rotate(-15deg); }
    to { opacity: 1; transform: translateY(0) rotate(0); }
}

/* Dhow boat sailing across */
.intro-dhow {
    position: absolute;
    bottom: 22%;
    left: -30%;
    width: 280px;
    color: rgba(212, 163, 55, 0.85);
    animation: dhowSail 4.5s cubic-bezier(0.65, 0, 0.35, 1) 0.6s both;
    will-change: transform;
}

@keyframes dhowSail {
    0% { left: -30%; transform: rotate(-2deg); }
    50% { transform: rotate(1.5deg); }
    100% { left: 130%; transform: rotate(-1deg); }
}

/* Wave silhouette at bottom */
.intro-waves {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 18%;
    color: rgba(27, 73, 101, 0.7);
    pointer-events: none;
}

.intro-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: var(--space-8);
    max-width: 760px;
}

.intro-eyebrow {
    font-family: var(--font-accent);
    font-size: clamp(20px, 3vw, 28px);
    color: rgba(244, 201, 93, 0.8);
    margin-bottom: var(--space-3);
    opacity: 0;
    animation: introFadeUp 0.9s var(--ease-out-expo) 0.4s forwards;
}

.intro-title {
    font-family: var(--font-display);
    font-size: clamp(48px, 9vw, 110px);
    font-weight: 600;
    line-height: 0.95;
    margin: 0 0 var(--space-4);
    color: #FFF;
    letter-spacing: var(--tracking-tight);
}

.intro-title .kin-char {
    display: inline-block;
    opacity: 0;
    transform: translateY(80px) rotate(8deg);
    animation: introCharIn 1s var(--ease-out-expo) forwards;
    animation-delay: calc(var(--i, 0) * 36ms + 700ms);
}

@keyframes introCharIn {
    to { opacity: 1; transform: translateY(0) rotate(0); }
}

.intro-sub {
    font-family: var(--font-body);
    font-size: clamp(13px, 1.5vw, 16px);
    text-transform: uppercase;
    letter-spacing: 0.3em;
    color: rgba(244, 201, 93, 0.7);
    opacity: 0;
    animation: introFadeUp 1s var(--ease-out-expo) 1.7s forwards;
}

@keyframes introFadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.intro-skip {
    position: absolute;
    top: var(--space-6);
    right: var(--space-6);
    padding: var(--space-2) var(--space-4);
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    -webkit-tap-highlight-color: transparent;
    z-index: 3;
}

.intro-skip:hover,
.intro-skip:focus-visible {
    color: #FFF;
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.08);
    outline: none;
}

.intro-progress {
    position: absolute;
    bottom: var(--space-8);
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    max-width: 70%;
    height: 2px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    overflow: hidden;
}

.intro-progress::after {
    content: '';
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--secondary), var(--accent));
    animation: introProgressFill 3s linear forwards;
}

@keyframes introProgressFill {
    to { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .intro-stars,
    .intro-crescent,
    .intro-dhow,
    .intro-eyebrow,
    .intro-sub,
    .intro-progress::after,
    .intro-title .kin-char {
        animation: none;
    }
    .intro-eyebrow,
    .intro-sub { opacity: 1; transform: none; }
    .intro-title .kin-char { opacity: 1; transform: none; }
}

/* ─── Custom cursor (desktop only) ───────────────────── */
.cursor-ring,
.cursor-dot { display: none; }

@media (pointer: fine) and (min-width: 1024px) and (prefers-reduced-motion: no-preference) {
    html.has-custom-cursor,
    html.has-custom-cursor body {
        cursor: none;
    }

    html.has-custom-cursor a,
    html.has-custom-cursor button,
    html.has-custom-cursor input,
    html.has-custom-cursor textarea,
    html.has-custom-cursor select,
    html.has-custom-cursor [role="button"],
    html.has-custom-cursor [tabindex] {
        cursor: none;
    }

    html.has-custom-cursor .cursor-ring,
    html.has-custom-cursor .cursor-dot {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        pointer-events: none;
        z-index: 99000;
        will-change: transform;
        mix-blend-mode: difference;
    }

    .cursor-ring {
        width: 36px;
        height: 36px;
        border: 1.5px solid rgba(244, 201, 93, 0.85);
        border-radius: 50%;
        margin: -18px 0 0 -18px;
        transition: width 0.25s var(--ease-out), height 0.25s var(--ease-out), margin 0.25s var(--ease-out), border-color 0.25s var(--ease-out), background 0.25s var(--ease-out);
    }

    .cursor-ring.is-hovering {
        width: 70px;
        height: 70px;
        margin: -35px 0 0 -35px;
        border-color: rgba(244, 201, 93, 0.95);
        background: rgba(244, 201, 93, 0.12);
    }

    .cursor-ring.is-clicking {
        width: 24px;
        height: 24px;
        margin: -12px 0 0 -12px;
    }

    .cursor-dot {
        width: 6px;
        height: 6px;
        background: var(--accent);
        border-radius: 50%;
        margin: -3px 0 0 -3px;
        transition: opacity 0.2s ease;
    }

    .cursor-ring.is-hovering ~ .cursor-dot,
    .cursor-dot.is-hovering { opacity: 0; }
}

/* ─── Compass scroll progress (replaces simple bar) ──── */
.compass-progress {
    position: fixed;
    top: calc(var(--header-height) + var(--space-3));
    right: var(--space-4);
    width: 56px;
    height: 56px;
    z-index: var(--z-progress);
    pointer-events: auto;
    cursor: pointer;
    background: var(--glass-bg);
    backdrop-filter: blur(12px) saturate(1.5);
    -webkit-backdrop-filter: blur(12px) saturate(1.5);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    box-shadow: var(--shadow);
    display: grid;
    place-items: center;
    transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.compass-progress:hover {
    transform: scale(1.06);
}

.compass-progress svg {
    width: 80%;
    height: 80%;
    color: var(--primary);
}

.compass-progress .compass-needle {
    transform-origin: 32px 32px;
    transition: transform 0.18s linear;
    transform: rotate(0deg);
    color: var(--wax-red, #8b0f1a);
}

@supports (animation-timeline: scroll()) {
    .compass-progress .compass-needle {
        transition: none;
        animation: needleSpin linear both;
        animation-timeline: scroll();
    }
    @keyframes needleSpin {
        from { transform: rotate(0deg); }
        to { transform: rotate(720deg); }
    }
}

@media (max-width: 767px) {
    .compass-progress {
        top: auto;
        right: calc(var(--mobile-gutter) + var(--safe-right));
        bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--space-4) + var(--fab-size) + var(--space-3) + 56px + var(--space-3));
        width: 44px;
        height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .compass-progress .compass-needle { animation: none; transition: none; }
}

/* Hide old simple progress bar if it exists alongside */
.scroll-progress { display: none; }

/* ─── Hero parallax layers ───────────────────────────── */
.hero-parallax {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.parallax-layer {
    position: absolute;
    inset: 0;
    will-change: transform;
}

/* Animated star field over hero */
.hero-stars {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(1.5px 1.5px at 8% 22%, rgba(244, 201, 93, 0.7), transparent 60%),
        radial-gradient(1px 1px at 28% 12%, rgba(244, 201, 93, 0.55), transparent 60%),
        radial-gradient(1px 1px at 48% 30%, rgba(255, 255, 255, 0.5), transparent 60%),
        radial-gradient(1.5px 1.5px at 68% 18%, rgba(244, 201, 93, 0.6), transparent 60%),
        radial-gradient(1px 1px at 88% 42%, rgba(255, 255, 255, 0.5), transparent 60%),
        radial-gradient(1.5px 1.5px at 18% 70%, rgba(244, 201, 93, 0.55), transparent 60%),
        radial-gradient(1px 1px at 78% 80%, rgba(244, 201, 93, 0.65), transparent 60%),
        radial-gradient(1px 1px at 38% 90%, rgba(255, 255, 255, 0.45), transparent 60%),
        radial-gradient(1.5px 1.5px at 58% 60%, rgba(244, 201, 93, 0.5), transparent 60%),
        radial-gradient(1px 1px at 92% 8%, rgba(255, 255, 255, 0.45), transparent 60%);
    animation: starsTwinkle 6s ease-in-out infinite alternate;
    opacity: 0.7;
}

@keyframes starsTwinkle {
    from { opacity: 0.7; }
    to { opacity: 0.35; }
}

/* Floating dhow on hero */
.hero-dhow {
    position: absolute;
    left: 8%;
    bottom: 18%;
    width: clamp(160px, 20vw, 260px);
    color: rgba(212, 163, 55, 0.55);
    pointer-events: none;
    z-index: 2;
    animation: dhowFloat 6s ease-in-out infinite alternate;
    will-change: transform;
}

@keyframes dhowFloat {
    from { transform: translateY(0) rotate(-1.5deg); }
    to { transform: translateY(-12px) rotate(1.5deg); }
}

@media (max-width: 767px) {
    .hero-dhow { left: 4%; bottom: 8%; opacity: 0.6; }
}

@media (prefers-reduced-motion: reduce) {
    .hero-stars,
    .hero-dhow { animation: none; }
}

/* ─── Chapters ───────────────────────────────────────── */
.chapter {
    position: relative;
}

.chapter-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin: 0 auto var(--space-12);
    padding-top: var(--space-12);
    max-width: 720px;
    color: var(--text);
}

.chapter-number {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(3.5rem, 8vw, 6rem);
    line-height: 0.85;
    color: var(--secondary);
    letter-spacing: 0.05em;
    background: linear-gradient(135deg, var(--secondary), var(--accent), var(--brass, #B88945));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: var(--space-2);
}

.chapter-eyebrow {
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4em;
    color: var(--text-muted);
    margin-bottom: var(--space-3);
}

.chapter-name {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3.5vw, 2.4rem);
    font-weight: 600;
    line-height: 1.1;
    color: var(--text);
    margin: 0;
}

.chapter-name em {
    font-style: italic;
    color: var(--primary);
    font-weight: 500;
}

.chapter-ornament {
    margin-top: var(--space-5);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    color: var(--secondary);
    opacity: 0.7;
}

.chapter-ornament::before,
.chapter-ornament::after {
    content: '';
    width: 60px;
    height: 1px;
    background: linear-gradient(90deg, transparent, currentColor, transparent);
}

.chapter-ornament svg {
    width: 28px;
    height: 28px;
}

/* ─── Drop caps (manuscript) ─────────────────────────── */
.manuscript p:first-of-type::first-letter,
.drop-cap::first-letter {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 4.4em;
    line-height: 0.85;
    float: left;
    margin: 0.05em 0.12em 0 0;
    color: var(--primary);
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    padding: 4px 8px 0 0;
    border-right: 2px solid var(--secondary);
    margin-right: 12px;
}

@media (max-width: 600px) {
    .manuscript p:first-of-type::first-letter,
    .drop-cap::first-letter {
        font-size: 3.5em;
    }
}

/* ─── Hand-drawn underline (animated) ────────────────── */
.hand-link {
    position: relative;
    display: inline-block;
    text-decoration: none;
    color: var(--primary);
    padding-bottom: 4px;
}

.hand-link::after {
    content: '';
    position: absolute;
    left: 0;
    right: 100%;
    bottom: 0;
    height: 6px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 8' preserveAspectRatio='none'><path d='M2 5 Q 50 1 100 4 T 198 4' stroke='%23D4A337' stroke-width='2' fill='none' stroke-linecap='round'/></svg>");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    transition: right 0.5s var(--ease-out-expo);
}

.hand-link:hover::after,
.hand-link:focus-visible::after {
    right: 0;
}

/* ─── Heritage / Raïs Hamidou tribute ─────────────────── */
.heritage {
    position: relative;
    padding: var(--space-20) 0;
    background:
        linear-gradient(180deg, transparent 0%, rgba(245, 232, 200, 0.4) 50%, transparent 100%),
        radial-gradient(ellipse at top, rgba(212, 163, 55, 0.12), transparent 60%);
    overflow: hidden;
}

.heritage::before,
.heritage::after {
    content: '';
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(244, 201, 93, 0.18), transparent 70%);
    pointer-events: none;
}

.heritage::before { top: 10%; left: -8%; }
.heritage::after { bottom: 10%; right: -8%; }

.heritage-quote {
    font-family: var(--font-display);
    font-style: italic;
    font-size: clamp(1.4rem, 3vw, 2rem);
    line-height: 1.4;
    color: var(--primary);
    text-align: center;
    max-width: 720px;
    margin: 0 auto var(--space-10);
    position: relative;
    padding: 0 var(--space-8);
}

.heritage-quote::before,
.heritage-quote::after {
    content: '"';
    position: absolute;
    font-family: var(--font-display);
    font-size: 5em;
    line-height: 0.5;
    color: var(--secondary);
    opacity: 0.35;
}

.heritage-quote::before { left: 0; top: -10px; }
.heritage-quote::after { right: 0; bottom: -40px; }

.heritage-quote-source {
    display: block;
    font-family: var(--font-body);
    font-style: normal;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--text-muted);
    margin-top: var(--space-4);
}

.heritage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-6);
    max-width: var(--container-md);
    margin: 0 auto;
    padding: 0 var(--space-6);
    position: relative;
    z-index: 2;
}

.heritage-card {
    padding: var(--space-6) var(--space-5);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-align: center;
    transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.heritage-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.heritage-card-year {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 600;
    color: var(--secondary);
    line-height: 1;
    margin-bottom: var(--space-2);
}

.heritage-card-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--space-2);
}

.heritage-card-text {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Heritage signature ornament */
.heritage-signature {
    text-align: center;
    margin-top: var(--space-12);
    font-family: var(--font-accent);
    font-size: clamp(28px, 4vw, 42px);
    color: var(--secondary);
    transform: rotate(-3deg);
    opacity: 0.85;
}

/* ─── Tifinagh decorative symbols (background accent) ─ */
.tifinagh-deco {
    position: absolute;
    font-family: serif;
    font-size: clamp(80px, 12vw, 200px);
    color: var(--primary);
    opacity: 0.04;
    pointer-events: none;
    user-select: none;
    line-height: 1;
    font-weight: 700;
}

.tifinagh-deco--top-right { top: 5%; right: -5%; transform: rotate(15deg); }
.tifinagh-deco--bot-left { bottom: 8%; left: -3%; transform: rotate(-10deg); }

/* ─── Variable font weight on H2 reveal ──────────────── */
.h2-reveal {
    transition: font-weight 1s var(--ease-out-expo);
    font-weight: 400;
}

.h2-reveal.visible {
    font-weight: 600;
}

/* ─── Image distortion hover (desktop) ───────────────── */
@media (hover: hover) and (pointer: fine) {
    .menu-item:hover .menu-item-image {
        filter: brightness(1.06) saturate(1.1);
    }

    .menu-item:hover .menu-item-image img {
        transform: scale(1.08) skewY(-0.5deg);
        transition: transform 0.55s var(--ease-out-expo), filter 0.55s var(--ease-out-expo);
    }
}

/* ─── Hero meta enhancement ──────────────────────────── */
.hero-content {
    position: relative;
    z-index: 4;
}

/* ─── Reduce motion safety net ───────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .parallax-layer { transform: none !important; }
    .h2-reveal { transition: none; }
    .heritage-card { transition: none; }
}

/* ─── Print : hide decorative elements ───────────────── */
@media print {
    .intro-screen,
    .cursor-ring,
    .cursor-dot,
    .compass-progress,
    .hero-parallax,
    .hero-dhow,
    .tifinagh-deco { display: none !important; }
}
