:root {
    --color-royal-red: #4a0404;
    --color-royal-red-dark: #2a0202;
    --color-gold: #d4af37;
    --color-gold-dim: #997f2b;
    --color-ivory: #fcfaf5;
    --color-charcoal: #1a1a1a;
    --color-overlay: rgba(20, 5, 5, 0.85);

    --font-heading: 'Cinzel', serif;
    --font-body: 'Lato', sans-serif;

    --transition-slow: 0.8s ease-out;
    --transition-med: 0.4s ease;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-royal-red);
    color: var(--color-ivory);
    line-height: 1.6;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s;
}

a:hover {
    color: var(--color-gold);
}

h1,
h2,
h3,
.nav-logo,
.footer-logo {
    font-family: var(--font-heading);
    color: var(--color-gold);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.narrow-container {
    max-width: 800px;
}

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.section {
    padding: 6rem 0;
}

.sacred-divider {
    height: 1px;
    width: 60px;
    background-color: var(--color-gold);
    margin: 1.5rem 0;
}

.center-divider {
    margin: 1.5rem auto;
}

.btn-royal {
    background: transparent;
    border: 1px solid var(--color-gold);
    color: var(--color-gold);
    padding: 1rem 2rem;
    font-family: var(--font-heading);
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.btn-royal:hover {
    background: var(--color-gold);
    color: var(--color-royal-red);
}

/* Loader */
.loader-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: var(--color-royal-red);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 1.5s ease-out;
    /* Slow elegant fade out */
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    width: 300px;
    /* Constrain width */
}

.loader-svg-custom {
    width: 100%;
    height: auto;
    max-width: 300px;
    /* Basic start state */
    overflow: visible;
}

/* Helper Class */
.opacity-0 {
    opacity: 0;
}

/* -----------------------------------------------------------
   CONSTRUCTION SEQUENCE (Total ~3.8s)
   ----------------------------------------------------------- */

/* 1. Base Construction (0s - 0.8s) */
#tool-scale {
    animation: seq-scale 0.8s linear forwards;
    transform-origin: center;
}

#temple-base {
    animation: seq-base-appear 0.8s linear forwards;
}

/* 2. Tier 1 Carving (0.8s - 1.6s) */
#tool-chisel {
    animation: seq-chisel 0.8s linear 0.8s forwards;
}

#temple-tier1 {
    animation: seq-tier1-appear 0.8s linear 0.8s forwards;
}

/* 3. Tier 2 Alignment (1.6s - 2.4s) */
#tool-plumb {
    animation: seq-plumb 0.8s ease-out 1.6s forwards;
}

#temple-tier2 {
    animation: seq-tier2-appear 0.8s linear 1.6s forwards;
}

/* 4. Kalasam & Final Touch (2.4s - 3.2s) */
#tool-compass {
    animation: seq-compass 0.8s ease-in-out 2.4s forwards;
}

#temple-kalasam {
    animation: seq-kalasam-appear 0.8s linear 2.4s forwards;
}

/* 5. Final Glow Pulse (3.2s onwards) */
#temple-structure {
    animation: seq-final-shine 0.6s ease-in-out 3.2s 1 forwards;
    /* 300ms rise, 300ms fall implied */
}

/* -----------------------------------------------------------
   KEYFRAMES
   ----------------------------------------------------------- */

/* SCALE: Slides across to 'draw' the base */
@keyframes seq-scale {
    0% {
        opacity: 0;
        transform: translateX(-20px);
    }

    10% {
        opacity: 1;
        transform: translateX(-20px);
    }

    80% {
        opacity: 1;
        transform: translateX(20px);
    }

    100% {
        opacity: 0;
        transform: translateX(20px);
    }
}

@keyframes seq-base-appear {
    0% {
        opacity: 0;
        clip-path: inset(0 100% 0 0);
    }

    10% {
        opacity: 1;
        clip-path: inset(0 100% 0 0);
    }

    /* Wait for scale start */
    90% {
        opacity: 1;
        clip-path: inset(0 0 0 0);
    }

    100% {
        opacity: 1;
        clip-path: inset(0 0 0 0);
    }
}

/* CHISEL: Taps to reveal details */
@keyframes seq-chisel {
    0% {
        opacity: 0;
        transform: translate(10px, -10px);
    }

    10% {
        opacity: 1;
        transform: translate(0, 0);
    }

    25% {
        transform: translate(-2px, 2px);
    }

    /* Tap 1 */
    40% {
        transform: translate(0, 0);
    }

    55% {
        transform: translate(-2px, 2px);
    }

    /* Tap 2 */
    70% {
        transform: translate(0, 0);
    }

    90% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translate(0, 0);
    }
}

@keyframes seq-tier1-appear {
    0% {
        opacity: 0;
        clip-path: inset(100% 0 0 0);
    }

    100% {
        opacity: 1;
        clip-path: inset(0 0 0 0);
    }
}

/* PLUMB LINE: Drops down to align */
@keyframes seq-plumb {
    0% {
        opacity: 0;
        transform: translateY(-30px);
    }

    20% {
        opacity: 1;
        transform: translateY(0);
    }

    60% {
        transform: translateY(0);
    }

    /* Hold steady */
    100% {
        opacity: 0;
        transform: translateY(0);
    }
}

@keyframes seq-tier2-appear {
    0% {
        opacity: 0;
        transform: scaleY(0.8);
        transform-origin: bottom center;
    }

    100% {
        opacity: 1;
        transform: scaleY(1);
        transform-origin: bottom center;
    }
}

/* COMPASS: Rotates to define top arch */
@keyframes seq-compass {
    0% {
        opacity: 0;
        transform: rotate(-15deg);
        transform-origin: 0 -15px;
    }

    20% {
        opacity: 1;
    }

    70% {
        transform: rotate(15deg);
        transform-origin: 0 -15px;
    }

    100% {
        opacity: 0;
        transform: rotate(15deg);
        transform-origin: 0 -15px;
    }
}

@keyframes seq-kalasam-appear {
    0% {
        opacity: 0;
        transform: scale(0.5);
        transform-origin: center bottom;
    }

    100% {
        opacity: 1;
        transform: scale(1);
        transform-origin: center bottom;
    }
}

/* FINAL SHINE: Subtle glow check */
@keyframes seq-final-shine {

    0%,
    100% {
        filter: none;
    }

    50% {
        filter: url(#royal-glow);
    }
}

.loader-text {
    margin-top: 20px;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    letter-spacing: 0.2em;
    color: var(--color-gold-dim);
}

/* Nav */
.main-nav {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 1.5rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    background: linear-gradient(to bottom, rgba(74, 4, 4, 0.9), transparent);
    transition: background 0.3s;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 2rem;
}

.nav-links li a {
    font-size: 0.9rem;
    letter-spacing: 0.15em;
    font-family: var(--font-heading);
}

.nav-logo {
    display: none;
    /* Hidden on desktop, layout choice */
}

/* Hero */
.hero-section {
    height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Optically centered, tweaked in JS/CSS if needed */
    align-items: center;
    text-align: center;
    padding-bottom: 5vh;
    /* Slight optical lift */
}

.hero-bg-texture {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Noise texture overlay */
    background:
        linear-gradient(to bottom, rgba(74, 4, 4, 0.8), rgba(42, 2, 2, 0.9)),
        url('../assets/noise.svg');
    background-size: cover, 200px 200px;
    z-index: -1;
}

.hero-logo-img {
    width: 200px;
    height: auto;
    display: block;
    margin: 12px auto 1.5rem auto;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    object-fit: contain;
}

.hero-title {
    font-size: 4rem;
    margin: 1rem 0 0.5rem;
    font-weight: 400;
}

.hero-tagline {
    font-size: 1.2rem;
    letter-spacing: 0.3em;
    color: var(--color-ivory);
    opacity: 0.8;
}

/* About Section */
.split-layout {
    display: flex;
    align-items: center;
    gap: 4rem;
}

.about-text {
    flex: 1;
}

.about-image {
    flex: 1;
}

.founder-portrait-frame {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--color-gold-dim);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    aspect-ratio: 4 / 5;
}

.founder-portrait-frame::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 60px rgba(42, 2, 2, 0.7);
    /* Blends with maroon background */
    pointer-events: none;
    z-index: 2;
}

.founder-portrait-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    /* Face always centered and visible at the top */
    display: block;
    filter: sepia(0.3) contrast(1.1) brightness(0.85);
    /* Subtle warm tone, not too bright */
    transition: transform 1s ease-out;
}

.founder-portrait-frame:hover .founder-portrait-img {
    transform: scale(1.03);
}

/* Philosophy */
.philosophy-section {
    background-color: var(--color-royal-red-dark);
}

.philosophy-text {
    font-size: 1.25rem;
    font-weight: 300;
    font-style: italic;
    color: var(--color-gold-dim);
}

/* Services */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 3rem;
    margin-top: 3rem;
}

.service-card {
    text-align: center;
    padding: 2rem;
    border: 1px solid transparent;
    transition: var(--transition-med);
}

.service-card:hover {
    border-color: var(--color-gold-dim);
    background: rgba(0, 0, 0, 0.1);
}

.service-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1.5rem;
    color: var(--color-gold);
}

.service-card h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.service-card p {
    font-size: 0.9rem;
    color: rgba(252, 250, 245, 0.8);
}

/* Portfolio */
.portfolio-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem;
    margin-bottom: 6rem;
}

.portfolio-item {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 5;
    background-color: var(--color-royal-red-dark);
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid rgba(212, 175, 55, 0.2);
    box-shadow: 0 10px 30px rgba(212, 175, 55, 0.08);
}

.portfolio-image-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.portfolio-item:hover .portfolio-image-img {
    transform: scale(1.05);
}

.portfolio-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70%;
    background: linear-gradient(to top, rgba(20, 5, 5, 0.95) 0%, rgba(212, 175, 55, 0.25) 60%, transparent 100%);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.portfolio-item:hover .portfolio-overlay {
    opacity: 1;
}

.portfolio-overlay .temple-name {
    font-family: var(--font-heading);
    color: var(--color-gold);
    font-weight: 800;
    font-size: 1.25rem;
    line-height: 1.3;
    margin-bottom: 0.25rem;
    transform: translateY(20px);
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.portfolio-overlay .temple-location {
    font-family: var(--font-body);
    color: var(--color-ivory);
    opacity: 0.75;
    font-size: 0.95rem;
    transform: translateY(20px);
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s;
}

.portfolio-item:hover .portfolio-overlay .temple-name,
.portfolio-item:hover .portfolio-overlay .temple-location {
    transform: translateY(0);
}



/* Contact */
.contact-form {
    background: rgba(0, 0, 0, 0.2);
    padding: 3rem;
    margin-top: 2rem;
    border: 1px solid var(--color-gold-dim);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--color-gold);
}

.form-group input,
.form-group textarea {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--color-gold-dim);
    color: var(--color-ivory);
    padding: 0.5rem 0;
    font-family: var(--font-body);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-bottom-color: var(--color-gold);
}

.contact-details {
    margin-top: 3rem;
    color: var(--color-gold-dim);
}

/* Footer */
.main-footer {
    padding: 3rem 0;
    border-top: 1px solid var(--color-gold-dim);
    text-align: center;
    margin-top: 4rem;
}

.footer-quote {
    font-style: italic;
    opacity: 0.7;
    margin: 1rem 0;
}

.footer-links a {
    margin: 0 0.5rem;
    font-size: 0.9rem;
}

.copyright {
    margin-top: 2rem;
    font-size: 0.75rem;
    opacity: 0.5;
}

/* Animations */
.fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1s ease-out, transform 1s ease-out;
}

.visible {
    opacity: 1;
    transform: translateY(0);
}

.delay-100 {
    transition-delay: 0.1s;
}

.delay-200 {
    transition-delay: 0.2s;
}

.delay-300 {
    transition-delay: 0.3s;
}

/* Responsive */
@media (max-width: 1024px) {
    .portfolio-gallery {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .split-layout {
        flex-direction: column-reverse;
        gap: 3rem;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .nav-links {
        display: none;
        /* In full version this would be a hamburger menu */
    }

    .portfolio-gallery {
        grid-template-columns: 1fr;
    }
}