/* --- CSS Variables for Consistency --- */
:root {
    --primary-red: #cc0000; /* Ibinalik sa pula para sa consistency */
    --dark-gray: #333;
    --light-gray: #f4f4f4;
    --text-gray: #555;
    --text-color-light: #fff; 
    --font-family: 'Poppins', sans-serif; /* Changed font to Poppins */
    --max-width: 1200px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scroll-behavior: smooth; /* Adds smooth scrolling for anchor links */
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--dark-gray);
    background-color: var(--light-gray);
}

/* --- Services Hero Section --- */
.services-hero {
    position: relative; 
    padding: 150px 20px 40px 20px; /* Reduced bottom padding for better flow */
    text-align: center;
    color: #ffffff; 
    background-image: url('https://images.pexels.com/photos/3735747/pexels-photo-3735747.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1');
    background-size: cover; 
    background-position: center; 
    background-attachment: scroll; /* Changed from fixed to prevent covering other pages */
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(44, 62, 80, 0.7); /* Dark blue overlay */
    z-index: 1; 
}

.hero-text-container {
    position: relative; 
    z-index: 2; /* Para siguradong nasa ibabaw ng overlay */
    max-width: 800px; 
    margin: auto; 
}

.services-hero h2 {
    font-size: 3.5em; 
    font-weight: 900;
    margin-bottom: 20px;
    color: #ffffff; /* Explicitly set color */
    margin-top: 0;
}

.services-hero p {
    font-size: 1.25em;
    line-height: 1.6;
}

/* Para sa mobile */
@media (max-width: 768px) {
    .services-hero {
        background-attachment: scroll; /* Mas maganda sa mobile */
    }
    .services-hero h2 {
        font-size: 2.5em; 
    }
}

/* --- Services Grid Section --- */
.services-grid-section {
    padding: 100px 0;
    background-color: var(--background-gray);
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 40px;
}

.service-item {
    background: var(--background-white);
    padding: 40px 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0,0,0,0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-top: 4px solid var(--primary-red);
}

.service-item:hover {
    transform: translateY(-10px);
    box-shadow: 0 12px 35px rgba(0,0,0,0.1);
}

.service-icon {
    font-size: 3.5em;
    color: var(--primary-red);
    margin-bottom: 25px;
    transition: transform 0.3s ease;
}

.service-item:hover .service-icon {
    transform: scale(1.1) rotate(-5deg);
}

.service-item h3 {
    font-size: 1.6em;
    color: var(--text-dark);
    margin-bottom: 15px;
}

.service-item p {
    color: var(--text-gray);
    line-height: 1.7;
}

/* Responsive for Services Grid */
@media (max-width: 768px) {
    .services-grid-section {
        padding: 80px 0;
    }
    .services-grid {
        grid-template-columns: 1fr;
    }
}

/* Testing Methods Grid */
.testing-methods {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 50px;
}

.method-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-top: 4px solid var(--primary-red);
    padding: 30px 25px;
    text-align: center;
}

.method-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.12);
}

.method-icon {
    background: linear-gradient(135deg, var(--primary-red), #ff6b6b);
    color: white;
    font-size: 1.8em;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 25px;
    transition: transform 0.3s ease;
}

.method-card:hover .method-icon {
    transform: scale(1.1) rotate(5deg);
}

.method-content h3 {
    font-size: 1.5em;
    color: var(--text-dark);
    margin-bottom: 15px;
}

.method-content p {
    color: var(--text-gray);
    line-height: 1.7;
    margin-bottom: 0;
}

.tables-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 40px;
}

.table-wrapper {
    background: var(--background-white);
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.07);
    padding: 30px;
    overflow-x: auto; /* For responsiveness on small screens */
}

.table-wrapper h3 {
    font-size: 1.7em;
    color: var(--primary-red);
    margin-bottom: 20px;
}

.table-wrapper table {
    width: 100%;
    border-collapse: collapse;
}

.table-wrapper th, .table-wrapper td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.table-wrapper thead th {
    background-color: var(--background-gray);
    font-weight: 700;
    color: var(--text-dark);
}

.table-wrapper tbody tr:hover {
    background-color: #f9f9f9;
}

.table-wrapper td:first-child {
    font-weight: 500;
}

.table-wrapper td:last-child {
    font-family: 'Courier New', Courier, monospace;
}

/* Override: Ibalik sa default font ang tables sa "Other Services" section */
#other-services .table-wrapper td {
    font-family: var(--font-family);
}

/* --- Clickable Test Name Link --- */
.test-name-link {
    color: var(--text-dark); /* Ginawang itim ang text */
    font-weight: 700;
    text-decoration: none; /* Inalis ang default underline para sa custom border */
    border-bottom: 2px solid var(--primary-red); /* Nagdagdag ng pulang underline */
    padding-bottom: 2px; /* Nagdagdag ng kaunting espasyo */
    transition: color 0.2s ease;
}

.test-name-link:hover {
    color: var(--primary-red); /* Nagiging pula ang text kapag na-hover */
    cursor: pointer;
}

/* --- Enhanced Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px;
    box-sizing: border-box;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: #ffffff;
    border-radius: 8px;
    max-width: 700px;
    width: 100%;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.modal-header {
    background: linear-gradient(135deg, #C52328, #E53935);
    color: white;
    padding: 25px 30px;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.8em;
    font-weight: 700;
    color: white;
    position: relative;
    display: inline-block;
}

.modal-header h3::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 60px;
    height: 3px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 3px;
}

.modal-body {
    padding: 30px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-body p {
    color: #4a5568;
    line-height: 1.8;
    margin-bottom: 20px;
    font-size: 1.05em;
}

.modal-body p strong {
    color: #2d3748;
    font-weight: 600;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.test-meta {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    background: #f8f9fa;
    padding: 15px 20px;
    border-radius: 8px;
    border-left: 4px solid #C52328;
}

.test-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95em;
}

.test-meta-item i {
    color: #C52328;
    font-size: 1.2em;
}

.test-purpose {
    background: #f0f7ff;
    border-left: 4px solid #3182ce;
    padding: 15px 20px;
    border-radius: 8px;
    margin-top: 25px;
}

.test-purpose strong {
    color: #2c5282;
    display: block;
    margin-bottom: 8px;
    font-size: 1.1em;
}

/* Animation for modal content */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content {
    animation: modalFadeIn 0.3s ease-out forwards;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .modal-body {
        padding: 20px;
    }
    
    .modal-header {
        padding: 20px;
    }
    
    .test-meta {
        flex-direction: column;
        gap: 10px;
    }
}

.modal-header {
    background: linear-gradient(135deg, #C52328, #E53935);
    color: white;
    padding: 25px 30px;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.8em;
    font-weight: 700;
    color: white;
    position: relative;
    display: inline-block;
}

.modal-header h3::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 60px;
    height: 3px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 3px;
}

.modal-body {
    padding: 30px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-body p {
    color: #4a5568;
    line-height: 1.8;
    margin-bottom: 20px;
    font-size: 1.05em;
}

.modal-body p strong {
    color: #2d3748;
    font-weight: 600;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.test-meta {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    background: #f8f9fa;
    padding: 15px 20px;
    border-radius: 8px;
    border-left: 4px solid #C52328;
}

.test-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95em;
}

.test-meta-item i {
    color: #C52328;
    font-size: 1.2em;
}

.test-purpose {
    background: #f0f7ff;
    border-left: 4px solid #3182ce;
    padding: 15px 20px;
    border-radius: 8px;
    margin-top: 25px;
}

.test-purpose strong {
    color: #2c5282;
    display: block;
    margin-bottom: 8px;
    font-size: 1.1em;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .modal-body {
        padding: 20px;
    }
    
    .modal-header {
        padding: 20px;
    }
    
    .test-meta {
        flex-direction: column;
        gap: 10px;
    }
}

.table-wrapper thead th {
    background-color: var(--background-gray);
    font-weight: 700;
    color: var(--text-dark);
}

.table-wrapper tbody tr:hover {
    background-color: #f9f9f9;
}

.table-wrapper td:first-child {
    font-weight: 500;
}

/* Override: Ibalik sa default font ang tables sa "Other Services" section */
#other-services .table-wrapper td {
    font-family: var(--font-family);
}

.table-wrapper tbody tr {
    background-color: #ffffff; /* White background for all rows */
}

.table-wrapper tbody tr:nth-child(even) {
    background-color: #F5F5F5; /* Alternating light gray for even rows */
}

/* Add space before the very first service block to separate it from the hero section */
.service-block:first-of-type {
    margin-top: 80px; /* Nagdagdag ng espasyo sa pagitan ng hero at unang service block */
}

.service-block-header {
    position: relative;
    padding: 120px 0;
    text-align: center;
    background-color: #2c3e50; /* Fallback color */
    color: #fff; /* White text */
    background-size: cover;
    background-position: center;
    background-attachment: scroll; /* Changed from fixed to prevent covering other pages */
}

/* Default overlay for all service blocks */
.service-block-header .header-overlay {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Remove overlay for specific sections */
#aggregate-testing .service-block-header .header-overlay,
#concrete-testing .service-block-header .header-overlay,
#other-services .service-block-header .header-overlay {
    background-color: transparent;
}

/* Keep overlay for soil & composite section */
#soil-composite-header .service-block-header .header-overlay {
    background-color: rgba(44, 62, 80, 0.75); /* Dark blue overlay */
}

.service-block-header .header-content {
    position: relative;
    z-index: 2;
}

/* --- Background Images for Each Service Block --- */
.service-block-header {
    position: relative;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    padding: 100px 20px;
    text-align: center;
}

.service-block-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.3) 0%,
        rgba(0, 0, 0, 0.5) 100%
    );
    z-index: 1;
}

.service-block-header > * {
    position: relative;
    z-index: 2;
}

/* Aggregate Testing */
#aggregate-testing .service-block-header {
    background-image: url('../IMAGES/servicepic.img/Agregate.jpg');
}

/* Concrete Testing */
#concrete-testing .service-block-header {
    background-image: url('../IMAGES/servicepic.img/Concrete.jpg');
}

/* Soil & Composite Testing */
#soil-composite-header .service-block-header {
    background-image: url('../IMAGES/servicepic.img/Soil.jpg');
}

/* Other Testing Services */
#other-services .service-block-header {
    background-image: url('../IMAGES/servicepic.img/Composite.jpg');
}

.service-block-header h1 {
    font-size: 3.2em;
    color: #fff;
    margin-bottom: 20px;
    font-weight: 900;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.8), 
                 0 0 10px rgba(0, 0, 0, 0.5);
    position: relative;
    padding: 15px 30px;
    letter-spacing: 0.5px;
    line-height: 1.3;
}

.service-block-header p {
    max-width: 800px;
    margin: 15px auto 0;
    font-size: 1.2em;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 1px 1px 6px rgba(0, 0, 0, 0.9);
    padding: 12px 25px;
    position: relative;
    line-height: 1.6;
    font-weight: 400;
}

/* Responsive for Parallax */
@media (max-width: 768px) {
    .service-block-header h1 {
        font-size: 2.5em;
    }
    .service-block-header { background-attachment: scroll; } /* Disable parallax on mobile */
}

/* --- Dual Column Header for Soil & Composite --- */
.dual-column-header .container.header-content {
    max-width: none; /* Aalisin ang max-width para mag-full-width */
    padding-left: 5vw; /* Gumamit ng viewport width para sa responsive na padding */
    padding-right: 5vw;
}

.dual-column-header .header-content {
    display: flex;
    gap: 40px;
    text-align: left;
}

/* Divider line for dual column header */
.dual-column-header .header-content::after {
    content: '';
    position: absolute;
    top: 10%; /* Start below the top edge */
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 80%; /* Adjust height */
    background-color: rgba(255, 255, 255, 0.2); /* Faded white line */
}

.header-column {
    flex: 1;
    min-width: 0;
}

.dual-column-header h1 {
    font-size: 2.5em; /* Slightly smaller to fit */
}

.dual-column-header p {
    max-width: 100%; /* Override max-width for single column headers */
}

/* Responsive for dual column header */
@media (max-width: 992px) {
    .dual-column-header .header-content {
        flex-direction: column;
        gap: 30px;
        text-align: center;
    }

    /* Hide the divider line on smaller screens */
    .dual-column-header .header-content::after {
        display: none;
    }

    .dual-column-header h1 {
        font-size: 2.2em;
    }
}

/* --- Collapsible Section Styles --- */
.collapsible-trigger {
    cursor: pointer;
    position: relative;
    transition: background-color 0.3s ease;
}

.collapsible-trigger:hover {
    background-color: #3a4b5c; /* Slightly lighter on hover */
}

.collapsible-trigger .fa-chevron-down {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
    font-size: 1.5em;
    color: rgba(255, 255, 255, 0.7);
    transition: transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.collapsible-trigger.active .fa-chevron-down {
    transform: translateY(-50%) rotate(180deg);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-out;
    background-color: var(--background-gray);
}

/* Adjust padding for content inside collapsible */
.collapsible-content .tables-container {
    padding: 80px 20px;
}

/* Remove default padding from service-block-content when it's collapsible */
.service-block-content {
    padding: 0;
}

/* Responsive for chevron */
@media (max-width: 768px) {
    .collapsible-trigger .fa-chevron-down {
        font-size: 1.2em;
        right: 20px;
    }
}

/* --- Test Section Images --- */
.test-section-image {
    width: 100%;
    max-width: 500px;
    height: 250px;
    object-fit: cover;
    border-radius: 8px;
    margin: 0 auto 30px auto; /* Inayos ang margin para sa espasyo sa ibaba */
    display: block;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.test-section-image:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.table-wrapper {
    position: relative;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .test-section-image {
        height: 200px;
        margin: 15px auto;
    }
}

/* --- Footer Logo Text Color --- */
.main-footer .logo-text {
    color: var(--primary-red); /* Pinalitan pabalik sa pula para sa consistency */
}

/* --- Alternating Section Backgrounds for Better Separation --- */
/* This will apply a light gray background to every other service block */
.service-block:nth-of-type(even) {
    background-color: #f8f9fa; /* A very light gray color */
}

.service-block:nth-of-type(even) .collapsible-content {
    background-color: #ffffff; /* Make the content white to contrast */
}

/* --- New Text Reveal Animation on Scroll --- */
.text-reveal-mask {
    display: block; /* Use block to ensure it takes full width for centering */
    overflow: hidden;
    line-height: 1.2; /* Adjust line-height to prevent clipping */
}

.animate-text-reveal {
    display: inline-block; /* Allows transform to work correctly */
    transform: translateY(110%);
    transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Triggered by home.js when the element is visible */
.fade-in-on-scroll.is-visible .animate-text-reveal {
    transform: translateY(0);
}
