/* --- 1. CORE RESET & BASE --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
body, html { 
    width: 100%; height: 100%; 
    background: #000; color: #d4af37; 
    font-family: 'serif'; overflow: hidden; 
}

.viewport { position: relative; width: 100vw; height: 100vh; perspective: 1500px; }

/* --- 2. THE STONES & OGHAM --- */
.stone {
    position: absolute; top: 0; width: 50.5%; height: 100%;
    background: #1b262c url('slate.png') center/cover;
    z-index: 50; display: flex; align-items: center; justify-content: center;
    transition: transform 2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 0 100px #000;
}
.left-stone { left: 0; transform-origin: left; }
.right-stone { right: 0; transform-origin: right; }

.celtic-mark {
    writing-mode: vertical-rl; transform: rotate(180deg);
    font-size: clamp(2.5rem, 8vw, 5rem); opacity: 0.8;
}

/* DESKTOP ANIMATION */
.active-gate .left-stone { transform: rotateY(-105deg); }
.active-gate .right-stone { transform: rotateY(105deg); }

/* --- 3. UI & ABOUT LAYERS --- */
#ui-overlay {
    position: absolute; inset: 0; z-index: 100;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    transition: opacity 1s;
}
.main-title { font-size: clamp(2.2rem, 9vw, 4.8rem); letter-spacing: 15px; text-align: center; }

#gate-button {
    margin-top: 30px; padding: 15px 40px; background: transparent;
    border: 2px solid #d4af37; color: #d4af37; cursor: pointer; letter-spacing: 4px;
    z-index: 110;
}

#about-section {
    position: absolute; inset: 0; z-index: 10; opacity: 0;
    transition: opacity 2s; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.active-gate #about-section { opacity: 1; }

/* LANDSCAPE BACKGROUND (Default) */
.bg-image-full { 
    position: absolute; 
    inset: 0; 
    background: url('ng.jpg') center/cover no-repeat; 
    opacity: 0.28; 
}

/* --- PORTRAIT BACKGROUND FIX (For Handhelds) --- */
@media (orientation: portrait) {
    .bg-image-full {
        background-image: url('ngp.jpg');
    }
}

/* --- 4. THE DEW / FOG EFFECT --- */
.fog-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40vh; 
    overflow: hidden;
    z-index: 70; 
    pointer-events: none;
}

.fog-layer {
    position: absolute;
    bottom: -10%;
    left: -100%; 
    width: 300%; 
    height: 100%;
    background: radial-gradient(ellipse at center, 
        rgba(255, 255, 255, 0.4) 0%, 
        rgba(255, 255, 255, 0.1) 40%, 
        transparent 75%);
    filter: blur(50px);
    animation: drift 80s linear infinite, breathe 10s ease-in-out infinite alternate;
}

.layer-2 {
    bottom: -15%;
    left: -150%;
    opacity: 0.4;
    animation-duration: 110s, 14s;
    animation-delay: -10s;
}

@keyframes drift {
    from { transform: translateX(0); }
    to { transform: translateX(33%); }
}

@keyframes breathe {
    from { opacity: 0.15; transform: scale(1); }
    to { opacity: 0.45; transform: scale(1.1); }
}

/* --- 5. TARGETED DEVICE FIXES (STRICTLY PRESERVED) --- */
@media (max-width: 768px) {
    #ui-overlay { pointer-events: none; } 
    #gate-button { pointer-events: auto; background: rgba(0,0,0,0.1); }
    .left-stone { justify-content: flex-start; padding-left: 5%; }
    .right-stone { justify-content: flex-end; padding-right: 5%; }
    .celtic-mark { font-size: 2rem; opacity: 0.4; }
    .active-gate .left-stone { transform: translateX(-100%); }
    .active-gate .right-stone { transform: translateX(100%); }
    .main-title { letter-spacing: 6px; width: 90%; }
}

@media (min-width: 769px) and (max-width: 1100px) {
    .active-gate .left-stone { transform: translateX(-100%); }
    .active-gate .right-stone { transform: translateX(100%); }
    .left-stone { justify-content: flex-start; padding-left: 5%; }
    .right-stone { justify-content: flex-end; padding-right: 5%; }
    .celtic-mark { font-size: 2.2rem; opacity: 0.4; }
    .main-title { width: 85%; letter-spacing: 8px; }
}

@media (min-width: 1101px) and (max-width: 1300px) and (max-height: 850px) {
    .active-gate .left-stone { transform: translateX(-100%); }
    .active-gate .right-stone { transform: translateX(100%); }
    .left-stone { justify-content: flex-start; padding-left: 5%; }
    .right-stone { justify-content: flex-end; padding-right: 5%; }
    .celtic-mark { font-size: 2.2rem; opacity: 0.3; }
    .main-title { letter-spacing: 10px; }
}

/* --- PROFILE BOX (ISOLATED ADDITION - TABLET OPTIMIZED) --- */
.about-content {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 85;
    perspective: 1500px; /* Added to support 3D flip */
}

.about-card {
    position: relative;
    width: 90%;
    max-width: 650px; 
    height: 600px; /* Locked height for flip stability */
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

/* 3D Flip Trigger */
.card-flipped { transform: rotateY(180deg); }

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: clamp(1.5rem, 5vh, 3rem);
    border-radius: 15px;
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(212, 175, 55, 0.2);
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    overflow-y: auto;
    scrollbar-width: none; /* Hide scroller Firefox */
}

.card-face::-webkit-scrollbar { display: none; } /* Hide scroller Chrome/Safari */

.card-front {
    transform: rotateY(0deg) translateZ(1px); /* Pushes bio slightly forward */
}

.card-back {
    transform: rotateY(180deg) translateZ(1px); /* Pushes links slightly 'forward' relative to its own 180 flip */
}


.profile-photo {
    width: clamp(100px, 25vw, 180px);
    height: clamp(100px, 25vw, 180px);
    border-radius: 50%;
    border: 2px solid #d4af37;
    object-fit: cover;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

@media (min-width: 768px) and (max-width: 1024px) {
    .profile-photo { width: 200px; height: 200px; }
}

.description {
    color: #f0f0f0;
    line-height: 1.6;
    text-align: center;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    margin-top: 1rem;
}

/* --- LINKS GRID --- */
.links-grid { display: flex; flex-direction: column; gap: 12px; width: 100%; margin: auto 0; }
.tablet-link {
    display: block; width: 100%; padding: 14px; text-align: center;
    background: rgba(212, 175, 55, 0.08); border: 1px solid rgba(212, 175, 55, 0.4);
    color: #d4af37; text-decoration: none; letter-spacing: 2px;
    font-size: 0.9rem; border-radius: 8px; transition: 0.3s;
}
.tablet-link:hover { background: rgba(212, 175, 55, 0.2); }

.flip-btn {
    margin-top: 20px; background: none; border: none; color: #d4af37;
    cursor: pointer; letter-spacing: 2px; opacity: 0.6; padding: 10px;
}

/* --- S24 / S25 / iPhone 17 Final Alignment --- */
@media screen and (max-width: 600px) {
    /* Just push the stones further so they clear the screen */
    .active-gate .left-stone { 
        transform: translateX(-120%) !important; 
    }
    .active-gate .right-stone { 
        transform: translateX(120%) !important; 
    }

    /* Fix Firefox mirror ghosting without touching main layout */
    .card-flipped .card-front { 
        visibility: hidden !important; 
    }
}